Fix coordinate handling in nearby event and communities map#693
Fix coordinate handling in nearby event and communities map#693RisingOrange wants to merge 2 commits intoPauseAI:mainfrom
Conversation
✅ Deploy Preview for pauseai ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Wait what? I guess it kinda worked before because both sides had the wrong order? Tysm, could you do some testing with the preview by overwriting the geo response? I'm not available atm |
|
@Wituareard Okay, I'll do some more tests and add testing instructions |
|
I tested the preview by overriding the geo and calendar responses in the browser, and the nearby-event banner shows correctly with the fix in place. To sanity-check, I also compared the same intended locations in a distance calculator, once with the coordinates entered in the correct order and once with them swapped. With the correct Correct order: distance is below 100 km
Swapped order: distance is above 100 km
|



This fixes two coordinate-handling issues:
NearbyEventnow passes coordinates to@turf/distancein the correct[longitude, latitude]order, and bothNearbyEventand the communities map now handle valid0latitude/longitude values correctly.Summary
NearbyEventto pass coordinates to@turf/distancein[longitude, latitude]orderNearbyEventnull checks so valid0latitude/longitude values are handled correctly0-value edge case in the communities map initial stateWhy
NearbyEventwas building@turf/distancecoordinate tuples as[latitude, longitude], but Turf expects GeoJSON order:[longitude, latitude].It was also using falsy checks for coordinate presence. In edge cases, that can treat valid coordinates like
0latitude or0longitude as missing.The communities map had the same edge case when initializing the map center and zoom from the user location.
Evidence
distancedocs use coordinate examples in[longitude, latitude]order:https://turfjs.org/docs/7.2.0/api/distance
https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1
Notes
src/routes/communities/+page.sveltealready follows[lng, lat]ordering, which was a useful internal consistency check.pnpm checkpasses.