gis-common 5.1.28 → 5.1.30
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/gis-common.es.js +21 -10
- package/dist/gis-common.umd.js +1 -1
- package/dist/index.d.ts +7 -6
- package/package.json +1 -1
package/dist/gis-common.es.js
CHANGED
|
@@ -2051,13 +2051,15 @@ const MathUtil = {
|
|
|
2051
2051
|
clamp(val, min, max) {
|
|
2052
2052
|
return Math.max(min, Math.min(max, val));
|
|
2053
2053
|
},
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2054
|
+
formatDistance(value, decimalPlaces = 1) {
|
|
2055
|
+
if (!Number.isInteger(decimalPlaces) || decimalPlaces < 0) {
|
|
2056
|
+
throw new Error("decimalPlaces 必须是非负整数");
|
|
2057
|
+
}
|
|
2058
|
+
if (value < 1e3) {
|
|
2059
|
+
return `${value.toFixed(decimalPlaces)} m`;
|
|
2059
2060
|
} else {
|
|
2060
|
-
|
|
2061
|
+
const kmValue = value / 1e3;
|
|
2062
|
+
return `${kmValue.toFixed(decimalPlaces)} km`;
|
|
2061
2063
|
}
|
|
2062
2064
|
},
|
|
2063
2065
|
formatArea(area, options = { decimal: 1 }) {
|
|
@@ -2862,12 +2864,18 @@ const TreeUtil = {
|
|
|
2862
2864
|
* @param data 树形结构的节点数组
|
|
2863
2865
|
* @returns 展平后的一维节点数组
|
|
2864
2866
|
*/
|
|
2865
|
-
flatTree(data) {
|
|
2867
|
+
flatTree(data, leaf) {
|
|
2866
2868
|
let result = [];
|
|
2867
2869
|
data.forEach((node) => {
|
|
2868
|
-
|
|
2870
|
+
if (leaf) {
|
|
2871
|
+
if (!node.children || node.children.length === 0) {
|
|
2872
|
+
result.push(node);
|
|
2873
|
+
}
|
|
2874
|
+
} else {
|
|
2875
|
+
result.push(node);
|
|
2876
|
+
}
|
|
2869
2877
|
if (node.children && node.children.length > 0) {
|
|
2870
|
-
result = result.concat(this.flatTree(node.children));
|
|
2878
|
+
result = result.concat(this.flatTree(node.children, leaf));
|
|
2871
2879
|
}
|
|
2872
2880
|
});
|
|
2873
2881
|
return result;
|
|
@@ -3470,7 +3478,7 @@ class DateTime extends Date {
|
|
|
3470
3478
|
return fmt;
|
|
3471
3479
|
}
|
|
3472
3480
|
addDate(interval, number) {
|
|
3473
|
-
const date = new
|
|
3481
|
+
const date = new DateTime(this);
|
|
3474
3482
|
switch (interval) {
|
|
3475
3483
|
case "y":
|
|
3476
3484
|
date.setFullYear(this.getFullYear() + number);
|
|
@@ -3502,6 +3510,9 @@ class DateTime extends Date {
|
|
|
3502
3510
|
}
|
|
3503
3511
|
return date;
|
|
3504
3512
|
}
|
|
3513
|
+
getLocalDay() {
|
|
3514
|
+
return ["日", "一", "二", "三", "四", "五", "六"][this.getDay()];
|
|
3515
|
+
}
|
|
3505
3516
|
static lastMonth() {
|
|
3506
3517
|
return new DateTime((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1);
|
|
3507
3518
|
}
|