@orbat-mapper/tactical-draw 0.34.0 → 0.35.0

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.
@@ -1,832 +0,0 @@
1
- import { PatternId, TextAmplifiers } from "@orbat-mapper/control-measures";
2
- import { Feature, Position } from "geojson";
3
-
4
- //#region src/pin-presentation.d.ts
5
- /** View preferences, never part of an authored PointSymbol snapshot. */
6
- interface PinPresentation {
7
- enabled: boolean;
8
- mode: "screen" | "world";
9
- liftPixels: number;
10
- heightMeters: number;
11
- sizePixels: number;
12
- occlusion: "none" | "terrain";
13
- prioritizePins: boolean;
14
- /** Paint whole pins far to near by camera depth; ties retain layer order. Default on. */
15
- depthSort: boolean;
16
- stem: {
17
- color: string;
18
- width: number;
19
- opacity: number;
20
- };
21
- dot: {
22
- color: string;
23
- radius: number;
24
- opacity: number;
25
- };
26
- halo: {
27
- color: string;
28
- width: number;
29
- opacity: number;
30
- };
31
- symbolHalo: {
32
- color: string;
33
- width: number;
34
- opacity: number;
35
- };
36
- plate: {
37
- enabled: boolean;
38
- color: string;
39
- borderColor: string;
40
- borderWidth: number;
41
- padding: number;
42
- radius: number;
43
- opacity: number;
44
- };
45
- /**
46
- * View-wide zoom-out shrinking of the screen-space pin (symbol, plate, halos,
47
- * dot and screen lift; stem width stays constant). Below `fullSizeZoom` the
48
- * pin is multiplied by `falloff` per zoom level; `sizeLimits` sets the floor.
49
- */
50
- zoomScale: {
51
- enabled: boolean;
52
- fullSizeZoom: number;
53
- falloff: number;
54
- };
55
- /**
56
- * View-wide perspective sizing: pins nearer the camera than the view center
57
- * grow and farther ones shrink, by `(centerDepth / pinDepth) ^ strength`
58
- * (1 = true perspective). Multiplies with `zoomScale`; scales the same parts.
59
- */
60
- distanceScale: {
61
- enabled: boolean;
62
- strength: number;
63
- };
64
- /**
65
- * View-wide bounds on the pin scale (zoom × distance), applied only while either
66
- * scaling mode is enabled: the one place that decides how small or large pins get.
67
- * If `minScale` exceeds `maxScale`, `maxScale` wins.
68
- */
69
- sizeLimits: {
70
- minScale: number;
71
- maxScale: number;
72
- };
73
- }
74
- /** Nested settings, merged key by key rather than replaced by a patch. */
75
- declare const sections: readonly ["stem", "dot", "halo", "symbolHalo", "plate", "zoomScale", "distanceScale", "sizeLimits"];
76
- type PinSection = (typeof sections)[number];
77
- declare const viewWideKeys: readonly ["mode", "occlusion", "prioritizePins", "depthSort", "zoomScale", "distanceScale", "sizeLimits"];
78
- type PinPresentationPatch = Partial<Omit<PinPresentation, PinSection>> & { [K in PinSection]?: Partial<PinPresentation[K]> };
79
- /** Per-unit appearance and dimensions; spatial rules belong to the view. */
80
- type PinOverridePatch = Omit<PinPresentationPatch, (typeof viewWideKeys)[number]>;
81
- interface PinPresentationState {
82
- defaults: PinPresentationPatch;
83
- overrides: Record<string, PinOverridePatch>;
84
- }
85
- type PinPresentationStatus = "supported" | "unsupported" | "loading" | "waiting-for-elevation" | "unavailable";
86
- interface PinPresentationCapability {
87
- status: PinPresentationStatus;
88
- reason?: string;
89
- }
90
- interface PinPresentationStatusEvent extends PinPresentationCapability {
91
- graphicIds: readonly string[];
92
- }
93
- /** Render payload for one atomic graphic; shared icon resources retain HQ staff. */
94
- interface PinRender {
95
- id: string;
96
- position: Position;
97
- resource: IconResource;
98
- octagonSize: number;
99
- presentation: PinPresentation;
100
- opacity: number;
101
- /** Absolute clockwise bearing in radians, independent of billboard orientation. */
102
- direction?: number;
103
- /** Selection chrome only, on the host highlight/handles surface. */
104
- highlightOnly?: boolean;
105
- }
106
- interface PinFootprint {
107
- ground: PixelCoordinate;
108
- attachment: PixelCoordinate;
109
- min: PixelCoordinate;
110
- max: PixelCoordinate;
111
- }
112
- declare const DEFAULT_PIN_PRESENTATION: Readonly<PinPresentation>;
113
- /**
114
- * Multiplier for screen-space pin dimensions at `zoom`, never above 1; 1 when zoom
115
- * scaling is off. Unbounded below: combinePinScale applies `sizeLimits`.
116
- */
117
- declare function pinZoomScale(presentation: PinPresentation, zoom: number): number;
118
- /**
119
- * Perspective multiplier for a pin at camera depth `depth` (clip-space w), relative
120
- * to the view center at `referenceDepth`; 1 when distance scaling is off. Unbounded:
121
- * combinePinScale applies `sizeLimits`. Engines that scale on the GPU must mirror
122
- * this formula in their shader.
123
- */
124
- declare function pinDistanceScale(presentation: PinPresentation, depth: number, referenceDepth: number): number;
125
- /**
126
- * Combined screen-space pin scale from the two mode factors (as returned by
127
- * pinZoomScale and pinDistanceScale), bounded by `sizeLimits` while either mode is
128
- * enabled; if its `minScale` exceeds `maxScale`, `maxScale` wins. Engines that
129
- * scale on the GPU must mirror this in their shader.
130
- */
131
- declare function combinePinScale(presentation: PinPresentation, zoomScale: number, distanceScale: number): number;
132
- /**
133
- * Whether `value` is an acceptable number for the pin setting named `key`.
134
- * Exported so a host's input handling can reject a value with the same rules
135
- * the store enforces, rather than re-encoding the bounds and drifting from it.
136
- */
137
- declare function isValidPinNumber(key: string, value: unknown): value is number;
138
- declare function resolvePinPresentation(...patches: readonly PinPresentationPatch[]): PinPresentation;
139
- /** Replacing patches makes omitted override properties inherit again. */
140
- declare class PinPresentationStore {
141
- private state;
142
- /** Monotonic stamp source for {@link revision}. */
143
- private revisions;
144
- private defaultsRevision;
145
- private readonly overrideRevisions;
146
- private readonly emitter;
147
- getState(): PinPresentationState;
148
- resolve(id: string): PinPresentation;
149
- /**
150
- * @internal A stamp that changes whenever {@link resolve} may return a
151
- * different presentation for `id`, so a renderer can keep reusing the pins
152
- * whose presentation a change left alone.
153
- */
154
- revision(id: string): number;
155
- replace(state: PinPresentationState): void;
156
- setDefaults(patch: PinPresentationPatch): void;
157
- setOverride(id: string, patch: PinOverridePatch): void;
158
- resetOverride(id: string): void;
159
- /**
160
- * Set several overrides, and with `null` reset them, as one validated change
161
- * and one `onChange` emit. Each patch replaces that id's previous patch, as
162
- * {@link setOverride} does; ids not named keep theirs. An invalid patch
163
- * throws and leaves every override unchanged.
164
- */
165
- setOverrides(patches: Readonly<Record<string, PinOverridePatch | null>>): void;
166
- onChange(listener: (state: PinPresentationState) => void): () => void;
167
- }
168
- //#endregion
169
- //#region src/gestures/types.d.ts
170
- interface PointerEventInfo {
171
- /** Per-event hit-tolerance override (e.g. larger for touch). */
172
- hitTolerance?: number;
173
- /**
174
- * Whether Alt/Option was held. Modifiers are populated on mouse
175
- * pointer-down; touch leaves them undefined. Which gesture reads which key
176
- * is set by `TacticalDrawOptions.editModifiers` and `offsetDragModifier`.
177
- */
178
- altKey?: boolean;
179
- /**
180
- * Whether Shift was held for this pointer event. Constrain gestures read
181
- * their key (Shift by default) live, on every move.
182
- */
183
- shiftKey?: boolean;
184
- /** Whether Control was held for this pointer event. */
185
- ctrlKey?: boolean;
186
- /** Whether Meta/Command was held for this pointer event. */
187
- metaKey?: boolean;
188
- /** Engine-native event, for drivers that need to call preventDefault etc. */
189
- native?: unknown;
190
- }
191
- interface PointerCallback {
192
- (pixel: PixelCoordinate, info?: PointerEventInfo): void;
193
- }
194
- /**
195
- * Engine-agnostic pointer driver consumed by `TacticalDraw`'s edit controller.
196
- * The controller owns handle rendering and hit-tests handles in lonLat space;
197
- * the driver only carries raw pointer events, drag-pan toggle, and pixel
198
- * projection.
199
- */
200
- interface EditPointerDriver {
201
- onPointerDown(cb: PointerCallback): () => void;
202
- onPointerMove(cb: PointerCallback): () => void;
203
- onPointerUp(cb: PointerCallback): () => void;
204
- /**
205
- * `false` holds the engine's own drag gestures for the duration of an edit
206
- * drag — its drag-pan, and any other drag the engine binds to the same
207
- * pointer (MapLibre's drag-rotate) — so the drag moves only the handle;
208
- * `true` restores the ones the host had enabled. Despite the name it is not
209
- * limited to panning.
210
- */
211
- setDragPanEnabled(enabled: boolean): void;
212
- toPixel(lonLat: Position): PixelCoordinate | null;
213
- fromPixel(pixel: PixelCoordinate): Position;
214
- /** Idempotent. */
215
- dispose(): void;
216
- }
217
- //#endregion
218
- //#region src/tactical-draw/edit-modifiers.d.ts
219
- /** A keyboard modifier a pointer gesture can read. */
220
- type ModifierKey = "alt" | "shift" | "ctrl" | "meta";
221
- /**
222
- * Which modifier keys the editor's gestures listen for (#652). Each role takes
223
- * a key or `false` to turn the gesture off; omitted roles keep their current
224
- * key. See {@link TacticalDrawOptions.editModifiers}.
225
- */
226
- interface EditModifiers {
227
- /**
228
- * Drag a vertex with this key held to hand the gesture to the definition's
229
- * `modifierDrag` hook (e.g. a Flow Arrow split or merge). Any key in a list
230
- * starts it. Held while pressing an option handle, it lets the definition
231
- * widen that drag or reset (e.g. sizing every Split Arrow head at once).
232
- * @default ["ctrl", "meta"]
233
- */
234
- modifierDrag?: ModifierKey | readonly ModifierKey[] | false;
235
- /**
236
- * Click a vertex with this key held to delete it, or an option handle to
237
- * reset its option. Must not share a key with `modifierDrag`.
238
- * @default "alt"
239
- */
240
- deleteOrReset?: ModifierKey | false;
241
- /**
242
- * Hold to constrain angles while drawing or dragging a vertex, and to step
243
- * rotations in 15° increments.
244
- * @default "shift"
245
- */
246
- constrain?: ModifierKey | false;
247
- /**
248
- * Click a point, a midpoint or the body of a graphic with parts (e.g. a Flow
249
- * Arrow's flows) with this key held to toggle that part in or out of the
250
- * edit session's part selection instead of selecting it alone (see
251
- * `EditSession.selectedParts`). A drag with the key held is a plain
252
- * drag, so it may share the `constrain` key (Shift-drag constrains,
253
- * Shift-click extends). Must not share a key with `modifierDrag` or
254
- * `deleteOrReset`, which act on the same press. Point and midpoint presses
255
- * read the key from the edit pointer events; a body click reads it from the
256
- * engine's click event.
257
- *
258
- * Off by default: a host that synthesises the constrain key on every event
259
- * (to make constraining persistent) would otherwise extend on every click.
260
- * @default false
261
- */
262
- extendPartSelection?: ModifierKey | false;
263
- }
264
- /** {@link EditModifiers} with every role filled in, as `getEditModifiers()` returns it. */
265
- interface ResolvedEditModifiers {
266
- modifierDrag: readonly ModifierKey[] | false;
267
- deleteOrReset: ModifierKey | false;
268
- constrain: ModifierKey | false;
269
- extendPartSelection: ModifierKey | false;
270
- }
271
- declare const DEFAULT_EDIT_MODIFIERS: ResolvedEditModifiers;
272
- //#endregion
273
- //#region src/point-symbol.d.ts
274
- type PointSymbolSize = {
275
- value: number;
276
- unit: "pixels";
277
- } | {
278
- value: number;
279
- unit: "meters"; /** Floor for the on-screen projection of the ground-based size; none when omitted. */
280
- minPixels?: number; /** Cap on the on-screen projection of the ground-based size — typically the pixel size the symbol had when anchored to ground; unclamped when omitted. */
281
- maxPixels?: number;
282
- };
283
- interface PointSymbolGraphicModifiers {
284
- /** Radians clockwise, relative to the point symbol's own orientation. */
285
- direction?: number;
286
- }
287
- interface PointSymbolColors {
288
- fill?: string;
289
- frame?: string;
290
- icon?: string;
291
- info?: string;
292
- outline?: string;
293
- }
294
- interface PointSymbolStyle {
295
- colors?: PointSymbolColors;
296
- monoColor?: string;
297
- opacity?: number;
298
- /** 0–1 multiplier applied to both body and connector opacity; defaults to 1. */
299
- overallOpacity?: number;
300
- outlineWidth?: number;
301
- fill?: boolean;
302
- frame?: boolean;
303
- icon?: boolean;
304
- }
305
- type PointSymbolPlacement = {
306
- mode: "screen-relative";
307
- offset: [number, number];
308
- } | {
309
- mode: "ground";
310
- position: Position;
311
- };
312
- /**
313
- * Modifier that temporarily activates offset placement for a body drag.
314
- * @deprecated Use {@link ModifierKey}; kept as an alias.
315
- */
316
- type OffsetDragModifier = ModifierKey;
317
- type PointSymbolConnector = "auto" | "direct";
318
- /** Optional connector overrides; omitted properties inherit symbol styling. */
319
- interface PointSymbolOffsetStyle {
320
- strokeColor?: string;
321
- /** 0–1, independent of the body opacity. */
322
- opacity?: number;
323
- /** Fixed CSS-pixel width, independent of symbol size. */
324
- strokeWidth?: number;
325
- /** Alternating dash/gap lengths in CSS pixels; [] means solid. */
326
- strokeDash?: number[];
327
- }
328
- interface PointSymbolOffset {
329
- /** Gap at the symbol attachment end, measured along the line in CSS pixels; defaults to 0. */
330
- anchorPadding?: number;
331
- style?: PointSymbolOffsetStyle;
332
- placement: PointSymbolPlacement;
333
- connector: PointSymbolConnector;
334
- /** Authored indicator length as a multiple of the displayed octagon size. */
335
- indicatorLength?: number;
336
- }
337
- interface PointSymbol {
338
- id: string;
339
- kind: "point-symbol";
340
- sidc: string;
341
- position: Position;
342
- /** Normalized radians clockwise from geographic north. */
343
- rotation: number;
344
- /** Milsymbol's octagon-based L dimension. */
345
- size: PointSymbolSize;
346
- offset?: PointSymbolOffset;
347
- textAmplifiers?: TextAmplifiers;
348
- graphicModifiers?: PointSymbolGraphicModifiers;
349
- style?: PointSymbolStyle;
350
- rendererOptions?: {
351
- milsymbol?: Record<string, unknown>;
352
- };
353
- properties?: Record<string, unknown>;
354
- schemaVersion?: 1;
355
- }
356
- interface PointSymbolAnchor {
357
- x: number;
358
- y: number;
359
- }
360
- interface PointSymbolRect {
361
- x: number;
362
- y: number;
363
- width: number;
364
- height: number;
365
- }
366
- /** Canonical-size, renderer-neutral point-symbol output. */
367
- interface PointSymbolRender {
368
- /** Content-derived identity for adapter-wide native-resource reuse. */
369
- resourceId: string;
370
- svg: string;
371
- /** Renderer-space octagon size used to interpret persisted symbol size. */
372
- octagonSize: number;
373
- width: number;
374
- height: number;
375
- /**
376
- * Visible content box in canonical SVG units, relative to the image's
377
- * top-left. Footprints, hit tests and edit boxes use it, so transparent
378
- * padding (e.g. room for a soft halo) is not clickable; the image itself is
379
- * still drawn at `width × height`. Defaults to the full image.
380
- */
381
- contentBounds?: PointSymbolRect;
382
- anchor: PointSymbolAnchor;
383
- octagonAnchor: PointSymbolAnchor;
384
- valid: boolean;
385
- validation?: unknown;
386
- /** Optional body/attachment capability. All coordinates are canonical SVG units. */
387
- offset?: {
388
- body: PointSymbolRender; /** Body registration in the ordinary image, preserving natural HQ placement. */
389
- ordinaryRegistration: PointSymbolAnchor;
390
- attachment: PointSymbolAnchor;
391
- indicator?: {
392
- direction: PointSymbolAnchor;
393
- length: number;
394
- minLength?: number;
395
- };
396
- strokeColor: string;
397
- strokeWidth: number;
398
- };
399
- }
400
- interface PointSymbolCapability {
401
- readonly defaultSize: PointSymbolSize;
402
- readonly defaultRotation: number;
403
- render(symbol: PointSymbol): PointSymbolRender;
404
- invalidate(): void;
405
- /**
406
- * Monotonic counter that increments on each `invalidate()` call. Consumers
407
- * (e.g. a render cache keyed on graphic snapshot identity) may read this to
408
- * detect that previously rendered point-symbol output is stale even though
409
- * the graphic snapshot itself is unchanged. Optional — when absent,
410
- * invalidation cannot be detected by cache layers, so they must not attempt
411
- * to key on it.
412
- */
413
- readonly generation?: number;
414
- }
415
- declare function isPointSymbol(graphic: unknown): graphic is PointSymbol;
416
- declare function clonePointSymbol(symbol: PointSymbol): PointSymbol;
417
- /**
418
- * Replace a point-symbol size value as a user-driven resize. Ground-size display
419
- * bounds scale with the value so they continue to constrain zoom changes rather
420
- * than preventing the resize itself.
421
- */
422
- declare function resizePointSymbolSize(size: PointSymbolSize, value: number): PointSymbolSize;
423
- //#endregion
424
- //#region src/fill-pattern.d.ts
425
- /**
426
- * Shared hatch fill-pattern tiles for area control-measure fills (ADR-0035
427
- * `FillPattern`, excluding `"solid"` which every adapter already renders as a
428
- * flat color). Both the MapLibre adapter (raster `addImage` pattern) and the
429
- * OpenLayers adapter (canvas `Pattern` fill) need the *same* diagonal-hatch
430
- * texture, so it is rasterized once here in pure math — no `HTMLCanvasElement`
431
- * — so it works in adapter code and in jsdom/node tests alike.
432
- */
433
- type HatchPattern = PatternId;
434
- /**
435
- * Every non-solid `FillPattern` as a runtime list — the value-level companion
436
- * to {@link HatchPattern}, so adapters can test membership and build filter
437
- * expressions without re-spelling the pattern vocabulary.
438
- */
439
- declare const HATCH_PATTERNS: readonly HatchPattern[];
440
- /** Tile edge, CSS px, of the mine-pictogram family (they use the full 32-unit tile). */
441
- declare const MINE_PATTERN_TILE_SIZE: number;
442
- /** True for the mine-pictogram family — a screen-space glyph texture rather than a repeating hatch. */
443
- declare function isMinePattern(pattern: HatchPattern): pattern is MinePattern;
444
- interface Rgba {
445
- r: number;
446
- g: number;
447
- b: number;
448
- a: number;
449
- }
450
- /**
451
- * Stable id for a rasterized tile, keyed by pattern and color. Adapters use
452
- * this as the image-registry key (MapLibre `addImage` id, OpenLayers pattern
453
- * cache key) so the same color+pattern never gets rasterized twice. Color is
454
- * lowercased so `"#FF0000"` and `"#ff0000"` share one texture.
455
- */
456
- declare function fillPatternImageId(color: string, pattern: HatchPattern): string;
457
- /**
458
- * Tile edge length in device pixels for a given `pixelRatio`. Must be a power
459
- * of two — MapLibre requires POT dimensions for seamless WebGL texture wrap —
460
- * and scales linearly with `pixelRatio` for the ratios that matter in
461
- * practice (1x/2x displays: 32 -> 64, both already POT). Non-POT products
462
- * (e.g. a 3x ratio, 32*3=96) round up to the next POT rather than losing the
463
- * power-of-two guarantee.
464
- */
465
- declare function fillPatternImageDimension(pixelRatio: number): number;
466
- /**
467
- * Parse a hex (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) or `rgb()`/`rgba()`
468
- * color string into normalized channels, alpha in `[0, 1]`. Unparseable input
469
- * falls back to opaque black rather than throwing, since a mis-themed fill
470
- * should still render *something*. Shared by every renderer that needs CSS
471
- * colors as numbers — hatch fills here, billboard pins in the MapLibre
472
- * adapter — so the accepted syntax stays identical across them.
473
- */
474
- declare function parseColor(color: string): Rgba;
475
- /** The mine-pictogram members of {@link HatchPattern}, derived so the family stays in one place. */
476
- type MinePattern = Extract<HatchPattern, `mine-${string}`>;
477
- /** Coverage from the canonical command interpreter, exposed only for focused conformance tests. */
478
- /**
479
- * Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
480
- * canvas involved, so this runs identically in a browser adapter and in
481
- * jsdom/node tests. Every command, tile dimension, stroke, fill, and dash is
482
- * read from the public renderer-neutral pattern definition.
483
- */
484
- declare function makeFillPatternImage(color: string, pattern: HatchPattern, pixelRatio?: number): {
485
- width: number;
486
- height: number;
487
- data: Uint8ClampedArray;
488
- };
489
- //#endregion
490
- //#region src/map-adapter.d.ts
491
- type PixelCoordinate = [number, number];
492
- type MapCursor = "" | "default" | "crosshair" | "grab" | "grabbing" | "pointer";
493
- interface MapEvent {
494
- type: string;
495
- coordinate: Position;
496
- pixel: PixelCoordinate;
497
- originalEvent: unknown;
498
- }
499
- type MapEventHandler = (event: MapEvent) => void;
500
- interface StyleOptions {
501
- strokeColor?: string;
502
- strokeWidth?: number;
503
- strokeDash?: number[];
504
- fillColor?: string;
505
- pointFillColor?: string;
506
- pointRadius?: number;
507
- text?: TextStyleOptions;
508
- }
509
- /**
510
- * Text (label) style for a layer. When `labelProperty` is set, adapters also
511
- * read per-feature label properties: `rotation` (radians, rendered as
512
- * `π − rotation`), the size anchor's `textSizeMeters` (ground) or
513
- * `textSizePixels` (screen) (ADR-0028), `textAnchor` (`"start"` = text
514
- * begins at the label point, `"end"` = text ends there; absent = centered),
515
- * and the screen-space offset `textAnchorGap`/`textBaselineShift` (ems of the
516
- * rendered size, applied after rotation in the text's own frame; read it as
517
- * `[right, down]` with `labelTextOffsetEms`, ADR-0068).
518
- * A ground-anchored label renders at `textSizeMeters / resolution`, pinned at
519
- * `textSizeMaxPixels` and faded out then hidden below `textSizeMinPixels`
520
- * (`resolveTextAppearance`, ADR-0060); a screen-anchored one at a constant
521
- * `textSizePixels`, unclamped.
522
- */
523
- interface TextStyleOptions {
524
- text?: string;
525
- labelProperty?: string;
526
- font?: string;
527
- fillColor?: string;
528
- strokeColor?: string;
529
- strokeWidth?: number;
530
- rotation?: number;
531
- /**
532
- * Lower edge of the ground-anchored label band (ADR-0060): zoomed out past
533
- * it, a label keeps shrinking with its graphic while it fades out, then
534
- * hides, so it never outgrows the area it names.
535
- * @default 4
536
- */
537
- textSizeMinPixels?: number;
538
- /**
539
- * Upper edge of the ground-anchored label band (ADR-0028): text never
540
- * renders above this pixel size, however far the view zooms in.
541
- * @default 24
542
- */
543
- textSizeMaxPixels?: number;
544
- }
545
- /**
546
- * Per-feature style for edit handles (vertex / midpoint / translate / rotate).
547
- * The producer (`TacticalDraw`) rides this on `properties.style`; the adapter
548
- * reads it back when rendering the handle, so it is part of the adapter
549
- * contract rather than the tactical-draw authoring surface. `pointRadius` is a
550
- * UI affordance not present on `ControlMeasureStyle`. See ADR-0006.
551
- */
552
- interface HandleStyle {
553
- strokeColor?: string;
554
- strokeWidth?: number;
555
- strokeDash?: readonly number[];
556
- fillColor?: string;
557
- /**
558
- * How `fillColor` paints a filled part's interior. Absent or `"solid"` is
559
- * today's flat fill; `"hatch"`/`"reverse-hatch"`/`"cross-hatch"`/`"horizontal"`/`"vertical"`/`"dots"` request the shared pattern texture
560
- * ({@link makeFillPatternImage}). Alpha rides in `fillColor` — there is no
561
- * separate opacity field. Adapters that cannot rasterize a pattern degrade
562
- * to solid. Per-feature only: layer-level `StyleOptions` has no equivalent.
563
- */
564
- fillPattern?: "solid" | HatchPattern;
565
- pointRadius?: number;
566
- /**
567
- * Highlight casing color for a line or area part (the renderer's resolved
568
- * `style.highlight`, opacity already folded in). Adapters paint a solid
569
- * casing `highlightCasingWidth(strokeWidth)` wide along the geometry —
570
- * outline only for an area — beneath every fill and stroke of the
571
- * feature's group, even when the stroke itself is transparent. The casing
572
- * is display-only: it never widens the feature's hit area. Per-feature
573
- * only: layer-level `StyleOptions` has no equivalent. Not to be confused
574
- * with the transient selection highlight of `setHighlightedGraphics`.
575
- */
576
- highlightColor?: string;
577
- /**
578
- * Casing reach past each side of the stroke in CSS pixels (the renderer's
579
- * resolved `HighlightAppearance.width`); absent means
580
- * `HIGHLIGHT_CASING_OUTSET_CSS_PIXELS`, and `0` paints no casing.
581
- */
582
- highlightWidth?: number;
583
- /**
584
- * Glow reach past the casing in CSS pixels (the renderer's resolved
585
- * `HighlightAppearance.glow`); absent means no glow. Adapters paint the
586
- * `HIGHLIGHT_GLOW_BANDS` beneath every casing of the group, as plain
587
- * translucent strokes. Display-only like the casing.
588
- */
589
- highlightGlow?: number;
590
- }
591
- type LayerId = string;
592
- /** Canonical SVG resource shared by point features through `iconId`. */
593
- interface IconResource {
594
- id: string;
595
- svg: string;
596
- width: number;
597
- height: number;
598
- anchor: [number, number];
599
- /**
600
- * Visible content box in unscaled canvas coordinates. Icon picks and their
601
- * footprints use it instead of the full canvas, so transparent padding is not
602
- * hit area; the icon is still drawn at `width × height`. Defaults to the full
603
- * canvas.
604
- */
605
- contentRect?: PointSymbolRect;
606
- /**
607
- * Direct visible mark used to rank icon picks, in unscaled canvas coordinates.
608
- * Hits elsewhere in the full canvas measure their distance from this rectangle;
609
- * omit it to preserve whole-canvas distance-zero behavior.
610
- */
611
- coreRect?: PointSymbolRect;
612
- }
613
- /** A self-contained image fixed to four geographic corners, ordered TL/TR/BR/BL. */
614
- interface ImageOverlayResource {
615
- id: string;
616
- url: string;
617
- width: number;
618
- height: number;
619
- coordinates: readonly [Position, Position, Position, Position];
620
- opacity: number;
621
- }
622
- /**
623
- * One stable, atomic unit in a logical layer's bottom-to-top paint stack.
624
- *
625
- * Features paint in array order inside the group. A filled feature paints its
626
- * interior before its outline, and text or icon content paints at that
627
- * feature's array position. An empty group is valid and keeps its identity and
628
- * stack position.
629
- */
630
- interface FeatureGroup {
631
- /** Optional view-only point-symbol presentation; ordinary features are the fallback. */
632
- pin?: PinRender;
633
- id: string;
634
- features: readonly Feature[];
635
- iconResources: readonly IconResource[];
636
- /**
637
- * Ground-anchored rasters painted atomically with this Graphic.
638
- *
639
- * Each overlay also needs a feature in `features` whose `properties.imageOverlayId`
640
- * is the overlay's `id`, with a polygon whose ring starts TL, TR, BR, BL. OpenLayers
641
- * paints an overlay only through the feature that names it, positioned from that
642
- * feature's geometry rather than `coordinates`, and silently drops an overlay no
643
- * feature names. MapLibre and Leaflet don't read the property, so such a bug shows
644
- * only on OpenLayers.
645
- */
646
- imageOverlays?: readonly ImageOverlayResource[];
647
- /**
648
- * Monotonic stamp identifying this group's rendered content, when the
649
- * producer supplies one. Two groups with the same `id` and the same
650
- * `revision` carry byte-identical `features` and `iconResources`, so an
651
- * adapter may skip any diff or upload work for them. A missing `revision`
652
- * means "unknown" — adapters must fall back to their own comparison and
653
- * must never treat two absent stamps as equal.
654
- */
655
- revision?: number;
656
- }
657
- /**
658
- * Click-style hit event delivered by {@link MapAdapter.onPick}.
659
- *
660
- * `id` is the control measure id, already split off the feature id by the
661
- * adapter (see `controlMeasureIdFromFeature`).
662
- *
663
- * `originalEvent` is whatever the engine surfaces — OpenLayers normalises to
664
- * `PointerEvent`, MapLibre delivers `MouseEvent`, Leaflet delivers
665
- * `MouseEvent | TouchEvent`. Do not narrow to `PointerEvent` at the consumer.
666
- */
667
- interface PickEvent {
668
- id: string;
669
- feature: Feature;
670
- pixel: PixelCoordinate;
671
- coordinate: Position;
672
- originalEvent: MouseEvent | PointerEvent | TouchEvent;
673
- }
674
- type PickHandler = (event: PickEvent) => void;
675
- interface PickOptions {
676
- signal?: AbortSignal;
677
- }
678
- interface MapAdapter {
679
- onPinPresentationStatusChange?(handler: (event: PinPresentationStatusEvent) => void): () => void;
680
- getPinPresentationCapability?(graphicId?: string): PinPresentationCapability;
681
- getPinFootprint?(graphicId: string): PinFootprint | null;
682
- pickPin?(graphicId: string, pixel: PixelCoordinate, tolerance: number): boolean;
683
- /** Invert a pinned attachment for a location drag, preserving pointer grab. */
684
- movePinFromPixel?(graphicId: string, attachment: PixelCoordinate): Position | null;
685
- /**
686
- * Add a vector layer to the map.
687
- * @returns unique layer ID
688
- */
689
- addVectorLayer(options?: {
690
- style?: StyleOptions;
691
- }): LayerId;
692
- /**
693
- * Remove a layer from the map.
694
- */
695
- removeLayer(layerId: LayerId): void;
696
- /**
697
- * Set the style for a specific layer.
698
- */
699
- setLayerStyle(layerId: LayerId, style: StyleOptions): void;
700
- /**
701
- * Reconcile one complete bottom-to-top desired state for a logical layer.
702
- *
703
- * Group IDs must be non-empty and unique within the layer. Every feature
704
- * must have an ID that is unique across all groups in the layer. Invalid
705
- * desired state throws synchronously before cache, resource, or engine
706
- * mutation.
707
- */
708
- setLayerFeatureGroups(layerId: LayerId, groups: readonly FeatureGroup[]): void;
709
- /**
710
- * Subscribe to click-style "pick" events for a specific layer. Basemap and
711
- * other-layer clicks never fire the handler.
712
- *
713
- * For control-measure features, adapters must set `PickEvent.id` to the
714
- * originating control-measure id (not the rendered part's feature id).
715
- * Features that do not satisfy the control-measure feature-id contract must
716
- * be ignored rather than dispatched.
717
- *
718
- * Bound to the engine's tap-suppressing click event (OL `singleclick`,
719
- * MapLibre `click`, Leaflet `click`) so the handler does not fire at the
720
- * end of a pan or pinch-zoom gesture.
721
- *
722
- * Hit tolerance is pointer-type aware: 4 px for mouse/pen, 12 px for touch.
723
- * Outline-only polygon interiors additionally have bounded inward selection
724
- * reach from visible viewport-clipped boundaries: 24 px for mouse/pen and
725
- * 36 px for touch. A visible solid or patterned fill owns its full interior.
726
- * For grouped desired state, comparable hits follow authoritative group
727
- * order even when the engine reports another native order. A fully opaque
728
- * solid fill in a higher group suppresses lower candidates beneath its
729
- * interior; translucent and patterned fills leave visible lower marks
730
- * eligible.
731
- *
732
- * Returns an unsubscribe function. The returned function and the optional
733
- * `signal` are both honoured; either teardown path stops further events,
734
- * and both are idempotent.
735
- */
736
- onPick(layerId: LayerId, handler: PickHandler, opts?: PickOptions): () => void;
737
- /**
738
- * Map Event Listeners
739
- *
740
- * Ordering contract: a `"click"` handler and the `onPick` handlers for the
741
- * same user click MUST observe the pick first — adapters deliver picks and
742
- * `"click"` from the same underlying engine event, in registration order.
743
- * The draw/edit controllers register their pick subscriptions before their
744
- * click handler and read the stashed pick inside it (click-away close /
745
- * close-then-pick re-dispatch); an adapter that fires `"click"` from an
746
- * earlier engine event than its picks breaks that contract (e.g. OL
747
- * `click` vs `singleclick`).
748
- */
749
- on(eventType: "click" | "pointermove" | "dblclick", handler: MapEventHandler): void;
750
- off(eventType: "click" | "pointermove" | "dblclick", handler: MapEventHandler): void;
751
- /**
752
- * Projection / Coordinate Utilities
753
- */
754
- toLonLat(coordinate: number[]): Position;
755
- fromLonLat(position: Position): number[];
756
- getPixelFromCoordinate(position: Position): PixelCoordinate | null;
757
- /**
758
- * Convert a viewport pixel to longitude/latitude. Optional so third-party
759
- * adapters compiled against an older ABI remain valid.
760
- */
761
- getCoordinateFromPixel?(pixel: PixelCoordinate): Position | null;
762
- /**
763
- * Get current viewport size in CSS pixels.
764
- */
765
- getViewportSize(): {
766
- width: number;
767
- height: number;
768
- };
769
- /**
770
- * Pan the map by pixel delta.
771
- * Positive delta means desired on-screen feature shift (right/down).
772
- */
773
- panByPixels(delta: PixelCoordinate, options?: {
774
- durationMs?: number;
775
- }): void;
776
- /**
777
- * Set the map viewport cursor. Pass an empty string to restore engine default styling.
778
- */
779
- setCursor(cursor: MapCursor): void;
780
- /**
781
- * Toggle the engine's native double-click-to-zoom gesture. `TacticalDraw`
782
- * disables this for the lifetime of a variable-length draw so the commit
783
- * `dblclick` doesn't also zoom the map.
784
- */
785
- setDoubleClickZoomEnabled(enabled: boolean): void;
786
- /**
787
- * Get current view resolution (meters per pixel at center or generally).
788
- * returns undefined if not supported or not ready.
789
- */
790
- getResolution(): number | undefined;
791
- /**
792
- * Get current map zoom level
793
- */
794
- getZoom(): number | undefined;
795
- /**
796
- * Get current view bearing, radians — the clockwise-from-north compass
797
- * direction that screen-up points to (MapLibre-bearing semantics). `0` for
798
- * engines/views that don't rotate.
799
- */
800
- getBearing(): number;
801
- /**
802
- * Listen for view changes (zoom/resolution)
803
- */
804
- onViewChange(handler: () => void): void;
805
- offViewChange(handler: () => void): void;
806
- /**
807
- * The engine evaluates the meters→pixels clamp for ground-sized point
808
- * symbols inside its own style layer, so meters-sized point symbols don't
809
- * need view-change re-renders for size.
810
- */
811
- readonly scalesGroundPointSymbolsNatively?: boolean;
812
- /**
813
- * Construct an {@link EditPointerDriver} for `TacticalDraw`'s edit
814
- * controller. The controller subscribes to pointer events on the returned
815
- * driver to wire handle drags (vertex / midpoint / translate / rotate).
816
- */
817
- createEditPointerDriver(): EditPointerDriver;
818
- /**
819
- * Release all adapter-owned map resources. Adapters must not be used after
820
- * destruction.
821
- */
822
- destroy(): void;
823
- /**
824
- * Returns the features currently set on the layer — the adapter-side cache
825
- * of the last grouped mutation, flattened in bottom-to-top group
826
- * order. Empty array for an unknown layer. The private ordered group cache is
827
- * not exposed. Callers must not mutate the returned array or features.
828
- */
829
- getLayerFeatures(layerId: LayerId): readonly Feature[];
830
- }
831
- //#endregion
832
- export { PinPresentationCapability as $, PointSymbolConnector as A, isPointSymbol as B, makeFillPatternImage as C, PointSymbolAnchor as D, PointSymbol as E, PointSymbolRect as F, ResolvedEditModifiers as G, DEFAULT_EDIT_MODIFIERS as H, PointSymbolRender as I, PointerEventInfo as J, EditPointerDriver as K, PointSymbolSize as L, PointSymbolOffset as M, PointSymbolOffsetStyle as N, PointSymbolCapability as O, PointSymbolPlacement as P, PinPresentation as Q, PointSymbolStyle as R, isMinePattern as S, OffsetDragModifier as T, EditModifiers as U, resizePointSymbolSize as V, ModifierKey as W, PinFootprint as X, DEFAULT_PIN_PRESENTATION as Y, PinOverridePatch as Z, HatchPattern as _, LayerId as a, PinRender as at, fillPatternImageDimension as b, MapEvent as c, pinDistanceScale as ct, PickHandler as d, PinPresentationPatch as et, PickOptions as f, HATCH_PATTERNS as g, TextStyleOptions as h, ImageOverlayResource as i, PinPresentationStore as it, PointSymbolGraphicModifiers as j, PointSymbolColors as k, MapEventHandler as l, pinZoomScale as lt, StyleOptions as m, HandleStyle as n, PinPresentationStatus as nt, MapAdapter as o, combinePinScale as ot, PixelCoordinate as p, PointerCallback as q, IconResource as r, PinPresentationStatusEvent as rt, MapCursor as s, isValidPinNumber as st, FeatureGroup as t, PinPresentationState as tt, PickEvent as u, resolvePinPresentation as ut, MINE_PATTERN_TILE_SIZE as v, parseColor as w, fillPatternImageId as x, Rgba as y, clonePointSymbol as z };