Skip to content

Commit

Permalink
editoast: fix records query for mvt tile generation
Browse files Browse the repository at this point in the history
  • Loading branch information
leovalais committed Jul 17, 2024
1 parent 1122145 commit 7a4590d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
21 changes: 4 additions & 17 deletions editoast/src/modelsv2/layers/geo_json_and_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,19 @@ pub struct GeoJsonAndData {
pub data: JsonValue,
}

#[derive(Debug)]
pub struct GeoPoint {
x: u64,
y: u64,
z: u64,
}

impl GeoPoint {
pub fn new(x: u64, y: u64, z: u64) -> Self {
Self { x, y, z }
}
}

impl GeoJsonAndData {
pub async fn get_records(
conn: &mut DbConnection,
layer: &Layer,
view: &View,
infra: i64,
geo_point: &GeoPoint,
(x, y, z): (u64, u64, u64),
) -> Result<Vec<GeoJsonAndData>, editoast_models::DatabaseError> {
let geo_json_query = get_geo_json_sql_query(&layer.table_name, view);
let records = sql_query(geo_json_query)
.bind::<Integer, _>(geo_point.z as i32)
.bind::<Integer, _>(geo_point.x as i32)
.bind::<Integer, _>(geo_point.y as i32)
.bind::<Integer, _>(z as i32)
.bind::<Integer, _>(x as i32)
.bind::<Integer, _>(y as i32)
.bind::<Integer, _>(infra as i32)
.get_results::<GeoJsonAndData>(conn)
.await?;
Expand Down
4 changes: 1 addition & 3 deletions editoast/src/views/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::map::MapLayers;
use crate::map::Tile;
use crate::modelsv2::layers::geo_json_and_data::create_and_fill_mvt_tile;
use crate::modelsv2::layers::geo_json_and_data::GeoJsonAndData;
use crate::modelsv2::layers::geo_json_and_data::GeoPoint;
use crate::RedisClient;

crate::routes! {
Expand Down Expand Up @@ -202,8 +201,7 @@ async fn cache_and_get_mvt_tile(
}

let conn = &mut db_pool.get().await?;
let records =
GeoJsonAndData::get_records(conn, layer, view, infra, &GeoPoint::new(z, x, y)).await?;
let records = GeoJsonAndData::get_records(conn, layer, view, infra, (x, y, z)).await?;

let mvt_bytes: Vec<u8> = create_and_fill_mvt_tile(layer_slug, records)
.to_bytes()
Expand Down

0 comments on commit 7a4590d

Please sign in to comment.