https://postgis.net/docs/ST_AsMVT.html https://postgis.net/docs/ST_AsMVTGeom.html
Animation showing how the process works https://info.crunchydata.com/hs-fs/hubfs/unnamed.gif
Available on RDS Postgres as of the 10.5 release which includes the required libprotobuf-c
Documentation of a group discussion about options
Heavily influenced by the Vector Tiles Recommentations document https://docs.google.com/document/d/1H-CDMLR_4cy5hyE5SomWtTInvqNhipRWGYay5gcuJJ4/
opensupplyhub/open-apparel-registry#730
opensupplyhub/open-apparel-registry#755 Aggregating at low zooms by dividing each tile into subtiles 3 zoom layers down
opensupplyhub/open-apparel-registry#797 "Why is that map broken" -- Deb's husband
Discussed several options at RRP (listed in the PR)
Several PostGIS hex grid implementations available. I found this one to be the simplest to implement and understand. Arguments are box and hex size. https://gist.github.com/mjumbewu/1761802ea06fb78c596f9cf8c9b2e769
opensupplyhub/open-apparel-registry#839 Putting 4326 geometries in the grid caused problems at low zooms Bug in the hex grid at 180. Work around.
The final tiler implementation https://github.com/open-apparel-registry/open-apparel-registry/blob/e84c3e1d123ded50093d8c7fdbe542410d9d0990/src/django/api/tiler.py
The supporting filter method https://github.com/open-apparel-registry/open-apparel-registry/blob/e84c3e1d123ded50093d8c7fdbe542410d9d0990/src/django/api/models.py#L964-L1039
Cache buster in the URL that can be incremented on demand Far-future expires headers
One desktop browser is going to make ~16 tile requests for an initial map load. Try to get query speed in the 10ms order of magnitude
In our filter case we are fortunate that Django is generating an IN clause with IDs rather than joining multiple tables. Simplifies SQL string manipulation.
Two different buffers. The MVT tile buffer and the buffer uses when querying features.
PostGIS 3 has a performance boost https://info.crunchydata.com/blog/waiting-for-postgis-3-st_asmvt-performance