aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/formatter.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-03-24 22:11:19 -0700
committerGitHub <noreply@github.com>2021-03-24 22:11:19 -0700
commit323aaaebc3fd62cdcb6ab5580153af8afeac30e4 (patch)
treede453a6d4d62cc76c0c500f7ca7ca8ae048c519d /modern/src/common/formatter.js
parentc92c5c5a805dfe6927e5c45f677bb386861b4917 (diff)
parentcfa8947f3a4adda1ed649210da4adfe21f44af21 (diff)
downloadtrackermap-web-323aaaebc3fd62cdcb6ab5580153af8afeac30e4.tar.gz
trackermap-web-323aaaebc3fd62cdcb6ab5580153af8afeac30e4.tar.bz2
trackermap-web-323aaaebc3fd62cdcb6ab5580153af8afeac30e4.zip
Merge pull request #828 from mail2bishnoi/custom_report_table
Cutome route table
Diffstat (limited to 'modern/src/common/formatter.js')
-rw-r--r--modern/src/common/formatter.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 289a6d94..0d8ac4c9 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -81,3 +81,28 @@ export const formatVolume = (value, unit) => {
export const formatHours = (value) => {
return moment.duration(value).humanize();
};
+
+export const formatCoordinate = (key, value, unit) => {
+ var hemisphere, degrees, minutes, seconds;
+ if (key === 'latitude') {
+ hemisphere = value >= 0 ? 'N' : 'S';
+ } else {
+ hemisphere = value >= 0 ? 'E' : 'W';
+ }
+
+ switch (unit) {
+ case 'ddm':
+ value = Math.abs(value);
+ degrees = Math.floor(value);
+ minutes = (value - degrees) * 60;
+ return degrees + '° ' + minutes.toFixed(6) + '\' ' + hemisphere;
+ case 'dms':
+ value = Math.abs(value);
+ degrees = Math.floor(value);
+ minutes = Math.floor((value - degrees) * 60);
+ seconds = Math.round((value - degrees - minutes / 60) * 3600);
+ return degrees + '° ' + minutes + '\' ' + seconds + '" ' + hemisphere;
+ default:
+ return value.toFixed(6) + '°';
+ }
+};