geohashes-between

Get a list of geohashes between two geohashes, or between two coordinates.

Usage no npm install needed!

<script type="module">
  import geohashesBetween from 'https://cdn.skypack.dev/geohashes-between';
</script>

README

geohashes-between

Get a list of geohashes between two geohashes, or between two coordinates.

Installation

Using npm, npm i geohashes-between.

Using yarn, yarn add geohashes-between.

Usage

Using import

import { getGeohashesBetweenTwoGeohashes } from 'geohashes-between';

In a CommonJS environment

const { getGeohashesBetweenTwoGeohashes } = require('geohashes-between');

Then:

const list = getGeohashesBetweenTwoGeohashes('ezep', 'ezex');
// list is ['ezer']

Or:

const pointA = [-3.684166, 40.416763];
const pointB = [-3.720741, 40.364335];

const list = getGeohashesBetweenCoordinates(pointA, pointB, 6);
// list is ['ezjmuj', 'ezjmuh','ezjmu5', 'ezjmgg','ezjmgf', 'ezjmgc','ezjmgb', 'ezjmg8','ezjmex', 'ezjmew','ezjmeq', 'ezjmem','ezjmek']

Table of contents

Functions

Functions

getGeohashesBetweenCoordinates

getGeohashesBetweenCoordinates(pointA: Position, pointB: Position, precision: number): string[]

Finds the geohashes of a given precision between two coordinates

Parameters

Name Type Description
pointA Position Starting coordinate [lon, lat]
pointB Position End coordinate [lon, lat]
precision number Desired geohash precision

Returns: string[]

The list of geohashes between those coords


getGeohashesBetweenTwoGeohashes

getGeohashesBetweenTwoGeohashes(geohashStart: string, geohashEnd: string, includeStartEnd?: boolean): string[]

Gets a list of geohashes between a starting and end geohash Both geohashes should be of the same precision

Parameters

Name Type Default value Description
geohashStart string - The starting geohash
geohashEnd string - The ending geohash
includeStartEnd boolean false Whether to include starting and ending geohash in the returned list

Returns: string[]

The list of geohashes between start and end