<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’m trying to use ST_AsMVT to respond to client tile requests with MVT-fromatted response.</div><div class=""><br class=""></div><div class="">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):</div><div class=""><a href="https://github.com/mapbox/postgis-vt-util/blob/master/postgis-vt-util.sql#L541" class="">https://github.com/mapbox/postgis-vt-util/blob/master/postgis-vt-util.sql#L541</a></div><div class=""> </div><div class="">When I use it's output geometry as a BBox parameter for ST_AsMVT function, I get an error:</div><div class=""><br class=""></div><div class="">[XX000] ERROR: mvt_agg_init_context: bounds must be square</div><div class=""><br class=""></div><div class="">Both CRS of BBox and the input geometry is 3857.</div><div class="">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)...</div><div class="">In all other cases ST_AsMVT returns this error. </div><div class="">I guess the returned BBox geometry is absolutely square only when x = y.</div><div class=""><br class=""></div><div class="">But how can I calculate the proper bounding box for each tile request? </div><div class="">TileBBox function looks pretty straightforward. Looks like there are no errors in it.</div></body></html>