@orbat-mapper/tactical-draw 0.3.1 → 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
|
|
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
|
@@ -8100,10 +8100,22 @@ const HATCH_PATTERNS = [
|
|
|
8100
8100
|
"cross-hatch",
|
|
8101
8101
|
"horizontal",
|
|
8102
8102
|
"vertical",
|
|
8103
|
-
"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"
|
|
8104
8110
|
];
|
|
8105
8111
|
/** Tile edge length, CSS px, before `pixelRatio` scaling. Kept a power of two. */
|
|
8106
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
|
+
}
|
|
8107
8119
|
/** Line spacing as a fraction of the tile edge — 4 repeats per tile. */
|
|
8108
8120
|
const SPACING_DIVISOR = 4;
|
|
8109
8121
|
/**
|
|
@@ -8218,6 +8230,127 @@ function dotCoverage(x, y, spacing, radius) {
|
|
|
8218
8230
|
const dy = centeredMod(y - spacing / 2, spacing);
|
|
8219
8231
|
return Math.min(1, Math.max(0, radius + .5 - Math.hypot(dx, dy)));
|
|
8220
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
|
+
}
|
|
8221
8354
|
/**
|
|
8222
8355
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
8223
8356
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
@@ -8239,7 +8372,8 @@ function makeFillPatternImage(color, pattern, pixelRatio = 1) {
|
|
|
8239
8372
|
const cx = x + .5;
|
|
8240
8373
|
const cy = y + .5;
|
|
8241
8374
|
let coverage;
|
|
8242
|
-
|
|
8375
|
+
if (isMinePattern(pattern)) coverage = minePatternCoverage(cx, cy, pattern, size / BASE_TILE_SIZE);
|
|
8376
|
+
else switch (pattern) {
|
|
8243
8377
|
case "reverse-hatch":
|
|
8244
8378
|
coverage = lineCoverage(cx, cy, spacing, lineWidth, "\\");
|
|
8245
8379
|
break;
|
|
@@ -8288,4 +8422,4 @@ function nearestWorldCopyPosition(position, refLng) {
|
|
|
8288
8422
|
return [nearestWorldCopyLng(position[0], refLng), ...position.slice(1)];
|
|
8289
8423
|
}
|
|
8290
8424
|
//#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 };
|
|
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 {
|
|
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.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.
|
|
42
|
+
"@orbat-mapper/control-measures": "^0.5.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|