Struct geo::Line[][src]

pub struct Line<T> where
    T: CoordNum
{ pub start: Coordinate<T>, pub end: Coordinate<T>, }

A line segment made up of exactly two Coordinates.

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]

pub fn new<C>(start: C, end: C) -> Line<T> where
    C: Into<Coordinate<T>>, 
[src]

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

type Epsilon = T

Used for specifying relative comparisons.

pub fn abs_diff_eq(
    &self,
    other: &Line<T>,
    epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
[src]

Equality assertion with an 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);

impl<T> Area<T> for Line<T> where
    T: CoordNum
[src]

impl<T> BoundingRect<T> for Line<T> where
    T: CoordNum
[src]

type Output = Rect<T>

impl<T> Centroid for Line<T> where
    T: GeoFloat
[src]

type Output = Point<T>

impl<T> Clone for Line<T> where
    T: Clone + CoordNum
[src]

impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Line<F>[src]

impl<T> Contains<Coordinate<T>> for Line<T> where
    T: GeoNum
[src]

impl<F> Contains<Line<F>> for MultiPolygon<F> where
    F: GeoFloat
[src]

impl<T> Contains<Line<T>> for Line<T> where
    T: GeoNum
[src]

impl<T> Contains<Line<T>> for LineString<T> where
    T: GeoNum
[src]

impl<T> Contains<Line<T>> for Polygon<T> where
    T: GeoFloat
[src]

impl<T> Contains<LineString<T>> for Line<T> where
    T: GeoNum
[src]

impl<T> Contains<Point<T>> for Line<T> where
    T: GeoNum
[src]

impl<T> CoordinatePosition for Line<T> where
    T: GeoNum
[src]

type Scalar = T

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_count(&'a self) -> usize[src]

Return the number of coordinates in the Line.

impl<T> Copy for Line<T> where
    T: Copy + CoordNum
[src]

impl<T> Debug for Line<T> where
    T: Debug + CoordNum
[src]

impl<T> Eq for Line<T> where
    T: Eq + CoordNum
[src]

impl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
    T: GeoFloat
[src]

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]

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]

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]

Line to Line distance

impl<T> EuclideanDistance<T, Line<T>> for LineString<T> where
    T: GeoFloat + FloatConst + Signed + RTreeNum
[src]

LineString to Line

impl<T> EuclideanDistance<T, Line<T>> for Polygon<T> where
    T: GeoFloat + FloatConst + Signed + RTreeNum
[src]

impl<T> EuclideanDistance<T, Line<T>> for MultiPolygon<T> where
    T: GeoFloat + FloatConst + Signed + RTreeNum
[src]

MultiPolygon to Line distance

impl<T> EuclideanDistance<T, LineString<T>> for Line<T> where
    T: GeoFloat + FloatConst + Signed + RTreeNum
[src]

Line to LineString

impl<T> EuclideanDistance<T, MultiPolygon<T>> for Line<T> where
    T: GeoFloat + FloatConst + Signed + RTreeNum
[src]

Line to MultiPolygon distance

impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
    T: GeoFloat
[src]

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]

impl<T> EuclideanLength<T, Line<T>> for Line<T> where
    T: CoordFloat
[src]

impl<T> From<[(T, T); 2]> for Line<T> where
    T: CoordNum
[src]

impl<T> From<Line<T>> for Geometry<T> where
    T: CoordNum
[src]

impl<T> From<Line<T>> for LineString<T> where
    T: CoordNum
[src]

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]

impl<T> Hash for Line<T> where
    T: Hash + CoordNum
[src]

impl<T> HaversineLength<T, Line<T>> for Line<T> where
    T: CoordFloat + FromPrimitive
[src]

impl<T> Intersects<Coordinate<T>> for Line<T> where
    T: GeoNum
[src]

impl<T> Intersects<Geometry<T>> for Line<T> where
    Geometry<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<GeometryCollection<T>> for Line<T> where
    GeometryCollection<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<Line<T>> for Coordinate<T> where
    Line<T>: Intersects<Coordinate<T>>,
    T: CoordNum
[src]

impl<T> Intersects<Line<T>> for Line<T> where
    T: GeoNum
[src]

impl<T> Intersects<Line<T>> for Polygon<T> where
    T: GeoNum
[src]

impl<T> Intersects<Line<T>> for Rect<T> where
    T: GeoNum
[src]

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

impl<T> Intersects<MultiPoint<T>> for Line<T> where
    MultiPoint<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<MultiPolygon<T>> for Line<T> where
    MultiPolygon<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<Point<T>> for Line<T> where
    Point<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<Polygon<T>> for Line<T> where
    Polygon<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<Rect<T>> for Line<T> where
    Rect<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<Triangle<T>> for Line<T> where
    Triangle<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> LineInterpolatePoint<T> for Line<T> where
    T: CoordFloat
[src]

type Output = Option<Point<T>>

impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
    T: CoordFloat
[src]

type Output = Option<T>

type Rhs = Point<T>

impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Line<T>[src]

type Output = Line<NT>

impl<T: CoordNum> MapCoordsInplace<T> for Line<T>[src]

impl<T> PartialEq<Line<T>> for Line<T> where
    T: PartialEq<T> + CoordNum
[src]

impl<T> PointDistance for Line<T> where
    T: Float + RTreeNum
[src]

impl<T> RTreeObject for Line<T> where
    T: Float + RTreeNum
[src]

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

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for Point<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for LineString<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for Polygon<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for MultiPoint<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for MultiLineString<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for MultiPolygon<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for Rect<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for Triangle<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, LineString<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, MultiLineString<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, MultiPoint<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, Point<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, Polygon<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, Rect<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, Triangle<F>> for Line<F>[src]

impl<T> RelativeEq<Line<T>> for Line<T> where
    T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>, 
[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]

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

impl<T> Rotate<T> for Line<T> where
    T: GeoFloat
[src]

impl<T> StructuralEq for Line<T> where
    T: CoordNum
[src]

impl<T> StructuralPartialEq for Line<T> where
    T: CoordNum
[src]

impl<T> TryFrom<Geometry<T>> for Line<T> where
    T: CoordNum
[src]

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.

impl<T: CoordNum, NT: CoordNum> TryMapCoords<T, NT> for Line<T>[src]

type Output = Line<NT>

impl<T> VincentyLength<T, Line<T>> for Line<T> where
    T: CoordFloat + FromPrimitive
[src]

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

impl<T> Send for Line<T> where
    T: Send

impl<T> Sync for Line<T> where
    T: Sync

impl<T> Unpin for Line<T> where
    T: Unpin

impl<T> UnwindSafe for Line<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, G> RotatePoint<T> for G where
    T: CoordFloat,
    G: MapCoords<T, T, Output = G>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, G> Translate<T> for G where
    T: CoordNum,
    G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.