maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.24k stars 639 forks source link

tileMargin not working anymore? #649

Closed geoportallux closed 1 year ago

geoportallux commented 1 year ago

we have a project using tileserver-gl 3.1.1 and the rendering is fine.

We use tileMargin : 10 to render texts properly in the raster version.

https://vectortiles.geoportail.lu/styles/topomap/?raster

image

We now wanted to upgrade to 4.2.0 and this does not seem to work anymore?

image

We use the docker version in both cases and we mount the same volumes.

Is this a known issue? Is there anything I can change in the config to make it work again

acalcutt commented 1 year ago

I'll have to look how that option gets used and get back to you. Does it work without that tileMargin option set? I thought' tile mode', which is enabled by default, already has a bigger margin.

I fixed a similar issue to this in maplibre-gl-native, which fixed the switch for tile mode ( https://github.com/maplibre/maplibre-gl-native/issues/284 ) , but that particular issue should be resolved.

geoportallux commented 1 year ago

Setting tileMargin or not, or setting it to any value does not make any difference, whereas this worked correctly in v3.1.1

acalcutt commented 1 year ago

I tried to replicate this a bit today by taking your topmap style and throwing in some of my own data layers here https://tiles.wifidb.net/styles/topomap/?raster#13/49.6579/6.1510

But when I look at this, the labels seem fine. Are you able to see the issue at my url? This is with the latest v4.3.2 image (note, my hillshade/contour layers aren't quite the same so it looks a bit faded, but the labels look ok)

acalcutt commented 1 year ago

can you post your config? Any difference in 4.3.2 over 4.2.0?

geoportallux commented 1 year ago

Hi, here is the content of my test folder:

https://download.geoportail.lu/index.php/s/i3rrYEHHEkZXYtA/download

and the command I am using:

docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl:v4.3.2

This url: http://localhost:8080/styles/topomap/?raster#12/49.6483/6.2686 then shows this:

image
acalcutt commented 1 year ago

I tested this out and can confirm I see this issue when using the files you provided. I also noticed at the command line it gets this error I am a bit familiar with from https://github.com/acalcutt/tileserver-gl/issues/5

mlgl: {
  class: 'General',
  severity: 'WARNING',
  text: 'Provided camera options returned 4 tiles, only 11/1058/697=>11 is taken in Tile mode.'
}

This is an issue I dealt with for static images, which related a change in mapbox-native that was made before it was forked to maplibre-native here https://github.com/mapbox/mapbox-gl-native/commit/9ceb619940901d06909f7d6d0fc4a4e64572d228 . This change was made after the last mapbox-native node release that was used in v3.1.1

I tried to convince the maplibre-native team this was a bug in https://github.com/maplibre/maplibre-gl-native/issues/479 and tried to revert that change, but I wasn't able to convince them tile mode should return more than one tile. For the static image mode I work around it by making a rendering pool that was not in tile mode, but that workaround wouldn't work here I don't think.

In testing I focused on these two images http://localhost:8080/styles/topomap/12/2117/1394.png http://localhost:8080/styles/topomap/12/2118/1394.png

they look like this image

I tested reverting ( https://github.com/mapbox/mapbox-gl-native/commit/9ceb619940901d06909f7d6d0fc4a4e64572d228 ) in @acalcutt/maplibre-gl-native@6.0.2-pre.0 and can see it seems to fix the issue. the images after reverting that look like this image

While I think I know the cause to this, it is going to take some convincing the maplibre-native team that this is really a bug that should be fixed.

acalcutt commented 1 year ago

Also, after reading my old posts. One issue with reverting that change was it broke a macos test... specifically the one I was using to illistrate the issue, tile-avoid-edges.

Looks like that is still and issue from https://github.com/acalcutt/maplibre-gl-native/actions/runs/3689607045/jobs/6245737704

acalcutt commented 1 year ago

tileMargin should work in v4.4.0. It should be fixed by https://github.com/maptiler/tileserver-gl/pull/694

Let me know if it works for you.

acalcutt commented 1 year ago

I've retested with your test data and it looked good

image

geoportallux commented 1 year ago

Thanks for the fix. It looks good indeed.

Only if you zoom in a bit further, you will still find this guy:

image

In v3.1.1 this text was omitted as it cannot be placed.

image

In v4.4.0, it is omitted on tile but not on the other

acalcutt commented 1 year ago

The only thing I can say for that one is maybe try increasing your tilemargin until that goes away. in 3.1.1 tile mode acted a bit different (like I pointed out above). the workaround I made makes it use static mode when a tilemargin is set to get around that issue, but if the margin isn't big enough you would see some clipping.

acalcutt commented 1 year ago

For example, if I set the tileMargin to 30 I get something like your 3.1.1 image

image

acalcutt commented 1 year ago

I should add, this is the maplibre thread where we discussed this issue https://github.com/maplibre/maplibre-gl-native/issues/644

I consider the current solution to be a workaround. The maplibre-native people seem to think this is an issue with the source mbtiles file. I think 'tile mode' is no longer working properly since being restricted to a single tile, but I can't get them to agree with me on that. they say the purpose of tile mode is to return one tile, so it does not need to work with more than one tile. While I do agree that tile mode should return one tile, based on my reading I feel its main purpose was to consider surrounding tiles, so labels that go across boundaries wouldn't be clipped like this.