projecthorus / sondehub-amateur-tracker

🎈 Frontend for SondeHub Amateur Radiosonde Tracking
https://amateur.sondehub.org/
MIT License
21 stars 5 forks source link

Investigate Leaflet.Geodesic to handle antimeridian wrapping issue #75

Open darksidelemm opened 1 year ago

darksidelemm commented 1 year ago

This might be an option: https://github.com/henrythasler/Leaflet.Geodesic

The GeodesicCircle part of this might also be useful for range rings.

darksidelemm commented 1 year ago

Some quick investigations suggest this might work with the wrap:false option when creating the polyline (now L.Geodesic instead of L.Wrapped.PolyLine)

To test this, replace all instances of L.Wrapped.PolyLine with L.Geodesic, then also replace instances of L.Geodesic(point with L.Geodesic([point] to get rid of some typing errors.

However, there is some weird behaviour with long polylines in this case, e.g. in this example:

Screen Shot 2023-03-26 at 10 32 20

It looks like the polyline continues off to the right of the screen, but cannot be viewed.

darksidelemm commented 1 year ago

It looks like the only way to handle this properly is going to be to make duplicate copies of the polyline shifted by multiples (up to some limit based on when worldCopyJump kicks in) of 360 degrees... Urgh.

darksidelemm commented 1 year ago

Thoughts on next steps for this...

darksidelemm commented 1 year ago
darksidelemm commented 1 year ago

This is the result of naively adding in additional polylines at +/- 360 degrees:

Screen Shot 2023-06-04 at 09 43 09

Almost works, but we get the issue where the track crosses the antimeridian and the polyline wraps back to the left. Maybe this approach combined with Geodesic will resolve that?

darksidelemm commented 1 year ago

Switching to Leaflet.Geodesic gets us closer (VE3OCL-34, 1 month history):

Screen Shot 2023-06-04 at 10 02 32

Unfortunately things still break if the polyline wraps the antimeridian more than once (in this case VE3OCL-34, with 6 months history):

Screen Shot 2023-06-04 at 10 04 20

To handle this, I think the code need to determine how many crossings the path takes over the antimeridian, and add additional polyline copies. e.g. one pass = copies at +/- 360 degrees of longitude, 2 passes = copies at +/- 720 degrees of longitude. So I need to figure out how to track this.

Also... the creation of the duplicate polylines really needs to be conditional on the payload path crossing the antimeridian in the first place, else you end up with 'confetti' on the map, like this:

Screen Shot 2023-06-04 at 10 14 08

Anyway, the current state of this is in https://github.com/darksidelemm/sondehub-amateur-tracker/tree/antimeridian