Struct geo::Line [−][src]
A line segment made up of exactly two
Coordinate
s.
Semantics
The interior and boundary are defined as with a
LineString
with the two end points.
Fields
start: Coordinate<T>
end: Coordinate<T>
Implementations
impl<T> Line<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn new<C>(start: C, end: C) -> Line<T> where
C: Into<Coordinate<T>>,
[src]
C: Into<Coordinate<T>>,
Creates a new line segment.
Examples
use geo_types::{Coordinate, Line}; let line = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1., y: 2. }); assert_eq!(line.start, Coordinate { x: 0., y: 0. }); assert_eq!(line.end, Coordinate { x: 1., y: 2. });
pub fn delta(&self) -> Coordinate<T>
[src]
Calculate the difference in coordinates (Δx, Δy).
pub fn dx(&self) -> T
[src]
Calculate the difference in ‘x’ components (Δx).
Equivalent to:
line.end.x - line.start.x
pub fn dy(&self) -> T
[src]
Calculate the difference in ‘y’ components (Δy).
Equivalent to:
line.end.y - line.start.y
pub fn slope(&self) -> T
[src]
Calculate the slope (Δy/Δx).
Equivalent to:
line.dy() / line.dx()
Note that:
Line::new(a, b).slope() == Line::new(b, a).slope()
pub fn determinant(&self) -> T
[src]
Calculate the determinant of the line.
Equivalent to:
line.start.x * line.end.y - line.start.y * line.end.x
Note that:
Line::new(a, b).determinant() == -Line::new(b, a).determinant()
pub fn start_point(&self) -> Point<T>
[src]
pub fn end_point(&self) -> Point<T>
[src]
pub fn points(&self) -> (Point<T>, Point<T>)
[src]
Trait Implementations
impl<T> AbsDiffEq<Line<T>> for Line<T> where
T: CoordNum + AbsDiffEq<T, Epsilon = T>,
[src]
T: CoordNum + AbsDiffEq<T, Epsilon = T>,
type Epsilon = T
Used for specifying relative comparisons.
pub fn default_epsilon() -> <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
[src]
pub fn abs_diff_eq(
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
[src]
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
Equality assertion with a absolute limit.
Examples
use geo_types::{Coordinate, Line}; let a = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1., y: 1. }); let b = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1.001, y: 1. }); approx::assert_abs_diff_eq!(a, b, epsilon=0.1);
pub fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
impl<T> Area<T> for Line<T> where
T: CoordNum,
[src]
T: CoordNum,
fn signed_area(&self) -> T
[src]
fn unsigned_area(&self) -> T
[src]
impl<T> BoundingRect<T> for Line<T> where
T: CoordNum,
[src]
T: CoordNum,
type Output = Rect<T>
fn bounding_rect(&self) -> Self::Output
[src]
impl<T> Centroid for Line<T> where
T: CoordFloat,
[src]
T: CoordFloat,
impl<T> Clone for Line<T> where
T: Clone + CoordNum,
[src]
T: Clone + CoordNum,
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Line<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<T> Contains<Coordinate<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Line<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
impl<T> Contains<Line<T>> for LineString<T> where
T: GeoNum,
[src]
T: GeoNum,
impl<T> Contains<Line<T>> for Polygon<T> where
T: GeoNum,
[src]
T: GeoNum,
impl<T> Contains<LineString<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, linestring: &LineString<T>) -> bool
[src]
impl<T> Contains<Point<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
impl<T> CoordinatePosition for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
[src]
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
[src]
impl<'a, T: CoordNum> CoordsIter<'a> for Line<T>
[src]
type Iter = Chain<Once<Coordinate<T>>, Once<Coordinate<T>>>
type ExteriorIter = Self::Iter
type Scalar = T
fn coords_iter(&'a self) -> Self::Iter
[src]
fn coords_count(&'a self) -> usize
[src]
Return the number of coordinates in the Line
.
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
[src]
impl<T> Copy for Line<T> where
T: Copy + CoordNum,
[src]
T: Copy + CoordNum,
impl<T> Debug for Line<T> where
T: Debug + CoordNum,
[src]
T: Debug + CoordNum,
impl<T> Eq for Line<T> where
T: Eq + CoordNum,
[src]
T: Eq + CoordNum,
impl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, coord: &Coordinate<T>) -> T
[src]
Minimum distance from a Line
to a Coordinate
impl<T> EuclideanDistance<T, Line<T>> for Coordinate<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, line: &Line<T>) -> T
[src]
Minimum distance from a Coordinate
to a Line
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, line: &Line<T>) -> T
[src]
Minimum distance from a Line to a Point
impl<T> EuclideanDistance<T, Line<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
[src]
T: GeoFloat + FloatConst + Signed + RTreeNum,
Line to Line distance
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, Line<T>> for LineString<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
[src]
T: GeoFloat + FloatConst + Signed + RTreeNum,
LineString to Line
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, Line<T>> for Polygon<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
[src]
T: GeoFloat + FloatConst + Signed + RTreeNum,
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, Line<T>> for MultiPolygon<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
[src]
T: GeoFloat + FloatConst + Signed + RTreeNum,
MultiPolygon to Line distance
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, LineString<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
[src]
T: GeoFloat + FloatConst + Signed + RTreeNum,
Line to LineString
fn euclidean_distance(&self, other: &LineString<T>) -> T
[src]
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
[src]
T: GeoFloat + FloatConst + Signed + RTreeNum,
Line to MultiPolygon distance
fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
[src]
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a Line to a Point
impl<T> EuclideanDistance<T, Polygon<T>> for Line<T> where
T: GeoFloat + Signed + RTreeNum + FloatConst,
[src]
T: GeoFloat + Signed + RTreeNum + FloatConst,
fn euclidean_distance(&self, other: &Polygon<T>) -> T
[src]
impl<T> EuclideanLength<T, Line<T>> for Line<T> where
T: CoordFloat,
[src]
T: CoordFloat,
fn euclidean_length(&self) -> T
[src]
impl<T> From<[(T, T); 2]> for Line<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> From<Line<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl GeodesicLength<f64, Line<f64>> for Line<f64>
[src]
fn geodesic_length(&self) -> f64
[src]
The units of the returned value is meters.
impl<C: CoordNum> HasDimensions for Line<C>
[src]
fn is_empty(&self) -> bool
[src]
fn dimensions(&self) -> Dimensions
[src]
fn boundary_dimensions(&self) -> Dimensions
[src]
impl<T> Hash for Line<T> where
T: Hash + CoordNum,
[src]
T: Hash + CoordNum,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> HaversineLength<T, Line<T>> for Line<T> where
T: CoordFloat + FromPrimitive,
[src]
T: CoordFloat + FromPrimitive,
fn haversine_length(&self) -> T
[src]
impl<T> Intersects<Coordinate<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
[src]
impl<T> Intersects<Geometry<T>> for Line<T> where
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
[src]
impl<T> Intersects<GeometryCollection<T>> for Line<T> where
GeometryCollection<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
GeometryCollection<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Coordinate<T> where
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Line<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Polygon<T> where
T: GeoNum,
[src]
T: GeoNum,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Rect<T> where
T: GeoNum,
[src]
T: GeoNum,
fn intersects(&self, rhs: &Line<T>) -> bool
[src]
impl<T> Intersects<LineString<T>> for Line<T> where
LineString<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
LineString<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
[src]
impl<T> Intersects<MultiPoint<T>> for Line<T> where
MultiPoint<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
MultiPoint<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
[src]
impl<T> Intersects<MultiPolygon<T>> for Line<T> where
MultiPolygon<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
MultiPolygon<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPolygon<T>) -> bool
[src]
impl<T> Intersects<Point<T>> for Line<T> where
Point<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Point<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
[src]
impl<T> Intersects<Polygon<T>> for Line<T> where
Polygon<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Polygon<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Polygon<T>) -> bool
[src]
impl<T> Intersects<Rect<T>> for Line<T> where
Rect<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Rect<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Rect<T>) -> bool
[src]
impl<T> Intersects<Triangle<T>> for Line<T> where
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
[src]
impl<T> LineInterpolatePoint<T> for Line<T> where
T: CoordFloat,
[src]
T: CoordFloat,
impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordFloat,
[src]
T: CoordFloat,
type Output = Option<T>
type Rhs = Point<T>
fn line_locate_point(&self, p: &Self::Rhs) -> Self::Output
[src]
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Line<T>
[src]
type Output = Line<NT>
fn map_coords(&self, func: impl Fn(&(T, T)) -> (NT, NT) + Copy) -> Self::Output
[src]
impl<T: CoordNum> MapCoordsInplace<T> for Line<T>
[src]
impl<T> PartialEq<Line<T>> for Line<T> where
T: PartialEq<T> + CoordNum,
[src]
T: PartialEq<T> + CoordNum,
impl<T> PointDistance for Line<T> where
T: Float + RTreeNum,
[src]
T: Float + RTreeNum,
pub fn distance_2(&self, point: &Point<T>) -> T
[src]
pub fn contains_point(
&self,
point: &<Self::Envelope as Envelope>::Point
) -> bool
[src]
&self,
point: &<Self::Envelope as Envelope>::Point
) -> bool
pub 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>
[src]
&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>
impl<T> RTreeObject for Line<T> where
T: Float + RTreeNum,
[src]
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 objects dimensionality. Read more
pub fn envelope(&self) -> <Line<T> as RTreeObject>::Envelope
[src]
impl<T> RelativeEq<Line<T>> for Line<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
[src]
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
pub fn default_max_relative() -> <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
[src]
pub fn relative_eq(
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon,
max_relative: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
[src]
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon,
max_relative: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
Equality assertion within a relative limit.
Examples
use geo_types::{Coordinate, Line}; let a = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1., y: 1. }); let b = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1.001, y: 1. }); approx::assert_relative_eq!(a, b, max_relative=0.1);
pub fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
impl<T> Rotate<T> for Line<T> where
T: CoordFloat,
[src]
T: CoordFloat,
impl<T> StructuralEq for Line<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> StructuralPartialEq for Line<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for Line<T> where
T: CoordNum,
[src]
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.
pub fn try_from(
geom: Geometry<T>
) -> Result<Line<T>, <Line<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Line<T>, <Line<T> as TryFrom<Geometry<T>>>::Error>
impl<T: CoordNum, NT: CoordNum> TryMapCoords<T, NT> for Line<T>
[src]
type Output = Line<NT>
fn try_map_coords(
&self,
func: impl Fn(&(T, T)) -> Result<(NT, NT), Box<dyn Error + Send + Sync>> + Copy
) -> Result<Self::Output, Box<dyn Error + Send + Sync>>
[src]
&self,
func: impl Fn(&(T, T)) -> Result<(NT, NT), Box<dyn Error + Send + Sync>> + Copy
) -> Result<Self::Output, Box<dyn Error + Send + Sync>>
impl<T> VincentyLength<T, Line<T>> for Line<T> where
T: CoordFloat + FromPrimitive,
[src]
T: CoordFloat + FromPrimitive,
fn vincenty_length(&self) -> Result<T, FailedToConvergeError>
[src]
The units of the returned value is meters.
Auto Trait Implementations
impl<T> RefUnwindSafe for Line<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Line<T> where
T: Send,
T: Send,
impl<T> Sync for Line<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Line<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Line<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T, G> Extremes<'a, T> for G where
T: CoordNum,
G: CoordsIter<'a, Scalar = T>,
[src]
T: CoordNum,
G: CoordsIter<'a, Scalar = T>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
[src]
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
pub fn rotate_around_point(&Self, T, Point<T>) -> G
[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
[src]
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,