pub struct LineString<T = f64>(pub Vec<Coord<T>>)
where
T: CoordNum;Expand description
An ordered collection of Coords, representing a path between locations.
To be valid, a LineString must be empty, or have two or more coords.
§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>>Implementations§
Source§impl<T> LineString<T>where
T: CoordNum,
impl<T> LineString<T>where
T: CoordNum,
Sourcepub fn new(value: Vec<Coord<T>>) -> LineString<T>
pub fn new(value: Vec<Coord<T>>) -> LineString<T>
Returns a LineString with the given coordinates
Sourcepub fn empty() -> LineString<T>
pub fn empty() -> LineString<T>
Returns an empty LineString
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 DoubleEndedIterator
pub fn coords(&self) -> impl DoubleEndedIterator
Return an iterator yielding the members of a LineString as Coords
Sourcepub fn coords_mut(&mut self) -> impl DoubleEndedIterator
pub fn coords_mut(&mut self) -> impl DoubleEndedIterator
Return an iterator yielding the coordinates of a LineString as mutable Coords
Sourcepub fn into_points(self) -> Vec<Point<T>>
pub fn into_points(self) -> Vec<Point<T>>
Return the coordinates of a LineString as a Vec of Points
Sourcepub fn into_inner(self) -> Vec<Coord<T>>
pub fn into_inner(self) -> Vec<Coord<T>>
Return the coordinates of a LineString as a Vec of Coords
Sourcepub fn lines(&self) -> impl ExactSizeIterator
pub fn lines(&self) -> impl ExactSizeIterator
Return an iterator yielding one Line for each line segment
in the LineString.
§Examples
use geo_types::{wkt, Line, LineString};
let line_string = wkt!(LINESTRING(0 0,5 0,7 9));
let mut lines = line_string.lines();
assert_eq!(
Some(Line::new((0, 0), (5, 0))),
lines.next()
);
assert_eq!(
Some(Line::new((5, 0), (7, 9))),
lines.next()
);
assert!(lines.next().is_none());Sourcepub fn rev_lines(&self) -> impl ExactSizeIterator
pub fn rev_lines(&self) -> impl ExactSizeIterator
Return an iterator yielding one Line for each line segment in the LineString,
starting from the end point of the LineString, working towards the start.
Note: This is like Self::lines, but the sequence and the orientation of
segments are reversed.
§Examples
use geo_types::{wkt, Line, LineString};
let line_string = wkt!(LINESTRING(0 0,5 0,7 9));
let mut lines = line_string.rev_lines();
assert_eq!(
Some(Line::new((7, 9), (5, 0))),
lines.next()
);
assert_eq!(
Some(Line::new((5, 0), (0, 0))),
lines.next()
);
assert!(lines.next().is_none());Sourcepub fn triangles(&self) -> impl ExactSizeIterator
pub fn triangles(&self) -> impl ExactSizeIterator
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 for LineString<T>
impl<T> AbsDiffEq for LineString<T>
Source§fn abs_diff_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &LineString<T>, epsilon: <LineString<T> as AbsDiffEq>::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>::Epsilon
fn default_epsilon() -> <LineString<T> as AbsDiffEq>::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§fn centroid(&self) -> Self::Output
fn centroid(&self) -> Self::Output
§Examples
use geo::Centroid;
use geo::{line_string, point};
let line_string = line_string![
(x: 1.0f32, y: 1.0),
(x: 2.0, y: 2.0),
(x: 4.0, y: 4.0)
];
assert_eq!(
// (1.0 * (1.5, 1.5) + 2.0 * (3.0, 3.0)) / 3.0
Some(point!(x: 2.5, y: 2.5)),
line_string.centroid(),
);type Output = Option<Point<T>>
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.Source§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>
impl<T> Clone for LineString<T>
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> for LineString<F>
impl<F: GeoFloat> ClosestPoint<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>
impl<T> ConcaveHull for LineString<T>
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 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> Contains for LineString<T>where
T: GeoNum,
impl<T> Contains for LineString<T>where
T: GeoNum,
fn contains(&self, rhs: &LineString<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> Debug for LineString<T>where
T: CoordNum,
impl<T> Debug for LineString<T>where
T: CoordNum,
Source§impl<T> Densify<T> for LineString<T>
impl<T> Densify<T> for LineString<T>
Source§impl<T> EuclideanDistance<T> for LineString<T>
LineString-LineString distance
impl<T> EuclideanDistance<T> for LineString<T>
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, Line<T>> for LineString<T>
LineString to Line
impl<T> EuclideanDistance<T, Line<T>> for LineString<T>
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>
Line to LineString
impl<T> EuclideanDistance<T, LineString<T>> for Line<T>
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 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>
Polygon to LineString distance
impl<T> EuclideanDistance<T, LineString<T>> for Polygon<T>
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>
LineString to Polygon
impl<T> EuclideanDistance<T, Polygon<T>> for LineString<T>
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> for LineString<T>where
T: CoordFloat + Sum,
impl<T> EuclideanLength<T> for LineString<T>where
T: CoordFloat + Sum,
Source§fn euclidean_length(&self) -> T
fn euclidean_length(&self) -> T
Source§impl<T> FrechetDistance<T> for LineString<T>where
T: GeoFloat + FromPrimitive,
impl<T> FrechetDistance<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<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>> for LineString<T>
Turn a Vec of Point-like objects into a LineString.
impl<T, IC> From<Vec<IC>> for LineString<T>
Turn a Vec of Point-like objects into a LineString.
Source§fn from(v: Vec<IC>) -> LineString<T>
fn from(v: Vec<IC>) -> LineString<T>
Source§impl<T, IC> FromIterator<IC> for LineString<T>
Turn an iterator of Point-like objects into a LineString.
impl<T, IC> FromIterator<IC> for LineString<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 GeodesicArea<f64> for LineString
impl GeodesicArea<f64> for LineString
Source§fn geodesic_perimeter(&self) -> f64
fn geodesic_perimeter(&self) -> f64
Source§fn geodesic_area_signed(&self) -> f64
fn geodesic_area_signed(&self) -> f64
Source§fn geodesic_area_unsigned(&self) -> f64
fn geodesic_area_unsigned(&self) -> f64
Source§impl GeodesicLength<f64> for LineString
impl GeodesicLength<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> Hash for LineString<T>
impl<T> Hash for LineString<T>
Source§impl<T> HaversineLength<T> for LineString<T>where
T: CoordFloat + FromPrimitive,
impl<T> HaversineLength<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>
impl<T, G> Intersects<G> for LineString<T>
fn intersects(&self, geom: &G) -> bool
Source§impl<T> Intersects<LineString<T>> for Coord<T>
impl<T> Intersects<LineString<T>> for Coord<T>
fn intersects(&self, rhs: &LineString<T>) -> bool
Source§impl<T> Intersects<LineString<T>> for Line<T>
impl<T> Intersects<LineString<T>> for Line<T>
fn intersects(&self, rhs: &LineString<T>) -> bool
Source§impl<T> Intersects<LineString<T>> for Polygon<T>
impl<T> Intersects<LineString<T>> for Polygon<T>
fn intersects(&self, rhs: &LineString<T>) -> bool
Source§impl<T> Intersects<LineString<T>> for Rect<T>
impl<T> Intersects<LineString<T>> for Rect<T>
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,
Mutably iterate over all the Coords in this LineString
impl<'a, T> IntoIterator for &'a mut LineString<T>where
T: CoordNum,
Mutably iterate over all the Coords in this LineString
Source§impl<T> IntoIterator for LineString<T>where
T: CoordNum,
Iterate over all the Coords in this LineString.
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 for LineString<T>
impl<T> PartialEq for LineString<T>
Source§impl<T> PointDistance for LineString<T>
impl<T> PointDistance for LineString<T>
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>
impl<T> RTreeObject for LineString<T>
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 for LineString<T>where
T: CoordNum + RelativeEq<Epsilon = T>,
impl<T> RelativeEq for LineString<T>where
T: CoordNum + RelativeEq<Epsilon = T>,
Source§fn relative_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq>::Epsilon,
max_relative: <LineString<T> as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &LineString<T>, epsilon: <LineString<T> as AbsDiffEq>::Epsilon, max_relative: <LineString<T> as AbsDiffEq>::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>::Epsilon
fn default_max_relative() -> <LineString<T> as AbsDiffEq>::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> Simplify<T> for LineString<T>where
T: GeoFloat,
impl<T> Simplify<T> for LineString<T>where
T: GeoFloat,
Source§impl<T> SimplifyIdx<T> for LineString<T>where
T: GeoFloat,
impl<T> SimplifyIdx<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> for LineString<T>where
T: CoordFloat,
impl<T> SimplifyVw<T> for LineString<T>where
T: CoordFloat,
Source§fn simplify_vw(&self, epsilon: &T) -> LineString<T>
fn simplify_vw(&self, epsilon: &T) -> LineString<T>
Source§impl<T> SimplifyVwIdx<T> for LineString<T>where
T: CoordFloat,
impl<T> SimplifyVwIdx<T> for LineString<T>where
T: CoordFloat,
Source§fn simplify_vw_idx(&self, epsilon: &T) -> Vec<usize>
fn simplify_vw_idx(&self, epsilon: &T) -> Vec<usize>
Source§impl<T> SimplifyVwPreserve<T> for LineString<T>
impl<T> SimplifyVwPreserve<T> for LineString<T>
Source§fn simplify_vw_preserve(&self, epsilon: &T) -> LineString<T>
fn simplify_vw_preserve(&self, epsilon: &T) -> LineString<T>
Source§impl<T> TryFrom<Geometry<T>> for LineString<T>where
T: CoordNum,
Convert a Geometry enum into its inner type.
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>
Source§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> UlpsEq for LineString<T>
impl<T> UlpsEq for LineString<T>
Source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
Source§fn ulps_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq>::Epsilon,
max_ulps: u32,
) -> bool
fn ulps_eq( &self, other: &LineString<T>, epsilon: <LineString<T> as AbsDiffEq>::Epsilon, max_ulps: u32, ) -> bool
Source§impl<T> VincentyLength<T> for LineString<T>where
T: CoordFloat + FromPrimitive,
impl<T> VincentyLength<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>
impl<T, K> Winding for LineString<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.Source§fn clone_to_winding_order(&self, winding_order: WindingOrder) -> Self
fn clone_to_winding_order(&self, winding_order: WindingOrder) -> Self
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>
impl<T> StructuralPartialEq for LineString<T>where
T: CoordNum,
Auto Trait Implementations§
impl<T> Freeze for LineString<T>
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 M
impl<T, M> AffineOps<T> for 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<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<'a, T, G> MinimumRotatedRect<'a, T> for G
impl<'a, T, G> MinimumRotatedRect<'a, T> for G
type Scalar = T
fn minimum_rotated_rect( &'a self, ) -> Option<Polygon<<G as MinimumRotatedRect<'a, T>>::Scalar>>
Source§impl<G, IP, IR, T> Rotate<T> for G
impl<G, IP, IR, T> Rotate<T> for G
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.