Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Aug 14, 2024
1 parent 7542f50 commit 084c289
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions server/src/maps/indoor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use sqlx::{PgPool, Row};
use tracing::{error, info};

#[tracing::instrument(skip(pool))]
pub async fn fetch_indoor_maps_inside_of(pool: &PgPool, geom: Geometry) -> anyhow::Result<Vec<i64>> {
pub async fn fetch_indoor_maps_inside_of(
pool: &PgPool,
geom: Geometry,
) -> anyhow::Result<Vec<i64>> {
let filtered_groups = sqlx::query("SELECT group_id from indoor_features where ST_Contains(convex_hull::geometry, $1::geometry)")
.bind(geozero::wkb::Encode(geom))
.fetch_all(pool)
Expand Down Expand Up @@ -41,46 +44,47 @@ pub async fn get_indoor_map(
data: web::Data<crate::AppData>,
) -> HttpResponse {
let id = params.into_inner();
let map=fetch_indoor_map(&data.pool,id).await;
let geometry=match map {
let map = fetch_indoor_map(&data.pool, id).await;
let geometry = match map {
Ok(g) => g,
Err(err) => {
error!("Failed to fetch indoor map {id} because {err:?}");
return HttpResponse::InternalServerError().finish();
},
}
};
info!("fetched {geometry:?}");
HttpResponse::Ok().finish()
}


#[derive(Serialize)]
struct RemoteMap{
name:String,
url:Url,
struct RemoteMap {
name: String,
url: Url,
}

#[post("/api/maps/indoor")]
pub async fn list_indoor_maps(
web::Query(args): web::Query<Arguments>,
data: web::Data<crate::AppData>,
) -> HttpResponse {
let maps=fetch_indoor_maps_inside_of(&data.pool,args.bbox.into()).await;
let maps=match maps{
Ok(m)=>m,
let maps = fetch_indoor_maps_inside_of(&data.pool, args.bbox.into()).await;
let maps = match maps {
Ok(m) => m,
Err(e) => {
error!("could not list maps because {e:?}");
return HttpResponse::InternalServerError().body("could not get indoor maps, please try again later");
},
return HttpResponse::InternalServerError()
.body("could not get indoor maps, please try again later");
}
};
let mut response = Vec::new();
for map in maps{
response.push(RemoteMap{
name: map.to_string(),
url: format!("https://nav.tum.de/api/maps/indoor/{map}").parse().unwrap(),
for map in maps {
response.push(RemoteMap {
name: map.to_string(),
url: format!("https://nav.tum.de/api/maps/indoor/{map}")
.parse()
.unwrap(),
})
}

HttpResponse::Ok().json(response)
}

0 comments on commit 084c289

Please sign in to comment.