@idm-plugin/geo 1.8.5 → 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
@@ -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;
@@ -2071,7 +2076,7 @@ class t0 {
2071
2076
  }
2072
2077
  if (z.features.push(...d), (Y == null ? void 0 : Y.length) > 1) {
2073
2078
  const e = N.lineString(X.convertToMonotonicLng2(Y), {
2074
- date: A.updated,
2079
+ date: (A == null ? void 0 : A.updated) || (L == null ? void 0 : L.format()),
2075
2080
  id: p.id || p.name,
2076
2081
  model: o.model,
2077
2082
  name: p.name,
@@ -2128,7 +2133,7 @@ class t0 {
2128
2133
  const b = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((q) => q.geometry.type === "LineString" && q.properties.type === "forecast"), O = [];
2129
2134
  for (const q of b) {
2130
2135
  const Y = q.properties.name, d = q.properties.model, L = q.properties.showCircle, T = q.properties.disabled, S = I(q.properties.date).utc();
2131
- let e = z * 60 - (S.get("hour") * 60 + S.get("minute")) % (z * 60);
2136
+ let e = z * 60;
2132
2137
  const r = (p = M == null ? void 0 : M.data) == null ? void 0 : p.features.filter(
2133
2138
  (P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${Y}-${d}`
2134
2139
  );