@orbat-mapper/tactical-draw 0.3.1 → 0.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/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
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-BkDIEriM.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
|
|
|
@@ -719,6 +719,11 @@ interface EditSession {
|
|
|
719
719
|
* from `EditOptions.sizeAnchor` and mutated by [[setSizeAnchor]].
|
|
720
720
|
*/
|
|
721
721
|
readonly sizeAnchor: SizeAnchor;
|
|
722
|
+
/**
|
|
723
|
+
* Whether this ground-anchored measure has one or more sizes that can be
|
|
724
|
+
* restored at the adapter's current resolution.
|
|
725
|
+
*/
|
|
726
|
+
readonly canResetGroundSizes: boolean;
|
|
722
727
|
/**
|
|
723
728
|
* Commit: returns the `GraphicSnapshot<ControlMeasure>` of the current working state
|
|
724
729
|
* and resolves the outer `edit` promise with the same value (the same
|
|
@@ -757,6 +762,13 @@ interface EditSession {
|
|
|
757
762
|
* inside.
|
|
758
763
|
*/
|
|
759
764
|
setSizeAnchor(anchor: SizeAnchor, options?: ControlMeasure["options"]): void;
|
|
765
|
+
/**
|
|
766
|
+
* Reset every geometry and label size to its default on-screen appearance at
|
|
767
|
+
* the current map resolution, persisted in meters. The measure stays
|
|
768
|
+
* ground-anchored and the reset is one undoable programmatic mutation.
|
|
769
|
+
* No-op when [[canResetGroundSizes]] is false or after settlement.
|
|
770
|
+
*/
|
|
771
|
+
resetGroundSizes(): void;
|
|
760
772
|
/** Shallow-merge per-measure style into the live working copy. */
|
|
761
773
|
setStyle(partial: ControlMeasureStyle): void;
|
|
762
774
|
/**
|
|
@@ -2041,4 +2053,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
|
|
|
2041
2053
|
/** `nearestWorldCopyLng` applied to a lon/lat position. */
|
|
2042
2054
|
declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
|
|
2043
2055
|
//#endregion
|
|
2044
|
-
export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DrawImageDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, type HandleStyle, type HatchPattern, type IconResource, type ImageCapability, ImageCapabilityRequiredError, type ImageFootprint, type ImageGraphic, type ImageGraphicStyle, type ImageIntrinsicSize, type ImageOverlayResource, type ImageRender, type ImageResource, type ImageSize, type InteractionHit, type InteractionStyle, type LabelExtent, type LayerId, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type MergedPickFeature, type NativeEventEntry, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type RotatedScreenBounds, type ScreenBounds, type SessionChangeSource, type SessionHistory, type SessionHistoryState, type SettleReason, type SizeAnchor, type SnapCandidate, type SnapCandidateProvider, type SnapCandidateRequest, type SnapInteraction, type SnapResult, type SnappingOptions, type StyleOptions, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, bindAbortable, cloneImageGraphic, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature, validateImageGraphic };
|
|
2056
|
+
export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DrawImageDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, type HandleStyle, type HatchPattern, type IconResource, type ImageCapability, ImageCapabilityRequiredError, type ImageFootprint, type ImageGraphic, type ImageGraphicStyle, type ImageIntrinsicSize, type ImageOverlayResource, type ImageRender, type ImageResource, type ImageSize, type InteractionHit, type InteractionStyle, type LabelExtent, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type MergedPickFeature, type NativeEventEntry, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type RotatedScreenBounds, type ScreenBounds, type SessionChangeSource, type SessionHistory, type SessionHistoryState, type SettleReason, type SizeAnchor, type SnapCandidate, type SnapCandidateProvider, type SnapCandidateRequest, type SnapInteraction, type SnapResult, type SnappingOptions, type StyleOptions, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, bindAbortable, cloneImageGraphic, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMinePattern, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature, validateImageGraphic };
|
package/dist/index.mjs
CHANGED
|
@@ -1130,6 +1130,40 @@ function sizeOptionSpecs(kind) {
|
|
|
1130
1130
|
return specs;
|
|
1131
1131
|
}
|
|
1132
1132
|
/**
|
|
1133
|
+
* Whether `kind` has at least one size that can be restored to its normal
|
|
1134
|
+
* pixel-authored appearance at the adapter's current resolution. Kept inside
|
|
1135
|
+
* tactical-draw with the private size-pair catalog so hosts never need to
|
|
1136
|
+
* infer option names or special-case captured labels.
|
|
1137
|
+
*/
|
|
1138
|
+
function canResetGroundSizes(measure, adapter) {
|
|
1139
|
+
const mpp = adapter.getResolution();
|
|
1140
|
+
return mpp !== void 0 && mpp > 0 && sizeOptionSpecs(measure.kind).length > 0;
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Return the complete option record produced by resetting every known size
|
|
1144
|
+
* pair to its default on-screen appearance at the adapter's current
|
|
1145
|
+
* resolution. Pixel keys are removed and meter keys are written, so the
|
|
1146
|
+
* result remains ground-anchored. Unrelated options are preserved.
|
|
1147
|
+
*
|
|
1148
|
+
* Returns `undefined` when the kind has no resettable sizes or the adapter has
|
|
1149
|
+
* no usable resolution.
|
|
1150
|
+
*/
|
|
1151
|
+
function resetGroundSizeOptions(measure, adapter) {
|
|
1152
|
+
const mpp = adapter.getResolution();
|
|
1153
|
+
const specs = sizeOptionSpecs(measure.kind);
|
|
1154
|
+
if (mpp === void 0 || mpp <= 0 || specs.length === 0) return void 0;
|
|
1155
|
+
const defaults = getDefaultOptions(measure.kind);
|
|
1156
|
+
const next = { ...measure.options ?? {} };
|
|
1157
|
+
for (const spec of specs) {
|
|
1158
|
+
const defaultPixels = spec === LABEL_SIZE_SPEC ? 14 : defaults[spec.pixels];
|
|
1159
|
+
if (typeof defaultPixels !== "number") continue;
|
|
1160
|
+
delete next[spec.pixels];
|
|
1161
|
+
next[spec.meters] = defaultPixels * mpp;
|
|
1162
|
+
}
|
|
1163
|
+
delete next.metersPerPixel;
|
|
1164
|
+
return next;
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1133
1167
|
* Whether `kind` authors `spec` in pixels — its defaults declare the pixel key
|
|
1134
1168
|
* with no meter counterpart. A static property of the definition, but
|
|
1135
1169
|
* `getDefaultOptions` deep-clones on every call, so it is memoised: the gate
|
|
@@ -4453,6 +4487,36 @@ function runEdit(opts) {
|
|
|
4453
4487
|
dirty = true;
|
|
4454
4488
|
emitChange(previousRendered, previousPoints, previousOptions, previousStyle, previousNonGeometryDirty, previousSizeAnchor, currentRendered, previousTextAmplifiers, previousAmplifierPlacements, previousProperties, "programmatic", nextOptions ? "Change size mode" : "Change size anchor");
|
|
4455
4489
|
}
|
|
4490
|
+
/** Restore all ground-sized dimensions in one atomic, undoable mutation. */
|
|
4491
|
+
function resetGroundSizes() {
|
|
4492
|
+
if (ctx.settled || sizeAnchor !== "ground") return;
|
|
4493
|
+
const nextOptions = resetGroundSizeOptions({
|
|
4494
|
+
kind: measure.kind,
|
|
4495
|
+
options: workingOptions
|
|
4496
|
+
}, adapter);
|
|
4497
|
+
if (!nextOptions) return;
|
|
4498
|
+
const previousPoints = workingPoints.map((p) => [...p]);
|
|
4499
|
+
const previousOptions = { ...workingOptions ?? {} };
|
|
4500
|
+
if (jsonEqual(nextOptions, previousOptions)) return;
|
|
4501
|
+
const previousStyle = currentStyle;
|
|
4502
|
+
const previousNonGeometryDirty = nonGeometryDirty;
|
|
4503
|
+
const previousTextAmplifiers = workingTextAmplifiers;
|
|
4504
|
+
const previousAmplifierPlacements = snapshotAmplifierPlacements();
|
|
4505
|
+
const previousProperties = snapshotProperties();
|
|
4506
|
+
const previousRendered = rebuildRendered();
|
|
4507
|
+
replaceWorkingOptions(nextOptions);
|
|
4508
|
+
let currentRendered;
|
|
4509
|
+
try {
|
|
4510
|
+
currentRendered = rebuildRendered();
|
|
4511
|
+
} catch (err) {
|
|
4512
|
+
replaceWorkingOptions(previousOptions);
|
|
4513
|
+
throw err;
|
|
4514
|
+
}
|
|
4515
|
+
renderWorkingGraphicAndHandles();
|
|
4516
|
+
nonGeometryDirty = true;
|
|
4517
|
+
dirty = true;
|
|
4518
|
+
emitChange(previousRendered, previousPoints, previousOptions, previousStyle, previousNonGeometryDirty, sizeAnchor, currentRendered, previousTextAmplifiers, previousAmplifierPlacements, previousProperties, "programmatic", "Reset sizes for current zoom");
|
|
4519
|
+
}
|
|
4456
4520
|
function modesEqual(a, b) {
|
|
4457
4521
|
if (a.length !== b.length) return false;
|
|
4458
4522
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
@@ -4535,6 +4599,9 @@ function runEdit(opts) {
|
|
|
4535
4599
|
get sizeAnchor() {
|
|
4536
4600
|
return sizeAnchor;
|
|
4537
4601
|
},
|
|
4602
|
+
get canResetGroundSizes() {
|
|
4603
|
+
return !ctx.settled && sizeAnchor === "ground" && canResetGroundSizes(measure, adapter);
|
|
4604
|
+
},
|
|
4538
4605
|
close() {
|
|
4539
4606
|
return ctx.commit(rebuildRendered);
|
|
4540
4607
|
},
|
|
@@ -4589,6 +4656,9 @@ function runEdit(opts) {
|
|
|
4589
4656
|
setSizeAnchor(next, options) {
|
|
4590
4657
|
setSizeAnchor(next, options);
|
|
4591
4658
|
},
|
|
4659
|
+
resetGroundSizes() {
|
|
4660
|
+
resetGroundSizes();
|
|
4661
|
+
},
|
|
4592
4662
|
onChange(listener) {
|
|
4593
4663
|
if (ctx.settled) return () => {};
|
|
4594
4664
|
return changeEmitter.register(listener);
|
|
@@ -8100,10 +8170,23 @@ const HATCH_PATTERNS = [
|
|
|
8100
8170
|
"cross-hatch",
|
|
8101
8171
|
"horizontal",
|
|
8102
8172
|
"vertical",
|
|
8103
|
-
"dots"
|
|
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"
|
|
8104
8181
|
];
|
|
8105
8182
|
/** Tile edge length, CSS px, before `pixelRatio` scaling. Kept a power of two. */
|
|
8106
8183
|
const BASE_TILE_SIZE = 32;
|
|
8184
|
+
/** Tile edge, CSS px, of the mine-pictogram family (they use the full 32-unit tile). */
|
|
8185
|
+
const MINE_PATTERN_TILE_SIZE = 32;
|
|
8186
|
+
/** True for the mine-pictogram family — a screen-space glyph texture rather than a repeating hatch. */
|
|
8187
|
+
function isMinePattern(pattern) {
|
|
8188
|
+
return pattern.startsWith("mine-");
|
|
8189
|
+
}
|
|
8107
8190
|
/** Line spacing as a fraction of the tile edge — 4 repeats per tile. */
|
|
8108
8191
|
const SPACING_DIVISOR = 4;
|
|
8109
8192
|
/**
|
|
@@ -8218,6 +8301,190 @@ function dotCoverage(x, y, spacing, radius) {
|
|
|
8218
8301
|
const dy = centeredMod(y - spacing / 2, spacing);
|
|
8219
8302
|
return Math.min(1, Math.max(0, radius + .5 - Math.hypot(dx, dy)));
|
|
8220
8303
|
}
|
|
8304
|
+
function segmentCoverage(x, y, ax, ay, bx, by, width) {
|
|
8305
|
+
const dx = bx - ax;
|
|
8306
|
+
const dy = by - ay;
|
|
8307
|
+
const length2 = dx * dx + dy * dy;
|
|
8308
|
+
const t = length2 > 0 ? Math.min(1, Math.max(0, ((x - ax) * dx + (y - ay) * dy) / length2)) : 0;
|
|
8309
|
+
return Math.min(1, Math.max(0, width / 2 + .5 - Math.hypot(x - (ax + t * dx), y - (ay + t * dy))));
|
|
8310
|
+
}
|
|
8311
|
+
function cubicMinePoint(t, p0, p1, p2, p3) {
|
|
8312
|
+
const u = 1 - t;
|
|
8313
|
+
const u2 = u * u;
|
|
8314
|
+
const t2 = t * t;
|
|
8315
|
+
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
|
+
}
|
|
8317
|
+
/**
|
|
8318
|
+
* Raster segments for milsymbol's dashed 36×20-unit mine-cluster outline. The
|
|
8319
|
+
* same curve is emitted as vector geometry by `minefield.ts`'s
|
|
8320
|
+
* `mineClusterGlyph` in `@orbat-mapper/control-measures` (in meters, y up
|
|
8321
|
+
* rather than tile units, y down) — keep the control points and dash cadence in
|
|
8322
|
+
* step so the area fill and the point glyph read alike.
|
|
8323
|
+
*/
|
|
8324
|
+
function mineClusterSegments() {
|
|
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 = [];
|
|
8334
|
+
let drawing = true;
|
|
8335
|
+
let remaining = 7.5 * scale;
|
|
8336
|
+
for (let index = 0; index < outline.length - 1; index++) {
|
|
8337
|
+
const a = outline[index];
|
|
8338
|
+
const b = outline[index + 1];
|
|
8339
|
+
const dx = b[0] - a[0];
|
|
8340
|
+
const dy = b[1] - a[1];
|
|
8341
|
+
const length = Math.hypot(dx, dy);
|
|
8342
|
+
let walked = 0;
|
|
8343
|
+
while (walked < length - 1e-9) {
|
|
8344
|
+
const step = Math.min(remaining, length - walked);
|
|
8345
|
+
if (drawing) {
|
|
8346
|
+
const t0 = walked / length;
|
|
8347
|
+
const t1 = (walked + step) / length;
|
|
8348
|
+
segments.push([
|
|
8349
|
+
a[0] + dx * t0,
|
|
8350
|
+
a[1] + dy * t0,
|
|
8351
|
+
a[0] + dx * t1,
|
|
8352
|
+
a[1] + dy * t1
|
|
8353
|
+
]);
|
|
8354
|
+
}
|
|
8355
|
+
walked += step;
|
|
8356
|
+
remaining -= step;
|
|
8357
|
+
if (remaining <= 1e-9) {
|
|
8358
|
+
drawing = !drawing;
|
|
8359
|
+
remaining = (drawing ? 7.5 : 5) * scale;
|
|
8360
|
+
}
|
|
8361
|
+
}
|
|
8362
|
+
}
|
|
8363
|
+
return segments;
|
|
8364
|
+
}
|
|
8365
|
+
const MINE_GLYPHS = {
|
|
8366
|
+
"mine-unspecified": {
|
|
8367
|
+
body: "ring",
|
|
8368
|
+
segments: []
|
|
8369
|
+
},
|
|
8370
|
+
"mine-antipersonnel": {
|
|
8371
|
+
body: "disc",
|
|
8372
|
+
segments: [[
|
|
8373
|
+
12.867,
|
|
8374
|
+
12.1,
|
|
8375
|
+
9.333,
|
|
8376
|
+
7.667
|
|
8377
|
+
], [
|
|
8378
|
+
19.133,
|
|
8379
|
+
12.1,
|
|
8380
|
+
22.667,
|
|
8381
|
+
7.667
|
|
8382
|
+
]]
|
|
8383
|
+
},
|
|
8384
|
+
"mine-antipersonnel-directional": {
|
|
8385
|
+
body: "disc",
|
|
8386
|
+
segments: [
|
|
8387
|
+
[
|
|
8388
|
+
12.867,
|
|
8389
|
+
12.1,
|
|
8390
|
+
9.333,
|
|
8391
|
+
7.667
|
|
8392
|
+
],
|
|
8393
|
+
[
|
|
8394
|
+
19.133,
|
|
8395
|
+
12.1,
|
|
8396
|
+
22.667,
|
|
8397
|
+
7.667
|
|
8398
|
+
],
|
|
8399
|
+
[
|
|
8400
|
+
21,
|
|
8401
|
+
16,
|
|
8402
|
+
22.1,
|
|
8403
|
+
16
|
|
8404
|
+
],
|
|
8405
|
+
[
|
|
8406
|
+
23.667,
|
|
8407
|
+
15.333,
|
|
8408
|
+
24.333,
|
|
8409
|
+
15.9
|
|
8410
|
+
],
|
|
8411
|
+
[
|
|
8412
|
+
24.333,
|
|
8413
|
+
15.9,
|
|
8414
|
+
23.667,
|
|
8415
|
+
16.667
|
|
8416
|
+
],
|
|
8417
|
+
[
|
|
8418
|
+
23.667,
|
|
8419
|
+
16.667,
|
|
8420
|
+
23.667,
|
|
8421
|
+
15.333
|
|
8422
|
+
]
|
|
8423
|
+
]
|
|
8424
|
+
},
|
|
8425
|
+
"mine-antitank": {
|
|
8426
|
+
body: "disc",
|
|
8427
|
+
segments: []
|
|
8428
|
+
},
|
|
8429
|
+
"mine-antitank-antihandling": {
|
|
8430
|
+
body: "disc",
|
|
8431
|
+
segments: [[
|
|
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()
|
|
8475
|
+
}
|
|
8476
|
+
};
|
|
8477
|
+
function minePatternCoverage(x, y, pattern, scale) {
|
|
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));
|
|
8486
|
+
return coverage;
|
|
8487
|
+
}
|
|
8221
8488
|
/**
|
|
8222
8489
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
8223
8490
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
@@ -8239,7 +8506,8 @@ function makeFillPatternImage(color, pattern, pixelRatio = 1) {
|
|
|
8239
8506
|
const cx = x + .5;
|
|
8240
8507
|
const cy = y + .5;
|
|
8241
8508
|
let coverage;
|
|
8242
|
-
|
|
8509
|
+
if (isMinePattern(pattern)) coverage = minePatternCoverage(cx, cy, pattern, size / BASE_TILE_SIZE);
|
|
8510
|
+
else switch (pattern) {
|
|
8243
8511
|
case "reverse-hatch":
|
|
8244
8512
|
coverage = lineCoverage(cx, cy, spacing, lineWidth, "\\");
|
|
8245
8513
|
break;
|
|
@@ -8288,4 +8556,4 @@ function nearestWorldCopyPosition(position, refLng) {
|
|
|
8288
8556
|
return [nearestWorldCopyLng(position[0], refLng), ...position.slice(1)];
|
|
8289
8557
|
}
|
|
8290
8558
|
//#endregion
|
|
8291
|
-
export { BaseMapAdapter, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, HATCH_PATTERNS, ImageCapabilityRequiredError, PointSymbolCapabilityRequiredError, PointerCallbackHub, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, TacticalDrawDestroyedError, bindAbortable, cloneImageGraphic, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature, validateImageGraphic };
|
|
8559
|
+
export { BaseMapAdapter, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, HATCH_PATTERNS, ImageCapabilityRequiredError, MINE_PATTERN_TILE_SIZE, PointSymbolCapabilityRequiredError, PointerCallbackHub, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, TacticalDrawDestroyedError, bindAbortable, cloneImageGraphic, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMinePattern, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature, validateImageGraphic };
|
|
@@ -56,6 +56,10 @@ type HatchPattern = Exclude<FillPattern, "solid">;
|
|
|
56
56
|
* expressions without re-spelling the pattern vocabulary.
|
|
57
57
|
*/
|
|
58
58
|
declare const HATCH_PATTERNS: readonly HatchPattern[];
|
|
59
|
+
/** Tile edge, CSS px, of the mine-pictogram family (they use the full 32-unit tile). */
|
|
60
|
+
declare const MINE_PATTERN_TILE_SIZE = 32;
|
|
61
|
+
/** True for the mine-pictogram family — a screen-space glyph texture rather than a repeating hatch. */
|
|
62
|
+
declare function isMinePattern(pattern: HatchPattern): pattern is MinePattern;
|
|
59
63
|
/**
|
|
60
64
|
* Stable id for a rasterized tile, keyed by pattern and color. Adapters use
|
|
61
65
|
* this as the image-registry key (MapLibre `addImage` id, OpenLayers pattern
|
|
@@ -72,6 +76,8 @@ declare function fillPatternImageId(color: string, pattern: HatchPattern): strin
|
|
|
72
76
|
* power-of-two guarantee.
|
|
73
77
|
*/
|
|
74
78
|
declare function fillPatternImageDimension(pixelRatio: number): number;
|
|
79
|
+
/** The mine-pictogram members of {@link HatchPattern}, derived so the family stays in one place. */
|
|
80
|
+
type MinePattern = Extract<HatchPattern, `mine-${string}`>;
|
|
75
81
|
/**
|
|
76
82
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
77
83
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
@@ -380,4 +386,4 @@ interface MapAdapter {
|
|
|
380
386
|
getLayerFeatures(layerId: LayerId): readonly Feature[];
|
|
381
387
|
}
|
|
382
388
|
//#endregion
|
|
383
|
-
export {
|
|
389
|
+
export { EditPointerDriver as C, makeFillPatternImage as S, PointerEventInfo as T, HatchPattern as _, LayerId as a, fillPatternImageId as b, MapEvent as c, PickHandler as d, PickOptions as f, HATCH_PATTERNS as g, TextStyleOptions as h, ImageOverlayResource as i, MapEventHandler as l, StyleOptions as m, HandleStyle as n, MapAdapter as o, PixelCoordinate as p, IconResource as r, MapCursor as s, FeatureGroup as t, PickEvent as u, MINE_PATTERN_TILE_SIZE as v, PointerCallback as w, isMinePattern as x, fillPatternImageDimension as y };
|
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-BkDIEriM.mjs";
|
|
2
2
|
import { Feature } from "geojson";
|
|
3
3
|
|
|
4
4
|
//#region src/testing/feature-group-conformance.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
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.5.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|