dbarbalato / magellan

JavaScript Latitude and Longitude Validation and Formatting
18 stars 12 forks source link

Format not parsed correctly #13

Open nickdos opened 8 years ago

nickdos commented 8 years ago

I have an example user input that does not return the expected DD output:

input coordinates: 36.01S,146.95E - this is recognised by Google geocoding API.

var parts = address.split(",");
var lat = magellan(parts[0]).latitude().toDD();
var lng = magellan(parts[1]).longitude().toDD();
console.log("magellan", parts, lat, lng);

console output:

magellan ["36.01S", "146.95E"] -3.100167 14.115833`

the following does work correctly:

magellan ["-36.01", "146.95"] -36.010000 146.950000
magellan ["36°1'S", "146°57'E"] -36.016667 146.950000
nickdos commented 8 years ago

Fixed with change to line 18:

var DD_FORMAT_REGEX = /^([+-]?\d{1,3})(.\d+)?\s*[NSEW]?$/;
mechalas commented 7 years ago

That should be line 15 on the current source (as of 3/8/17). But yes, this does fix tihngs.