Expand description
Maybe a misnomer, but like a PolyLine, but closed.
Fields
pts: Vec<Pt2D>
Implementations
sourceimpl Ring
impl Ring
pub fn new(pts: Vec<Pt2D>) -> Result<Ring>
pub fn must_new(pts: Vec<Pt2D>) -> Ring
sourcepub fn deduping_new(pts: Vec<Pt2D>) -> Result<Self>
pub fn deduping_new(pts: Vec<Pt2D>) -> Result<Self>
First dedupes adjacent points
sourcepub fn to_outline(&self, thickness: Distance) -> Polygon
pub fn to_outline(&self, thickness: Distance) -> Polygon
Draws the ring with some thickness, with half of it straddling the interor of the ring, and half on the outside.
pub fn into_polygon(self) -> Polygon
pub fn points(&self) -> &Vec<Pt2D>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn into_points(self) -> Vec<Pt2D>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn all_intersections(&self, other: &PolyLine) -> Vec<Pt2D>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn all_intersections(&self, other: &PolyLine) -> Vec<Pt2D>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Be careful with the order of results. Hits on an earlier line segment of other show up first, but if the ring hits a line segment at multiple points, who knows. Dedupes.
pub(crate) fn get_both_slices_btwn(
&self,
pt1: Pt2D,
pt2: Pt2D
) -> Option<(PolyLine, PolyLine)>
sourcepub fn get_slice_between(
&self,
pt1: Pt2D,
pt2: Pt2D,
longer: bool
) -> Option<PolyLine>
pub fn get_slice_between(
&self,
pt1: Pt2D,
pt2: Pt2D,
longer: bool
) -> Option<PolyLine>
Assuming both points are somewhere along the ring, return the points in between the two, by
tracing along the ring in the longer or shorter direction (depending on longer
). If both
points are the same, returns None
. The result is oriented from pt1
to pt2
.
sourcepub fn get_shorter_slice_between(
&self,
pt1: Pt2D,
pt2: Pt2D
) -> Option<PolyLine>
pub fn get_shorter_slice_between(
&self,
pt1: Pt2D,
pt2: Pt2D
) -> Option<PolyLine>
Assuming both points are somewhere along the ring, return the points in between the two, by
tracing along the ring in the shorter direction. If both points are the same, returns
None
. The result is oriented from pt1
to pt2
.
pub fn get_shorter_slice_btwn(&self, pt1: Pt2D, pt2: Pt2D) -> Option<PolyLine>
sourcepub fn split_points(pts: &[Pt2D]) -> Result<(Vec<PolyLine>, Vec<Ring>)>
pub fn split_points(pts: &[Pt2D]) -> Result<(Vec<PolyLine>, Vec<Ring>)>
Extract all PolyLines and Rings. Doesn’t handle crazy double loops and stuff.
pub fn contains_pt(&self, pt: Pt2D) -> bool
sourcepub fn to_geojson(&self, gps: Option<&GPSBounds>) -> Geometry
pub fn to_geojson(&self, gps: Option<&GPSBounds>) -> Geometry
Produces a GeoJSON polygon, optionally mapping the world-space points back to GPS.
sourcepub fn polylabel(&self) -> Pt2D
pub fn polylabel(&self) -> Pt2D
Find the “pole of inaccessibility” – the most distant internal point from the polygon outline
sourcepub fn doubles_back(&self) -> bool
pub fn doubles_back(&self) -> bool
Look for “bad” rings that double back on themselves. These’re likely to cause many downstream problems. “Bad” means the order of points doesn’t match the order when sorting by angle from the center.
TODO I spot many false positives. Look for better definitions – maybe self-intersecting polygons?
sourcepub fn as_geo_linestring(&self) -> String
pub fn as_geo_linestring(&self) -> String
Print the coordinates of this ring as a geo::LineString
for easy bug reports
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Ring
impl<'de> Deserialize<'de> for Ring
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Ring
Auto Trait Implementations
impl RefUnwindSafe for Ring
impl Send for Ring
impl Sync for Ring
impl Unpin for Ring
impl UnwindSafe for Ring
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more