mapcache
mapcache copied to clipboard
Part of geometries missing at tiles borders for MVT
We are serving MVT via Mapcache/Mapserver. Problem is that part of geometires at tiles borders are missing. We tried to use meta_buffer to solve the problem but its not implemented for raw format. Is there some workaround?

I suspect this is more of a MapServer issue. What version are you using? Do you have a test case?
Thinking about this more - @robrichter, could this be a client/rendering issue? I mean, the MVT file just contains the point coordinate and not the symbol, so the clipping is a rendering artifact. There is an edge buffer used as part of the production - it's set in the MVT output format:
OUTPUTFORMAT
NAME "mvt"
DRIVER MVT
FORMATOPTION "EDGE_BUFFER=20" # default is 10
END
You could try bumping that value and see what happens.
--Steve
Problem doesn't seem to be Mapcache related.
Our Mapfile:
OUTPUTFORMAT
NAME "mvt"
DRIVER MVT
MIMETYPE "application/x-protobuf"
EXTENSION "pbf"
FORMATOPTION "EDGE_BUFFER=20"
END
I tried increasing edge buffer and nothing changed. So I tried to omit Mapcache and request Mapserver directly via /mapserv?map=mvt.map&LAYERS=reports&MODE=tile&TILEMODE=gmap&TILE=1104+692+11&FORMAT=mvt
The problem remained.
I tried changing edge buffer from 0 to 1000 and request the same tile. All created pbf files had the exactly same size. It seems that buffer is ignored. Any idea what am I doing wrong? I have MapServer version 7.6.4
What software is doing the rendering part? It seems that the circle symbol in one tile is rendered correctly but then the adjacent tile is rendered on top of that layer and the the polygon fill paints partly over the symbol.
I do not know how these issues are usually handled on the client side vector tile rendering. The result should be good if all the polygon layers would be rendered first for all tiles, and the POI layer would be painted last.
This issue https://github.com/Leaflet/Leaflet.VectorGrid/issues/149 looks pretty similar.
I cannot read https://github.com/MapServer/MapServer/blob/01d0e7cfb9f92542a578704439edfc713e041d06/mapmvt.c well enough to say if EDGE_BUFFER is also increasing the rectangle that is used to do SELECT with ST_Intersects so that the points which are close to the tile borders get selected into both adjacent tiles. Lines and polygons do not need extended BBOX for selecting, just for clipping.
Is that OpenLayers? We got a report about labels which were cut at the MVT tile boundaries. We noticed that an application that was using MapLibre GL JS was showing labels fine but OpenLayers did not. We could correct the label issue by using an option "declutter": true. https://openlayers.org/en/latest/apidoc/module-ol_layer_VectorTile-VectorTileLayer.html. Maybe it could help also with symbols.
A possible lesson to learn is that because vector tiles are rendered on the client side then also the reason for the rendering issues may be in the client. Of course data can have an effect as well.
Yes, we use OpenLayers. But we also tried T-REX as mvt source with exactly same Postgis data. We used buffer_size=30. Everything worked fine. As I mentioned in my previous post, it seems to me that edge buffer in Mapserver is not working at all for us.
We tried to use option "declutter": true on OpenLayers client and the results are strange. Some points were missing in lower zooms and started to appear when zooming in. And it also badly affected styling. Only some points were styled the rest remained blank, see screenshot below.

You can open the .pbf tile files with QGIS as a plain vector layer (Layer-Add Layer-Add vector layer). Save the two adjacent .pbf tiles on disk and check if the problematic point is included only into one tile. If that is the case you are right with your assumption about edge buffer. You can by the same study if it happens to have some effect on lines and polygons.
I'd like to look into this more but need a test case if possible.
@sdlime Thanks What do you need to prepare for the test case? I created github repo with mapcache config, mapfile and sql dump. Is that enough?
https://github.com/robrichter/mapcache-mvt-test
@sdlime Thanks What do you need to prepare for the test case? I created github repo with mapcache config, mapfile and sql dump. Is that enough?
https://github.com/robrichter/mapcache-mvt-test
Data is great. A simple client setup would also be helpful - a skeleton OpenLayers page.
There is OL client example https://codesandbox.io/s/vector-tiles-openlayers-memj5x?file=/main.js
Please let me know if it is sufficient
Thanks, will try to get that running on a dev box.