@orbat-mapper/control-measures 0.2.0-alpha.1 → 0.2.0-alpha.11

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.
Files changed (60) hide show
  1. package/README.md +16 -3
  2. package/dist/index-C6nqkw1A.d.mts +2552 -0
  3. package/dist/index.d.mts +2 -1441
  4. package/dist/index.mjs +16 -5516
  5. package/dist/preview/index.d.mts +115 -0
  6. package/dist/preview/index.mjs +365 -0
  7. package/dist/renderControlMeasure-NKEYq3Fg.mjs +9799 -0
  8. package/media/airborne-attack.svg +1 -1
  9. package/media/ambush.svg +1 -1
  10. package/media/antitank-ditch-completed.svg +1 -1
  11. package/media/antitank-ditch-under-construction.svg +1 -1
  12. package/media/antitank-wall.svg +1 -1
  13. package/media/area-of-operations.svg +1 -0
  14. package/media/assembly-area.svg +1 -0
  15. package/media/attack-by-fire.svg +1 -1
  16. package/media/attack-helicopter.svg +1 -1
  17. package/media/battle-handover-line.svg +1 -0
  18. package/media/battle-position.svg +1 -0
  19. package/media/block-arrow.svg +1 -1
  20. package/media/block-mission-task.svg +1 -1
  21. package/media/block.svg +1 -1
  22. package/media/boundary.svg +1 -0
  23. package/media/breach.svg +1 -1
  24. package/media/bypass.svg +1 -1
  25. package/media/canalize.svg +1 -1
  26. package/media/circle.svg +1 -0
  27. package/media/classic-arrow.svg +1 -1
  28. package/media/clear.svg +1 -1
  29. package/media/delay.svg +1 -1
  30. package/media/disrupt.svg +1 -1
  31. package/media/encirclement.svg +1 -0
  32. package/media/engineer-work-line.svg +1 -0
  33. package/media/final-protective-fire-left.svg +1 -1
  34. package/media/final-protective-fire-right.svg +1 -1
  35. package/media/fix.svg +1 -1
  36. package/media/flot.svg +1 -1
  37. package/media/fortified-area.svg +1 -1
  38. package/media/fortified-line.svg +1 -1
  39. package/media/generic-c2-line.svg +1 -0
  40. package/media/handover-line.svg +1 -0
  41. package/media/isolate.svg +1 -1
  42. package/media/joint-tactical-action-area.svg +1 -0
  43. package/media/landing-zone.svg +1 -0
  44. package/media/light-line.svg +1 -0
  45. package/media/line.svg +1 -0
  46. package/media/main-attack.svg +1 -1
  47. package/media/obstacle-bypass-difficult.svg +1 -1
  48. package/media/obstacle-bypass-easy.svg +1 -1
  49. package/media/obstacle-bypass-impossible.svg +1 -1
  50. package/media/phase-line.svg +1 -0
  51. package/media/pickup-zone.svg +1 -0
  52. package/media/polygon.svg +1 -0
  53. package/media/principal-direction-of-fire.svg +1 -1
  54. package/media/rectangle.svg +1 -0
  55. package/media/search-area.svg +1 -1
  56. package/media/strong-point.svg +1 -0
  57. package/media/support-by-fire.svg +1 -1
  58. package/media/supporting-attack.svg +1 -1
  59. package/media/turn.svg +1 -1
  60. package/package.json +2 -1
@@ -0,0 +1,115 @@
1
+ import { X as ControlMeasureId, or as TextAmplifiers } from "../index-C6nqkw1A.mjs";
2
+ import { FeatureCollection, Geometry } from "geojson";
3
+
4
+ //#region src/preview/index.d.ts
5
+ /**
6
+ * Renders a measure's representative preview to GeoJSON. Pure — no map engine,
7
+ * so it runs identically at build time (docs catalog, README generator) and in
8
+ * the browser (preview app). Returns an empty collection if the generator
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.
15
+ */
16
+ declare function renderRepresentative(id: ControlMeasureId, overrides?: {
17
+ textAmplifiers?: TextAmplifiers;
18
+ options?: Record<string, unknown>;
19
+ }): FeatureCollection<Geometry, unknown>;
20
+ /** A styling-free preview primitive. Consumers supply stroke, radius, font,
21
+ * and colors when they draw it. */
22
+ interface PreviewShape {
23
+ type: "polyline" | "polygon" | "circle" | "text";
24
+ /** SVG path data for `polyline`/`polygon`. */
25
+ d?: string;
26
+ /** Center for `circle`/`text`. */
27
+ cx?: number;
28
+ cy?: number;
29
+ /** Whether a `polygon` is a doctrinal solid (arrowhead) vs an area outline. */
30
+ filled?: boolean;
31
+ /** Glyph text for `text` (e.g. breach's "B"). */
32
+ text?: string;
33
+ /** Generator-frame rotation (radians) for `text`. */
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";
51
+ }
52
+ /** Target viewBox the geometry is fit into. */
53
+ interface ProjectDimensions {
54
+ width: number;
55
+ height: number;
56
+ pad: number;
57
+ }
58
+ /**
59
+ * Fits a rendered `FeatureCollection` into a `width`×`height` viewBox (inset by
60
+ * `pad`) and emits styling-free {@link PreviewShape}s. North is up (y is
61
+ * flipped). Returns `ok: false` for an empty/degenerate render so consumers can
62
+ * show a geometry-typed fallback glyph.
63
+ */
64
+ declare function projectRenderToShapes(fc: FeatureCollection<Geometry, unknown>, dims: ProjectDimensions): {
65
+ shapes: PreviewShape[];
66
+ ok: boolean;
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;
114
+ //#endregion
115
+ export { PreviewShape, ProjectDimensions, projectRenderToShapes, renderRepresentative, svgTextTransform, viewBoxString, viewBoxWithLabels };
@@ -0,0 +1,365 @@
1
+ import { c as DEFINITIONS, t as renderControlMeasure } from "../renderControlMeasure-NKEYq3Fg.mjs";
2
+ //#region src/preview/index.ts
3
+ /**
4
+ * Unitless `previewSample` points (~`[-1, 1]`) are scaled by this degree offset
5
+ * before reaching a generator. Most generators operate in projected meters, so
6
+ * small degree offsets near the origin yield visible geometry. The single place
7
+ * that knows preview points are degree offsets feeding projected-meter
8
+ * generators.
9
+ */
10
+ const D = .005;
11
+ /**
12
+ * Generic, category-level layout for measures without a `previewSample`
13
+ * override — keyed off `geometry`/`minCoordinates`/`entityType` so a whole
14
+ * class shares one layout rather than each sibling repeating it. Per-measure
15
+ * quirks live on the definition (ADR-0025). Points are unitless.
16
+ */
17
+ function fallbackControlPoints(m) {
18
+ const min = m.minCoordinates ?? 2;
19
+ if (m.geometry === "point" || min <= 1) return [[0, 0]];
20
+ if (min === 2) return [[-1, 0], [1, 0]];
21
+ if (m.entityType === "Axis of Advance") return [
22
+ [-1, -.4],
23
+ [1, -.4],
24
+ [1.8, -.4],
25
+ [0, .6]
26
+ ];
27
+ if (min === 3) return [
28
+ [-1, -.4],
29
+ [1, -.4],
30
+ [0, .6]
31
+ ];
32
+ return [
33
+ [-.3, -.3],
34
+ [.3, -.3],
35
+ [-.6, .1],
36
+ [.6, .1]
37
+ ];
38
+ }
39
+ /**
40
+ * Resolves a measure's representative input: its co-located `previewSample`
41
+ * override if present, otherwise the generic {@link fallbackControlPoints}.
42
+ * Unitless points are scaled by {@link D} to the degree offsets a generator
43
+ * expects.
44
+ */
45
+ function representativeSample(id) {
46
+ const definition = DEFINITIONS[id];
47
+ const sample = definition.previewSample;
48
+ const controlPoints = (sample ? sample.controlPoints : fallbackControlPoints(definition.metadata)).map(([x, y]) => [x * D, y * D]);
49
+ const options = sample?.options;
50
+ const textAmplifiers = sample?.textAmplifiers;
51
+ return {
52
+ controlPoints,
53
+ ...options ? { options } : {},
54
+ ...textAmplifiers ? { textAmplifiers } : {}
55
+ };
56
+ }
57
+ /**
58
+ * Renders a measure's representative preview to GeoJSON. Pure — no map engine,
59
+ * so it runs identically at build time (docs catalog, README generator) and in
60
+ * the browser (preview app). Returns an empty collection if the generator
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.
67
+ */
68
+ function renderRepresentative(id, overrides) {
69
+ try {
70
+ const { controlPoints, options, textAmplifiers } = representativeSample(id);
71
+ return renderControlMeasure({
72
+ id: "preview",
73
+ kind: id,
74
+ controlPoints,
75
+ options: {
76
+ ...options,
77
+ ...overrides?.options
78
+ },
79
+ textAmplifiers: {
80
+ ...textAmplifiers,
81
+ ...overrides?.textAmplifiers
82
+ }
83
+ });
84
+ } catch {
85
+ return {
86
+ type: "FeatureCollection",
87
+ features: []
88
+ };
89
+ }
90
+ }
91
+ /**
92
+ * Fits a rendered `FeatureCollection` into a `width`×`height` viewBox (inset by
93
+ * `pad`) and emits styling-free {@link PreviewShape}s. North is up (y is
94
+ * flipped). Returns `ok: false` for an empty/degenerate render so consumers can
95
+ * show a geometry-typed fallback glyph.
96
+ */
97
+ function projectRenderToShapes(fc, dims) {
98
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
99
+ const walk = (p) => {
100
+ if (p[0] < minX) minX = p[0];
101
+ if (p[0] > maxX) maxX = p[0];
102
+ if (p[1] < minY) minY = p[1];
103
+ if (p[1] > maxY) maxY = p[1];
104
+ };
105
+ for (const f of fc.features) collectCoords(f.geometry, walk);
106
+ if (!isFinite(minX) || !isFinite(minY)) return {
107
+ shapes: [],
108
+ ok: false
109
+ };
110
+ const spanX = Math.max(maxX - minX, 1e-9);
111
+ const spanY = Math.max(maxY - minY, 1e-9);
112
+ const innerW = dims.width - dims.pad * 2;
113
+ const innerH = dims.height - dims.pad * 2;
114
+ const scale = Math.min(innerW / spanX, innerH / spanY);
115
+ const offsetX = dims.pad + (innerW - spanX * scale) / 2;
116
+ const offsetY = dims.pad + (innerH - spanY * scale) / 2;
117
+ const tx = (p) => [offsetX + (p[0] - minX) * scale, offsetY + (maxY - p[1]) * scale];
118
+ const shapes = [];
119
+ const bboxArea = spanX * spanY;
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);
126
+ return {
127
+ shapes,
128
+ ok: shapes.length > 0
129
+ };
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
+ }
261
+ function ringArea(ring) {
262
+ let a = 0;
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]);
264
+ return Math.abs(a / 2);
265
+ }
266
+ function collectCoords(g, push) {
267
+ switch (g.type) {
268
+ case "Point":
269
+ push(g.coordinates);
270
+ break;
271
+ case "MultiPoint":
272
+ case "LineString":
273
+ g.coordinates.forEach(push);
274
+ break;
275
+ case "MultiLineString":
276
+ case "Polygon":
277
+ g.coordinates.forEach((ring) => ring.forEach(push));
278
+ break;
279
+ case "MultiPolygon":
280
+ g.coordinates.forEach((poly) => poly.forEach((ring) => ring.forEach(push)));
281
+ break;
282
+ case "GeometryCollection":
283
+ g.geometries.forEach((sub) => collectCoords(sub, push));
284
+ break;
285
+ }
286
+ }
287
+ function pathFromRing(ring, tx, close) {
288
+ if (ring.length === 0) return "";
289
+ const parts = ring.map((p, i) => {
290
+ const [x, y] = tx(p);
291
+ return `${i === 0 ? "M" : "L"}${x.toFixed(2)} ${y.toFixed(2)}`;
292
+ });
293
+ if (close) parts.push("Z");
294
+ return parts.join(" ");
295
+ }
296
+ function collectShapes(g, tx, out, bboxArea, textLimits, props) {
297
+ const labelProps = props && typeof props === "object" ? props : {};
298
+ const labelText = typeof labelProps.text === "string" ? labelProps.text : void 0;
299
+ const labelRotation = typeof labelProps.rotation === "number" ? labelProps.rotation : void 0;
300
+ const labelAnchor = labelProps.textAnchor === "start" || labelProps.textAnchor === "end" ? labelProps.textAnchor : void 0;
301
+ const polygonFilled = (ring) => bboxArea > 0 && ringArea(ring) / bboxArea < .25;
302
+ switch (g.type) {
303
+ case "Point": {
304
+ const [x, y] = tx(g.coordinates);
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({
317
+ type: "circle",
318
+ cx: x,
319
+ cy: y
320
+ });
321
+ break;
322
+ }
323
+ case "MultiPoint":
324
+ g.coordinates.forEach((p) => {
325
+ const [x, y] = tx(p);
326
+ out.push({
327
+ type: "circle",
328
+ cx: x,
329
+ cy: y
330
+ });
331
+ });
332
+ break;
333
+ case "LineString":
334
+ out.push({
335
+ type: "polyline",
336
+ d: pathFromRing(g.coordinates, tx, false)
337
+ });
338
+ break;
339
+ case "MultiLineString":
340
+ g.coordinates.forEach((line) => out.push({
341
+ type: "polyline",
342
+ d: pathFromRing(line, tx, false)
343
+ }));
344
+ break;
345
+ case "Polygon":
346
+ g.coordinates.forEach((ring) => out.push({
347
+ type: "polygon",
348
+ d: pathFromRing(ring, tx, true),
349
+ filled: polygonFilled(ring)
350
+ }));
351
+ break;
352
+ case "MultiPolygon":
353
+ g.coordinates.forEach((poly) => poly.forEach((ring) => out.push({
354
+ type: "polygon",
355
+ d: pathFromRing(ring, tx, true),
356
+ filled: polygonFilled(ring)
357
+ })));
358
+ break;
359
+ case "GeometryCollection":
360
+ g.geometries.forEach((sub) => collectShapes(sub, tx, out, bboxArea, textLimits, props));
361
+ break;
362
+ }
363
+ }
364
+ //#endregion
365
+ export { projectRenderToShapes, renderRepresentative, svgTextTransform, viewBoxString, viewBoxWithLabels };