1.0.1 • Published 1 year ago

barbora-delivery-coordinate v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Coordinate utility package

This package have functionality to convert multiple format from one to another

Problem

Depends on system multiple systems can use different coordinate formats. For example:

MapBox, Vroom, OSRM uses lng,lat Google uses { latitude: x, longitude: y } or { lat: x, lng: x } or lat,lng

This project provides unified experience with working with coordinates

Usage

import { Coordinate } from "barbora-delivery-coordinate"


Coordinate.from([1,1])
Coordinate.from({ lat, lng })
Coordinate.from({ longitude, latitude })

new Coordinate([1,2]).tuple() // [1,2] return strict Coordinate tuple [number, number]
new Coordinate([1,2]).lngLat() // { lat: 2, lng: 1 }
new Coordinate([1,2]).long() // { longitude: 1, latitude: 2 }
new Coordinate([1,2]).toString() // 1,2
new Coordinate([1,2]).toString() // 1,2