Add anti-meridian support by rendering multiple world copies in WebGL2#388
Add anti-meridian support by rendering multiple world copies in WebGL2#388ZwaarContrast wants to merge 1 commit intoallmaps:developfrom
Conversation
fd8044f to
da290f1
Compare
|
Thank you for this very complete PR, @ZwaarContrast ! Firs off, and for historic reference: we were doing something similar than the wrapping you are proposing here before fixing the rendering over the anti-meridian, see And related info: the anti-meridian rendering seems to work now for MapLibre but not for OpenLayers. I'll be looking at that in the coming days first. Maybe we switch away from using geo coordinates in the process altogether, which could impact this PR. But this PR is not a fix for anti-meridian rendering but rather extending functionality to rendering multiple copies. Let's first consider what is the desirable behavior here. I'd say: Hard requirements:
Open questions:
Maybe you have other cases you think of, or this behaviour is prescribed in one of the plugins. Please share! We must also take into consideration that the plugins behave differently, with their own settings on allowing panning across the anti-meridian for 'global' projections (this makes no sence on say a 'RD new' projection), and whether features should be copied then. And finally, we are considering to (also) build a tiled warpedmaplayer, i.e. render a webgl image per tile, and not just one for the entire viewport. This approach would make rendering multiple copies very easy, and could maybe be the preferred approach for this problem? |
|
Thanks for the thorough review Manuel, really helpful context! I want to clarify what this PR fixes, because I think it's a different problem from the Bering Strait case. What this PR fixes: When panning past the antimeridian in OpenLayers, maps disappear. OL's viewState.center grows unbounded past ±20037508 by design, so maps at primary world coordinates end up off-screen. What this PR does NOT fix: Maps whose GCPs span both sides of the antimeridian. As you mentioned, that would need changes at the annotation/editor level, which is a different problem from what this PR tackles. I think the OL antimeridian issue you're planning to look at might actually be this same problem. Your +over fix in 2a21ede works for MapLibre (verified locally), but not for OL. The multi-world rendering loop in this PR follows the same pattern OL's own vector/tile layers use internally for wrapX. I couldn't find a simpler OL-side fix since the View intentionally leaves the center unbounded. Note: the multi-world rendering currently only activates for Mercator projections. For other projections it falls back to a single render pass, so there's no risk of breaking non-Mercator use cases as far as I can see. I agree multi-world rendering should be optional per map (like wrapX), and I'd be interested to hear more about the tiled renderer approach. Happy to rework the PR once the direction is clearer. Also spotted a small bug while I was going through the code: getLonLatDefinition and getWebMercatorDefinition are both missing a return on the over: false branch. Currently dormant since everything defaults to over: true, but opened a fix: #400. |
Summary
Files changed