[postgis-devel] Proposal: Adding buffer parameter to ST_TileEnvelope()

Yuri Astrakhan yuriastrakhan at gmail.com
Wed Nov 13 06:10:15 PST 2019


Wrapping would look like this for srid=3857, and more complex for other
srids (assuming my math is correct). I think having it as part of the
ST_TileEnvelope will simplify this very common use case, avoid errors, and
will run faster.

ST_Expand(
  ST_TileEnvelope(:zoom, :x, :y),
  20037508.34 * 2 / (2 ^ :zoom) / :extent * :buffer
)

Both :extent and :buffer are defined in ST_AsMVTGeom().

Note that the same argument could have been used for ST_TileEnvelope()
itself -- it can be easily implemented with a short function. but it was
implemented as a native PostGIS function because of how frequently it is
used.
https://github.com/mapbox/postgis-vt-util/blob/master/src/TileBBox.sql#L17


On Wed, Nov 13, 2019 at 4:31 AM Felix Kunde <felix-kunde at gmx.de> wrote:

> What speaks against ST_Expand(ST_TileEnvelope ... ?
>
> *Gesendet:* Mittwoch, 13. November 2019 um 07:06 Uhr
> *Von:* "Yuri Astrakhan" <yuriastrakhan at gmail.com>
> *An:* "PostGIS Development Discussion" <postgis-devel at lists.osgeo.org>
> *Betreff:* [postgis-devel] Proposal: Adding buffer parameter to
> ST_TileEnvelope()
> Would it make sense to add a `buffer` parameter to ST_TileEnvelope(),
> similar to ST_AsMVTGeom() ?
>
> To my understanding, ST_TileEnvelope common use case is to create a bbox
> filter -- to get just the relevant data before packaging it with
> ST_AsMVT().  This works well for the line and polygon geometries, but when
> dealing with point data, e.g. city names, one has to increase that bbox by
> a significant margin (e.g. half of the tile size) in order to capture
> labels from the neighboring tiles and prevent label clipping.
>
> I think this use case is common enough to add buffer parameter to
> ST_TileEnvelope - where it would increase the bbox size by the the
> given distance in tile coordinate space.
>
> Proposed additional signature:
>
> geometry ST_TileEnvelope(integer tileZoom, integer tileX, integer tileY,
> integer buffer=0, geometry bounds=...);
>
> (Would existing method signature without the buffer param conflict if the
> buffer is added before the existing bounds param? They are of different
> type.)
> _______________________________________________ postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20191113/a2da691e/attachment.html>


More information about the postgis-devel mailing list