nicecode-v2/packages/func/lib/map/index.js

55 lines
1.7 KiB
JavaScript

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/map/index.ts
var map_exports = {};
__export(map_exports, {
fixedLngLat: () => fixedLngLat,
transformLngLat: () => transformLngLat
});
module.exports = __toCommonJS(map_exports);
var fixedLngLat = (lngLat) => {
if (!lngLat) {
return "";
}
const lngLatArr = lngLat.split(",");
const longitude = Number(lngLatArr[0]).toFixed(6);
const latitude = Number(lngLatArr[1]).toFixed(6);
if (lngLatArr.length < 2) {
return "";
}
return `${longitude},${latitude}`;
};
var transformLngLat = (lngLat) => {
if (lngLat) {
const lngLatArr = lngLat ? lngLat.split(",") : [];
const longitude = Number(lngLatArr[0]);
const latitude = Number(lngLatArr[1]);
if (lngLatArr.length < 2) {
return null;
}
return { longitude, latitude };
}
return null;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
fixedLngLat,
transformLngLat
});