convert-coords

converts an object containint two pairs of lat/long coords with unknown keys into a known API.

Usage no npm install needed!

<script type="module">
  import convertCoords from 'https://cdn.skypack.dev/convert-coords';
</script>

README

Convert Coordinates

This module takes a nested object in the form of two objects, lat and long, each of which is containing a pair of lat. and/or long. values demarcating a section on a map. The names of the keys are unknown to the module, only that each sub object contains two lat. or two long. values.

It returns an object like so:

{
  lat: {
    northBorder: 45.9,
    southBorder: 47.7
  },
  long: {
    eastBorder: -123.45,
    westBorder: -123.83
  }
}

This allows the incoming coordinates to be used regardless of the names of the keys used.