@seatmap-fyi/map-domain 0.1.0-alpha.4 → 0.1.0-alpha.50
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/arc-fan-rebuild.d.ts +17 -0
- package/dist/arc-fan-rebuild.js +227 -0
- package/dist/arc-fan-section-layout.d.ts +11 -0
- package/dist/arc-fan-section-layout.js +54 -0
- package/dist/arc-fan.d.ts +27 -0
- package/dist/arc-fan.interface.d.ts +100 -0
- package/dist/arc-fan.interface.js +30 -0
- package/dist/arc-fan.js +182 -0
- package/dist/catalog.d.ts +6 -4
- package/dist/catalog.js +31 -17
- package/dist/categories.d.ts +14 -3
- package/dist/categories.js +146 -35
- package/dist/editor-state.d.ts +4 -1
- package/dist/editor-state.js +53 -30
- package/dist/floors.d.ts +22 -0
- package/dist/floors.js +72 -0
- package/dist/geometry/boundary.d.ts +1 -1
- package/dist/geometry/boundary.js +16 -12
- package/dist/geometry/curve-warnings.d.ts +1 -1
- package/dist/geometry/curve-warnings.js +3 -5
- package/dist/geometry/decoration-bounds.d.ts +4 -0
- package/dist/geometry/decoration-bounds.js +42 -0
- package/dist/geometry/ellipse.js +4 -12
- package/dist/geometry/geometry.d.ts +9 -3
- package/dist/geometry/geometry.js +58 -34
- package/dist/geometry/inventory-outline.d.ts +8 -0
- package/dist/geometry/inventory-outline.js +46 -0
- package/dist/geometry/layout-transform.d.ts +10 -0
- package/dist/geometry/layout-transform.interface.d.ts +6 -0
- package/dist/geometry/layout-transform.interface.js +1 -0
- package/dist/geometry/layout-transform.js +206 -0
- package/dist/geometry/polygon-curves.d.ts +17 -0
- package/dist/geometry/polygon-curves.interface.d.ts +21 -0
- package/dist/geometry/polygon-curves.interface.js +5 -0
- package/dist/geometry/polygon-curves.js +169 -0
- package/dist/geometry/primitives.d.ts +1 -1
- package/dist/geometry/primitives.js +2 -3
- package/dist/geometry/seat-shape.d.ts +1 -1
- package/dist/geometry/seat-shape.js +5 -5
- package/dist/geometry/seating-layout.d.ts +10 -1
- package/dist/geometry/seating-layout.js +73 -57
- package/dist/geometry/units.d.ts +8 -0
- package/dist/geometry/units.js +13 -0
- package/dist/geometry/venue-outline.d.ts +4 -18
- package/dist/geometry/venue-outline.interface.d.ts +23 -0
- package/dist/geometry/venue-outline.interface.js +7 -0
- package/dist/geometry/venue-outline.js +142 -49
- package/dist/identity.d.ts +3 -1
- package/dist/identity.js +32 -17
- package/dist/issues.d.ts +16 -2
- package/dist/issues.js +17 -6
- package/dist/labels.d.ts +6 -1
- package/dist/labels.js +20 -18
- package/dist/layers.d.ts +26 -0
- package/dist/layers.js +86 -0
- package/dist/media.d.ts +27 -0
- package/dist/media.js +89 -0
- package/dist/{types.d.ts → physical-document.interface.d.ts} +142 -10
- package/dist/{types.js → physical-document.interface.js} +23 -0
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +39 -29
- package/dist/reference.js +1 -1
- package/dist/row-segments.d.ts +5 -1
- package/dist/row-segments.js +10 -9
- package/dist/schema.d.ts +680 -18
- package/dist/schema.js +269 -111
- package/dist/seat-proximity.d.ts +4 -0
- package/dist/seat-proximity.js +119 -0
- package/dist/section-elevation.d.ts +5 -0
- package/dist/section-elevation.interface.d.ts +26 -0
- package/dist/section-elevation.interface.js +8 -0
- package/dist/section-elevation.js +53 -0
- package/dist/section-fill-rebuild.d.ts +10 -0
- package/dist/section-fill-rebuild.js +64 -0
- package/dist/section-fill.d.ts +84 -0
- package/dist/section-fill.interface.d.ts +94 -0
- package/dist/section-fill.interface.js +22 -0
- package/dist/section-fill.js +306 -0
- package/dist/section-growth.d.ts +11 -0
- package/dist/section-growth.interface.d.ts +20 -0
- package/dist/section-growth.interface.js +1 -0
- package/dist/section-growth.js +245 -0
- package/dist/section-layout.d.ts +101 -0
- package/dist/section-layout.interface.d.ts +8 -0
- package/dist/section-layout.interface.js +5 -0
- package/dist/section-layout.js +72 -0
- package/dist/section-outline-refit.d.ts +8 -0
- package/dist/section-outline-refit.js +246 -0
- package/dist/section-refit.d.ts +22 -0
- package/dist/section-refit.interface.d.ts +49 -0
- package/dist/section-refit.interface.js +6 -0
- package/dist/section-refit.js +179 -0
- package/dist/section-scale.d.ts +2 -0
- package/dist/section-scale.js +128 -0
- package/dist/sections.d.ts +23 -0
- package/dist/sections.js +144 -0
- package/dist/selling.d.ts +1 -1
- package/dist/selling.js +11 -26
- package/dist/spacing-repairs.d.ts +31 -0
- package/dist/spacing-repairs.js +168 -0
- package/dist/table-layout.d.ts +3 -3
- package/dist/table-layout.js +35 -35
- package/dist/validation.d.ts +7 -2
- package/dist/validation.interface.d.ts +20 -0
- package/dist/validation.interface.js +9 -0
- package/dist/validation.js +221 -85
- package/dist/wayfinding.d.ts +10 -0
- package/dist/wayfinding.interface.d.ts +52 -0
- package/dist/wayfinding.interface.js +28 -0
- package/dist/wayfinding.js +63 -0
- package/package.json +97 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurveMode, TableChairDistribution, RowAlignment, SeatingKind, } from "../
|
|
1
|
+
import { CurveMode, TableChairDistribution, RowAlignment, RowStagger, SeatingKind, } from "../physical-document.interface.js";
|
|
2
2
|
import { ellipseAngleAtDistance } from "./ellipse.js";
|
|
3
3
|
export var TableSide;
|
|
4
4
|
(function (TableSide) {
|
|
@@ -7,30 +7,38 @@ export var TableSide;
|
|
|
7
7
|
TableSide["Bottom"] = "bottom";
|
|
8
8
|
TableSide["Left"] = "left";
|
|
9
9
|
})(TableSide || (TableSide = {}));
|
|
10
|
+
const clockwiseTableSides = Object.values(TableSide);
|
|
11
|
+
const sideOrderedTableSides = [TableSide.Top, TableSide.Bottom, TableSide.Left, TableSide.Right];
|
|
12
|
+
export function rectangularChairOrder(recipe) {
|
|
13
|
+
return recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
14
|
+
? sideOrderedTableSides
|
|
15
|
+
: clockwiseTableSides;
|
|
16
|
+
}
|
|
17
|
+
export function rowStaggerOffset(recipe, index) {
|
|
18
|
+
const lane = index % 2 === 0 ? RowStagger.First : RowStagger.Second;
|
|
19
|
+
return recipe.stagger === lane ? recipe.seatPitchM / 2 : 0;
|
|
20
|
+
}
|
|
21
|
+
/** A lane shift is derived from the recipe. The row offset remains an independent edit. */
|
|
22
|
+
export function rowPlacementOffset(group, index, offset) {
|
|
23
|
+
return {
|
|
24
|
+
x: (offset?.x ?? 0) + (group.kind === SeatingKind.Straight ? rowStaggerOffset(group.recipe, index) : 0),
|
|
25
|
+
y: offset?.y ?? 0,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
10
28
|
export function rowSeatGeometry(group, row, seat, count, longestRow = count, layout) {
|
|
11
29
|
if (layout) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
? 1 - (angle * angle) / 6
|
|
19
|
-
: Math.sin(angle) / angle;
|
|
20
|
-
const cosc = Math.abs(angle) < 1e-6
|
|
21
|
-
? angle / 2 - (angle * angle * angle) / 24
|
|
22
|
-
: (1 - Math.cos(angle)) / angle;
|
|
23
|
-
const x = distance * sinc;
|
|
24
|
-
const y = -distance * cosc;
|
|
25
|
-
const rotation = (layout.rotationDeg * Math.PI) / 180;
|
|
30
|
+
const halfStep = (layout.curveDeg * Math.PI) / (360 * Math.max(1, count - 1));
|
|
31
|
+
const halfAngle = seat * halfStep;
|
|
32
|
+
// The pitch is a straight-line gap between adjacent seat centres.
|
|
33
|
+
const chord = halfStep ? Math.sin(halfAngle) / Math.sin(halfStep) : seat;
|
|
34
|
+
const distance = layout.seatPitchM * chord;
|
|
35
|
+
const direction = (layout.rotationDeg * Math.PI) / 180 - halfAngle;
|
|
26
36
|
return {
|
|
27
37
|
position: {
|
|
28
|
-
x: layout.originM.x +
|
|
29
|
-
y: layout.originM.y +
|
|
38
|
+
x: layout.originM.x + distance * Math.cos(direction),
|
|
39
|
+
y: layout.originM.y + distance * Math.sin(direction),
|
|
30
40
|
},
|
|
31
|
-
rotationDeg: layout.rotationDeg -
|
|
32
|
-
(angle * 180) / Math.PI +
|
|
33
|
-
(layout.seatRotationOffsetDeg ?? 0),
|
|
41
|
+
rotationDeg: layout.rotationDeg - (halfAngle * 360) / Math.PI + (layout.seatRotationOffsetDeg ?? 0),
|
|
34
42
|
};
|
|
35
43
|
}
|
|
36
44
|
if (group.kind === SeatingKind.Straight)
|
|
@@ -49,27 +57,50 @@ export function rowSeatGeometry(group, row, seat, count, longestRow = count, lay
|
|
|
49
57
|
rotationDeg: 0,
|
|
50
58
|
};
|
|
51
59
|
const radius = group.recipe.innerRadiusM + row * group.recipe.rowPitchM;
|
|
52
|
-
const horizontal = group.recipe.innerRadiusM * (group.recipe.axisRatio ?? 1) +
|
|
53
|
-
row * group.recipe.rowPitchM;
|
|
60
|
+
const horizontal = group.recipe.innerRadiusM * (group.recipe.axisRatio ?? 1) + row * group.recipe.rowPitchM;
|
|
54
61
|
const p = group.recipe.placement;
|
|
55
62
|
const angle = p.kind === CurveMode.Pitch
|
|
56
63
|
? ellipseAngleAtDistance(horizontal, radius, (p.centerAngleDeg * Math.PI) / 180, (seat - (count - 1) / 2) * p.seatPitchM)
|
|
57
64
|
: ((p.startAngleDeg +
|
|
58
65
|
(count === 1
|
|
59
66
|
? p.sweepAngleDeg / 2
|
|
60
|
-
: (p.sweepAngleDeg * seat) /
|
|
61
|
-
(Math.abs(p.sweepAngleDeg) === 360 ? count : count - 1))) *
|
|
67
|
+
: (p.sweepAngleDeg * seat) / (Math.abs(p.sweepAngleDeg) === 360 ? count : count - 1))) *
|
|
62
68
|
Math.PI) /
|
|
63
69
|
180;
|
|
64
70
|
return {
|
|
65
71
|
position: { x: horizontal * Math.cos(angle), y: radius * Math.sin(angle) },
|
|
66
72
|
rotationDeg: horizontal === radius
|
|
67
73
|
? (angle * 180) / Math.PI + 90
|
|
68
|
-
: (Math.atan2(radius * Math.cos(angle), -horizontal * Math.sin(angle)) *
|
|
69
|
-
180) /
|
|
70
|
-
Math.PI,
|
|
74
|
+
: (Math.atan2(radius * Math.cos(angle), -horizontal * Math.sin(angle)) * 180) / Math.PI,
|
|
71
75
|
};
|
|
72
76
|
}
|
|
77
|
+
function normalizeRowAngle(rotationDeg) {
|
|
78
|
+
return ((((rotationDeg + 180) % 360) + 360) % 360) - 180;
|
|
79
|
+
}
|
|
80
|
+
function rowCurveAxisOffset(curveDeg) {
|
|
81
|
+
return curveDeg < 0 ? 180 : 0;
|
|
82
|
+
}
|
|
83
|
+
/** The row axis is independent of its chair-facing offset. */
|
|
84
|
+
export function rowLayoutAxisRotation(layout) {
|
|
85
|
+
return layout.rotationDeg - rowCurveAxisOffset(layout.curveDeg);
|
|
86
|
+
}
|
|
87
|
+
export function setRowLayoutAxisRotation(layout, rotationDeg) {
|
|
88
|
+
const rotation = rotationDeg + rowCurveAxisOffset(layout.curveDeg);
|
|
89
|
+
return {
|
|
90
|
+
...layout,
|
|
91
|
+
rotationDeg: normalizeRowAngle(rotation),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Curve edits preserve the row axis and its independent chair-facing offset. */
|
|
95
|
+
export function setRowLayoutCurve(layout, curveDeg) {
|
|
96
|
+
const axisRotation = rowLayoutAxisRotation(layout);
|
|
97
|
+
const facingOffset = layout.rotationDeg + (layout.seatRotationOffsetDeg ?? 0) - axisRotation;
|
|
98
|
+
return setRowLayoutAxisRotation({
|
|
99
|
+
...layout,
|
|
100
|
+
curveDeg,
|
|
101
|
+
seatRotationOffsetDeg: normalizeRowAngle(facingOffset - rowCurveAxisOffset(curveDeg)),
|
|
102
|
+
}, axisRotation);
|
|
103
|
+
}
|
|
73
104
|
/** Resolves inherited geometry once when a row becomes independently editable. */
|
|
74
105
|
export function resolveRowLayout(group, rowIndex) {
|
|
75
106
|
const row = group.rows[rowIndex];
|
|
@@ -84,43 +115,32 @@ export function resolveRowLayout(group, rowIndex) {
|
|
|
84
115
|
originM: first.position,
|
|
85
116
|
seatPitchM: group.recipe.seatPitchM,
|
|
86
117
|
curveDeg: 0,
|
|
87
|
-
rotationDeg: (
|
|
118
|
+
rotationDeg: normalizeRowAngle(first.rotationDeg),
|
|
88
119
|
};
|
|
89
120
|
const radius = group.recipe.innerRadiusM + rowIndex * group.recipe.rowPitchM;
|
|
90
121
|
const placement = group.recipe.placement;
|
|
91
122
|
const intervals = Math.max(0, row.seats.length - 1);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
sweep =
|
|
100
|
-
placement.sweepAngleDeg *
|
|
101
|
-
(Math.abs(placement.sweepAngleDeg) === 360
|
|
102
|
-
? intervals / row.seats.length
|
|
103
|
-
: 1);
|
|
104
|
-
pitch = intervals
|
|
105
|
-
? (((Math.abs(sweep) * Math.PI) / 180) * radius) / intervals
|
|
106
|
-
: 0.55;
|
|
123
|
+
const sweep = placement.kind === CurveMode.Pitch
|
|
124
|
+
? (((intervals * placement.seatPitchM) / radius) * 180) / Math.PI
|
|
125
|
+
: placement.sweepAngleDeg * (Math.abs(placement.sweepAngleDeg) === 360 ? intervals / row.seats.length : 1);
|
|
126
|
+
let pitch = placement.kind === CurveMode.Pitch ? placement.seatPitchM : 0.55;
|
|
127
|
+
if (intervals) {
|
|
128
|
+
const second = rowSeatGeometry(group, rowIndex, 1, row.seats.length, longest).position;
|
|
129
|
+
pitch = Math.hypot(second.x - first.position.x, second.y - first.position.y);
|
|
107
130
|
}
|
|
108
131
|
const tangent = first.rotationDeg + (sweep < 0 ? 180 : 0);
|
|
109
132
|
return {
|
|
110
133
|
originM: first.position,
|
|
111
134
|
seatPitchM: pitch,
|
|
112
135
|
curveDeg: -sweep,
|
|
113
|
-
rotationDeg: (
|
|
136
|
+
rotationDeg: normalizeRowAngle(tangent),
|
|
114
137
|
...(sweep < 0 ? { seatRotationOffsetDeg: -180 } : {}),
|
|
115
138
|
};
|
|
116
139
|
}
|
|
117
140
|
export function roundChairGeometry(recipe, chairHeightM, seat, count) {
|
|
118
141
|
const radius = recipe.diameterM / 2 + recipe.chairGapM + chairHeightM / 2;
|
|
119
142
|
const arc = recipe.seatArcDeg ?? 360;
|
|
120
|
-
const angle = recipe.startAngleDeg +
|
|
121
|
-
(count === 1
|
|
122
|
-
? 0
|
|
123
|
-
: (360 - arc) / 2 + (arc * seat) / (arc === 360 ? count : count - 1));
|
|
143
|
+
const angle = recipe.startAngleDeg + (count === 1 ? 0 : (360 - arc) / 2 + (arc * seat) / (arc === 360 ? count : count - 1));
|
|
124
144
|
return {
|
|
125
145
|
position: {
|
|
126
146
|
x: radius * Math.cos((angle * Math.PI) / 180),
|
|
@@ -152,9 +172,7 @@ export function rectangularChairGeometry(recipe, chairHeightM, side, seat, count
|
|
|
152
172
|
case TableSide.Bottom:
|
|
153
173
|
return {
|
|
154
174
|
position: {
|
|
155
|
-
x: recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
156
|
-
? along
|
|
157
|
-
: -along,
|
|
175
|
+
x: recipe.chairDistribution === TableChairDistribution.EqualSegments ? along : -along,
|
|
158
176
|
y: recipe.depthM / 2 + gap,
|
|
159
177
|
},
|
|
160
178
|
rotationDeg: -90,
|
|
@@ -163,9 +181,7 @@ export function rectangularChairGeometry(recipe, chairHeightM, side, seat, count
|
|
|
163
181
|
return {
|
|
164
182
|
position: {
|
|
165
183
|
x: -recipe.widthM / 2 - gap,
|
|
166
|
-
y: recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
167
|
-
? along
|
|
168
|
-
: -along,
|
|
184
|
+
y: recipe.chairDistribution === TableChairDistribution.EqualSegments ? along : -along,
|
|
169
185
|
},
|
|
170
186
|
rotationDeg: 0,
|
|
171
187
|
};
|
|
@@ -179,8 +195,7 @@ export function* previewSeats(layout) {
|
|
|
179
195
|
switch (layout.kind) {
|
|
180
196
|
case SeatingKind.Straight:
|
|
181
197
|
case SeatingKind.Curved: {
|
|
182
|
-
const longestRow = layout.rowCounts?.reduce((max, count) => Math.max(max, count), 0) ??
|
|
183
|
-
layout.seatsPerRow;
|
|
198
|
+
const longestRow = layout.rowCounts?.reduce((max, count) => Math.max(max, count), 0) ?? layout.seatsPerRow;
|
|
184
199
|
for (let row = 0; row < layout.rows; row++)
|
|
185
200
|
for (let seat = 0; seat < (layout.rowCounts?.[row] ?? layout.seatsPerRow); seat++)
|
|
186
201
|
yield {
|
|
@@ -203,7 +218,8 @@ export function* previewSeats(layout) {
|
|
|
203
218
|
for (const side of Object.values(TableSide))
|
|
204
219
|
for (let seat = 0; seat < layout.sides[side]; seat++)
|
|
205
220
|
yield {
|
|
206
|
-
position: rectangularChairGeometry(layout.recipe, layout.seatSizeM, side, seat, layout.sides[side])
|
|
221
|
+
position: rectangularChairGeometry(layout.recipe, layout.seatSizeM, side, seat, layout.sides[side])
|
|
222
|
+
.position,
|
|
207
223
|
row: null,
|
|
208
224
|
ordinal: ++ordinal,
|
|
209
225
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const LayoutUnitM: number;
|
|
2
|
+
/**
|
|
3
|
+
* @method toLayoutUnits
|
|
4
|
+
* @description Convert through the authored scale without rounding precise geometry to a canvas grid.
|
|
5
|
+
* @param {number} distanceM - Distance in metres.
|
|
6
|
+
* @returns {number} Distance in authoring layout units.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toLayoutUnits(distanceM: number): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const layoutScaleM = 0.55;
|
|
2
|
+
const layoutScaleUnits = 24;
|
|
3
|
+
// Standard authoring scale: 24 canvas units span a 0.55m seat pitch.
|
|
4
|
+
export const LayoutUnitM = layoutScaleM / layoutScaleUnits;
|
|
5
|
+
/**
|
|
6
|
+
* @method toLayoutUnits
|
|
7
|
+
* @description Convert through the authored scale without rounding precise geometry to a canvas grid.
|
|
8
|
+
* @param {number} distanceM - Distance in metres.
|
|
9
|
+
* @returns {number} Distance in authoring layout units.
|
|
10
|
+
*/
|
|
11
|
+
export function toLayoutUnits(distanceM) {
|
|
12
|
+
return (distanceM / layoutScaleM) * layoutScaleUnits;
|
|
13
|
+
}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import type { PointM, PolygonM } from "../
|
|
2
|
-
|
|
3
|
-
Rectangle = "rectangle",
|
|
4
|
-
Ellipse = "ellipse",
|
|
5
|
-
Sector = "sector",
|
|
6
|
-
Envelope = "envelope"
|
|
7
|
-
}
|
|
8
|
-
export type OutlineParameters = {
|
|
9
|
-
kind: Exclude<OutlineKind, "envelope">;
|
|
10
|
-
center: PointM;
|
|
11
|
-
radiusX: number;
|
|
12
|
-
radiusY: number;
|
|
13
|
-
innerRatio: number;
|
|
14
|
-
startDeg: number;
|
|
15
|
-
sweepDeg: number;
|
|
16
|
-
};
|
|
1
|
+
import type { PointM, PolygonM } from "../physical-document.interface.js";
|
|
2
|
+
import { type OutlineParameters } from "./venue-outline.interface.js";
|
|
17
3
|
export declare function sampledOutline(p: OutlineParameters): PolygonM;
|
|
18
4
|
/** Conservative convex envelope, with no invented architectural voids. */
|
|
19
5
|
export declare function memberEnvelope(points: readonly PointM[], paddingM?: number): PolygonM;
|
|
20
|
-
/**
|
|
21
|
-
export declare function interiorLabelPoint(
|
|
6
|
+
/** Maximum-clearance interior anchor. Holes and curved contours share the same geometry owner. */
|
|
7
|
+
export declare function interiorLabelPoint(source: PolygonM): PointM;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PointM } from "../physical-document.interface.js";
|
|
2
|
+
export declare enum OutlineKind {
|
|
3
|
+
Rectangle = "rectangle",
|
|
4
|
+
Ellipse = "ellipse",
|
|
5
|
+
Sector = "sector",
|
|
6
|
+
Envelope = "envelope"
|
|
7
|
+
}
|
|
8
|
+
export type OutlineParameters = {
|
|
9
|
+
kind: Exclude<OutlineKind, OutlineKind.Envelope>;
|
|
10
|
+
center: PointM;
|
|
11
|
+
radiusX: number;
|
|
12
|
+
radiusY: number;
|
|
13
|
+
innerRatio: number;
|
|
14
|
+
startDeg: number;
|
|
15
|
+
sweepDeg: number;
|
|
16
|
+
};
|
|
17
|
+
export interface InteriorLabelCell {
|
|
18
|
+
center: PointM;
|
|
19
|
+
halfWidthM: number;
|
|
20
|
+
halfHeightM: number;
|
|
21
|
+
distanceM: number;
|
|
22
|
+
maximumM: number;
|
|
23
|
+
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
+
import { PolygonVertexLimit, polygonContour, sideCurvePoint } from "./polygon-curves.js";
|
|
1
2
|
import { pointsBounds, containsPoint } from "./primitives.js";
|
|
2
3
|
import { ellipseSegments } from "./ellipse.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
OutlineKind["Ellipse"] = "ellipse";
|
|
7
|
-
OutlineKind["Sector"] = "sector";
|
|
8
|
-
OutlineKind["Envelope"] = "envelope";
|
|
9
|
-
})(OutlineKind || (OutlineKind = {}));
|
|
4
|
+
import TinyQueue from "tinyqueue";
|
|
5
|
+
import { LayoutUnitM } from "./units.js";
|
|
6
|
+
import { OutlineKind } from "./venue-outline.interface.js";
|
|
10
7
|
export function sampledOutline(p) {
|
|
11
|
-
if (![
|
|
12
|
-
p.center.x,
|
|
13
|
-
p.center.y,
|
|
14
|
-
p.radiusX,
|
|
15
|
-
p.radiusY,
|
|
16
|
-
p.innerRatio,
|
|
17
|
-
p.startDeg,
|
|
18
|
-
p.sweepDeg,
|
|
19
|
-
].every(Number.isFinite) ||
|
|
8
|
+
if (![p.center.x, p.center.y, p.radiusX, p.radiusY, p.innerRatio, p.startDeg, p.sweepDeg].every(Number.isFinite) ||
|
|
20
9
|
p.radiusX <= 0 ||
|
|
21
10
|
p.radiusY <= 0 ||
|
|
22
11
|
p.innerRatio < 0 ||
|
|
@@ -38,9 +27,7 @@ export function sampledOutline(p) {
|
|
|
38
27
|
],
|
|
39
28
|
holes: [],
|
|
40
29
|
};
|
|
41
|
-
const sweep = p.kind === OutlineKind.Ellipse
|
|
42
|
-
? Math.PI * 2
|
|
43
|
-
: (p.sweepDeg * Math.PI) / 180, start = (p.startDeg * Math.PI) / 180, full = Math.abs(sweep) === Math.PI * 2;
|
|
30
|
+
const sweep = p.kind === OutlineKind.Ellipse ? Math.PI * 2 : (p.sweepDeg * Math.PI) / 180, start = (p.startDeg * Math.PI) / 180, full = Math.abs(sweep) === Math.PI * 2;
|
|
44
31
|
const count = ellipseSegments(p.radiusX, p.radiusY, sweep);
|
|
45
32
|
const arc = (ratio) => Array.from({ length: count + (full ? 0 : 1) }, (_, i) => point(start + (sweep * i) / count, ratio));
|
|
46
33
|
const outer = arc(1);
|
|
@@ -49,10 +36,7 @@ export function sampledOutline(p) {
|
|
|
49
36
|
outer,
|
|
50
37
|
holes: p.innerRatio > 0 ? [arc(p.innerRatio).reverse()] : [],
|
|
51
38
|
};
|
|
52
|
-
const ring = [
|
|
53
|
-
...outer,
|
|
54
|
-
...(p.innerRatio > 0 ? arc(p.innerRatio).reverse() : [p.center]),
|
|
55
|
-
];
|
|
39
|
+
const ring = [...outer, ...(p.innerRatio > 0 ? arc(p.innerRatio).reverse() : [p.center])];
|
|
56
40
|
if (ring.length > 10000)
|
|
57
41
|
throw new Error("The sector exceeds the 10,000-vertex limit at 1mm accuracy.");
|
|
58
42
|
return { outer: ring, holes: [] };
|
|
@@ -73,8 +57,7 @@ export function memberEnvelope(points, paddingM = 0.15) {
|
|
|
73
57
|
const half = (input) => {
|
|
74
58
|
const result = [];
|
|
75
59
|
for (const p of input) {
|
|
76
|
-
while (result.length > 1 &&
|
|
77
|
-
cross(result[result.length - 2], result[result.length - 1], p) <= 0)
|
|
60
|
+
while (result.length > 1 && cross(result[result.length - 2], result[result.length - 1], p) <= 0)
|
|
78
61
|
result.pop();
|
|
79
62
|
result.push(p);
|
|
80
63
|
}
|
|
@@ -88,33 +71,143 @@ export function memberEnvelope(points, paddingM = 0.15) {
|
|
|
88
71
|
throw new Error("The envelope exceeds the boundary vertex limit.");
|
|
89
72
|
return { outer, holes: [] };
|
|
90
73
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
const labelSearchPrecisionM = 1.5 * LayoutUnitM;
|
|
75
|
+
const curvedLabelSearchPrecisionM = 1.25 * LayoutUnitM;
|
|
76
|
+
const labelCurveSampleSpacingM = 2 * LayoutUnitM;
|
|
77
|
+
const labelInitialCellLimit = 64;
|
|
78
|
+
const labelSearchRoundoff = 16 * Number.EPSILON;
|
|
79
|
+
const labelPoints = new WeakMap();
|
|
80
|
+
function curvedLabelContour(source) {
|
|
81
|
+
const { edgeCurvature, outer, holes, cornerRounding, cornerRadiusM } = source;
|
|
82
|
+
if (!edgeCurvature?.some(Boolean) || cornerRounding || cornerRadiusM)
|
|
83
|
+
return null;
|
|
84
|
+
const segments = outer.map((start, index) => {
|
|
85
|
+
const curvature = edgeCurvature[index];
|
|
86
|
+
if (!curvature)
|
|
87
|
+
return 1;
|
|
88
|
+
const end = outer[(index + 1) % outer.length];
|
|
89
|
+
const chord = Math.hypot(end.x - start.x, end.y - start.y);
|
|
90
|
+
// The two outer legs of the equivalent cubic share a normal offset.
|
|
91
|
+
const controlLength = (chord * (1 + 2 * Math.hypot(1, (2 * curvature) / 100))) / 3;
|
|
92
|
+
return Math.max(1, Math.ceil(controlLength / labelCurveSampleSpacingM));
|
|
93
|
+
});
|
|
94
|
+
if (segments.reduce((count, side) => count + side, 0) > PolygonVertexLimit)
|
|
95
|
+
return null;
|
|
96
|
+
const contour = outer.flatMap((start, index) => {
|
|
97
|
+
const count = segments[index];
|
|
98
|
+
if (count === 1)
|
|
99
|
+
return [start];
|
|
100
|
+
const end = outer[(index + 1) % outer.length];
|
|
101
|
+
return Array.from({ length: count }, (_, step) => sideCurvePoint(start, end, edgeCurvature[index], step / count));
|
|
102
|
+
});
|
|
103
|
+
return { outer: contour, holes };
|
|
104
|
+
}
|
|
105
|
+
function outlineClearance(polygon, point) {
|
|
106
|
+
let distanceSquared = Infinity;
|
|
107
|
+
for (const ring of [polygon.outer, ...polygon.holes]) {
|
|
108
|
+
for (let index = 0; index < ring.length; index++) {
|
|
109
|
+
const start = ring[index], end = ring[(index + 1) % ring.length];
|
|
110
|
+
const dx = end.x - start.x, dy = end.y - start.y;
|
|
111
|
+
const lengthSquared = dx * dx + dy * dy;
|
|
112
|
+
const fraction = lengthSquared === 0
|
|
113
|
+
? 0
|
|
114
|
+
: Math.max(0, Math.min(1, ((point.x - start.x) * dx + (point.y - start.y) * dy) / lengthSquared));
|
|
115
|
+
const x = point.x - start.x - fraction * dx, y = point.y - start.y - fraction * dy;
|
|
116
|
+
distanceSquared = Math.min(distanceSquared, x * x + y * y);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const inside = containsPoint(polygon.outer, point) && !polygon.holes.some((hole) => containsPoint(hole, point));
|
|
120
|
+
return Math.sqrt(distanceSquared) * (inside ? 1 : -1);
|
|
121
|
+
}
|
|
122
|
+
function outlineCentroid(polygon) {
|
|
123
|
+
let area = 0, x = 0, y = 0;
|
|
124
|
+
const ring = polygon.outer;
|
|
125
|
+
const origin = ring[0];
|
|
126
|
+
for (let index = 0; index < ring.length; index++) {
|
|
127
|
+
const start = ring[index], end = ring[(index + 1) % ring.length];
|
|
128
|
+
const startX = start.x - origin.x, startY = start.y - origin.y;
|
|
129
|
+
const endX = end.x - origin.x, endY = end.y - origin.y;
|
|
130
|
+
const cross = startX * endY - endX * startY;
|
|
131
|
+
area += cross;
|
|
132
|
+
x += (startX + endX) * cross;
|
|
133
|
+
y += (startY + endY) * cross;
|
|
134
|
+
}
|
|
135
|
+
return area === 0 ? origin : { x: origin.x + x / (3 * area), y: origin.y + y / (3 * area) };
|
|
136
|
+
}
|
|
137
|
+
/** Maximum-clearance interior anchor. Holes and curved contours share the same geometry owner. */
|
|
138
|
+
export function interiorLabelPoint(source) {
|
|
139
|
+
const cached = labelPoints.get(source);
|
|
140
|
+
if (cached)
|
|
141
|
+
return cached;
|
|
142
|
+
const labelContour = curvedLabelContour(source);
|
|
143
|
+
const polygon = labelContour ?? polygonContour(source);
|
|
144
|
+
const precisionM = labelContour ? curvedLabelSearchPrecisionM : labelSearchPrecisionM;
|
|
145
|
+
const bounds = pointsBounds(polygon.outer);
|
|
146
|
+
const width = bounds.maxX - bounds.minX, height = bounds.maxY - bounds.minY;
|
|
147
|
+
const roundoffM = Math.max(width, height, Math.abs(bounds.minX), Math.abs(bounds.minY), Math.abs(bounds.maxX), Math.abs(bounds.maxY)) * labelSearchRoundoff;
|
|
148
|
+
const cell = (center, halfWidthM, halfHeightM) => {
|
|
149
|
+
const distanceM = outlineClearance(polygon, center);
|
|
150
|
+
return {
|
|
151
|
+
center,
|
|
152
|
+
halfWidthM,
|
|
153
|
+
halfHeightM,
|
|
154
|
+
distanceM,
|
|
155
|
+
maximumM: distanceM + Math.hypot(halfWidthM, halfHeightM),
|
|
156
|
+
};
|
|
98
157
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
158
|
+
const center = cell({ x: (bounds.minX + bounds.maxX) / 2, y: (bounds.minY + bounds.maxY) / 2 }, 0, 0);
|
|
159
|
+
let best = labelContour ? center : cell(outlineCentroid(polygon), 0, 0);
|
|
160
|
+
if (center.distanceM > best.distanceM + roundoffM)
|
|
161
|
+
best = center;
|
|
162
|
+
// A boundary vertex is admissible when the initial candidate falls in a void.
|
|
163
|
+
if (best.distanceM < 0)
|
|
164
|
+
best = cell(polygon.outer[0], 0, 0);
|
|
165
|
+
// No inscribed circle can exceed half the smaller bounding-box dimension.
|
|
166
|
+
if (Math.min(width, height) / 2 - best.distanceM <= precisionM) {
|
|
167
|
+
labelPoints.set(source, best.center);
|
|
168
|
+
return best.center;
|
|
169
|
+
}
|
|
170
|
+
const queue = new TinyQueue([], (left, right) => {
|
|
171
|
+
const difference = right.maximumM - left.maximumM;
|
|
172
|
+
// Symmetric cells must keep the same queue order across layout-unit/metre conversion.
|
|
173
|
+
return Math.abs(difference) <= roundoffM ? 0 : difference;
|
|
174
|
+
});
|
|
175
|
+
const smallerSpanM = Math.min(width, height);
|
|
176
|
+
const coarsening = 2 ** Math.max(0, Math.ceil(Math.log2(Math.max(width, height) / smallerSpanM / labelInitialCellLimit)));
|
|
177
|
+
const sizeM = Math.max(precisionM, smallerSpanM * coarsening);
|
|
178
|
+
const halfWidthM = Math.min(sizeM, width) / 2, halfHeightM = Math.min(sizeM, height) / 2;
|
|
179
|
+
for (let x = bounds.minX; x < bounds.maxX; x += sizeM) {
|
|
180
|
+
for (let y = bounds.minY; y < bounds.maxY; y += sizeM) {
|
|
181
|
+
queue.push(cell({ x: x + halfWidthM, y: y + halfHeightM }, halfWidthM, halfHeightM));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
while (queue.length) {
|
|
185
|
+
const current = queue.pop();
|
|
186
|
+
if (current.distanceM > best.distanceM + roundoffM)
|
|
187
|
+
best = current;
|
|
188
|
+
if (smallerSpanM / 2 - best.distanceM <= precisionM)
|
|
189
|
+
break;
|
|
190
|
+
if (current.maximumM - best.distanceM <= precisionM)
|
|
191
|
+
continue;
|
|
192
|
+
const halfWidth = current.halfWidthM / 2, halfHeight = current.halfHeightM / 2;
|
|
193
|
+
if (current.halfWidthM > current.halfHeightM) {
|
|
194
|
+
for (const dx of [-halfWidth, halfWidth]) {
|
|
195
|
+
queue.push(cell({ x: current.center.x + dx, y: current.center.y }, halfWidth, current.halfHeightM));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (current.halfHeightM > current.halfWidthM) {
|
|
199
|
+
for (const dy of [-halfHeight, halfHeight]) {
|
|
200
|
+
queue.push(cell({ x: current.center.x, y: current.center.y + dy }, current.halfWidthM, halfHeight));
|
|
109
201
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
for (const dy of [-halfHeight, halfHeight]) {
|
|
205
|
+
for (const dx of [-halfWidth, halfWidth]) {
|
|
206
|
+
queue.push(cell({ x: current.center.x + dx, y: current.center.y + dy }, halfWidth, halfHeight));
|
|
207
|
+
}
|
|
116
208
|
}
|
|
117
209
|
}
|
|
118
210
|
}
|
|
119
|
-
|
|
211
|
+
labelPoints.set(source, best.center);
|
|
212
|
+
return best.center;
|
|
120
213
|
}
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { PhysicalDocumentV1 } from "./
|
|
1
|
+
import type { PhysicalDocumentV1 } from "./physical-document.interface.js";
|
|
2
|
+
/** Work reported by allocation, remapping and final document validation. Assets keep their IDs. */
|
|
3
|
+
export declare function remapDocumentWork(source: PhysicalDocumentV1): number;
|
|
2
4
|
export declare function remapDocumentSteps(source: PhysicalDocumentV1, name: string): Generator<number, {
|
|
3
5
|
document: PhysicalDocumentV1;
|
|
4
6
|
warnings: string[];
|
package/dist/identity.js
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { DocumentParseStatus, parsePhysicalDocument } from "./schema.js";
|
|
2
|
+
import { DocumentParseStatus, groupSeatCount, parsePhysicalDocument } from "./schema.js";
|
|
3
|
+
const identityFields = new Set([
|
|
4
|
+
"id",
|
|
5
|
+
"parentId",
|
|
6
|
+
"sectionId",
|
|
7
|
+
"companionForSeatId",
|
|
8
|
+
"assetId",
|
|
9
|
+
"categoryId",
|
|
10
|
+
"rowId",
|
|
11
|
+
"floorId",
|
|
12
|
+
"zoneId",
|
|
13
|
+
"gateId",
|
|
14
|
+
]);
|
|
15
|
+
const identityRecordSchema = z.record(z.string(), z.unknown());
|
|
16
|
+
/** Work reported by allocation, remapping and final document validation. Assets keep their IDs. */
|
|
17
|
+
export function remapDocumentWork(source) {
|
|
18
|
+
const identities = source.sections.length +
|
|
19
|
+
source.collections.length +
|
|
20
|
+
source.areas.length +
|
|
21
|
+
source.decorations.length +
|
|
22
|
+
(source.floors?.length ?? 0) +
|
|
23
|
+
(source.zones?.length ?? 0) +
|
|
24
|
+
(source.segmentedRows?.length ?? 0) +
|
|
25
|
+
(source.categories?.reduce((total, category) => total + 1 + (category.ticketOptions?.length ?? 0), 0) ?? 0) +
|
|
26
|
+
source.seatingGroups.reduce((total, group) => total + 1 + groupSeatCount(group) + ("rows" in group ? group.rows.length : 0), 0);
|
|
27
|
+
return identities * 2 + source.assets.length + 1;
|
|
28
|
+
}
|
|
3
29
|
export function* remapDocumentSteps(source, name) {
|
|
4
30
|
const ids = new Map(), warnings = [];
|
|
5
31
|
function* allocate(value) {
|
|
@@ -11,7 +37,7 @@ export function* remapDocumentSteps(source, name) {
|
|
|
11
37
|
yield* allocate(child);
|
|
12
38
|
return;
|
|
13
39
|
}
|
|
14
|
-
const record =
|
|
40
|
+
const record = identityRecordSchema.parse(value);
|
|
15
41
|
if (typeof record.id === "string")
|
|
16
42
|
ids.set(record.id, crypto.randomUUID());
|
|
17
43
|
yield typeof record.id === "string" ? 1 : 0;
|
|
@@ -29,13 +55,11 @@ export function* remapDocumentSteps(source, name) {
|
|
|
29
55
|
return result;
|
|
30
56
|
}
|
|
31
57
|
if (value && typeof value === "object") {
|
|
32
|
-
const record =
|
|
58
|
+
const record = identityRecordSchema.parse(value);
|
|
33
59
|
yield typeof record.id === "string" ? 1 : 0;
|
|
34
60
|
const result = {};
|
|
35
61
|
for (const [field, child] of Object.entries(record)) {
|
|
36
|
-
if (field === "companionForSeatId" &&
|
|
37
|
-
typeof child === "string" &&
|
|
38
|
-
!ids.has(child)) {
|
|
62
|
+
if (field === "companionForSeatId" && typeof child === "string" && !ids.has(child)) {
|
|
39
63
|
warnings.push("An external companion relationship was cleared.");
|
|
40
64
|
continue;
|
|
41
65
|
}
|
|
@@ -43,22 +67,13 @@ export function* remapDocumentSteps(source, name) {
|
|
|
43
67
|
}
|
|
44
68
|
return result;
|
|
45
69
|
}
|
|
46
|
-
if (typeof value === "string" &&
|
|
47
|
-
[
|
|
48
|
-
"id",
|
|
49
|
-
"parentId",
|
|
50
|
-
"sectionId",
|
|
51
|
-
"companionForSeatId",
|
|
52
|
-
"assetId",
|
|
53
|
-
"categoryId",
|
|
54
|
-
"rowId",
|
|
55
|
-
].includes(key))
|
|
70
|
+
if (typeof value === "string" && identityFields.has(key))
|
|
56
71
|
return ids.get(value) ?? value;
|
|
57
72
|
return value;
|
|
58
73
|
}
|
|
59
74
|
const remapped = yield* remap(source);
|
|
60
75
|
const parsed = parsePhysicalDocument({
|
|
61
|
-
...
|
|
76
|
+
...identityRecordSchema.parse(remapped),
|
|
62
77
|
mapId: crypto.randomUUID(),
|
|
63
78
|
name,
|
|
64
79
|
});
|