@idm-plugin/geo 1.8.6 → 1.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -154,7 +154,7 @@ var j = { exports: {} };
154
154
  try {
155
155
  var W = Intl.DateTimeFormat().resolvedOptions().timeZone;
156
156
  if (W && W.length > 3) {
157
- var a = p[K(W)];
157
+ var a = p[h(W)];
158
158
  if (a)
159
159
  return a;
160
160
  D("Moment Timezone found " + W + " from the Intl api, but did not have that data loaded.");
@@ -172,16 +172,16 @@ var j = { exports: {} };
172
172
  function O0(W) {
173
173
  return (!o || W) && (o = p0()), o;
174
174
  }
175
- function K(W) {
175
+ function h(W) {
176
176
  return (W || "").toLowerCase().replace(/\//g, "_");
177
177
  }
178
178
  function k(W) {
179
179
  var a, n, R, i;
180
180
  for (typeof W == "string" && (W = [W]), a = 0; a < W.length; a++)
181
- R = W[a].split("|"), n = R[0], i = K(n), b[i] = W[a], p[i] = n, z0(i, R[2].split(" "));
181
+ R = W[a].split("|"), n = R[0], i = h(n), b[i] = W[a], p[i] = n, z0(i, R[2].split(" "));
182
182
  }
183
183
  function g(W, a) {
184
- W = K(W);
184
+ W = h(W);
185
185
  var n = b[W], R;
186
186
  return n instanceof Z ? n : typeof n == "string" ? (n = new Z(n), b[W] = n, n) : O[W] && a !== g && (R = g(O[W], g)) ? (n = b[W] = new Z(), n._set(R), n.name = p[W], n) : null;
187
187
  }
@@ -197,7 +197,7 @@ var j = { exports: {} };
197
197
  function v(W) {
198
198
  var a, n, R, i;
199
199
  for (typeof W == "string" && (W = [W]), a = 0; a < W.length; a++)
200
- n = W[a].split("|"), R = K(n[0]), i = K(n[1]), O[R] = i, p[R] = n[0], O[i] = R, p[i] = n[1];
200
+ n = W[a].split("|"), R = h(n[0]), i = h(n[1]), O[R] = i, p[R] = n[0], O[i] = R, p[i] = n[1];
201
201
  }
202
202
  function W0(W) {
203
203
  var a, n, R, i;
@@ -277,8 +277,8 @@ var j = { exports: {} };
277
277
  C.zoneName = y(C.zoneName), C.zoneAbbr = y(C.zoneAbbr), C.utc = w(C.utc), C.local = w(C.local), C.utcOffset = d0(C.utcOffset), M.tz.setDefault = function(W) {
278
278
  return (Y < 2 || Y === 2 && d < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = W ? g(W) : null, M;
279
279
  };
280
- var h = M.momentProperties;
281
- return Object.prototype.toString.call(h) === "[object Array]" ? (h.push("_z"), h.push("_a")) : h && (h._z = null), M;
280
+ var K = M.momentProperties;
281
+ return Object.prototype.toString.call(K) === "[object Array]" ? (K.push("_z"), K.push("_a")) : K && (K._z = null), M;
282
282
  });
283
283
  })(j);
284
284
  var n0 = j.exports;
@@ -1173,8 +1173,13 @@ class X {
1173
1173
  let z = Math.floor(Math.abs(M)), b = Math.round((Math.abs(M) - z) * 60);
1174
1174
  return b = b > 9 ? b : `0${b}`, z = z > 9 ? z : `0${z}`, M > 0 ? `+${z}:${b}` : `-${z}:${b}`;
1175
1175
  }
1176
+ /**
1177
+ * @param lng
1178
+ * @param precision 3位小数在百米级,4位小数在十米级, 5位小数在米级
1179
+ * @param format
1180
+ */
1176
1181
  static lng2pretty(M, z = 6, b = "H°M′") {
1177
- z = z < 6 ? 6 : z, M = X.convertToStdLng(M, z);
1182
+ M = X.convertToStdLng(M, z);
1178
1183
  let O = "E";
1179
1184
  M < 0 && (O = "W"), M = Math.abs(M), b = b.toUpperCase();
1180
1185
  let c = M * 3600, p, A, o, q, Y, d;
@@ -1195,7 +1200,7 @@ class X {
1195
1200
  * @param format 格式化
1196
1201
  */
1197
1202
  static lat2pretty(M, z = 6, b = "H°M′") {
1198
- z = z < 6 ? 6 : z, M = M % 180;
1203
+ M = M % 180;
1199
1204
  let O = "N";
1200
1205
  M < 0 && (O = "S"), M = Math.abs(M), b = b.toUpperCase();
1201
1206
  let c = M * 3600, p, A, o, q, Y, d;
@@ -1215,13 +1220,13 @@ class X {
1215
1220
  M = X.strReplace(M, "LNG");
1216
1221
  const O = M[M.length - 1].toUpperCase();
1217
1222
  M = M.substring(0, M.length - 1).trim();
1218
- const c = M.split(" ").filter((o) => o !== "").map((o) => Math.abs(Number(o)));
1219
- let [p, A] = c;
1220
- if (A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, p > 360 && !A) {
1221
- const o = this.roundPrecision(p / 100, 0);
1222
- A = p - o * 100, p = o;
1223
+ const c = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
1224
+ let [p, A, o] = c;
1225
+ if (A = A || 0, A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, o = o || 0, o = o > 60 ? o / Math.pow(10, String(o).length - 2) : o, p > 360 && !A) {
1226
+ const q = this.roundPrecision(p / 100, 0);
1227
+ A = p - q * 100, p = q;
1223
1228
  }
1224
- b = p + (A ?? 0) / 60, O === "W" && (b = b * -1);
1229
+ b = p + A / 60 + o / 3600, O === "W" && (b = b * -1);
1225
1230
  } else
1226
1231
  b = Number(M);
1227
1232
  return X.convertToStdLng(b, z);
@@ -1232,13 +1237,13 @@ class X {
1232
1237
  M = X.strReplace(M, "LAT");
1233
1238
  const O = M[M.length - 1].toUpperCase();
1234
1239
  M = M.substring(0, M.length - 1).trim();
1235
- const c = M.split(" ").filter((o) => o !== "").map((o) => Math.abs(Number(o)));
1236
- let [p, A] = c;
1237
- if (A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, p > 90 && !A) {
1238
- const o = this.roundPrecision(p / 100, 0);
1239
- A = p - o * 100, p = o;
1240
+ const c = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
1241
+ let [p, A, o] = c;
1242
+ if (o = o || 0, A = A || 0, A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, o = o > 60 ? o / Math.pow(10, String(o).length - 2) : o, p > 90 && !A) {
1243
+ const q = this.roundPrecision(p / 100, 0);
1244
+ A = p - q * 100, p = q;
1240
1245
  }
1241
- if (b = p + (A ?? 0) / 60, b > 90)
1246
+ if (b = p + A / 60 + o / 3600, b > 90)
1242
1247
  throw new Error(`latitude out of range: ${M}${O}`);
1243
1248
  O === "S" && (b = b * -1);
1244
1249
  } else
@@ -1257,7 +1262,7 @@ class X {
1257
1262
  static convertToStdLng(M, z = 6) {
1258
1263
  return M > 180 ? (M = M % 360, M = M > 180 ? M - 360 : M) : M < -180 && (M = M % 360, M = M < -180 ? M + 360 : M), X.roundPrecision(M, z);
1259
1264
  }
1260
- static roundPrecision(M, z = 4) {
1265
+ static roundPrecision(M, z = 6) {
1261
1266
  if (typeof M == "number") {
1262
1267
  const b = Number("1".padEnd(z + 1, "0"));
1263
1268
  return Math.round(M * b) / b;
@@ -1283,7 +1288,7 @@ class X {
1283
1288
  return M;
1284
1289
  }
1285
1290
  static strReplace(M, z = "LAT") {
1286
- M = M.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g, "$1 $2").replace(/°/, " ").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
1291
+ M = M.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g, "$1 $2").replace(/°/, " ").replace(/(\d+)-(\d?)/g, "$1 $2").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
1287
1292
  const b = M[M.length - 1].toUpperCase();
1288
1293
  if (!["N", "S", "E", "W"].includes(b)) {
1289
1294
  const O = M, c = Number(O.split(" ")[0]);
@@ -1302,7 +1307,7 @@ class X {
1302
1307
  */
1303
1308
  static padNumber(M, z = 2, b = 2) {
1304
1309
  const O = X.roundPrecision(M - Math.trunc(M), b), c = O >= 1 ? Math.trunc(M + 1).toString().padStart(z, "0") : Math.trunc(M).toString().padStart(z, "0");
1305
- return O >= 1 ? c : `${c}.${Math.trunc(O * Math.pow(10, b)).toString().padStart(b, "0")}`;
1310
+ return O >= 1 ? c : b > 0 ? `${c}.${Math.trunc(O * Math.pow(10, b)).toString().padStart(b, "0")}` : c;
1306
1311
  }
1307
1312
  }
1308
1313
  let r0;