Compatible coordinates
If you ever worked with coordinates on the web you probably know that there's no "standard" way of passing them around to libraries etc.
Examples that this solves:
- Google maps wants
{ lat, lng }
and[latitude, longitude]
- SMHI (Swedish weather) wants
{ lat, lon }
- cheap-ruler wants
[longitude, latitude]
(reversed!!!!)
Or versose, because tab completion and readability { latitude, longitude }
Install
yarn add compatible-coordinates
npm install --save compatible-coordinates
Usage
const CompatibleCoordinates = const home = 59 18 console //=> 59console //=> 59console //=> 59 console //=> 18console //=> 18console //=> 18console //=> 18 console //=> [59, 18]
Reversed tuple
For some reason, cheap-ruler expects the coordinates in [longitude, latitude], to reverse the tuple without changing the behaviour of the other properties, you can use .reversed()
const homeReversed = home console //=> 59console //=> 18 console // => 18
Credits
@linusu for coming up with this clever but simple solution ⚡️