Fix brush filters for longitudes that lie outside the normal -180 to 180 range
Closes #41056
Description
Fix brush filter for LeafletMap.jsx to allow selecting points anywhere on the map.
- update
Leafletmap.jsxto callLatLng.wrap()to wrap longitudes infilterBoundsinto the canonical range [-180, 180]. - modify
update-lat-lon-filterso that if the filter bounds cross the 180th meridian, the filter is split into two parts covering the east and west sides with separate:insidefilters that are ORed together.
How to verify
Describe the steps to verify that the changes are working as expected.
- New question -> Sample Dataset -> People
- Visualize
- Change viz type to Pin Map
- Scroll east or west a long ways (far enough to cross the 180th meridian)
- Click
Draw box to filterbutton - Draw a box
- Filter should work
- Zoom out
- Scroll to the 180th meridian (either direction)
- Click
Draw box to filterbutton - Draw a filter box that crosses the 180th meridian.
- Unless you modify your sample DB, you won't have any points near the meridian, but if you make your box large enough you can select some points in, e.g., Alaska.
- Verify that a two-part filter is added that covers both the eastern and western hemisphere sides of your selection.
- Get crazy. Zoom out and select a region > 360º.
- Should filter to the range [-180,180].
Demo
Loom demo posted to slack here
https://metaboat.slack.com/archives/C0645JP1W81/p1738960382927599
Checklist
- [x] Tests have been added/updated to cover changes in this PR
I had to check if [-180, 180] is actually canonical. AFAICT that is the case. There are some shenanigans with the International Date Line and certain time zones, see for example when Samoa moved from UTC-11 to UTC+13 in 2011. But that's a time zone thing only; Samoa is located near 172 degrees W.
I had to check if
[-180, 180]is actually canonical. AFAICT that is the case. There are some shenanigans with the International Date Line and certain time zones, see for example when Samoa moved from UTC-11 to UTC+13 in 2011. But that's a time zone thing only; Samoa is located near 172 degrees W.
I had the same concern. AFAICT ISO 6709 is the relevant standard and seemingly common enough that assuming [-180,180] will likely fix more people than it breaks, but it's a good call out and worth checking in with @mngr to get his thoughts before merging.