@orbat-mapper/tactical-draw 0.9.1 → 0.10.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 CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PinOverridePatch, B as resolvePinPresentation, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PinPresentationStatus, I as PinPresentationStatusEvent, L as PinPresentationStore, M as PinPresentationCapability, N as PinPresentationPatch, O as DEFAULT_PIN_PRESENTATION, P as PinPresentationState, R as PinRender, S as isMinePattern, T as EditPointerDriver, _ as HatchPattern, a as LayerId, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, j as PinPresentation, k as PinFootprint, 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 parseColor, x as fillPatternImageId, y as Rgba, z as isValidPinNumber } from "./map-adapter-azR_hVjj.mjs";
1
+ import { A as PinOverridePatch, B as resolvePinPresentation, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PinPresentationStatus, I as PinPresentationStatusEvent, L as PinPresentationStore, M as PinPresentationCapability, N as PinPresentationPatch, O as DEFAULT_PIN_PRESENTATION, P as PinPresentationState, R as PinRender, S as isMinePattern, T as EditPointerDriver, _ as HatchPattern, a as LayerId, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, j as PinPresentation, k as PinFootprint, 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 parseColor, x as fillPatternImageId, y as Rgba, z as isValidPinNumber } from "./map-adapter-2Cmj-tem.mjs";
2
2
  import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
3
3
  import { Feature, Position } from "geojson";
4
4
 
package/dist/index.mjs CHANGED
@@ -1088,7 +1088,12 @@ function createCommitEmitter(listenerErrorsMessage) {
1088
1088
  //#endregion
1089
1089
  //#region src/pin-presentation.ts
1090
1090
  function validateOverride(patch) {
1091
- for (const key of ["mode", "occlusion"]) if (Object.hasOwn(patch, key)) throw new TypeError(`Pin setting ${key} is view-wide only`);
1091
+ for (const key of [
1092
+ "mode",
1093
+ "occlusion",
1094
+ "prioritizePins",
1095
+ "depthSort"
1096
+ ]) if (Object.hasOwn(patch, key)) throw new TypeError(`Pin setting ${key} is view-wide only`);
1092
1097
  }
1093
1098
  const DEFAULT_PIN_PRESENTATION = Object.freeze({
1094
1099
  enabled: false,
@@ -1097,6 +1102,8 @@ const DEFAULT_PIN_PRESENTATION = Object.freeze({
1097
1102
  heightMeters: 250,
1098
1103
  sizePixels: 32,
1099
1104
  occlusion: "none",
1105
+ prioritizePins: true,
1106
+ depthSort: true,
1100
1107
  stem: Object.freeze({
1101
1108
  color: "#172033",
1102
1109
  width: 2,
@@ -6062,6 +6069,15 @@ function runGroupTransform(opts) {
6062
6069
  }
6063
6070
  return pixels;
6064
6071
  }
6072
+ /** An axis-aligned {@link TransformBox} spanning a min/max pixel extent. */
6073
+ function boxFromPixelBounds(min, max) {
6074
+ return {
6075
+ center: [(min[0] + max[0]) / 2, (min[1] + max[1]) / 2],
6076
+ halfWidth: (max[0] - min[0]) / 2,
6077
+ halfHeight: (max[1] - min[1]) / 2,
6078
+ angle: 0
6079
+ };
6080
+ }
6065
6081
  /** The rotated-text footprint corners for a Text member's rendered feature, or `null`. */
6066
6082
  function textFootprintCorners(features) {
6067
6083
  const box = fitTextFootprintFromFeatures(features, driver.toPixel, {
@@ -6127,6 +6143,7 @@ function runGroupTransform(opts) {
6127
6143
  let features;
6128
6144
  let iconResources = [];
6129
6145
  let imageOverlays;
6146
+ let pinGroup;
6130
6147
  let boxPixels = [];
6131
6148
  if (isImageMember(member)) {
6132
6149
  const image = buildWorkingImage(member);
@@ -6138,11 +6155,23 @@ function runGroupTransform(opts) {
6138
6155
  } else try {
6139
6156
  if (isPointSymbolMember(member)) {
6140
6157
  const symbol = buildWorkingPointSymbol(member);
6141
- const plan = renderPointSymbolForAdapter(adapter, capability, symbol);
6142
- iconResources = [plan.resource];
6143
- features = plan.features;
6144
- const footprint = pointSymbolFootprint(symbol, plan.render, adapter);
6145
- if (footprint) boxPixels = footprint.corners;
6158
+ pinGroup = opts.renderPin?.(symbol);
6159
+ if (pinGroup?.pin) {
6160
+ features = pinGroup.features;
6161
+ iconResources = pinGroup.iconResources;
6162
+ const pinFootprint = adapter.getPinFootprint?.(symbol.id);
6163
+ if (pinFootprint) boxPixels = boxCorners(boxFromPixelBounds(pinFootprint.min, pinFootprint.max));
6164
+ else {
6165
+ const footprint = pointSymbolFootprint(symbol, renderPointSymbolForAdapter(adapter, capability, symbol).render, adapter);
6166
+ if (footprint) boxPixels = footprint.corners;
6167
+ }
6168
+ } else {
6169
+ const plan = renderPointSymbolForAdapter(adapter, capability, symbol);
6170
+ iconResources = [plan.resource];
6171
+ features = plan.features;
6172
+ const footprint = pointSymbolFootprint(symbol, plan.render, adapter);
6173
+ if (footprint) boxPixels = footprint.corners;
6174
+ }
6146
6175
  } else {
6147
6176
  const working = workingGraphicFor(i);
6148
6177
  features = renderMeasureForAdapter(adapter, working, renderOpts).features;
@@ -6153,16 +6182,11 @@ function runGroupTransform(opts) {
6153
6182
  boxPixels = [];
6154
6183
  }
6155
6184
  member.lastBoxPixels = boxPixels;
6156
- if (member.usesGraphicStack) workingGroups.push({
6157
- id: member.graphic.id,
6158
- features,
6159
- iconResources,
6160
- ...imageOverlays ? { imageOverlays } : {}
6161
- });
6162
- else previewGroups.push({
6185
+ (member.usesGraphicStack ? workingGroups : previewGroups).push({
6163
6186
  id: member.graphic.id,
6164
6187
  features,
6165
6188
  iconResources,
6189
+ ...pinGroup?.pin ? { pin: pinGroup.pin } : {},
6166
6190
  ...imageOverlays ? { imageOverlays } : {}
6167
6191
  });
6168
6192
  });
@@ -8485,6 +8509,7 @@ var TacticalDraw = class {
8485
8509
  adapter: this.adapter,
8486
8510
  capability: this.pointSymbols,
8487
8511
  imageCapability: this.images,
8512
+ ...this.pointSymbols ? { renderPin: (symbol) => this.buildGraphicGroup(symbol) } : {},
8488
8513
  graphics: measures,
8489
8514
  graphicsLayer: this.graphicsLayer,
8490
8515
  previewLayer: this.previewLayer,
@@ -10,6 +10,9 @@ interface PinPresentation {
10
10
  heightMeters: number;
11
11
  sizePixels: number;
12
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;
13
16
  stem: {
14
17
  color: string;
15
18
  width: number;
@@ -48,7 +51,7 @@ type PinPresentationPatch = Partial<Omit<PinPresentation, "stem" | "dot" | "halo
48
51
  plate?: Partial<PinPresentation["plate"]>;
49
52
  };
50
53
  /** Per-unit appearance and dimensions; spatial rules belong to the view. */
51
- type PinOverridePatch = Omit<PinPresentationPatch, "mode" | "occlusion">;
54
+ type PinOverridePatch = Omit<PinPresentationPatch, "mode" | "occlusion" | "prioritizePins" | "depthSort">;
52
55
  interface PinPresentationState {
53
56
  defaults: PinPresentationPatch;
54
57
  overrides: Record<string, PinOverridePatch>;
@@ -1,4 +1,4 @@
1
- import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-azR_hVjj.mjs";
1
+ import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-2Cmj-tem.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.9.1",
3
+ "version": "0.10.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",