add Ox.formatDegrees
This commit is contained in:
parent
1d86f10e79
commit
18ba0d5347
1 changed files with 23 additions and 0 deletions
|
@ -371,6 +371,29 @@ Ox.formatDateRangeDuration = function(start, end, utc) {
|
||||||
}).join(' ');
|
}).join(' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*@
|
||||||
|
Ox.formatDegrees <f> Formats degrees as D°MM'SS"
|
||||||
|
> Ox.formatDegrees(-111.11, 'lng')
|
||||||
|
"111\u00B006'36\"W"
|
||||||
|
@*/
|
||||||
|
Ox.formatDegrees = function(deg, mode) {
|
||||||
|
var days = 0,
|
||||||
|
sec = Math.round(Math.abs(deg) * 3600),
|
||||||
|
sign = deg < 0 ? '-' : '',
|
||||||
|
split = Ox.formatDuration(sec).split(':');
|
||||||
|
if (split.length == 4) {
|
||||||
|
days = parseInt(split.shift(), 10);
|
||||||
|
}
|
||||||
|
split[0] = days * 24 + parseInt(split[0], 10);
|
||||||
|
return (!mode ? sign : '')
|
||||||
|
+ split[0] + '\u00B0' + split[1] + "'" + split[2] + '"'
|
||||||
|
+ (
|
||||||
|
mode == 'lat' ? (deg < 0 ? 'S' : 'N')
|
||||||
|
: mode == 'lng' ? (deg < 0 ? 'W' : 'E')
|
||||||
|
: ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.formatDuration <f> Formats a duration as a string
|
Ox.formatDuration <f> Formats a duration as a string
|
||||||
> Ox.formatDuration(3599.999)
|
> Ox.formatDuration(3599.999)
|
||||||
|
|
Loading…
Reference in a new issue