iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.07k stars 290 forks source link

[BUG] Difference in representation of MVT between iTowns and OpenLayer #2292

Open AnthonyGlt opened 3 months ago

AnthonyGlt commented 3 months ago

It seems that iTowns is requesting one zoom level above openlayer.

Context

When we synchronize an OpenLayer view with an Itowns view, we can see that, for the same extent, we have 2 differents representations.

Steps to Reproduce (for bugs)

Open a view in openLayer with a MVT feed such as https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json

Expected Behavior

Having the same details/representation in both engine

Actual Behavior

Screenshot from 2024-03-14 15-47-51

Possible Cause/Fix/Solution

From https://wiki.openstreetmap.org/wiki/Zoom_levels, at the end: Mapbox GL based libraries uses 512×512-pixel tiles by default, so Mapbox GL zoom levels are one fewer than the zoom levels described above that are used by other tools.

it sounds a lot like the issue described here

Desplandis commented 3 months ago

The vector tiles from IGN's PLAN.IGN is distributed as a TMS, so both openlayers and itowns should have the same tiles for a given zoom level. I think your issue is caused by the fact that itowns subdivides the terrain before openlayers.

The subdivision threshold should be configurable in both GlobeView (resp PlanarView) or directly in GlobeLayer (resp. PlanarLayer). It could maybe be not exposed or documented for the end-user...

However if you decide to delay the subvision of the tile, your data may appear blurry at the default resolution of 256x256 pixels. It seems however that this resolution is hardcoded in itowns but IHMO it should set as a parameter of the Layer.

N.B. It seems that FeatureToTexture has a parameter to control the texture size however it is called with the value 256 : https://github.com/iTowns/itowns/blob/2fb3298f07a07cc1b7fb98025479da29f6f51557/src/Converter/textureConverter.js#L31

AnthonyGlt commented 3 months ago

It looks like I need to change in 3 places : https://github.com/iTowns/itowns/blob/2fb3298f07a07cc1b7fb98025479da29f6f51557/src/Converter/textureConverter.js#L31 https://github.com/iTowns/itowns/blob/2fb3298f07a07cc1b7fb98025479da29f6f51557/src/Provider/Fetcher.js#L4 Edit not the fetcher, it seems that its not used in the case of MVT https://github.com/iTowns/itowns/blob/2fb3298f07a07cc1b7fb98025479da29f6f51557/src/Process/LayeredMaterialNodeProcessing.js#L5