@orbat-mapper/tactical-draw 0.3.0 → 0.3.2

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 PointerEventInfo, S as PointerCallback, _ as HatchPattern, a as LayerId, b as makeFillPatternImage, 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 fillPatternImageDimension, x as EditPointerDriver, y as fillPatternImageId } from "./map-adapter-DfIb57kQ.mjs";
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
 
@@ -2041,4 +2041,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
2041
2041
  /** `nearestWorldCopyLng` applied to a lon/lat position. */
2042
2042
  declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
2043
2043
  //#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 };
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, 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
@@ -1,4 +1,4 @@
1
- import { applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, freezeOrientationOptions, getControlMeasureMetadata, getDefaultOptions, renderControlMeasure, resolveAmplifierPlacement, resolveStyleHints, roundToFixed } from "@orbat-mapper/control-measures";
1
+ import { 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";
@@ -1102,6 +1102,10 @@ const PIXEL_SIZE_OPTIONS = {
1102
1102
  pixels: "toothHeightPixels",
1103
1103
  meters: "toothHeight"
1104
1104
  },
1105
+ minefield: {
1106
+ pixels: "sizePixels",
1107
+ meters: "sizeMeters"
1108
+ },
1105
1109
  text: {
1106
1110
  pixels: "sizePixels",
1107
1111
  meters: "sizeMeters"
@@ -1126,6 +1130,22 @@ function sizeOptionSpecs(kind) {
1126
1130
  return specs;
1127
1131
  }
1128
1132
  /**
1133
+ * Whether `kind` authors `spec` in pixels — its defaults declare the pixel key
1134
+ * with no meter counterpart. A static property of the definition, but
1135
+ * `getDefaultOptions` deep-clones on every call, so it is memoised: the gate
1136
+ * below runs per measure per view-change frame.
1137
+ */
1138
+ const pixelAuthoredCache = /* @__PURE__ */ new Map();
1139
+ function isPixelAuthored(kind, spec) {
1140
+ const cacheKey = `${kind}:${spec.pixels}`;
1141
+ const cached = pixelAuthoredCache.get(cacheKey);
1142
+ if (cached !== void 0) return cached;
1143
+ const defaults = getDefaultOptions(kind);
1144
+ const authored = defaults[spec.pixels] !== void 0 && defaults[spec.meters] === void 0;
1145
+ pixelAuthoredCache.set(cacheKey, authored);
1146
+ return authored;
1147
+ }
1148
+ /**
1129
1149
  * Whether `measure` carries a pixel-denominated size option whose resolution
1130
1150
  * to meters depends on the live map (`metersPerPixel`) — i.e. it is
1131
1151
  * *screen-anchored*. Used both to inject the override
@@ -1136,7 +1156,11 @@ function sizeOptionSpecs(kind) {
1136
1156
  */
1137
1157
  function measureUsesAdapterResolution(measure) {
1138
1158
  const options = measure.options;
1139
- return sizeOptionSpecs(measure.kind).some((spec) => options?.[spec.pixels] !== void 0);
1159
+ return sizeOptionSpecs(measure.kind).some((spec) => {
1160
+ if (options?.[spec.pixels] !== void 0) return true;
1161
+ if (options?.[spec.meters] !== void 0) return false;
1162
+ return isPixelAuthored(measure.kind, spec);
1163
+ });
1140
1164
  }
1141
1165
  /**
1142
1166
  * Whether rendering `measure` through [[renderMeasureForAdapter]] reads live
@@ -3866,6 +3890,7 @@ function runEdit(opts) {
3866
3890
  const guideEnabled = (guideOpt ?? true) && !shouldSuppressGuide(metadata);
3867
3891
  const isAreaKind = metadata.geometry === "area";
3868
3892
  const isTextGraphic = measure.kind === "text";
3893
+ const foldsTransformIntoOptions = foldsBoxTransformOptions(measure.kind);
3869
3894
  const requestedModes = normaliseModes(initialModes);
3870
3895
  const editStartPoints = measure.controlPoints.map((p) => [...p]);
3871
3896
  const workingPoints = editStartPoints.map((p) => [...p]);
@@ -4024,7 +4049,7 @@ function runEdit(opts) {
4024
4049
  const px = driver.toPixel(p);
4025
4050
  if (px) pixels.push(px);
4026
4051
  }
4027
- return fitTransformBox(pixels, boxAngle, interactionStyle?.boxPadding ?? 0);
4052
+ return fitTransformBox(pixels, activeOptionTransformInFlight() ? activeBoxDrag.lastSnapshot.box.angle : boxAngle, interactionStyle?.boxPadding ?? 0);
4028
4053
  }
4029
4054
  /**
4030
4055
  * The Text footprint box (rotated rectangle hugging the rendered text),
@@ -4043,12 +4068,12 @@ function runEdit(opts) {
4043
4068
  * Re-fit `box` from `lastWorkingFeatures`. A no-op while a box gesture is
4044
4069
  * in flight — that drag paints the box rigidly from its own snapshot
4045
4070
  * (`BoxDragSnapshot.box`) instead of a re-fit, so a corner/rotate/body drag
4046
- * doesn't fight its own paint. Text is the exception: its box follows the
4047
- * rendered footprint live (a rotate/scale gesture changes the rendered text),
4048
- * so it re-fits every frame, drag included.
4071
+ * doesn't fight its own paint. Option-backed transforms are the exception:
4072
+ * their anchor points stay fixed while their rendered footprint changes, so
4073
+ * the box must re-fit from that live render on every tick.
4049
4074
  */
4050
4075
  function refitBox() {
4051
- if (activeBoxDrag && !isTextGraphic) return;
4076
+ if (activeBoxDrag && !activeOptionTransformInFlight()) return;
4052
4077
  box = fitBoxFromFeatures(lastWorkingFeatures);
4053
4078
  }
4054
4079
  function renderWorkingGraphic() {
@@ -4100,7 +4125,7 @@ function runEdit(opts) {
4100
4125
  }), handleIdPrefix, interactionStyle);
4101
4126
  if (modes.includes("labeldrag")) features.push(...labels.handleFeatures());
4102
4127
  if (modes.includes("transform")) {
4103
- const liveBox = activeBoxDrag && !isTextGraphic ? activeBoxDrag.lastSnapshot.box : box;
4128
+ const liveBox = activeBoxDrag && !activeOptionTransformInFlight() ? activeBoxDrag.lastSnapshot.box : box;
4104
4129
  if (liveBox) {
4105
4130
  features.push(boxOutlineFeature(liveBox, dragProjection.fromPixel, `${handleIdPrefix}:box-outline`, interactionStyle?.boxOutline));
4106
4131
  features.push(...toFeatures(boxToHandles(liveBox, dragProjection.fromPixel), handleIdPrefix, interactionStyle));
@@ -4754,13 +4779,12 @@ function runEdit(opts) {
4754
4779
  }
4755
4780
  /**
4756
4781
  * Fold a box gesture's delta (the box `to` relative to `from`, given the
4757
- * gesture `kind`) into a Text graphic's `rotation`/size options, on top of
4758
- * `base`. A `scale` grows the active size anchor; a `rotate` adds to the
4759
- * rotation. Returns `base` unchanged when the kind produces no patch. The
4760
- * delta (uniform scale ratio, angle difference) is pivot-independent, so
4761
- * folding it keeps the anchor point fixed while the glyph turns/grows.
4782
+ * gesture `kind`) into a graphic's option-backed rotation/size, on top of
4783
+ * `base`. Returns `null` when the definition produces no patch. The delta is
4784
+ * pivot-independent, so folding it keeps single-anchor geometry fixed while
4785
+ * the rendered graphic turns or grows.
4762
4786
  */
4763
- function foldTextTransform(from, to, kind, base) {
4787
+ function foldOptionTransform(from, to, kind, base) {
4764
4788
  const { scale, rotation } = boxScaleRotation(kind, to, from);
4765
4789
  const patch = applyBoxTransformOptions(measure.kind, base ?? {}, {
4766
4790
  scale,
@@ -4769,16 +4793,23 @@ function runEdit(opts) {
4769
4793
  return patch ? {
4770
4794
  ...base ?? {},
4771
4795
  ...patch
4772
- } : base;
4796
+ } : null;
4797
+ }
4798
+ /** Whether the current live box gesture changes rendered options rather than control points. */
4799
+ function activeOptionTransformInFlight() {
4800
+ if (!activeBoxDrag || !foldsTransformIntoOptions) return false;
4801
+ const kind = activeBoxDrag.fsm.kind;
4802
+ return kind === "rotate" || kind === "scale";
4773
4803
  }
4774
4804
  function paintBoxDragSnapshot(pixel, info, constrainRotation = false) {
4775
4805
  if (!activeBoxDrag) return;
4776
4806
  const resolvedPixel = translatedBoxPixel(pixel, info, activeBoxDrag);
4777
4807
  const snapshot = activeBoxDrag.fsm.move(resolvedPixel, { constrainRotation });
4778
4808
  activeBoxDrag.lastSnapshot = snapshot;
4779
- if (isTextGraphic && (activeBoxDrag.fsm.kind === "rotate" || activeBoxDrag.fsm.kind === "scale")) {
4809
+ if (activeOptionTransformInFlight()) {
4810
+ const foldedOptions = foldOptionTransform(activeBoxDrag.preDragBox, snapshot.box, activeBoxDrag.fsm.kind, activeBoxDrag.preDragOptions);
4780
4811
  workingPoints.splice(0, workingPoints.length, ...activeBoxDrag.preDragPoints);
4781
- workingOptions = foldTextTransform(activeBoxDrag.preDragBox, snapshot.box, activeBoxDrag.fsm.kind, activeBoxDrag.preDragOptions);
4812
+ if (foldedOptions) workingOptions = foldedOptions;
4782
4813
  nonGeometryDirty = true;
4783
4814
  renderWorkingGraphic();
4784
4815
  renderHandlesLayer();
@@ -4876,13 +4907,14 @@ function runEdit(opts) {
4876
4907
  const finalSnapshot = fsm.move(finalPixel, { constrainRotation: info?.shiftKey });
4877
4908
  replaceWorkingPoints(preDragPoints);
4878
4909
  workingAmplifierPlacements = preDragAmplifierPlacements;
4879
- const textOptionFold = isTextGraphic && (fsm.kind === "rotate" || fsm.kind === "scale");
4910
+ const optionFold = foldsTransformIntoOptions && (fsm.kind === "rotate" || fsm.kind === "scale");
4880
4911
  if (fsm.kind === "rotate" && !isTextGraphic) boxAngle += finalSnapshot.box.angle - preDragBox.angle;
4881
- if (textOptionFold) {
4882
- workingOptions = foldTextTransform(preDragBox, finalSnapshot.box, fsm.kind, preDragOptions);
4912
+ if (optionFold) {
4913
+ const foldedOptions = foldOptionTransform(preDragBox, finalSnapshot.box, fsm.kind, preDragOptions);
4914
+ if (foldedOptions) workingOptions = foldedOptions;
4883
4915
  nonGeometryDirty = true;
4884
4916
  }
4885
- const committedPoints = textOptionFold ? preDragPoints : finalSnapshot.points;
4917
+ const committedPoints = optionFold ? preDragPoints : finalSnapshot.points;
4886
4918
  emitTransient("end", committedPoints, null);
4887
4919
  commitGesture(committedPoints, preDragOptions, transformAmplifierPlacements(preDragAmplifierPlacements, preDragBox, finalSnapshot.box, driver), preDragBox.angle);
4888
4920
  return;
@@ -8068,10 +8100,22 @@ const HATCH_PATTERNS = [
8068
8100
  "cross-hatch",
8069
8101
  "horizontal",
8070
8102
  "vertical",
8071
- "dots"
8103
+ "dots",
8104
+ "mine-unspecified",
8105
+ "mine-antipersonnel",
8106
+ "mine-antipersonnel-directional",
8107
+ "mine-antitank",
8108
+ "mine-antitank-antihandling",
8109
+ "mine-wide-area-antitank"
8072
8110
  ];
8073
8111
  /** Tile edge length, CSS px, before `pixelRatio` scaling. Kept a power of two. */
8074
8112
  const BASE_TILE_SIZE = 32;
8113
+ /** Tile edge, CSS px, of the mine-pictogram family (they use the full 32-unit tile). */
8114
+ const MINE_PATTERN_TILE_SIZE = 32;
8115
+ /** True for the mine-pictogram family — a screen-space glyph texture rather than a repeating hatch. */
8116
+ function isMinePattern(pattern) {
8117
+ return pattern.startsWith("mine-");
8118
+ }
8075
8119
  /** Line spacing as a fraction of the tile edge — 4 repeats per tile. */
8076
8120
  const SPACING_DIVISOR = 4;
8077
8121
  /**
@@ -8186,6 +8230,127 @@ function dotCoverage(x, y, spacing, radius) {
8186
8230
  const dy = centeredMod(y - spacing / 2, spacing);
8187
8231
  return Math.min(1, Math.max(0, radius + .5 - Math.hypot(dx, dy)));
8188
8232
  }
8233
+ function segmentCoverage(x, y, ax, ay, bx, by, width) {
8234
+ const dx = bx - ax;
8235
+ const dy = by - ay;
8236
+ const length2 = dx * dx + dy * dy;
8237
+ const t = length2 > 0 ? Math.min(1, Math.max(0, ((x - ax) * dx + (y - ay) * dy) / length2)) : 0;
8238
+ return Math.min(1, Math.max(0, width / 2 + .5 - Math.hypot(x - (ax + t * dx), y - (ay + t * dy))));
8239
+ }
8240
+ const MINE_GLYPHS = {
8241
+ "mine-unspecified": {
8242
+ filled: false,
8243
+ segments: []
8244
+ },
8245
+ "mine-antipersonnel": {
8246
+ filled: true,
8247
+ segments: [[
8248
+ 13,
8249
+ 12,
8250
+ 9,
8251
+ 7
8252
+ ], [
8253
+ 19,
8254
+ 12,
8255
+ 23,
8256
+ 7
8257
+ ]]
8258
+ },
8259
+ "mine-antipersonnel-directional": {
8260
+ filled: true,
8261
+ segments: [
8262
+ [
8263
+ 13,
8264
+ 12,
8265
+ 9,
8266
+ 7
8267
+ ],
8268
+ [
8269
+ 19,
8270
+ 12,
8271
+ 23,
8272
+ 7
8273
+ ],
8274
+ [
8275
+ 20,
8276
+ 16,
8277
+ 27,
8278
+ 16
8279
+ ]
8280
+ ],
8281
+ arrow: [
8282
+ 29,
8283
+ 16,
8284
+ 26,
8285
+ 2.4
8286
+ ]
8287
+ },
8288
+ "mine-antitank": {
8289
+ filled: true,
8290
+ segments: []
8291
+ },
8292
+ "mine-antitank-antihandling": {
8293
+ filled: true,
8294
+ segments: [[
8295
+ 16,
8296
+ 20,
8297
+ 16,
8298
+ 27
8299
+ ], [
8300
+ 16,
8301
+ 27,
8302
+ 19,
8303
+ 24
8304
+ ]]
8305
+ },
8306
+ "mine-wide-area-antitank": {
8307
+ filled: true,
8308
+ segments: [
8309
+ [
8310
+ 10,
8311
+ 22,
8312
+ 12,
8313
+ 25
8314
+ ],
8315
+ [
8316
+ 12,
8317
+ 25,
8318
+ 14,
8319
+ 21
8320
+ ],
8321
+ [
8322
+ 18,
8323
+ 21,
8324
+ 20,
8325
+ 25
8326
+ ],
8327
+ [
8328
+ 20,
8329
+ 25,
8330
+ 22,
8331
+ 22
8332
+ ]
8333
+ ]
8334
+ }
8335
+ };
8336
+ function minePatternCoverage(x, y, pattern, scale) {
8337
+ const glyph = MINE_GLYPHS[pattern];
8338
+ const cx = 16 * scale;
8339
+ const cy = 16 * scale;
8340
+ const radius = 5 * scale;
8341
+ const lineWidth = Math.max(1, scale);
8342
+ const distance = Math.hypot(x - cx, y - cy);
8343
+ let coverage = glyph.filled ? Math.min(1, Math.max(0, radius + .5 - distance)) : Math.min(1, Math.max(0, lineWidth / 2 + .5 - Math.abs(distance - radius)));
8344
+ 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));
8345
+ if (glyph.arrow) {
8346
+ const [tipX, tipY, baseX, halfHeight] = glyph.arrow;
8347
+ const px = x / scale;
8348
+ const py = y / scale;
8349
+ const slope = halfHeight / (tipX - baseX);
8350
+ if (px >= baseX && px <= tipX && Math.abs(py - tipY) <= (tipX - px) * slope) coverage = 1;
8351
+ }
8352
+ return coverage;
8353
+ }
8189
8354
  /**
8190
8355
  * Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
8191
8356
  * canvas involved, so this runs identically in a browser adapter and in
@@ -8207,7 +8372,8 @@ function makeFillPatternImage(color, pattern, pixelRatio = 1) {
8207
8372
  const cx = x + .5;
8208
8373
  const cy = y + .5;
8209
8374
  let coverage;
8210
- switch (pattern) {
8375
+ if (isMinePattern(pattern)) coverage = minePatternCoverage(cx, cy, pattern, size / BASE_TILE_SIZE);
8376
+ else switch (pattern) {
8211
8377
  case "reverse-hatch":
8212
8378
  coverage = lineCoverage(cx, cy, spacing, lineWidth, "\\");
8213
8379
  break;
@@ -8256,4 +8422,4 @@ function nearestWorldCopyPosition(position, refLng) {
8256
8422
  return [nearestWorldCopyLng(position[0], refLng), ...position.slice(1)];
8257
8423
  }
8258
8424
  //#endregion
8259
- 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 };
8425
+ 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 { PointerEventInfo as C, PointerCallback as S, HatchPattern as _, LayerId as a, makeFillPatternImage 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, fillPatternImageDimension as v, EditPointerDriver as x, fillPatternImageId as y };
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 };
@@ -1,4 +1,4 @@
1
- import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-DfIb57kQ.mjs";
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.0",
3
+ "version": "0.3.2",
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.3.1"
42
+ "@orbat-mapper/control-measures": "^0.5.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vitest": ">=4.0.0"