@orbat-mapper/tactical-draw 0.20.0 → 0.22.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.
- package/dist/index.d.mts +103 -3
- package/dist/index.mjs +168 -43
- package/dist/{map-adapter-D6pkU0iz.d.mts → map-adapter-Btuz2FLI.d.mts} +24 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +94 -47
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as PinPresentationStatusEvent, A as PointSymbolAnchor, B as PointSymbolSize, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PointSymbolOffset, G as DEFAULT_PIN_PRESENTATION, H as clonePointSymbol, I as PointSymbolOffsetStyle, J as PinPresentation, K as PinFootprint, L as PointSymbolPlacement, M as PointSymbolColors, N as PointSymbolConnector, O as OffsetDragModifier, P as PointSymbolGraphicModifiers, Q as PinPresentationStatus, R as PointSymbolRect, S as isMinePattern, T as EditPointerDriver, U as isPointSymbol, V as PointSymbolStyle, W as resizePointSymbolSize, X as PinPresentationPatch, Y as PinPresentationCapability, Z as PinPresentationState, _ as HatchPattern, a as LayerId, at as pinZoomScale, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, et as PinPresentationStore, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as pinDistanceScale, j as PointSymbolCapability, k as PointSymbol, l as MapEventHandler, m as StyleOptions, n as HandleStyle, nt as combinePinScale, o as MapAdapter, ot as resolvePinPresentation, p as PixelCoordinate, q as PinOverridePatch, r as IconResource, rt as isValidPinNumber, s as MapCursor, t as FeatureGroup, tt as PinRender, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as PointSymbolRender } from "./map-adapter-
|
|
2
|
-
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
1
|
+
import { $ as PinPresentationStatusEvent, A as PointSymbolAnchor, B as PointSymbolSize, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PointSymbolOffset, G as DEFAULT_PIN_PRESENTATION, H as clonePointSymbol, I as PointSymbolOffsetStyle, J as PinPresentation, K as PinFootprint, L as PointSymbolPlacement, M as PointSymbolColors, N as PointSymbolConnector, O as OffsetDragModifier, P as PointSymbolGraphicModifiers, Q as PinPresentationStatus, R as PointSymbolRect, S as isMinePattern, T as EditPointerDriver, U as isPointSymbol, V as PointSymbolStyle, W as resizePointSymbolSize, X as PinPresentationPatch, Y as PinPresentationCapability, Z as PinPresentationState, _ as HatchPattern, a as LayerId, at as pinZoomScale, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, et as PinPresentationStore, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as pinDistanceScale, j as PointSymbolCapability, k as PointSymbol, l as MapEventHandler, m as StyleOptions, n as HandleStyle, nt as combinePinScale, o as MapAdapter, ot as resolvePinPresentation, p as PixelCoordinate, q as PinOverridePatch, r as IconResource, rt as isValidPinNumber, s as MapCursor, t as FeatureGroup, tt as PinRender, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as PointSymbolRender } from "./map-adapter-Btuz2FLI.mjs";
|
|
2
|
+
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, HighlightAppearance, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
3
3
|
import { Feature, Position } from "geojson";
|
|
4
4
|
|
|
5
5
|
//#region src/base-map-adapter.d.ts
|
|
@@ -218,6 +218,84 @@ declare function resolvePickPresentation(feature: Feature, layerStyle?: StyleOpt
|
|
|
218
218
|
* when missing or shaped wrong so callers fall through to the layer style.
|
|
219
219
|
*/
|
|
220
220
|
declare function coerceHandleStyle(raw: unknown): HandleStyle | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Default reach of a Highlight casing past each side of the stroke, in CSS
|
|
223
|
+
* pixels, when the renderer emitted no `highlightWidth`. The casing is a solid
|
|
224
|
+
* line `strokeWidth + 2 × outset` wide, so the default 2 px stroke gets an
|
|
225
|
+
* 8 px band: wide enough to read as a highlighter mark, narrow enough not to
|
|
226
|
+
* swallow neighbouring graphics. The renderer's `DEFAULT_HIGHLIGHT_WIDTH`.
|
|
227
|
+
*/
|
|
228
|
+
declare const HIGHLIGHT_CASING_OUTSET_CSS_PIXELS = 3;
|
|
229
|
+
/** Width of the Highlight casing beneath a stroke `strokeWidth` px wide. */
|
|
230
|
+
declare function highlightCasingWidth(strokeWidth: number, outset?: number): number;
|
|
231
|
+
/** The solid casing an adapter paints beneath a highlighted part. */
|
|
232
|
+
interface HighlightCasing {
|
|
233
|
+
color: string;
|
|
234
|
+
/** Full casing width in CSS pixels: the stroke width plus the outset on each side. */
|
|
235
|
+
width: number;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Where a Highlight band sits, bottom to top. Every part's glow bands paint
|
|
239
|
+
* beneath every part's casing in the same graphic, outer glow lowest.
|
|
240
|
+
*/
|
|
241
|
+
type HighlightBandSlot = "glow-outer" | "glow-inner" | "casing";
|
|
242
|
+
/** Bottom-to-top order of {@link HighlightBandSlot}s. */
|
|
243
|
+
declare const HIGHLIGHT_BAND_SLOTS: readonly HighlightBandSlot[];
|
|
244
|
+
/**
|
|
245
|
+
* The fading glow bands outside the casing (ADR-0062): each reaches `reach ×
|
|
246
|
+
* highlightGlow` past the casing on each side at a constant `opacity`. Plain
|
|
247
|
+
* translucent strokes, never a blur, so they cost no more to draw than the
|
|
248
|
+
* casing and print the same in every output.
|
|
249
|
+
*/
|
|
250
|
+
declare const HIGHLIGHT_GLOW_BANDS: Readonly<Record<Exclude<HighlightBandSlot, "casing">, {
|
|
251
|
+
reach: number;
|
|
252
|
+
opacity: number;
|
|
253
|
+
}>>;
|
|
254
|
+
/** One stroke of a part's Highlight: its casing or a glow band. */
|
|
255
|
+
interface HighlightBand {
|
|
256
|
+
slot: HighlightBandSlot;
|
|
257
|
+
color: string;
|
|
258
|
+
/** Full band width in CSS pixels. */
|
|
259
|
+
width: number;
|
|
260
|
+
/** Stroke opacity, multiplied with any alpha already in `color`. */
|
|
261
|
+
opacity: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Whether a rendered feature gets a Highlight: only a line or area part whose
|
|
265
|
+
* `properties.style` carries the renderer's resolved `highlightColor`.
|
|
266
|
+
*/
|
|
267
|
+
declare function hasHighlightCasing(feature: Feature): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* The Highlight bands for a rendered feature, bottom to top: the glow bands
|
|
270
|
+
* when it has a glow, the casing when its outset is above `0`; empty when it
|
|
271
|
+
* is not highlighted. An area is cased along its outline. Widths follow the
|
|
272
|
+
* part's own `strokeWidth`, else `fallbackStrokeWidth` — the stroke width the
|
|
273
|
+
* adapter would draw it at — whatever the stroke color, so a fully transparent
|
|
274
|
+
* stroke is cased too.
|
|
275
|
+
*/
|
|
276
|
+
declare function resolveHighlightBands(feature: Feature, fallbackStrokeWidth: number): HighlightBand[];
|
|
277
|
+
/**
|
|
278
|
+
* {@link resolveHighlightBands} for an adapter that already knows the part is
|
|
279
|
+
* a line or area and holds only its resolved `HandleStyle`.
|
|
280
|
+
*/
|
|
281
|
+
declare function highlightBandsForStyle(style: HandleStyle, fallbackStrokeWidth: number): HighlightBand[];
|
|
282
|
+
/** One Highlight band of one rendered feature; see {@link highlightBandsInPaintOrder}. */
|
|
283
|
+
interface FeatureHighlightBand<F extends Feature = Feature> {
|
|
284
|
+
feature: F;
|
|
285
|
+
band: HighlightBand;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Every Highlight band of one graphic's features in paint order (ADR-0062):
|
|
289
|
+
* slot by slot, so every glow band paints beneath every casing, and in feature
|
|
290
|
+
* order within a slot. Adapters paint the result as-is, beneath all of the
|
|
291
|
+
* graphic's other paint.
|
|
292
|
+
*/
|
|
293
|
+
declare function highlightBandsInPaintOrder<F extends Feature>(features: readonly F[], fallbackStrokeWidth: number): FeatureHighlightBand<F>[];
|
|
294
|
+
/**
|
|
295
|
+
* The solid Highlight casing for a rendered feature, or `null` when it has
|
|
296
|
+
* none; see {@link resolveHighlightBands} for the casing plus its glow bands.
|
|
297
|
+
*/
|
|
298
|
+
declare function resolveHighlightCasing(feature: Feature, fallbackStrokeWidth: number): HighlightCasing | null;
|
|
221
299
|
/**
|
|
222
300
|
* Default lower edge of the ground-anchored label band (ADR-0060): below it a
|
|
223
301
|
* label fades out and hides on the map, rather than pinning.
|
|
@@ -1453,6 +1531,13 @@ interface TacticalDrawOptions {
|
|
|
1453
1531
|
graphicsStyle?: ControlMeasureStyle;
|
|
1454
1532
|
/** Doctrinal defaults; explicit style colors take precedence. */
|
|
1455
1533
|
symbolColors?: SymbolColors;
|
|
1534
|
+
/**
|
|
1535
|
+
* How every graphic with `style.highlight` looks (ADR-0062): casing color,
|
|
1536
|
+
* casing width past the stroke and glow reach, all in CSS pixels. Omitted
|
|
1537
|
+
* fields keep their defaults (a 3 px orange casing, no glow). Change it
|
|
1538
|
+
* later with {@link TacticalDraw.setHighlightAppearance}.
|
|
1539
|
+
*/
|
|
1540
|
+
highlightAppearance?: HighlightAppearance;
|
|
1456
1541
|
/**
|
|
1457
1542
|
* Pixel band for ground-anchored labels on the graphics and preview layers
|
|
1458
1543
|
* (ADR-0060). A label stops growing at `textSizeMaxPixels` (default 24) and,
|
|
@@ -1647,6 +1732,11 @@ declare class TacticalDraw {
|
|
|
1647
1732
|
private readonly ownedLayers;
|
|
1648
1733
|
private readonly graphicsStyle;
|
|
1649
1734
|
private readonly symbolColors;
|
|
1735
|
+
/**
|
|
1736
|
+
* Render options shared by the graphics layer and every draw, edit and
|
|
1737
|
+
* transform session; `setHighlightAppearance` updates it in place.
|
|
1738
|
+
*/
|
|
1739
|
+
private readonly sessionRenderOptions;
|
|
1650
1740
|
private readonly labelSizeBand;
|
|
1651
1741
|
private labelFit;
|
|
1652
1742
|
private readonly defaultInteractionStyle;
|
|
@@ -1799,6 +1889,16 @@ declare class TacticalDraw {
|
|
|
1799
1889
|
* {@link TacticalDrawOptions.labelFit}.
|
|
1800
1890
|
*/
|
|
1801
1891
|
setLabelFit(labelFit: LabelFit): void;
|
|
1892
|
+
/** The current app-wide Highlight appearance; see {@link setHighlightAppearance}. */
|
|
1893
|
+
getHighlightAppearance(): HighlightAppearance;
|
|
1894
|
+
/**
|
|
1895
|
+
* Change how highlighted graphics look (ADR-0062), merging `patch` into the
|
|
1896
|
+
* current appearance: a field set to `undefined` returns to its default.
|
|
1897
|
+
* Re-renders the graphics layer and any graphic being drawn, edited or
|
|
1898
|
+
* transformed; a no-op when nothing changes. See
|
|
1899
|
+
* {@link TacticalDrawOptions.highlightAppearance}.
|
|
1900
|
+
*/
|
|
1901
|
+
setHighlightAppearance(patch: HighlightAppearance): void;
|
|
1802
1902
|
/** Replace snapping configuration without recreating the map adapter or façade. */
|
|
1803
1903
|
setSnappingOptions(options?: SnappingOptions): void;
|
|
1804
1904
|
/** Clear transient host affordances when snapping or its interaction ends. */
|
|
@@ -2298,4 +2398,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
|
|
|
2298
2398
|
/** `nearestWorldCopyLng` applied to a lon/lat position. */
|
|
2299
2399
|
declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
|
|
2300
2400
|
//#endregion
|
|
2301
|
-
export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DeferredSnapProvider, type DrawImageDraft, type DrawMarkerDraft, 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 LabelSizeBand, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type Marker, type MarkerAnchor, type MarkerCapability, MarkerCapabilityRequiredError, type MarkerFootprint, type MarkerIcon, type MarkerRender, type MarkerSize, type MarkerStyle, type MergedPickFeature, type NativeEventEntry, type OffsetDragModifier, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, PinFootprint, PinOverridePatch, PinPresentation, PinPresentationCapability, PinPresentationPatch, PinPresentationState, PinPresentationStatus, PinPresentationStatusEvent, PinPresentationStore, PinRender, type PinnableGraphic, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolConnector, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolOffset, type PointSymbolOffsetControls, type PointSymbolOffsetLayout, type PointSymbolOffsetStyle, type PointSymbolPlacement, type PointSymbolProjection, type PointSymbolRect, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type Rgba, 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_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextAppearance, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, cloneImageGraphic, cloneMarker, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
|
|
2401
|
+
export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DeferredSnapProvider, type DrawImageDraft, type DrawMarkerDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type FeatureHighlightBand, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, HIGHLIGHT_BAND_SLOTS, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS, HIGHLIGHT_GLOW_BANDS, type HandleStyle, type HatchPattern, type HighlightBand, type HighlightBandSlot, type HighlightCasing, 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 LabelSizeBand, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type Marker, type MarkerAnchor, type MarkerCapability, MarkerCapabilityRequiredError, type MarkerFootprint, type MarkerIcon, type MarkerRender, type MarkerSize, type MarkerStyle, type MergedPickFeature, type NativeEventEntry, type OffsetDragModifier, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, PinFootprint, PinOverridePatch, PinPresentation, PinPresentationCapability, PinPresentationPatch, PinPresentationState, PinPresentationStatus, PinPresentationStatusEvent, PinPresentationStore, PinRender, type PinnableGraphic, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolConnector, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolOffset, type PointSymbolOffsetControls, type PointSymbolOffsetLayout, type PointSymbolOffsetStyle, type PointSymbolPlacement, type PointSymbolProjection, type PointSymbolRect, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type Rgba, 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_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextAppearance, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, cloneImageGraphic, cloneMarker, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hasHighlightCasing, highlightBandsForStyle, highlightBandsInPaintOrder, highlightCasingWidth, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolveHighlightBands, resolveHighlightCasing, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_SYMBOL_COLOR, FILL_PATTERN_DEFINITIONS, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureOptionHandles, getDefaultOptions, normalizeTextAmplifiers, remapVertexAlignedOptions, renderControlMeasure, resetControlMeasureOptionHandle, resolveAmplifierPlacement, resolveSizePair, resolveStyleHints, resolveSymbolColor, roundToFixed, switchSizePairUnit } from "@orbat-mapper/control-measures";
|
|
1
|
+
import { DEFAULT_HIGHLIGHT_WIDTH, DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_SYMBOL_COLOR, FILL_PATTERN_DEFINITIONS, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureOptionHandles, getDefaultOptions, normalizeTextAmplifiers, remapVertexAlignedOptions, renderControlMeasure, resetControlMeasureOptionHandle, resolveAmplifierPlacement, resolveSizePair, resolveStyleHints, resolveSymbolColor, roundToFixed, switchSizePairUnit } 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";
|
|
@@ -648,6 +648,124 @@ function coerceHandleStyle(raw) {
|
|
|
648
648
|
return raw;
|
|
649
649
|
}
|
|
650
650
|
/**
|
|
651
|
+
* Default reach of a Highlight casing past each side of the stroke, in CSS
|
|
652
|
+
* pixels, when the renderer emitted no `highlightWidth`. The casing is a solid
|
|
653
|
+
* line `strokeWidth + 2 × outset` wide, so the default 2 px stroke gets an
|
|
654
|
+
* 8 px band: wide enough to read as a highlighter mark, narrow enough not to
|
|
655
|
+
* swallow neighbouring graphics. The renderer's `DEFAULT_HIGHLIGHT_WIDTH`.
|
|
656
|
+
*/
|
|
657
|
+
const HIGHLIGHT_CASING_OUTSET_CSS_PIXELS = DEFAULT_HIGHLIGHT_WIDTH;
|
|
658
|
+
/** Width of the Highlight casing beneath a stroke `strokeWidth` px wide. */
|
|
659
|
+
function highlightCasingWidth(strokeWidth, outset = HIGHLIGHT_CASING_OUTSET_CSS_PIXELS) {
|
|
660
|
+
return strokeWidth + 2 * outset;
|
|
661
|
+
}
|
|
662
|
+
/** Bottom-to-top order of {@link HighlightBandSlot}s. */
|
|
663
|
+
const HIGHLIGHT_BAND_SLOTS = [
|
|
664
|
+
"glow-outer",
|
|
665
|
+
"glow-inner",
|
|
666
|
+
"casing"
|
|
667
|
+
];
|
|
668
|
+
/**
|
|
669
|
+
* The fading glow bands outside the casing (ADR-0062): each reaches `reach ×
|
|
670
|
+
* highlightGlow` past the casing on each side at a constant `opacity`. Plain
|
|
671
|
+
* translucent strokes, never a blur, so they cost no more to draw than the
|
|
672
|
+
* casing and print the same in every output.
|
|
673
|
+
*/
|
|
674
|
+
const HIGHLIGHT_GLOW_BANDS = {
|
|
675
|
+
"glow-outer": {
|
|
676
|
+
reach: 1,
|
|
677
|
+
opacity: .22
|
|
678
|
+
},
|
|
679
|
+
"glow-inner": {
|
|
680
|
+
reach: .5,
|
|
681
|
+
opacity: .45
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
const CASED_GEOMETRIES = new Set([
|
|
685
|
+
"LineString",
|
|
686
|
+
"MultiLineString",
|
|
687
|
+
"Polygon",
|
|
688
|
+
"MultiPolygon"
|
|
689
|
+
]);
|
|
690
|
+
/**
|
|
691
|
+
* Whether a rendered feature gets a Highlight: only a line or area part whose
|
|
692
|
+
* `properties.style` carries the renderer's resolved `highlightColor`.
|
|
693
|
+
*/
|
|
694
|
+
function hasHighlightCasing(feature) {
|
|
695
|
+
return typeof coerceHandleStyle(feature.properties?.style)?.highlightColor === "string" && CASED_GEOMETRIES.has(feature.geometry?.type ?? "");
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* The Highlight bands for a rendered feature, bottom to top: the glow bands
|
|
699
|
+
* when it has a glow, the casing when its outset is above `0`; empty when it
|
|
700
|
+
* is not highlighted. An area is cased along its outline. Widths follow the
|
|
701
|
+
* part's own `strokeWidth`, else `fallbackStrokeWidth` — the stroke width the
|
|
702
|
+
* adapter would draw it at — whatever the stroke color, so a fully transparent
|
|
703
|
+
* stroke is cased too.
|
|
704
|
+
*/
|
|
705
|
+
function resolveHighlightBands(feature, fallbackStrokeWidth) {
|
|
706
|
+
if (!hasHighlightCasing(feature)) return [];
|
|
707
|
+
return highlightBandsForStyle(coerceHandleStyle(feature.properties?.style), fallbackStrokeWidth);
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* {@link resolveHighlightBands} for an adapter that already knows the part is
|
|
711
|
+
* a line or area and holds only its resolved `HandleStyle`.
|
|
712
|
+
*/
|
|
713
|
+
function highlightBandsForStyle(style, fallbackStrokeWidth) {
|
|
714
|
+
if (typeof style.highlightColor !== "string") return [];
|
|
715
|
+
const color = style.highlightColor;
|
|
716
|
+
const strokeWidth = typeof style.strokeWidth === "number" ? style.strokeWidth : fallbackStrokeWidth;
|
|
717
|
+
const outset = nonNegativeOr(style.highlightWidth, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS);
|
|
718
|
+
const glow = nonNegativeOr(style.highlightGlow, 0);
|
|
719
|
+
const casingWidth = highlightCasingWidth(strokeWidth, outset);
|
|
720
|
+
return HIGHLIGHT_BAND_SLOTS.flatMap((slot) => {
|
|
721
|
+
if (slot === "casing") return outset > 0 ? [{
|
|
722
|
+
slot,
|
|
723
|
+
color,
|
|
724
|
+
width: casingWidth,
|
|
725
|
+
opacity: 1
|
|
726
|
+
}] : [];
|
|
727
|
+
if (glow === 0) return [];
|
|
728
|
+
const { reach, opacity } = HIGHLIGHT_GLOW_BANDS[slot];
|
|
729
|
+
return [{
|
|
730
|
+
slot,
|
|
731
|
+
color,
|
|
732
|
+
width: casingWidth + 2 * reach * glow,
|
|
733
|
+
opacity
|
|
734
|
+
}];
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
const SLOT_ORDER = {
|
|
738
|
+
"glow-outer": 0,
|
|
739
|
+
"glow-inner": 1,
|
|
740
|
+
casing: 2
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* Every Highlight band of one graphic's features in paint order (ADR-0062):
|
|
744
|
+
* slot by slot, so every glow band paints beneath every casing, and in feature
|
|
745
|
+
* order within a slot. Adapters paint the result as-is, beneath all of the
|
|
746
|
+
* graphic's other paint.
|
|
747
|
+
*/
|
|
748
|
+
function highlightBandsInPaintOrder(features, fallbackStrokeWidth) {
|
|
749
|
+
return features.flatMap((feature) => resolveHighlightBands(feature, fallbackStrokeWidth).map((band) => ({
|
|
750
|
+
feature,
|
|
751
|
+
band
|
|
752
|
+
}))).sort((a, b) => SLOT_ORDER[a.band.slot] - SLOT_ORDER[b.band.slot]);
|
|
753
|
+
}
|
|
754
|
+
function nonNegativeOr(value, fallback) {
|
|
755
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* The solid Highlight casing for a rendered feature, or `null` when it has
|
|
759
|
+
* none; see {@link resolveHighlightBands} for the casing plus its glow bands.
|
|
760
|
+
*/
|
|
761
|
+
function resolveHighlightCasing(feature, fallbackStrokeWidth) {
|
|
762
|
+
const casing = resolveHighlightBands(feature, fallbackStrokeWidth).find((band) => band.slot === "casing");
|
|
763
|
+
return casing ? {
|
|
764
|
+
color: casing.color,
|
|
765
|
+
width: casing.width
|
|
766
|
+
} : null;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
651
769
|
* Default lower edge of the ground-anchored label band (ADR-0060): below it a
|
|
652
770
|
* label fades out and hides on the map, rather than pinning.
|
|
653
771
|
*/
|
|
@@ -2137,17 +2255,6 @@ function withCommittedAdapterMeasureOptions(measure) {
|
|
|
2137
2255
|
}
|
|
2138
2256
|
};
|
|
2139
2257
|
}
|
|
2140
|
-
/**
|
|
2141
|
-
* Render a measure with the adapter's live scale supplied through core's
|
|
2142
|
-
* renderer-owned context. The single seam for
|
|
2143
|
-
* "turn a measure into features against the live map" — every TacticalDraw
|
|
2144
|
-
* layer write (graphics reconcile, draw preview, edit preview, commit snapshot)
|
|
2145
|
-
* routes through here so pixel sizing is resolved identically everywhere. The
|
|
2146
|
-
* adapter resolution is Web Mercator construction scale; converting it to true
|
|
2147
|
-
* ground at the Graphic midpoint lets core's compatibility boundary round-trip
|
|
2148
|
-
* to the same construction scale. Default label capture remains a derived copy
|
|
2149
|
-
* for previews, while the input Graphic is never augmented with live scale.
|
|
2150
|
-
*/
|
|
2151
2258
|
function renderMeasureForAdapter(adapter, measure, opts) {
|
|
2152
2259
|
const withLabelSize = withCommittedAdapterMeasureOptions(measure);
|
|
2153
2260
|
const resolution = adapter.getResolution();
|
|
@@ -2680,7 +2787,7 @@ const PREVIEW_CURSOR$1 = "crosshair";
|
|
|
2680
2787
|
* kinds need no host UI.
|
|
2681
2788
|
*/
|
|
2682
2789
|
function runFixedLengthDraw(options) {
|
|
2683
|
-
const { adapter, kind, previewLayer, guideLayer,
|
|
2790
|
+
const { adapter, kind, previewLayer, guideLayer, renderOptions: renderOpts, generateId, signal, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, onSession, seed, snap } = options;
|
|
2684
2791
|
const metadata = getControlMeasureMetadata(kind);
|
|
2685
2792
|
const rule = metadata.rule;
|
|
2686
2793
|
const min = metadata.minCoordinates;
|
|
@@ -2689,10 +2796,6 @@ function runFixedLengthDraw(options) {
|
|
|
2689
2796
|
if (rule) required = rule.minimumUserPoints;
|
|
2690
2797
|
else if (typeof min === "number" && typeof max === "number" && min === max) required = min;
|
|
2691
2798
|
else throw new Error(`runFixedLengthDraw: kind "${kind}" is not fixed-length (min=${min}, max=${max})`);
|
|
2692
|
-
const renderOpts = {
|
|
2693
|
-
graphicsStyle,
|
|
2694
|
-
symbolColors
|
|
2695
|
-
};
|
|
2696
2799
|
const guideEnabled = (guideOpt ?? true) && !shouldSuppressGuide(metadata);
|
|
2697
2800
|
const isAreaKind = metadata.geometry === "area";
|
|
2698
2801
|
const initialPoints = [];
|
|
@@ -2961,7 +3064,7 @@ const PREVIEW_CURSOR = "crosshair";
|
|
|
2961
3064
|
* added point again" as additional gesture-level commit triggers.
|
|
2962
3065
|
*/
|
|
2963
3066
|
function runVariableLengthDraw(options) {
|
|
2964
|
-
const { adapter, kind, previewLayer, guideLayer,
|
|
3067
|
+
const { adapter, kind, previewLayer, guideLayer, renderOptions: renderOpts, generateId, signal, onSession, seed, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, snap } = options;
|
|
2965
3068
|
const metadata = getControlMeasureMetadata(kind);
|
|
2966
3069
|
if (typeof metadata.minCoordinates !== "number") throw new Error(`runVariableLengthDraw: kind "${kind}" has no minCoordinates metadata`);
|
|
2967
3070
|
const min = metadata.minCoordinates;
|
|
@@ -2979,10 +3082,6 @@ function runVariableLengthDraw(options) {
|
|
|
2979
3082
|
function insertionIndex(len) {
|
|
2980
3083
|
return canonicalFormed(len) ? len - trailingFixed : len;
|
|
2981
3084
|
}
|
|
2982
|
-
const renderOpts = {
|
|
2983
|
-
graphicsStyle,
|
|
2984
|
-
symbolColors
|
|
2985
|
-
};
|
|
2986
3085
|
const initialPoints = [];
|
|
2987
3086
|
if (seed) {
|
|
2988
3087
|
for (const pos of seed) {
|
|
@@ -4613,11 +4712,7 @@ const ALLOWED_EDIT_MODES = new Set([
|
|
|
4613
4712
|
* - close / abort / signal / preempt / destroy paths
|
|
4614
4713
|
*/
|
|
4615
4714
|
function runEdit(opts) {
|
|
4616
|
-
const { adapter, measure, graphicsLayer, previewLayer, guideLayer, handlesLayer,
|
|
4617
|
-
const renderOpts = {
|
|
4618
|
-
graphicsStyle,
|
|
4619
|
-
symbolColors
|
|
4620
|
-
};
|
|
4715
|
+
const { adapter, measure, graphicsLayer, previewLayer, guideLayer, handlesLayer, renderOptions: renderOpts, signal, closeOnClickAway = true, modes: initialModes, interactionStyle, onSession, handleIdPrefix, guide: guideOpt, settleToGraphics, publishWorkingGraphic, onSettled, onClickAwayGraphicsPick, snap, deferredSnap } = opts;
|
|
4621
4716
|
let sizeAnchor = opts.sizeAnchor ?? defaultSizeAnchor(measure);
|
|
4622
4717
|
let detailHandles = opts.detailHandles ?? false;
|
|
4623
4718
|
const metadata = getControlMeasureMetadata(measure.kind);
|
|
@@ -5917,6 +6012,10 @@ function runEdit(opts) {
|
|
|
5917
6012
|
if (stylesEqual(currentStyle, next.style)) return;
|
|
5918
6013
|
currentStyle = next.style;
|
|
5919
6014
|
renderWorkingGraphic();
|
|
6015
|
+
},
|
|
6016
|
+
refreshPresentation() {
|
|
6017
|
+
if (core.settled) return;
|
|
6018
|
+
renderWorkingGraphic();
|
|
5920
6019
|
}
|
|
5921
6020
|
};
|
|
5922
6021
|
}
|
|
@@ -6440,13 +6539,9 @@ function defaultGroupSizeAnchor(graphics) {
|
|
|
6440
6539
|
* a live session without a session boundary
|
|
6441
6540
|
*/
|
|
6442
6541
|
function runGroupTransform(opts) {
|
|
6443
|
-
const { adapter, capability, imageCapability, markerCapability, graphics, graphicsLayer, previewLayer, handlesLayer,
|
|
6542
|
+
const { adapter, capability, imageCapability, markerCapability, graphics, graphicsLayer, previewLayer, handlesLayer, renderOptions: renderOpts, signal, closeOnClickAway = true, interactionStyle, onSession, handleIdPrefix, publishWorkingGraphics, settleWorkingGraphics, isOnGraphicsLayer, onSettled, onClickAwayGraphicsPick } = opts;
|
|
6444
6543
|
assertCapabilityFor(graphics);
|
|
6445
6544
|
validateHostResources(graphics);
|
|
6446
|
-
const renderOpts = {
|
|
6447
|
-
graphicsStyle,
|
|
6448
|
-
symbolColors
|
|
6449
|
-
};
|
|
6450
6545
|
let sizeAnchor = opts.sizeAnchor ?? defaultGroupSizeAnchor(graphics);
|
|
6451
6546
|
/** Throw synchronously if any graphic in `list` is a point symbol and no capability was supplied. */
|
|
6452
6547
|
function assertCapabilityFor(list) {
|
|
@@ -8625,6 +8720,11 @@ var TacticalDraw = class {
|
|
|
8625
8720
|
ownedLayers;
|
|
8626
8721
|
graphicsStyle;
|
|
8627
8722
|
symbolColors;
|
|
8723
|
+
/**
|
|
8724
|
+
* Render options shared by the graphics layer and every draw, edit and
|
|
8725
|
+
* transform session; `setHighlightAppearance` updates it in place.
|
|
8726
|
+
*/
|
|
8727
|
+
sessionRenderOptions;
|
|
8628
8728
|
labelSizeBand;
|
|
8629
8729
|
labelFit;
|
|
8630
8730
|
defaultInteractionStyle;
|
|
@@ -8749,6 +8849,11 @@ var TacticalDraw = class {
|
|
|
8749
8849
|
this.labelFit = options?.labelFit ?? "shrink";
|
|
8750
8850
|
this.lastViewResolution = adapter.getResolution();
|
|
8751
8851
|
this.graphicsStyle = resolveStyleHints(BUILT_IN_GRAPHICS_STYLE, options?.graphicsStyle, void 0);
|
|
8852
|
+
this.sessionRenderOptions = {
|
|
8853
|
+
graphicsStyle: this.graphicsStyle,
|
|
8854
|
+
symbolColors: this.symbolColors,
|
|
8855
|
+
highlightAppearance: { ...options?.highlightAppearance }
|
|
8856
|
+
};
|
|
8752
8857
|
this.defaultInteractionStyle = options?.interactionStyle;
|
|
8753
8858
|
this.generateId = options?.generateId ?? (() => `td-${++this.idCounter}`);
|
|
8754
8859
|
this.pointSymbols = options?.pointSymbols;
|
|
@@ -8857,6 +8962,31 @@ var TacticalDraw = class {
|
|
|
8857
8962
|
this.invalidateGraphicGroupCache(false);
|
|
8858
8963
|
if (this.hasRendered) this.reconcileGraphicsStack();
|
|
8859
8964
|
}
|
|
8965
|
+
/** The current app-wide Highlight appearance; see {@link setHighlightAppearance}. */
|
|
8966
|
+
getHighlightAppearance() {
|
|
8967
|
+
return { ...this.sessionRenderOptions.highlightAppearance };
|
|
8968
|
+
}
|
|
8969
|
+
/**
|
|
8970
|
+
* Change how highlighted graphics look (ADR-0062), merging `patch` into the
|
|
8971
|
+
* current appearance: a field set to `undefined` returns to its default.
|
|
8972
|
+
* Re-renders the graphics layer and any graphic being drawn, edited or
|
|
8973
|
+
* transformed; a no-op when nothing changes. See
|
|
8974
|
+
* {@link TacticalDrawOptions.highlightAppearance}.
|
|
8975
|
+
*/
|
|
8976
|
+
setHighlightAppearance(patch) {
|
|
8977
|
+
this.assertAlive();
|
|
8978
|
+
const next = {
|
|
8979
|
+
...this.sessionRenderOptions.highlightAppearance,
|
|
8980
|
+
...patch
|
|
8981
|
+
};
|
|
8982
|
+
for (const key of Object.keys(next)) if (next[key] === void 0) delete next[key];
|
|
8983
|
+
if (deepEqual(next, this.sessionRenderOptions.highlightAppearance)) return;
|
|
8984
|
+
this.sessionRenderOptions.highlightAppearance = next;
|
|
8985
|
+
if (this.graphicsStyle.highlight === true) this.invalidateGraphicGroupCache(false);
|
|
8986
|
+
else for (const graphic of this.lastRenderedMeasures) if (!isAnchoredGraphic(graphic) && graphic.style?.highlight === true) this.graphicGroupCache.delete(graphic);
|
|
8987
|
+
if (this.hasRendered) this.reconcileGraphicsStack();
|
|
8988
|
+
this.refreshActiveEditPresentation();
|
|
8989
|
+
}
|
|
8860
8990
|
/** Replace snapping configuration without recreating the map adapter or façade. */
|
|
8861
8991
|
setSnappingOptions(options) {
|
|
8862
8992
|
this.assertAlive();
|
|
@@ -8968,8 +9098,7 @@ var TacticalDraw = class {
|
|
|
8968
9098
|
};
|
|
8969
9099
|
}
|
|
8970
9100
|
const render = renderMeasureForAdapter(this.adapter, graphic, {
|
|
8971
|
-
|
|
8972
|
-
symbolColors: this.symbolColors,
|
|
9101
|
+
...this.sessionRenderOptions,
|
|
8973
9102
|
context: { labelFit: this.labelFit }
|
|
8974
9103
|
});
|
|
8975
9104
|
return {
|
|
@@ -9440,8 +9569,7 @@ var TacticalDraw = class {
|
|
|
9440
9569
|
kind,
|
|
9441
9570
|
previewLayer: this.previewLayer,
|
|
9442
9571
|
guideLayer: this.guideLayer,
|
|
9443
|
-
|
|
9444
|
-
symbolColors: this.symbolColors,
|
|
9572
|
+
renderOptions: this.sessionRenderOptions,
|
|
9445
9573
|
generateId: () => measureDraft.id ?? this.generateId(),
|
|
9446
9574
|
signal: options?.signal,
|
|
9447
9575
|
measureOptions: measureDraft.options,
|
|
@@ -9459,8 +9587,7 @@ var TacticalDraw = class {
|
|
|
9459
9587
|
kind,
|
|
9460
9588
|
previewLayer: this.previewLayer,
|
|
9461
9589
|
guideLayer: this.guideLayer,
|
|
9462
|
-
|
|
9463
|
-
symbolColors: this.symbolColors,
|
|
9590
|
+
renderOptions: this.sessionRenderOptions,
|
|
9464
9591
|
generateId: () => measureDraft.id ?? this.generateId(),
|
|
9465
9592
|
signal: options?.signal,
|
|
9466
9593
|
onSession: this.trackSession(options?.onSession),
|
|
@@ -9623,8 +9750,7 @@ var TacticalDraw = class {
|
|
|
9623
9750
|
previewLayer: this.previewLayer,
|
|
9624
9751
|
guideLayer: this.guideLayer,
|
|
9625
9752
|
handlesLayer: this.handlesLayer,
|
|
9626
|
-
|
|
9627
|
-
symbolColors: this.symbolColors,
|
|
9753
|
+
renderOptions: this.sessionRenderOptions,
|
|
9628
9754
|
labelSizeBand: this.labelSizeBand,
|
|
9629
9755
|
signal: options?.signal,
|
|
9630
9756
|
closeOnClickAway: options?.closeOnClickAway,
|
|
@@ -9684,8 +9810,7 @@ var TacticalDraw = class {
|
|
|
9684
9810
|
graphicsLayer: this.graphicsLayer,
|
|
9685
9811
|
previewLayer: this.previewLayer,
|
|
9686
9812
|
handlesLayer: this.handlesLayer,
|
|
9687
|
-
|
|
9688
|
-
symbolColors: this.symbolColors,
|
|
9813
|
+
renderOptions: this.sessionRenderOptions,
|
|
9689
9814
|
signal: options?.signal,
|
|
9690
9815
|
closeOnClickAway: options?.closeOnClickAway,
|
|
9691
9816
|
interactionStyle: mergedInteractionStyle,
|
|
@@ -10493,4 +10618,4 @@ function nearestWorldCopyPosition(position, refLng) {
|
|
|
10493
10618
|
return [nearestWorldCopyLng(position[0], refLng), ...position.slice(1)];
|
|
10494
10619
|
}
|
|
10495
10620
|
//#endregion
|
|
10496
|
-
export { BaseMapAdapter, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, HATCH_PATTERNS, ImageCapabilityRequiredError, MINE_PATTERN_TILE_SIZE, MarkerCapabilityRequiredError, PinPresentationStore, PointSymbolCapabilityRequiredError, PointerCallbackHub, TEXT_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, TacticalDrawDestroyedError, alignPointSymbolIndicator, bindAbortable, cloneImageGraphic, cloneMarker, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
|
|
10621
|
+
export { BaseMapAdapter, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, HATCH_PATTERNS, HIGHLIGHT_BAND_SLOTS, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS, HIGHLIGHT_GLOW_BANDS, ImageCapabilityRequiredError, MINE_PATTERN_TILE_SIZE, MarkerCapabilityRequiredError, PinPresentationStore, PointSymbolCapabilityRequiredError, PointerCallbackHub, TEXT_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, TacticalDrawDestroyedError, alignPointSymbolIndicator, bindAbortable, cloneImageGraphic, cloneMarker, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hasHighlightCasing, highlightBandsForStyle, highlightBandsInPaintOrder, highlightCasingWidth, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolveHighlightBands, resolveHighlightCasing, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
|
|
@@ -496,6 +496,30 @@ interface HandleStyle {
|
|
|
496
496
|
*/
|
|
497
497
|
fillPattern?: "solid" | HatchPattern;
|
|
498
498
|
pointRadius?: number;
|
|
499
|
+
/**
|
|
500
|
+
* Highlight casing color for a line or area part (the renderer's resolved
|
|
501
|
+
* `style.highlight`, opacity already folded in). Adapters paint a solid
|
|
502
|
+
* casing `highlightCasingWidth(strokeWidth)` wide along the geometry —
|
|
503
|
+
* outline only for an area — beneath every fill and stroke of the
|
|
504
|
+
* feature's group, even when the stroke itself is transparent. The casing
|
|
505
|
+
* is display-only: it never widens the feature's hit area. Per-feature
|
|
506
|
+
* only: layer-level `StyleOptions` has no equivalent. Not to be confused
|
|
507
|
+
* with the transient selection highlight of `setHighlightedGraphics`.
|
|
508
|
+
*/
|
|
509
|
+
highlightColor?: string;
|
|
510
|
+
/**
|
|
511
|
+
* Casing reach past each side of the stroke in CSS pixels (the renderer's
|
|
512
|
+
* resolved `HighlightAppearance.width`); absent means
|
|
513
|
+
* `HIGHLIGHT_CASING_OUTSET_CSS_PIXELS`, and `0` paints no casing.
|
|
514
|
+
*/
|
|
515
|
+
highlightWidth?: number;
|
|
516
|
+
/**
|
|
517
|
+
* Glow reach past the casing in CSS pixels (the renderer's resolved
|
|
518
|
+
* `HighlightAppearance.glow`); absent means no glow. Adapters paint the
|
|
519
|
+
* `HIGHLIGHT_GLOW_BANDS` beneath every casing of the group, as plain
|
|
520
|
+
* translucent strokes. Display-only like the casing.
|
|
521
|
+
*/
|
|
522
|
+
highlightGlow?: number;
|
|
499
523
|
}
|
|
500
524
|
type LayerId = string;
|
|
501
525
|
/** Canonical SVG resource shared by point features through `iconId`. */
|
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-Btuz2FLI.mjs";
|
|
2
2
|
import { Feature } from "geojson";
|
|
3
3
|
|
|
4
4
|
//#region src/testing/feature-group-conformance.d.ts
|
package/dist/testing.mjs
CHANGED
|
@@ -2,53 +2,86 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
//#region src/testing/feature-group-conformance.ts
|
|
3
3
|
function runFeatureGroupConformance(name, createSubject, options = {}) {
|
|
4
4
|
describe(`${name} feature-group conformance`, () => {
|
|
5
|
-
if (options.canonicalFeatureOrder)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
5
|
+
if (options.canonicalFeatureOrder) {
|
|
6
|
+
it("paints interleaved feature content in canonical array order", () => {
|
|
7
|
+
const subject = createSubject();
|
|
8
|
+
const { adapter, layerId } = subject;
|
|
9
|
+
const icon = iconResource("order-icon");
|
|
10
|
+
const mixed = canonicalOrderFeatures(icon.id);
|
|
11
|
+
adapter.setLayerStyle(layerId, { text: { labelProperty: "label" } });
|
|
12
|
+
adapter.setLayerFeatureGroups(layerId, [group$1("mixed", mixed, [icon]), group$1("upper", [line$1("upper-stroke")])]);
|
|
13
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
14
|
+
"solid:fill",
|
|
15
|
+
"solid:stroke",
|
|
16
|
+
"label:text",
|
|
17
|
+
"pattern:pattern",
|
|
18
|
+
"pattern:stroke",
|
|
19
|
+
"icon:icon",
|
|
20
|
+
"last-stroke:stroke",
|
|
21
|
+
"upper-stroke:stroke"
|
|
22
|
+
]);
|
|
23
|
+
const updated = [
|
|
24
|
+
mixed[3],
|
|
25
|
+
mixed[0],
|
|
26
|
+
mixed[1],
|
|
27
|
+
mixed[2],
|
|
28
|
+
mixed[4]
|
|
29
|
+
];
|
|
30
|
+
adapter.setLayerFeatureGroups(layerId, [group$1("mixed", updated, [icon]), group$1("upper", [line$1("upper-stroke")])]);
|
|
31
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
32
|
+
"icon:icon",
|
|
33
|
+
"solid:fill",
|
|
34
|
+
"solid:stroke",
|
|
35
|
+
"label:text",
|
|
36
|
+
"pattern:pattern",
|
|
37
|
+
"pattern:stroke",
|
|
38
|
+
"last-stroke:stroke",
|
|
39
|
+
"upper-stroke:stroke"
|
|
40
|
+
]);
|
|
41
|
+
adapter.setLayerFeatureGroups(layerId, [group$1("upper", [line$1("upper-stroke")]), group$1("mixed", updated, [icon])]);
|
|
42
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
43
|
+
"upper-stroke:stroke",
|
|
44
|
+
"icon:icon",
|
|
45
|
+
"solid:fill",
|
|
46
|
+
"solid:stroke",
|
|
47
|
+
"label:text",
|
|
48
|
+
"pattern:pattern",
|
|
49
|
+
"pattern:stroke",
|
|
50
|
+
"last-stroke:stroke"
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
it("paints a highlighted graphic's casings beneath all of its own paint", () => {
|
|
54
|
+
const subject = createSubject();
|
|
55
|
+
const { adapter, layerId } = subject;
|
|
56
|
+
const highlighted = [highlight(polygon$1("area")), highlight(line$1("shaft"))];
|
|
57
|
+
adapter.setLayerFeatureGroups(layerId, [
|
|
58
|
+
group$1("lower", [line$1("lower-stroke")]),
|
|
59
|
+
group$1("highlighted", highlighted),
|
|
60
|
+
group$1("upper", [line$1("upper-stroke")])
|
|
61
|
+
]);
|
|
62
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
63
|
+
"lower-stroke:stroke",
|
|
64
|
+
"area:casing",
|
|
65
|
+
"shaft:casing",
|
|
66
|
+
"area:fill",
|
|
67
|
+
"area:stroke",
|
|
68
|
+
"shaft:stroke",
|
|
69
|
+
"upper-stroke:stroke"
|
|
70
|
+
]);
|
|
71
|
+
adapter.setLayerFeatureGroups(layerId, [
|
|
72
|
+
group$1("lower", [line$1("lower-stroke")]),
|
|
73
|
+
group$1("highlighted", [polygon$1("area"), line$1("shaft")]),
|
|
74
|
+
group$1("upper", [line$1("upper-stroke")])
|
|
75
|
+
]);
|
|
76
|
+
expect(subject.paintSequence?.()).toEqual([
|
|
77
|
+
"lower-stroke:stroke",
|
|
78
|
+
"area:fill",
|
|
79
|
+
"area:stroke",
|
|
80
|
+
"shaft:stroke",
|
|
81
|
+
"upper-stroke:stroke"
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
52
85
|
it("reconciles complete ordered group state, including pure reorders", () => {
|
|
53
86
|
const subject = createSubject();
|
|
54
87
|
const { adapter, layerId } = subject;
|
|
@@ -170,6 +203,20 @@ function iconPoint(id, iconId) {
|
|
|
170
203
|
properties: { iconId }
|
|
171
204
|
};
|
|
172
205
|
}
|
|
206
|
+
/** The same feature as a highlighted graphic's part: the renderer's resolved casing color. */
|
|
207
|
+
function highlight(feature) {
|
|
208
|
+
const style = feature.properties?.style ?? {};
|
|
209
|
+
return {
|
|
210
|
+
...feature,
|
|
211
|
+
properties: {
|
|
212
|
+
...feature.properties,
|
|
213
|
+
style: {
|
|
214
|
+
...style,
|
|
215
|
+
highlightColor: "#ff6a00"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
173
220
|
function line$1(id) {
|
|
174
221
|
return {
|
|
175
222
|
type: "Feature",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
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.38.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|