@mark1russell7/layout-contract 0.11.0 → 0.11.2

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 CHANGED
@@ -8,7 +8,7 @@ The package has one runtime dependency: `@mark1russell7/rigor-generators`, the h
8
8
 
9
9
  | Part | Exports |
10
10
  |---|---|
11
- | Geometry | `Point`, `Rect`, `Region`, `Side`, `Sides`, `Margin`, `marginSides`, `grow`, `boundsOf`, `regionArea`, `regionPerimeter`, `translate`, `overlapOf`, `segmentsCross`, `crossingPoint`, `pointSegmentDistance`, `nearestOnSegment`, `pointPolylineDistance`, `Ring`, `pointInRing`, `pointInRings`, `pointRegionDistance`, `convexCorners`, `convexOverlap`, `cornersInConvex`, `rectCenter`, `boxCenterDistance` |
11
+ | Geometry | `Point`, `Rect`, `Region`, `Side`, `Sides`, `Margin`, `marginSides`, `grow`, `boundsOf`, `regionArea`, `regionPerimeter`, `translate`, `overlapOf`, `segmentsCross`, `crossingPoint`, `pointSegmentDistance`, `nearestOnSegment`, `pointPolylineDistance`, `PolylinePlace`, `locateOnPolyline`, `pointAlongPolyline`, `chainPolylines`, `Ring`, `pointInRing`, `pointInRings`, `pointRegionDistance`, `convexCorners`, `convexOverlap`, `cornersInConvex`, `rectCenter`, `boxCenterDistance` |
12
12
  | Geometry in 3D | `Point3`, `Box3`, `Rotation3`, `Transform3`, `ORIGIN3`, `NO_ROTATION3`, `NO_TRANSFORM3`, `addPoints3`, `subtractPoints3`, `scalePoint3`, `dot3`, `cross3`, `length3`, `distance3`, `rotationAbout`, `rotatePoint3`, `composeRotations3`, `inverseRotation3`, `normalizeRotation3`, `transformPoint3`, `composeTransforms3`, `inverseTransform3`, `transformMatrix4`, `box3Center`, `box3Volume`, `box3Corners`, `boundsOf3`, `transformedBounds3`, `overlapOf3` |
13
13
  | The shape kinds | `ShapeKind`, `SHAPE_KINDS`, `SHAPE_KIND_IDS`, `ShapeKindSpec`, `ShapeGeometry`, `DEFAULT_SHAPES`, `ShapeSupport`, `ShapeBound`, `RuleLevel`, `ShapeLevel`, `ShapeCheck`, `isShapeKind`, `shapeKindOf`, `shapeKindsOf`, `itemShapeOf`, `shapeKindProblem`, `shapesOf`, `ruleLevel`, `shapeLevel`, `shapeSupportProblems`, `boxArea`, `checkShapes` |
14
14
  | The input `layout-input/1` | `LayoutInput`, `LayoutBox` (`Item` for the packer), `Port`, `portPoint`, `LayoutEdge`, `LayoutContainer`, `Obstacle`, `LayoutCell`, `LayoutGenerator`, `PairGap`, `canonicalInput` |
@@ -114,22 +114,22 @@ The comments of the source name each doc as `docs/<NAME>.md`. The docs are in th
114
114
 
115
115
  | Doc | The subject |
116
116
  |---|---|
117
- | [`docs/BALANCE.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/BALANCE.md) | The balance and stability measures of a pack and of a joint layout |
118
- | [`docs/CELLS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CELLS.md) | The cell measures of a Voronoi treemap: the area error and the compactness of the cells |
119
- | [`docs/CURVES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CURVES.md) | The Hilbert, Moore and Morton curves through a grid, as data |
120
- | [`docs/FRAMES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/FRAMES.md) | The frame record `layout-frame/1`, the frames between two layouts and their laws |
121
- | [`docs/GEOMETRY-3D.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/GEOMETRY-3D.md) | The 3D records: points, boxes, rotations and rigid transforms |
122
- | [`docs/PICTURE.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/PICTURE.md) | The picture record `layout-picture/1`: the placed boxes, the path of each route and the labels that a viewer draws |
123
- | [`docs/NESTED.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/NESTED.md) | The boxes in boxes of an input: the tree for a layout engine, and the flat input with ports for a router |
124
- | [`docs/TEXT.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/TEXT.md) | The text layout of the subpath `/text`: the rules, the units and the measures |
125
- | [`docs/CORPUS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CORPUS.md) | The shared corpus registry, its dimensions and families |
126
- | [`docs/CORPUS-CHECKS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CORPUS-CHECKS.md) | The corpus checks and the split files |
127
- | [`docs/JOINT-CORPUS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/JOINT-CORPUS.md) | The joint corpus |
128
- | [`docs/JOINT-MEASURES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/JOINT-MEASURES.md) | The joint measures |
129
- | [`docs/PORTFOLIO.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/PORTFOLIO.md) | The portfolio and its pick rule |
130
- | [`docs/PROMOTION.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/PROMOTION.md) | The promotion guards |
131
- | [`docs/SHAPES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/SHAPES.md) | The shape kinds, the levels of a rule and what a bound value proves |
132
- | [`docs/STRATEGY-SPACE.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/STRATEGY-SPACE.md) | The strategy space |
133
- | [`docs/VERDICT.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/VERDICT.md) | The verdict over families |
117
+ | [`docs/BALANCE.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/BALANCE.md) | The balance and stability measures of a pack and of a joint layout |
118
+ | [`docs/CELLS.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/CELLS.md) | The cell measures of a Voronoi treemap: the area error and the compactness of the cells |
119
+ | [`docs/CURVES.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/CURVES.md) | The Hilbert, Moore and Morton curves through a grid, as data |
120
+ | [`docs/FRAMES.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/FRAMES.md) | The frame record `layout-frame/1`, the frames between two layouts and their laws |
121
+ | [`docs/GEOMETRY-3D.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/GEOMETRY-3D.md) | The 3D records: points, boxes, rotations and rigid transforms |
122
+ | [`docs/PICTURE.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/PICTURE.md) | The picture record `layout-picture/1`: the placed boxes, the path of each route and the labels that a viewer draws |
123
+ | [`docs/NESTED.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/NESTED.md) | The boxes in boxes of an input: the tree for a layout engine, and the flat input with ports for a router |
124
+ | [`docs/TEXT.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/TEXT.md) | The text layout of the subpath `/text`: the rules, the units and the measures |
125
+ | [`docs/CORPUS.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/CORPUS.md) | The shared corpus registry, its dimensions and families |
126
+ | [`docs/CORPUS-CHECKS.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/CORPUS-CHECKS.md) | The corpus checks and the split files |
127
+ | [`docs/JOINT-CORPUS.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/JOINT-CORPUS.md) | The joint corpus |
128
+ | [`docs/JOINT-MEASURES.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/JOINT-MEASURES.md) | The joint measures |
129
+ | [`docs/PORTFOLIO.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/PORTFOLIO.md) | The portfolio and its pick rule |
130
+ | [`docs/PROMOTION.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/PROMOTION.md) | The promotion guards |
131
+ | [`docs/SHAPES.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/SHAPES.md) | The shape kinds, the levels of a rule and what a bound value proves |
132
+ | [`docs/STRATEGY-SPACE.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/STRATEGY-SPACE.md) | The strategy space |
133
+ | [`docs/VERDICT.md`](https://github.com/metrograph-labs/layout-contract/blob/main/docs/VERDICT.md) | The verdict over families |
134
134
 
135
135
  The formats are in `docs/FORMAT.md` of `packing` and `docs/LAYOUT-RECORDS.md` of `highways`. The TSDoc of `ShapeBound` also has the table of what a bound value proves.
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as CorpusEntry, $t as translate, A as shapeKindsOf, At as convexCorners, B as LayoutInput, Bt as pointInRings, C as checkShapes, Ct as SIDES, D as ruleLevel, Dt as boundsOf, E as itemShapeOf, Et as SizedRect, F as LayoutBox, Ft as grow, G as PairGap, Gt as regionArea, H as PackInput, Ht as pointRegionDistance, I as LayoutCell, It as marginSides, J as canonicalInput, Jt as scaleRect, K as Port, Kt as regionPerimeter, L as LayoutContainer, Lt as nearestOnSegment, M as shapeSupportProblems, Mt as cornersInConvex, N as shapesOf, Nt as crossingPoint, O as shapeKindOf, Ot as boxCenterDistance, P as Item, Pt as dropIndex, Q as ClaimBreak, Qt as toSizedRect, R as LayoutEdge, Rt as overlapOf, S as boxArea, St as Ring, T as isShapeKind, Tt as Sides, U as PackInputOptions, Ut as pointSegmentDistance, V as Obstacle, Vt as pointPolylineDistance, W as PackLink, Wt as rectCenter, X as portPoint, Xt as snapRect, Y as packLinks, Yt as segmentsCross, Z as toPackInput, Zt as toRect, _ as ShapeKind, _t as splitFolds, a as MeasureSpec, at as FamilyCell, b as ShapeLimit, bt as Rect, c as minEffectOf, ct as SplitFold, d as SHAPE_KINDS, dt as corpusHashOf, et as CorpusSplit, f as SHAPE_KIND_IDS, ft as declaredClaimOf, g as ShapeInput, gt as splitFileName, h as ShapeGeometry, ht as leaveOneSeedOut, i as JointMeasureId, it as FamilyBy, j as shapeLevel, jt as convexOverlap, k as shapeKindProblem, kt as clipRing, l as DEFAULT_SHAPES, lt as checkDeclared, m as ShapeCheck, mt as familyOf, n as JOINT_MEASURES, nt as Declares, o as Verdict, ot as SPLIT_SCHEMA, p as ShapeBound, pt as declaredCounts, q as Resize, qt as ringCentroid, r as JOINT_MOVED_MIN, rt as FAMILY_ANY_KIND, s as compareMeasure, st as SplitCorpus, t as Direction, tt as DeclaredClaim, u as RuleLevel, ut as checkSplit, v as ShapeKindSpec, vt as Margin, w as inputShapeLevel, wt as Side, x as ShapeSupport, xt as Region, y as ShapeLevel, yt as Point, z as LayoutGenerator, zt as pointInRing } from "./measures-Qii_B6SV.js";
1
+ import { $ as CorpusEntry, $t as segmentsCross, A as shapeKindsOf, At as chainPolylines, B as LayoutInput, Bt as nearestOnSegment, C as checkShapes, Ct as Ring, D as ruleLevel, Dt as SizedRect, E as itemShapeOf, Et as Sides, F as LayoutBox, Ft as crossingPoint, G as PairGap, Gt as pointPolylineDistance, H as PackInput, Ht as pointAlongPolyline, I as LayoutCell, It as dropIndex, J as canonicalInput, Jt as rectCenter, K as Port, Kt as pointRegionDistance, L as LayoutContainer, Lt as grow, M as shapeSupportProblems, Mt as convexCorners, N as shapesOf, Nt as convexOverlap, O as shapeKindOf, Ot as boundsOf, P as Item, Pt as cornersInConvex, Q as ClaimBreak, Qt as scaleRect, R as LayoutEdge, Rt as locateOnPolyline, S as boxArea, St as Region, T as isShapeKind, Tt as Side, U as PackInputOptions, Ut as pointInRing, V as Obstacle, Vt as overlapOf, W as PackLink, Wt as pointInRings, X as portPoint, Xt as regionPerimeter, Y as packLinks, Yt as regionArea, Z as toPackInput, Zt as ringCentroid, _ as ShapeKind, _t as splitFolds, a as MeasureSpec, at as FamilyCell, b as ShapeLimit, bt as PolylinePlace, c as minEffectOf, ct as SplitFold, d as SHAPE_KINDS, dt as corpusHashOf, en as snapRect, et as CorpusSplit, f as SHAPE_KIND_IDS, ft as declaredClaimOf, g as ShapeInput, gt as splitFileName, h as ShapeGeometry, ht as leaveOneSeedOut, i as JointMeasureId, it as FamilyBy, j as shapeLevel, jt as clipRing, k as shapeKindProblem, kt as boxCenterDistance, l as DEFAULT_SHAPES, lt as checkDeclared, m as ShapeCheck, mt as familyOf, n as JOINT_MEASURES, nn as toSizedRect, nt as Declares, o as Verdict, ot as SPLIT_SCHEMA, p as ShapeBound, pt as declaredCounts, q as Resize, qt as pointSegmentDistance, r as JOINT_MOVED_MIN, rn as translate, rt as FAMILY_ANY_KIND, s as compareMeasure, st as SplitCorpus, t as Direction, tn as toRect, tt as DeclaredClaim, u as RuleLevel, ut as checkSplit, v as ShapeKindSpec, vt as Margin, w as inputShapeLevel, wt as SIDES, x as ShapeSupport, xt as Rect, y as ShapeLevel, yt as Point, z as LayoutGenerator, zt as marginSides } from "./measures-DXg0-L2U.js";
2
2
  import { AnyOption, BooleanOption, DeclaredStrategy, EnumOption, EnumerateOptions, EnumerateOptions as EnumerateOptions$1, GridOptions, KindOptions, KindOptions as KindOptions$1, ListItem, MemberRule, NoDefault, NoDefaultReason, NumberOption, OptionDeclaration, OptionIssue, OptionRef, OptionScale, OptionSchema, OptionSetting, OptionSupports, ParamKind, ParamValue, ParamWhen, STRATEGY_SPACE_SCHEMA, SampleOptions, ShapeFilter, SpaceConstraint, SpaceParam, SpaceSize, SpaceSize as SpaceSize$1, SpaceSizeOptions, SpaceSizeOptions as SpaceSizeOptions$1, SpaceStage, StageChoice, StageOption, StrategyConfig, StrategyConfig as StrategyConfig$1, StrategySpace, StrategySpace as StrategySpace$1, SweepOptions, ValueOption, canonicalConfig, checkConfig, checkOptions, checkSchema, clampOptions, configId, declarationIssues, joinConfigs, listOptions, optionDefaults, optionIssue, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, productSpace, splitConfig, sweepGrid, sweepOf, sweepValues } from "@mark1russell7/strategy-space";
3
3
  /**
4
4
  * The 3D records: points, boxes with their sides along the axes, rotations and rigid transforms.
@@ -2228,5 +2228,5 @@ export declare function checkSurvey(v: unknown): string[];
2228
2228
  export declare function nameAfterStage(id: string): string;
2229
2229
  /** This function gives the findings of a good survey. `checkSurvey` examines the survey first. */
2230
2230
  export declare function surveyFindings(survey: MeasureSurvey): SurveyFindings;
2231
- export { type AnyOption, type BooleanOption, ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, type DeclaredStrategy, Declares, Direction, type EnumOption, type EnumerateOptions, FAMILY_ANY_KIND, FamilyBy, FamilyCell, type GridOptions, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, type KindOptions, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, type ListItem, Margin, MeasureSpec, type MemberRule, type NoDefault, type NoDefaultReason, type NumberOption, Obstacle, type OptionDeclaration, type OptionIssue, type OptionRef, type OptionScale, type OptionSchema, type OptionSetting, type OptionSupports, PackInput, PackInputOptions, PackLink, PairGap, type ParamKind, type ParamValue, type ParamWhen, Point, Port, Rect, Region, Resize, Ring, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, type SampleOptions, ShapeBound, ShapeCheck, type ShapeFilter, ShapeGeometry, ShapeInput, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeLimit, ShapeSupport, Side, Sides, SizedRect, type SpaceConstraint, type SpaceParam, type SpaceSize, type SpaceSizeOptions, type SpaceStage, SplitCorpus, SplitFold, type StageChoice, type StageOption, type StrategyConfig, type StrategySpace, type SweepOptions, type ValueOption, Verdict, boundsOf, boxArea, boxCenterDistance, canonicalConfig, canonicalInput, checkConfig, checkDeclared, checkOptions, checkSchema, checkShapes, checkSplit, clampOptions, clipRing, compareMeasure, configId, convexCorners, convexOverlap, cornersInConvex, corpusHashOf, crossingPoint, declarationIssues, declaredClaimOf, declaredCounts, dropIndex, familyOf, grow, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, listOptions, marginSides, minEffectOf, nearestOnSegment, optionDefaults, optionIssue, overlapOf, packLinks, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, pointInRing, pointInRings, pointPolylineDistance, pointRegionDistance, pointSegmentDistance, portPoint, productSpace, rectCenter, regionArea, regionPerimeter, ringCentroid, ruleLevel, scaleRect, segmentsCross, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, snapRect, splitConfig, splitFileName, splitFolds, sweepGrid, sweepOf, sweepValues, toPackInput, toRect, toSizedRect, translate };
2231
+ export { type AnyOption, type BooleanOption, ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, type DeclaredStrategy, Declares, Direction, type EnumOption, type EnumerateOptions, FAMILY_ANY_KIND, FamilyBy, FamilyCell, type GridOptions, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, type KindOptions, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, type ListItem, Margin, MeasureSpec, type MemberRule, type NoDefault, type NoDefaultReason, type NumberOption, Obstacle, type OptionDeclaration, type OptionIssue, type OptionRef, type OptionScale, type OptionSchema, type OptionSetting, type OptionSupports, PackInput, PackInputOptions, PackLink, PairGap, type ParamKind, type ParamValue, type ParamWhen, Point, PolylinePlace, Port, Rect, Region, Resize, Ring, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, type SampleOptions, ShapeBound, ShapeCheck, type ShapeFilter, ShapeGeometry, ShapeInput, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeLimit, ShapeSupport, Side, Sides, SizedRect, type SpaceConstraint, type SpaceParam, type SpaceSize, type SpaceSizeOptions, type SpaceStage, SplitCorpus, SplitFold, type StageChoice, type StageOption, type StrategyConfig, type StrategySpace, type SweepOptions, type ValueOption, Verdict, boundsOf, boxArea, boxCenterDistance, canonicalConfig, canonicalInput, chainPolylines, checkConfig, checkDeclared, checkOptions, checkSchema, checkShapes, checkSplit, clampOptions, clipRing, compareMeasure, configId, convexCorners, convexOverlap, cornersInConvex, corpusHashOf, crossingPoint, declarationIssues, declaredClaimOf, declaredCounts, dropIndex, familyOf, grow, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, listOptions, locateOnPolyline, marginSides, minEffectOf, nearestOnSegment, optionDefaults, optionIssue, overlapOf, packLinks, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, pointAlongPolyline, pointInRing, pointInRings, pointPolylineDistance, pointRegionDistance, pointSegmentDistance, portPoint, productSpace, rectCenter, regionArea, regionPerimeter, ringCentroid, ruleLevel, scaleRect, segmentsCross, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, snapRect, splitConfig, splitFileName, splitFolds, sweepGrid, sweepOf, sweepValues, toPackInput, toRect, toSizedRect, translate };
2232
2232
  //# sourceMappingURL=index.d.ts.map
package/build/index.js CHANGED
@@ -377,6 +377,110 @@ function pointPolylineDistance(p, points) {
377
377
  for (let i = 1; i < points.length; i++) best = Math.min(best, pointSegmentDistance(p, points[i - 1], points[i]));
378
378
  return best;
379
379
  }
380
+ /**
381
+ * This function gives the place on a polyline nearest to `p`: the point, its length along the polyline, the distance and the side.
382
+ * When two segments are at the same distance, the first segment wins. An empty polyline gives `undefined`.
383
+ * A street address uses it: the length along the street line of each known number, and its side of the street.
384
+ */
385
+ function locateOnPolyline(p, points) {
386
+ const first = points[0];
387
+ if (first === void 0) return void 0;
388
+ if (points.length === 1) return {
389
+ point: first,
390
+ along: 0,
391
+ distance: Math.hypot(p.x - first.x, p.y - first.y),
392
+ segment: 0,
393
+ side: 0
394
+ };
395
+ let best;
396
+ let run = 0;
397
+ for (let i = 1; i < points.length; i++) {
398
+ const a = points[i - 1];
399
+ const b = points[i];
400
+ const length = Math.hypot(b.x - a.x, b.y - a.y);
401
+ const near = nearestOnSegment(p, a, b);
402
+ const distance = pointSegmentDistance(p, a, b);
403
+ if (best === void 0 || distance < best.distance) best = {
404
+ point: near,
405
+ along: run + Math.hypot(near.x - a.x, near.y - a.y),
406
+ distance,
407
+ segment: i - 1,
408
+ side: length === 0 ? 0 : side(a, b, p)
409
+ };
410
+ run += length;
411
+ }
412
+ return best;
413
+ }
414
+ /**
415
+ * This function gives the point at the length `along` of a polyline, moved by `offset` at a right angle to its segment.
416
+ * A positive `offset` moves the point to the side 1 of `locateOnPolyline`, and a negative `offset` to the side -1.
417
+ *
418
+ * An `along` less than 0 gives the first point, and an `along` more than the length gives the last point. The offset then uses the segment at that end.
419
+ * Segments of length 0 have no direction, so the offset skips them. A polyline with no direction gives its point with no offset.
420
+ * An empty polyline gives `undefined`.
421
+ */
422
+ function pointAlongPolyline(points, along, offset = 0) {
423
+ const first = points[0];
424
+ if (first === void 0) return void 0;
425
+ let run = 0;
426
+ let last;
427
+ for (let i = 1; i < points.length; i++) {
428
+ const a = points[i - 1];
429
+ const b = points[i];
430
+ const length = Math.hypot(b.x - a.x, b.y - a.y);
431
+ if (length === 0) continue;
432
+ if (along <= run + length) return offsetPoint(a, b, length, Math.max(0, along - run), offset);
433
+ last = {
434
+ a,
435
+ b,
436
+ length
437
+ };
438
+ run += length;
439
+ }
440
+ if (last === void 0) return first;
441
+ return offsetPoint(last.a, last.b, last.length, last.length, offset);
442
+ }
443
+ /** This function gives the point at the length `at` of the segment `ab`, moved by `offset` to the side 1 of the segment. */
444
+ function offsetPoint(a, b, length, at, offset) {
445
+ const ux = (b.x - a.x) / length;
446
+ const uy = (b.y - a.y) / length;
447
+ return {
448
+ x: a.x + at * ux - offset * uy,
449
+ y: a.y + at * uy + offset * ux
450
+ };
451
+ }
452
+ /**
453
+ * This function joins polylines at their shared end points into longer polylines, for example the ways of one street.
454
+ * Two ends join only when their coordinates are equal. A join reverses a polyline when its direction is opposite.
455
+ * The first polyline that is left starts each chain, and the chain grows at both ends with the first polyline that touches an end.
456
+ * Thus a branch point keeps one branch in the chain, and the other branches start their own chains. An empty polyline gives no chain.
457
+ */
458
+ function chainPolylines(lines) {
459
+ const same = (a, b) => a.x === b.x && a.y === b.y;
460
+ const rest = lines.filter((line) => line.length > 0).map((line) => [...line]);
461
+ const chains = [];
462
+ for (let chain = rest.shift(); chain !== void 0; chain = rest.shift()) {
463
+ let grew = true;
464
+ while (grew) {
465
+ grew = false;
466
+ for (let i = 0; i < rest.length; i++) {
467
+ const line = rest[i];
468
+ const start = chain[0];
469
+ const end = chain.at(-1);
470
+ if (same(line[0], end)) chain = [...chain, ...line.slice(1)];
471
+ else if (same(line.at(-1), end)) chain = [...chain, ...line.toReversed().slice(1)];
472
+ else if (same(line.at(-1), start)) chain = [...line.slice(0, -1), ...chain];
473
+ else if (same(line[0], start)) chain = [...line.toReversed().slice(0, -1), ...chain];
474
+ else continue;
475
+ rest.splice(i, 1);
476
+ grew = true;
477
+ break;
478
+ }
479
+ }
480
+ chains.push(chain);
481
+ }
482
+ return chains;
483
+ }
380
484
  /** This function tells if the point (`x`, `y`) is inside a ring, by the even-odd rule. A ring can be concave. The answer for a point on the border can be each value. */
381
485
  function pointInRing(x, y, ring) {
382
486
  return pointInRings(x, y, [ring]);
@@ -7202,6 +7306,6 @@ function surveyFindings(survey) {
7202
7306
  units
7203
7307
  };
7204
7308
  }
7205
- export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CELL_MEASURE_SUFFIXES, CELL_SOURCE, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, CORPUS_MANIFEST_SCHEMA, CURVE_MAX_SIDE, CURVE_SYMMETRIES, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, FLATTEN_SIDES, FRAME_SCHEMA, FRAME_STATES, HARD_RULE_VERSION, HILBERT_CURVE, HILBERT_PATTERN, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, JOINT_SOURCE, LABEL_ALIGNS, MEASURE_REGISTRY, MEASURE_SURVEY_SCHEMA, MOORE_CURVE, MOORE_PATTERN, MORTON_CURVE, NODE_POSITIONS_DIMENSION, NOISE_KINDS, NO_FINITE_RANGE, NO_ROTATION3, NO_TRANSFORM3, NO_UNIT, ORIGIN3, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, PATH_KINDS, PICTURE_SCHEMA, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, REFUSED_PROBE, SHAPE_KINDS, SHAPE_KIND_IDS, SHARE_UNIT, SIDES, SPLIT_SCHEMA, SQUARE_COMPACTNESS, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, addPoints3, applyPack, applySymmetry, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boundsOf3, box3Center, box3Corners, box3Volume, boxArea, boxCenterDistance, boxTree, canonicalConfig, canonicalInput, canonicalJson, carryRecord, catalogChoices, catalogDefaults, catalogKey, catalogOptions, cellMeasureEntries, cellMeasureSpecs, cellMeasures, cellsOf, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkPath, checkPicture, checkRegistry, checkSchema, checkShapes, checkSpace, checkSplit, checkSurvey, circleOverlaps, circlesOutside, clampOptions, clipRing, compareMeasure, composeFamily, composeRotations3, composeTransforms3, configId, convexCorners, convexOverlap, cornersInConvex, corpusHashOf, corpusManifestText, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, countResizeBreaks, createFamilyRegistry, cross3, crossingPoint, cubicAt, curveCell, curveCells, curveIndex, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, defaultNormalize, dimensionAt, dimensionSupports, dimensionUnit, distance3, documentHash, dot3, dropIndex, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fingerprintOf, fixedPointMove, flatPortId, flattenInput, fnv1a32, frameAt, frameMove, frameOf, grow, hardRuleOf, hilbertCell, hilbertIndex, inputShapeLevel, inverseRotation3, inverseSymmetry, inverseTransform3, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, length3, levelsOf, lineJson, listOptions, manifestText, marginSides, measureEntry, minEffectOf, mooreCell, mooreIndex, mortonCell, mortonIndex, mulberry32, nameAfterStage, nearestGaps, nearestOnSegment, normalizeMeasure, normalizeRotation3, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, outputOf, overlapOf, overlapOf3, ownerDimension, packHard, packLinks, packOutputForm, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, parseLayoutRecord, parsePicture, parseStrategyCatalog, pathBounds, pathEnd, pathOf, pathStart, perChange, pickMoves, pictureBounds, pictureOf, placedCircle, placedConvex, placedRect, pointInRing, pointInRings, pointPolylineDistance, pointRegionDistance, pointSegmentDistance, portPoint, portfolio, probeHash, procrustesOf, productSpace, randomInt, rectCenter, rectInRegion, regionArea, regionHitsRect, regionPerimeter, resizeBox, resizeProblems, resolveDimensions, ringCentroid, rotatePoint3, rotationAbout, ruleLevel, samplePath, scalePoint3, scaleRect, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeFits, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, siblingEdges, sizeBoundsOf, sizeFits, snapRect, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, subtractPoints3, surveyFindings, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, toSvgPath, topBoxes, transformMatrix4, transformPoint3, transformedBounds3, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnResize, turnSide, unitFault, verdict, writeStrategyCatalog };
7309
+ export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CELL_MEASURE_SUFFIXES, CELL_SOURCE, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, CORPUS_MANIFEST_SCHEMA, CURVE_MAX_SIDE, CURVE_SYMMETRIES, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, FLATTEN_SIDES, FRAME_SCHEMA, FRAME_STATES, HARD_RULE_VERSION, HILBERT_CURVE, HILBERT_PATTERN, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, JOINT_SOURCE, LABEL_ALIGNS, MEASURE_REGISTRY, MEASURE_SURVEY_SCHEMA, MOORE_CURVE, MOORE_PATTERN, MORTON_CURVE, NODE_POSITIONS_DIMENSION, NOISE_KINDS, NO_FINITE_RANGE, NO_ROTATION3, NO_TRANSFORM3, NO_UNIT, ORIGIN3, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, PATH_KINDS, PICTURE_SCHEMA, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, REFUSED_PROBE, SHAPE_KINDS, SHAPE_KIND_IDS, SHARE_UNIT, SIDES, SPLIT_SCHEMA, SQUARE_COMPACTNESS, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, addPoints3, applyPack, applySymmetry, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boundsOf3, box3Center, box3Corners, box3Volume, boxArea, boxCenterDistance, boxTree, canonicalConfig, canonicalInput, canonicalJson, carryRecord, catalogChoices, catalogDefaults, catalogKey, catalogOptions, cellMeasureEntries, cellMeasureSpecs, cellMeasures, cellsOf, chainPolylines, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkPath, checkPicture, checkRegistry, checkSchema, checkShapes, checkSpace, checkSplit, checkSurvey, circleOverlaps, circlesOutside, clampOptions, clipRing, compareMeasure, composeFamily, composeRotations3, composeTransforms3, configId, convexCorners, convexOverlap, cornersInConvex, corpusHashOf, corpusManifestText, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, countResizeBreaks, createFamilyRegistry, cross3, crossingPoint, cubicAt, curveCell, curveCells, curveIndex, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, defaultNormalize, dimensionAt, dimensionSupports, dimensionUnit, distance3, documentHash, dot3, dropIndex, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fingerprintOf, fixedPointMove, flatPortId, flattenInput, fnv1a32, frameAt, frameMove, frameOf, grow, hardRuleOf, hilbertCell, hilbertIndex, inputShapeLevel, inverseRotation3, inverseSymmetry, inverseTransform3, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, length3, levelsOf, lineJson, listOptions, locateOnPolyline, manifestText, marginSides, measureEntry, minEffectOf, mooreCell, mooreIndex, mortonCell, mortonIndex, mulberry32, nameAfterStage, nearestGaps, nearestOnSegment, normalizeMeasure, normalizeRotation3, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, outputOf, overlapOf, overlapOf3, ownerDimension, packHard, packLinks, packOutputForm, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, parseLayoutRecord, parsePicture, parseStrategyCatalog, pathBounds, pathEnd, pathOf, pathStart, perChange, pickMoves, pictureBounds, pictureOf, placedCircle, placedConvex, placedRect, pointAlongPolyline, pointInRing, pointInRings, pointPolylineDistance, pointRegionDistance, pointSegmentDistance, portPoint, portfolio, probeHash, procrustesOf, productSpace, randomInt, rectCenter, rectInRegion, regionArea, regionHitsRect, regionPerimeter, resizeBox, resizeProblems, resolveDimensions, ringCentroid, rotatePoint3, rotationAbout, ruleLevel, samplePath, scalePoint3, scaleRect, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeFits, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, siblingEdges, sizeBoundsOf, sizeFits, snapRect, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, subtractPoints3, surveyFindings, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, toSvgPath, topBoxes, transformMatrix4, transformPoint3, transformedBounds3, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnResize, turnSide, unitFault, verdict, writeStrategyCatalog };
7206
7310
 
7207
7311
  //# sourceMappingURL=index.js.map