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

fix(PlanarLayer): Fix delete new extent from globalExtentTMS const #2279

Open ketourneau opened 4 months ago

ketourneau commented 4 months ago

Proposed fix for #2244

Motivation and Context

When PlanarLayer is deleted, it doesn't remove extent from globalExtentTMS const. It's why we got some trouble when we try to reload itowns with new extent. It keep previous extent added to globalExtentTMS.

I don't know if it's better to reset globalExtentTMS when view is disposed or remove extent from globalExtentTMS if PlanarLayer is deleted.

I think my fix may cause a problem if two PlanarLayer use the same extent and one was deleted.

What do you think ?

jailln commented 4 months ago

Thanks for finding and correcting this bug :slightly_smiling_face:

It actually corrects the issue but I think that we need to re-think the globalExtentTMS implementation/usage as it doesn't allow to have multiple views with the same CRS and different extents at the same time.

It seems that globalExtentTMS is used for two things:

I propose that we limit the usage of globalExtentTMS to the first usecase and therefore:

WDYT @ketourneau @Desplandis ?

Disclaimer: I tried to explain my thoughts as clear as possible but we may discuss it in a voice call if needed :grin:

ketourneau commented 4 months ago

I agree with you. I also wondered whether globalExtentTMS should be used for global extent (like EPSG:3857).

jailln commented 4 months ago

I also wondered whether globalExtentTMS should be used for global extent (like EPSG:3857).

You mean we should remove it totally?

ketourneau commented 4 months ago

No, I just wanted to say that I agree with your suggestion. I'm waiting to see what you decide.

Desplandis commented 3 months ago

@jailln @ketourneau : According to @mgermerie, the root cause of this issue seems to be that tiles of the terrain (as created by the view) does not match that of an actual TMS. He detailed different solutions for this issue in the https://github.com/iTowns/itowns/issues/2290 proposal, which could fix other related issues in iTowns.

ketourneau commented 3 months ago

@Desplandis @mgermerie We also have the same error with cog example when we try to dispose view and load another cog.

If you Load 1 band sample and then Load RGB sample with this commit : https://github.com/bloc-in-bloc/itowns/commit/833fc686e2cc6227fa5262b86deeab5c6ad39382 you will got this result : Capture d’écran 2024-03-15 à 08 32 33

It's the same error, when we call view.dispose(true) it doesn't remove extent from globalExtentTMS const. So if we reload view with another extent we got problem.

Desplandis commented 3 months ago

@ketourneau Yeah I think this again a mix between the issue described in #2290 and cache coherency...