@orbat-mapper/tactical-draw-adapter-maplibre 0.4.2 → 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.mjs +10 -10
- package/package.json +1 -1
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
|
}
|
|
@@ -677,13 +678,12 @@ var PinLayer = class {
|
|
|
677
678
|
const pin = this.pins[i], p = pin.presentation;
|
|
678
679
|
const anchor = pinMercator(pin.position);
|
|
679
680
|
anchor.x += Math.round(center.x - anchor.x);
|
|
680
|
-
const
|
|
681
|
+
const sampledElevation = this.elevation(pin.position);
|
|
682
|
+
const hasElevation = Number.isFinite(sampledElevation);
|
|
683
|
+
const elevation = elevationOrSeaLevel(sampledElevation);
|
|
681
684
|
this.elevations[i] = elevation;
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
this.pendingElevation.delete(pin.id);
|
|
685
|
+
if (hasElevation) this.pendingElevation.delete(pin.id);
|
|
686
|
+
else this.pendingElevation.add(pin.id);
|
|
687
687
|
const a = [
|
|
688
688
|
anchor.x - center.x,
|
|
689
689
|
anchor.y - center.y,
|
|
@@ -700,7 +700,7 @@ var PinLayer = class {
|
|
|
700
700
|
const opacity = pin.opacity;
|
|
701
701
|
const highlightOnly = pin.highlightOnly;
|
|
702
702
|
const instanceId = i + 1;
|
|
703
|
-
const occlusionFlag = p.occlusion === "terrain" ? 1 : 0;
|
|
703
|
+
const occlusionFlag = hasElevation && p.occlusion === "terrain" ? 1 : 0;
|
|
704
704
|
const worldMode = p.mode === "world" ? 1 : 0;
|
|
705
705
|
const haloColor = rgba(p.halo.color, p.halo.opacity * opacity);
|
|
706
706
|
const stemColor = rgba(p.stem.color, p.stem.opacity * opacity);
|
|
@@ -824,7 +824,7 @@ var PinLayer = class {
|
|
|
824
824
|
this.buildPin(i, center, data, []);
|
|
825
825
|
const slice = this.slices[i];
|
|
826
826
|
const page = this.atlas.entries.get(this.pins[i].resource.id)?.page;
|
|
827
|
-
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)) {
|
|
828
828
|
this.pendingElevation = previousPending;
|
|
829
829
|
this.dirty = true;
|
|
830
830
|
break;
|
|
@@ -1026,7 +1026,7 @@ var PinLayer = class {
|
|
|
1026
1026
|
const c = pinMercator(ll);
|
|
1027
1027
|
c.x += Math.round(this.origin[0] - c.x);
|
|
1028
1028
|
const world = 512 * 2 ** this.map.getZoom();
|
|
1029
|
-
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));
|
|
1030
1030
|
return [px, py - (p.mode === "screen" ? p.liftPixels : 0)];
|
|
1031
1031
|
};
|
|
1032
1032
|
return invertPinProjection(project, pin.position, attachment, this.map.getProjection()?.type === "globe" ? 90 : void 0);
|
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",
|