Skip to content

Conversation

@bkeepers
Copy link
Member

This adds the ability to search for stations by proximity using the near and nearest functions:

import { near, nearest } from "@neaps/tide-database";

// Find all stations within 10 km of a lat/lon
const nearbyStations = near(
  { lat: 37.7749, lon: -122.4194 },
  { maxDistance: 10 },
);
console.log("Nearby stations:", nearbyStations.length);

// Find the single nearest station to a lat/lon
const nearestStation = nearest([-75.5, 22]);
console.log("Nearest station:", nearestStation);

The search uses geokdbush for efficient geospatial searching. The index is created at bundle time.

@bkeepers bkeepers force-pushed the search branch 4 times, most recently from ce33b18 to a68bef5 Compare January 12, 2026 18:42
@bkeepers bkeepers merged commit 6abc926 into main Jan 12, 2026
2 checks passed
@bkeepers bkeepers deleted the search branch January 12, 2026 18:50
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