ianengelbrecht / 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.
MIT License
38 stars 9 forks source link

Truncating decimals appropriately #1

Closed uamp closed 4 years ago

uamp commented 5 years ago

Great parser, thank you for writing it!

Line 238-269 in converter.js is causing issues though...

(node:16848) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined at converter (node_modules\geo-coordinates-parser\converter.js:248:19)

This happens when trying to decode a location with zero minutes (and possibly seconds, not tried) Eg "N 52d0m0s E 000d0m0s"

Suggest either a check for parts.length!=1 or zero padding further up in the code.

Thanks in advance if you are able to fix it!

Portree-Kid commented 4 years ago

"N49 0.000 E02 33.314" fails to be parsed for the same reason.

ianengelbrecht commented 4 years ago

Thank you so much for the positive feedback! Fixed, tested and published to NPM, version 1.2.4.