@orbat-mapper/tactical-draw-adapter-maplibre 0.4.1 → 0.4.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/index.d.mts +2 -0
- package/dist/index.mjs +16 -12
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -65,6 +65,8 @@ declare class PinLayer implements CustomLayerInterface {
|
|
|
65
65
|
private version;
|
|
66
66
|
private resourceRevision;
|
|
67
67
|
private needsDepth;
|
|
68
|
+
/** Whether a pin hit outranks an overlapping ordinary graphic during selection. */
|
|
69
|
+
prioritizesSelection: boolean;
|
|
68
70
|
private elevationCache;
|
|
69
71
|
private pendingElevation;
|
|
70
72
|
private removed;
|
package/dist/index.mjs
CHANGED
|
@@ -439,6 +439,7 @@ function shader(gl, type, source) {
|
|
|
439
439
|
}
|
|
440
440
|
return s;
|
|
441
441
|
}
|
|
442
|
+
const elevationOrSeaLevel = (value) => Number.isFinite(value) ? value : 0;
|
|
442
443
|
/**
|
|
443
444
|
* Appends one instance's worth of vertex-shader input to `data` and extends `ranges`
|
|
444
445
|
* accordingly. Hoisted out of rebuild()'s per-pin loop (ADR n/a) so pushing 10k+ pins
|
|
@@ -471,7 +472,7 @@ function arrowSegmentPoint(center, position, elevationAt, from, to, t) {
|
|
|
471
472
|
return [
|
|
472
473
|
mc.x - center.x,
|
|
473
474
|
mc.y - center.y,
|
|
474
|
-
elevationAt(ll) + 1,
|
|
475
|
+
elevationOrSeaLevel(elevationAt(ll)) + 1,
|
|
475
476
|
0
|
|
476
477
|
];
|
|
477
478
|
}
|
|
@@ -495,6 +496,8 @@ var PinLayer = class {
|
|
|
495
496
|
version = 0;
|
|
496
497
|
resourceRevision = -1;
|
|
497
498
|
needsDepth = false;
|
|
499
|
+
/** Whether a pin hit outranks an overlapping ordinary graphic during selection. */
|
|
500
|
+
prioritizesSelection = false;
|
|
498
501
|
elevationCache = /* @__PURE__ */ new Map();
|
|
499
502
|
pendingElevation = /* @__PURE__ */ new Set();
|
|
500
503
|
removed = false;
|
|
@@ -638,6 +641,7 @@ var PinLayer = class {
|
|
|
638
641
|
}
|
|
639
642
|
}
|
|
640
643
|
this.pins = pins;
|
|
644
|
+
this.prioritizesSelection = pins[0]?.presentation.prioritizePins ?? false;
|
|
641
645
|
if (this.elevationCache.size > pins.length * 60 + 1e3) this.elevationCache.clear();
|
|
642
646
|
if (!this.program) {
|
|
643
647
|
this.onStatus?.({
|
|
@@ -674,13 +678,12 @@ var PinLayer = class {
|
|
|
674
678
|
const pin = this.pins[i], p = pin.presentation;
|
|
675
679
|
const anchor = pinMercator(pin.position);
|
|
676
680
|
anchor.x += Math.round(center.x - anchor.x);
|
|
677
|
-
const
|
|
681
|
+
const sampledElevation = this.elevation(pin.position);
|
|
682
|
+
const hasElevation = Number.isFinite(sampledElevation);
|
|
683
|
+
const elevation = elevationOrSeaLevel(sampledElevation);
|
|
678
684
|
this.elevations[i] = elevation;
|
|
679
|
-
if (
|
|
680
|
-
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
this.pendingElevation.delete(pin.id);
|
|
685
|
+
if (hasElevation) this.pendingElevation.delete(pin.id);
|
|
686
|
+
else this.pendingElevation.add(pin.id);
|
|
684
687
|
const a = [
|
|
685
688
|
anchor.x - center.x,
|
|
686
689
|
anchor.y - center.y,
|
|
@@ -697,7 +700,7 @@ var PinLayer = class {
|
|
|
697
700
|
const opacity = pin.opacity;
|
|
698
701
|
const highlightOnly = pin.highlightOnly;
|
|
699
702
|
const instanceId = i + 1;
|
|
700
|
-
const occlusionFlag = p.occlusion === "terrain" ? 1 : 0;
|
|
703
|
+
const occlusionFlag = hasElevation && p.occlusion === "terrain" ? 1 : 0;
|
|
701
704
|
const worldMode = p.mode === "world" ? 1 : 0;
|
|
702
705
|
const haloColor = rgba(p.halo.color, p.halo.opacity * opacity);
|
|
703
706
|
const stemColor = rgba(p.stem.color, p.stem.opacity * opacity);
|
|
@@ -821,7 +824,7 @@ var PinLayer = class {
|
|
|
821
824
|
this.buildPin(i, center, data, []);
|
|
822
825
|
const slice = this.slices[i];
|
|
823
826
|
const page = this.atlas.entries.get(this.pins[i].resource.id)?.page;
|
|
824
|
-
if (data.length !== slice.length || page !== slice.page) {
|
|
827
|
+
if (data.length !== slice.length || page !== slice.page || previousPending.has(this.pins[i].id) !== this.pendingElevation.has(this.pins[i].id)) {
|
|
825
828
|
this.pendingElevation = previousPending;
|
|
826
829
|
this.dirty = true;
|
|
827
830
|
break;
|
|
@@ -1023,7 +1026,7 @@ var PinLayer = class {
|
|
|
1023
1026
|
const c = pinMercator(ll);
|
|
1024
1027
|
c.x += Math.round(this.origin[0] - c.x);
|
|
1025
1028
|
const world = 512 * 2 ** this.map.getZoom();
|
|
1026
|
-
const [px, py] = this.projectToPixel((c.x - this.origin[0]) * world, (c.y - this.origin[1]) * world, this.elevation(ll) + (p.mode === "world" ? p.heightMeters : 0));
|
|
1029
|
+
const [px, py] = this.projectToPixel((c.x - this.origin[0]) * world, (c.y - this.origin[1]) * world, elevationOrSeaLevel(this.elevation(ll)) + (p.mode === "world" ? p.heightMeters : 0));
|
|
1027
1030
|
return [px, py - (p.mode === "screen" ? p.liftPixels : 0)];
|
|
1028
1031
|
};
|
|
1029
1032
|
return invertPinProjection(project, pin.position, attachment, this.map.getProjection()?.type === "globe" ? 90 : void 0);
|
|
@@ -2611,7 +2614,7 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
2611
2614
|
bearing: this.getBearing()
|
|
2612
2615
|
});
|
|
2613
2616
|
const pinHit = this.pinHit(layerId, [x, y], tol);
|
|
2614
|
-
if (pinHit && (!candidate || pinHit.order >= (this.getFeatureGroupOrder(layerId, candidate.feature.id) ?? -1))) {
|
|
2617
|
+
if (pinHit && (pinHit.prioritize || !candidate || pinHit.order >= (this.getFeatureGroupOrder(layerId, candidate.feature.id) ?? -1))) {
|
|
2615
2618
|
handler({
|
|
2616
2619
|
id: pinHit.id,
|
|
2617
2620
|
feature: pinHit.feature,
|
|
@@ -2696,7 +2699,8 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
2696
2699
|
if (feature) return {
|
|
2697
2700
|
id,
|
|
2698
2701
|
feature,
|
|
2699
|
-
order: this.getFeatureGroupOrder(layerId, feature.id) ?? 0
|
|
2702
|
+
order: this.getFeatureGroupOrder(layerId, feature.id) ?? 0,
|
|
2703
|
+
prioritize: pinLayer.prioritizesSelection
|
|
2700
2704
|
};
|
|
2701
2705
|
}
|
|
2702
2706
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw-adapter-maplibre",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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/
|
|
41
|
-
"@orbat-mapper/
|
|
40
|
+
"@orbat-mapper/control-measures": "^0.27.0",
|
|
41
|
+
"@orbat-mapper/tactical-draw": "^0.9.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"maplibre-gl": ">=5.8.0 <7.0.0"
|