Skip to content

Fix coordinate handling in nearby event and communities map#693

Open
RisingOrange wants to merge 2 commits intoPauseAI:mainfrom
RisingOrange:fix/nearby-event-coordinates
Open

Fix coordinate handling in nearby event and communities map#693
RisingOrange wants to merge 2 commits intoPauseAI:mainfrom
RisingOrange:fix/nearby-event-coordinates

Conversation

@RisingOrange
Copy link
Contributor

This fixes two coordinate-handling issues: NearbyEvent now passes coordinates to @turf/distance in the correct [longitude, latitude] order, and both NearbyEvent and the communities map now handle valid 0 latitude/longitude values correctly.

Summary

  • fix NearbyEvent to pass coordinates to @turf/distance in [longitude, latitude] order
  • fix NearbyEvent null checks so valid 0 latitude/longitude values are handled correctly
  • fix the same 0-value edge case in the communities map initial state

Why

NearbyEvent was building @turf/distance coordinate 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 0 latitude or 0 longitude as missing.

The communities map had the same edge case when initializing the map center and zoom from the user location.

Evidence

Notes

  • The existing MapLibre code in src/routes/communities/+page.svelte already follows [lng, lat] ordering, which was a useful internal consistency check.
  • pnpm check passes.

@netlify
Copy link

netlify bot commented Mar 20, 2026

Deploy Preview for pauseai ready!

Name Link
🔨 Latest commit 8b93a99
🔍 Latest deploy log https://app.netlify.com/projects/pauseai/deploys/69bd3ffaf13439000858619d
😎 Deploy Preview https://deploy-preview-693--pauseai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 86 (🟢 up 1 from production)
Accessibility: 90 (no change from production)
Best Practices: 92 (no change from production)
SEO: 99 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@RisingOrange RisingOrange marked this pull request as ready for review March 20, 2026 12:42
@Wituareard
Copy link
Collaborator

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

@RisingOrange
Copy link
Contributor Author

@Wituareard Okay, I'll do some more tests and add testing instructions

@RisingOrange
Copy link
Contributor Author

RisingOrange commented Mar 20, 2026

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 [longitude, latitude] order, the distance stays below the 100 km threshold, but with the swapped interpretation it goes above 100 km.

Correct order: distance is below 100 km

image

Swapped order: distance is above 100 km

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants