gis-common 5.1.28 → 5.1.29

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.
@@ -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
- formatLength(length, options = { decimal: 1 }) {
2055
- const { decimal } = options;
2056
- if (length >= 1e3) {
2057
- const km = length / 1e3;
2058
- return km % 1 === 0 ? `${km.toFixed(0)}km` : `${km.toFixed(decimal).replace(/\.?0+$/, "")}km`;
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
- return length % 1 === 0 ? `${length.toFixed(0)}m` : `${length.toFixed(decimal).replace(/\.?0+$/, "")}m`;
2061
+ const kmValue = value / 1e3;
2062
+ return `${kmValue.toFixed(decimalPlaces)} km`;
2061
2063
  }
2062
2064
  },
2063
2065
  formatArea(area, options = { decimal: 1 }) {
@@ -3502,6 +3504,9 @@ class DateTime extends Date {
3502
3504
  }
3503
3505
  return date;
3504
3506
  }
3507
+ getLocalDay() {
3508
+ return ["日", "一", "二", "三", "四", "五", "六"][this.getDay()];
3509
+ }
3505
3510
  static lastMonth() {
3506
3511
  return new DateTime((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1);
3507
3512
  }