Pad min. and sec. with leading zeros in DMS notation

FIxes 3776
This commit is contained in:
Pierre GIRAUD
2015-06-25 08:40:43 +02:00
parent 28450cbb5a
commit 1cdfc709ae
2 changed files with 4 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ goog.provide('ol.CoordinateFormatType');
goog.provide('ol.coordinate');
goog.require('goog.math');
goog.require('goog.string');
/**
@@ -129,8 +130,8 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres) {
var normalizedDegrees = goog.math.modulo(degrees + 180, 360) - 180;
var x = Math.abs(Math.round(3600 * normalizedDegrees));
return Math.floor(x / 3600) + '\u00b0 ' +
Math.floor((x / 60) % 60) + '\u2032 ' +
Math.floor(x % 60) + '\u2033 ' +
goog.string.padNumber(Math.floor((x / 60) % 60), 2) + '\u2032 ' +
goog.string.padNumber(Math.floor(x % 60), 2) + '\u2033 ' +
hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);
};