"use strict"; exports.__esModule = true; /* 205.395583333332 = 205°23'44.1" 1,直接读取"度":205 2,(205.395583333332-205)*60=23.734999999920 得到"分":23 3,(23.734999999920-23)*60=44.099999995200 得到"秒":44.1 return string, */ function latLngDecimalToDegrees(decimal) { var absDecimal = Math.abs(decimal); var isNegative = Math.abs(decimal) != decimal; var d = Math.floor(absDecimal); //度 var m = Math.floor((absDecimal - d) * 60); //分 var s = Math.round((absDecimal - d) * 3600 % 60); //秒 if (s == 60) { s = 0; m++; } if (m == 60) { m = 0; d++; } //d = ('000'+d).slice(-3); // left-pad with leading zeros var mm = ('00' + m).slice(-2); // left-pad with leading zeros var ss = ('00' + s).slice(-2); //if (s<10) s = '0' + s; // left-pad with leading zeros (note may include decimals) return (isNegative ? "-" : "") + d + '°' + mm + "′" + ss + '″'; } exports.latLngDecimalToDegrees = latLngDecimalToDegrees; /* Decimal Degrees = Degrees + minutes/60 + seconds/3600 例:57°55'56.6" =57+55/60+56.6/3600=57.9323888888888 return Float or NaN */ function latLngDegreesToDecimal(degreesStr) { var degreesArr = degreesStr.split("°"); var degrees = parseInt(degreesArr[0]); var isNegative = Math.abs(degrees) != degrees; if (degreesArr.length == 1) { return degrees; } else if (!isSafeString(degreesArr[1])) { return degrees; } var minutesArr = degreesArr[1].split("′"); var minutes = parseInt(minutesArr[0]); var min = parseFloat((isNegative ? "-" : "") + (Math.abs(degrees) + Math.abs(minutes) / 60)); if (minutesArr.length == 1) { return min; } else if (!isSafeString(minutesArr[1])) { return min; } var secondsStr = minutesArr[1]; var secondsArr = secondsStr.split('″'); var seconds = parseFloat(secondsArr[0]); return parseFloat((isNegative ? "-" : "") + (Math.abs(degrees) + Math.abs(minutes) / 60 + Math.abs(seconds) / 3600)); } exports.latLngDegreesToDecimal = latLngDegreesToDecimal; function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; function isSafeString(arg) { if (isUndefined(arg)) { return false; } if (!isString(arg)) { return false; } if (arg.length == 0) { return false; } return true; } exports.isSafeString = isSafeString; function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; function hasPoint(obj) { return (isObject(obj) && isSafeString(obj.lat) && isSafeString(obj.lng)); } exports.hasPoint = hasPoint;