Opened 6 months ago

Closed 6 days ago

Last modified 6 days ago

#5758 closed defect (fixed)

Documentation bug in SQL query example for ST_AsMVTGeom

Reported by: azakh Owned by: robe
Priority: medium Milestone: PostGIS 3.5.1
Component: documentation Version: 3.4.x
Keywords: MVT, ST_AsMVTGeom Cc:

Description

Currently:

SELECT ST_AsMVTGeom(
            ST_Transform( geom, 3857 ),
            ST_TileEnvelope(12, 513, 412), extent => 4096, buffer => 64) AS geom
  FROM data
  WHERE geom && ST_TileEnvelope(12, 513, 412, margin => (64.0 / 4096))

Should be:

SELECT ST_AsMVTGeom(
            ST_Transform( geom, 3857 ),
            ST_TileEnvelope(12, 513, 412), extent => 4096, buffer => 64) AS geom
  FROM data
  WHERE ST_Transform(geom, 3857) && ST_TileEnvelope(12, 513, 412, margin => (64.0 / 4096))

Namely, the geom column should be transformed both in SELECT and WHERE clauses.

Related issue: https://trac.osgeo.org/postgis/ticket/5198

Change History (5)

comment:1 by robe, 6 months ago

I think it's better to transform the ST_TileEnvelope rather than the geom, cause otherwise no index would be used unless there is a functional index on the ST_Transform(geom,3857)

-- this assumes the geom has a 4326 srid
SELECT ST_AsMVTGeom(
            ST_Transform( geom, 3857 ),
            ST_TileEnvelope(12, 513, 412), extent => 4096, buffer => 64) AS geom
  FROM data
  WHERE geom && ST_Transform(ST_TileEnvelope(12, 513, 412, margin => (64.0 / 4096)),4326)

@pramsey @mdavis - you agree?

comment:2 by pramsey, 4 months ago

Milestone: PostGIS 3.4.3PostGIS 3.4.4

comment:3 by robe, 7 days ago

Milestone: PostGIS 3.4.4PostGIS 3.5.1

comment:4 by Regina Obe <lr@…>, 6 days ago

Resolution: fixed
Status: newclosed

In 460c1e9/git:

Fix ST_AsMVTGeom example. Closes #5758 for PostGIS 3.5.1

comment:5 by Regina Obe <lr@…>, 6 days ago

In c9e5e238/git Fix ST_AsMVTGeom example. Closes #5758 for PostGIS 3.6.0

Last edited 6 days ago by robe (previous) (diff)
Note: See TracTickets for help on using tickets.