-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_scan.rs
More file actions
28 lines (22 loc) · 856 Bytes
/
run_scan.rs
File metadata and controls
28 lines (22 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// src/web/scan.rs
use axum::{Json, extract::State};
use serde::Deserialize;
use std::sync::{Arc, RwLock};
use crate::map_segment::MapSegment;
#[derive(Deserialize)]
pub struct ScanRequest {
from_lat: f64,
from_lon: f64,
radius: usize,
observer_height: f32,
}
pub async fn handler(
State(ms): State<Arc<RwLock<MapSegment>>>,
Json(payload): Json<ScanRequest>,
) -> Result<Json<bool>, axum::http::StatusCode> {
println!("Starting LOS map generation...");
let mut ms = ms.write().map_err(|_| axum::http::StatusCode::INTERNAL_SERVER_ERROR)?;
ms.generate_los_map(payload.from_lat, payload.from_lon, payload.radius, payload.observer_height);
println!("LOS map generated for observer at ({}, {}) radius {} height {}", payload.from_lat, payload.from_lon, payload.radius, payload.observer_height);
Ok(Json(true))
}