diff --git a/src/dem.rs b/src/dem.rs index 16ed4e9..f4584eb 100644 --- a/src/dem.rs +++ b/src/dem.rs @@ -1,13 +1,8 @@ use std::borrow::{Borrow, BorrowMut}; -use std::cell::RefCell; use std::collections::HashMap; -use std::hash::Hash; -use std::path::Path; -use std::rc::Rc; -use std::sync::{Arc, RwLock}; -use tokio::sync::{Mutex, OnceCell}; +use std::sync::{Arc}; use gdal::errors::GdalError; 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}"); - //#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) { println!(">>> WILL GET {full_filename} because not in cache!"); 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_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!("PRojection: {}", ds.projection()); diff --git a/src/main.rs b/src/main.rs index 379e5fa..b9c47a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,15 @@ 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::{ - 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; @@ -54,14 +52,9 @@ async fn root() -> &'static str { } -//async fn get_elevation(State(data_set_cache): State>>, Path((lat, lon)): Path<(f64, f64)>) -> String{ #[debug_handler] async fn get_elevation(State(shared): State, 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 myele = ele.await; format!("{lat} {lon} {myele}")