fixed the degreesToStringHDMS_() function to promote a seconds value of 60 up to the next minute; fixed calculation of components

This commit is contained in:
alfred.jackson
2017-01-27 17:32:21 -06:00
parent 2001244b88
commit eebcccab66

View File

@@ -112,20 +112,21 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres, opt_fraction
var normalizedDegrees = ol.math.modulo(degrees + 180, 360) - 180; var normalizedDegrees = ol.math.modulo(degrees + 180, 360) - 180;
var x = Math.abs(3600 * normalizedDegrees); var x = Math.abs(3600 * normalizedDegrees);
var dflPrecision = opt_fractionDigits || 0; var dflPrecision = opt_fractionDigits || 0;
var precision = Math.pow(10, dflPrecision);
var deg = Math.floor(x / 3600); var deg = Math.floor(x / 3600);
var min = Math.floor((x / 60) % 60); var min = Math.floor((x - deg * 3600) / 60);
var precision = Math.pow(10, dflPrecision); var sec = x - (deg * 3600) - (min * 60);
var sec = Math.ceil((x * precision) % 60) / precision; sec = Math.ceil(sec * precision) / precision;
if (60 === sec) { if (sec >= 60) {
sec = 0; sec = 0;
min += 1; min += 1;
} }
if (min >= 60) { if (min >= 60) {
min -= 60; min = 0;
deg = deg >= 0 ? deg + 1 : deg - 1; deg += 1;
} }
return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' + return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' +