@orbat-mapper/control-measures 0.2.0-alpha.2 → 0.2.0-alpha.20
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/README.md +9 -3
- package/dist/index-C1NE59Nx.d.mts +2731 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +24 -8
- package/dist/preview/index.d.mts +73 -3
- package/dist/preview/index.mjs +173 -19
- package/dist/{renderControlMeasure-C7pY-TcL.mjs → renderControlMeasure-DURyfLXo.mjs} +7299 -2392
- package/media/airborne-attack.svg +1 -1
- package/media/ambush.svg +1 -1
- package/media/antitank-ditch-completed.svg +1 -1
- package/media/antitank-ditch-under-construction.svg +1 -1
- package/media/antitank-wall.svg +1 -1
- package/media/area-of-operations.svg +1 -0
- package/media/assembly-area.svg +1 -0
- package/media/attack-by-fire.svg +1 -1
- package/media/attack-helicopter.svg +1 -1
- package/media/battle-handover-line.svg +1 -0
- package/media/battle-position.svg +1 -1
- package/media/block-arrow.svg +1 -1
- package/media/block-mission-task.svg +1 -1
- package/media/block.svg +1 -1
- package/media/boundary.svg +1 -1
- package/media/breach.svg +1 -1
- package/media/bypass.svg +1 -1
- package/media/canalize.svg +1 -1
- package/media/circle.svg +1 -0
- package/media/classic-arrow.svg +1 -1
- package/media/clear.svg +1 -1
- package/media/delay.svg +1 -1
- package/media/disrupt.svg +1 -1
- package/media/encirclement.svg +1 -0
- package/media/engineer-work-line.svg +1 -0
- package/media/final-protective-fire-left.svg +1 -1
- package/media/final-protective-fire-right.svg +1 -1
- package/media/fix.svg +1 -1
- package/media/flot.svg +1 -1
- package/media/fortified-area.svg +1 -1
- package/media/fortified-line.svg +1 -1
- package/media/generic-c2-line.svg +1 -0
- package/media/handover-line.svg +1 -0
- package/media/isolate.svg +1 -1
- package/media/joint-tactical-action-area.svg +1 -0
- package/media/landing-zone.svg +1 -0
- package/media/light-line.svg +1 -0
- package/media/line.svg +1 -0
- package/media/main-attack.svg +1 -1
- package/media/obstacle-bypass-difficult.svg +1 -1
- package/media/obstacle-bypass-easy.svg +1 -1
- package/media/obstacle-bypass-impossible.svg +1 -1
- package/media/phase-line.svg +1 -0
- package/media/pickup-zone.svg +1 -0
- package/media/polygon.svg +1 -0
- package/media/principal-direction-of-fire.svg +1 -1
- package/media/rectangle.svg +1 -0
- package/media/search-area.svg +1 -1
- package/media/strong-point.svg +1 -0
- package/media/support-by-fire.svg +1 -1
- package/media/supporting-attack.svg +1 -1
- package/media/turn.svg +1 -1
- package/package.json +1 -1
- package/dist/index-D7uBPw7l.d.mts +0 -1653
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type AirborneAttackOptions, type AmbushOptions, type AnchorTransformEvent, type AntitankDitchOptions, type AntitankWallOptions, type AttackByFireOptions, type AttackHelicopterOptions, type BaselineFrame, type BaselineFrameNormal, type BaselineFrameOptions, type BaselineFrameOrigin, type BlockMissionTaskOptions, type BlockOptions, type BreachOptions, type BypassOptions, CONTROL_MEASURE_IDS, CONTROL_MEASURE_METADATA, type CanalizeOptions, type ClearOptions, type ControlMeasure, type ControlMeasureDrawRule, type ControlMeasureGeometry, type ControlMeasureGeometryType, type ControlMeasureId, type ControlMeasureKind, type ControlMeasureMetadata, type ControlMeasureRender, type
|
|
1
|
+
import { $ as ObstacleBypassDifficultOptions, $n as DirectionOfAttackAviationOptions, $t as SupportByFireOptions, A as roundToFixed, An as DEFAULT_JOINT_TACTICAL_ACTION_AREA_OPTIONS, Ar as canonicalTextAmplifierKey, At as DEFAULT_TACTICAL_ARROW_OPTIONS, B as isKind, Bn as ControlMeasureRender, Bt as BlockMissionTaskOptions, C as BaselineFrame, Cn as computeInitialWidthPoint, Cr as CanonicalTextAmplifiers, Ct as ScreenOptions, D as createBaselineFrame, Dn as PickupZoneOptions, Dr as TextAmplifierField, Dt as DelayOptions, E as BaselineFrameOrigin, En as DEFAULT_PICKUP_ZONE_OPTIONS, Er as TEXT_AMPLIFIER_FIELDS, Et as DEFAULT_DELAY_OPTIONS, F as freezeOrientationOptions, Fn as DEFAULT_AREA_DEFENSE_OPTIONS, Ft as DEFAULT_CANALIZE_OPTIONS, G as OptionsByKind, Gn as FillPattern, Gt as HandoverLineOptions, H as CONTROL_MEASURE_METADATA, Hn as StyleHints, Ht as BattleHandoverLineOptions, I as RenderOptions, In as DEFAULT_ENCIRCLEMENT_OPTIONS, It as BypassOptions, J as getDefaultOptions, Jn as DEFAULT_DIRECTION_OF_SUPPORTING_ATTACK_OPTIONS, Jt as DEFAULT_FLOT_OPTIONS, K as getControlMeasureMetadata, Kn as DEFAULT_PRINCIPAL_DIRECTION_OF_FIRE_OPTIONS, Kt as DEFAULT_PHASE_LINE_OPTIONS, L as renderControlMeasure, Ln as EncirclementOptions, Lt as DEFAULT_BYPASS_OPTIONS, M as SimpleStyleRender, Mn as AssemblyAreaOptions, Mr as resolveAmplifierPlacement, Mt as ClearOptions, N as toSimpleStyle, Nn as DEFAULT_ASSEMBLY_AREA_OPTIONS, Nr as AnchorTransformEvent, Nt as DEFAULT_CLEAR_OPTIONS, O as EPSILON, On as DEFAULT_LANDING_ZONE_OPTIONS, Or as TextAmplifierKey, Ot as CoverOptions, P as resolveStyleHints, Pn as AreaDefenseOptions, Pr as ControlMeasureDrawRule, Pt as CanalizeOptions, Q as DEFAULT_OBSTACLE_BYPASS_DIFFICULT_OPTIONS, Qn as DEFAULT_DIRECTION_OF_ATTACK_AVIATION_OPTIONS, Qt as DEFAULT_SUPPORT_BY_FIRE_OPTIONS, R as ControlMeasure, Rn as DEFAULT_FINAL_PROTECTIVE_FIRE_OPTIONS, Rt as BreachOptions, S as snapToMidpointPerpendicular, Sn as calculateMetrics, Sr as AmplifierPlacements, St as DEFAULT_SCREEN_OPTIONS, T as BaselineFrameOptions, Tn as DEFAULT_AREA_OF_OPERATIONS_OPTIONS, Tr as LabelPlacementOverride, Tt as GuardOptions, U as ControlMeasureId, Un as controlMeasureIdFromFeature, Ut as DEFAULT_BATTLE_HANDOVER_LINE_OPTIONS, V as CONTROL_MEASURE_IDS, Vn as FeaturePartProps, Vt as DEFAULT_BLOCK_MISSION_TASK_OPTIONS, W as ControlMeasureKind, Wn as ControlMeasureStyle, Wt as DEFAULT_HANDOVER_LINE_OPTIONS, X as DEFAULT_OBSTACLE_BYPASS_IMPOSSIBLE_OPTIONS, Xn as DEFAULT_DIRECTION_OF_MAIN_ATTACK_OPTIONS, Xt as AttackByFireOptions, Y as listControlMeasureMetadata, Yn as DirectionOfSupportingAttackOptions, Yt as FLOTOptions, Z as ObstacleBypassImpossibleOptions, Zn as DirectionOfMainAttackOptions, Zt as DEFAULT_ATTACK_BY_FIRE_OPTIONS, _ as MidpointPerpendicularDrawRuleOptions, _n as DEFAULT_CLASSIC_ARROW_OPTIONS, _r as ControlMeasureGeometryType, _t as FortifiedLineOptions, a as supportByFireDrawRule, an as GenericCircleOptions, ar as GenericC2LineOptions, at as FixOptions, b as getMidpointPerpendicularSignedDistance, bn as DEFAULT_MAIN_ATTACK_OPTIONS, br as TextAmplifierDescriptor, bt as AntitankDitchOptions, c as line23DrawRule, cn as DEFAULT_GENERIC_POLYGON_OPTIONS, cr as DEFAULT_LIGHT_LINE_OPTIONS, ct as BlockOptions, d as ambushDrawRule, dn as GenericLineOptions, dr as Point2D, dt as TurningMovementOptions, en as AttackHelicopterOptions, er as DEFAULT_STRONG_POINT_OPTIONS, et as DEFAULT_OBSTACLE_BYPASS_EASY_OPTIONS, f as attackByFireDrawRule, fn as BlockArrowHeadStyle, fr as project, ft as DEFAULT_FRONTAL_ATTACK_OPTIONS, g as blockDrawRule, gn as ClassicArrowOptions, gr as ControlMeasureGeometry, gt as DEFAULT_FORTIFIED_LINE_OPTIONS, h as disruptDrawRule, hn as ClassicArrowHeadStyle, hr as DEFAULT_BOUNDARY_OPTIONS, ht as FortifiedAreaOptions, i as axis1DrawRule, in as DEFAULT_GENERIC_CIRCLE_OPTIONS, ir as DEFAULT_GENERIC_C2_LINE_OPTIONS, it as DEFAULT_FIX_OPTIONS, j as SimpleStyleProps, jn as JointTacticalActionAreaOptions, jr as normalizeTextAmplifiers, jt as TacticalArrowOptions, k as getMetersPerPixel, kn as LandingZoneOptions, kr as TextAmplifiers, kt as DEFAULT_COVER_OPTIONS, l as turnDrawRule, ln as GenericPolygonOptions, lr as LightLineOptions, lt as DEFAULT_BLOCK_OPTIONS, m as centerRadiusDrawRule, mn as DEFAULT_BLOCK_ARROW_OPTIONS, mr as BoundaryOptions, mt as DEFAULT_FORTIFIED_AREA_OPTIONS, n as DEFAULT_AMBUSH_OPTIONS, nn as AirborneAttackOptions, nr as BattlePositionOptions, nt as DEFAULT_TURN_OPTIONS, o as line26DrawRule, on as DEFAULT_GENERIC_RECTANGLE_OPTIONS, or as DEFAULT_ENGINEER_WORK_LINE_OPTIONS, ot as DEFAULT_DISRUPT_OPTIONS, p as point12DrawRule, pn as BlockArrowOptions, pr as unproject, pt as FrontalAttackOptions, q as getControlMeasureMetadataByValue, qn as PrincipalDirectionOfFireOptions, qt as PhaseLineOptions, r as rectangleDrawRule, rn as DEFAULT_AIRBORNE_ATTACK_OPTIONS, rr as DEFAULT_BATTLE_POSITION_OPTIONS, rt as TurnOptions, s as line24DrawRule, sn as GenericRectangleOptions, sr as EngineerWorkLineOptions, st as DisruptOptions, t as AmbushOptions, tn as DEFAULT_ATTACK_HELICOPTER_OPTIONS, tr as StrongPointOptions, tt as ObstacleBypassEasyOptions, u as line1DrawRule, un as DEFAULT_GENERIC_LINE_OPTIONS, ur as LabelSizeOptions, ut as DEFAULT_TURNING_MOVEMENT_OPTIONS, v as computeDefaultMidpointPerpendicularPoint, vn as DEFAULT_SUPPORTING_ATTACK_OPTIONS, vr as ControlMeasureMetadata, vt as AntitankWallOptions, w as BaselineFrameNormal, wn as AreaOfOperationsOptions, wr as GeneratedLabelKey, wt as DEFAULT_GUARD_OPTIONS, x as pointOnMidpointPerpendicularAxis, xn as MainAttackOptions, xr as AmplifierPlacement, xt as DEFAULT_ANTITANK_DITCH_OPTIONS, y as createMidpointPerpendicularDrawRule, yn as SupportingAttackOptions, yr as ParamDescriptor, yt as DEFAULT_ANTITANK_WALL_OPTIONS, z as cloneControlMeasure, zn as FinalProtectiveFireOptions, zt as DEFAULT_BREACH_OPTIONS } from "./index-C1NE59Nx.mjs";
|
|
2
|
+
export { type AirborneAttackOptions, type AmbushOptions, type AmplifierPlacement, type AmplifierPlacements, type AnchorTransformEvent, type AntitankDitchOptions, type AntitankWallOptions, type AreaDefenseOptions, type AreaOfOperationsOptions, type AssemblyAreaOptions, type AttackByFireOptions, type AttackHelicopterOptions, type BaselineFrame, type BaselineFrameNormal, type BaselineFrameOptions, type BaselineFrameOrigin, type BattleHandoverLineOptions, type BattlePositionOptions, type BlockArrowHeadStyle, type BlockArrowOptions, type BlockMissionTaskOptions, type BlockOptions, type BoundaryOptions, type BreachOptions, type BypassOptions, CONTROL_MEASURE_IDS, CONTROL_MEASURE_METADATA, type CanalizeOptions, type CanonicalTextAmplifiers, type ClassicArrowHeadStyle, type ClassicArrowOptions, type ClearOptions, type ControlMeasure, type ControlMeasureDrawRule, type ControlMeasureGeometry, type ControlMeasureGeometryType, type ControlMeasureId, type ControlMeasureKind, type ControlMeasureMetadata, type ControlMeasureRender, type ControlMeasureStyle, type CoverOptions, DEFAULT_AIRBORNE_ATTACK_OPTIONS, DEFAULT_AMBUSH_OPTIONS, DEFAULT_ANTITANK_DITCH_OPTIONS, DEFAULT_ANTITANK_WALL_OPTIONS, DEFAULT_AREA_DEFENSE_OPTIONS, DEFAULT_AREA_OF_OPERATIONS_OPTIONS, DEFAULT_ASSEMBLY_AREA_OPTIONS, DEFAULT_ATTACK_BY_FIRE_OPTIONS, DEFAULT_ATTACK_HELICOPTER_OPTIONS, DEFAULT_BATTLE_HANDOVER_LINE_OPTIONS, DEFAULT_BATTLE_POSITION_OPTIONS, DEFAULT_BLOCK_ARROW_OPTIONS, DEFAULT_BLOCK_MISSION_TASK_OPTIONS, DEFAULT_BLOCK_OPTIONS, DEFAULT_BOUNDARY_OPTIONS, DEFAULT_BREACH_OPTIONS, DEFAULT_BYPASS_OPTIONS, DEFAULT_CANALIZE_OPTIONS, DEFAULT_CLASSIC_ARROW_OPTIONS, DEFAULT_CLEAR_OPTIONS, DEFAULT_COVER_OPTIONS, DEFAULT_DELAY_OPTIONS, DEFAULT_DIRECTION_OF_ATTACK_AVIATION_OPTIONS, DEFAULT_DIRECTION_OF_MAIN_ATTACK_OPTIONS, DEFAULT_DIRECTION_OF_SUPPORTING_ATTACK_OPTIONS, DEFAULT_DISRUPT_OPTIONS, DEFAULT_ENCIRCLEMENT_OPTIONS, DEFAULT_ENGINEER_WORK_LINE_OPTIONS, DEFAULT_FINAL_PROTECTIVE_FIRE_OPTIONS, DEFAULT_FIX_OPTIONS, DEFAULT_FLOT_OPTIONS, DEFAULT_FORTIFIED_AREA_OPTIONS, DEFAULT_FORTIFIED_LINE_OPTIONS, DEFAULT_FRONTAL_ATTACK_OPTIONS, DEFAULT_GENERIC_C2_LINE_OPTIONS, DEFAULT_GENERIC_CIRCLE_OPTIONS, DEFAULT_GENERIC_LINE_OPTIONS, DEFAULT_GENERIC_POLYGON_OPTIONS, DEFAULT_GENERIC_RECTANGLE_OPTIONS, DEFAULT_GUARD_OPTIONS, DEFAULT_HANDOVER_LINE_OPTIONS, DEFAULT_JOINT_TACTICAL_ACTION_AREA_OPTIONS, DEFAULT_LANDING_ZONE_OPTIONS, DEFAULT_LIGHT_LINE_OPTIONS, DEFAULT_MAIN_ATTACK_OPTIONS, DEFAULT_OBSTACLE_BYPASS_DIFFICULT_OPTIONS, DEFAULT_OBSTACLE_BYPASS_EASY_OPTIONS, DEFAULT_OBSTACLE_BYPASS_IMPOSSIBLE_OPTIONS, DEFAULT_PHASE_LINE_OPTIONS, DEFAULT_PICKUP_ZONE_OPTIONS, DEFAULT_PRINCIPAL_DIRECTION_OF_FIRE_OPTIONS, DEFAULT_SCREEN_OPTIONS, DEFAULT_STRONG_POINT_OPTIONS, DEFAULT_SUPPORTING_ATTACK_OPTIONS, DEFAULT_SUPPORT_BY_FIRE_OPTIONS, DEFAULT_TACTICAL_ARROW_OPTIONS, DEFAULT_TURNING_MOVEMENT_OPTIONS, DEFAULT_TURN_OPTIONS, type DelayOptions, type DirectionOfAttackAviationOptions, type DirectionOfMainAttackOptions, type DirectionOfSupportingAttackOptions, type DisruptOptions, EPSILON, type EncirclementOptions, type EngineerWorkLineOptions, type FLOTOptions, type FeaturePartProps, type FillPattern, type FinalProtectiveFireOptions, type FixOptions, type FortifiedAreaOptions, type FortifiedLineOptions, type FrontalAttackOptions, type GeneratedLabelKey, type GenericC2LineOptions, type GenericCircleOptions, type GenericLineOptions, type GenericPolygonOptions, type GenericRectangleOptions, type GuardOptions, type HandoverLineOptions, type JointTacticalActionAreaOptions, type LabelPlacementOverride, type LabelSizeOptions, type LandingZoneOptions, type LightLineOptions, type MainAttackOptions, type MidpointPerpendicularDrawRuleOptions, type ObstacleBypassDifficultOptions, type ObstacleBypassEasyOptions, type ObstacleBypassImpossibleOptions, type OptionsByKind, type ParamDescriptor, type PhaseLineOptions, type PickupZoneOptions, type Point2D, type PrincipalDirectionOfFireOptions, type RenderOptions, type ScreenOptions, type SimpleStyleProps, type SimpleStyleRender, type StrongPointOptions, type StyleHints, type SupportByFireOptions, type SupportingAttackOptions, TEXT_AMPLIFIER_FIELDS, type TacticalArrowOptions, type TextAmplifierDescriptor, type TextAmplifierField, type TextAmplifierKey, type TextAmplifiers, type TurnOptions, type TurningMovementOptions, ambushDrawRule, attackByFireDrawRule, axis1DrawRule, blockDrawRule, calculateMetrics, canonicalTextAmplifierKey, centerRadiusDrawRule, cloneControlMeasure, computeDefaultMidpointPerpendicularPoint, computeInitialWidthPoint, controlMeasureIdFromFeature, createBaselineFrame, createMidpointPerpendicularDrawRule, disruptDrawRule, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureMetadataByValue, getDefaultOptions, getMetersPerPixel, getMidpointPerpendicularSignedDistance, isKind, line1DrawRule, line23DrawRule, line24DrawRule, line26DrawRule, listControlMeasureMetadata, normalizeTextAmplifiers, point12DrawRule, pointOnMidpointPerpendicularAxis, project, rectangleDrawRule, renderControlMeasure, resolveAmplifierPlacement, resolveStyleHints, roundToFixed, snapToMidpointPerpendicular, supportByFireDrawRule, toSimpleStyle, turnDrawRule, unproject };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as DEFAULT_BLOCK_ARROW_OPTIONS, A as DEFAULT_FLOT_OPTIONS, At as disruptDrawRule, B as DEFAULT_GENERIC_RECTANGLE_OPTIONS, Bt as project, C as DEFAULT_SCREEN_OPTIONS, Ct as line23DrawRule, D as DEFAULT_BATTLE_HANDOVER_LINE_OPTIONS, Dt as attackByFireDrawRule, E as DEFAULT_FORTIFIED_LINE_OPTIONS, Et as ambushDrawRule, F as DEFAULT_GUARD_OPTIONS, Ft as pointOnMidpointPerpendicularAxis, G as DEFAULT_CANALIZE_OPTIONS, H as DEFAULT_GENERIC_LINE_OPTIONS, Ht as EPSILON, I as DEFAULT_DELAY_OPTIONS, It as snapToMidpointPerpendicular, J as DEFAULT_BLOCK_MISSION_TASK_OPTIONS, K as DEFAULT_BYPASS_OPTIONS, L as DEFAULT_COVER_OPTIONS, Lt as createBaselineFrame, M as DEFAULT_FINAL_PROTECTIVE_FIRE_OPTIONS, Mt as computeDefaultMidpointPerpendicularPoint, N as DEFAULT_ENCIRCLEMENT_OPTIONS, Nt as createMidpointPerpendicularDrawRule, O as DEFAULT_HANDOVER_LINE_OPTIONS, Ot as point12DrawRule, P as DEFAULT_DISRUPT_OPTIONS, Pt as getMidpointPerpendicularSignedDistance, Q as DEFAULT_BOUNDARY_OPTIONS, R as DEFAULT_TACTICAL_ARROW_OPTIONS, Rt as calculateMetrics, S as DEFAULT_JOINT_TACTICAL_ACTION_AREA_OPTIONS, St as line24DrawRule, T as DEFAULT_FORTIFIED_AREA_OPTIONS, Tt as line1DrawRule, U as DEFAULT_GENERIC_CIRCLE_OPTIONS, Ut as getMetersPerPixel, V as DEFAULT_GENERIC_POLYGON_OPTIONS, Vt as unproject, W as DEFAULT_CLASSIC_ARROW_OPTIONS, Wt as roundToFixed, X as DEFAULT_ENGINEER_WORK_LINE_OPTIONS, Y as DEFAULT_GENERIC_C2_LINE_OPTIONS, Z as DEFAULT_LIGHT_LINE_OPTIONS, _ as DEFAULT_OBSTACLE_BYPASS_IMPOSSIBLE_OPTIONS, _t as DEFAULT_AIRBORNE_ATTACK_OPTIONS, a as DEFINITIONS, at as DEFAULT_ANTITANK_DITCH_OPTIONS, b as DEFAULT_MAIN_ATTACK_OPTIONS, bt as supportByFireDrawRule, c as getDefaultOptions, ct as DEFAULT_AREA_DEFENSE_OPTIONS, d as DEFAULT_TURN_OPTIONS, dt as normalizeTextAmplifiers, et as DEFAULT_BLOCK_OPTIONS, f as DEFAULT_SUPPORTING_ATTACK_OPTIONS, ft as resolveAmplifierPlacement, g as DEFAULT_PICKUP_ZONE_OPTIONS, gt as DEFAULT_AMBUSH_OPTIONS, h as DEFAULT_PRINCIPAL_DIRECTION_OF_FIRE_OPTIONS, ht as DEFAULT_DIRECTION_OF_ATTACK_AVIATION_OPTIONS, i as CONTROL_MEASURE_METADATA, it as DEFAULT_ANTITANK_WALL_OPTIONS, j as DEFAULT_FIX_OPTIONS, jt as blockDrawRule, k as DEFAULT_PHASE_LINE_OPTIONS, kt as centerRadiusDrawRule, l as listControlMeasureMetadata, lt as TEXT_AMPLIFIER_FIELDS, m as DEFAULT_STRONG_POINT_OPTIONS, mt as DEFAULT_DIRECTION_OF_MAIN_ATTACK_OPTIONS, n as resolveStyleHints, nt as DEFAULT_ATTACK_HELICOPTER_OPTIONS, o as getControlMeasureMetadata, ot as DEFAULT_ASSEMBLY_AREA_OPTIONS, p as DEFAULT_SUPPORT_BY_FIRE_OPTIONS, pt as DEFAULT_DIRECTION_OF_SUPPORTING_ATTACK_OPTIONS, q as DEFAULT_BREACH_OPTIONS, r as CONTROL_MEASURE_IDS, rt as DEFAULT_ATTACK_BY_FIRE_OPTIONS, s as getControlMeasureMetadataByValue, st as DEFAULT_AREA_OF_OPERATIONS_OPTIONS, t as renderControlMeasure, tt as DEFAULT_BATTLE_POSITION_OPTIONS, u as DEFAULT_TURNING_MOVEMENT_OPTIONS, ut as canonicalTextAmplifierKey, v as DEFAULT_OBSTACLE_BYPASS_EASY_OPTIONS, vt as rectangleDrawRule, w as DEFAULT_FRONTAL_ATTACK_OPTIONS, wt as turnDrawRule, x as DEFAULT_LANDING_ZONE_OPTIONS, xt as line26DrawRule, y as DEFAULT_OBSTACLE_BYPASS_DIFFICULT_OPTIONS, yt as axis1DrawRule, z as DEFAULT_CLEAR_OPTIONS, zt as computeInitialWidthPoint } from "./renderControlMeasure-DURyfLXo.mjs";
|
|
2
|
+
//#region src/freeze-orientation.ts
|
|
3
|
+
/**
|
|
4
|
+
* Dispatches to a measure kind's `freezeOrientation` hook (see
|
|
5
|
+
* {@link import("./define").ControlMeasureDefinition.freezeOrientation}),
|
|
6
|
+
* pinning orientation-derived option defaults to their current concrete
|
|
7
|
+
* values ahead of a rigid rotation of `controlPoints`. Returns `undefined`
|
|
8
|
+
* when the kind declares no hook, or when the hook itself finds nothing to
|
|
9
|
+
* freeze. Edit hosts call this when a rotate gesture starts (ADR-0023).
|
|
10
|
+
*/
|
|
11
|
+
function freezeOrientationOptions(kind, controlPoints, options) {
|
|
12
|
+
const definition = DEFINITIONS[kind];
|
|
13
|
+
if (!definition.freezeOrientation) return void 0;
|
|
14
|
+
return definition.freezeOrientation(controlPoints, options ?? {});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
2
17
|
//#region src/instance.ts
|
|
3
18
|
function isKind(cm, kind) {
|
|
4
19
|
return cm.kind === kind;
|
|
@@ -6,10 +21,10 @@ function isKind(cm, kind) {
|
|
|
6
21
|
/**
|
|
7
22
|
* Deep-clone a `ControlMeasure` so held references survive mutations to the
|
|
8
23
|
* original (and vice versa). Used by the session façade to build the
|
|
9
|
-
* `
|
|
10
|
-
* `options`, `style`, and `
|
|
11
|
-
* `Record<string, unknown>` and may carry arbitrary host
|
|
12
|
-
* shallow copy would leak shared references.
|
|
24
|
+
* `graphic` half of TacticalDraw's `GraphicSnapshot`. Nested values inside
|
|
25
|
+
* `options`, `style`, `properties`, and `textAmplifiers` are cloned too —
|
|
26
|
+
* `properties` is `Record<string, unknown>` and may carry arbitrary host
|
|
27
|
+
* metadata, so a shallow copy would leak shared references.
|
|
13
28
|
*
|
|
14
29
|
* Backed by `structuredClone`: only structured-cloneable values are
|
|
15
30
|
* supported (no functions, DOM nodes, class instances). Absent optional
|
|
@@ -42,8 +57,9 @@ function controlMeasureIdFromFeature(feature) {
|
|
|
42
57
|
* three-layer merge and stays a pure post-processing step.
|
|
43
58
|
*
|
|
44
59
|
* Lossy mapping, by design:
|
|
45
|
-
* - `strokeDash`
|
|
46
|
-
*
|
|
60
|
+
* - `strokeDash` and `fillPattern` have no simplestyle equivalent and are
|
|
61
|
+
* dropped — dashed sub-lines and patterned fills render solid in
|
|
62
|
+
* simplestyle consumers.
|
|
47
63
|
* - colors must be hex or `rgb()/rgba()`; alpha becomes `*-opacity`. Other
|
|
48
64
|
* color forms (named, `hsl()`) are omitted rather than guessed.
|
|
49
65
|
*/
|
|
@@ -99,4 +115,4 @@ function toHexChannel(value) {
|
|
|
99
115
|
return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
100
116
|
}
|
|
101
117
|
//#endregion
|
|
102
|
-
export { CONTROL_MEASURE_IDS, CONTROL_MEASURE_METADATA, DEFAULT_AIRBORNE_ATTACK_OPTIONS, DEFAULT_AMBUSH_OPTIONS, DEFAULT_ANTITANK_DITCH_OPTIONS, DEFAULT_ANTITANK_WALL_OPTIONS, DEFAULT_ATTACK_BY_FIRE_OPTIONS, DEFAULT_ATTACK_HELICOPTER_OPTIONS, DEFAULT_BLOCK_MISSION_TASK_OPTIONS, DEFAULT_BLOCK_OPTIONS, DEFAULT_BREACH_OPTIONS, DEFAULT_BYPASS_OPTIONS, DEFAULT_CANALIZE_OPTIONS, DEFAULT_CLEAR_OPTIONS, DEFAULT_DELAY_OPTIONS, DEFAULT_DISRUPT_OPTIONS, DEFAULT_FINAL_PROTECTIVE_FIRE_OPTIONS, DEFAULT_FIX_OPTIONS, DEFAULT_FLOT_OPTIONS, DEFAULT_FORTIFIED_AREA_OPTIONS, DEFAULT_FORTIFIED_LINE_OPTIONS, DEFAULT_MAIN_ATTACK_OPTIONS, DEFAULT_OBSTACLE_BYPASS_DIFFICULT_OPTIONS, DEFAULT_OBSTACLE_BYPASS_EASY_OPTIONS, DEFAULT_OBSTACLE_BYPASS_IMPOSSIBLE_OPTIONS, DEFAULT_PRINCIPAL_DIRECTION_OF_FIRE_OPTIONS, DEFAULT_SUPPORTING_ATTACK_OPTIONS, DEFAULT_SUPPORT_BY_FIRE_OPTIONS, DEFAULT_TACTICAL_ARROW_OPTIONS, DEFAULT_TURN_OPTIONS, EPSILON, ambushDrawRule, attackByFireDrawRule, axis1DrawRule, blockDrawRule, calculateMetrics, cloneControlMeasure, computeDefaultMidpointPerpendicularPoint, computeInitialWidthPoint, controlMeasureIdFromFeature, createBaselineFrame, createMidpointPerpendicularDrawRule, disruptDrawRule, getControlMeasureMetadata, getControlMeasureMetadataByValue, getDefaultOptions, getMetersPerPixel, getMidpointPerpendicularSignedDistance, isKind, line1DrawRule, line23DrawRule, line24DrawRule, listControlMeasureMetadata, point12DrawRule, pointOnMidpointPerpendicularAxis, project, renderControlMeasure, resolveStyleHints, roundToFixed, snapToMidpointPerpendicular, supportByFireDrawRule, toSimpleStyle, turnDrawRule, unproject };
|
|
118
|
+
export { CONTROL_MEASURE_IDS, CONTROL_MEASURE_METADATA, DEFAULT_AIRBORNE_ATTACK_OPTIONS, DEFAULT_AMBUSH_OPTIONS, DEFAULT_ANTITANK_DITCH_OPTIONS, DEFAULT_ANTITANK_WALL_OPTIONS, DEFAULT_AREA_DEFENSE_OPTIONS, DEFAULT_AREA_OF_OPERATIONS_OPTIONS, DEFAULT_ASSEMBLY_AREA_OPTIONS, DEFAULT_ATTACK_BY_FIRE_OPTIONS, DEFAULT_ATTACK_HELICOPTER_OPTIONS, DEFAULT_BATTLE_HANDOVER_LINE_OPTIONS, DEFAULT_BATTLE_POSITION_OPTIONS, DEFAULT_BLOCK_ARROW_OPTIONS, DEFAULT_BLOCK_MISSION_TASK_OPTIONS, DEFAULT_BLOCK_OPTIONS, DEFAULT_BOUNDARY_OPTIONS, DEFAULT_BREACH_OPTIONS, DEFAULT_BYPASS_OPTIONS, DEFAULT_CANALIZE_OPTIONS, DEFAULT_CLASSIC_ARROW_OPTIONS, DEFAULT_CLEAR_OPTIONS, DEFAULT_COVER_OPTIONS, DEFAULT_DELAY_OPTIONS, DEFAULT_DIRECTION_OF_ATTACK_AVIATION_OPTIONS, DEFAULT_DIRECTION_OF_MAIN_ATTACK_OPTIONS, DEFAULT_DIRECTION_OF_SUPPORTING_ATTACK_OPTIONS, DEFAULT_DISRUPT_OPTIONS, DEFAULT_ENCIRCLEMENT_OPTIONS, DEFAULT_ENGINEER_WORK_LINE_OPTIONS, DEFAULT_FINAL_PROTECTIVE_FIRE_OPTIONS, DEFAULT_FIX_OPTIONS, DEFAULT_FLOT_OPTIONS, DEFAULT_FORTIFIED_AREA_OPTIONS, DEFAULT_FORTIFIED_LINE_OPTIONS, DEFAULT_FRONTAL_ATTACK_OPTIONS, DEFAULT_GENERIC_C2_LINE_OPTIONS, DEFAULT_GENERIC_CIRCLE_OPTIONS, DEFAULT_GENERIC_LINE_OPTIONS, DEFAULT_GENERIC_POLYGON_OPTIONS, DEFAULT_GENERIC_RECTANGLE_OPTIONS, DEFAULT_GUARD_OPTIONS, DEFAULT_HANDOVER_LINE_OPTIONS, DEFAULT_JOINT_TACTICAL_ACTION_AREA_OPTIONS, DEFAULT_LANDING_ZONE_OPTIONS, DEFAULT_LIGHT_LINE_OPTIONS, DEFAULT_MAIN_ATTACK_OPTIONS, DEFAULT_OBSTACLE_BYPASS_DIFFICULT_OPTIONS, DEFAULT_OBSTACLE_BYPASS_EASY_OPTIONS, DEFAULT_OBSTACLE_BYPASS_IMPOSSIBLE_OPTIONS, DEFAULT_PHASE_LINE_OPTIONS, DEFAULT_PICKUP_ZONE_OPTIONS, DEFAULT_PRINCIPAL_DIRECTION_OF_FIRE_OPTIONS, DEFAULT_SCREEN_OPTIONS, DEFAULT_STRONG_POINT_OPTIONS, DEFAULT_SUPPORTING_ATTACK_OPTIONS, DEFAULT_SUPPORT_BY_FIRE_OPTIONS, DEFAULT_TACTICAL_ARROW_OPTIONS, DEFAULT_TURNING_MOVEMENT_OPTIONS, DEFAULT_TURN_OPTIONS, EPSILON, TEXT_AMPLIFIER_FIELDS, ambushDrawRule, attackByFireDrawRule, axis1DrawRule, blockDrawRule, calculateMetrics, canonicalTextAmplifierKey, centerRadiusDrawRule, cloneControlMeasure, computeDefaultMidpointPerpendicularPoint, computeInitialWidthPoint, controlMeasureIdFromFeature, createBaselineFrame, createMidpointPerpendicularDrawRule, disruptDrawRule, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureMetadataByValue, getDefaultOptions, getMetersPerPixel, getMidpointPerpendicularSignedDistance, isKind, line1DrawRule, line23DrawRule, line24DrawRule, line26DrawRule, listControlMeasureMetadata, normalizeTextAmplifiers, point12DrawRule, pointOnMidpointPerpendicularAxis, project, rectangleDrawRule, renderControlMeasure, resolveAmplifierPlacement, resolveStyleHints, roundToFixed, snapToMidpointPerpendicular, supportByFireDrawRule, toSimpleStyle, turnDrawRule, unproject };
|
package/dist/preview/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as ControlMeasureId, kr as TextAmplifiers } from "../index-C1NE59Nx.mjs";
|
|
2
2
|
import { FeatureCollection, Geometry } from "geojson";
|
|
3
3
|
|
|
4
4
|
//#region src/preview/index.d.ts
|
|
@@ -7,8 +7,16 @@ import { FeatureCollection, Geometry } from "geojson";
|
|
|
7
7
|
* so it runs identically at build time (docs catalog, README generator) and in
|
|
8
8
|
* the browser (preview app). Returns an empty collection if the generator
|
|
9
9
|
* throws, so a single broken measure never breaks a whole gallery.
|
|
10
|
+
*
|
|
11
|
+
* `overrides.textAmplifiers` and `overrides.options` are each merged over the
|
|
12
|
+
* sample's own amplifiers/options (override wins per key, sample-only keys
|
|
13
|
+
* survive) — used by the params panel's placement preview to substitute
|
|
14
|
+
* placeholder values (`<T>`, `<N>`, …) for whatever the sample carries.
|
|
10
15
|
*/
|
|
11
|
-
declare function renderRepresentative(id: ControlMeasureId
|
|
16
|
+
declare function renderRepresentative(id: ControlMeasureId, overrides?: {
|
|
17
|
+
textAmplifiers?: TextAmplifiers;
|
|
18
|
+
options?: Record<string, unknown>;
|
|
19
|
+
}): FeatureCollection<Geometry, unknown>;
|
|
12
20
|
/** A styling-free preview primitive. Consumers supply stroke, radius, font,
|
|
13
21
|
* and colors when they draw it. */
|
|
14
22
|
interface PreviewShape {
|
|
@@ -24,6 +32,22 @@ interface PreviewShape {
|
|
|
24
32
|
text?: string;
|
|
25
33
|
/** Generator-frame rotation (radians) for `text`. */
|
|
26
34
|
rotation?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Text height in the same SVG units as `d`/`cx`/`cy`, derived from the
|
|
37
|
+
* source label's ground-anchored `textSizeMeters` (ADR-0028) scaled through
|
|
38
|
+
* the fit into the viewBox, then clamped so a long string can't exceed ~40%
|
|
39
|
+
* of the viewBox width. Present only when the label carried real
|
|
40
|
+
* ground-anchored sizing; a fixed glyph with no sizing (e.g. breach's "B",
|
|
41
|
+
* or Boundary's echelon-only sample) or a screen-anchored label (bare
|
|
42
|
+
* `textSizePixels`, unresolvable to a ground size without a live map
|
|
43
|
+
* resolution) leaves this `undefined` — a consumer should fall back to its
|
|
44
|
+
* own fixed font size, matching behavior from before this field existed.
|
|
45
|
+
*/
|
|
46
|
+
heightPx?: number;
|
|
47
|
+
/** Horizontal alignment relative to (`cx`, `cy`), mirroring the label
|
|
48
|
+
* feature's `textAnchor` — `"start"`/`"end"` anchor the text at the point
|
|
49
|
+
* instead of centering it. Undefined = centered. */
|
|
50
|
+
textAnchor?: "start" | "end";
|
|
27
51
|
}
|
|
28
52
|
/** Target viewBox the geometry is fit into. */
|
|
29
53
|
interface ProjectDimensions {
|
|
@@ -41,5 +65,51 @@ declare function projectRenderToShapes(fc: FeatureCollection<Geometry, unknown>,
|
|
|
41
65
|
shapes: PreviewShape[];
|
|
42
66
|
ok: boolean;
|
|
43
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Grows a viewBox to include every `text` shape's estimated on-screen box —
|
|
70
|
+
* {@link projectRenderToShapes} fits geometry coordinates only, so an
|
|
71
|
+
* anchor-aware label (e.g. a phase line's end-anchored "PL ECHO") can extend
|
|
72
|
+
* well past the plain `0 0 width height` viewBox. Consumers should build
|
|
73
|
+
* their SVG `viewBox` from this instead.
|
|
74
|
+
*
|
|
75
|
+
* For each text shape (skipping shapes without `cx`/`cy`), estimates a box
|
|
76
|
+
* from its glyph count (`CHAR_WIDTH_RATIO` × `fontSize`) and `fontSize`
|
|
77
|
+
* itself, placed per `textAnchor` horizontally and centered on `cy`
|
|
78
|
+
* vertically (SVG text uses `dominant-baseline="central"`), rotates its
|
|
79
|
+
* corners around `(cx, cy)` by the same angle the SVG transform applies
|
|
80
|
+
* (`renderedAngle = PI - rotation`, negated for SVG's y-down axis — see
|
|
81
|
+
* {@link svgTextTransform}; labels commonly carry `rotation = PI`,
|
|
82
|
+
* which renders flat, so an undefined rotation must not be treated as
|
|
83
|
+
* rotated), and unions the result with the base `[0, 0, width, height]` box.
|
|
84
|
+
*
|
|
85
|
+
* `fontSize` is supplied by the caller since each gallery picks its own
|
|
86
|
+
* fallback/cap for `heightPx`.
|
|
87
|
+
*/
|
|
88
|
+
declare function viewBoxWithLabels(shapes: PreviewShape[], dims: {
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
}, fontSize: (s: PreviewShape) => number): {
|
|
92
|
+
minX: number;
|
|
93
|
+
minY: number;
|
|
94
|
+
width: number;
|
|
95
|
+
height: number;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The SVG `viewBox` string for a preview, grown to include every label's
|
|
99
|
+
* on-screen box (see {@link viewBoxWithLabels}). The convenience every Vue
|
|
100
|
+
* consumer wants — they only ever format the box into this exact string.
|
|
101
|
+
*/
|
|
102
|
+
declare function viewBoxString(shapes: PreviewShape[], dims: {
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
}, fontSize: (s: PreviewShape) => number): string;
|
|
106
|
+
/**
|
|
107
|
+
* The SVG `transform` attribute that rotates a `text` shape into place, or
|
|
108
|
+
* `undefined` for an unrotated/incomplete shape. Text rotations use the same
|
|
109
|
+
* generator convention as the map adapters (`renderedAngle = PI - rotation`);
|
|
110
|
+
* SVG's y-axis points down, so the angle is negated. Shared by every SVG
|
|
111
|
+
* preview consumer (sidebar gallery, docs catalog, README generator).
|
|
112
|
+
*/
|
|
113
|
+
declare function svgTextTransform(s: PreviewShape): string | undefined;
|
|
44
114
|
//#endregion
|
|
45
|
-
export { PreviewShape, ProjectDimensions, projectRenderToShapes, renderRepresentative };
|
|
115
|
+
export { PreviewShape, ProjectDimensions, projectRenderToShapes, renderRepresentative, svgTextTransform, viewBoxString, viewBoxWithLabels };
|
package/dist/preview/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DEFINITIONS, t as renderControlMeasure } from "../renderControlMeasure-
|
|
1
|
+
import { a as DEFINITIONS, t as renderControlMeasure } from "../renderControlMeasure-DURyfLXo.mjs";
|
|
2
2
|
//#region src/preview/index.ts
|
|
3
3
|
/**
|
|
4
4
|
* Unitless `previewSample` points (~`[-1, 1]`) are scaled by this degree offset
|
|
@@ -47,25 +47,39 @@ function representativeSample(id) {
|
|
|
47
47
|
const sample = definition.previewSample;
|
|
48
48
|
const controlPoints = (sample ? sample.controlPoints : fallbackControlPoints(definition.metadata)).map(([x, y]) => [x * D, y * D]);
|
|
49
49
|
const options = sample?.options;
|
|
50
|
-
|
|
50
|
+
const textAmplifiers = sample?.textAmplifiers;
|
|
51
|
+
return {
|
|
51
52
|
controlPoints,
|
|
52
|
-
options
|
|
53
|
-
|
|
53
|
+
...options ? { options } : {},
|
|
54
|
+
...textAmplifiers ? { textAmplifiers } : {}
|
|
55
|
+
};
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Renders a measure's representative preview to GeoJSON. Pure — no map engine,
|
|
57
59
|
* so it runs identically at build time (docs catalog, README generator) and in
|
|
58
60
|
* the browser (preview app). Returns an empty collection if the generator
|
|
59
61
|
* throws, so a single broken measure never breaks a whole gallery.
|
|
62
|
+
*
|
|
63
|
+
* `overrides.textAmplifiers` and `overrides.options` are each merged over the
|
|
64
|
+
* sample's own amplifiers/options (override wins per key, sample-only keys
|
|
65
|
+
* survive) — used by the params panel's placement preview to substitute
|
|
66
|
+
* placeholder values (`<T>`, `<N>`, …) for whatever the sample carries.
|
|
60
67
|
*/
|
|
61
|
-
function renderRepresentative(id) {
|
|
68
|
+
function renderRepresentative(id, overrides) {
|
|
62
69
|
try {
|
|
63
|
-
const { controlPoints, options } = representativeSample(id);
|
|
70
|
+
const { controlPoints, options, textAmplifiers } = representativeSample(id);
|
|
64
71
|
return renderControlMeasure({
|
|
65
72
|
id: "preview",
|
|
66
73
|
kind: id,
|
|
67
74
|
controlPoints,
|
|
68
|
-
|
|
75
|
+
options: {
|
|
76
|
+
...options,
|
|
77
|
+
...overrides?.options
|
|
78
|
+
},
|
|
79
|
+
textAmplifiers: {
|
|
80
|
+
...textAmplifiers,
|
|
81
|
+
...overrides?.textAmplifiers
|
|
82
|
+
}
|
|
69
83
|
});
|
|
70
84
|
} catch {
|
|
71
85
|
return {
|
|
@@ -103,12 +117,147 @@ function projectRenderToShapes(fc, dims) {
|
|
|
103
117
|
const tx = (p) => [offsetX + (p[0] - minX) * scale, offsetY + (maxY - p[1]) * scale];
|
|
104
118
|
const shapes = [];
|
|
105
119
|
const bboxArea = spanX * spanY;
|
|
106
|
-
|
|
120
|
+
const textLimits = {
|
|
121
|
+
scale,
|
|
122
|
+
maxWidthPx: dims.width * MAX_TEXT_WIDTH_RATIO,
|
|
123
|
+
maxHeightPx: dims.height * MAX_TEXT_HEIGHT_RATIO
|
|
124
|
+
};
|
|
125
|
+
for (const f of fc.features) collectShapes(f.geometry, tx, shapes, bboxArea, textLimits, f.properties);
|
|
107
126
|
return {
|
|
108
127
|
shapes,
|
|
109
128
|
ok: shapes.length > 0
|
|
110
129
|
};
|
|
111
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Meters per degree of latitude, converting a label's ground-meter height
|
|
133
|
+
* (`textSizeMeters`, ADR-0028) into the lon/lat degree frame the render was
|
|
134
|
+
* fit in. Preview samples sit near the origin (see `D`), where this holds for
|
|
135
|
+
* both axes. Without it the raw height overshoots by ~5 orders of magnitude,
|
|
136
|
+
* pinning every label to the width/height caps — larger than its geometric
|
|
137
|
+
* footprint, swallowing the clearance the generator baked in between line and
|
|
138
|
+
* label.
|
|
139
|
+
*/
|
|
140
|
+
const METERS_PER_DEGREE = 111320;
|
|
141
|
+
/** Rough average glyph width, as a ratio of height, for a bold sans-serif
|
|
142
|
+
* label — used only to estimate whether a string will overflow the viewBox,
|
|
143
|
+
* not to lay out real text. */
|
|
144
|
+
const CHAR_WIDTH_RATIO = .62;
|
|
145
|
+
/**
|
|
146
|
+
* Glyph-width ratio for {@link viewBoxWithLabels}' extent boxes. Deliberately
|
|
147
|
+
* wider than {@link CHAR_WIDTH_RATIO}: the average slightly undershoots bold
|
|
148
|
+
* uppercase strings ("PL ECHO"), and an extent estimate that undershoots crops
|
|
149
|
+
* the label edge while one that overshoots only costs a little slack.
|
|
150
|
+
*/
|
|
151
|
+
const EXTENT_CHAR_WIDTH_RATIO = .75;
|
|
152
|
+
/** A text shape may not claim more than this fraction of the viewBox width;
|
|
153
|
+
* longer strings shrink their `heightPx` to fit. */
|
|
154
|
+
const MAX_TEXT_WIDTH_RATIO = .4;
|
|
155
|
+
/**
|
|
156
|
+
* A text shape may not claim more than this fraction of the viewBox height —
|
|
157
|
+
* guards short strings (e.g. "LL", "BHL") whose ground-anchored size would
|
|
158
|
+
* otherwise fit the width cap easily but still tower over the sample line. The
|
|
159
|
+
* preview samples sit near the origin (see `D`), so the fit `scale` is large
|
|
160
|
+
* and a real-sized label's `raw` height overshoots this cap almost every time;
|
|
161
|
+
* the cap, not the ground size, is what sets the on-screen height. Kept well
|
|
162
|
+
* below the fixed glyph fallback so labels read as annotations on the line
|
|
163
|
+
* rather than dominating a 96×48 thumbnail.
|
|
164
|
+
*/
|
|
165
|
+
const MAX_TEXT_HEIGHT_RATIO = .16;
|
|
166
|
+
/**
|
|
167
|
+
* Grows a viewBox to include every `text` shape's estimated on-screen box —
|
|
168
|
+
* {@link projectRenderToShapes} fits geometry coordinates only, so an
|
|
169
|
+
* anchor-aware label (e.g. a phase line's end-anchored "PL ECHO") can extend
|
|
170
|
+
* well past the plain `0 0 width height` viewBox. Consumers should build
|
|
171
|
+
* their SVG `viewBox` from this instead.
|
|
172
|
+
*
|
|
173
|
+
* For each text shape (skipping shapes without `cx`/`cy`), estimates a box
|
|
174
|
+
* from its glyph count (`CHAR_WIDTH_RATIO` × `fontSize`) and `fontSize`
|
|
175
|
+
* itself, placed per `textAnchor` horizontally and centered on `cy`
|
|
176
|
+
* vertically (SVG text uses `dominant-baseline="central"`), rotates its
|
|
177
|
+
* corners around `(cx, cy)` by the same angle the SVG transform applies
|
|
178
|
+
* (`renderedAngle = PI - rotation`, negated for SVG's y-down axis — see
|
|
179
|
+
* {@link svgTextTransform}; labels commonly carry `rotation = PI`,
|
|
180
|
+
* which renders flat, so an undefined rotation must not be treated as
|
|
181
|
+
* rotated), and unions the result with the base `[0, 0, width, height]` box.
|
|
182
|
+
*
|
|
183
|
+
* `fontSize` is supplied by the caller since each gallery picks its own
|
|
184
|
+
* fallback/cap for `heightPx`.
|
|
185
|
+
*/
|
|
186
|
+
function viewBoxWithLabels(shapes, dims, fontSize) {
|
|
187
|
+
let minX = 0;
|
|
188
|
+
let minY = 0;
|
|
189
|
+
let maxX = dims.width;
|
|
190
|
+
let maxY = dims.height;
|
|
191
|
+
for (const s of shapes) {
|
|
192
|
+
if (s.type !== "text" || s.cx === void 0 || s.cy === void 0) continue;
|
|
193
|
+
const font = fontSize(s);
|
|
194
|
+
const w = (s.text?.length ?? 0) * EXTENT_CHAR_WIDTH_RATIO * font;
|
|
195
|
+
const h = font;
|
|
196
|
+
const left = s.textAnchor === "start" ? s.cx : s.textAnchor === "end" ? s.cx - w : s.cx - w / 2;
|
|
197
|
+
const right = left + w;
|
|
198
|
+
const top = s.cy - h / 2;
|
|
199
|
+
const bottom = s.cy + h / 2;
|
|
200
|
+
const theta = s.rotation === void 0 ? 0 : -(Math.PI - s.rotation);
|
|
201
|
+
const cos = Math.cos(theta);
|
|
202
|
+
const sin = Math.sin(theta);
|
|
203
|
+
for (const [x, y] of [
|
|
204
|
+
[left, top],
|
|
205
|
+
[right, top],
|
|
206
|
+
[right, bottom],
|
|
207
|
+
[left, bottom]
|
|
208
|
+
]) {
|
|
209
|
+
const rx = s.cx + (x - s.cx) * cos - (y - s.cy) * sin;
|
|
210
|
+
const ry = s.cy + (x - s.cx) * sin + (y - s.cy) * cos;
|
|
211
|
+
if (rx < minX) minX = rx;
|
|
212
|
+
if (rx > maxX) maxX = rx;
|
|
213
|
+
if (ry < minY) minY = ry;
|
|
214
|
+
if (ry > maxY) maxY = ry;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
minX,
|
|
219
|
+
minY,
|
|
220
|
+
width: maxX - minX,
|
|
221
|
+
height: maxY - minY
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The SVG `viewBox` string for a preview, grown to include every label's
|
|
226
|
+
* on-screen box (see {@link viewBoxWithLabels}). The convenience every Vue
|
|
227
|
+
* consumer wants — they only ever format the box into this exact string.
|
|
228
|
+
*/
|
|
229
|
+
function viewBoxString(shapes, dims, fontSize) {
|
|
230
|
+
const box = viewBoxWithLabels(shapes, dims, fontSize);
|
|
231
|
+
return `${box.minX} ${box.minY} ${box.width} ${box.height}`;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The SVG `transform` attribute that rotates a `text` shape into place, or
|
|
235
|
+
* `undefined` for an unrotated/incomplete shape. Text rotations use the same
|
|
236
|
+
* generator convention as the map adapters (`renderedAngle = PI - rotation`);
|
|
237
|
+
* SVG's y-axis points down, so the angle is negated. Shared by every SVG
|
|
238
|
+
* preview consumer (sidebar gallery, docs catalog, README generator).
|
|
239
|
+
*/
|
|
240
|
+
function svgTextTransform(s) {
|
|
241
|
+
if (s.rotation === void 0 || s.cx === void 0 || s.cy === void 0) return void 0;
|
|
242
|
+
return `rotate(${(-((Math.PI - s.rotation) * 180) / Math.PI).toFixed(3)} ${s.cx.toFixed(3)} ${s.cy.toFixed(3)})`;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Resolves a label's SVG-unit text height from its `textSizeMeters` property
|
|
246
|
+
* (ADR-0028's ground anchor), scaled by the same `scale` the geometry was fit
|
|
247
|
+
* with, then clamped by both the height cap and the width the string would
|
|
248
|
+
* occupy at that height (so a long string can't overflow `maxWidthPx`).
|
|
249
|
+
* Returns `undefined` when the label carries no ground-anchored sizing — a
|
|
250
|
+
* screen-anchored label (bare `textSizePixels`, meaningless without a live map
|
|
251
|
+
* resolution to convert it) or one with no size at all — and the caller
|
|
252
|
+
* leaves `heightPx` unset.
|
|
253
|
+
*/
|
|
254
|
+
function resolveTextHeightPx(labelProps, text, limits) {
|
|
255
|
+
const sizeMeters = labelProps.textSizeMeters;
|
|
256
|
+
if (typeof sizeMeters !== "number") return void 0;
|
|
257
|
+
const raw = sizeMeters * limits.scale / METERS_PER_DEGREE;
|
|
258
|
+
const widthLimit = text.length > 0 ? limits.maxWidthPx / (text.length * CHAR_WIDTH_RATIO) : Infinity;
|
|
259
|
+
return Math.min(raw, limits.maxHeightPx, widthLimit);
|
|
260
|
+
}
|
|
112
261
|
function ringArea(ring) {
|
|
113
262
|
let a = 0;
|
|
114
263
|
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) a += (ring[j][0] - ring[i][0]) * (ring[j][1] + ring[i][1]);
|
|
@@ -144,22 +293,27 @@ function pathFromRing(ring, tx, close) {
|
|
|
144
293
|
if (close) parts.push("Z");
|
|
145
294
|
return parts.join(" ");
|
|
146
295
|
}
|
|
147
|
-
function collectShapes(g, tx, out, bboxArea, props) {
|
|
296
|
+
function collectShapes(g, tx, out, bboxArea, textLimits, props) {
|
|
148
297
|
const labelProps = props && typeof props === "object" ? props : {};
|
|
149
298
|
const labelText = typeof labelProps.text === "string" ? labelProps.text : void 0;
|
|
150
299
|
const labelRotation = typeof labelProps.rotation === "number" ? labelProps.rotation : void 0;
|
|
300
|
+
const labelAnchor = labelProps.textAnchor === "start" || labelProps.textAnchor === "end" ? labelProps.textAnchor : void 0;
|
|
151
301
|
const polygonFilled = (ring) => bboxArea > 0 && ringArea(ring) / bboxArea < .25;
|
|
152
302
|
switch (g.type) {
|
|
153
303
|
case "Point": {
|
|
154
304
|
const [x, y] = tx(g.coordinates);
|
|
155
|
-
if (labelText !== void 0)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
305
|
+
if (labelText !== void 0) {
|
|
306
|
+
const heightPx = resolveTextHeightPx(labelProps, labelText, textLimits);
|
|
307
|
+
out.push({
|
|
308
|
+
type: "text",
|
|
309
|
+
cx: x,
|
|
310
|
+
cy: y,
|
|
311
|
+
text: labelText,
|
|
312
|
+
rotation: labelRotation,
|
|
313
|
+
heightPx,
|
|
314
|
+
textAnchor: labelAnchor
|
|
315
|
+
});
|
|
316
|
+
} else out.push({
|
|
163
317
|
type: "circle",
|
|
164
318
|
cx: x,
|
|
165
319
|
cy: y
|
|
@@ -203,9 +357,9 @@ function collectShapes(g, tx, out, bboxArea, props) {
|
|
|
203
357
|
})));
|
|
204
358
|
break;
|
|
205
359
|
case "GeometryCollection":
|
|
206
|
-
g.geometries.forEach((sub) => collectShapes(sub, tx, out, bboxArea, props));
|
|
360
|
+
g.geometries.forEach((sub) => collectShapes(sub, tx, out, bboxArea, textLimits, props));
|
|
207
361
|
break;
|
|
208
362
|
}
|
|
209
363
|
}
|
|
210
364
|
//#endregion
|
|
211
|
-
export { projectRenderToShapes, renderRepresentative };
|
|
365
|
+
export { projectRenderToShapes, renderRepresentative, svgTextTransform, viewBoxString, viewBoxWithLabels };
|