Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part of geometries missing at tiles borders for MVT #289

Open
robrichter opened this issue Jun 8, 2022 · 12 comments
Open

Part of geometries missing at tiles borders for MVT #289

robrichter opened this issue Jun 8, 2022 · 12 comments

Comments

@robrichter
Copy link

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?

image

@sdlime
Copy link
Member

sdlime commented Jun 8, 2022

I suspect this is more of a MapServer issue. What version are you using? Do you have a test case?

@sdlime
Copy link
Member

sdlime commented Jun 10, 2022

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

@robrichter
Copy link
Author

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

@jratike80
Copy link

jratike80 commented Jun 13, 2022

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 Leaflet/Leaflet.VectorGrid#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.

@jratike80
Copy link

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.

@robrichter
Copy link
Author

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.

obrazek

@jratike80
Copy link

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.

@sdlime
Copy link
Member

sdlime commented Jun 23, 2022

I'd like to look into this more but need a test case if possible.

@robrichter
Copy link
Author

@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
Copy link
Member

sdlime commented Jun 28, 2022

@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.

@robrichter
Copy link
Author

There is OL client example
https://codesandbox.io/s/vector-tiles-openlayers-memj5x?file=/main.js

Please let me know if it is sufficient

@sdlime
Copy link
Member

sdlime commented Jul 6, 2022

Thanks, will try to get that running on a dev box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants