dtable-utils
Advanced tools
Comparing version 5.0.11 to 5.0.12
import { GROUP_GEOLOCATION_GRANULARITY } from '../constants/group.js'; | ||
import { isValidPosition } from '../validate/geolocation.js'; | ||
var _convertLatitudeDecimalToDMS = function _convertLatitudeDecimalToDMS(latitudeDecimal) { | ||
if (!latitudeDecimal && latitudeDecimal !== 0) return ''; | ||
if (latitudeDecimal < -90 || latitudeDecimal > 90) { | ||
return ''; | ||
} | ||
var degrees = Math.floor(Math.abs(latitudeDecimal)); | ||
var minutesDecimal = (Math.abs(latitudeDecimal) - degrees) * 60; | ||
var minutes = Math.floor(minutesDecimal); | ||
var seconds = Math.round((minutesDecimal - minutes) * 60); | ||
var latitudeNS = latitudeDecimal >= 0 ? 'N' : 'S'; | ||
return "".concat(latitudeNS).concat(degrees, "\xB0").concat(minutes, "'").concat(seconds, "\""); | ||
}; | ||
var _convertLongitudeDecimalToDMS = function _convertLongitudeDecimalToDMS(longitudeDecimal) { | ||
if (!longitudeDecimal && longitudeDecimal !== 0) return ''; | ||
if (longitudeDecimal < -180 || longitudeDecimal > 180) { | ||
return ''; | ||
} | ||
var degrees = Math.floor(Math.abs(longitudeDecimal)); | ||
var minutesDecimal = (Math.abs(longitudeDecimal) - degrees) * 60; | ||
var minutes = Math.floor(minutesDecimal); | ||
var seconds = Math.round((minutesDecimal - minutes) * 60); | ||
var longitudeNS = longitudeDecimal >= 0 ? 'E' : 'W'; | ||
return "".concat(longitudeNS).concat(degrees, "\xB0").concat(minutes, "'").concat(seconds, "\""); | ||
}; | ||
/** | ||
@@ -13,6 +38,5 @@ * Get formatted geolocation | ||
var getGeolocationDisplayString = function getGeolocationDisplayString(loc, formats) { | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref$isBaiduMap = _ref.isBaiduMap, | ||
isBaiduMap = _ref$isBaiduMap === void 0 ? true : _ref$isBaiduMap, | ||
_ref$hyphen = _ref.hyphen, | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
_ref.isBaiduMap; | ||
var _ref$hyphen = _ref.hyphen, | ||
hyphen = _ref$hyphen === void 0 ? '' : _ref$hyphen; | ||
@@ -28,3 +52,5 @@ if (!loc) return ''; | ||
if (!isValidPosition(lng, lat)) return ''; | ||
return isBaiduMap ? "".concat(lng, ", ").concat(lat) : "".concat(lat, ", ").concat(lng); | ||
var lngDMS = _convertLongitudeDecimalToDMS(lng); | ||
var latDMS = _convertLatitudeDecimalToDMS(lat); | ||
return "".concat(latDMS, ", ").concat(lngDMS); | ||
} | ||
@@ -31,0 +57,0 @@ case 'country_region': |
@@ -8,2 +8,27 @@ 'use strict'; | ||
var _convertLatitudeDecimalToDMS = function _convertLatitudeDecimalToDMS(latitudeDecimal) { | ||
if (!latitudeDecimal && latitudeDecimal !== 0) return ''; | ||
if (latitudeDecimal < -90 || latitudeDecimal > 90) { | ||
return ''; | ||
} | ||
var degrees = Math.floor(Math.abs(latitudeDecimal)); | ||
var minutesDecimal = (Math.abs(latitudeDecimal) - degrees) * 60; | ||
var minutes = Math.floor(minutesDecimal); | ||
var seconds = Math.round((minutesDecimal - minutes) * 60); | ||
var latitudeNS = latitudeDecimal >= 0 ? 'N' : 'S'; | ||
return "".concat(latitudeNS).concat(degrees, "\xB0").concat(minutes, "'").concat(seconds, "\""); | ||
}; | ||
var _convertLongitudeDecimalToDMS = function _convertLongitudeDecimalToDMS(longitudeDecimal) { | ||
if (!longitudeDecimal && longitudeDecimal !== 0) return ''; | ||
if (longitudeDecimal < -180 || longitudeDecimal > 180) { | ||
return ''; | ||
} | ||
var degrees = Math.floor(Math.abs(longitudeDecimal)); | ||
var minutesDecimal = (Math.abs(longitudeDecimal) - degrees) * 60; | ||
var minutes = Math.floor(minutesDecimal); | ||
var seconds = Math.round((minutesDecimal - minutes) * 60); | ||
var longitudeNS = longitudeDecimal >= 0 ? 'E' : 'W'; | ||
return "".concat(longitudeNS).concat(degrees, "\xB0").concat(minutes, "'").concat(seconds, "\""); | ||
}; | ||
/** | ||
@@ -18,6 +43,5 @@ * Get formatted geolocation | ||
var getGeolocationDisplayString = function getGeolocationDisplayString(loc, formats) { | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref$isBaiduMap = _ref.isBaiduMap, | ||
isBaiduMap = _ref$isBaiduMap === void 0 ? true : _ref$isBaiduMap, | ||
_ref$hyphen = _ref.hyphen, | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
_ref.isBaiduMap; | ||
var _ref$hyphen = _ref.hyphen, | ||
hyphen = _ref$hyphen === void 0 ? '' : _ref$hyphen; | ||
@@ -33,3 +57,5 @@ if (!loc) return ''; | ||
if (!geolocation.isValidPosition(lng, lat)) return ''; | ||
return isBaiduMap ? "".concat(lng, ", ").concat(lat) : "".concat(lat, ", ").concat(lng); | ||
var lngDMS = _convertLongitudeDecimalToDMS(lng); | ||
var latDMS = _convertLatitudeDecimalToDMS(lat); | ||
return "".concat(latDMS, ", ").concat(lngDMS); | ||
} | ||
@@ -36,0 +62,0 @@ case 'country_region': |
{ | ||
"name": "dtable-utils", | ||
"version": "5.0.11", | ||
"version": "5.0.12", | ||
"description": "dtable common utils", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
915536
20239