Struct geom::polygon::Polygon [−][src]
Fields
points: Vec<Pt2D>
indices: Vec<u16>
Groups of three indices make up the triangles
rings: Option<Vec<Ring>>
If the polygon has holes, explicitly store all the rings (the one outer and all of the inner) so they can later be used to generate outlines and such. If the polygon has no holes, then this will just be None, since the points form a ring.
Implementations
impl Polygon
[src]
pub fn buggy_new(orig_pts: Vec<Pt2D>) -> Polygon
[src]
pub fn with_holes(outer: Ring, inner: Vec<Ring>) -> Polygon
[src]
pub fn from_rings(rings: Vec<Ring>) -> Polygon
[src]
pub fn from_geojson(raw: &[Vec<Vec<f64>>]) -> Result<Polygon>
[src]
pub fn precomputed(points: Vec<Pt2D>, indices: Vec<usize>) -> Polygon
[src]
pub fn from_triangle(tri: &Triangle) -> Polygon
[src]
pub fn triangles(&self) -> Vec<Triangle>
[src]
pub fn raw_for_rendering(&self) -> (&Vec<Pt2D>, &Vec<u16>)
[src]
pub fn contains_pt(&self, pt: Pt2D) -> bool
[src]
Does this polygon contain the point either in the interior or right on the border? Haven’t tested carefully for polygons with holes.
pub fn get_bounds(&self) -> Bounds
[src]
fn transform<F: Fn(&Pt2D) -> Pt2D>(&self, f: F) -> Polygon
[src]
pub fn translate(&self, dx: f64, dy: f64) -> Polygon
[src]
pub fn scale(&self, factor: f64) -> Polygon
[src]
pub fn scale_xy(&self, x_factor: f64, y_factor: f64) -> Polygon
[src]
pub fn rotate(&self, angle: Angle) -> Polygon
[src]
pub fn rotate_around(&self, angle: Angle, pivot: Pt2D) -> Polygon
[src]
pub fn points(&self) -> &Vec<Pt2D>
[src]
The order of these points depends on the constructor! The first and last point may or may not match. Polygons constructed from PolyLines will have a very weird order.
pub fn into_points(self) -> Vec<Pt2D>
[src]
pub fn into_ring(self) -> Ring
[src]
pub fn center(&self) -> Pt2D
[src]
pub fn rectangle(width: f64, height: f64) -> Polygon
[src]
Top-left at the origin. Doesn’t take Distance, because this is usually pixels, actually.
pub fn rectangle_centered(
center: Pt2D,
width: Distance,
height: Distance
) -> Polygon
[src]
center: Pt2D,
width: Distance,
height: Distance
) -> Polygon
pub fn rectangle_two_corners(pt1: Pt2D, pt2: Pt2D) -> Option<Polygon>
[src]
pub fn maybe_rounded_rectangle<R: Into<CornerRadii>>(
w: f64,
h: f64,
r: R
) -> Option<Polygon>
[src]
w: f64,
h: f64,
r: R
) -> Option<Polygon>
Top-left at the origin. Doesn’t take Distance, because this is usually pixels, actually.
pub fn pill(w: f64, h: f64) -> Polygon
[src]
A rectangle, two sides of which are fully rounded half-circles.
pub fn rounded_rectangle<R: Into<CornerRadii>>(w: f64, h: f64, r: R) -> Polygon
[src]
Top-left at the origin. Doesn’t take Distance, because this is usually pixels, actually. If it’s not possible to apply the specified radius, fallback to a regular rectangle.
pub fn union(self, other: Polygon) -> Polygon
[src]
pub fn union_all(list: Vec<Polygon>) -> Polygon
[src]
pub fn intersection(&self, other: &Polygon) -> Vec<Polygon>
[src]
pub fn convex_hull(list: Vec<Polygon>) -> Polygon
[src]
pub fn concave_hull(list: Vec<Polygon>, concavity: f64) -> Polygon
[src]
pub fn polylabel(&self) -> Pt2D
[src]
pub fn intersects(&self, other: &Polygon) -> bool
[src]
Do two polygons intersect at all?
pub fn intersects_polyline(&self, pl: &PolyLine) -> bool
[src]
Does this polygon intersect a polyline?
pub fn to_outline(&self, thickness: Distance) -> Result<Polygon>
[src]
Creates the outline around the polygon, with the thickness half straddling the polygon and half of it just outside. Only works for polygons that’re formed from rings. Those made from PolyLines won’t work, for example.
pub fn strip_rings(&self) -> Polygon
[src]
Remove the internal rings used for to_outline. This is fine to do if the polygon is being added to some larger piece of geometry that won’t need an outline.
pub fn area(&self) -> f64
[src]
Usually m^2, unless the polygon is in screen-space
pub fn clip_polyline(&self, input: &PolyLine) -> Option<Vec<Pt2D>>
[src]
Doesn’t handle multiple crossings in and out.
pub fn clip_ring(&self, input: &Ring) -> Option<Vec<Pt2D>>
[src]
pub fn to_geojson(&self, gps: Option<&GPSBounds>) -> Geometry
[src]
If the polygon is just a single outer ring, produces a GeoJSON polygon. Otherwise, produces a GeoJSON multipolygon consisting of individual triangles. Optionally map the world-space points back to GPS.
pub fn from_geojson_bytes(
raw_bytes: &[u8],
gps_bounds: &GPSBounds,
require_in_bounds: bool
) -> Result<Vec<(Polygon, Tags)>>
[src]
raw_bytes: &[u8],
gps_bounds: &GPSBounds,
require_in_bounds: bool
) -> Result<Vec<(Polygon, Tags)>>
Extracts all polygons from raw bytes representing a GeoJSON file, along with the string
key/value properties. Only the first polygon from multipolygons is returned. If
require_in_bounds
is set, then the polygon must completely fit within the gps_bounds
.
Trait Implementations
impl Clone for Polygon
[src]
impl Debug for Polygon
[src]
impl<'de> Deserialize<'de> for Polygon
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for Polygon
[src]
impl From<Polygon<f64>> for Polygon
[src]
impl From<Polygon> for Polygon<f64>
[src]
impl PartialEq<Polygon> for Polygon
[src]
impl Serialize for Polygon
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Polygon
[src]
Auto Trait Implementations
impl RefUnwindSafe for Polygon
impl Send for Polygon
impl Sync for Polygon
impl Unpin for Polygon
impl UnwindSafe for Polygon
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,