Trait Length

Source
pub trait Length<F: CoordFloat> {
    // Required method
    fn length(&self, geometry: &impl LengthMeasurable<F>) -> F;
}
Expand description

Calculate the length of a Line, LineString, or MultiLineString using a given metric space.

§Examples

use geo::algorithm::line_measures::{Length, Euclidean, Haversine};

let line_string = geo::wkt!(LINESTRING(
    0.0 0.0,
    3.0 4.0,
    3.0 5.0
));
assert_eq!(Euclidean.length(&line_string), 6.);

let line_string_lon_lat = geo::wkt!(LINESTRING (
    -47.9292 -15.7801f64,
    -58.4173 -34.6118,
    -70.6483 -33.4489
));
assert_eq!(Haversine.length(&line_string_lon_lat).round(), 3_474_956.0);

Required Methods§

Source

fn length(&self, geometry: &impl LengthMeasurable<F>) -> F

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F: CoordFloat, PointDistance: Distance<F, Point<F>, Point<F>>> Length<F> for PointDistance