Skip to content

Commit

Permalink
made sure that geodata is queryable
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Aug 14, 2024
1 parent 50c6290 commit a3e93af
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 0 deletions.
165 changes: 165 additions & 0 deletions server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ time = "0.3.36"
polars = { version = "0.41.3", features = ["dtype-struct", "parquet"] }
#polars = { git = "https://github.com/CommanderStorm/polars.git", branch = "serialisation-experiment", features = ["parquet", "serde", "dtype-full"] }

# geodata
geo = "0.28.0"
geozero = { version = "0.13.0", features = ["with-postgis-sqlx", "with-geojson"] }
geo-types = "0.7.13"

[dev-dependencies]
insta = { version = "1.39.0", features = ["json", "redactions", "yaml"] }
pretty_assertions = "1.4.0"
Expand Down Expand Up @@ -111,3 +116,8 @@ similar.opt-level = 3
ignored = [
"rustls", # we need to configure between ring and aws crypto library
]

[patch.crates-io]
# needs release after 0.13
# https://github.com/georust/geozero/tags
geozero = { git = "https://github.com/georust/geozero.git", rev = "f8ab4363b0660cd84a58212039651fd68c3a8567" }
16 changes: 16 additions & 0 deletions server/src/maps/indoor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use sqlx::{PgPool, Row};
#[tracing::instrument(skip(pool))]
pub async fn list_indoor_inside_of(pool:&PgPool) ->anyhow::Result<Vec<i64>>{
let geom: geo_types::Geometry<f64> = geo::Point::new(10.0, 20.0).into();
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)
.await?;
let mut filtered_group_ids =Vec::<i64>::new();
for group in filtered_groups {
let group_id = group.get_unchecked(0);
filtered_group_ids.push(group_id);
}

Ok(filtered_group_ids)
}
1 change: 1 addition & 0 deletions server/src/maps/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod fetch_tile;
pub(crate) mod overlay_map;
pub(crate) mod overlay_text;
mod indoor;

0 comments on commit a3e93af

Please sign in to comment.