Skip to content

markstos/parse-coordinates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parse-coordinates

Parse coordinate strings.

Synopsis

var latLng = require('parse-coordinates');

var coords = latLng('-80.21, 21.32');
// => [-80.21, 21.32]

Description

  var coords = latLng('-80.21, 21.32');
  // => [-80.21, 21.32]

The function returned parses a comma separated latitude and longitude pair and returns them as an array.

Latitude is validated to range from -90 to 90. Longitude value is validated to range from -180 to 180.

Leading and trailing space are tolerated in the string, as well as around the comma.

If the parsing fails for any reason, null is returned instead of the array.

Author

Mark Stosberg <mark@rideamigos.com>

Credit

Forked from to-coordinates, which lacked validation of the number coordinates as well as the valid lat/lng value ranges.

Licence

MIT

About

Node.js module to extract and validate a latitude, longitude pair from a string and convert them to an array.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published