feat: initial MVT ST_TileEnvelope implementation#594
Conversation
|
Note that this isn't very useful for MVT without https://postgis.net/docs/ST_AsMVTGeom.html and https://postgis.net/docs/ST_AsMVT.html equivalent implementations, but I'll get to those next. |
|
Hello! Thanks for the PR! Code looks good, but Im not sure about the testing script. We can't include code from PostGIS as it's licensed under GPL-V2. I also don't think that including 40k+ lines of tests is proportional for this function - perhaps just writing a couple of unitt-tests that check e.g. min/max zoom levels, invalid parameter errors, or that e.g. a tile at zoom 5 It's cool that you're interested in adding the other function required for creating vector tiles. I've made an attempt at this previously in this old branch. Ive been thinking of revisiting it sometime soon but it might provide more useful to you. The hard part is going to be clipping the geometries to the tile boundaries. You can use GEOS for it, but as a result of clipping you will end up with degenerate cases that GEOS will reject (e.g. line-strings with a single point), or other inconsistencies that is going to make you want to support extra buffering in the ST_AsMVTGeom function. Additionally, while somewhat less important, round-tripping everything back and forth through GEOS will be slow, and the contention on memory allocation that GEOS introduces will limit the effectiveness of DuckDBs parallelism. Therefore my plan was to first try to implement a clipping routine natively in SGL, probably some extension of Greiner-Hormann and then give ST_AsMVT and friends another shot. |
The testing script isn't from PostGIS. It just calls psql to get the answers that PostGIS would return for the same query.
OK, I like tests... Will trim the tests.
Thanks. Looks very useful.
For my use, points are essential, linestrings are important, and anything else doesn't really matter. So maybe the implementation could check points, clip linestrings, and bail to GEOS for anything more complicated. When a native SGL clipping routine is available, that could be swapped out. There is already an extra buffer in the |
|
Also it looks like the tests are failing for something unrelated to the change I'm proposing here. |
|
I hit the same failure. It seems it's better to set the base branch to v1.3.0 instead of main. |
|
I've cut down the tests, and incorporated some of the implementation from your version of ST_TileEnvelope on that branch you pointed to, since that seemed cleaner. |
|
Cool! Im retargeting this to |
|
Updated to reflect |
This is similar to the PostGIS ST_TileEnvelope function, but only supports the standard (EPSG:3857) geometry, and does not support additional margins.
|
The windows test failure looks unrelated to the change I'm making here. |
|
Thanks! The windows fail is indeed unrelated, it should hopefully go away on its own soon once we reenable vcpkg caching |
This is similar to the PostGIS ST_TileEnvelope function, but only supports the standard (EPSG:3857) geometry, and does not support additional margins. See https://postgis.net/docs/ST_TileEnvelope.html
There is extensive testing of zoom levels and tile indices, mainly generated by a script that uses PostGIS as a test oracle. The generator script is included.
There are a lot of tests. On my machine, those tests take about 3 minutes. Possibly those could be
_slow.test.