Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geo-coordinates-parser

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-coordinates-parser

A Javascript function for reading a variety of coordinate formats and converting to decimal numbers. Builds on other efforts by returning the verbatim coordinates and the decimal coordinates all in one object.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
decreased by-34.63%
Maintainers
1
Weekly downloads
 
Created
Source

Geo Coordinate Parser

A Javascript function for reading a variety of coordinate formats and converting to decimal numbers. Builds on other efforts for convenience by returning the verbatim coordinates and the decimal coordinates all in one object. Also includes a function to test existing decimal coordinates against those from the converter.

Usage

parseCoordsString = require('geo-coordinate-parser');

let converted = parseCoordsString('40° 26.7717, -79° 56.93172');

converted.decimalLatitude; // 40.446195 ✓
converted.decimalLongitude; // -79.948862 ✓
converted.verbatimLatitude; // '40° 26.7717' ✓
converted.verbatimLongitude; // '-79° 56.93172' ✓

The returned object includes properties verbatimCoordinates, verbatimLatitude, verbatimLongitude, decimalLatitude, decimalLatitude, and decimalCoordinates.

Sometimes we may want to validate existing decimal coordinates against those returned from the converter to find errors. Because we're working with decimal numbers we must settle for values that are close enough (in this case the same up to six decimal places).

converted.closeEnough(yourDecimalCoordinatesToTest) //must be a string separated by ,

Supported formats

All formats (except the 'exotic formats') covered by npm coordinate-parser and the coordinate regex in this GitHub Gist, as well as the following:

  • -23.3245° S / 28.2344° E
  • 27deg 15min 45.2sec S 18deg 32min 53.7sec E
  • 18.24S 22.45E // read as degrees and minutes

Please add coordinate formats that throw an error in the Issues.

License

MIT Licence

Acknowledgements

Support for development was provided by the Animal Demography Unit of the University of Cape Town.

Keywords

FAQs

Package last updated on 13 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc