Sample Header Ad - 728x90

Does ST_AsMVTGeom/ST_AsMVT truncate data, or is my query wrong?

1 vote
1 answer
50 views
Here's the individual activity, which is GeoJSON displayed on the map rather than doing any ST_AsMVTGeom/ST_AsMVT work: individual activity via GeoJSON Here's the result of the ST_AsMVTGeom/ST_AsMVT query: activities via ST_AsMVT If you compare the purple lines in the second image to the individual activity display in the first image, you can see how the stretch of 15th Ave S is missing in the ST_AsMVT version. I'm _decently_ certain that the underlying data for this activity is a point at the fork in the road on 15th Ave S and then another point down on E 62nd St, with no coordinates existing in between, because this person said they drew this route manually. This is query I'm running to produce the tiles (where #{z}, #{x}, #{y}, and #{id} are passed-in variables):
WITH bounds AS (
  SELECT ST_TileEnvelope(#{z}, #{x}, #{y}) AS geom
),
tile AS
(
  SELECT ST_AsMVTGeom(ST_Transform(activities.geog::geometry, 3857), bounds.geom) AS geom, id
  FROM activities, bounds
  WHERE activities.geog::geometry && ST_Transform(bounds.geom, 4326)
  AND user_id = #{id}
)
SELECT ST_AsMVT(tile, 'activities', 4096, 'geom', 'id') AS mvt
FROM tile;
- PostgreSQL 14.10 - PostGIS 3.4.0 Is there something about my query that's causing the data to be dropped and not displayed, or is this the expected result out of ST_AsMVTGeom/ST_AsMVT?
Asked by James Chevalier (111 rep)
Mar 12, 2024, 05:20 PM
Last activity: Jun 10, 2025, 11:59 PM