Struct geo::geometry::LineString
source · Expand description
An ordered collection of two or more Coords, representing a
path between locations.
Semantics
- A
LineStringis closed if it is empty, or if the first and last coordinates are the same. - The boundary of a
LineStringis either:- empty if it is closed (see 1) or
- contains the start and end coordinates.
- The interior is the (infinite) set of all coordinates along the
LineString, not including the boundary. - A
LineStringis simple if it does not intersect except optionally at the first and last coordinates (in which case it is also closed, see 1). - A simple and closed
LineStringis aLinearRingas defined in the OGC-SFA (but is not defined as a separate type in this crate).
Validity
A LineString is valid if it is either empty or
contains 2 or more coordinates.
Further, a closed LineString must not self-intersect. Note that its
validity is not enforced, and operations and
predicates are undefined on invalid LineStrings.
Examples
Creation
Create a LineString by calling it directly:
use geo_types::{coord, LineString};
let line_string = LineString::new(vec![
coord! { x: 0., y: 0. },
coord! { x: 10., y: 0. },
]);Create a LineString with the [line_string!] macro:
use geo_types::line_string;
let line_string = line_string![
(x: 0., y: 0.),
(x: 10., y: 0.),
];By converting from a Vec of coordinate-like things:
use geo_types::LineString;
let line_string: LineString<f32> = vec![(0., 0.), (10., 0.)].into();use geo_types::LineString;
let line_string: LineString = vec![[0., 0.], [10., 0.]].into();Or by collecting from a Coord iterator
use geo_types::{coord, LineString};
let mut coords_iter =
vec![coord! { x: 0., y: 0. }, coord! { x: 10., y: 0. }].into_iter();
let line_string: LineString<f32> = coords_iter.collect();Iteration
LineString provides five iterators: coords, coords_mut, points, lines, and triangles:
use geo_types::{coord, LineString};
let line_string = LineString::new(vec![
coord! { x: 0., y: 0. },
coord! { x: 10., y: 0. },
]);
line_string.coords().for_each(|coord| println!("{:?}", coord));
for point in line_string.points() {
println!("Point x = {}, y = {}", point.x(), point.y());
}Note that its IntoIterator impl yields Coords when looping:
use geo_types::{coord, LineString};
let line_string = LineString::new(vec![
coord! { x: 0., y: 0. },
coord! { x: 10., y: 0. },
]);
for coord in &line_string {
println!("Coordinate x = {}, y = {}", coord.x, coord.y);
}
for coord in line_string {
println!("Coordinate x = {}, y = {}", coord.x, coord.y);
}
Decomposition
You can decompose a LineString into a Vec of Coords or Points:
use geo_types::{coord, LineString, Point};
let line_string = LineString::new(vec![
coord! { x: 0., y: 0. },
coord! { x: 10., y: 0. },
]);
let coordinate_vec = line_string.clone().into_inner();
let point_vec = line_string.clone().into_points();
Tuple Fields§
§0: Vec<Coord<T>, Global>Implementations§
source§impl<T> LineString<T>where
T: CoordNum,
impl<T> LineString<T>where
T: CoordNum,
sourcepub fn new(value: Vec<Coord<T>, Global>) -> LineString<T>
pub fn new(value: Vec<Coord<T>, Global>) -> LineString<T>
Instantiate Self from the raw content value
sourcepub fn points_iter(&self) -> PointsIter<'_, T>
👎Deprecated: Use points() instead
pub fn points_iter(&self) -> PointsIter<'_, T>
Return an iterator yielding the coordinates of a LineString as Points
sourcepub fn points(&self) -> PointsIter<'_, T>
pub fn points(&self) -> PointsIter<'_, T>
Return an iterator yielding the coordinates of a LineString as Points
sourcepub fn coords(&self) -> impl Iterator<Item = &Coord<T>>
pub fn coords(&self) -> impl Iterator<Item = &Coord<T>>
Return an iterator yielding the members of a LineString as Coords
sourcepub fn coords_mut(&mut self) -> impl Iterator<Item = &mut Coord<T>>
pub fn coords_mut(&mut self) -> impl Iterator<Item = &mut Coord<T>>
Return an iterator yielding the coordinates of a LineString as mutable Coords
sourcepub fn into_points(self) -> Vec<Point<T>, Global>
pub fn into_points(self) -> Vec<Point<T>, Global>
Return the coordinates of a LineString as a Vec of Points
sourcepub fn into_inner(self) -> Vec<Coord<T>, Global>
pub fn into_inner(self) -> Vec<Coord<T>, Global>
Return the coordinates of a LineString as a Vec of Coords
sourcepub fn lines(&self) -> impl ExactSizeIterator + Iterator<Item = Line<T>>
pub fn lines(&self) -> impl ExactSizeIterator + Iterator<Item = Line<T>>
Return an iterator yielding one Line for each line segment
in the LineString.
Examples
use geo_types::{coord, Line, LineString};
let mut coords = vec![(0., 0.), (5., 0.), (7., 9.)];
let line_string: LineString<f32> = coords.into_iter().collect();
let mut lines = line_string.lines();
assert_eq!(
Some(Line::new(
coord! { x: 0., y: 0. },
coord! { x: 5., y: 0. }
)),
lines.next()
);
assert_eq!(
Some(Line::new(
coord! { x: 5., y: 0. },
coord! { x: 7., y: 9. }
)),
lines.next()
);
assert!(lines.next().is_none());sourcepub fn triangles(&self) -> impl ExactSizeIterator + Iterator<Item = Triangle<T>>
pub fn triangles(&self) -> impl ExactSizeIterator + Iterator<Item = Triangle<T>>
An iterator which yields the coordinates of a LineString as Triangles
sourcepub fn close(&mut self)
pub fn close(&mut self)
Close the LineString. Specifically, if the LineString has at least one Coord, and
the value of the first Coord does not equal the value of the last Coord, then a
new Coord is added to the end with the value of the first Coord.
sourcepub fn num_coords(&self) -> usize
👎Deprecated: Use geo::CoordsIter::coords_count instead
pub fn num_coords(&self) -> usize
Return the number of coordinates in the LineString.
Examples
use geo_types::LineString;
let mut coords = vec![(0., 0.), (5., 0.), (7., 9.)];
let line_string: LineString<f32> = coords.into_iter().collect();
assert_eq!(3, line_string.num_coords());sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Checks if the linestring is closed; i.e. it is either empty or, the first and last points are the same.
Examples
use geo_types::LineString;
let mut coords = vec![(0., 0.), (5., 0.), (0., 0.)];
let line_string: LineString<f32> = coords.into_iter().collect();
assert!(line_string.is_closed());Note that we diverge from some libraries (JTS et al), which have a LinearRing type,
separate from LineString. Those libraries treat an empty LinearRing as closed by
definition, while treating an empty LineString as open. Since we don’t have a separate
LinearRing type, and use a LineString in its place, we adopt the JTS LinearRing is_closed
behavior in all places: that is, we consider an empty LineString as closed.
This is expected when used in the context of a Polygon.exterior and elsewhere; And there
seems to be no reason to maintain the separate behavior for LineStrings used in
non-LinearRing contexts.
Trait Implementations§
source§impl<T> AbsDiffEq<LineString<T>> for LineString<T>where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
impl<T> AbsDiffEq<LineString<T>> for LineString<T>where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
source§fn abs_diff_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
) -> bool
Equality assertion with an absolute limit.
Examples
use geo_types::LineString;
let mut coords_a = vec![(0., 0.), (5., 0.), (7., 9.)];
let a: LineString<f32> = coords_a.into_iter().collect();
let mut coords_b = vec![(0., 0.), (5., 0.), (7.001, 9.)];
let b: LineString<f32> = coords_b.into_iter().collect();
approx::assert_relative_eq!(a, b, epsilon=0.1)source§fn default_epsilon() -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
fn default_epsilon() -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq.source§impl<T> Area<T> for LineString<T>where
T: CoordNum,
impl<T> Area<T> for LineString<T>where
T: CoordNum,
fn signed_area(&self) -> T
fn unsigned_area(&self) -> T
source§impl<T> BoundingRect<T> for LineString<T>where
T: CoordNum,
impl<T> BoundingRect<T> for LineString<T>where
T: CoordNum,
source§impl<T> Centroid for LineString<T>where
T: GeoFloat,
impl<T> Centroid for LineString<T>where
T: GeoFloat,
source§impl<T> ChaikinSmoothing<T> for LineString<T>where
T: CoordFloat + FromPrimitive,
impl<T> ChaikinSmoothing<T> for LineString<T>where
T: CoordFloat + FromPrimitive,
source§fn chaikin_smoothing(&self, n_iterations: usize) -> Self
fn chaikin_smoothing(&self, n_iterations: usize) -> Self
n_iterations times. Read moresource§impl<T> ChamberlainDuquetteArea<T> for LineString<T>where
T: CoordFloat,
impl<T> ChamberlainDuquetteArea<T> for LineString<T>where
T: CoordFloat,
fn chamberlain_duquette_signed_area(&self) -> T
fn chamberlain_duquette_unsigned_area(&self) -> T
source§impl<T> Clone for LineString<T>where
T: Clone + CoordNum,
impl<T> Clone for LineString<T>where
T: Clone + CoordNum,
source§fn clone(&self) -> LineString<T>
fn clone(&self) -> LineString<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<F: GeoFloat> ClosestPoint<F, Point<F>> for LineString<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for LineString<F>
source§fn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
self and p.source§impl<T> ConcaveHull for LineString<T>where
T: GeoFloat + RTreeNum,
impl<T> ConcaveHull for LineString<T>where
T: GeoFloat + RTreeNum,
source§impl<T> Contains<GeometryCollection<T>> for LineString<T>where
T: GeoFloat,
impl<T> Contains<GeometryCollection<T>> for LineString<T>where
T: GeoFloat,
fn contains(&self, target: &GeometryCollection<T>) -> bool
source§impl<F> Contains<LineString<F>> for MultiPolygon<F>where
F: GeoFloat,
impl<F> Contains<LineString<F>> for MultiPolygon<F>where
F: GeoFloat,
fn contains(&self, rhs: &LineString<F>) -> bool
source§impl<T> Contains<LineString<T>> for Geometry<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for Geometry<T>where
T: GeoFloat,
fn contains(&self, line_string: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for GeometryCollection<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for GeometryCollection<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for Line<T>where
T: GeoNum,
impl<T> Contains<LineString<T>> for Line<T>where
T: GeoNum,
fn contains(&self, linestring: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for LineString<T>where
T: GeoNum,
impl<T> Contains<LineString<T>> for LineString<T>where
T: GeoNum,
fn contains(&self, rhs: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for MultiLineString<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for MultiLineString<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for MultiPoint<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for MultiPoint<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for Point<T>where
T: CoordNum,
impl<T> Contains<LineString<T>> for Point<T>where
T: CoordNum,
fn contains(&self, line_string: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for Polygon<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for Polygon<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for Rect<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for Rect<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
source§impl<T> Contains<LineString<T>> for Triangle<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for Triangle<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
source§impl<T> Contains<MultiLineString<T>> for LineString<T>where
T: GeoFloat,
impl<T> Contains<MultiLineString<T>> for LineString<T>where
T: GeoFloat,
fn contains(&self, target: &MultiLineString<T>) -> bool
source§impl<T> Contains<MultiPoint<T>> for LineString<T>where
T: GeoFloat,
impl<T> Contains<MultiPoint<T>> for LineString<T>where
T: GeoFloat,
fn contains(&self, target: &MultiPoint<T>) -> bool
source§impl<T> Contains<MultiPolygon<T>> for LineString<T>where
T: GeoFloat,
impl<T> Contains<MultiPolygon<T>> for LineString<T>where
T: GeoFloat,
fn contains(&self, target: &MultiPolygon<T>) -> bool
source§impl<T> CoordinatePosition for LineString<T>where
T: GeoNum,
impl<T> CoordinatePosition for LineString<T>where
T: GeoNum,
source§impl<'a, T: CoordNum + 'a> CoordsIter<'a> for LineString<T>
impl<'a, T: CoordNum + 'a> CoordsIter<'a> for LineString<T>
source§fn coords_count(&'a self) -> usize
fn coords_count(&'a self) -> usize
Return the number of coordinates in the LineString.
type Iter = Copied<Iter<'a, Coord<T>>>
type ExteriorIter = <LineString<T> as CoordsIter<'a>>::Iter
type Scalar = T
source§fn coords_iter(&'a self) -> Self::Iter
fn coords_iter(&'a self) -> Self::Iter
source§fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
source§impl<T> Densify<T> for LineString<T>where
T: CoordFloat,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
impl<T> Densify<T> for LineString<T>where
T: CoordFloat,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
source§impl<'de, T> Deserialize<'de> for LineString<T>where
T: CoordNum + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for LineString<T>where
T: CoordNum + Deserialize<'de>,
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<LineString<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<LineString<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<T> EuclideanDistance<T, Line<T>> for LineString<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, Line<T>> for LineString<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
LineString to Line
source§fn euclidean_distance(&self, other: &Line<T>) -> T
fn euclidean_distance(&self, other: &Line<T>) -> T
source§impl<T> EuclideanDistance<T, LineString<T>> for Line<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, LineString<T>> for Line<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
Line to LineString
source§fn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
source§impl<T> EuclideanDistance<T, LineString<T>> for LineString<T>where
T: GeoFloat + Signed + RTreeNum,
impl<T> EuclideanDistance<T, LineString<T>> for LineString<T>where
T: GeoFloat + Signed + RTreeNum,
LineString-LineString distance
source§fn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
source§impl<T> EuclideanDistance<T, LineString<T>> for Point<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T, LineString<T>> for Point<T>where
T: GeoFloat,
source§fn euclidean_distance(&self, linestring: &LineString<T>) -> T
fn euclidean_distance(&self, linestring: &LineString<T>) -> T
Minimum distance from a Point to a LineString
source§impl<T> EuclideanDistance<T, LineString<T>> for Polygon<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, LineString<T>> for Polygon<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
Polygon to LineString distance
source§fn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
source§impl<T> EuclideanDistance<T, Point<T>> for LineString<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for LineString<T>where
T: GeoFloat,
source§fn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a LineString to a Point
source§impl<T> EuclideanDistance<T, Polygon<T>> for LineString<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, Polygon<T>> for LineString<T>where
T: GeoFloat + FloatConst + Signed + RTreeNum,
LineString to Polygon
source§fn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
source§impl<T> EuclideanLength<T, LineString<T>> for LineString<T>where
T: CoordFloat + Sum,
impl<T> EuclideanLength<T, LineString<T>> for LineString<T>where
T: CoordFloat + Sum,
source§fn euclidean_length(&self) -> T
fn euclidean_length(&self) -> T
source§impl<T> FrechetDistance<T, LineString<T>> for LineString<T>where
T: GeoFloat + FromPrimitive,
impl<T> FrechetDistance<T, LineString<T>> for LineString<T>where
T: GeoFloat + FromPrimitive,
source§fn frechet_distance(&self, ls: &LineString<T>) -> T
fn frechet_distance(&self, ls: &LineString<T>) -> T
source§impl<T> From<Line<T>> for LineString<T>where
T: CoordNum,
impl<T> From<Line<T>> for LineString<T>where
T: CoordNum,
source§fn from(line: Line<T>) -> LineString<T>
fn from(line: Line<T>) -> LineString<T>
source§impl<T> From<LineString<T>> for Geometry<T>where
T: CoordNum,
impl<T> From<LineString<T>> for Geometry<T>where
T: CoordNum,
source§fn from(x: LineString<T>) -> Geometry<T>
fn from(x: LineString<T>) -> Geometry<T>
source§impl<T, IC> From<Vec<IC, Global>> for LineString<T>where
T: CoordNum,
IC: Into<Coord<T>>,
impl<T, IC> From<Vec<IC, Global>> for LineString<T>where
T: CoordNum,
IC: Into<Coord<T>>,
Turn a Vec of Point-like objects into a LineString.
source§impl<T, IC> FromIterator<IC> for LineString<T>where
T: CoordNum,
IC: Into<Coord<T>>,
impl<T, IC> FromIterator<IC> for LineString<T>where
T: CoordNum,
IC: Into<Coord<T>>,
Turn an iterator of Point-like objects into a LineString.
source§fn from_iter<I>(iter: I) -> LineString<T>where
I: IntoIterator<Item = IC>,
fn from_iter<I>(iter: I) -> LineString<T>where
I: IntoIterator<Item = IC>,
source§impl GeodesicLength<f64, LineString<f64>> for LineString
impl GeodesicLength<f64, LineString<f64>> for LineString
source§fn geodesic_length(&self) -> f64
fn geodesic_length(&self) -> f64
source§impl<C: CoordNum> HasDimensions for LineString<C>
impl<C: CoordNum> HasDimensions for LineString<C>
source§fn boundary_dimensions(&self) -> Dimensions
fn boundary_dimensions(&self) -> Dimensions
use geo_types::line_string;
use geo::dimensions::{HasDimensions, Dimensions};
let ls = line_string![(x: 0., y: 0.), (x: 0., y: 1.), (x: 1., y: 1.)];
assert_eq!(Dimensions::ZeroDimensional, ls.boundary_dimensions());
let ls = line_string![(x: 0., y: 0.), (x: 0., y: 1.), (x: 1., y: 1.), (x: 0., y: 0.)];
assert_eq!(Dimensions::Empty, ls.boundary_dimensions());source§fn dimensions(&self) -> Dimensions
fn dimensions(&self) -> Dimensions
Rects are 2-dimensional, but it’s possible to create degenerate Rects which
have either 1 or 0 dimensions. Read moresource§impl<T> HaversineLength<T, LineString<T>> for LineString<T>where
T: CoordFloat + FromPrimitive,
impl<T> HaversineLength<T, LineString<T>> for LineString<T>where
T: CoordFloat + FromPrimitive,
source§fn haversine_length(&self) -> T
fn haversine_length(&self) -> T
source§impl<T> InteriorPoint for LineString<T>where
T: GeoFloat,
impl<T> InteriorPoint for LineString<T>where
T: GeoFloat,
source§impl<T, G> Intersects<G> for LineString<T>where
T: CoordNum,
Line<T>: Intersects<G>,
G: BoundingRect<T>,
impl<T, G> Intersects<G> for LineString<T>where
T: CoordNum,
Line<T>: Intersects<G>,
G: BoundingRect<T>,
fn intersects(&self, geom: &G) -> bool
source§impl<T> Intersects<LineString<T>> for Coord<T>where
LineString<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Coord<T>where
LineString<T>: Intersects<Coord<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
source§impl<T> Intersects<LineString<T>> for Line<T>where
LineString<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Line<T>where
LineString<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
source§impl<T> Intersects<LineString<T>> for Polygon<T>where
LineString<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Polygon<T>where
LineString<T>: Intersects<Polygon<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
source§impl<T> Intersects<LineString<T>> for Rect<T>where
LineString<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Rect<T>where
LineString<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
source§impl<'a, T> IntoIterator for &'a LineString<T>where
T: CoordNum,
impl<'a, T> IntoIterator for &'a LineString<T>where
T: CoordNum,
source§impl<'a, T> IntoIterator for &'a mut LineString<T>where
T: CoordNum,
impl<'a, T> IntoIterator for &'a mut LineString<T>where
T: CoordNum,
Mutably iterate over all the [Coordinate]s in this LineString
source§impl<T> IntoIterator for LineString<T>where
T: CoordNum,
impl<T> IntoIterator for LineString<T>where
T: CoordNum,
Iterate over all the Coords in this LineString.
source§impl<T: HasKernel> IsConvex for LineString<T>
impl<T: HasKernel> IsConvex for LineString<T>
source§fn convex_orientation(
&self,
allow_collinear: bool,
specific_orientation: Option<Orientation>
) -> Option<Orientation>
fn convex_orientation(
&self,
allow_collinear: bool,
specific_orientation: Option<Orientation>
) -> Option<Orientation>
allow_collinear, and
only accepts a specific orientation if provided. Read moresource§fn is_collinear(&self) -> bool
fn is_collinear(&self) -> bool
source§fn is_ccw_convex(&self) -> bool
fn is_ccw_convex(&self) -> bool
source§fn is_cw_convex(&self) -> bool
fn is_cw_convex(&self) -> bool
source§fn is_strictly_convex(&self) -> bool
fn is_strictly_convex(&self) -> bool
source§fn is_strictly_ccw_convex(&self) -> bool
fn is_strictly_ccw_convex(&self) -> bool
source§fn is_strictly_cw_convex(&self) -> bool
fn is_strictly_cw_convex(&self) -> bool
source§impl<T> LineInterpolatePoint<T> for LineString<T>where
T: CoordFloat + AddAssign + Debug,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
impl<T> LineInterpolatePoint<T> for LineString<T>where
T: CoordFloat + AddAssign + Debug,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
source§impl<T> LineLocatePoint<T, Point<T>> for LineString<T>where
T: CoordFloat + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
impl<T> LineLocatePoint<T, Point<T>> for LineString<T>where
T: CoordFloat + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
source§impl<'a, T: CoordNum + 'a> LinesIter<'a> for LineString<T>
impl<'a, T: CoordNum + 'a> LinesIter<'a> for LineString<T>
type Scalar = T
type Iter = LineStringIter<'a, <LineString<T> as LinesIter<'a>>::Scalar>
source§fn lines_iter(&'a self) -> Self::Iter
fn lines_iter(&'a self) -> Self::Iter
source§impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for LineString<T>
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for LineString<T>
source§impl<T: CoordNum> MapCoordsInPlace<T> for LineString<T>
impl<T: CoordNum> MapCoordsInPlace<T> for LineString<T>
source§impl<T: CoordNum> MapCoordsInplace<T> for LineString<T>
impl<T: CoordNum> MapCoordsInplace<T> for LineString<T>
source§fn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy)where
T: CoordNum,
👎Deprecated since 0.21.0: use MapCoordsInPlace::map_coords_in_place instead which takes a Coord instead of an (x,y) tuple
fn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy)where
T: CoordNum,
MapCoordsInPlace::map_coords_in_place instead which takes a Coord instead of an (x,y) tupleApply a function to all the coordinates in a geometric object, in place
Examples
#[allow(deprecated)]
use geo::MapCoordsInplace;
use geo::Point;
use approx::assert_relative_eq;
let mut p = Point::new(10., 20.);
#[allow(deprecated)]
p.map_coords_inplace(|(x, y)| (x + 1000., y * 2.));
assert_relative_eq!(p, Point::new(1010., 40.), epsilon = 1e-6);source§impl<T> PartialEq<LineString<T>> for LineString<T>where
T: PartialEq<T> + CoordNum,
impl<T> PartialEq<LineString<T>> for LineString<T>where
T: PartialEq<T> + CoordNum,
source§fn eq(&self, other: &LineString<T>) -> bool
fn eq(&self, other: &LineString<T>) -> bool
source§impl<T> PointDistance for LineString<T>where
T: Float + RTreeNum,
impl<T> PointDistance for LineString<T>where
T: Float + RTreeNum,
source§fn distance_2(&self, point: &Point<T>) -> T
fn distance_2(&self, point: &Point<T>) -> T
source§fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
true if a point is contained within this object. Read moresource§fn distance_2_if_less_or_equal(
&self,
point: &<Self::Envelope as Envelope>::Point,
max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>
fn distance_2_if_less_or_equal(
&self,
point: &<Self::Envelope as Envelope>::Point,
max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>
None if the distance
is larger than a given maximum value. Read moresource§impl<T> RTreeObject for LineString<T>where
T: Float + RTreeNum,
impl<T> RTreeObject for LineString<T>where
T: Float + RTreeNum,
source§impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for LineString<F>
fn relate(&self, other: &GeometryCollection<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, Line<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Line<F>> for LineString<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for GeometryCollection<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for GeometryCollection<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for Line<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Line<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for LineString<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for MultiLineString<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for MultiLineString<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for MultiPoint<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for MultiPoint<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for MultiPolygon<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for MultiPolygon<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for Point<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Point<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for Polygon<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Polygon<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Rect<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, LineString<F>> for Triangle<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Triangle<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, MultiLineString<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, MultiLineString<F>> for LineString<F>
fn relate(&self, other: &MultiLineString<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, MultiPoint<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, MultiPoint<F>> for LineString<F>
fn relate(&self, other: &MultiPoint<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for LineString<F>
fn relate(&self, other: &MultiPolygon<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, Point<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Point<F>> for LineString<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, Polygon<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Polygon<F>> for LineString<F>
fn relate(&self, other: &Polygon<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, Rect<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for LineString<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
source§impl<F: GeoFloat> Relate<F, Triangle<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Triangle<F>> for LineString<F>
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
source§impl<T> RelativeEq<LineString<T>> for LineString<T>where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<LineString<T>> for LineString<T>where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
source§fn relative_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon,
max_relative: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon,
max_relative: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
) -> bool
Equality assertion within a relative limit.
Examples
use geo_types::LineString;
let mut coords_a = vec![(0., 0.), (5., 0.), (7., 9.)];
let a: LineString<f32> = coords_a.into_iter().collect();
let mut coords_b = vec![(0., 0.), (5., 0.), (7.001, 9.)];
let b: LineString<f32> = coords_b.into_iter().collect();
approx::assert_relative_eq!(a, b, max_relative=0.1)source§fn default_max_relative(
) -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
fn default_max_relative(
) -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
RelativeEq::relative_eq.source§impl<T> RemoveRepeatedPoints<T> for LineString<T>where
T: CoordNum + FromPrimitive,
impl<T> RemoveRepeatedPoints<T> for LineString<T>where
T: CoordNum + FromPrimitive,
source§fn remove_repeated_points(&self) -> Self
fn remove_repeated_points(&self) -> Self
Create a LineString with consecutive repeated points removed.
source§fn remove_repeated_points_mut(&mut self)
fn remove_repeated_points_mut(&mut self)
Remove consecutive repeated points from a LineString inplace.
source§impl<T> Serialize for LineString<T>where
T: CoordNum + Serialize,
impl<T> Serialize for LineString<T>where
T: CoordNum + Serialize,
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl<T> Simplify<T, T> for LineString<T>where
T: GeoFloat,
impl<T> Simplify<T, T> for LineString<T>where
T: GeoFloat,
source§impl<T> SimplifyIdx<T, T> for LineString<T>where
T: GeoFloat,
impl<T> SimplifyIdx<T, T> for LineString<T>where
T: GeoFloat,
source§fn simplify_idx(&self, epsilon: &T) -> Vec<usize>
fn simplify_idx(&self, epsilon: &T) -> Vec<usize>
source§impl<T> SimplifyVW<T, T> for LineString<T>where
T: CoordFloat,
impl<T> SimplifyVW<T, T> for LineString<T>where
T: CoordFloat,
source§fn simplifyvw(&self, epsilon: &T) -> LineString<T>
fn simplifyvw(&self, epsilon: &T) -> LineString<T>
source§impl<T> SimplifyVWPreserve<T, T> for LineString<T>where
T: CoordFloat + RTreeNum + HasKernel,
impl<T> SimplifyVWPreserve<T, T> for LineString<T>where
T: CoordFloat + RTreeNum + HasKernel,
source§fn simplifyvw_preserve(&self, epsilon: &T) -> LineString<T>
fn simplifyvw_preserve(&self, epsilon: &T) -> LineString<T>
source§impl<T> SimplifyVwIdx<T, T> for LineString<T>where
T: CoordFloat,
impl<T> SimplifyVwIdx<T, T> for LineString<T>where
T: CoordFloat,
source§fn simplifyvw_idx(&self, epsilon: &T) -> Vec<usize>
fn simplifyvw_idx(&self, epsilon: &T) -> Vec<usize>
source§impl<T> TryFrom<Geometry<T>> for LineString<T>where
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for LineString<T>where
T: CoordNum,
Convert a Geometry enum into its inner type.
Fails if the enum case does not match the type you are trying to convert it to.
source§impl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for LineString<T>
impl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for LineString<T>
§type Output = LineString<NT>
type Output = LineString<NT>
MapCoords::try_map_coords which takes a Coord instead of an (x,y) tuplesource§fn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
fn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
MapCoords::try_map_coords which takes a Coord instead of an (x,y) tuplesource§impl<T: CoordNum, E> TryMapCoordsInplace<T, E> for LineString<T>
impl<T: CoordNum, E> TryMapCoordsInplace<T, E> for LineString<T>
source§fn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
fn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
MapCoordsInPlace::try_map_coords_in_place which takes a Coord instead of an (x,y) tupleResult. Read moresource§impl<T> VincentyLength<T, LineString<T>> for LineString<T>where
T: CoordFloat + FromPrimitive,
impl<T> VincentyLength<T, LineString<T>> for LineString<T>where
T: CoordFloat + FromPrimitive,
source§fn vincenty_length(&self) -> Result<T, FailedToConvergeError>
fn vincenty_length(&self) -> Result<T, FailedToConvergeError>
source§impl<T, K> Winding for LineString<T>where
T: HasKernel<Ker = K>,
K: Kernel<T>,
impl<T, K> Winding for LineString<T>where
T: HasKernel<Ker = K>,
K: Kernel<T>,
source§fn points_cw(&self) -> Points<'_, Self::Scalar> ⓘ
fn points_cw(&self) -> Points<'_, Self::Scalar> ⓘ
Iterate over the points in a clockwise order
The Linestring isn’t changed, and the points are returned either in order, or in reverse order, so that the resultant order makes it appear clockwise
source§fn points_ccw(&self) -> Points<'_, Self::Scalar> ⓘ
fn points_ccw(&self) -> Points<'_, Self::Scalar> ⓘ
Iterate over the points in a counter-clockwise order
The Linestring isn’t changed, and the points are returned either in order, or in reverse order, so that the resultant order makes it appear counter-clockwise
source§fn make_cw_winding(&mut self)
fn make_cw_winding(&mut self)
Change this line’s points so they are in clockwise winding order
source§fn make_ccw_winding(&mut self)
fn make_ccw_winding(&mut self)
Change this line’s points so they are in counterclockwise winding order
type Scalar = T
source§fn winding_order(&self) -> Option<WindingOrder>
fn winding_order(&self) -> Option<WindingOrder>
None otherwise. Read moresource§fn clone_to_winding_order(&self, winding_order: WindingOrder) -> Selfwhere
Self: Sized + Clone,
fn clone_to_winding_order(&self, winding_order: WindingOrder) -> Selfwhere
Self: Sized + Clone,
source§fn make_winding_order(&mut self, winding_order: WindingOrder)
fn make_winding_order(&mut self, winding_order: WindingOrder)
impl<T> Eq for LineString<T>where
T: Eq + CoordNum,
impl<T> StructuralEq for LineString<T>where
T: CoordNum,
impl<T> StructuralPartialEq for LineString<T>where
T: CoordNum,
Auto Trait Implementations§
impl<T> RefUnwindSafe for LineString<T>where
T: RefUnwindSafe,
impl<T> Send for LineString<T>where
T: Send,
impl<T> Sync for LineString<T>where
T: Sync,
impl<T> Unpin for LineString<T>where
T: Unpin,
impl<T> UnwindSafe for LineString<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T, M> AffineOps<T> for Mwhere
T: CoordNum,
M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,
impl<T, M> AffineOps<T> for Mwhere
T: CoordNum,
M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,
source§fn affine_transform(&self, transform: &AffineTransform<T>) -> M
fn affine_transform(&self, transform: &AffineTransform<T>) -> M
transform immutably, outputting a new geometry.source§fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)
fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)
transform to mutate self.source§impl<G, T, U> Convert<T, U> for Gwhere
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
impl<G, T, U> Convert<T, U> for Gwhere
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
source§impl<'a, T, G> ConvexHull<'a, T> for Gwhere
T: GeoNum,
G: CoordsIter<'a, Scalar = T>,
impl<'a, T, G> ConvexHull<'a, T> for Gwhere
T: GeoNum,
G: CoordsIter<'a, Scalar = T>,
source§impl<'a, T, G> Extremes<'a, T> for Gwhere
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
impl<'a, T, G> Extremes<'a, T> for Gwhere
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
source§impl<G, IP, IR, T> Rotate<T> for Gwhere
T: CoordFloat,
IP: Into<Option<Point<T>>>,
IR: Into<Option<Rect<T>>>,
G: Clone + Centroid<Output = IP> + BoundingRect<T, Output = IR> + AffineOps<T>,
impl<G, IP, IR, T> Rotate<T> for Gwhere
T: CoordFloat,
IP: Into<Option<Point<T>>>,
IR: Into<Option<Rect<T>>>,
G: Clone + Centroid<Output = IP> + BoundingRect<T, Output = IR> + AffineOps<T>,
source§fn rotate_around_centroid(&self, degrees: T) -> G
fn rotate_around_centroid(&self, degrees: T) -> G
source§fn rotate_around_centroid_mut(&mut self, degrees: T)
fn rotate_around_centroid_mut(&mut self, degrees: T)
Self::rotate_around_centroidsource§fn rotate_around_center(&self, degrees: T) -> G
fn rotate_around_center(&self, degrees: T) -> G
source§fn rotate_around_center_mut(&mut self, degrees: T)
fn rotate_around_center_mut(&mut self, degrees: T)
Self::rotate_around_centersource§fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G
fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G
source§fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)
fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)
Self::rotate_around_pointsource§impl<T, IR, G> Scale<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
impl<T, IR, G> Scale<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
source§fn scale(&self, scale_factor: T) -> G
fn scale(&self, scale_factor: T) -> G
source§fn scale_xy(&self, x_factor: T, y_factor: T) -> G
fn scale_xy(&self, x_factor: T, y_factor: T) -> G
x_factor and
y_factor to distort the geometry’s aspect ratio. Read moresource§fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)
fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)
scale_xy.source§fn scale_around_point(
&self,
x_factor: T,
y_factor: T,
origin: impl Into<Coord<T>>
) -> G
fn scale_around_point(
&self,
x_factor: T,
y_factor: T,
origin: impl Into<Coord<T>>
) -> G
origin. Read moresource§fn scale_around_point_mut(
&mut self,
x_factor: T,
y_factor: T,
origin: impl Into<Coord<T>>
)
fn scale_around_point_mut(
&mut self,
x_factor: T,
y_factor: T,
origin: impl Into<Coord<T>>
)
scale_around_point.source§impl<T, IR, G> Skew<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
impl<T, IR, G> Skew<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
source§fn skew(&self, degrees: T) -> G
fn skew(&self, degrees: T) -> G
source§fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G
fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G
source§fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)
fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)
skew_xy.source§fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G
fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G
origin, sheared by an
angle along the x and y dimensions. Read moresource§fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)
fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)
skew_around_point.