Skip to content

Part of geometries missing at tiles borders for MVT #289

Description

@robrichter

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

Activity

  1. sdlime commented on Jun 8, 2022

    @sdlime
    Member

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

  2. sdlime commented on Jun 10, 2022

    @sdlime
    Member

    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

  3. robrichter commented on Jun 13, 2022

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

  4. jratike80 commented on Jun 13, 2022

    @jratike80

    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.

  5. jratike80 commented on Jun 22, 2022

    @jratike80

    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.

  6. robrichter commented on Jun 23, 2022

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

  7. jratike80 commented on Jun 23, 2022

    @jratike80

    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.

  8. sdlime commented on Jun 23, 2022

    @sdlime
    Member

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

  9. robrichter commented on Jun 28, 2022

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

  10. sdlime commented on Jun 28, 2022

    @sdlime
    Member

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

  11. robrichter commented on Jun 30, 2022

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

  12. sdlime commented on Jul 6, 2022

    @sdlime
    Member

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

  13. theopauw commented on Nov 3, 2025

    @theopauw

    @sdlime did you ever have a chance to look at this? I think I am running into the same underlying issue.

    I am using MapLibre and I find that points very close to the tile edge completely disappear at intermediate zoom levels.

    Image Image

    If I load the same service in QGIS the points are split in half similar to the original example.

    Image

    I tried patching Mapserver to apply the EDGE_BUFFER during feature selection as well (i.e. duplicating the point between the two adjacent tiles) and this fixes the issue for me.

    Image Image

    The fix works regardless of whether the request goes directly to Mapserver or through Mapcache.

    See my patched code and example data, mapfile and maplibre html. I can submit a PR to Mapserver if this behaviour is acceptable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions