wip
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
2a6982afb0
commit
e43d8a2dd9
3 changed files with 819 additions and 20 deletions
792
Cargo.lock
generated
792
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,14 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
exclude = ["data"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
axum = "0.7.5"
|
||||||
|
axum-macros = "0.4.1"
|
||||||
gdal = { version = "0.16.0", features = ["bindgen"] }
|
gdal = { version = "0.16.0", features = ["bindgen"] }
|
||||||
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
|
serde_json = "1.0.115"
|
||||||
|
tokio = { version = "1.37.0", features = ["full"] }
|
||||||
|
tracing = "0.1.40"
|
||||||
|
tracing-subscriber = "0.3.18"
|
||||||
|
|
37
src/main.rs
37
src/main.rs
|
@ -1,11 +1,40 @@
|
||||||
|
|
||||||
mod dem;
|
mod dem;
|
||||||
|
use std::io::{self, BufRead};
|
||||||
|
|
||||||
use crate::dem::elevation_from_coordinates;
|
use crate::dem::elevation_from_coordinates;
|
||||||
|
|
||||||
|
use axum_macros::debug_handler;
|
||||||
|
use axum::{
|
||||||
|
extract::Path, http::StatusCode, routing::{get, post}, Json, Router,
|
||||||
|
};
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let lat = 46.6;
|
|
||||||
let lon = 6.;
|
|
||||||
println!("ELE {lat} {lon}: {}", elevation_from_coordinates(lat, lon))
|
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// initialize tracing
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
|
// build our application with a route
|
||||||
|
let app = Router::new()
|
||||||
|
// `GET /` goes to `root`
|
||||||
|
.route("/", get(root))
|
||||||
|
.route("/elevation/:lat/:lon", get(get_elevation));
|
||||||
|
|
||||||
|
// run our app with hyper, listening globally on port 3000
|
||||||
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||||
|
axum::serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// basic handler that responds with a static string
|
||||||
|
async fn root() -> &'static str {
|
||||||
|
"Hello, World!"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[debug_handler]
|
||||||
|
async fn get_elevation(Path((lat, lon)): Path<(f64, f64)>) -> String{
|
||||||
|
let ele = elevation_from_coordinates(lat, lon);
|
||||||
|
format!("{ele}")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue