Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Created December 16, 2023 17:17
Show Gist options
  • Save mhkeller/05d7eafc43966a2b3b5b2d41784b300b to your computer and use it in GitHub Desktop.
Save mhkeller/05d7eafc43966a2b3b5b2d41784b300b to your computer and use it in GitHub Desktop.
WITH tilebounds (geom) AS (SELECT ST_TileEnvelope($1, $2, $3)),
query AS (
SELECT ST_Makeline(geom ORDER BY field_order) as geom FROM path_test
)
SELECT ST_AsMVT(q, 'default', 4096, 'mvtgeom')
FROM (
SELECT
*,
ST_AsMVTGeom(
ST_Transform(query.geom, 3857),
tileBounds.geom,
4096,
256,
true
) mvtgeom
FROM query, tilebounds
WHERE ST_Transform(query.geom, 3857) && tilebounds.geom
) q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment