pub fn calculate_geometry_length(geometry: &[Coordinate]) -> f64
Expand description
Calculate the total length of a sequence of coordinates by summing the distance between consecutive coordinates.
Arguments
geometry
- A slice ofCoordinate
values representing a sequence of connected points.
Examples
use openrailwaymap_exporter::importer::overpass_importer::Coordinate;
use openrailwaymap_exporter::importer::overpass_importer::calculate_geometry_length;
let geometry = vec![
Coordinate { lat: 1.0, lon: 1.0 },
Coordinate { lat: 2.0, lon: 1.0 },
Coordinate { lat: 2.0, lon: 2.0 },
];
let length = calculate_geometry_length(&geometry);
assert_eq!(length, 221827.195);