@orbat-mapper/tactical-draw 0.3.3 → 0.4.1
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 +1 -1
- package/dist/index.mjs +182 -286
- package/dist/{map-adapter-BkDIEriM.d.mts → map-adapter-BWvKku2P.d.mts} +10 -11
- package/dist/testing.d.mts +6 -2
- package/dist/testing.mjs +68 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as EditPointerDriver, S as makeFillPatternImage, T as PointerEventInfo, _ as HatchPattern, a as LayerId, b as fillPatternImageId, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, l as MapEventHandler, m as StyleOptions, n as HandleStyle, o as MapAdapter, p as PixelCoordinate, r as IconResource, s as MapCursor, t as FeatureGroup, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as PointerCallback, x as isMinePattern, y as fillPatternImageDimension } from "./map-adapter-
|
|
1
|
+
import { C as EditPointerDriver, S as makeFillPatternImage, T as PointerEventInfo, _ as HatchPattern, a as LayerId, b as fillPatternImageId, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, l as MapEventHandler, m as StyleOptions, n as HandleStyle, o as MapAdapter, p as PixelCoordinate, r as IconResource, s as MapCursor, t as FeatureGroup, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as PointerCallback, x as isMinePattern, y as fillPatternImageDimension } from "./map-adapter-BWvKku2P.mjs";
|
|
2
2
|
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
3
3
|
import { Feature, Position } from "geojson";
|
|
4
4
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getDefaultOptions, renderControlMeasure, resolveAmplifierPlacement, resolveStyleHints, roundToFixed } from "@orbat-mapper/control-measures";
|
|
1
|
+
import { FILL_PATTERN_DEFINITIONS, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getDefaultOptions, renderControlMeasure, resolveAmplifierPlacement, resolveStyleHints, roundToFixed } from "@orbat-mapper/control-measures";
|
|
2
2
|
function pickPointerType(originalEvent) {
|
|
3
3
|
if (typeof PointerEvent !== "undefined" && originalEvent instanceof PointerEvent) {
|
|
4
4
|
if (originalEvent.pointerType === "touch") return "touch";
|
|
@@ -1275,25 +1275,6 @@ function bakePixelSizeToGround(measure, adapter) {
|
|
|
1275
1275
|
};
|
|
1276
1276
|
}
|
|
1277
1277
|
/**
|
|
1278
|
-
* Stamp the adapter's current `metersPerPixel` onto a measure that sizes itself
|
|
1279
|
-
* in pixels, so the generator resolves pixel options (`radiusPixels`,
|
|
1280
|
-
* `toothSizePixels`, `toothHeightPixels`) against the live map zoom. Returns the
|
|
1281
|
-
* measure unchanged when the adapter has no usable resolution or the
|
|
1282
|
-
* kind/options don't opt into pixel sizing.
|
|
1283
|
-
*/
|
|
1284
|
-
function withAdapterMeasureOptions(measure, adapter) {
|
|
1285
|
-
const mpp = adapter.getResolution();
|
|
1286
|
-
if (mpp === void 0 || mpp <= 0) return measure;
|
|
1287
|
-
if (!measureUsesAdapterResolution(measure)) return measure;
|
|
1288
|
-
return {
|
|
1289
|
-
...measure,
|
|
1290
|
-
options: {
|
|
1291
|
-
...measure.options,
|
|
1292
|
-
metersPerPixel: mpp
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
}
|
|
1296
|
-
/**
|
|
1297
1278
|
* Stamp the draw-time default label size, in its screen-anchored
|
|
1298
1279
|
* (`labelSizePixels`) form, onto a `capturesLabelSize` measure that carries no
|
|
1299
1280
|
* label size of its own (ADR-0028). The pixel form keeps the in-flight
|
|
@@ -1316,21 +1297,39 @@ function withCommittedAdapterMeasureOptions(measure) {
|
|
|
1316
1297
|
};
|
|
1317
1298
|
}
|
|
1318
1299
|
/**
|
|
1319
|
-
* Render a measure with the adapter's
|
|
1300
|
+
* Render a measure with the adapter's live scale supplied through core's
|
|
1301
|
+
* renderer-owned context. The single seam for
|
|
1320
1302
|
* "turn a measure into features against the live map" — every TacticalDraw
|
|
1321
1303
|
* layer write (graphics reconcile, draw preview, edit preview, commit snapshot)
|
|
1322
|
-
* routes through here so pixel sizing is resolved identically everywhere
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
* is never mutated, and callers that need the persisted/working measure to
|
|
1328
|
-
* stay free of these render-only options must keep using that separately
|
|
1329
|
-
* (draw/edit commit paths call [[withCommittedAdapterMeasureOptions]]
|
|
1330
|
-
* directly to produce the value they persist).
|
|
1304
|
+
* routes through here so pixel sizing is resolved identically everywhere. The
|
|
1305
|
+
* adapter resolution is Web Mercator construction scale; converting it to true
|
|
1306
|
+
* ground at the Graphic midpoint lets core's compatibility boundary round-trip
|
|
1307
|
+
* to the same construction scale. Default label capture remains a derived copy
|
|
1308
|
+
* for previews, while the input Graphic is never augmented with live scale.
|
|
1331
1309
|
*/
|
|
1332
1310
|
function renderMeasureForAdapter(adapter, measure, opts) {
|
|
1333
|
-
|
|
1311
|
+
const withLabelSize = withCommittedAdapterMeasureOptions(measure);
|
|
1312
|
+
const resolution = adapter.getResolution();
|
|
1313
|
+
const midpointLatitude = geographicMidpointLatitude(measure.controlPoints);
|
|
1314
|
+
const groundMetersPerCssPixel = resolution !== void 0 && resolution > 0 && midpointLatitude !== void 0 ? resolution * Math.cos(midpointLatitude * Math.PI / 180) : void 0;
|
|
1315
|
+
return renderControlMeasure(withLabelSize, {
|
|
1316
|
+
...opts,
|
|
1317
|
+
context: {
|
|
1318
|
+
...opts?.context,
|
|
1319
|
+
...groundMetersPerCssPixel !== void 0 ? { groundMetersPerCssPixel } : {}
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
/** Geographic bounding-box midpoint latitude used by core's Mercator compatibility boundary. */
|
|
1324
|
+
function geographicMidpointLatitude(points) {
|
|
1325
|
+
if (points.length === 0) return void 0;
|
|
1326
|
+
let min = Infinity;
|
|
1327
|
+
let max = -Infinity;
|
|
1328
|
+
for (const point of points) {
|
|
1329
|
+
min = Math.min(min, point[1]);
|
|
1330
|
+
max = Math.max(max, point[1]);
|
|
1331
|
+
}
|
|
1332
|
+
return (min + max) / 2;
|
|
1334
1333
|
}
|
|
1335
1334
|
//#endregion
|
|
1336
1335
|
//#region src/tactical-draw/run-interaction.ts
|
|
@@ -1547,6 +1546,26 @@ function snappedDrawPosition(snap, event) {
|
|
|
1547
1546
|
originalEvent: event.originalEvent
|
|
1548
1547
|
})?.coordinate ?? event.coordinate;
|
|
1549
1548
|
}
|
|
1549
|
+
/** Read Shift through engine event wrappers without assuming a DOM event type. */
|
|
1550
|
+
function shiftKeyPressed(originalEvent) {
|
|
1551
|
+
let event = originalEvent;
|
|
1552
|
+
for (let depth = 0; depth < 4; depth += 1) {
|
|
1553
|
+
if (typeof event !== "object" || event === null) return false;
|
|
1554
|
+
if ("shiftKey" in event && event.shiftKey === true) return true;
|
|
1555
|
+
if (!("originalEvent" in event)) return false;
|
|
1556
|
+
event = event.originalEvent;
|
|
1557
|
+
}
|
|
1558
|
+
return false;
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Apply a rule's angular constraint to `points` when the gesture asks for it
|
|
1562
|
+
* (Shift held) and the rule defines one. Returns `points` unchanged otherwise,
|
|
1563
|
+
* so callers can use the result unconditionally.
|
|
1564
|
+
*/
|
|
1565
|
+
function constrainedDrawPoints(rule, points, activePointIndex, originalEvent) {
|
|
1566
|
+
if (!rule?.constrainAngles || !shiftKeyPressed(originalEvent)) return points;
|
|
1567
|
+
return rule.constrainAngles(points, activePointIndex);
|
|
1568
|
+
}
|
|
1550
1569
|
const DEFAULT_TOLERANCE_PIXELS = 12;
|
|
1551
1570
|
function graphicCandidates(graphics) {
|
|
1552
1571
|
const candidates = [];
|
|
@@ -1992,7 +2011,9 @@ function runFixedLengthDraw(options) {
|
|
|
1992
2011
|
ctx.commit(buildSnapshot);
|
|
1993
2012
|
return;
|
|
1994
2013
|
}
|
|
2014
|
+
const activePointIndex = committed.length;
|
|
1995
2015
|
committed.push(position);
|
|
2016
|
+
committed.splice(0, committed.length, ...constrainedDrawPoints(rule, committed, activePointIndex, event.originalEvent));
|
|
1996
2017
|
rubberBand = void 0;
|
|
1997
2018
|
if (committed.length >= required) {
|
|
1998
2019
|
ctx.commit(buildSnapshot);
|
|
@@ -2009,8 +2030,9 @@ function runFixedLengthDraw(options) {
|
|
|
2009
2030
|
if (ctx.settled) return;
|
|
2010
2031
|
if (committed.length === 0) return;
|
|
2011
2032
|
rubberBand = snappedDrawPosition(snap, event);
|
|
2033
|
+
const points = constrainedDrawPoints(rule, [...committed, rubberBand], committed.length, event.originalEvent);
|
|
2034
|
+
rubberBand = points[committed.length] ?? rubberBand;
|
|
2012
2035
|
renderPreview();
|
|
2013
|
-
const points = [...committed, rubberBand];
|
|
2014
2036
|
const phase = transientStarted ? "move" : "start";
|
|
2015
2037
|
transientStarted = true;
|
|
2016
2038
|
transientEmitter.emit({
|
|
@@ -2292,7 +2314,7 @@ function runVariableLengthDraw(options) {
|
|
|
2292
2314
|
const idx = insertionIndex(committed.length);
|
|
2293
2315
|
committed.splice(idx, 0, [...pos]);
|
|
2294
2316
|
if (rule) {
|
|
2295
|
-
const derived = rule.derive(committed);
|
|
2317
|
+
const derived = rule.derive(constrainedDrawPoints(rule, committed, idx, event.originalEvent));
|
|
2296
2318
|
committed.splice(0, committed.length, ...derived);
|
|
2297
2319
|
}
|
|
2298
2320
|
committed.splice(0, committed.length, ...roundControlPoints(committed));
|
|
@@ -2312,10 +2334,12 @@ function runVariableLengthDraw(options) {
|
|
|
2312
2334
|
if (ctx.settled) return;
|
|
2313
2335
|
if (committed.length === 0) return;
|
|
2314
2336
|
rubberBand = snappedDrawPosition(snap, event);
|
|
2315
|
-
renderPreview();
|
|
2316
2337
|
const idx = insertionIndex(committed.length);
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2338
|
+
const spine = [...committed];
|
|
2339
|
+
spine.splice(idx, 0, rubberBand);
|
|
2340
|
+
const points = constrainedDrawPoints(rule, spine, idx, event.originalEvent);
|
|
2341
|
+
rubberBand = points[idx] ?? rubberBand;
|
|
2342
|
+
renderPreview();
|
|
2319
2343
|
const phase = transientStarted ? "move" : "start";
|
|
2320
2344
|
transientStarted = true;
|
|
2321
2345
|
transientEmitter.emit({
|
|
@@ -2924,7 +2948,7 @@ function begun(kind, initialBase, move) {
|
|
|
2924
2948
|
drag: {
|
|
2925
2949
|
kind,
|
|
2926
2950
|
move,
|
|
2927
|
-
end: (pixel) => move(pixel).points
|
|
2951
|
+
end: (pixel, modifiers) => move(pixel, modifiers).points
|
|
2928
2952
|
},
|
|
2929
2953
|
initialPoints: clonePoints(initialBase)
|
|
2930
2954
|
};
|
|
@@ -2941,14 +2965,17 @@ function beginHandleDrag(args) {
|
|
|
2941
2965
|
const { hit, points, projection, rule } = args;
|
|
2942
2966
|
const { fromPixel } = projection;
|
|
2943
2967
|
const preDragPoints = clonePoints(points);
|
|
2944
|
-
const snap = (next, activePointIndex) =>
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2968
|
+
const snap = (next, activePointIndex, modifiers) => {
|
|
2969
|
+
const transformed = rule ? rule.transform({
|
|
2970
|
+
previous: preDragPoints,
|
|
2971
|
+
next,
|
|
2972
|
+
activePointIndex
|
|
2973
|
+
}) : next;
|
|
2974
|
+
return modifiers?.constrainAngles && rule?.constrainAngles ? rule.constrainAngles(transformed, activePointIndex) : transformed;
|
|
2975
|
+
};
|
|
2949
2976
|
const dragOnePoint = (base, activeIndex) => {
|
|
2950
|
-
const move = (pixel) => {
|
|
2951
|
-
return { points: snap(base.map((p, i) => i === activeIndex ? fromPixel(pixel) : [...p]), activeIndex) };
|
|
2977
|
+
const move = (pixel, modifiers) => {
|
|
2978
|
+
return { points: snap(base.map((p, i) => i === activeIndex ? fromPixel(pixel) : [...p]), activeIndex, modifiers) };
|
|
2952
2979
|
};
|
|
2953
2980
|
return move;
|
|
2954
2981
|
};
|
|
@@ -4840,7 +4867,7 @@ function runEdit(opts) {
|
|
|
4840
4867
|
function paintDragSnapshot(pixel, info) {
|
|
4841
4868
|
if (!activeDrag) return;
|
|
4842
4869
|
const resolvedPixel = snappedPixel(pixel, info, "reshape", activeDrag.controlPointIndex);
|
|
4843
|
-
const snapshot = activeDrag.fsm.move(resolvedPixel);
|
|
4870
|
+
const snapshot = activeDrag.fsm.move(resolvedPixel, { constrainAngles: info?.shiftKey });
|
|
4844
4871
|
workingPoints.splice(0, workingPoints.length, ...snapshot.points);
|
|
4845
4872
|
renderWorkingGraphic();
|
|
4846
4873
|
renderHandlesLayer();
|
|
@@ -4941,7 +4968,7 @@ function runEdit(opts) {
|
|
|
4941
4968
|
const { fsm, preDragPoints, controlPointIndex } = activeDrag;
|
|
4942
4969
|
activeDrag = null;
|
|
4943
4970
|
driver.setDragPanEnabled(true);
|
|
4944
|
-
const next = fsm.end(snappedPixel(pixel, info, "reshape", controlPointIndex));
|
|
4971
|
+
const next = fsm.end(snappedPixel(pixel, info, "reshape", controlPointIndex), { constrainAngles: info?.shiftKey });
|
|
4945
4972
|
emitTransient("end", next, controlPointIndex);
|
|
4946
4973
|
replaceWorkingPoints(preDragPoints);
|
|
4947
4974
|
commitGesture(next);
|
|
@@ -8164,38 +8191,15 @@ function resolveSlot(adapter, supplied, owned) {
|
|
|
8164
8191
|
* to {@link HatchPattern}, so adapters can test membership and build filter
|
|
8165
8192
|
* expressions without re-spelling the pattern vocabulary.
|
|
8166
8193
|
*/
|
|
8167
|
-
const HATCH_PATTERNS =
|
|
8168
|
-
"hatch",
|
|
8169
|
-
"reverse-hatch",
|
|
8170
|
-
"cross-hatch",
|
|
8171
|
-
"horizontal",
|
|
8172
|
-
"vertical",
|
|
8173
|
-
"dots",
|
|
8174
|
-
"mine-unspecified",
|
|
8175
|
-
"mine-antipersonnel",
|
|
8176
|
-
"mine-antipersonnel-directional",
|
|
8177
|
-
"mine-antitank",
|
|
8178
|
-
"mine-antitank-antihandling",
|
|
8179
|
-
"mine-wide-area-antitank",
|
|
8180
|
-
"mine-cluster"
|
|
8181
|
-
];
|
|
8194
|
+
const HATCH_PATTERNS = NON_SOLID_FILL_PATTERNS;
|
|
8182
8195
|
/** Tile edge length, CSS px, before `pixelRatio` scaling. Kept a power of two. */
|
|
8183
8196
|
const BASE_TILE_SIZE = 32;
|
|
8184
8197
|
/** Tile edge, CSS px, of the mine-pictogram family (they use the full 32-unit tile). */
|
|
8185
|
-
const MINE_PATTERN_TILE_SIZE =
|
|
8198
|
+
const MINE_PATTERN_TILE_SIZE = FILL_PATTERN_DEFINITIONS["mine-unspecified"].tile.width;
|
|
8186
8199
|
/** True for the mine-pictogram family — a screen-space glyph texture rather than a repeating hatch. */
|
|
8187
8200
|
function isMinePattern(pattern) {
|
|
8188
8201
|
return pattern.startsWith("mine-");
|
|
8189
8202
|
}
|
|
8190
|
-
/** Line spacing as a fraction of the tile edge — 4 repeats per tile. */
|
|
8191
|
-
const SPACING_DIVISOR = 4;
|
|
8192
|
-
/**
|
|
8193
|
-
* Dot radius, CSS px, before `pixelRatio` scaling — the `"dots"` counterpart to
|
|
8194
|
-
* the 1px line width, sized so a dot reads at the same weight as a hatch line.
|
|
8195
|
-
* Must stay in lockstep with the vector tiles in the Leaflet adapter and the
|
|
8196
|
-
* static previews.
|
|
8197
|
-
*/
|
|
8198
|
-
const DOT_RADIUS = 1.25;
|
|
8199
8203
|
/**
|
|
8200
8204
|
* Stable id for a rasterized tile, keyed by pattern and color. Adapters use
|
|
8201
8205
|
* this as the image-registry key (MapLibre `addImage` id, OpenLayers pattern
|
|
@@ -8267,40 +8271,6 @@ function parseColor(color) {
|
|
|
8267
8271
|
a: 1
|
|
8268
8272
|
};
|
|
8269
8273
|
}
|
|
8270
|
-
/** `v mod m`, folded into `[-m/2, m/2)`. Used to find distance to the nearest line in a periodic family. */
|
|
8271
|
-
function centeredMod(v, m) {
|
|
8272
|
-
const wrapped = (v % m + m) % m;
|
|
8273
|
-
return wrapped >= m / 2 ? wrapped - m : wrapped;
|
|
8274
|
-
}
|
|
8275
|
-
const SQRT2 = Math.SQRT2;
|
|
8276
|
-
/**
|
|
8277
|
-
* Coverage in `[0, 1]` of one diagonal line family (slope +1 or -1, both
|
|
8278
|
-
* period `spacing`) at pixel center `(x, y)`, antialiased over a ~1 device-px
|
|
8279
|
-
* band. `axis` selects `y - x` (the "/" hatch) or `y + x` (the "\" mirror,
|
|
8280
|
-
* "reverse-hatch", which "cross-hatch" unions on top of the hatch). Because `spacing`
|
|
8281
|
-
* divides the tile dimension evenly, shifting
|
|
8282
|
-
* `x` or `y` by a whole tile is a whole number of `spacing` periods, so the
|
|
8283
|
-
* mod-distance — and therefore the coverage — is identical at the tile edges
|
|
8284
|
-
* as at their wrapped continuation. That periodicity is what makes the tile
|
|
8285
|
-
* seamless.
|
|
8286
|
-
*/
|
|
8287
|
-
function lineCoverage(x, y, spacing, lineWidth, axis) {
|
|
8288
|
-
const t = axis === "/" ? y - x : axis === "\\" ? y + x : (axis === "-" ? y : x) - spacing / 2;
|
|
8289
|
-
const raw = Math.abs(centeredMod(t, spacing));
|
|
8290
|
-
const perpDist = axis === "/" || axis === "\\" ? raw / SQRT2 : raw;
|
|
8291
|
-
const halfWidth = lineWidth / 2;
|
|
8292
|
-
return Math.min(1, Math.max(0, halfWidth + .5 - perpDist));
|
|
8293
|
-
}
|
|
8294
|
-
/**
|
|
8295
|
-
* Coverage in `[0, 1]` of a square lattice of dots — one per `spacing × spacing`
|
|
8296
|
-
* cell, centered in the cell so the tile stays seamless — antialiased over the
|
|
8297
|
-
* same ~1px band as {@link lineCoverage}.
|
|
8298
|
-
*/
|
|
8299
|
-
function dotCoverage(x, y, spacing, radius) {
|
|
8300
|
-
const dx = centeredMod(x - spacing / 2, spacing);
|
|
8301
|
-
const dy = centeredMod(y - spacing / 2, spacing);
|
|
8302
|
-
return Math.min(1, Math.max(0, radius + .5 - Math.hypot(dx, dy)));
|
|
8303
|
-
}
|
|
8304
8274
|
function segmentCoverage(x, y, ax, ay, bx, by, width) {
|
|
8305
8275
|
const dx = bx - ax;
|
|
8306
8276
|
const dy = by - ay;
|
|
@@ -8308,36 +8278,24 @@ function segmentCoverage(x, y, ax, ay, bx, by, width) {
|
|
|
8308
8278
|
const t = length2 > 0 ? Math.min(1, Math.max(0, ((x - ax) * dx + (y - ay) * dy) / length2)) : 0;
|
|
8309
8279
|
return Math.min(1, Math.max(0, width / 2 + .5 - Math.hypot(x - (ax + t * dx), y - (ay + t * dy))));
|
|
8310
8280
|
}
|
|
8311
|
-
function
|
|
8281
|
+
function cubicPoint(t, p0, p1, p2, p3) {
|
|
8312
8282
|
const u = 1 - t;
|
|
8313
8283
|
const u2 = u * u;
|
|
8314
8284
|
const t2 = t * t;
|
|
8315
8285
|
return [u2 * u * p0[0] + 3 * u2 * t * p1[0] + 3 * u * t2 * p2[0] + t2 * t * p3[0], u2 * u * p0[1] + 3 * u2 * t * p1[1] + 3 * u * t2 * p2[1] + t2 * t * p3[1]];
|
|
8316
8286
|
}
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
const scale = 1 / 3;
|
|
8326
|
-
const point = (x, y) => [16 + x * scale, 16 + y * scale];
|
|
8327
|
-
const right = point(18, 10);
|
|
8328
|
-
const left = point(-18, 10);
|
|
8329
|
-
const top = point(0, -10);
|
|
8330
|
-
const outline = [right, left];
|
|
8331
|
-
for (let index = 1; index <= 16; index++) outline.push(cubicMinePoint(index / 16, left, point(-18, 0), point(-15, -10), top));
|
|
8332
|
-
for (let index = 1; index <= 16; index++) outline.push(cubicMinePoint(index / 16, top, point(15, -10), point(18, 0), right));
|
|
8333
|
-
const segments = [];
|
|
8287
|
+
function scaledPoint(point, scale) {
|
|
8288
|
+
return [point[0] * scale, point[1] * scale];
|
|
8289
|
+
}
|
|
8290
|
+
function dashSegments(segments, dash) {
|
|
8291
|
+
if (dash.length === 0) return [...segments];
|
|
8292
|
+
const result = [];
|
|
8293
|
+
let dashIndex = 0;
|
|
8294
|
+
let remaining = dash[0];
|
|
8334
8295
|
let drawing = true;
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
const
|
|
8338
|
-
const b = outline[index + 1];
|
|
8339
|
-
const dx = b[0] - a[0];
|
|
8340
|
-
const dy = b[1] - a[1];
|
|
8296
|
+
for (const [ax, ay, bx, by] of segments) {
|
|
8297
|
+
const dx = bx - ax;
|
|
8298
|
+
const dy = by - ay;
|
|
8341
8299
|
const length = Math.hypot(dx, dy);
|
|
8342
8300
|
let walked = 0;
|
|
8343
8301
|
while (walked < length - 1e-9) {
|
|
@@ -8345,186 +8303,124 @@ function mineClusterSegments() {
|
|
|
8345
8303
|
if (drawing) {
|
|
8346
8304
|
const t0 = walked / length;
|
|
8347
8305
|
const t1 = (walked + step) / length;
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8306
|
+
result.push([
|
|
8307
|
+
ax + dx * t0,
|
|
8308
|
+
ay + dy * t0,
|
|
8309
|
+
ax + dx * t1,
|
|
8310
|
+
ay + dy * t1
|
|
8353
8311
|
]);
|
|
8354
8312
|
}
|
|
8355
8313
|
walked += step;
|
|
8356
8314
|
remaining -= step;
|
|
8357
8315
|
if (remaining <= 1e-9) {
|
|
8358
|
-
|
|
8359
|
-
|
|
8316
|
+
dashIndex = (dashIndex + 1) % dash.length;
|
|
8317
|
+
drawing = dashIndex % 2 === 0;
|
|
8318
|
+
remaining = dash[dashIndex];
|
|
8360
8319
|
}
|
|
8361
8320
|
}
|
|
8362
8321
|
}
|
|
8363
|
-
return
|
|
8322
|
+
return result;
|
|
8364
8323
|
}
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
],
|
|
8399
|
-
[
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
]
|
|
8424
|
-
}
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
16,
|
|
8433
|
-
21,
|
|
8434
|
-
16,
|
|
8435
|
-
25.333
|
|
8436
|
-
], [
|
|
8437
|
-
16,
|
|
8438
|
-
25.333,
|
|
8439
|
-
18,
|
|
8440
|
-
23.333
|
|
8441
|
-
]]
|
|
8442
|
-
},
|
|
8443
|
-
"mine-wide-area-antitank": {
|
|
8444
|
-
body: "disc",
|
|
8445
|
-
segments: [
|
|
8446
|
-
[
|
|
8447
|
-
9.333,
|
|
8448
|
-
21,
|
|
8449
|
-
12,
|
|
8450
|
-
24.333
|
|
8451
|
-
],
|
|
8452
|
-
[
|
|
8453
|
-
12,
|
|
8454
|
-
24.333,
|
|
8455
|
-
13.833,
|
|
8456
|
-
20.667
|
|
8457
|
-
],
|
|
8458
|
-
[
|
|
8459
|
-
18.167,
|
|
8460
|
-
20.667,
|
|
8461
|
-
20,
|
|
8462
|
-
24.333
|
|
8463
|
-
],
|
|
8464
|
-
[
|
|
8465
|
-
20,
|
|
8466
|
-
24.333,
|
|
8467
|
-
22.667,
|
|
8468
|
-
21
|
|
8469
|
-
]
|
|
8470
|
-
]
|
|
8471
|
-
},
|
|
8472
|
-
"mine-cluster": {
|
|
8473
|
-
body: "none",
|
|
8474
|
-
segments: mineClusterSegments()
|
|
8324
|
+
function pathSegments(command, scale) {
|
|
8325
|
+
const segments = [];
|
|
8326
|
+
let current;
|
|
8327
|
+
let start;
|
|
8328
|
+
for (const operation of command.operations) if (operation.type === "move") {
|
|
8329
|
+
current = scaledPoint(operation.to, scale);
|
|
8330
|
+
start = current;
|
|
8331
|
+
} else if (operation.type === "line" && current) {
|
|
8332
|
+
const next = scaledPoint(operation.to, scale);
|
|
8333
|
+
segments.push([
|
|
8334
|
+
current[0],
|
|
8335
|
+
current[1],
|
|
8336
|
+
next[0],
|
|
8337
|
+
next[1]
|
|
8338
|
+
]);
|
|
8339
|
+
current = next;
|
|
8340
|
+
} else if (operation.type === "cubic" && current) {
|
|
8341
|
+
const control1 = scaledPoint(operation.control1, scale);
|
|
8342
|
+
const control2 = scaledPoint(operation.control2, scale);
|
|
8343
|
+
const end = scaledPoint(operation.to, scale);
|
|
8344
|
+
for (let index = 1; index <= 16; index++) {
|
|
8345
|
+
const next = cubicPoint(index / 16, current, control1, control2, end);
|
|
8346
|
+
const previous = index === 1 ? current : cubicPoint((index - 1) / 16, current, control1, control2, end);
|
|
8347
|
+
segments.push([
|
|
8348
|
+
previous[0],
|
|
8349
|
+
previous[1],
|
|
8350
|
+
next[0],
|
|
8351
|
+
next[1]
|
|
8352
|
+
]);
|
|
8353
|
+
}
|
|
8354
|
+
current = end;
|
|
8355
|
+
} else if (operation.type === "close" && current && start) {
|
|
8356
|
+
if (current[0] !== start[0] || current[1] !== start[1]) segments.push([
|
|
8357
|
+
current[0],
|
|
8358
|
+
current[1],
|
|
8359
|
+
start[0],
|
|
8360
|
+
start[1]
|
|
8361
|
+
]);
|
|
8362
|
+
current = start;
|
|
8363
|
+
}
|
|
8364
|
+
const dash = command.paint.stroke?.dash?.map((value) => value * scale);
|
|
8365
|
+
return dash ? dashSegments(segments, dash) : segments;
|
|
8366
|
+
}
|
|
8367
|
+
function rasterCommands(pattern, coordinateScale, paintScale) {
|
|
8368
|
+
return FILL_PATTERN_DEFINITIONS[pattern].commands.flatMap((command) => {
|
|
8369
|
+
if (command.type === "circle") return [{
|
|
8370
|
+
type: "circle",
|
|
8371
|
+
cx: command.center[0] * coordinateScale,
|
|
8372
|
+
cy: command.center[1] * coordinateScale,
|
|
8373
|
+
radius: command.radius * paintScale,
|
|
8374
|
+
fill: command.paint.fill !== void 0,
|
|
8375
|
+
...command.paint.stroke ? { strokeWidth: Math.max(1, command.paint.stroke.width * paintScale) } : {}
|
|
8376
|
+
}];
|
|
8377
|
+
if (!command.paint.stroke) return [];
|
|
8378
|
+
return [{
|
|
8379
|
+
type: "path",
|
|
8380
|
+
segments: pathSegments(command, coordinateScale),
|
|
8381
|
+
strokeWidth: Math.max(1, command.paint.stroke.width * paintScale)
|
|
8382
|
+
}];
|
|
8383
|
+
});
|
|
8384
|
+
}
|
|
8385
|
+
function commandCoverage(x, y, command) {
|
|
8386
|
+
if (command.type === "circle") {
|
|
8387
|
+
const distance = Math.hypot(x - command.cx, y - command.cy);
|
|
8388
|
+
const fillCoverage = command.fill ? Math.min(1, Math.max(0, command.radius + .5 - distance)) : 0;
|
|
8389
|
+
const strokeCoverage = command.strokeWidth ? Math.min(1, Math.max(0, command.strokeWidth / 2 + .5 - Math.abs(distance - command.radius))) : 0;
|
|
8390
|
+
return Math.max(fillCoverage, strokeCoverage);
|
|
8475
8391
|
}
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
const glyph = MINE_GLYPHS[pattern];
|
|
8479
|
-
const cx = 16 * scale;
|
|
8480
|
-
const cy = 16 * scale;
|
|
8481
|
-
const radius = 5 * scale;
|
|
8482
|
-
const lineWidth = Math.max(1, scale);
|
|
8483
|
-
const distance = Math.hypot(x - cx, y - cy);
|
|
8484
|
-
let coverage = glyph.body === "none" ? 0 : glyph.body === "disc" ? Math.min(1, Math.max(0, radius + .5 - distance)) : Math.min(1, Math.max(0, lineWidth / 2 + .5 - Math.abs(distance - radius)));
|
|
8485
|
-
for (const [ax, ay, bx, by] of glyph.segments) coverage = Math.max(coverage, segmentCoverage(x, y, ax * scale, ay * scale, bx * scale, by * scale, lineWidth));
|
|
8392
|
+
let coverage = 0;
|
|
8393
|
+
for (const [ax, ay, bx, by] of command.segments) coverage = Math.max(coverage, segmentCoverage(x, y, ax, ay, bx, by, command.strokeWidth));
|
|
8486
8394
|
return coverage;
|
|
8487
8395
|
}
|
|
8396
|
+
function preparePatternRaster(pattern, pixelRatio) {
|
|
8397
|
+
const size = fillPatternImageDimension(pixelRatio);
|
|
8398
|
+
const definition = FILL_PATTERN_DEFINITIONS[pattern];
|
|
8399
|
+
const coordinateScale = size / BASE_TILE_SIZE;
|
|
8400
|
+
return {
|
|
8401
|
+
commands: rasterCommands(pattern, coordinateScale, isMinePattern(pattern) ? coordinateScale : Math.max(1, Math.round(pixelRatio))),
|
|
8402
|
+
tileWidth: definition.tile.width * coordinateScale,
|
|
8403
|
+
tileHeight: definition.tile.height * coordinateScale
|
|
8404
|
+
};
|
|
8405
|
+
}
|
|
8488
8406
|
/**
|
|
8489
8407
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
8490
8408
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
8491
|
-
* jsdom/node tests.
|
|
8492
|
-
*
|
|
8493
|
-
* draws the "/" diagonal, `"reverse-hatch"` its "\" mirror, and `"cross-hatch"` unions
|
|
8494
|
-
* both via `Math.max` coverage. `"horizontal"`/`"vertical"` draw the
|
|
8495
|
-
* axis-aligned families at the same spacing, and `"dots"` a square lattice of
|
|
8496
|
-
* dots (see {@link dotCoverage}).
|
|
8409
|
+
* jsdom/node tests. Every command, tile dimension, stroke, fill, and dash is
|
|
8410
|
+
* read from the public renderer-neutral pattern definition.
|
|
8497
8411
|
*/
|
|
8498
8412
|
function makeFillPatternImage(color, pattern, pixelRatio = 1) {
|
|
8499
8413
|
const size = fillPatternImageDimension(pixelRatio);
|
|
8500
|
-
const
|
|
8501
|
-
const lineWidth = Math.max(1, Math.round(pixelRatio));
|
|
8502
|
-
const dotRadius = DOT_RADIUS * Math.max(1, Math.round(pixelRatio));
|
|
8414
|
+
const prepared = preparePatternRaster(pattern, pixelRatio);
|
|
8503
8415
|
const { r, g, b, a } = parseColor(color);
|
|
8504
8416
|
const data = new Uint8ClampedArray(size * size * 4);
|
|
8505
8417
|
for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
|
|
8506
8418
|
const cx = x + .5;
|
|
8507
8419
|
const cy = y + .5;
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
coverage = lineCoverage(cx, cy, spacing, lineWidth, "\\");
|
|
8513
|
-
break;
|
|
8514
|
-
case "cross-hatch":
|
|
8515
|
-
coverage = Math.max(lineCoverage(cx, cy, spacing, lineWidth, "/"), lineCoverage(cx, cy, spacing, lineWidth, "\\"));
|
|
8516
|
-
break;
|
|
8517
|
-
case "horizontal":
|
|
8518
|
-
coverage = lineCoverage(cx, cy, spacing, lineWidth, "-");
|
|
8519
|
-
break;
|
|
8520
|
-
case "vertical":
|
|
8521
|
-
coverage = lineCoverage(cx, cy, spacing, lineWidth, "|");
|
|
8522
|
-
break;
|
|
8523
|
-
case "dots":
|
|
8524
|
-
coverage = dotCoverage(cx, cy, spacing, dotRadius);
|
|
8525
|
-
break;
|
|
8526
|
-
default: coverage = lineCoverage(cx, cy, spacing, lineWidth, "/");
|
|
8527
|
-
}
|
|
8420
|
+
const localX = cx % prepared.tileWidth;
|
|
8421
|
+
const localY = cy % prepared.tileHeight;
|
|
8422
|
+
let coverage = 0;
|
|
8423
|
+
for (const command of prepared.commands) coverage = Math.max(coverage, commandCoverage(localX, localY, command));
|
|
8528
8424
|
const i = (y * size + x) * 4;
|
|
8529
8425
|
data[i] = r;
|
|
8530
8426
|
data[i + 1] = g;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PatternId } from "@orbat-mapper/control-measures";
|
|
2
2
|
import { Feature, Position } from "geojson";
|
|
3
3
|
|
|
4
4
|
//#region src/gestures/types.d.ts
|
|
@@ -49,7 +49,7 @@ interface EditPointerDriver {
|
|
|
49
49
|
* texture, so it is rasterized once here in pure math — no `HTMLCanvasElement`
|
|
50
50
|
* — so it works in adapter code and in jsdom/node tests alike.
|
|
51
51
|
*/
|
|
52
|
-
type HatchPattern =
|
|
52
|
+
type HatchPattern = PatternId;
|
|
53
53
|
/**
|
|
54
54
|
* Every non-solid `FillPattern` as a runtime list — the value-level companion
|
|
55
55
|
* to {@link HatchPattern}, so adapters can test membership and build filter
|
|
@@ -57,7 +57,7 @@ type HatchPattern = Exclude<FillPattern, "solid">;
|
|
|
57
57
|
*/
|
|
58
58
|
declare const HATCH_PATTERNS: readonly HatchPattern[];
|
|
59
59
|
/** Tile edge, CSS px, of the mine-pictogram family (they use the full 32-unit tile). */
|
|
60
|
-
declare const MINE_PATTERN_TILE_SIZE
|
|
60
|
+
declare const MINE_PATTERN_TILE_SIZE: number;
|
|
61
61
|
/** True for the mine-pictogram family — a screen-space glyph texture rather than a repeating hatch. */
|
|
62
62
|
declare function isMinePattern(pattern: HatchPattern): pattern is MinePattern;
|
|
63
63
|
/**
|
|
@@ -78,15 +78,12 @@ declare function fillPatternImageId(color: string, pattern: HatchPattern): strin
|
|
|
78
78
|
declare function fillPatternImageDimension(pixelRatio: number): number;
|
|
79
79
|
/** The mine-pictogram members of {@link HatchPattern}, derived so the family stays in one place. */
|
|
80
80
|
type MinePattern = Extract<HatchPattern, `mine-${string}`>;
|
|
81
|
+
/** Coverage from the canonical command interpreter, exposed only for focused conformance tests. */
|
|
81
82
|
/**
|
|
82
83
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
83
84
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
84
|
-
* jsdom/node tests.
|
|
85
|
-
*
|
|
86
|
-
* draws the "/" diagonal, `"reverse-hatch"` its "\" mirror, and `"cross-hatch"` unions
|
|
87
|
-
* both via `Math.max` coverage. `"horizontal"`/`"vertical"` draw the
|
|
88
|
-
* axis-aligned families at the same spacing, and `"dots"` a square lattice of
|
|
89
|
-
* dots (see {@link dotCoverage}).
|
|
85
|
+
* jsdom/node tests. Every command, tile dimension, stroke, fill, and dash is
|
|
86
|
+
* read from the public renderer-neutral pattern definition.
|
|
90
87
|
*/
|
|
91
88
|
declare function makeFillPatternImage(color: string, pattern: HatchPattern, pixelRatio?: number): {
|
|
92
89
|
width: number;
|
|
@@ -198,8 +195,10 @@ interface ImageOverlayResource {
|
|
|
198
195
|
/**
|
|
199
196
|
* One stable, atomic unit in a logical layer's bottom-to-top paint stack.
|
|
200
197
|
*
|
|
201
|
-
* Features
|
|
202
|
-
*
|
|
198
|
+
* Features paint in array order inside the group. A filled feature paints its
|
|
199
|
+
* interior before its outline, and text or icon content paints at that
|
|
200
|
+
* feature's array position. An empty group is valid and keeps its identity and
|
|
201
|
+
* stack position.
|
|
203
202
|
*/
|
|
204
203
|
interface FeatureGroup {
|
|
205
204
|
id: string;
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-
|
|
1
|
+
import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-BWvKku2P.mjs";
|
|
2
2
|
import { Feature } from "geojson";
|
|
3
3
|
|
|
4
4
|
//#region src/testing/feature-group-conformance.d.ts
|
|
@@ -11,8 +11,12 @@ interface FeatureGroupConformanceSubject {
|
|
|
11
11
|
rendersFeatureStyle(id: string | number, channel: "fill" | "stroke"): boolean;
|
|
12
12
|
mutationCount(): number;
|
|
13
13
|
operationLog(): readonly string[];
|
|
14
|
+
/** Bottom-to-top native paint operations, when the engine exposes ordering conformance. */
|
|
15
|
+
paintSequence?(): readonly string[];
|
|
14
16
|
}
|
|
15
|
-
declare function runFeatureGroupConformance(name: string, createSubject: () => FeatureGroupConformanceSubject
|
|
17
|
+
declare function runFeatureGroupConformance(name: string, createSubject: () => FeatureGroupConformanceSubject, options?: {
|
|
18
|
+
canonicalFeatureOrder?: boolean;
|
|
19
|
+
}): void;
|
|
16
20
|
//#endregion
|
|
17
21
|
//#region src/testing/grouped-pick-conformance.d.ts
|
|
18
22
|
interface GroupedPickConformanceSubject {
|
package/dist/testing.mjs
CHANGED
|
@@ -1,7 +1,54 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
//#region src/testing/feature-group-conformance.ts
|
|
3
|
-
function runFeatureGroupConformance(name, createSubject) {
|
|
3
|
+
function runFeatureGroupConformance(name, createSubject, options = {}) {
|
|
4
4
|
describe(`${name} feature-group conformance`, () => {
|
|
5
|
+
if (options.canonicalFeatureOrder) it("paints interleaved feature content in canonical array order", () => {
|
|
6
|
+
const subject = createSubject();
|
|
7
|
+
const { adapter, layerId } = subject;
|
|
8
|
+
const icon = iconResource("order-icon");
|
|
9
|
+
const mixed = canonicalOrderFeatures(icon.id);
|
|
10
|
+
adapter.setLayerStyle(layerId, { text: { labelProperty: "label" } });
|
|
11
|
+
adapter.setLayerFeatureGroups(layerId, [group$1("mixed", mixed, [icon]), group$1("upper", [line$1("upper-stroke")])]);
|
|
12
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
13
|
+
"solid:fill",
|
|
14
|
+
"solid:stroke",
|
|
15
|
+
"label:text",
|
|
16
|
+
"pattern:pattern",
|
|
17
|
+
"pattern:stroke",
|
|
18
|
+
"icon:icon",
|
|
19
|
+
"last-stroke:stroke",
|
|
20
|
+
"upper-stroke:stroke"
|
|
21
|
+
]);
|
|
22
|
+
const updated = [
|
|
23
|
+
mixed[3],
|
|
24
|
+
mixed[0],
|
|
25
|
+
mixed[1],
|
|
26
|
+
mixed[2],
|
|
27
|
+
mixed[4]
|
|
28
|
+
];
|
|
29
|
+
adapter.setLayerFeatureGroups(layerId, [group$1("mixed", updated, [icon]), group$1("upper", [line$1("upper-stroke")])]);
|
|
30
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
31
|
+
"icon:icon",
|
|
32
|
+
"solid:fill",
|
|
33
|
+
"solid:stroke",
|
|
34
|
+
"label:text",
|
|
35
|
+
"pattern:pattern",
|
|
36
|
+
"pattern:stroke",
|
|
37
|
+
"last-stroke:stroke",
|
|
38
|
+
"upper-stroke:stroke"
|
|
39
|
+
]);
|
|
40
|
+
adapter.setLayerFeatureGroups(layerId, [group$1("upper", [line$1("upper-stroke")]), group$1("mixed", updated, [icon])]);
|
|
41
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
42
|
+
"upper-stroke:stroke",
|
|
43
|
+
"icon:icon",
|
|
44
|
+
"solid:fill",
|
|
45
|
+
"solid:stroke",
|
|
46
|
+
"label:text",
|
|
47
|
+
"pattern:pattern",
|
|
48
|
+
"pattern:stroke",
|
|
49
|
+
"last-stroke:stroke"
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
5
52
|
it("reconciles complete ordered group state, including pure reorders", () => {
|
|
6
53
|
const subject = createSubject();
|
|
7
54
|
const { adapter, layerId } = subject;
|
|
@@ -157,6 +204,26 @@ function polygon$1(id) {
|
|
|
157
204
|
}
|
|
158
205
|
};
|
|
159
206
|
}
|
|
207
|
+
function canonicalOrderFeatures(iconId) {
|
|
208
|
+
return [
|
|
209
|
+
polygon$1("solid"),
|
|
210
|
+
{
|
|
211
|
+
...point("label"),
|
|
212
|
+
properties: { label: "LABEL" }
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
...polygon$1("pattern"),
|
|
216
|
+
properties: { style: {
|
|
217
|
+
fillColor: "#ffffff",
|
|
218
|
+
fillPattern: "hatch",
|
|
219
|
+
strokeColor: "#000000",
|
|
220
|
+
strokeWidth: 2
|
|
221
|
+
} }
|
|
222
|
+
},
|
|
223
|
+
iconPoint("icon", iconId),
|
|
224
|
+
line$1("last-stroke")
|
|
225
|
+
];
|
|
226
|
+
}
|
|
160
227
|
function featureIds(features) {
|
|
161
228
|
return features.map((feature) => feature.id);
|
|
162
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Engine-agnostic draw/edit core for tactical control measures (MIL-STD-2525 / APP-6). The MapAdapter ABI and bring-your-own-engine entry point for the tactical-draw package family.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orbat-mapper/control-measures": "^0.
|
|
42
|
+
"@orbat-mapper/control-measures": "^0.7.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|