@orbat-mapper/tactical-draw-adapter-maplibre 0.2.0-alpha.20 → 0.2.0-alpha.22
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.d.mts +10 -1
- package/dist/index.mjs +17 -6
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -17,7 +17,16 @@ interface MapLibreGroupBundle {
|
|
|
17
17
|
readonly sourceId: string;
|
|
18
18
|
readonly layerIds: Map<PaintChannel, string>;
|
|
19
19
|
features: readonly Feature[];
|
|
20
|
-
|
|
20
|
+
/** Unset while the stored value describes older features than `features` holds. */
|
|
21
|
+
featureSignature: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Last `FeatureGroup.revision` seen for this bundle, when the producer
|
|
24
|
+
* supplied one. Two consecutive groups with the same `revision` are known
|
|
25
|
+
* to carry byte-identical `features`, so it stands in for `featureSignature`
|
|
26
|
+
* without paying to re-stringify the whole group. A missing revision on
|
|
27
|
+
* either side falls back to the signature comparison — see `applyFeatureGroups`.
|
|
28
|
+
*/
|
|
29
|
+
revision?: number;
|
|
21
30
|
requiredIconIds: ReadonlySet<string>;
|
|
22
31
|
}
|
|
23
32
|
type MapLibreEventToken = (e: any) => void;
|
package/dist/index.mjs
CHANGED
|
@@ -22,6 +22,11 @@ function firstBundleLayerId(bundle) {
|
|
|
22
22
|
if (layerId) return layerId;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
function sameOrder(a, b) {
|
|
26
|
+
if (a.length !== b.length) return false;
|
|
27
|
+
for (let index = 0; index < a.length; index++) if (a[index] !== b[index]) return false;
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
25
30
|
/**
|
|
26
31
|
* Find the largest subset of bundles whose relative order already matches the
|
|
27
32
|
* desired stack. Reorders then move only the remaining bundles.
|
|
@@ -794,14 +799,20 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
794
799
|
if (!bundle) {
|
|
795
800
|
bundle = this.createGroupBundle(layerId, handle);
|
|
796
801
|
handle.groupBundles.set(group.id, bundle);
|
|
797
|
-
bundlesNeedingOrder.add(group.id);
|
|
798
802
|
}
|
|
799
|
-
|
|
800
|
-
|
|
803
|
+
let contentChanged;
|
|
804
|
+
if (!isNewBundle && bundle.revision !== void 0 && group.revision !== void 0) {
|
|
805
|
+
contentChanged = bundle.revision !== group.revision;
|
|
806
|
+
if (contentChanged) bundle.featureSignature = void 0;
|
|
807
|
+
} else {
|
|
808
|
+
const featureSignature = JSON.stringify(group.features);
|
|
809
|
+
contentChanged = isNewBundle || bundle.featureSignature !== featureSignature;
|
|
810
|
+
bundle.featureSignature = featureSignature;
|
|
811
|
+
}
|
|
801
812
|
const requiredIconIds = this.requiredIconIds(group);
|
|
802
813
|
const resourcesChanged = bundle.requiredIconIds.size !== requiredIconIds.size || [...bundle.requiredIconIds].some((id) => !requiredIconIds.has(id));
|
|
803
814
|
bundle.features = group.features;
|
|
804
|
-
bundle.
|
|
815
|
+
bundle.revision = group.revision;
|
|
805
816
|
bundle.requiredIconIds = requiredIconIds;
|
|
806
817
|
if (this.reconcileGroupChannels(handle, bundle, groupPaintChannels(group.features, handle.style))) bundlesNeedingOrder.add(group.id);
|
|
807
818
|
if (contentChanged || resourcesChanged) this.updateGroupBundleSource(bundle);
|
|
@@ -922,12 +933,12 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
922
933
|
orderGroupBundles(handle, previousGroupIds, desiredGroupIds, forcedGroupIds) {
|
|
923
934
|
let beforeId = handle.mlLayerIds[0];
|
|
924
935
|
if (!beforeId) return;
|
|
925
|
-
const stableGroupIds = longestStableGroupIds(previousGroupIds, desiredGroupIds);
|
|
936
|
+
const stableGroupIds = sameOrder(previousGroupIds, desiredGroupIds) ? null : longestStableGroupIds(previousGroupIds, desiredGroupIds);
|
|
926
937
|
for (let index = desiredGroupIds.length - 1; index >= 0; index--) {
|
|
927
938
|
const groupId = desiredGroupIds[index];
|
|
928
939
|
const bundle = handle.groupBundles.get(groupId);
|
|
929
940
|
if (!bundle) continue;
|
|
930
|
-
if (
|
|
941
|
+
if (forcedGroupIds.has(groupId) || stableGroupIds !== null && !stableGroupIds.has(groupId)) for (const channel of PAINT_CHANNELS) {
|
|
931
942
|
const layerId = bundle.layerIds.get(channel);
|
|
932
943
|
if (layerId && this.map.getLayer(layerId)) this.map.moveLayer(layerId, beforeId);
|
|
933
944
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw-adapter-maplibre",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.22",
|
|
4
4
|
"description": "MapLibre GL JS engine adapter for @orbat-mapper/tactical-draw. Draw and edit tactical control measures (MIL-STD-2525 / APP-6) on a MapLibre map.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@orbat-mapper/control-measures": "^0.2.0-alpha.
|
|
41
|
-
"@orbat-mapper/tactical-draw": "^0.2.0-alpha.
|
|
40
|
+
"@orbat-mapper/control-measures": "^0.2.0-alpha.26",
|
|
41
|
+
"@orbat-mapper/tactical-draw": "^0.2.0-alpha.38"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"maplibre-gl": ">=5.8.0 <6.0.0"
|