[postgis-users] ST_AsMVT returns an error when calculating tile bbox from x, y, z

Nikolai Bezdna mofoyoda at gmail.com
Sat Nov 26 00:59:34 PST 2016


I’m trying to use ST_AsMVT to respond to client tile requests with MVT-fromatted response.

From the client side I’m getting standard web mercator tile coordinates as z, x, y. To transfer these numbers to proper BBox, I’m using this Mapbox helper function for PostGIS (TileBBox):
https://github.com/mapbox/postgis-vt-util/blob/master/postgis-vt-util.sql#L541 <https://github.com/mapbox/postgis-vt-util/blob/master/postgis-vt-util.sql#L541>
 
When I use it's output geometry as a BBox parameter for ST_AsMVT function, I get an error:

[XX000] ERROR: mvt_agg_init_context: bounds must be square

Both CRS of BBox and the input geometry is 3857.
ST_AsMVT runs without this error only when x and y are the same, e.g: ST_AsMVT('test’, TileBBox(10, 1279, 1279), 4096, 0, false, ‘geom’, q)...
In all other cases ST_AsMVT returns this error. 
I guess the returned BBox geometry is absolutely square only when x = y.

But how can I calculate the proper bounding box for each tile request? 
TileBBox function looks pretty straightforward. Looks like there are no errors in it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20161126/965c5bdf/attachment.html>


More information about the postgis-users mailing list