Skip to content

Commit

Permalink
transform final result to 4326
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Apr 1, 2024
1 parent b57ddaa commit cd7a7e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 51 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ geojson = { version = "0.24.1", features = ["geo-types"] }
rstar = "0.12.0"
sqlx = {version = "0.7.4", features = ["postgres","runtime-tokio", "macros"]}
tilejson = "0.4.1"
tile-grid = "=0.2.2"

[[bin]]
name = "maple"
Expand Down
57 changes: 6 additions & 51 deletions src/birch/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,12 @@ pub async fn shapes_not_bus(
) -> impl Responder {
let (z, x, y) = path.into_inner();

let grid = catenary::grid::Grid::wgs84();
let grid = tile_grid::Grid::wgs84();

let bbox = grid.tile_extent(z, x, y);
let bbox = grid.tile_extent(x, y, z);

let sqlx_pool_ref = sqlx_pool.as_ref().as_ref();

/*
let mvt_result = sqlx::query!("SELECT
ST_AsMVT(q, 'data', 4096, 'geom')
FROM (
SELECT
onestop_feed_id,
shape_id,
attempt_id,
color,
routes,
route_type,
route_label,
text_color,
chateau,
ST_AsMVTGeom(linestring, ST_Transform(ST_MakeEnvelope($1, $2, $3, $4, $5), 4326), 4096, 256, false) AS geom
FROM
gtfs.shapes_not_bus
WHERE
ST_Intersects(linestring, ST_Transform(ST_MakeEnvelope($1, $2, $3, $4, $5), 4326)) AND allowed_spatial_query = true
) q",bbox.minx,bbox.miny,bbox.maxx,bbox.maxy,grid.srid
).fetch_one(sqlx_pool_ref).await.unwrap();*/

let query_str = format!("
SELECT
ST_AsMVT(q, 'data', 4096, 'geom')
Expand Down Expand Up @@ -180,34 +158,11 @@ pub async fn shapes_bus(
) -> impl Responder {
let (z, x, y) = path.into_inner();

let grid = catenary::grid::Grid::wgs84();

let bbox = grid.tile_extent(z, x, y);

let grid = tile_grid::Grid::wgs84();
let bbox = grid.tile_extent(x, y, z);

let sqlx_pool_ref = sqlx_pool.as_ref().as_ref();

/*
let mvt_result = sqlx::query!("SELECT
ST_AsMVT(q, 'data', 4096, 'geom')
FROM (
SELECT
onestop_feed_id,
shape_id,
attempt_id,
color,
routes,
route_type,
route_label,
text_color,
chateau,
ST_AsMVTGeom(linestring, ST_Transform(ST_MakeEnvelope($1, $2, $3, $4, $5), 4326), 4096, 256, false) AS geom
FROM
gtfs.shapes_not_bus
WHERE
ST_Intersects(linestring, ST_Transform(ST_MakeEnvelope($1, $2, $3, $4, $5), 4326)) AND allowed_spatial_query = true
) q",bbox.minx,bbox.miny,bbox.maxx,bbox.maxy,grid.srid
).fetch_one(sqlx_pool_ref).await.unwrap();*/

let query_str = format!("
SELECT
ST_AsMVT(q, 'data', 4096, 'geom')
Expand All @@ -222,7 +177,7 @@ FROM (
route_label,
text_color,
chateau,
ST_AsMVTGeom(linestring,
ST_AsMVTGeom(ST_Transform(linestring, 4326),
ST_Transform(ST_TileEnvelope({z}, {x}, {y}),4326), 4096, 64, false) AS geom
FROM
gtfs.shapes
Expand Down

0 comments on commit cd7a7e7

Please sign in to comment.