Struct geo::geometry::LineString

source ·
pub struct LineString<T = f64>(pub Vec<Coord<T>>)
where
    T: CoordNum;
Expand description

An ordered collection of two or more Coords, representing a path between locations.

§Semantics

  1. A LineString is closed if it is empty, or if the first and last coordinates are the same.
  2. The boundary of a LineString is either:
    • empty if it is closed (see 1) or
    • contains the start and end coordinates.
  3. The interior is the (infinite) set of all coordinates along the LineString, not including the boundary.
  4. 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).
  5. A simple and closed LineString is a LinearRing 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 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,

source

pub fn new(value: Vec<Coord<T>>) -> LineString<T>

Instantiate Self from the raw content value

source

pub fn points_iter(&self) -> PointsIter<'_, T>

👎Deprecated: Use points() instead

Return an iterator yielding the coordinates of a LineString as Points

source

pub fn points(&self) -> PointsIter<'_, T>

Return an iterator yielding the coordinates of a LineString as Points

source

pub fn coords(&self) -> impl DoubleEndedIterator

Return an iterator yielding the members of a LineString as Coords

source

pub fn coords_mut(&mut self) -> impl DoubleEndedIterator

Return an iterator yielding the coordinates of a LineString as mutable Coords

source

pub fn into_points(self) -> Vec<Point<T>>

Return the coordinates of a LineString as a Vec of Points

source

pub fn into_inner(self) -> Vec<Coord<T>>

Return the coordinates of a LineString as a Vec of Coords

source

pub fn lines(&self) -> impl ExactSizeIterator

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());
source

pub fn triangles(&self) -> impl ExactSizeIterator

An iterator which yields the coordinates of a LineString as Triangles

source

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.

source

pub fn num_coords(&self) -> usize

👎Deprecated: Use geo::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());
source

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>
where T: AbsDiffEq<Epsilon = T> + CoordNum,

source§

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)
§

type Epsilon = T

Used for specifying relative comparisons.
source§

fn default_epsilon() -> <LineString<T> as AbsDiffEq>::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

The inverse of [AbsDiffEq::abs_diff_eq].
source§

impl<T> Area<T> for LineString<T>
where T: CoordNum,

source§

fn signed_area(&self) -> T

source§

fn unsigned_area(&self) -> T

source§

impl<T> BoundingRect<T> for LineString<T>
where T: CoordNum,

source§

fn bounding_rect(&self) -> Self::Output

Return the BoundingRect for a LineString

§

type Output = Option<Rect<T>>

source§

impl<T> Centroid for LineString<T>
where T: GeoFloat,

source§

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>

source§

fn chaikin_smoothing(&self, n_iterations: usize) -> Self

create a new geometry with the Chaikin smoothing being applied n_iterations times.
source§

impl<T> ChamberlainDuquetteArea<T> for LineString<T>
where T: CoordFloat,

source§

impl<T> Clone for LineString<T>
where T: Clone + CoordNum,

source§

fn clone(&self) -> LineString<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F: GeoFloat> ClosestPoint<F> for LineString<F>

source§

fn closest_point(&self, p: &Point<F>) -> Closest<F>

Find the closest point between self and p.
source§

impl<T> ConcaveHull for LineString<T>
where T: GeoFloat + RTreeNum,

§

type Scalar = T

source§

fn concave_hull(&self, concavity: Self::Scalar) -> Polygon<Self::Scalar>

source§

impl<T> Contains<Coord<T>> for LineString<T>
where T: GeoNum,

source§

fn contains(&self, coord: &Coord<T>) -> bool

source§

impl<T> Contains<Geometry<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, geometry: &Geometry<T>) -> bool

source§

impl<T> Contains<GeometryCollection<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &GeometryCollection<T>) -> bool

source§

impl<T> Contains<Line<T>> for LineString<T>
where T: GeoNum,

source§

fn contains(&self, line: &Line<T>) -> bool

source§

impl<F> Contains<LineString<F>> for MultiPolygon<F>
where F: GeoFloat,

source§

fn contains(&self, rhs: &LineString<F>) -> bool

source§

impl<T> Contains<LineString<T>> for Geometry<T>
where T: GeoFloat,

source§

fn contains(&self, line_string: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for GeometryCollection<T>
where T: GeoFloat,

source§

fn contains(&self, target: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for Line<T>
where T: GeoNum,

source§

fn contains(&self, linestring: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for MultiLineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for MultiPoint<T>
where T: GeoFloat,

source§

fn contains(&self, target: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for Point<T>
where T: CoordNum,

source§

fn contains(&self, line_string: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for Polygon<T>
where T: GeoFloat,

source§

fn contains(&self, target: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for Rect<T>
where T: GeoFloat,

source§

fn contains(&self, target: &LineString<T>) -> bool

source§

impl<T> Contains<LineString<T>> for Triangle<T>
where T: GeoFloat,

source§

fn contains(&self, target: &LineString<T>) -> bool

source§

impl<T> Contains<MultiLineString<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &MultiLineString<T>) -> bool

source§

impl<T> Contains<MultiPoint<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &MultiPoint<T>) -> bool

source§

impl<T> Contains<MultiPolygon<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &MultiPolygon<T>) -> bool

source§

impl<T> Contains<Point<T>> for LineString<T>
where T: GeoNum,

source§

fn contains(&self, p: &Point<T>) -> bool

source§

impl<T> Contains<Polygon<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &Polygon<T>) -> bool

source§

impl<T> Contains<Rect<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &Rect<T>) -> bool

source§

impl<T> Contains<Triangle<T>> for LineString<T>
where T: GeoFloat,

source§

fn contains(&self, target: &Triangle<T>) -> bool

source§

impl<T> Contains for LineString<T>
where T: GeoNum,

source§

fn contains(&self, rhs: &LineString<T>) -> bool

source§

impl<T> CoordinatePosition for LineString<T>
where T: GeoNum,

§

type Scalar = T

source§

fn calculate_coordinate_position( &self, coord: &Coord<T>, is_inside: &mut bool, boundary_count: &mut usize )

source§

fn coordinate_position(&self, coord: &Coord<Self::Scalar>) -> CoordPos

source§

impl<T: CoordNum> CoordsIter for LineString<T>

source§

fn coords_count(&self) -> usize

Return the number of coordinates in the LineString.

§

type Iter<'a> = Copied<Iter<'a, Coord<T>>> where T: 'a

§

type ExteriorIter<'a> = <LineString<T> as CoordsIter>::Iter<'a> where T: 'a

§

type Scalar = T

source§

fn coords_iter(&self) -> Self::Iter<'_>

Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
source§

fn exterior_coords_iter(&self) -> Self::ExteriorIter<'_>

Iterate over all exterior coordinates of a geometry. Read more
source§

impl<T> Debug for LineString<T>
where T: Debug + CoordNum,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Densify<T> for LineString<T>

§

type Output = LineString<T>

source§

fn densify(&self, max_distance: T) -> Self::Output

source§

impl<T> DensifyHaversine<T> for LineString<T>

§

type Output = LineString<T>

source§

fn densify_haversine(&self, max_distance: T) -> Self::Output

source§

impl<T> EuclideanDistance<T> for LineString<T>
where T: GeoFloat + Signed + RTreeNum,

LineString-LineString distance

source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, Geometry<T>> for LineString<T>

source§

fn euclidean_distance(&self, geom: &Geometry<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, GeometryCollection<T>> for LineString<T>

source§

fn euclidean_distance(&self, target: &GeometryCollection<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, Line<T>> for LineString<T>

LineString to Line

source§

fn euclidean_distance(&self, other: &Line<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for Geometry<T>

source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for GeometryCollection<T>

source§

fn euclidean_distance(&self, target: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for Line<T>

Line to LineString

source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for MultiLineString<T>

source§

fn euclidean_distance(&self, target: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for MultiPoint<T>

source§

fn euclidean_distance(&self, target: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for MultiPolygon<T>

source§

fn euclidean_distance(&self, target: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for Point<T>
where T: GeoFloat,

source§

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

source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for Rect<T>

source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, LineString<T>> for Triangle<T>

source§

fn euclidean_distance(&self, other: &LineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, MultiLineString<T>> for LineString<T>

source§

fn euclidean_distance(&self, target: &MultiLineString<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, MultiPoint<T>> for LineString<T>

source§

fn euclidean_distance(&self, target: &MultiPoint<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, MultiPolygon<T>> for LineString<T>

source§

fn euclidean_distance(&self, target: &MultiPolygon<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, Point<T>> for LineString<T>
where T: GeoFloat,

source§

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

source§

fn euclidean_distance(&self, other: &Polygon<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, Rect<T>> for LineString<T>

source§

fn euclidean_distance(&self, other: &Rect<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanDistance<T, Triangle<T>> for LineString<T>

source§

fn euclidean_distance(&self, other: &Triangle<T>) -> T

Returns the distance between two geometries Read more
source§

impl<T> EuclideanLength<T> for LineString<T>
where T: CoordFloat + Sum,

source§

fn euclidean_length(&self) -> T

Calculation of the length of a Line Read more
source§

impl<T> FrechetDistance<T> for LineString<T>

source§

fn frechet_distance(&self, ls: &LineString<T>) -> T

Determine the similarity between two LineStrings using the Frechet distance. Read more
source§

impl<T> From<&Line<T>> for LineString<T>
where T: CoordNum,

source§

fn from(line: &Line<T>) -> LineString<T>

Converts to this type from the input type.
source§

impl<T> From<Line<T>> for LineString<T>
where T: CoordNum,

source§

fn from(line: Line<T>) -> LineString<T>

Converts to this type from the input type.
source§

impl<T> From<LineString<T>> for Geometry<T>
where T: CoordNum,

source§

fn from(x: LineString<T>) -> Geometry<T>

Converts to this type from the input type.
source§

impl<T, IC> From<Vec<IC>> for LineString<T>
where T: CoordNum, IC: Into<Coord<T>>,

Turn a Vec of Point-like objects into a LineString.

source§

fn from(v: Vec<IC>) -> LineString<T>

Converts to this type from the input type.
source§

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>,

Creates a value from an iterator. Read more
source§

impl GeodesicArea<f64> for LineString

source§

fn geodesic_perimeter(&self) -> f64

Determine the perimeter of a geometry on an ellipsoidal model of the earth. Read more
source§

fn geodesic_area_signed(&self) -> f64

Determine the area of a geometry on an ellipsoidal model of the earth. Read more
source§

fn geodesic_area_unsigned(&self) -> f64

Determine the area of a geometry on an ellipsoidal model of the earth. Supports very large geometries that cover a significant portion of the earth. Read more
source§

fn geodesic_perimeter_area_signed(&self) -> (f64, f64)

Determine the perimeter and area of a geometry on an ellipsoidal model of the earth, all in one operation. Read more
source§

fn geodesic_perimeter_area_unsigned(&self) -> (f64, f64)

Determine the perimeter and area of a geometry on an ellipsoidal model of the earth, all in one operation. Supports very large geometries that cover a significant portion of the earth. Read more
source§

impl GeodesicLength<f64> for LineString

source§

fn geodesic_length(&self) -> f64

Determine the length of a geometry on an ellipsoidal model of the earth. Read more
source§

impl<C: CoordNum> HasDimensions for LineString<C>

source§

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 is_empty(&self) -> bool

Some geometries, like a MultiPoint, can have zero coordinates - we call these empty. Read more
source§

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 Rects are 2-dimensional, but it’s possible to create degenerate Rects which have either 1 or 0 dimensions. Read more
source§

impl<T> Hash for LineString<T>
where T: Hash + CoordNum,

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> HaversineClosestPoint<T> for LineString<T>

source§

fn haversine_closest_point(&self, from: &Point<T>) -> Closest<T>

source§

impl<T> HaversineLength<T> for LineString<T>

source§

fn haversine_length(&self) -> T

Determine the length of a geometry using the haversine formula. Read more
source§

impl<T> Index<usize> for LineString<T>
where T: CoordNum,

§

type Output = Coord<T>

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Coord<T>

Performs the indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<usize> for LineString<T>
where T: CoordNum,

source§

fn index_mut(&mut self, index: usize) -> &mut Coord<T>

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T> InteriorPoint for LineString<T>
where T: GeoFloat,

§

type Output = Option<Point<T>>

source§

fn interior_point(&self) -> Self::Output

Calculates a representative point inside the Geometry Read more
source§

impl<T, G> Intersects<G> for LineString<T>
where T: CoordNum, Line<T>: Intersects<G>, G: BoundingRect<T>,

source§

fn intersects(&self, geom: &G) -> bool

source§

impl<T> Intersects<LineString<T>> for Coord<T>
where LineString<T>: Intersects<Coord<T>>, T: CoordNum,

source§

fn intersects(&self, rhs: &LineString<T>) -> bool

source§

impl<T> Intersects<LineString<T>> for Line<T>
where LineString<T>: Intersects<Line<T>>, T: CoordNum,

source§

fn intersects(&self, rhs: &LineString<T>) -> bool

source§

impl<T> Intersects<LineString<T>> for Polygon<T>

source§

fn intersects(&self, rhs: &LineString<T>) -> bool

source§

impl<T> Intersects<LineString<T>> for Rect<T>
where LineString<T>: Intersects<Rect<T>>, T: CoordNum,

source§

fn intersects(&self, rhs: &LineString<T>) -> bool

source§

impl<T> Intersects<LineString<T>> for Triangle<T>

source§

fn intersects(&self, rhs: &LineString<T>) -> bool

source§

impl<'a, T> IntoIterator for &'a LineString<T>
where T: CoordNum,

§

type Item = &'a Coord<T>

The type of the elements being iterated over.
§

type IntoIter = CoordinatesIter<'a, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a LineString<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> IntoIterator for &'a mut LineString<T>
where T: CoordNum,

Mutably iterate over all the Coords in this LineString

§

type Item = &'a mut Coord<T>

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, Coord<T>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IterMut<'a, Coord<T>>

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for LineString<T>
where T: CoordNum,

Iterate over all the Coords in this LineString.

§

type Item = Coord<T>

The type of the elements being iterated over.
§

type IntoIter = IntoIter<Coord<T>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <LineString<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: GeoNum> IsConvex for LineString<T>

source§

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
source§

fn is_collinear(&self) -> bool

Test if the shape lies on a line.
source§

fn is_convex(&self) -> bool

Test if the shape is convex.
source§

fn is_ccw_convex(&self) -> bool

Test if the shape is convex, and oriented counter-clockwise.
source§

fn is_cw_convex(&self) -> bool

Test if the shape is convex, and oriented clockwise.
source§

fn is_strictly_convex(&self) -> bool

Test if the shape is strictly convex.
source§

fn is_strictly_ccw_convex(&self) -> bool

Test if the shape is strictly convex, and oriented counter-clockwise.
source§

fn is_strictly_cw_convex(&self) -> bool

Test if the shape is strictly convex, and oriented clockwise.
source§

impl<T> LineInterpolatePoint<T> for LineString<T>

§

type Output = Option<Point<T>>

source§

fn line_interpolate_point(&self, fraction: T) -> Self::Output

source§

impl<T> LineLocatePoint<T, Point<T>> for LineString<T>

§

type Output = Option<T>

§

type Rhs = Point<T>

source§

fn line_locate_point(&self, p: &Self::Rhs) -> Self::Output

source§

impl LineStringSegmentize for LineString

source§

impl LineStringSegmentizeHaversine for LineString

source§

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

Iterate over all exterior and (if any) interior lines of a geometry. Read more
source§

impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for LineString<T>

§

type Output = LineString<NT>

source§

fn map_coords( &self, func: impl Fn(Coord<T>) -> Coord<NT> + Copy ) -> Self::Output

Apply a function to all the coordinates in a geometric object, returning a new object. Read more
source§

fn try_map_coords<E>( &self, func: impl Fn(Coord<T>) -> Result<Coord<NT>, E> + Copy ) -> Result<Self::Output, E>

Map a fallible function over all the coordinates in a geometry, returning a Result Read more
source§

impl<T: CoordNum> MapCoordsInPlace<T> for LineString<T>

source§

fn map_coords_in_place(&mut self, func: impl Fn(Coord<T>) -> Coord<T>)

Apply a function to all the coordinates in a geometric object, in place Read more
source§

fn try_map_coords_in_place<E>( &mut self, func: impl Fn(Coord<T>) -> Result<Coord<T>, E> ) -> Result<(), E>

Map a fallible function over all the coordinates in a geometry, in place, returning a Result. Read more
source§

impl<T> PartialEq for LineString<T>
where T: PartialEq + CoordNum,

source§

fn eq(&self, other: &LineString<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PointDistance for LineString<T>
where T: Float + RTreeNum,

source§

fn distance_2(&self, point: &Point<T>) -> T

Returns the squared distance between an object and a point. Read more
source§

fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool

Returns true if a point is contained within this object. Read more
source§

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
source§

impl<T> RTreeObject for LineString<T>
where T: Float + RTreeNum,

§

type Envelope = AABB<Point<T>>

The object’s envelope type. Usually, AABB will be the right choice. This type also defines the object’s dimensionality.
source§

fn envelope(&self) -> <LineString<T> as RTreeObject>::Envelope

Returns the object’s envelope. Read more
source§

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for LineString<F>

source§

impl<F: GeoFloat> Relate<F, Line<F>> for LineString<F>

source§

fn relate(&self, other: &Line<F>) -> IntersectionMatrix

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for GeometryCollection<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for Line<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for LineString<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for MultiLineString<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for MultiPoint<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for MultiPolygon<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for Point<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for Polygon<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for Rect<F>

source§

impl<F: GeoFloat> Relate<F, LineString<F>> for Triangle<F>

source§

impl<F: GeoFloat> Relate<F, MultiLineString<F>> for LineString<F>

source§

impl<F: GeoFloat> Relate<F, MultiPoint<F>> for LineString<F>

source§

impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for LineString<F>

source§

impl<F: GeoFloat> Relate<F, Point<F>> for LineString<F>

source§

fn relate(&self, other: &Point<F>) -> IntersectionMatrix

source§

impl<F: GeoFloat> Relate<F, Polygon<F>> for LineString<F>

source§

fn relate(&self, other: &Polygon<F>) -> IntersectionMatrix

source§

impl<F: GeoFloat> Relate<F, Rect<F>> for LineString<F>

source§

fn relate(&self, other: &Rect<F>) -> IntersectionMatrix

source§

impl<F: GeoFloat> Relate<F, Triangle<F>> for LineString<F>

source§

fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix

source§

impl<T> RelativeEq for LineString<T>
where T: AbsDiffEq<Epsilon = T> + CoordNum + RelativeEq,

source§

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

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

The inverse of [RelativeEq::relative_eq].
source§

impl<T> RemoveRepeatedPoints<T> for LineString<T>

source§

fn remove_repeated_points(&self) -> Self

Create a LineString with consecutive repeated points removed.

source§

fn remove_repeated_points_mut(&mut self)

Remove consecutive repeated points from a LineString inplace.

source§

impl<T> RhumbLength<T> for LineString<T>

source§

fn rhumb_length(&self) -> T

Determine the length of a geometry assuming each segment is a rhumb line. Read more
source§

impl<T> Simplify<T> for LineString<T>
where T: GeoFloat,

source§

fn simplify(&self, epsilon: &T) -> Self

Returns the simplified representation of a geometry, using the Ramer–Douglas–Peucker algorithm Read more
source§

impl<T> SimplifyIdx<T> for LineString<T>
where T: GeoFloat,

source§

fn simplify_idx(&self, epsilon: &T) -> Vec<usize>

Returns the simplified indices of a geometry, using the Ramer–Douglas–Peucker algorithm Read more
source§

impl<T> SimplifyVw<T> for LineString<T>
where T: CoordFloat,

source§

fn simplify_vw(&self, epsilon: &T) -> LineString<T>

Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm Read more
source§

impl<T> SimplifyVwIdx<T> for LineString<T>
where T: CoordFloat,

source§

fn simplify_vw_idx(&self, epsilon: &T) -> Vec<usize>

Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm Read more
source§

impl<T> SimplifyVwPreserve<T> for LineString<T>
where T: GeoFloat + RTreeNum,

source§

fn simplify_vw_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
source§

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.

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from( geom: Geometry<T> ) -> Result<LineString<T>, <LineString<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
source§

impl<T> VincentyLength<T> for LineString<T>

source§

fn vincenty_length(&self) -> Result<T, FailedToConvergeError>

Determine the length of a geometry using Vincenty’s formulae. Read more
source§

impl<T, K> Winding for LineString<T>
where T: GeoNum<Ker = K>, K: Kernel<T>,

source§

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>

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)

Change this line’s points so they are in clockwise winding order

source§

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>

Return the winding order of this object if it contains at least three distinct coordinates, and None otherwise.
source§

fn is_cw(&self) -> bool

True iff this is wound clockwise
source§

fn is_ccw(&self) -> bool

True iff this is wound counterclockwise
source§

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
source§

fn make_winding_order(&mut self, winding_order: WindingOrder)

Change the winding order so that it is in this winding order
source§

impl<T> Eq for LineString<T>
where T: Eq + CoordNum,

source§

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 M
where T: CoordNum, M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,

source§

fn affine_transform(&self, transform: &AffineTransform<T>) -> M

Apply transform immutably, outputting a new geometry.
source§

fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)

Apply transform to mutate self.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<G, T, U> Convert<T, U> for G
where T: CoordNum, U: CoordNum + From<T>, G: MapCoords<T, U>,

§

type Output = <G as MapCoords<T, U>>::Output

source§

fn convert(&self) -> <G as Convert<T, U>>::Output

source§

impl<'a, T, G> ConvexHull<'a, T> for G
where T: GeoNum, G: CoordsIter<Scalar = T>,

§

type Scalar = T

source§

fn convex_hull(&'a self) -> Polygon<T>

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<'a, T, G> Extremes<'a, T> for G
where G: CoordsIter<Scalar = T>, T: CoordNum,

source§

fn extremes(&'a self) -> Option<Outcome<T>>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, G> HausdorffDistance<T> for G
where T: GeoFloat, G: CoordsIter<Scalar = T>,

source§

fn hausdorff_distance<Rhs>(&self, rhs: &Rhs) -> T
where Rhs: CoordsIter<Scalar = T>,

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, G> MinimumRotatedRect<T> for G
where T: CoordFloat + GeoFloat + GeoNum, G: CoordsIter<Scalar = T>,

source§

impl<G, IP, IR, T> Rotate<T> for G
where 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

Rotate a geometry around its centroid by an angle, in degrees Read more
source§

fn rotate_around_centroid_mut(&mut self, degrees: T)

Mutable version of Self::rotate_around_centroid
source§

fn rotate_around_center(&self, degrees: T) -> G

Rotate a geometry around the center of its bounding box by an angle, in degrees. Read more
source§

fn rotate_around_center_mut(&mut self, degrees: T)

Mutable version of Self::rotate_around_center
source§

fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G

Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more
source§

fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)

Mutable version of Self::rotate_around_point
source§

impl<T, IR, G> Scale<T> for G
where T: CoordFloat, IR: Into<Option<Rect<T>>>, G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,

source§

fn scale(&self, scale_factor: T) -> G

Scale a geometry from it’s bounding box center. Read more
source§

fn scale_mut(&mut self, scale_factor: T)

Mutable version of scale
source§

fn scale_xy(&self, x_factor: T, y_factor: T) -> G

Scale a geometry from it’s bounding box center, using different values for x_factor and y_factor to distort the geometry’s aspect ratio. Read more
source§

fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)

Mutable version of scale_xy.
source§

fn scale_around_point( &self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>> ) -> G

Scale a geometry around a point of origin. Read more
source§

fn scale_around_point_mut( &mut self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>> )

Mutable version of scale_around_point.
source§

impl<T, IR, G> Skew<T> for G
where T: CoordFloat, IR: Into<Option<Rect<T>>>, G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,

source§

fn skew(&self, degrees: T) -> G

An affine transformation which skews a geometry, sheared by a uniform angle along the x and y dimensions. Read more
source§

fn skew_mut(&mut self, degrees: T)

Mutable version of skew.
source§

fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G

An affine transformation which skews a geometry, sheared by an angle along the x and y dimensions. Read more
source§

fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)

Mutable version of skew_xy.
source§

fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G

An affine transformation which skews a geometry around a point of origin, sheared by an angle along the x and y dimensions. Read more
source§

fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)

Mutable version of skew_around_point.
source§

impl<T, G> ToDegrees<T> for G
where T: CoordFloat, G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,

source§

fn to_degrees(&self) -> Self

source§

fn to_degrees_in_place(&mut self)

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, G> ToRadians<T> for G
where T: CoordFloat, G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,

source§

fn to_radians(&self) -> Self

source§

fn to_radians_in_place(&mut self)

source§

impl<T, G> Translate<T> for G
where T: CoordNum, G: AffineOps<T>,

source§

fn translate(&self, x_offset: T, y_offset: T) -> G

Translate a Geometry along its axes by the given offsets Read more
source§

fn translate_mut(&mut self, x_offset: T, y_offset: T)

Translate a Geometry along its axes, but in place.
source§

impl<'a, T, G> TriangulateSpade<'a, T> for G
where T: SpadeTriangulationFloat, G: TriangulationRequirementTrait<'a, T>,

source§

fn unconstrained_triangulation(&'a self) -> TriangulationResult<Triangles<T>>

returns a triangulation that’s solely based on the points of the geometric object Read more
source§

fn constrained_outer_triangulation( &'a self, config: SpadeTriangulationConfig<T> ) -> TriangulationResult<Triangles<T>>

returns triangulation that’s based on the points of the geometric object and also incorporates the lines of the input geometry Read more
source§

fn constrained_triangulation( &'a self, config: SpadeTriangulationConfig<T> ) -> TriangulationResult<Triangles<T>>

returns triangulation that’s based on the points of the geometric object and also incorporates the lines of the input geometry Read more
source§

impl<G, T, U> TryConvert<T, U> for G
where T: CoordNum, U: CoordNum + TryFrom<T>, G: MapCoords<T, U>,

§

type Output = Result<<G as MapCoords<T, U>>::Output, <U as TryFrom<T>>::Error>

source§

fn try_convert(&self) -> <G as TryConvert<T, U>>::Output

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool