Closed oscarhidalgo closed 9 years ago
On toDMS function you ca't use only Math.floor because on negative values this return an incorrect value. For example the Math.floor(-8.76) is -9
You can change the code, for example:
toDMS : function (deg) {
var d = Math.floor(Math.abs(deg));
var minfloat = (Math.abs(deg)-d)*60;
var m = Math.floor(minfloat);
var secfloat = (minfloat-m)*60;
var s = Math.round(secfloat);
if (s==60) {
m++;
s="00";
}
if (m==60) {
d++;
m="00";
}
if(s<10) {
s="0"+s;
}
if(m<10){
m="0"+m;
}
var dir = "";
if (deg < 0)
{
dir="-";
}
else
{
dir="";
}
return ("" + dir + d + "° " + m + "' " + s + "''");
},
Thanks! Fixed it and also added Jasmine tests to verify. Created a new release 0.1.4 dc2a7e88848135aeaf34c68ff85c5d0aecca2edd
On negative longitude the DMS coordinates are wrong.