#altitude #elevation

coordinate-altitude

Fetch altitude/elevation for geographical coordinates of planet Earth

1 unstable release

0.1.0 Jul 5, 2024

#154 in Geospatial

MIT license

14KB
217 lines

coordinate-altitude

fetch altitude/elevation data for a coordinate of planet Earth

example

after cargo add coordinate_altitude, do

use coordinate_altitude::*;

fn main() {
    // coordinate as a tuple
    let coord: (f64, f64) = (34.324, 1.88832);
    // coordinate as a `Coord`
    let coord: Coord = coord.into();
    // and finally fetch altitude for `coord`
    let coord: Option<Coord> = coord.fetch_altitude();
    println!("coordinate: {coord:?}");
}

see examples for more

warning!

open-elevation is only 6 decimal places accurate eg.: 32.324325435 will become 32.324325

dependencies


lib.rs:

Get altitude/elevation data for geographical coordinates of planet Earth

WARNING

every latitude, longitude data will be rounded to 6 decimal places accuracy by open-elevation api

Usage

use coordinate_altitude::*;

// fetch altitude for a single `Coord`
// could also be a tuple for example, and later converted into Coord
// let coord: (f64, f64) = (34.324, 1.88832);
// let coord: Coord = coord.into();
// coordinate as a `Coord`
let coord = Coord::new(34.324, 1.88832);
// and finally fetch altitude for `coord`
let coord: Option<Coord> = coord.fetch_altitude();
println!("coordinate: {coord:?}");


// add altitude for a `Vec<Coord>`
let mut coords: Vec<Coord> = vec![   
    (58.2926289, 134.3025286).into(),   // Sheep Mountain
    (7.4894883, 80.8144869).into(),     // Sri Lanka
    Coord::new(47.0745464, 12.6938825), // Großglockner
];
add_altitude(&mut coords);
println!("coordinates: {coords:#?}");
  • you could also add altitude for a single Coord
  • or fetch altitude for a Vec<Coord>
  • you can easily impl From<YourWayOfStoringCoordinates> for Coord, see tests/integ.rs

Dependencies

~10–18MB
~356K SLoC