@watergis/maplibre-gl-terradraw 1.3.2 → 1.3.3
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/maplibre-gl-terradraw.es.js +54 -65
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +2 -2
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/helpers/calcArea.d.ts.map +1 -1
- package/dist/types/helpers/calcDistance.d.ts.map +1 -1
- package/dist/types/helpers/capitalize.d.ts.map +1 -1
- package/dist/types/helpers/cleanMaplibreStyle.d.ts.map +1 -1
- package/dist/types/helpers/convertAreaUnit.d.ts.map +1 -1
- package/dist/types/helpers/debounce.d.ts.map +1 -1
- package/dist/types/helpers/getDistanceUnitName.d.ts.map +1 -1
- package/dist/types/helpers/queryElevationByPoint.d.ts.map +1 -1
- package/dist/types/helpers/queryElevationFromRasterDEM.d.ts.map +1 -1
- package/package.json +22 -21
|
@@ -4582,29 +4582,27 @@ class ko extends bo {
|
|
|
4582
4582
|
* @param ids Feature IDs
|
|
4583
4583
|
*/
|
|
4584
4584
|
handleTerradrawFeatureChanged(e, i) {
|
|
4585
|
-
if (!this.map || i === "
|
|
4586
|
-
const
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4585
|
+
if (!this.map || i === "styling") return;
|
|
4586
|
+
const r = [
|
|
4587
|
+
this.measureOptions.pointLayerLabelSpec,
|
|
4588
|
+
this.measureOptions.lineLayerLabelSpec,
|
|
4589
|
+
this.measureOptions.lineLayerNodeSpec,
|
|
4590
|
+
this.measureOptions.polygonLayerSpec
|
|
4591
|
+
].map((l) => l.source);
|
|
4592
|
+
if (i === "delete") {
|
|
4593
|
+
this.clearMeasureFeatures(r, e);
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
const n = this.getTerraDrawInstance();
|
|
4597
|
+
if (!n) return;
|
|
4598
|
+
const a = n.getSnapshot();
|
|
4599
|
+
for (const l of e) {
|
|
4600
|
+
const d = a.find((h) => h.id === l);
|
|
4601
|
+
if (d) {
|
|
4602
|
+
const h = d.geometry.type, c = d.properties.mode;
|
|
4603
|
+
c === "linestring" && h === "LineString" ? this.measureLine(l) : c === "point" && h === "Point" ? this.measurePoint(l) : !["point", "linestring", "select", "render"].includes(c) && h === "Polygon" && this.measurePolygon(l);
|
|
4594
4604
|
} else
|
|
4595
|
-
this.clearMeasureFeatures(
|
|
4596
|
-
n,
|
|
4597
|
-
this.measureOptions.lineLayerNodeSpec.source
|
|
4598
|
-
), this.clearMeasureFeatures(
|
|
4599
|
-
n,
|
|
4600
|
-
this.measureOptions.lineLayerLabelSpec.source
|
|
4601
|
-
), this.clearMeasureFeatures(
|
|
4602
|
-
n,
|
|
4603
|
-
this.measureOptions.polygonLayerSpec.source
|
|
4604
|
-
), this.clearMeasureFeatures(
|
|
4605
|
-
n,
|
|
4606
|
-
this.measureOptions.pointLayerLabelSpec.source
|
|
4607
|
-
);
|
|
4605
|
+
this.clearMeasureFeatures(r, [l]);
|
|
4608
4606
|
}
|
|
4609
4607
|
}
|
|
4610
4608
|
/**
|
|
@@ -4627,20 +4625,20 @@ class ko extends bo {
|
|
|
4627
4625
|
}
|
|
4628
4626
|
/**
|
|
4629
4627
|
* Clear GeoJSON feature related to measure control by TerraDraw feature ID
|
|
4630
|
-
* @param
|
|
4631
|
-
* @param
|
|
4628
|
+
* @param sourceIds the array of source ID to delete
|
|
4629
|
+
* @param ids the array of feature ID. Optional, if undefined, delete all labels for source
|
|
4632
4630
|
* @returns void
|
|
4633
4631
|
*/
|
|
4634
|
-
clearMeasureFeatures(e, i) {
|
|
4635
|
-
var
|
|
4636
|
-
if (
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4632
|
+
clearMeasureFeatures(e, i = void 0) {
|
|
4633
|
+
var o;
|
|
4634
|
+
if (this.map)
|
|
4635
|
+
for (const r of e) {
|
|
4636
|
+
const n = this.map.getStyle().sources[r];
|
|
4637
|
+
n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (i === void 0 ? n.data.features = [] : n.data.features = n.data.features.filter((a) => {
|
|
4638
|
+
var l;
|
|
4639
|
+
return (l = a.properties) != null && l.originalId ? !i.includes(a.properties.originalId) : !i.includes(a.id);
|
|
4640
|
+
}), (o = this.map.getSource(r)) == null || o.setData(n.data));
|
|
4642
4641
|
}
|
|
4643
|
-
), (r = this.map.getSource(i)) == null || r.setData(o.data));
|
|
4644
4642
|
}
|
|
4645
4643
|
/**
|
|
4646
4644
|
* Replace GeoJSON source with updated features for a given source ID
|
|
@@ -4649,32 +4647,35 @@ class ko extends bo {
|
|
|
4649
4647
|
* @param type either 'linestring' or 'point'
|
|
4650
4648
|
*/
|
|
4651
4649
|
replaceGeoJSONSource(e, i, o) {
|
|
4652
|
-
var n;
|
|
4650
|
+
var n, a;
|
|
4653
4651
|
if (!this.map) return;
|
|
4654
4652
|
const r = this.map.getStyle().sources[i];
|
|
4655
4653
|
if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4656
|
-
const
|
|
4654
|
+
const l = [];
|
|
4655
|
+
for (const h of e)
|
|
4656
|
+
(n = this.terradraw) != null && n.getSnapshotFeature(h.id) && l.push(h);
|
|
4657
|
+
const d = l.map((h) => h.id);
|
|
4657
4658
|
if (typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4658
4659
|
o === "linestring" ? r.data.features = [
|
|
4659
4660
|
...r.data.features = r.data.features.filter(
|
|
4660
|
-
(
|
|
4661
|
-
var
|
|
4662
|
-
return !(
|
|
4661
|
+
(c) => {
|
|
4662
|
+
var u;
|
|
4663
|
+
return !(d.includes((u = c.properties) == null ? void 0 : u.originalId) && c.geometry.type === "Point");
|
|
4663
4664
|
}
|
|
4664
4665
|
),
|
|
4665
|
-
...
|
|
4666
|
+
...l
|
|
4666
4667
|
] : o === "point" && (r.data.features = [
|
|
4667
4668
|
...r.data.features = r.data.features.filter(
|
|
4668
|
-
(
|
|
4669
|
+
(c) => !(d.includes(c.id) && c.geometry.type === "Point")
|
|
4669
4670
|
),
|
|
4670
|
-
...
|
|
4671
|
+
...l
|
|
4671
4672
|
]);
|
|
4672
|
-
const
|
|
4673
|
-
r.data.features.forEach((
|
|
4674
|
-
var
|
|
4675
|
-
const
|
|
4676
|
-
|
|
4677
|
-
}), r.data.features = Array.from(Object.values(
|
|
4673
|
+
const h = {};
|
|
4674
|
+
r.data.features.forEach((c) => {
|
|
4675
|
+
var p;
|
|
4676
|
+
const u = c.id;
|
|
4677
|
+
h[u] ? !h[u].properties.elevation && ((p = c.properties) != null && p.elevation) && (h[u] = c) : h[u] = c;
|
|
4678
|
+
}), r.data.features = Array.from(Object.values(h)), (a = this.map.getSource(i)) == null || a.setData(r.data);
|
|
4678
4679
|
}
|
|
4679
4680
|
}
|
|
4680
4681
|
}
|
|
@@ -4801,29 +4802,17 @@ class ko extends bo {
|
|
|
4801
4802
|
* Event definition when feature is deleted by terradraw
|
|
4802
4803
|
*/
|
|
4803
4804
|
onFeatureDeleted(e) {
|
|
4804
|
-
var o, r;
|
|
4805
4805
|
if (!this.map) return;
|
|
4806
4806
|
if (this.getTerraDrawInstance()) {
|
|
4807
|
-
let
|
|
4808
|
-
typeof e == "object" && e !== null && "deletedIds" in e && (
|
|
4809
|
-
const
|
|
4807
|
+
let o = [];
|
|
4808
|
+
typeof e == "object" && e !== null && "deletedIds" in e && (o = e.deletedIds);
|
|
4809
|
+
const n = [
|
|
4810
4810
|
this.measureOptions.pointLayerLabelSpec,
|
|
4811
4811
|
this.measureOptions.lineLayerLabelSpec,
|
|
4812
|
+
this.measureOptions.lineLayerNodeSpec,
|
|
4812
4813
|
this.measureOptions.polygonLayerSpec
|
|
4813
|
-
];
|
|
4814
|
-
|
|
4815
|
-
for (const l of a) {
|
|
4816
|
-
const d = this.map.getStyle().sources[l.source];
|
|
4817
|
-
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter((h) => {
|
|
4818
|
-
var c;
|
|
4819
|
-
return (c = h.properties) != null && c.originalId ? !n.includes(h.properties.originalId) : !n.includes(h.id);
|
|
4820
|
-
})), (o = this.map.getSource(l.source)) == null || o.setData(d.data));
|
|
4821
|
-
}
|
|
4822
|
-
else
|
|
4823
|
-
for (const l of a) {
|
|
4824
|
-
const d = this.map.getStyle().sources[l.source];
|
|
4825
|
-
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (r = this.map.getSource(l.source)) == null || r.setData(d.data));
|
|
4826
|
-
}
|
|
4814
|
+
].map((a) => a.source);
|
|
4815
|
+
o && o.length > 0 ? this.clearMeasureFeatures(n, o) : this.clearMeasureFeatures(n, void 0);
|
|
4827
4816
|
}
|
|
4828
4817
|
}
|
|
4829
4818
|
/**
|