works
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
0507a4d7d7
commit
6338feea30
2 changed files with 5 additions and 31 deletions
21
src/dem.rs
21
src/dem.rs
|
@ -1,13 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
use std::borrow::{Borrow, BorrowMut};
|
use std::borrow::{Borrow, BorrowMut};
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::hash::Hash;
|
use std::sync::{Arc};
|
||||||
use std::path::Path;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::{Arc, RwLock};
|
|
||||||
use tokio::sync::{Mutex, OnceCell};
|
|
||||||
|
|
||||||
use gdal::errors::GdalError;
|
use gdal::errors::GdalError;
|
||||||
use gdal::Dataset;
|
use gdal::Dataset;
|
||||||
|
@ -95,16 +90,6 @@ pub async fn elevation_from_coordinates(dsc: DSC, lat: f64, lon: f64) -> f64 {
|
||||||
println!("file for {lat} {lon} is {full_filename}");
|
println!("file for {lat} {lon} is {full_filename}");
|
||||||
|
|
||||||
|
|
||||||
//#let ds = dsc.lock().unwrap().get_dataset_for_filename(full_filename);
|
|
||||||
//let ds: &Dataset;
|
|
||||||
//{
|
|
||||||
// //let dd = dsc.lock().await.get_dataset_for_filename(full_filename).clone();
|
|
||||||
// let dd = dsc.lock().await.db.get(&full_filename).unwrap();
|
|
||||||
// ds = dd;
|
|
||||||
// //ds = cache.await.get_dataset_for_filename(full_filename);
|
|
||||||
//}
|
|
||||||
//let x = dsc.get_dataset_for_filename(full_filename);
|
|
||||||
|
|
||||||
if !dsc.contains_key(&full_filename) {
|
if !dsc.contains_key(&full_filename) {
|
||||||
println!(">>> WILL GET {full_filename} because not in cache!");
|
println!(">>> WILL GET {full_filename} because not in cache!");
|
||||||
let ds = Arc::new(MyDataset{ds:Dataset::open(full_filename.clone()).unwrap()});
|
let ds = Arc::new(MyDataset{ds:Dataset::open(full_filename.clone()).unwrap()});
|
||||||
|
@ -114,10 +99,6 @@ pub async fn elevation_from_coordinates(dsc: DSC, lat: f64, lon: f64) -> f64 {
|
||||||
let ds = &dsc.get(&full_filename).await.unwrap().ds;
|
let ds = &dsc.get(&full_filename).await.unwrap().ds;
|
||||||
|
|
||||||
|
|
||||||
//let ds = dsc.get_dataset_for_filename(full_filename);
|
|
||||||
|
|
||||||
|
|
||||||
//let ds = Dataset::open(full_filename).unwrap();
|
|
||||||
println!("This {} is in '{}' and has {} bands.", ds.driver().long_name(), ds.spatial_ref().unwrap().name().unwrap(), ds.raster_count());
|
println!("This {} is in '{}' and has {} bands.", ds.driver().long_name(), ds.spatial_ref().unwrap().name().unwrap(), ds.raster_count());
|
||||||
println!("PRojection: {}", ds.projection());
|
println!("PRojection: {}", ds.projection());
|
||||||
|
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -1,17 +1,15 @@
|
||||||
|
|
||||||
mod dem;
|
mod dem;
|
||||||
use std::{borrow::Borrow, collections::HashMap, io::{self, BufRead}, sync::{Arc, RwLock}};
|
|
||||||
use tokio::sync::Mutex;
|
|
||||||
use tracing_subscriber::registry::Data;
|
|
||||||
|
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use axum_macros::debug_handler;
|
use axum_macros::debug_handler;
|
||||||
use axum::{
|
use axum::{
|
||||||
body::Bytes, extract::{Path, State}, http::StatusCode, routing::{get, post}, Json, Router
|
extract::{Path, State}, http::StatusCode, routing::{get}, Router
|
||||||
};
|
};
|
||||||
use dem::{DatasetCache, MyDataset};
|
use dem::{MyDataset};
|
||||||
|
|
||||||
use gdal::Dataset;
|
|
||||||
use moka::future::Cache;
|
use moka::future::Cache;
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,14 +52,9 @@ async fn root() -> &'static str {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//async fn get_elevation(State(data_set_cache): State<Arc<RwLock<DatasetCache>>>, Path((lat, lon)): Path<(f64, f64)>) -> String{
|
|
||||||
#[debug_handler]
|
#[debug_handler]
|
||||||
async fn get_elevation(State(shared): State<DSC>, Path((lat, lon)): Path<(f64, f64)>) -> String{
|
async fn get_elevation(State(shared): State<DSC>, Path((lat, lon)): Path<(f64, f64)>) -> String{
|
||||||
|
|
||||||
// let x = AppState::default();
|
|
||||||
// x.db.get("hello");
|
|
||||||
|
|
||||||
|
|
||||||
let ele = dem::elevation_from_coordinates(shared, lat, lon);
|
let ele = dem::elevation_from_coordinates(shared, lat, lon);
|
||||||
let myele = ele.await;
|
let myele = ele.await;
|
||||||
format!("{lat} {lon} {myele}")
|
format!("{lat} {lon} {myele}")
|
||||||
|
|
Loading…
Reference in a new issue