The `geohash-area` library provides specialized utilities for working with geohashes, primarily focused on generating and querying geohashes for rectangular regions and arbitrary areas. It is designed to facilitate efficient spatial lookups in databases by producing a set of geohashes that cover a specific geographical extent. The package is currently at version 0.1.0, indicating an early development stage, and while a specific release cadence is not defined, its focused scope suggests a stable, yet evolving, set of core functionalities. Key differentiators include its unique `rect` function for radial geohash generation and an `area` function that supports recursively determining geohashes for complex, user-defined geographical boundaries via a callback, setting it apart from more generic geohash encoding/decoding libraries. It ships with comprehensive TypeScript type definitions, ensuring a robust development experience.
npm install geohash-areaVerified import paths — ran on the pinned version, not inferred.
Demonstrates encoding, decoding, generating geohashes for a rectangular area, and calculating distance between two points using the `geohash-area` library.
Always pin to exact versions (e.g., `"geohash-area": "0.1.0"`) and thoroughly review release notes when upgrading to new versions, even patch or minor releases.
Be aware that the unit is miles. If kilometers or another unit is required, perform a conversion manually after obtaining the result from `geohash.distance` (e.g., `distanceInKm = distanceInMiles * 1.60934`).
Carefully review the documentation for the `fn` parameter of `geohash.area`. Ensure your callback correctly returns `0` (not included), `1` (partially included), or `2` (fully included) as specified to guarantee accurate area coverage.
Start with a lower precision and gradually increase it, monitoring performance and the number of generated geohashes. Choose the lowest precision that meets your application's accuracy requirements to optimize performance.
Use a module namespace import: `import * as geohash from 'geohash-area';` and then access the function as `geohash.encode(...)`.
Ensure the `precision` value passed to geohash functions is an integer between 1 and 12, inclusive. Refer to geohash standards for appropriate precision levels based on desired accuracy.
Ensure that a valid callback function is passed as the first argument to `geohash.area`. This function should accept a geohash string and return `0`, `1`, or `2` based on its relation to the area of interest.
No dependency data recorded yet.