Improve internal usability of ol.coordinate.degreesToStringHDMS
This commit is contained in:
@@ -101,14 +101,13 @@ ol.coordinate.createStringXY = function(opt_fractionDigits) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
|
||||||
* @param {number} degrees Degrees.
|
|
||||||
* @param {string} hemispheres Hemispheres.
|
* @param {string} hemispheres Hemispheres.
|
||||||
|
* @param {number} degrees Degrees.
|
||||||
* @param {number=} opt_fractionDigits The number of digits to include
|
* @param {number=} opt_fractionDigits The number of digits to include
|
||||||
* after the decimal point. Default is `0`.
|
* after the decimal point. Default is `0`.
|
||||||
* @return {string} String.
|
* @return {string} String.
|
||||||
*/
|
*/
|
||||||
ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres, opt_fractionDigits) {
|
ol.coordinate.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) {
|
||||||
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;
|
||||||
@@ -130,8 +129,8 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres, opt_fraction
|
|||||||
}
|
}
|
||||||
|
|
||||||
return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' +
|
return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' +
|
||||||
ol.string.padNumber(sec, 2, dflPrecision) + '\u2033 ' +
|
ol.string.padNumber(sec, 2, dflPrecision) + '\u2033' +
|
||||||
hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);
|
(normalizedDegrees == 0 ? '' : ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -313,8 +312,8 @@ ol.coordinate.squaredDistanceToSegment = function(coordinate, segment) {
|
|||||||
*/
|
*/
|
||||||
ol.coordinate.toStringHDMS = function(coordinate, opt_fractionDigits) {
|
ol.coordinate.toStringHDMS = function(coordinate, opt_fractionDigits) {
|
||||||
if (coordinate) {
|
if (coordinate) {
|
||||||
return ol.coordinate.degreesToStringHDMS_(coordinate[1], 'NS', opt_fractionDigits) + ' ' +
|
return ol.coordinate.degreesToStringHDMS('NS', coordinate[1], opt_fractionDigits) + ' ' +
|
||||||
ol.coordinate.degreesToStringHDMS_(coordinate[0], 'EW', opt_fractionDigits);
|
ol.coordinate.degreesToStringHDMS('EW', coordinate[0], opt_fractionDigits);
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user