gis-common 4.2.6 → 4.2.8

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.
@@ -46,6 +46,7 @@ var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
46
46
  ErrorType2["PARAMETER_ERROR_STRING"] = "验证数据类型失败,必须是字符";
47
47
  ErrorType2["PARAMETER_ERROR_FUNCTION"] = "验证数据类型失败,必须是函数";
48
48
  ErrorType2["PARAMETER_ERROR_OBJECT"] = "验证数据类型失败,必须是对象";
49
+ ErrorType2["PARAMETER_ERROR_INTEGER"] = "验证数据类型失败,必须是整型";
49
50
  ErrorType2["PARAMETER_ERROR_NUMBER"] = "验证数据类型失败,必须是数值";
50
51
  ErrorType2["PARAMETER_ERROR_LACK"] = "验证数据类型失败,必须非空";
51
52
  ErrorType2["DATA_ERROR"] = "格式类型验证失败";
@@ -465,6 +466,9 @@ const CommUtils = {
465
466
  isNumber(a) {
466
467
  return typeof a === "number" && !isNaN(a) || typeof a === "string" && Number.isFinite(+a);
467
468
  },
469
+ isInteger(a) {
470
+ return parseInt(a) === a;
471
+ },
468
472
  isFunction(obj) {
469
473
  if (this.isNil(obj)) {
470
474
  return false;
@@ -902,9 +906,7 @@ const MathUtils = {
902
906
  return Math.max(min, Math.min(max, val));
903
907
  }
904
908
  };
905
- const GeoUtil = {
906
- toRadian: Math.PI / 180,
907
- R: 6371393,
909
+ class GeoUtil {
908
910
  /**
909
911
  * 判断给定的经纬度是否合法
910
912
  *
@@ -912,9 +914,9 @@ const GeoUtil = {
912
914
  * @param lat 纬度值
913
915
  * @returns 如果经纬度合法,返回true;否则返回false
914
916
  */
915
- isLnglat(lng, lat) {
917
+ static isLnglat(lng, lat) {
916
918
  return !isNaN(lng) && !isNaN(lat) && !!(+lat > -90 && +lat < 90 && +lng > -180 && +lng < 180);
917
- },
919
+ }
918
920
  /**
919
921
  * 计算两哥平面坐标点间的距离
920
922
  *
@@ -922,9 +924,9 @@ const GeoUtil = {
922
924
  * @param p2 坐标点2,包含x和y属性
923
925
  * @returns 返回两点间的欧几里得距离
924
926
  */
925
- distance(p1, p2) {
927
+ static distance(p1, p2) {
926
928
  return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
927
- },
929
+ }
928
930
  /**
929
931
  * 计算两个经纬度点之间的距离
930
932
  *
@@ -932,7 +934,7 @@ const GeoUtil = {
932
934
  * @param B 经纬度点B,包含lng(经度)和lat(纬度)两个属性
933
935
  * @returns 返回两点之间的距离,单位为米
934
936
  */
935
- distanceByPoints(A, B) {
937
+ static distanceByPoints(A, B) {
936
938
  const { lng: lngA, lat: latA } = A;
937
939
  const { lng: lngB, lat: latB } = B;
938
940
  const earthR = 6371e3;
@@ -944,7 +946,7 @@ const GeoUtil = {
944
946
  const alpha = Math.acos(s);
945
947
  const distance = alpha * earthR;
946
948
  return distance;
947
- },
949
+ }
948
950
  /**
949
951
  * 格式化经纬度为度分秒格式
950
952
  *
@@ -952,7 +954,7 @@ const GeoUtil = {
952
954
  * @param lat 纬度
953
955
  * @returns 返回格式化后的经纬度字符串,格式为:经度度分秒,纬度度分秒
954
956
  */
955
- formatLnglat(lng, lat) {
957
+ static formatLnglat(lng, lat) {
956
958
  let res = "";
957
959
  function formatDegreeToDMS(valueInDegrees) {
958
960
  const degree = Math.floor(valueInDegrees);
@@ -968,7 +970,7 @@ const GeoUtil = {
968
970
  res = formatDegreeToDMS(lat);
969
971
  }
970
972
  return res;
971
- },
973
+ }
972
974
  /**
973
975
  * 将经纬度字符串转换为度
974
976
  *
@@ -976,7 +978,7 @@ const GeoUtil = {
976
978
  * @param lat 纬度字符串
977
979
  * @returns 转换后的经纬度对象
978
980
  */
979
- transformLnglat(lng, lat) {
981
+ static transformLnglat(lng, lat) {
980
982
  function dms2deg(dmsString) {
981
983
  const isNegative = /[sw]/i.test(dmsString);
982
984
  let factor = isNegative ? -1 : 1;
@@ -994,7 +996,7 @@ const GeoUtil = {
994
996
  lat: dms2deg(lat)
995
997
  };
996
998
  }
997
- },
999
+ }
998
1000
  /**
999
1001
  * 射线法判断点是否在多边形内
1000
1002
  *
@@ -1002,7 +1004,7 @@ const GeoUtil = {
1002
1004
  * @param poly 多边形顶点数组,可以是字符串数组或对象数组
1003
1005
  * @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
1004
1006
  */
1005
- rayCasting(p, poly) {
1007
+ static rayCasting(p, poly) {
1006
1008
  var px = p.x, py = p.y, flag = false;
1007
1009
  for (var i = 0, l = poly.length, j = l - 1; i < l; j = i, i++) {
1008
1010
  var sx = poly[i].x, sy = poly[i].y, tx = poly[j].x, ty = poly[j].y;
@@ -1020,7 +1022,7 @@ const GeoUtil = {
1020
1022
  }
1021
1023
  }
1022
1024
  return flag ? "in" : "out";
1023
- },
1025
+ }
1024
1026
  /**
1025
1027
  * 旋转点
1026
1028
  *
@@ -1029,11 +1031,11 @@ const GeoUtil = {
1029
1031
  * @param θ 旋转角度(顺时针旋转为正)
1030
1032
  * @returns 旋转后点坐标
1031
1033
  */
1032
- rotatePoint(p1, p2, θ) {
1034
+ static rotatePoint(p1, p2, θ) {
1033
1035
  const x = (p1.x - p2.x) * Math.cos(Math.PI / 180 * -θ) - (p1.y - p2.y) * Math.sin(Math.PI / 180 * -θ) + p2.x;
1034
1036
  const y = (p1.x - p2.x) * Math.sin(Math.PI / 180 * -θ) + (p1.y - p2.y) * Math.cos(Math.PI / 180 * -θ) + p2.y;
1035
1037
  return { x, y };
1036
- },
1038
+ }
1037
1039
  /**
1038
1040
  * 根据两个平面坐标点计算方位角和距离
1039
1041
  *
@@ -1041,7 +1043,7 @@ const GeoUtil = {
1041
1043
  * @param p2 第二个点的坐标对象
1042
1044
  * @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
1043
1045
  */
1044
- calcBearAndDis(p1, p2) {
1046
+ static calcBearAndDis(p1, p2) {
1045
1047
  const { x: x1, y: y1 } = p1;
1046
1048
  const { x: x2, y: y2 } = p2;
1047
1049
  const dx = x2 - x1;
@@ -1050,7 +1052,7 @@ const GeoUtil = {
1050
1052
  const angleInRadians = Math.atan2(dy, dx);
1051
1053
  const angle = (angleInRadians * (180 / Math.PI) + 360 + 90) % 360;
1052
1054
  return { angle, distance };
1053
- },
1055
+ }
1054
1056
  /**
1055
1057
  * 根据两个经纬度点计算方位角和距离
1056
1058
  *
@@ -1058,7 +1060,7 @@ const GeoUtil = {
1058
1060
  * @param latlng2 第二个经纬度点
1059
1061
  * @returns 包含方位角和距离的对象
1060
1062
  */
1061
- calcBearAndDisByPoints(latlng1, latlng2) {
1063
+ static calcBearAndDisByPoints(latlng1, latlng2) {
1062
1064
  var f1 = latlng1.lat * 1, l1 = latlng1.lng * 1, f2 = latlng2.lat * 1, l2 = latlng2.lng * 1;
1063
1065
  var y = Math.sin((l2 - l1) * this.toRadian) * Math.cos(f2 * this.toRadian);
1064
1066
  var x = Math.cos(f1 * this.toRadian) * Math.sin(f2 * this.toRadian) - Math.sin(f1 * this.toRadian) * Math.cos(f2 * this.toRadian) * Math.cos((l2 - l1) * this.toRadian);
@@ -1072,7 +1074,7 @@ const GeoUtil = {
1072
1074
  angle,
1073
1075
  distance
1074
1076
  };
1075
- },
1077
+ }
1076
1078
  /**
1077
1079
  * 计算点P到线段P1P2的最短距离
1078
1080
  *
@@ -1081,7 +1083,7 @@ const GeoUtil = {
1081
1083
  * @param p2 线段终点P2的坐标
1082
1084
  * @returns 点P到线段P1P2的最短距离
1083
1085
  */
1084
- distanceToSegment(p, p1, p2) {
1086
+ static distanceToSegment(p, p1, p2) {
1085
1087
  const x = p.x, y = p.y, x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y;
1086
1088
  const cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1);
1087
1089
  if (cross <= 0) {
@@ -1095,7 +1097,7 @@ const GeoUtil = {
1095
1097
  const px = x1 + (x2 - x1) * r;
1096
1098
  const py = y1 + (y2 - y1) * r;
1097
1099
  return Math.sqrt((x - px) * (x - px) + (y - py) * (y - py));
1098
- },
1100
+ }
1099
1101
  /**
1100
1102
  * 根据给定的经纬度、角度和距离计算新的经纬度点
1101
1103
  *
@@ -1104,7 +1106,7 @@ const GeoUtil = {
1104
1106
  * @param distance 距离值,单位为米,表示从当前点出发的距离
1105
1107
  * @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
1106
1108
  */
1107
- calcPointByBearAndDis(latlng, angle, distance) {
1109
+ static calcPointByBearAndDis(latlng, angle, distance) {
1108
1110
  const sLat = MathUtils.deg2Rad(latlng.lat * 1);
1109
1111
  const sLng = MathUtils.deg2Rad(latlng.lng * 1);
1110
1112
  const d = distance / this.R;
@@ -1115,7 +1117,7 @@ const GeoUtil = {
1115
1117
  lat: MathUtils.rad2Deg(lat),
1116
1118
  lng: MathUtils.rad2Deg(lon)
1117
1119
  };
1118
- },
1120
+ }
1119
1121
  /**
1120
1122
  * 将墨卡托坐标转换为经纬度坐标
1121
1123
  *
@@ -1123,12 +1125,12 @@ const GeoUtil = {
1123
1125
  * @param y 墨卡托坐标的y值
1124
1126
  * @returns 返回包含转换后的经度lng和纬度lat的对象
1125
1127
  */
1126
- mercatorTolonlat(x, y) {
1128
+ static mercatorTolonlat(x, y) {
1127
1129
  const lng = x / 2003750834e-2 * 180;
1128
1130
  var mmy = y / 2003750834e-2 * 180;
1129
1131
  const lat = 180 / Math.PI * (2 * Math.atan(Math.exp(mmy * Math.PI / 180)) - Math.PI / 2);
1130
1132
  return { lng, lat };
1131
- },
1133
+ }
1132
1134
  /**
1133
1135
  * 将经纬度坐标转换为墨卡托坐标
1134
1136
  *
@@ -1136,13 +1138,13 @@ const GeoUtil = {
1136
1138
  * @param lat 纬度值
1137
1139
  * @returns 墨卡托坐标对象,包含x和y属性
1138
1140
  */
1139
- lonlatToMercator(lng, lat) {
1141
+ static lonlatToMercator(lng, lat) {
1140
1142
  var earthRad = 6378137;
1141
1143
  const x = lng * Math.PI / 180 * earthRad;
1142
1144
  var a = lat * Math.PI / 180;
1143
1145
  const y = earthRad / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a)));
1144
1146
  return { x, y };
1145
- },
1147
+ }
1146
1148
  /**
1147
1149
  * 根据百分比获取坐标
1148
1150
  *
@@ -1151,11 +1153,13 @@ const GeoUtil = {
1151
1153
  * @param percent 百分比,取值范围0-1
1152
1154
  * @returns 返回插值后的坐标
1153
1155
  */
1154
- interpolate({ x: x1, y: y1, z: z1 = 0 }, { x: x2, y: y2, z: z2 = 0 }, percent) {
1156
+ static interpolate({ x: x1, y: y1, z: z1 = 0 }, { x: x2, y: y2, z: z2 = 0 }, percent) {
1155
1157
  const dx = x2 - x1, dy = y2 - y1, dz = z2 - z1;
1156
1158
  return { x: x1 + dx * percent, y: y1 + dy * percent, z: z1 + dz * percent };
1157
1159
  }
1158
- };
1160
+ }
1161
+ __publicField(GeoUtil, "toRadian", Math.PI / 180);
1162
+ __publicField(GeoUtil, "R", 6371393);
1159
1163
  const StringUtil = {
1160
1164
  /**
1161
1165
  * 校验字符串是否符合指定类型
@@ -1310,6 +1314,52 @@ const StringUtil = {
1310
1314
  }
1311
1315
  }
1312
1316
  return str;
1317
+ },
1318
+ string2Bytes(str) {
1319
+ const bytes = [];
1320
+ let c;
1321
+ const len = str.length;
1322
+ for (let i = 0; i < len; i++) {
1323
+ c = str.charCodeAt(i);
1324
+ if (c >= 65536 && c <= 1114111) {
1325
+ bytes.push(c >> 18 & 7 | 240);
1326
+ bytes.push(c >> 12 & 63 | 128);
1327
+ bytes.push(c >> 6 & 63 | 128);
1328
+ bytes.push(c & 63 | 128);
1329
+ } else if (c >= 2048 && c <= 65535) {
1330
+ bytes.push(c >> 12 & 15 | 224);
1331
+ bytes.push(c >> 6 & 63 | 128);
1332
+ bytes.push(c & 63 | 128);
1333
+ } else if (c >= 128 && c <= 2047) {
1334
+ bytes.push(c >> 6 & 31 | 192);
1335
+ bytes.push(c & 63 | 128);
1336
+ } else {
1337
+ bytes.push(c & 255);
1338
+ }
1339
+ }
1340
+ return new Uint8Array(bytes);
1341
+ },
1342
+ bytes2String(uint8arr) {
1343
+ if (typeof uint8arr === "string") {
1344
+ return uint8arr;
1345
+ }
1346
+ let str = "";
1347
+ const _arr = uint8arr;
1348
+ for (let i = 0; i < _arr.length; i++) {
1349
+ const one = _arr[i].toString(2), v = one.match(/^1+?(?=0)/);
1350
+ if (v && one.length == 8) {
1351
+ const bytesLength = v[0].length;
1352
+ let store = _arr[i].toString(2).slice(7 - bytesLength);
1353
+ for (let st = 1; st < bytesLength; st++) {
1354
+ store += _arr[st + i].toString(2).slice(2);
1355
+ }
1356
+ str += String.fromCharCode(parseInt(store, 2));
1357
+ i += bytesLength - 1;
1358
+ } else {
1359
+ str += String.fromCharCode(_arr[i]);
1360
+ }
1361
+ }
1362
+ return str;
1313
1363
  }
1314
1364
  };
1315
1365
  const TYPES = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"];
@@ -1561,6 +1611,13 @@ const AssertUtil = {
1561
1611
  }
1562
1612
  });
1563
1613
  },
1614
+ assertInteger(...arg) {
1615
+ arg.forEach((a) => {
1616
+ if (!CommUtils.isInteger(a)) {
1617
+ throw Error(ErrorType.PARAMETER_ERROR_INTEGER + " -> " + a);
1618
+ }
1619
+ });
1620
+ },
1564
1621
  assertNumber(...arg) {
1565
1622
  arg.forEach((a) => {
1566
1623
  if (!CommUtils.isNumber(a)) {
@@ -1620,6 +1677,16 @@ const AssertUtil = {
1620
1677
  throw Error(ErrorType.STRING_CHECK_LOSS + " -> " + str);
1621
1678
  }
1622
1679
  },
1680
+ assertStartWith(value, prefix) {
1681
+ if (!value.startsWith(prefix)) {
1682
+ throw Error("字符串" + value + "开头不是 -> " + prefix);
1683
+ }
1684
+ },
1685
+ assertEndWith(value, prefix) {
1686
+ if (!value.endsWith(prefix)) {
1687
+ throw Error("字符串" + value + "结尾不是 -> " + prefix);
1688
+ }
1689
+ },
1623
1690
  /**
1624
1691
  * 判断字符串是否合法
1625
1692
  *
@@ -1797,6 +1864,18 @@ const ArrayUtil = {
1797
1864
  difference(...args) {
1798
1865
  if (args.length === 0) return [];
1799
1866
  return this.union(...args).filter((d) => !this.intersection(...args).includes(d));
1867
+ },
1868
+ /**
1869
+ * 对字符串数组进行中文排序
1870
+ *
1871
+ * @param arr 待排序的字符串数组
1872
+ * @returns 排序后的字符串数组
1873
+ */
1874
+ zhSort(arr) {
1875
+ arr.sort(function(a, b) {
1876
+ return a.localeCompare(b, "zh");
1877
+ });
1878
+ return arr;
1800
1879
  }
1801
1880
  };
1802
1881
  class BrowserUtil {
@@ -2066,7 +2145,7 @@ class BrowserUtil {
2066
2145
  }
2067
2146
  hander && clearInterval(hander);
2068
2147
  };
2069
- hander = setInterval(function() {
2148
+ hander = window.setInterval(function() {
2070
2149
  let ips = [...ipSet];
2071
2150
  if (ips.length) {
2072
2151
  closeConnect();
@@ -2111,10 +2190,8 @@ __publicField(BrowserUtil, "document", window == null ? void 0 : window.document
2111
2190
  __publicField(BrowserUtil, "navigator", window == null ? void 0 : window.navigator);
2112
2191
  __publicField(BrowserUtil, "userAgent", (_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent);
2113
2192
  __publicField(BrowserUtil, "screen", window == null ? void 0 : window.screen);
2114
- const CoordsUtil = {
2115
- PI: 3.141592653589793,
2116
- XPI: 3.141592653589793 * 3e3 / 180,
2117
- delta(lat, lng) {
2193
+ class CoordsUtil {
2194
+ static delta(lat, lng) {
2118
2195
  const a = 6378245;
2119
2196
  const ee = 0.006693421622965943;
2120
2197
  let dLat = this.transformLat(lng - 105, lat - 35);
@@ -2126,7 +2203,7 @@ const CoordsUtil = {
2126
2203
  dLat = dLat * 180 / (a * (1 - ee) / (magic * sqrtMagic) * this.PI);
2127
2204
  dLon = dLon * 180 / (a / sqrtMagic * Math.cos(radLat) * this.PI);
2128
2205
  return { lat: dLat, lng: dLon };
2129
- },
2206
+ }
2130
2207
  /**
2131
2208
  * 判断经纬度是否不在中国境内
2132
2209
  *
@@ -2134,7 +2211,7 @@ const CoordsUtil = {
2134
2211
  * @param lat 纬度
2135
2212
  * @returns 如果经纬度不在中国境内则返回true,否则返回false
2136
2213
  */
2137
- outOfChina(lng, lat) {
2214
+ static outOfChina(lng, lat) {
2138
2215
  if (lng < 72.004 || lng > 137.8347) {
2139
2216
  return true;
2140
2217
  }
@@ -2142,25 +2219,25 @@ const CoordsUtil = {
2142
2219
  return true;
2143
2220
  }
2144
2221
  return false;
2145
- },
2222
+ }
2146
2223
  // WGS-84 to GCJ-02
2147
- gcjEncrypt(wgsLat, wgsLon) {
2224
+ static gcjEncrypt(wgsLat, wgsLon) {
2148
2225
  if (this.outOfChina(wgsLat, wgsLon)) {
2149
2226
  return { lat: wgsLat, lng: wgsLon };
2150
2227
  }
2151
2228
  const d = this.delta(wgsLat, wgsLon);
2152
2229
  return { lat: wgsLat + d.lat, lng: wgsLon + d.lng };
2153
- },
2230
+ }
2154
2231
  // GCJ-02 to WGS-84
2155
- gcjDecrypt(gcjLat, gcjLon) {
2232
+ static gcjDecrypt(gcjLat, gcjLon) {
2156
2233
  if (this.outOfChina(gcjLat, gcjLon)) {
2157
2234
  return { lat: gcjLat, lng: gcjLon };
2158
2235
  }
2159
2236
  const d = this.delta(gcjLat, gcjLon);
2160
2237
  return { lat: gcjLat - d.lat, lng: gcjLon - d.lng };
2161
- },
2238
+ }
2162
2239
  // GCJ-02 to WGS-84 exactly
2163
- gcjDecryptExact(gcjLat, gcjLon) {
2240
+ static gcjDecryptExact(gcjLat, gcjLon) {
2164
2241
  const initDelta = 0.01;
2165
2242
  const threshold = 1e-9;
2166
2243
  let dLat = initDelta;
@@ -2188,9 +2265,9 @@ const CoordsUtil = {
2188
2265
  if (++i > 1e4) break;
2189
2266
  }
2190
2267
  return { lat: wgsLat, lng: wgsLon };
2191
- },
2268
+ }
2192
2269
  // GCJ-02 to BD-09
2193
- bdEncrypt(gcjLat, gcjLon) {
2270
+ static bdEncrypt(gcjLat, gcjLon) {
2194
2271
  const x = gcjLon;
2195
2272
  const y = gcjLat;
2196
2273
  const z = Math.sqrt(x * x + y * y) + 2e-5 * Math.sin(y * this.XPI);
@@ -2198,9 +2275,9 @@ const CoordsUtil = {
2198
2275
  const bdLon = z * Math.cos(theta) + 65e-4;
2199
2276
  const bdLat = z * Math.sin(theta) + 6e-3;
2200
2277
  return { lat: bdLat, lng: bdLon };
2201
- },
2278
+ }
2202
2279
  // BD-09 to GCJ-02
2203
- bdDecrypt(bdLat, bdLon) {
2280
+ static bdDecrypt(bdLat, bdLon) {
2204
2281
  const x = bdLon - 65e-4;
2205
2282
  const y = bdLat - 6e-3;
2206
2283
  const z = Math.sqrt(x * x + y * y) - 2e-5 * Math.sin(y * this.XPI);
@@ -2208,37 +2285,37 @@ const CoordsUtil = {
2208
2285
  const gcjLon = z * Math.cos(theta);
2209
2286
  const gcjLat = z * Math.sin(theta);
2210
2287
  return { lat: gcjLat, lng: gcjLon };
2211
- },
2288
+ }
2212
2289
  // WGS-84 to Web mercator
2213
2290
  // mercatorLat -> y mercatorLon -> x
2214
- mercatorEncrypt(wgsLat, wgsLon) {
2291
+ static mercatorEncrypt(wgsLat, wgsLon) {
2215
2292
  const x = wgsLon * 2003750834e-2 / 180;
2216
2293
  let y = Math.log(Math.tan((90 + wgsLat) * this.PI / 360)) / (this.PI / 180);
2217
2294
  y = y * 2003750834e-2 / 180;
2218
2295
  return { lat: y, lng: x };
2219
- },
2296
+ }
2220
2297
  // Web mercator to WGS-84
2221
2298
  // mercatorLat -> y mercatorLon -> x
2222
- mercatorDecrypt(mercatorLat, mercatorLon) {
2299
+ static mercatorDecrypt(mercatorLat, mercatorLon) {
2223
2300
  const x = mercatorLon / 2003750834e-2 * 180;
2224
2301
  let y = mercatorLat / 2003750834e-2 * 180;
2225
2302
  y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180)) - this.PI / 2);
2226
2303
  return { lat: y, lng: x };
2227
- },
2228
- transformLat(x, y) {
2304
+ }
2305
+ static transformLat(x, y) {
2229
2306
  let ret = -100 + 2 * x + 3 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
2230
2307
  ret += (20 * Math.sin(6 * x * this.PI) + 20 * Math.sin(2 * x * this.PI)) * 2 / 3;
2231
2308
  ret += (20 * Math.sin(y * this.PI) + 40 * Math.sin(y / 3 * this.PI)) * 2 / 3;
2232
2309
  ret += (160 * Math.sin(y / 12 * this.PI) + 320 * Math.sin(y * this.PI / 30)) * 2 / 3;
2233
2310
  return ret;
2234
- },
2235
- transformLon(x, y) {
2311
+ }
2312
+ static transformLon(x, y) {
2236
2313
  let ret = 300 + x + 2 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
2237
2314
  ret += (20 * Math.sin(6 * x * this.PI) + 20 * Math.sin(2 * x * this.PI)) * 2 / 3;
2238
2315
  ret += (20 * Math.sin(x * this.PI) + 40 * Math.sin(x / 3 * this.PI)) * 2 / 3;
2239
2316
  ret += (150 * Math.sin(x / 12 * this.PI) + 300 * Math.sin(x / 30 * this.PI)) * 2 / 3;
2240
2317
  return ret;
2241
- },
2318
+ }
2242
2319
  /**
2243
2320
  * 生成一个介于两个坐标之间的随机坐标
2244
2321
  *
@@ -2246,12 +2323,12 @@ const CoordsUtil = {
2246
2323
  * @param end 结束坐标,包含x和y属性
2247
2324
  * @returns 返回一个包含x和y属性的随机坐标
2248
2325
  */
2249
- random({ x: minX, y: minY }, { x: maxX, y: maxY }) {
2326
+ static random({ x: minX, y: minY }, { x: maxX, y: maxY }) {
2250
2327
  return {
2251
2328
  x: Math.random() * (maxX - minX) + minX,
2252
2329
  y: Math.random() * (maxY - minY) + minY
2253
2330
  };
2254
- },
2331
+ }
2255
2332
  /**
2256
2333
  * 对坐标数组进行解构并应用函数处理
2257
2334
  *
@@ -2260,7 +2337,7 @@ const CoordsUtil = {
2260
2337
  * @param context 函数执行上下文,可选
2261
2338
  * @returns 处理后的数组
2262
2339
  */
2263
- deCompose(arr, fn, context) {
2340
+ static deCompose(arr, fn, context) {
2264
2341
  if (!Array.isArray(arr)) {
2265
2342
  return context ? fn.call(context, arr) : fn(arr);
2266
2343
  }
@@ -2281,7 +2358,9 @@ const CoordsUtil = {
2281
2358
  }
2282
2359
  return result;
2283
2360
  }
2284
- };
2361
+ }
2362
+ __publicField(CoordsUtil, "PI", 3.141592653589793);
2363
+ __publicField(CoordsUtil, "XPI", 3.141592653589793 * 3e3 / 180);
2285
2364
  const myDate = Object.create(Date);
2286
2365
  myDate.prototype.format = function(fmt = "yyyy-MM-dd hh:mm:ss") {
2287
2366
  const o = {
@@ -2346,17 +2425,8 @@ myDate.prototype.addDate = function(interval, number) {
2346
2425
  }
2347
2426
  return date;
2348
2427
  };
2349
- const DateUtil = {
2350
- lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
2351
- thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
2352
- nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
2353
- lastWeekDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 - 7 - (/* @__PURE__ */ new Date()).getDay()),
2354
- thisWeekDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 - (/* @__PURE__ */ new Date()).getDay()),
2355
- nextWeekDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 + 7 - (/* @__PURE__ */ new Date()).getDay()),
2356
- lastDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() - 1),
2357
- thisDayDate: new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
2358
- nextDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1),
2359
- parseDate(str) {
2428
+ class DateUtil {
2429
+ static parseDate(str) {
2360
2430
  if (typeof str == "string") {
2361
2431
  var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
2362
2432
  if (results && results.length > 3) return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]));
@@ -2383,7 +2453,7 @@ const DateUtil = {
2383
2453
  );
2384
2454
  }
2385
2455
  return null;
2386
- },
2456
+ }
2387
2457
  /**
2388
2458
  * 格式化时间间隔
2389
2459
  *
@@ -2391,7 +2461,7 @@ const DateUtil = {
2391
2461
  * @param endTime 结束时间,可以是字符串、数字或日期类型
2392
2462
  * @returns 返回格式化后的时间间隔字符串,格式为"天数 天 小时 时 分钟 分 秒 秒"或"少于1秒"
2393
2463
  */
2394
- formatDateInterval(startTime, endTime) {
2464
+ static formatDateInterval(startTime, endTime) {
2395
2465
  const dateCreateTime = new Date(startTime);
2396
2466
  const dateFinishTime = new Date(endTime);
2397
2467
  const dateInterval = dateFinishTime.getTime() - dateCreateTime.getTime();
@@ -2419,8 +2489,8 @@ const DateUtil = {
2419
2489
  intervalDes = "少于1秒";
2420
2490
  }
2421
2491
  return intervalDes;
2422
- },
2423
- formatterCounter(times) {
2492
+ }
2493
+ static formatterCounter(times) {
2424
2494
  const checked = function(j) {
2425
2495
  return (j > 10 ? "" : "0") + (j || 0);
2426
2496
  };
@@ -2430,10 +2500,19 @@ const DateUtil = {
2430
2500
  const leave2 = level1 % 60;
2431
2501
  const seconds = checked(Math.round(leave2));
2432
2502
  return `${houres}:${minutes}:${seconds}`;
2433
- },
2434
- sleep(d) {
2435
2503
  }
2436
- };
2504
+ static sleep(d) {
2505
+ }
2506
+ }
2507
+ __publicField(DateUtil, "lastMonthDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1));
2508
+ __publicField(DateUtil, "thisMonthDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1));
2509
+ __publicField(DateUtil, "nextMonthDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1));
2510
+ __publicField(DateUtil, "lastWeekDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 - 7 - (/* @__PURE__ */ new Date()).getDay()));
2511
+ __publicField(DateUtil, "thisWeekDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 - (/* @__PURE__ */ new Date()).getDay()));
2512
+ __publicField(DateUtil, "nextWeekDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 + 7 - (/* @__PURE__ */ new Date()).getDay()));
2513
+ __publicField(DateUtil, "lastDayDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() - 1));
2514
+ __publicField(DateUtil, "thisDayDate", new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)));
2515
+ __publicField(DateUtil, "nextDayDate", new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1));
2437
2516
  function trim(str) {
2438
2517
  return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
2439
2518
  }
@@ -2671,6 +2750,34 @@ const FileUtil = {
2671
2750
  window.URL.revokeObjectURL(link.href);
2672
2751
  }
2673
2752
  };
2753
+ class MessageUtil {
2754
+ static warning(valid, message) {
2755
+ if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
2756
+ console.error(`Warning: ${message}`);
2757
+ }
2758
+ }
2759
+ static note(valid, message) {
2760
+ if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
2761
+ console.warn(`Note: ${message}`);
2762
+ }
2763
+ }
2764
+ static resetWarned() {
2765
+ this.warned = {};
2766
+ }
2767
+ static _call(method, valid, message) {
2768
+ if (!valid && !this.warned[message]) {
2769
+ method(false, message);
2770
+ this.warned[message] = true;
2771
+ }
2772
+ }
2773
+ static warningOnce(valid, message) {
2774
+ this._call(this.warning, valid, message);
2775
+ }
2776
+ static noteOnce(valid, message) {
2777
+ this._call(this.note, valid, message);
2778
+ }
2779
+ }
2780
+ __publicField(MessageUtil, "warned", {});
2674
2781
  const OptimizeUtil = {
2675
2782
  /**
2676
2783
  * 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
@@ -3393,6 +3500,12 @@ __publicField(_MqttClient, "defaultContext", {
3393
3500
  });
3394
3501
  let MqttClient = _MqttClient;
3395
3502
  const _Storage = class _Storage {
3503
+ static useLocal() {
3504
+ this.store = window.localStorage;
3505
+ }
3506
+ static useSession() {
3507
+ this.store = window.sessionStorage;
3508
+ }
3396
3509
  /**
3397
3510
  * 将键值对存储到localStorage中
3398
3511
  *
@@ -3409,13 +3522,13 @@ const _Storage = class _Storage {
3409
3522
  if (expires) {
3410
3523
  data.expires = expires;
3411
3524
  }
3412
- localStorage.setItem(query_key, JSON.stringify(data));
3525
+ this.store.setItem(query_key, JSON.stringify(data));
3413
3526
  } catch (e) {
3414
- if (console) console.warn(`Storage didn't successfully save the '{"${key}": "${value}"}' pair, because the localStorage is full.`);
3527
+ if (console) console.warn(`Storage didn't successfully save the '{"${key}": "${value}"}' pair, because the Storage is full.`);
3415
3528
  }
3416
3529
  }
3417
3530
  /**
3418
- * 从localStorage中获取指定key的存储值
3531
+ * 从Storage中获取指定key的存储值
3419
3532
  *
3420
3533
  * @param key 存储键名
3421
3534
  * @param missing 当获取不到指定key的存储值时返回的默认值
@@ -3425,10 +3538,10 @@ const _Storage = class _Storage {
3425
3538
  static get(key, missing, options) {
3426
3539
  var query_key = this._getPrefixedKey(key, options), value;
3427
3540
  try {
3428
- value = JSON.parse(localStorage.getItem(query_key) || "");
3541
+ value = JSON.parse(this.store.getItem(query_key) || "");
3429
3542
  } catch (e) {
3430
- if (localStorage[query_key]) {
3431
- value = { data: localStorage.getItem(query_key) };
3543
+ if (this.store[query_key]) {
3544
+ value = { data: this.store.getItem(query_key) };
3432
3545
  } else {
3433
3546
  value = null;
3434
3547
  }
@@ -3445,7 +3558,7 @@ const _Storage = class _Storage {
3445
3558
  }
3446
3559
  static keys() {
3447
3560
  const keys = [];
3448
- var allKeys = Object.keys(localStorage);
3561
+ var allKeys = Object.keys(this.store);
3449
3562
  if (_Storage.prefix.length === 0) {
3450
3563
  return allKeys;
3451
3564
  }
@@ -3473,18 +3586,19 @@ const _Storage = class _Storage {
3473
3586
  }
3474
3587
  static remove(key, options) {
3475
3588
  var queryKey = this._getPrefixedKey(key, options);
3476
- localStorage.removeItem(queryKey);
3589
+ this.store.removeItem(queryKey);
3477
3590
  }
3478
3591
  static clear(options) {
3479
3592
  if (_Storage.prefix.length) {
3480
3593
  this.keys().forEach((key) => {
3481
- localStorage.removeItem(this._getPrefixedKey(key, options));
3594
+ this.store.removeItem(this._getPrefixedKey(key, options));
3482
3595
  });
3483
3596
  } else {
3484
- localStorage.clear();
3597
+ this.store.clear();
3485
3598
  }
3486
3599
  }
3487
3600
  };
3601
+ __publicField(_Storage, "store", window.localStorage);
3488
3602
  __publicField(_Storage, "prefix", "");
3489
3603
  __publicField(_Storage, "_getPrefixedKey", function(key, options) {
3490
3604
  options = options || {};
@@ -3520,6 +3634,7 @@ export {
3520
3634
  LineSymbol,
3521
3635
  MathUtils as MathUtil,
3522
3636
  MeasureMode,
3637
+ MessageUtil,
3523
3638
  MqttClient,
3524
3639
  ObjectState,
3525
3640
  ObjectUtil,