https://github.com/alrico88/common-geohash-parent
Compendium of methods to find common geohash parents from points, geohashes, polygons or other GeoJSON features
https://github.com/alrico88/common-geohash-parent
feature geohash node parent polygon
Last synced: about 1 month ago
JSON representation
Compendium of methods to find common geohash parents from points, geohashes, polygons or other GeoJSON features
- Host: GitHub
- URL: https://github.com/alrico88/common-geohash-parent
- Owner: alrico88
- Created: 2020-04-28T13:44:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-28T14:18:07.000Z (over 5 years ago)
- Last Synced: 2025-03-24T04:34:02.561Z (7 months ago)
- Topics: feature, geohash, node, parent, polygon
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/common-geohash-parent
- Size: 78.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Common geohash parent finder v0.1.0
Class with multiple methods to help you find the common parent geohash from points, geohashes, bounding boxes, polygons or other GeoJSON shapes.
## Installation
Using npm:
`npm i common-geohash-parent`
Using yarn:
`yarn add common-geohash-parent`
## Example usage
In node:
```javascript
const ParentFinder = require('common-geohash-parent');const bbox = [-3.944092, 40.241799, -3.261566, 40.779502];
const precision = 5;
const finder = new ParentFinder(precision);
finder.fromBBox(bbox)
.then((parents) => {
// parents is ['ezjp','ezjr','ezjx','ezjn','ezjq','ezjw','ezjj','ezjm','ezjt','ezjh','ezjk','ezjs']
...
});
```## Classes
## Typedefs
-
ParentGeohashList :Array.<string>
- OptimizationOptions
## ParentFinder
**Kind**: global class
- [ParentFinder](#ParentFinder)
- [new ParentFinder()](#new_ParentFinder_new)
- _instance_
- [.fromPoints(points)](#ParentFinder+fromPoints) ⇒ [ParentGeohashList
](#ParentGeohashList)
- [.fromGeohashes(hashes)](#ParentFinder+fromGeohashes) ⇒ [ParentGeohashList
](#ParentGeohashList)
- [.fromBBox(bbox)](#ParentFinder+fromBBox) ⇒ [Promise.<ParentGeohashList>
](#ParentGeohashList)
- [.fromPolygon(inputPolygon)](#ParentFinder+fromPolygon) ⇒ [Promise.<ParentGeohashList>
](#ParentGeohashList)
- _static_
- [.ParentFinder](#ParentFinder.ParentFinder)
- [new ParentFinder(parentPrecision, [optimization])](#new_ParentFinder.ParentFinder_new)
### new ParentFinder()
ParentFinder class
### parentFinder.fromPoints(points) ⇒ [ParentGeohashList
](#ParentGeohashList)
Finds common parents from array of points
**Kind**: instance method of [ParentFinder
](#ParentFinder)
**Returns**: [ParentGeohashList
](#ParentGeohashList) - Array of geohashes
| Param | Type | Description |
| ------ | ----------------------------------------------- | ----------- |
| points | Array.<Array.<number>>
| [lon, lat] |
### parentFinder.fromGeohashes(hashes) ⇒ [ParentGeohashList
](#ParentGeohashList)
Finds common parents from array of geohashes
**Kind**: instance method of [ParentFinder
](#ParentFinder)
**Returns**: [ParentGeohashList
](#ParentGeohashList) - List of parent geohashes
| Param | Type | Description |
| ------ | --------------------------------- | ----------------- |
| hashes | Array.<string>
| List of geohashes |
### parentFinder.fromBBox(bbox) ⇒ [Promise.<ParentGeohashList>
](#ParentGeohashList)
Finds common parents from bounding box
**Kind**: instance method of [ParentFinder
](#ParentFinder)
**Returns**: [Promise.<ParentGeohashList>
](#ParentGeohashList) - Promise of list of parent geohashes
| Param | Type | Description |
| ----- | --------------------------------- | -------------------------------- |
| bbox | Array.<number>
| [number, number, number, number] |
### parentFinder.fromPolygon(inputPolygon) ⇒ [Promise.<ParentGeohashList>
](#ParentGeohashList)
Finds common parents from polygon feature
**Kind**: instance method of [ParentFinder
](#ParentFinder)
**Returns**: [Promise.<ParentGeohashList>
](#ParentGeohashList) - Promise of list of parent geohashes
| Param | Type | Description |
| ------------ | ------------------- | ------------- |
| inputPolygon | object
| GeoJSON shape |
### ParentFinder.ParentFinder
**Kind**: static class of [ParentFinder
](#ParentFinder)
#### new ParentFinder(parentPrecision, [optimization])
Creates an instance of ParentFinder.
| Param | Type | Description |
| --------------- | -------------------------------------------------------- | ---------------------------------------- |
| parentPrecision | number
| Initial parent precision |
| [optimization] | [OptimizationOptions
](#OptimizationOptions) | If desired, specify optimization options |
## ParentGeohashList : Array.<string>
## OptimizationOptions
**Kind**: global typedef
**Properties**
| Name | Type |
| ---------- | -------------------- |
| enabled | boolean
|
| maxParents | number
|