Struct geo::LineString
source · [−]pub struct LineString<T>(pub Vec<Coordinate<T>, Global>)
where
T: CoordNum;
Expand description
An ordered collection of two or more Coordinate
s, representing a
path between locations.
Semantics
- A
LineString
is closed if it is empty, or if the first and last coordinates are the same. - The boundary of a
LineString
is 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
LineString
is 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
LineString
is aLinearRing
as 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 LineString
s.
Examples
Creation
Create a LineString
by calling it directly:
use geo_types::{Coordinate, LineString};
let line_string = LineString(vec![
Coordinate { x: 0., y: 0. },
Coordinate { 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<f64> = vec![[0., 0.], [10., 0.]].into();
Or by collect
ing from a Coordinate
iterator
use geo_types::{Coordinate, LineString};
let mut coords_iter =
vec![Coordinate { x: 0., y: 0. }, Coordinate { 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::{Coordinate, LineString};
let line_string = LineString(vec![
Coordinate { x: 0., y: 0. },
Coordinate { 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 Coordinate
s when looping:
use geo_types::{Coordinate, LineString};
let line_string = LineString(vec![
Coordinate { x: 0., y: 0. },
Coordinate { 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 Coordinate
s or Point
s:
use geo_types::{Coordinate, LineString, Point};
let line_string = LineString(vec![
Coordinate { x: 0., y: 0. },
Coordinate { x: 10., y: 0. },
]);
let coordinate_vec = line_string.clone().into_inner();
let point_vec = line_string.clone().into_points();
Tuple Fields
0: Vec<Coordinate<T>, Global>
Implementations
sourceimpl<T> LineString<T> where
T: CoordNum,
impl<T> LineString<T> where
T: CoordNum,
sourcepub fn points_iter(&self) -> PointsIter<'_, T>
👎 Deprecated: Use points() instead
pub fn points_iter(&self) -> PointsIter<'_, T>
Use points() instead
Return an iterator yielding the coordinates of a LineString
as Point
s
sourcepub fn points(&self) -> PointsIter<'_, T>
pub fn points(&self) -> PointsIter<'_, T>
Return an iterator yielding the coordinates of a LineString
as Point
s
sourcepub fn coords(&self) -> impl Iterator<Item = &Coordinate<T>>
pub fn coords(&self) -> impl Iterator<Item = &Coordinate<T>>
Return an iterator yielding the members of a LineString
as Coordinate
s
sourcepub fn coords_mut(&mut self) -> impl Iterator<Item = &mut Coordinate<T>>
pub fn coords_mut(&mut self) -> impl Iterator<Item = &mut Coordinate<T>>
Return an iterator yielding the coordinates of a LineString
as mutable Coordinate
s
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 Point
s
sourcepub fn into_inner(self) -> Vec<Coordinate<T>, Global>
pub fn into_inner(self) -> Vec<Coordinate<T>, Global>
Return the coordinates of a LineString
as a Vec
of Coordinate
s
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::{Coordinate, 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(
Coordinate { x: 0., y: 0. },
Coordinate { x: 5., y: 0. }
)),
lines.next()
);
assert_eq!(
Some(Line::new(
Coordinate { x: 5., y: 0. },
Coordinate { 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 Coordinate
, and
the value of the first Coordinate
does not equal the value of the last Coordinate
, then a
new Coordinate
is added to the end with the value of the first Coordinate
.
sourcepub fn num_coords(&self) -> usize
👎 Deprecated: Use geo::algorithm::coords_iter::CoordsIter::coords_count instead
pub fn num_coords(&self) -> usize
Use geo::algorithm::coords_iter::CoordsIter::coords_count instead
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 LineString
s used in
non-LinearRing
contexts.
Trait Implementations
sourceimpl<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,
sourcepub fn abs_diff_eq(
&self,
other: &LineString<T>,
epsilon: <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
) -> bool
pub 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)
type Epsilon = T
type Epsilon = T
Used for specifying relative comparisons.
sourcepub fn default_epsilon() -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
pub fn default_epsilon() -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of [AbsDiffEq::abs_diff_eq
].
sourceimpl<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
sourceimpl<T> BoundingRect<T> for LineString<T> where
T: CoordNum,
impl<T> BoundingRect<T> for LineString<T> where
T: CoordNum,
sourceimpl<T> Centroid for LineString<T> where
T: GeoFloat,
impl<T> Centroid for LineString<T> where
T: GeoFloat,
sourceimpl<T> ChaikinSmoothing<T> for LineString<T> where
T: CoordFloat + FromPrimitive,
impl<T> ChaikinSmoothing<T> for LineString<T> where
T: CoordFloat + FromPrimitive,
sourcefn chaikin_smoothing(&self, n_iterations: usize) -> Self
fn chaikin_smoothing(&self, n_iterations: usize) -> Self
create a new geometry with the Chaikin smoothing being
applied n_iterations
times. Read more
sourceimpl<T> Clone for LineString<T> where
T: Clone + CoordNum,
impl<T> Clone for LineString<T> where
T: Clone + CoordNum,
sourcepub fn clone(&self) -> LineString<T>
pub fn clone(&self) -> LineString<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for LineString<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for LineString<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<T> ConcaveHull for LineString<T> where
T: GeoFloat + RTreeNum,
impl<T> ConcaveHull for LineString<T> where
T: GeoFloat + RTreeNum,
sourceimpl<T> Contains<Coordinate<T>> for LineString<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for LineString<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Line<T>> for LineString<T> where
T: GeoNum,
impl<T> Contains<Line<T>> for LineString<T> where
T: GeoNum,
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<T> Contains<LineString<T>> for Polygon<T> where
T: GeoFloat,
impl<T> Contains<LineString<T>> for Polygon<T> where
T: GeoFloat,
fn contains(&self, linestring: &LineString<T>) -> bool
sourceimpl<T> Contains<Point<T>> for LineString<T> where
T: GeoNum,
impl<T> Contains<Point<T>> for LineString<T> where
T: GeoNum,
sourceimpl<T> ConvexHull for LineString<T> where
T: GeoNum,
impl<T> ConvexHull for LineString<T> where
T: GeoNum,
type Scalar = T
fn convex_hull(&self) -> Polygon<T>
sourceimpl<T> CoordinatePosition for LineString<T> where
T: GeoNum,
impl<T> CoordinatePosition for LineString<T> where
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
sourceimpl<'a, T: CoordNum + 'a> CoordsIter<'a> for LineString<T>
impl<'a, T: CoordNum + 'a> CoordsIter<'a> for LineString<T>
sourcefn coords_count(&'a self) -> usize
fn coords_count(&'a self) -> usize
Return the number of coordinates in the LineString
.
type Iter = Copied<Iter<'a, Coordinate<T>>>
type ExteriorIter = Self::Iter
type Scalar = T
sourcefn coords_iter(&'a self) -> Self::Iter
fn coords_iter(&'a self) -> Self::Iter
Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
sourcefn exterior_coords_iter(&'a self) -> Self::ExteriorIter
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
Iterate over all exterior coordinates of a geometry. Read more
sourceimpl<T> Debug for LineString<T> where
T: Debug + CoordNum,
impl<T> Debug for LineString<T> where
T: Debug + CoordNum,
sourceimpl<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
sourcefn euclidean_distance(&self, other: &Line<T>) -> T
fn euclidean_distance(&self, other: &Line<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, linestring: &LineString<T>) -> T
fn euclidean_distance(&self, linestring: &LineString<T>) -> T
Minimum distance from a Point to a LineString
sourceimpl<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
sourcefn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<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
sourcefn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<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
sourcefn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a LineString to a Point
sourceimpl<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
sourcefn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<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,
sourcefn euclidean_length(&self) -> T
fn euclidean_length(&self) -> T
Calculation of the length of a Line Read more
sourceimpl<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,
sourcefn frechet_distance(&self, ls: &LineString<T>) -> T
fn frechet_distance(&self, ls: &LineString<T>) -> T
Determine the similarity between two LineStrings
using the Frechet distance. Read more
sourceimpl<T> From<Line<T>> for LineString<T> where
T: CoordNum,
impl<T> From<Line<T>> for LineString<T> where
T: CoordNum,
sourcepub fn from(line: Line<T>) -> LineString<T>
pub fn from(line: Line<T>) -> LineString<T>
Performs the conversion.
sourceimpl<T> From<LineString<T>> for Geometry<T> where
T: CoordNum,
impl<T> From<LineString<T>> for Geometry<T> where
T: CoordNum,
sourcepub fn from(x: LineString<T>) -> Geometry<T>
pub fn from(x: LineString<T>) -> Geometry<T>
Performs the conversion.
sourceimpl<T, IC> From<Vec<IC, Global>> for LineString<T> where
T: CoordNum,
IC: Into<Coordinate<T>>,
impl<T, IC> From<Vec<IC, Global>> for LineString<T> where
T: CoordNum,
IC: Into<Coordinate<T>>,
Turn a Vec
of Point
-like objects into a LineString
.
sourcepub fn from(v: Vec<IC, Global>) -> LineString<T>
pub fn from(v: Vec<IC, Global>) -> LineString<T>
Performs the conversion.
sourceimpl<T, IC> FromIterator<IC> for LineString<T> where
T: CoordNum,
IC: Into<Coordinate<T>>,
impl<T, IC> FromIterator<IC> for LineString<T> where
T: CoordNum,
IC: Into<Coordinate<T>>,
Turn an iterator of Point
-like objects into a LineString
.
sourcepub fn from_iter<I>(iter: I) -> LineString<T> where
I: IntoIterator<Item = IC>,
pub fn from_iter<I>(iter: I) -> LineString<T> where
I: IntoIterator<Item = IC>,
Creates a value from an iterator. Read more
sourceimpl GeodesicLength<f64, LineString<f64>> for LineString<f64>
impl GeodesicLength<f64, LineString<f64>> for LineString<f64>
sourcefn geodesic_length(&self) -> f64
fn geodesic_length(&self) -> f64
Determine the length of a geometry on an ellipsoidal model of the earth. Read more
sourceimpl<C: CoordNum> HasDimensions for LineString<C>
impl<C: CoordNum> HasDimensions for LineString<C>
sourcefn boundary_dimensions(&self) -> Dimensions
fn boundary_dimensions(&self) -> Dimensions
use geo_types::line_string;
use geo::algorithm::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());
sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Some geometries, like a MultiPoint
, can have zero coordinates - we call these empty
. Read more
sourcefn dimensions(&self) -> Dimensions
fn dimensions(&self) -> Dimensions
The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However
for others, the dimensionality depends on the specific geometry instance - for example
typical Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read more
sourceimpl<T> Hash for LineString<T> where
T: Hash + CoordNum,
impl<T> Hash for LineString<T> where
T: Hash + CoordNum,
sourceimpl<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,
sourcefn haversine_length(&self) -> T
fn haversine_length(&self) -> T
Determine the length of a geometry using the haversine formula. Read more
sourceimpl<T> Index<usize> for LineString<T> where
T: CoordNum,
impl<T> Index<usize> for LineString<T> where
T: CoordNum,
type Output = Coordinate<T>
type Output = Coordinate<T>
The returned type after indexing.
sourcepub fn index(&self, index: usize) -> &Coordinate<T>
pub fn index(&self, index: usize) -> &Coordinate<T>
Performs the indexing (container[index]
) operation. Read more
sourceimpl<T> IndexMut<usize> for LineString<T> where
T: CoordNum,
impl<T> IndexMut<usize> for LineString<T> where
T: CoordNum,
sourcepub fn index_mut(&mut self, index: usize) -> &mut Coordinate<T>
pub fn index_mut(&mut self, index: usize) -> &mut Coordinate<T>
Performs the mutable indexing (container[index]
) operation. Read more
sourceimpl<T, G> Intersects<G> for LineString<T> where
T: CoordNum,
Line<T>: Intersects<G>,
impl<T, G> Intersects<G> for LineString<T> where
T: CoordNum,
Line<T>: Intersects<G>,
fn intersects(&self, geom: &G) -> bool
sourceimpl<T> Intersects<LineString<T>> for Coordinate<T> where
LineString<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Coordinate<T> where
LineString<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<'a, T> IntoIterator for &'a LineString<T> where
T: CoordNum,
impl<'a, T> IntoIterator for &'a LineString<T> where
T: CoordNum,
type Item = &'a Coordinate<T>
type Item = &'a Coordinate<T>
The type of the elements being iterated over.
type IntoIter = CoordinatesIter<'a, T>
type IntoIter = CoordinatesIter<'a, T>
Which kind of iterator are we turning this into?
sourcepub fn into_iter(self) -> <&'a LineString<T> as IntoIterator>::IntoIter
pub fn into_iter(self) -> <&'a LineString<T> as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
sourceimpl<'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
type Item = &'a mut Coordinate<T>
type Item = &'a mut Coordinate<T>
The type of the elements being iterated over.
type IntoIter = IterMut<'a, Coordinate<T>>
type IntoIter = IterMut<'a, Coordinate<T>>
Which kind of iterator are we turning this into?
sourcepub fn into_iter(self) -> IterMut<'a, Coordinate<T>>
pub fn into_iter(self) -> IterMut<'a, Coordinate<T>>
Creates an iterator from a value. Read more
sourceimpl<T> IntoIterator for LineString<T> where
T: CoordNum,
impl<T> IntoIterator for LineString<T> where
T: CoordNum,
Iterate over all the Coordinate
s in this LineString
.
type Item = Coordinate<T>
type Item = Coordinate<T>
The type of the elements being iterated over.
type IntoIter = IntoIter<Coordinate<T>, Global>
type IntoIter = IntoIter<Coordinate<T>, Global>
Which kind of iterator are we turning this into?
sourcepub fn into_iter(self) -> <LineString<T> as IntoIterator>::IntoIter
pub fn into_iter(self) -> <LineString<T> as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
sourceimpl<T: HasKernel> IsConvex for LineString<T>
impl<T: HasKernel> IsConvex for LineString<T>
sourcefn 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>
Test and get the orientation if the shape is convex.
Tests for strict convexity if allow_collinear
, and
only accepts a specific orientation if provided. Read more
sourcefn is_collinear(&self) -> bool
fn is_collinear(&self) -> bool
Test if the shape lies on a line.
sourcefn is_ccw_convex(&self) -> bool
fn is_ccw_convex(&self) -> bool
Test if the shape is convex, and oriented counter-clockwise. Read more
sourcefn is_cw_convex(&self) -> bool
fn is_cw_convex(&self) -> bool
Test if the shape is convex, and oriented clockwise.
sourcefn is_strictly_convex(&self) -> bool
fn is_strictly_convex(&self) -> bool
Test if the shape is strictly convex.
sourcefn is_strictly_ccw_convex(&self) -> bool
fn is_strictly_ccw_convex(&self) -> bool
Test if the shape is strictly convex, and oriented counter-clockwise. Read more
sourcefn is_strictly_cw_convex(&self) -> bool
fn is_strictly_cw_convex(&self) -> bool
Test if the shape is strictly convex, and oriented clockwise. Read more
sourceimpl<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>,
sourceimpl<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>,
sourceimpl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for LineString<T>
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for LineString<T>
sourceimpl<T: CoordNum> MapCoordsInplace<T> for LineString<T>
impl<T: CoordNum> MapCoordsInplace<T> for LineString<T>
sourceimpl<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,
sourcepub fn eq(&self, other: &LineString<T>) -> bool
pub fn eq(&self, other: &LineString<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcepub fn ne(&self, other: &LineString<T>) -> bool
pub fn ne(&self, other: &LineString<T>) -> bool
This method tests for !=
.
sourceimpl<T> PointDistance for LineString<T> where
T: Float + RTreeNum,
impl<T> PointDistance for LineString<T> where
T: Float + RTreeNum,
sourcepub fn distance_2(&self, point: &Point<T>) -> T
pub fn distance_2(&self, point: &Point<T>) -> T
Returns the squared euclidean distance of an object to a point.
sourcefn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
Returns true if a point is contained within this object. Read more
sourcefn 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>
Returns the squared distance to this object or None
if the distance
is larger than a given maximum value. Read more
sourceimpl<T> RTreeObject for LineString<T> where
T: Float + RTreeNum,
impl<T> RTreeObject for LineString<T> where
T: Float + RTreeNum,
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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
sourceimpl<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>,
sourcepub 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
pub 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)
sourcepub fn default_max_relative(
) -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
pub fn default_max_relative(
) -> <LineString<T> as AbsDiffEq<LineString<T>>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
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
The inverse of [RelativeEq::relative_eq
].
sourceimpl<T> Rotate<T> for LineString<T> where
T: GeoFloat,
impl<T> Rotate<T> for LineString<T> where
T: GeoFloat,
sourcefn rotate_around_centroid(&self, angle: T) -> Self
fn rotate_around_centroid(&self, angle: T) -> Self
Rotate the LineString about its centroid by the given number of degrees
sourcefn rotate_around_center(&self, angle: T) -> Self
fn rotate_around_center(&self, angle: T) -> Self
Rotate a geometry around the center of its bounding box by an angle, in degrees. Read more
sourceimpl<T> Simplify<T, T> for LineString<T> where
T: GeoFloat,
impl<T> Simplify<T, T> for LineString<T> where
T: GeoFloat,
sourcefn simplify(&self, epsilon: &T) -> Self
fn simplify(&self, epsilon: &T) -> Self
Returns the simplified representation of a geometry, using the Ramer–Douglas–Peucker algorithm Read more
sourceimpl<T> SimplifyIdx<T, T> for LineString<T> where
T: GeoFloat,
impl<T> SimplifyIdx<T, T> for LineString<T> where
T: GeoFloat,
sourcefn simplify_idx(&self, epsilon: &T) -> Vec<usize>
fn simplify_idx(&self, epsilon: &T) -> Vec<usize>
Returns the simplified indices of a geometry, using the Ramer–Douglas–Peucker algorithm Read more
sourceimpl<T> SimplifyVW<T, T> for LineString<T> where
T: CoordFloat,
impl<T> SimplifyVW<T, T> for LineString<T> where
T: CoordFloat,
sourcefn simplifyvw(&self, epsilon: &T) -> LineString<T>
fn simplifyvw(&self, epsilon: &T) -> LineString<T>
Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm Read more
sourceimpl<T> SimplifyVWPreserve<T, T> for LineString<T> where
T: CoordFloat + RTreeNum,
impl<T> SimplifyVWPreserve<T, T> for LineString<T> where
T: CoordFloat + RTreeNum,
sourcefn simplifyvw_preserve(&self, epsilon: &T) -> LineString<T>
fn simplifyvw_preserve(&self, epsilon: &T) -> LineString<T>
Returns the simplified representation of a geometry, using a topology-preserving variant of the Visvalingam-Whyatt algorithm. Read more
sourceimpl<T> SimplifyVwIdx<T, T> for LineString<T> where
T: CoordFloat,
impl<T> SimplifyVwIdx<T, T> for LineString<T> where
T: CoordFloat,
sourcefn simplifyvw_idx(&self, epsilon: &T) -> Vec<usize>
fn simplifyvw_idx(&self, epsilon: &T) -> Vec<usize>
Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm Read more
sourceimpl<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.
sourceimpl<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>
sourceimpl<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,
sourcefn vincenty_length(&self) -> Result<T, FailedToConvergeError>
fn vincenty_length(&self) -> Result<T, FailedToConvergeError>
Determine the length of a geometry using Vincenty’s formulae. Read more
sourceimpl<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>,
sourcefn points_cw(&self) -> Points<'_, Self::Scalar>ⓘNotable traits for Points<'a, T>impl<'a, T> Iterator for Points<'a, T> where
T: CoordNum, type Item = Point<T>;
fn points_cw(&self) -> Points<'_, Self::Scalar>ⓘNotable traits for Points<'a, T>impl<'a, T> Iterator for Points<'a, T> where
T: CoordNum, type Item = Point<T>;
T: CoordNum, type Item = Point<T>;
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
sourcefn points_ccw(&self) -> Points<'_, Self::Scalar>ⓘNotable traits for Points<'a, T>impl<'a, T> Iterator for Points<'a, T> where
T: CoordNum, type Item = Point<T>;
fn points_ccw(&self) -> Points<'_, Self::Scalar>ⓘNotable traits for Points<'a, T>impl<'a, T> Iterator for Points<'a, T> where
T: CoordNum, type Item = Point<T>;
T: CoordNum, type Item = Point<T>;
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
sourcefn make_cw_winding(&mut self)
fn make_cw_winding(&mut self)
Change this line’s points so they are in clockwise winding order
sourcefn 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
sourcefn winding_order(&self) -> Option<WindingOrder>
fn winding_order(&self) -> Option<WindingOrder>
Return the winding order of this object if it
contains at least three distinct coordinates, and
None
otherwise. Read more
sourcefn clone_to_winding_order(&self, winding_order: WindingOrder) -> Self where
Self: Sized + Clone,
fn clone_to_winding_order(&self, winding_order: WindingOrder) -> Self where
Self: Sized + Clone,
Return a clone of this object, but in the specified winding order
sourcefn make_winding_order(&mut self, winding_order: WindingOrder)
fn make_winding_order(&mut self, winding_order: WindingOrder)
Change the winding order so that it is in this winding order
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
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
sourceimpl<'a, T, G> Extremes<'a, T> for G where
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
impl<'a, T, G> Extremes<'a, T> for G where
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
sourceimpl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
impl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
sourcefn rotate_around_point(&self, angle: T, point: Point<T>) -> Self
fn rotate_around_point(&self, angle: T, point: Point<T>) -> Self
Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more
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
sourceimpl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
impl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
sourcefn translate(&self, xoff: T, yoff: T) -> Self
fn translate(&self, xoff: T, yoff: T) -> Self
Translate a Geometry along its axes by the given offsets Read more
sourcefn translate_inplace(&mut self, xoff: T, yoff: T)
fn translate_inplace(&mut self, xoff: T, yoff: T)
Translate a Geometry along its axes, but in place.