Struct geo::LineString
[−]
[src]
pub struct LineString<T>(pub Vec<Point<T>>)
where
T: CoordinateType;
An ordered collection of two or more Point
s, representing a path between locations
Create a LineString
by calling it directly:
use geo_types::{LineString, Point}; let line = LineString(vec![Point::new(0., 0.), Point::new(10., 0.)]);
Converting a Vec
of Point
-like things:
let line: LineString<f32> = vec![(0., 0.), (10., 0.)].into();
Or collect
ing from a Point iterator
let mut points = vec![Point::new(0., 0.), Point::new(10., 0.)]; let line: LineString<f32> = points.into_iter().collect();
You can iterate over the points in the LineString
use geo_types::{LineString, Point}; let line = LineString(vec![Point::new(0., 0.), Point::new(10., 0.)]); for point in line { println!("Point x = {}, y = {}", point.x(), point.y()); }
Methods
impl<T> LineString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
ⓘImportant traits for Box<W>pub fn lines(&'a self) -> Box<Iterator<Item = Line<T>> + 'a>
[src]
Return an Line
iterator that yields one Line
for each line segment
in the LineString
.
Examples
use geo_types::{Line, LineString, Point}; let mut points = vec![(0., 0.), (5., 0.), (7., 9.)]; let linestring: LineString<f32> = points.into_iter().collect(); let mut lines = linestring.lines(); assert_eq!( Some(Line::new(Point::new(0., 0.), Point::new(5., 0.))), lines.next() ); assert_eq!( Some(Line::new(Point::new(5., 0.), Point::new(7., 9.))), lines.next() ); assert!(lines.next().is_none());
ⓘImportant traits for Iter<'a, T>pub fn points(&self) -> Iter<Point<T>>
[src]
ⓘImportant traits for IterMut<'a, T>pub fn points_mut(&mut self) -> IterMut<Point<T>>
[src]
Trait Implementations
impl<'de, T> Deserialize<'de> for LineString<T> where
T: CoordinateType + Deserialize<'de>,
[src]
T: CoordinateType + Deserialize<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<LineString<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<LineString<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T> IntoIterator for LineString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
Iterate over all the Points in this linestring
type Item = Point<T>
The type of the elements being iterated over.
type IntoIter = IntoIter<Point<T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <LineString<T> as IntoIterator>::IntoIter
[src]
Creates an iterator from a value. Read more
impl<T> Serialize for LineString<T> where
T: CoordinateType + Serialize,
[src]
T: CoordinateType + Serialize,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T, IP> FromIterator<IP> for LineString<T> where
IP: Into<Point<T>>,
T: CoordinateType,
[src]
IP: Into<Point<T>>,
T: CoordinateType,
Turn a Point
-ish iterator into a LineString
.
fn from_iter<I>(iter: I) -> LineString<T> where
I: IntoIterator<Item = IP>,
[src]
I: IntoIterator<Item = IP>,
Creates a value from an iterator. Read more
impl<T> PartialEq<LineString<T>> for LineString<T> where
T: PartialEq<T> + CoordinateType,
[src]
T: PartialEq<T> + CoordinateType,
fn eq(&self, __arg_0: &LineString<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &LineString<T>) -> bool
[src]
This method tests for !=
.
impl<T, IP> From<Vec<IP>> for LineString<T> where
IP: Into<Point<T>>,
T: CoordinateType,
[src]
IP: Into<Point<T>>,
T: CoordinateType,
Turn a Vec
of Point
-ish objects into a LineString
.
fn from(v: Vec<IP>) -> LineString<T>
[src]
Performs the conversion.
impl<T> From<LineString<T>> for Geometry<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn from(x: LineString<T>) -> Geometry<T>
[src]
Performs the conversion.
impl<T> Clone for LineString<T> where
T: Clone + CoordinateType,
[src]
T: Clone + CoordinateType,
fn clone(&self) -> LineString<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Debug for LineString<T> where
T: Debug + CoordinateType,
[src]
T: Debug + CoordinateType,
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl<T> Centroid<T> for LineString<T> where
T: Float,
[src]
T: Float,
type Output = Option<Point<T>>
fn centroid(&self) -> Self::Output
[src]
See: https://en.wikipedia.org/wiki/Centroid Read more
impl<T> Contains<Point<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn contains(&self, p: &Point<T>) -> bool
[src]
Checks if the geometry A is completely inside the B geometry. Read more
impl<T> Contains<LineString<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn contains(&self, linestring: &LineString<T>) -> bool
[src]
Checks if the geometry A is completely inside the B geometry. Read more
impl<T> Contains<Line<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn contains(&self, line: &Line<T>) -> bool
[src]
Checks if the geometry A is completely inside the B geometry. Read more
impl<T> Contains<LineString<T>> for Polygon<T> where
T: Float,
[src]
T: Float,
fn contains(&self, linestring: &LineString<T>) -> bool
[src]
Checks if the geometry A is completely inside the B geometry. Read more
impl<T> Intersects<LineString<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, linestring: &LineString<T>) -> bool
[src]
Checks if the geometry A intersects the geometry B. Read more
impl<T> Intersects<Line<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, line: &Line<T>) -> bool
[src]
Checks if the geometry A intersects the geometry B. Read more
impl<T> Intersects<LineString<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, linestring: &LineString<T>) -> bool
[src]
Checks if the geometry A intersects the geometry B. Read more
impl<T> Intersects<LineString<T>> for Polygon<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, linestring: &LineString<T>) -> bool
[src]
Checks if the geometry A intersects the geometry B. Read more
impl<T> EuclideanLength<T> for LineString<T> where
T: Float,
[src]
T: Float,
fn euclidean_length(&self) -> T
[src]
Calculation of the length of a Line Read more
impl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, linestring: &LineString<T>) -> T
[src]
Minimum distance from a Point to a LineString
impl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a LineString to a Point
impl<T> BoundingBox<T> for LineString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
type Output = Option<Bbox<T>>
fn bbox(&self) -> Self::Output
[src]
Return the BoundingBox for a LineString
impl<T> Simplify<T> for LineString<T> where
T: Float,
[src]
T: Float,
fn simplify(&self, epsilon: &T) -> LineString<T>
[src]
Returns the simplified representation of a geometry, using the Ramer–Douglas–Peucker algorithm Read more
impl<T> SimplifyVWPreserve<T> for LineString<T> where
T: Float + SpadeFloat,
[src]
T: Float + SpadeFloat,
fn simplifyvw_preserve(&self, epsilon: &T) -> LineString<T>
[src]
Returns the simplified representation of a geometry, using a topology-preserving variant of the Visvalingam-Whyatt algorithm. Read more
impl<T> SimplifyVW<T> for LineString<T> where
T: Float,
[src]
T: Float,
fn simplifyvw(&self, epsilon: &T) -> LineString<T>
[src]
Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm Read more
impl<T> ConvexHull<T> for LineString<T> where
T: Float,
[src]
T: Float,
fn convex_hull(&self) -> Polygon<T>
[src]
Returns the convex hull of a Polygon. The hull is always oriented counter-clockwise. Read more
impl<T> Rotate<T> for LineString<T> where
T: Float,
[src]
T: Float,
fn rotate(&self, angle: T) -> Self
[src]
Rotate the LineString about its centroid by the given number of degrees
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for LineString<T>
[src]
type Output = LineString<NT>
fn map_coords(&self, func: &Fn(&(T, T)) -> (NT, NT)) -> Self::Output
[src]
Apply a function to all the coordinates in a geometric object, returning a new object. Read more
impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for LineString<T>
[src]
type Output = LineString<NT>
fn try_map_coords(
&self,
func: &Fn(&(T, T)) -> Result<(NT, NT), Error>
) -> Result<Self::Output, Error>
[src]
&self,
func: &Fn(&(T, T)) -> Result<(NT, NT), Error>
) -> Result<Self::Output, Error>
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
impl<T: CoordinateType> MapCoordsInplace<T> for LineString<T>
[src]
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T))
[src]
Apply a function to all the coordinates in a geometric object, in place Read more
impl<F: Float> ClosestPoint<F> for LineString<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
Find the closest point between self
and p
.
impl<T> HaversineLength<T> for LineString<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn haversine_length(&self) -> T
[src]
Calculation of the length of a Line Read more
impl<T> Winding<T> for LineString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn winding_order(&self) -> Option<WindingOrder>
[src]
Returns the winding order of this line None if the winding order is undefined.
ⓘImportant traits for Box<W>fn points_cw<'a>(&'a self) -> Box<Iterator<Item = &'a Point<T>> + 'a>
[src]
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
ⓘImportant traits for Box<W>fn points_ccw<'a>(&'a self) -> Box<Iterator<Item = &'a Point<T>> + 'a>
[src]
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
fn make_cw_winding(&mut self)
[src]
Change this line's points so they are in clockwise winding order
fn make_ccw_winding(&mut self)
[src]
Change this line's points so they are in counterclockwise winding order
fn is_cw(&self) -> bool
[src]
True iff this clockwise
fn is_ccw(&self) -> bool
[src]
True iff this is wound counterclockwise
fn clone_to_winding_order(&self, winding_order: WindingOrder) -> Self where
Self: Sized + Clone,
[src]
Self: Sized + Clone,
Return a clone of this object, but in the specified winding order
fn make_winding_order(&mut self, winding_order: WindingOrder)
[src]
Change the winding order so that it is in this winding order
Auto Trait Implementations
impl<T> Send for LineString<T> where
T: Send,
T: Send,
impl<T> Sync for LineString<T> where
T: Sync,
T: Sync,