pub struct Line<T = f64> where
T: CoordNum, {
pub start: Coordinate<T>,
pub end: Coordinate<T>,
}
Expand description
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
sourceimpl<T> Line<T> where
T: CoordNum,
impl<T> Line<T> where
T: CoordNum,
sourcepub fn new<C>(start: C, end: C) -> Line<T> where
C: Into<Coordinate<T>>,
pub fn new<C>(start: C, end: C) -> Line<T> where
C: Into<Coordinate<T>>,
Creates a new line segment.
Examples
use geo_types::{coord, Line};
let line = Line::new(coord! { x: 0., y: 0. }, coord! { x: 1., y: 2. });
assert_eq!(line.start, coord! { x: 0., y: 0. });
assert_eq!(line.end, coord! { x: 1., y: 2. });
sourcepub fn delta(&self) -> Coordinate<T>
pub fn delta(&self) -> Coordinate<T>
Calculate the difference in coordinates (Δx, Δy).
sourcepub fn dx(&self) -> T
pub fn dx(&self) -> T
Calculate the difference in ‘x’ components (Δx).
Equivalent to:
line.end.x - line.start.x
sourcepub fn dy(&self) -> T
pub fn dy(&self) -> T
Calculate the difference in ‘y’ components (Δy).
Equivalent to:
line.end.y - line.start.y
sourcepub fn slope(&self) -> T
pub fn slope(&self) -> T
Calculate the slope (Δy/Δx).
Equivalent to:
line.dy() / line.dx()
Note that:
Line::new(a, b).slope() == Line::new(b, a).slope()
sourcepub fn determinant(&self) -> T
pub fn determinant(&self) -> T
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>
pub fn end_point(&self) -> Point<T>
pub fn points(&self) -> (Point<T>, Point<T>)
Trait Implementations
sourceimpl<T> AbsDiffEq<Line<T>> for Line<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
impl<T> AbsDiffEq<Line<T>> for Line<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
sourcefn abs_diff_eq(
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
Equality assertion with an absolute limit.
Examples
use geo_types::{coord, Line};
let a = Line::new(coord! { x: 0., y: 0. }, coord! { x: 1., y: 1. });
let b = Line::new(coord! { x: 0., y: 0. }, coord! { x: 1.001, y: 1. });
approx::assert_abs_diff_eq!(a, b, epsilon=0.1);
type Epsilon = T
type Epsilon = T
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
fn default_epsilon() -> <Line<T> as AbsDiffEq<Line<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 Line<T> where
T: CoordNum,
impl<T> Area<T> for Line<T> where
T: CoordNum,
fn signed_area(&self) -> T
fn unsigned_area(&self) -> T
sourceimpl<T> BoundingRect<T> for Line<T> where
T: CoordNum,
impl<T> BoundingRect<T> for Line<T> where
T: CoordNum,
sourceimpl<T> ChamberlainDuquetteArea<T> for Line<T> where
T: CoordFloat,
impl<T> ChamberlainDuquetteArea<T> for Line<T> where
T: CoordFloat,
fn chamberlain_duquette_signed_area(&self) -> T
fn chamberlain_duquette_unsigned_area(&self) -> T
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Line<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Line<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> Contains<Coordinate<T>> for Line<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for Line<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<GeometryCollection<T>> for Line<T> where
T: GeoFloat,
impl<T> Contains<GeometryCollection<T>> for Line<T> where
T: GeoFloat,
fn contains(&self, target: &GeometryCollection<T>) -> bool
sourceimpl<F> Contains<Line<F>> for MultiPolygon<F> where
F: GeoFloat,
impl<F> Contains<Line<F>> for MultiPolygon<F> where
F: GeoFloat,
sourceimpl<T> Contains<Line<T>> for GeometryCollection<T> where
T: GeoFloat,
impl<T> Contains<Line<T>> for GeometryCollection<T> where
T: GeoFloat,
sourceimpl<T> Contains<Line<T>> for LineString<T> where
T: GeoNum,
impl<T> Contains<Line<T>> for LineString<T> where
T: GeoNum,
sourceimpl<T> Contains<Line<T>> for MultiLineString<T> where
T: GeoFloat,
impl<T> Contains<Line<T>> for MultiLineString<T> where
T: GeoFloat,
sourceimpl<T> Contains<Line<T>> for MultiPoint<T> where
T: GeoFloat,
impl<T> Contains<Line<T>> for MultiPoint<T> where
T: GeoFloat,
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<MultiLineString<T>> for Line<T> where
T: GeoFloat,
impl<T> Contains<MultiLineString<T>> for Line<T> where
T: GeoFloat,
fn contains(&self, target: &MultiLineString<T>) -> bool
sourceimpl<T> Contains<MultiPoint<T>> for Line<T> where
T: GeoFloat,
impl<T> Contains<MultiPoint<T>> for Line<T> where
T: GeoFloat,
fn contains(&self, target: &MultiPoint<T>) -> bool
sourceimpl<T> Contains<MultiPolygon<T>> for Line<T> where
T: GeoFloat,
impl<T> Contains<MultiPolygon<T>> for Line<T> where
T: GeoFloat,
fn contains(&self, target: &MultiPolygon<T>) -> bool
sourceimpl<T> CoordinatePosition for Line<T> where
T: GeoNum,
impl<T> CoordinatePosition for Line<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> CoordsIter<'a> for Line<T>
impl<'a, T: CoordNum> CoordsIter<'a> for Line<T>
sourcefn coords_count(&'a self) -> usize
fn coords_count(&'a self) -> usize
Return the number of coordinates in the Line
.
type Iter = Chain<Once<Coordinate<T>>, Once<Coordinate<T>>>
type ExteriorIter = <Line<T> as CoordsIter<'a>>::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> Densify<T> for Line<T> where
T: CoordFloat,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
impl<T> Densify<T> for Line<T> where
T: CoordFloat,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
type Output = LineString<T>
fn densify(&self, max_distance: T) -> Self::Output
sourceimpl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, coord: &Coordinate<T>) -> T
fn euclidean_distance(&self, coord: &Coordinate<T>) -> T
Minimum distance from a Line
to a Coordinate
sourceimpl<T> EuclideanDistance<T, Line<T>> for Coordinate<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Line<T>> for Coordinate<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, line: &Line<T>) -> T
fn euclidean_distance(&self, line: &Line<T>) -> T
Minimum distance from a Coordinate
to a Line
sourceimpl<T> EuclideanDistance<T, Line<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, Line<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
Line to Line distance
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, 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, Line<T>> for MultiPolygon<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, Line<T>> for MultiPolygon<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
MultiPolygon to Line distance
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, Line<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, line: &Line<T>) -> T
fn euclidean_distance(&self, line: &Line<T>) -> T
Minimum distance from a Line to a Point
sourceimpl<T> EuclideanDistance<T, Line<T>> for Polygon<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, Line<T>> for Polygon<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
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 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, MultiPolygon<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Line<T> where
T: GeoFloat + FloatConst + Signed + RTreeNum,
Line to MultiPolygon distance
sourcefn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a Line to a Point
sourceimpl<T> EuclideanDistance<T, Polygon<T>> for Line<T> where
T: GeoFloat + Signed + RTreeNum + FloatConst,
impl<T> EuclideanDistance<T, Polygon<T>> for Line<T> where
T: GeoFloat + Signed + RTreeNum + FloatConst,
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, Line<T>> for Line<T> where
T: CoordFloat,
impl<T> EuclideanLength<T, Line<T>> for Line<T> where
T: CoordFloat,
sourcefn euclidean_length(&self) -> T
fn euclidean_length(&self) -> T
Calculation of the length of a Line Read more
sourceimpl<T: GeoNum> From<Line<T>> for LineOrPoint<T>
impl<T: GeoNum> From<Line<T>> for LineOrPoint<T>
Convert from a Line
ensuring end point ordering.
sourceimpl<T> From<Line<T>> for LineString<T> where
T: CoordNum,
impl<T> From<Line<T>> for LineString<T> where
T: CoordNum,
sourcefn from(line: Line<T>) -> LineString<T>
fn from(line: Line<T>) -> LineString<T>
Converts to this type from the input type.
sourceimpl GeodesicLength<f64, Line<f64>> for Line
impl GeodesicLength<f64, Line<f64>> for Line
sourcefn geodesic_length(&self) -> f64
fn geodesic_length(&self) -> f64
The units of the returned value is meters.
sourceimpl<C: CoordNum> HasDimensions for Line<C>
impl<C: CoordNum> HasDimensions for Line<C>
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
sourcefn boundary_dimensions(&self) -> Dimensions
fn boundary_dimensions(&self) -> Dimensions
The dimensions of the Geometry
’s boundary, as used by OGC-SFA. Read more
sourceimpl<T> HaversineLength<T, Line<T>> for Line<T> where
T: CoordFloat + FromPrimitive,
impl<T> HaversineLength<T, Line<T>> for Line<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> InteriorPoint for Line<T> where
T: GeoFloat,
impl<T> InteriorPoint for Line<T> where
T: GeoFloat,
sourceimpl<T> Intersects<Coordinate<T>> for Line<T> where
T: GeoNum,
impl<T> Intersects<Coordinate<T>> for Line<T> where
T: GeoNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
sourceimpl<T> Intersects<Geometry<T>> for Line<T> where
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Line<T> where
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
sourceimpl<T> Intersects<GeometryCollection<T>> for Line<T> where
GeometryCollection<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Line<T> where
GeometryCollection<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
sourceimpl<T> Intersects<Line<T>> for Coordinate<T> where
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Line<T>> for Coordinate<T> where
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Line<T>) -> bool
sourceimpl<T> Intersects<Line<T>> for Line<T> where
T: GeoNum,
impl<T> Intersects<Line<T>> for Line<T> where
T: GeoNum,
fn intersects(&self, line: &Line<T>) -> bool
sourceimpl<T> Intersects<Line<T>> for Polygon<T> where
T: GeoNum,
impl<T> Intersects<Line<T>> for Polygon<T> where
T: GeoNum,
fn intersects(&self, line: &Line<T>) -> bool
sourceimpl<T> Intersects<Line<T>> for Rect<T> where
T: GeoNum,
impl<T> Intersects<Line<T>> for Rect<T> where
T: GeoNum,
fn intersects(&self, rhs: &Line<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<MultiLineString<T>> for Line<T> where
MultiLineString<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<MultiLineString<T>> for Line<T> where
MultiLineString<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiLineString<T>) -> bool
sourceimpl<T> Intersects<MultiPoint<T>> for Line<T> where
MultiPoint<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<MultiPoint<T>> for Line<T> where
MultiPoint<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
sourceimpl<T> Intersects<MultiPolygon<T>> for Line<T> where
MultiPolygon<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<MultiPolygon<T>> for Line<T> where
MultiPolygon<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPolygon<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Line<T> where
Point<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Point<T>> for Line<T> where
Point<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<T> Intersects<Polygon<T>> for Line<T> where
Polygon<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Polygon<T>> for Line<T> where
Polygon<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Polygon<T>) -> bool
sourceimpl<T> Intersects<Rect<T>> for Line<T> where
Rect<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Rect<T>> for Line<T> where
Rect<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Rect<T>) -> bool
sourceimpl<T> Intersects<Triangle<T>> for Line<T> where
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Line<T> where
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
sourceimpl<T> LineInterpolatePoint<T> for Line<T> where
T: CoordFloat,
impl<T> LineInterpolatePoint<T> for Line<T> where
T: CoordFloat,
sourceimpl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordFloat,
impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordFloat,
sourceimpl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Line<T>
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Line<T>
type Output = Line<NT>
sourcefn map_coords(
&self,
func: impl Fn(Coordinate<T>) -> Coordinate<NT> + Copy
) -> Self::Output
fn map_coords(
&self,
func: impl Fn(Coordinate<T>) -> Coordinate<NT> + Copy
) -> Self::Output
Apply a function to all the coordinates in a geometric object, returning a new object. Read more
sourcefn try_map_coords<E>(
&self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<NT>, E> + Copy
) -> Result<Self::Output, E>
fn try_map_coords<E>(
&self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<NT>, E> + Copy
) -> Result<Self::Output, E>
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
sourceimpl<T: CoordNum> MapCoordsInPlace<T> for Line<T>
impl<T: CoordNum> MapCoordsInPlace<T> for Line<T>
sourcefn map_coords_in_place(&mut self, func: impl Fn(Coordinate<T>) -> Coordinate<T>)
fn map_coords_in_place(&mut self, func: impl Fn(Coordinate<T>) -> Coordinate<T>)
Apply a function to all the coordinates in a geometric object, in place Read more
sourcefn try_map_coords_in_place<E>(
&mut self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<T>, E>
) -> Result<(), E>
fn try_map_coords_in_place<E>(
&mut self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<T>, E>
) -> Result<(), E>
Map a fallible function over all the coordinates in a geometry, in place, returning a Result
. Read more
sourceimpl<T: CoordNum> MapCoordsInplace<T> for Line<T>
impl<T: CoordNum> MapCoordsInplace<T> for Line<T>
sourcefn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy) where
T: CoordNum,
👎Deprecated since 0.21.0: use MapCoordsInPlace::map_coords_in_place
instead which takes a Coordinate
instead of an (x,y) tuple
fn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy) where
T: CoordNum,
use MapCoordsInPlace::map_coords_in_place
instead which takes a Coordinate
instead of an (x,y) tuple
Apply a function to all the coordinates in a geometric object, in place
Examples
#[allow(deprecated)]
use geo::MapCoordsInplace;
use geo::Point;
use approx::assert_relative_eq;
let mut p = Point::new(10., 20.);
#[allow(deprecated)]
p.map_coords_inplace(|(x, y)| (x + 1000., y * 2.));
assert_relative_eq!(p, Point::new(1010., 40.), epsilon = 1e-6);
sourceimpl<T> PartialEq<Line<T>> for Line<T> where
T: PartialEq<T> + CoordNum,
impl<T> PartialEq<Line<T>> for Line<T> where
T: PartialEq<T> + CoordNum,
sourceimpl<T> PointDistance for Line<T> where
T: Float + RTreeNum,
impl<T> PointDistance for Line<T> where
T: Float + RTreeNum,
sourcefn distance_2(&self, point: &Point<T>) -> T
fn distance_2(&self, point: &Point<T>) -> T
Returns the squared euclidean distance between 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 Line<T> where
T: Float + RTreeNum,
impl<T> RTreeObject for Line<T> where
T: Float + RTreeNum,
sourceimpl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Line<F>
impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Line<F>
fn relate(&self, other: &GeometryCollection<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for GeometryCollection<F>
impl<F: GeoFloat> Relate<F, Line<F>> for GeometryCollection<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Line<F>
fn relate(&self, other: &Line<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, Line<F>> for MultiLineString<F>
impl<F: GeoFloat> Relate<F, Line<F>> for MultiLineString<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for MultiPoint<F>
impl<F: GeoFloat> Relate<F, Line<F>> for MultiPoint<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for MultiPolygon<F>
impl<F: GeoFloat> Relate<F, Line<F>> for MultiPolygon<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Point<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Polygon<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Polygon<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Rect<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Triangle<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Triangle<F>
fn relate(&self, other: &Line<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, MultiLineString<F>> for Line<F>
impl<F: GeoFloat> Relate<F, MultiLineString<F>> for Line<F>
fn relate(&self, other: &MultiLineString<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiPoint<F>> for Line<F>
impl<F: GeoFloat> Relate<F, MultiPoint<F>> for Line<F>
fn relate(&self, other: &MultiPoint<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Line<F>
impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Line<F>
fn relate(&self, other: &MultiPolygon<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Line<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Polygon<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Polygon<F>> for Line<F>
fn relate(&self, other: &Polygon<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Line<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Triangle<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Triangle<F>> for Line<F>
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
sourceimpl<T> RelativeEq<Line<T>> for Line<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<Line<T>> for Line<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
sourcefn relative_eq(
&self,
other: &Line<T>,
epsilon: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon,
max_relative: <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
) -> bool
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
Equality assertion within a relative limit.
Examples
use geo_types::{coord, Line};
let a = Line::new(coord! { x: 0., y: 0. }, coord! { x: 1., y: 1. });
let b = Line::new(coord! { x: 0., y: 0. }, coord! { x: 1.001, y: 1. });
approx::assert_relative_eq!(a, b, max_relative=0.1);
sourcefn default_max_relative() -> <Line<T> as AbsDiffEq<Line<T>>>::Epsilon
fn default_max_relative() -> <Line<T> as AbsDiffEq<Line<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> TryFrom<Geometry<T>> for Line<T> where
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for Line<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 Line<T>
impl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for Line<T>
type Output = Line<NT>
type Output = Line<NT>
use MapCoords::try_map_coords
which takes a Coordinate
instead of an (x,y) tuple
sourcefn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
fn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
use MapCoords::try_map_coords
which takes a Coordinate
instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
sourceimpl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Line<T>
impl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Line<T>
sourcefn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
fn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
use MapCoordsInPlace::try_map_coords_in_place
which takes a Coordinate
instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, in place, returning a Result
. Read more
sourceimpl<T> VincentyLength<T, Line<T>> for Line<T> where
T: CoordFloat + FromPrimitive,
impl<T> VincentyLength<T, Line<T>> for Line<T> where
T: CoordFloat + FromPrimitive,
sourcefn vincenty_length(&self) -> Result<T, FailedToConvergeError>
fn vincenty_length(&self) -> Result<T, FailedToConvergeError>
The units of the returned value is meters.
impl<T> Copy for Line<T> where
T: Copy + CoordNum,
impl<T> Eq for Line<T> where
T: Eq + CoordNum,
impl<T> StructuralEq for Line<T> where
T: CoordNum,
impl<T> StructuralPartialEq for Line<T> where
T: CoordNum,
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
sourceimpl<T, M> AffineOps<T> for M where
T: CoordNum,
M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,
impl<T, M> AffineOps<T> for M where
T: CoordNum,
M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,
sourcefn affine_transform(&self, transform: &AffineTransform<T>) -> M
fn affine_transform(&self, transform: &AffineTransform<T>) -> M
Apply transform
immutably, outputting a new geometry.
sourcefn affine_transform_mut(&mut self, transform: &AffineTransform<T>)
fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)
Apply transform
to mutate self
.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<G, T, U> Convert<T, U> for G where
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
impl<G, T, U> Convert<T, U> for G where
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
sourceimpl<'a, T, G> ConvexHull<'a, T> for G where
T: GeoNum,
G: CoordsIter<'a, Scalar = T>,
impl<'a, T, G> ConvexHull<'a, T> for G where
T: GeoNum,
G: CoordsIter<'a, Scalar = T>,
type Scalar = T
fn convex_hull(&'a self) -> Polygon<T>
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<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>,
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>,
sourcefn rotate_around_centroid(&self, degrees: T) -> G
fn rotate_around_centroid(&self, degrees: T) -> G
sourcefn rotate_around_centroid_mut(&mut self, degrees: T)
fn rotate_around_centroid_mut(&mut self, degrees: T)
Mutable version of Self::rotate_around_centroid
sourcefn rotate_around_center(&self, degrees: T) -> G
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
sourcefn rotate_around_center_mut(&mut self, degrees: T)
fn rotate_around_center_mut(&mut self, degrees: T)
Mutable version of Self::rotate_around_center
sourcefn rotate_around_point(&self, degrees: T, point: Point<T>) -> G
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
sourcefn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)
fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)
Mutable version of Self::rotate_around_point
sourceimpl<T, IR, G> Scale<T> for G where
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
impl<T, IR, G> Scale<T> for G where
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
sourcefn scale(&self, scale_factor: T) -> G
fn scale(&self, scale_factor: T) -> G
Scale a geometry from it’s bounding box center. Read more
sourcefn scale_xy(&self, x_factor: T, y_factor: T) -> G
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
sourcefn scale_xy_mut(&mut self, x_factor: T, y_factor: T)
fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)
Mutable version of scale_xy
.
sourcefn scale_around_point(
&self,
x_factor: T,
y_factor: T,
origin: impl Into<Coordinate<T>>
) -> G
fn scale_around_point(
&self,
x_factor: T,
y_factor: T,
origin: impl Into<Coordinate<T>>
) -> G
Scale a geometry around a point of origin
. Read more
sourcefn scale_around_point_mut(
&mut self,
x_factor: T,
y_factor: T,
origin: impl Into<Coordinate<T>>
)
fn scale_around_point_mut(
&mut self,
x_factor: T,
y_factor: T,
origin: impl Into<Coordinate<T>>
)
Mutable version of scale_around_point
.
sourceimpl<T, IR, G> Skew<T> for G where
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
impl<T, IR, G> Skew<T> for G where
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
sourcefn skew(&self, degrees: T) -> G
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
sourcefn skew_xy(&self, degrees_x: T, degrees_y: T) -> G
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
sourcefn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)
fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)
Mutable version of skew_xy
.
sourcefn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coordinate<T>>) -> G
fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coordinate<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
sourcefn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coordinate<T>>)
fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coordinate<T>>)
Mutable version of skew_around_point
.
sourceimpl<T, G> Translate<T> for G where
T: CoordNum,
G: AffineOps<T>,
impl<T, G> Translate<T> for G where
T: CoordNum,
G: AffineOps<T>,
sourcefn translate(&self, x_offset: T, y_offset: T) -> G
fn translate(&self, x_offset: T, y_offset: T) -> G
Translate a Geometry along its axes by the given offsets Read more
sourcefn translate_mut(&mut self, x_offset: T, y_offset: T)
fn translate_mut(&mut self, x_offset: T, y_offset: T)
Translate a Geometry along its axes, but in place.