1.0.2 • Published 6 months ago

geo-objectid v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

geo-objectid

This package encode geographical coordinates as point or circle into an object id. Also it is able to decode encoded object id values.

Installation

npm i --save geo-objectid

Usage

import GeObjectId from 'geo-objectid'

console.log(GeObjectId.encodePoint(41.014399, 28.9855536, 21))
//=> 030ce81b9c04dda6a5e00015

console.log(GeObjectId.decodePoint("030ce81b9c04dda6a5e00015"))
//=> { lat: 41.014399, lon: 28.9855536, rad: 21 }

API

encodePoint(lat: number, lon: number, rad: number)

  • returns string - a 24 character hex string representing a random ObjectId

decodePoint(objectId: string)

  • returns object - { lat: number; lon: number; rad: number }