dbarbalato / magellan

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

Negative 0 coordinates #17

Open cvaida opened 7 years ago

cvaida commented 7 years ago

When you try to load negative 0 coordinate (f.e. -0.9160958), the result will be positive. The reason for it is mainly caused by expressions like this: coordinate.degrees >= 0 For background information you can check this: are 0 and -0 the same This is resolved in ES2015, but unfortunately that one is not yet widely implemented.

There would be quite a number of changes to the code to make it work properly (which is why I am not sure if I should submit a patch). One solution would be using a function like this for the positivity test: var positiveNumber = function(value) { return ((1/value) === (1/Math.abs(value))); }

PS: I am no expert in GIS or coordinates systems, but I thought that minutes and seconds cannot be negative. I see some tests of their positivity and that seem off to me...