@mark1russell7/cartography 0.1.2 → 0.1.4

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
@@ -44,6 +44,9 @@ const svg = renderMap(map);
44
44
  | `checkMap(map)` | Nothing. It throws a `MapError` for a map that is not correct. |
45
45
  | `frameView(frame)` | The functions between the Earth and the paper, and the direction of north. |
46
46
  | `frameBBox(frame)` | The box on the Earth around the frame, for a fetch of the data of a map. |
47
+ | `frameAround(points, options)` | The frame with the largest scale that shows each point inside the margin. The option `roundScale` rounds the scale up. |
48
+ | `niceScale(value)` | The smallest round scale that is not less than the value, from `NICE_SCALE_STEPS`. |
49
+ | `geometryPath(view, geometry, options)` | The SVG path data of a line or an area on the paper of a frame. |
47
50
  | `matchesFilter(filter, feature)` | `true` when the feature matches the filter. |
48
51
  | `checkFilter(value)` | Nothing. It throws a `MapError` for a value that is not a `Filter`. |
49
52
  | `attributionLines(map)` | The lines of the attribution block: the scale, the projection and each source. |
@@ -114,6 +117,33 @@ const svg = renderMap({ ...map, frame, legendPlace: fit.legendPlace }, { labelFo
114
117
  - `mapMargins` gives the space around the frame for each place. The label font measures the legend texts.
115
118
  - `fit.space` is the index of the space of the frame. In this example, the value 1 tells to print the map in landscape.
116
119
 
120
+ ## A frame for a box on the Earth
121
+
122
+ With no `heightMm`, `frameAround` fits the width only, and the height follows from the points. For a box in degrees, give its 4 corners and the middles of its north and south edges. An edge of the box is a curve on most planes. `geometryPath` gives the SVG path data of a geometry on the frame.
123
+
124
+ ```ts
125
+ // A made-up box of approximately 8 km by 4.4 km, on a map of 180 mm width.
126
+ const box = { south: 44.98, west: 9.95, north: 45.02, east: 10.05 };
127
+ const middle = (box.west + box.east) / 2;
128
+ const points = [
129
+ { lat: box.south, lon: box.west }, { lat: box.south, lon: box.east },
130
+ { lat: box.north, lon: box.west }, { lat: box.north, lon: box.east },
131
+ { lat: box.north, lon: middle }, { lat: box.south, lon: middle },
132
+ ];
133
+ const frame = frameAround(points, { projection: azimuthalEquidistant, widthMm: 180, roundScale: false });
134
+ const d = geometryPath(frameView(frame), { type: "Polygon", coordinates: [[[9.97, 44.99], [10.03, 44.99], [10.03, 45.01], [9.97, 44.99]]] });
135
+ const svg = `<svg viewBox="0 0 ${frame.widthMm} ${frame.heightMm}"><path d="${d}" fill="none" stroke="black"/></svg>`;
136
+ ```
137
+
138
+ - The center of the frame is the middle of the box of the points in degrees, not on the plane. The option `center` sets a different center.
139
+ - The frame has the center at its middle. The point that is farthest from the center in x touches a side edge.
140
+ - For points that are symmetric about the center, a point touches each of the two side edges.
141
+ - The height is the reach of the points in y on the two sides of the center, with the margins. It is rounded up to a whole millimetre.
142
+ - With `roundScale`, the default, the scale goes up to a round value. Then the points do not fill the width.
143
+ - Each ring of a polygon is `M` and its first point, `L` and each next point, and `Z`. A line has no `Z`. A point gives no path data.
144
+ - The values are in millimetres from the top left corner of the frame, with 2 decimals. The option `decimals` changes the number.
145
+ - `renderMap` uses the same path data for its lines and areas. `geometryPath` does not clip to the frame.
146
+
117
147
  ## An atlas of a large area
118
148
 
119
149
  An area that is too large for one page at a good scale goes on the pages of an atlas. `atlasPages` gives a grid of frames on the plane of one projection.
package/dist/index.d.ts CHANGED
@@ -63,6 +63,42 @@ export declare function frameView(frame: Frame): FrameView;
63
63
  * @throws MapError - The code is `frame`.
64
64
  */
65
65
  export declare function frameBBox(frame: Frame): BBox;
66
+ /** The options of `frameAround`. */
67
+ interface FrameAroundOptions {
68
+ /** This function gives the projection of the frame for its center, for example `azimuthalEquidistant` of geo. */
69
+ readonly projection: (center: LatLon) => Projection;
70
+ /** The width of the map on the paper, in millimetres. */
71
+ readonly widthMm: number;
72
+ /**
73
+ * The height of the map on the paper, in millimetres. With no height, the scale fits the width only. Then the height
74
+ * is the extent of the points in y at that scale, with the margins. It is rounded up to a whole millimetre.
75
+ */
76
+ readonly heightMm?: number;
77
+ /** The space between each point and the edge of the frame, in millimetres. The default is 0. */
78
+ readonly marginMm?: number;
79
+ /** The center of the frame. The default is the middle of the box of the points. */
80
+ readonly center?: LatLon;
81
+ /** The value `true`, the default, rounds the scale up to a value of `NICE_SCALE_STEPS`. */
82
+ readonly roundScale?: boolean;
83
+ }
84
+ /** The first digits of a round scale, for example 1:25,000 or 1:1,500,000. `frameAround` rounds a scale up to one of them. */
85
+ export declare const NICE_SCALE_STEPS: readonly number[];
86
+ /** This function gives the smallest round scale that is not less than the value, from `NICE_SCALE_STEPS`. */
87
+ export declare function niceScale(value: number): number;
88
+ /**
89
+ * This function gives the frame with the largest scale that shows each point inside the margin.
90
+ *
91
+ * - The center is the middle of the box of the points, or the option `center`. The frame has the center at the middle
92
+ * of the paper, so the space on the two sides of the center is the same.
93
+ * - The function finds the scale on the plane of the projection, as `frameView` uses it.
94
+ * - With `roundScale`, the scale goes up to a round value. A larger denominator shows more ground, so each point stays inside.
95
+ * - With no `heightMm`, the scale fits the width only, and the height follows from the points. For a box on the Earth,
96
+ * the points are its 4 corners and the middles of its north and south edges.
97
+ *
98
+ * @throws MapError - The code is `frame`. The reason is no point, a size or a margin that is not correct, or all the
99
+ * points at the center. With no height, the reason can also be all the points on one vertical line, or no height.
100
+ */
101
+ export declare function frameAround(points: readonly LatLon[], options: FrameAroundOptions): Frame;
66
102
  /** The units of the scale bars of a map. `both` gives a metric bar and an imperial bar. */
67
103
  type ScaleBarUnits = "metric" | "imperial" | "both" | "none";
68
104
  /** The length of a scale bar on the ground and its label. */
@@ -206,7 +242,7 @@ export declare function atlasIndexFrame(atlas: Atlas, widthMm: number, heightMm:
206
242
  * - `frame`: the scale or the size of a frame is not a finite number more than 0.
207
243
  * - `id`: an identifier is not lower case letters, digits and hyphens, or two layers have the same identifier.
208
244
  * - `filter`: a filter is not one of the forms of `Filter`.
209
- * - `style`: a style draws nothing, or a size, a gray level or a dash is not correct.
245
+ * - `style`: a style draws nothing, or a size, a gray level, a dash or the count of decimals is not correct.
210
246
  * - `source`: a layer has no source, or its source has no title or no license.
211
247
  * - `label`: a label rule, a label font or an edge text is not correct.
212
248
  * - `atlas`: the radius or the overlap of an atlas is not correct.
@@ -465,6 +501,25 @@ type LegendPlace = "below" | "side";
465
501
  * @throws MapError - The code tells the reason.
466
502
  */
467
503
  export declare function checkMap(map: MapDocument): void;
504
+ /** The options of `geometryPath`. */
505
+ interface PathOptions {
506
+ /** The number of decimals of each millimetre value: an integer from 0 to 10. The default is 2, as in `renderMap`. */
507
+ readonly decimals?: number;
508
+ }
509
+ /**
510
+ * This function gives the SVG path data (the attribute `d`) of a geometry on the paper of a frame, in millimetres.
511
+ * `renderMap` uses the same path data for its lines and areas.
512
+ *
513
+ * - Each ring of a polygon is `M` and its first point, `L` and each next point, and `Z`: `M10 20L30 20L30 40Z`.
514
+ * - A line is the same with no `Z`.
515
+ * - A polygon with holes and a multi-polygon give one path data. Use `fill-rule="evenodd"` to fill it.
516
+ * - A point gives no path data. A geometry collection gives the path data of each of its geometries.
517
+ * - The function does not clip. A point out of the frame gives values out of the frame.
518
+ *
519
+ * @throws MapError - The code is `style`. The number of decimals is not an integer from 0 to 10.
520
+ * @throws GeoError - A position is not correct for the projection.
521
+ */
522
+ export declare function geometryPath(view: FrameView, geometry: Geometry, options?: PathOptions): string;
468
523
  /** The options of `renderMap` and `mapLabels`. */
469
524
  interface RenderOptions {
470
525
  /** The font of the labels. A map with a label rule needs it. */
@@ -546,5 +601,5 @@ export declare function attributionLines(map: MapDocument): string[];
546
601
  * @throws GeoError - A position is not correct for the projection.
547
602
  */
548
603
  export declare function renderMap(map: MapDocument, options?: RenderOptions): string;
549
- export type { Atlas, AtlasPage, AtlasPlan, EdgeMark, FillStyle, Filter, FilterValue, FitOptions, Frame, FrameEdge, FrameFit, FrameView, GeometryKind, HatchStyle, LabelFont, LabelLayer, LabelPlacement, LabelRule, Layer, LegendPlace, MapDocument, MapErrorCode, MapMargins, MapSpace, PaperPoint, PlacedLabel, PointStyle, PointSymbol, RenderOptions, ScaleBarLength, ScaleBarUnits, Source, StrokeStyle, Style };
604
+ export type { Atlas, AtlasPage, AtlasPlan, EdgeMark, FillStyle, Filter, FilterValue, FitOptions, Frame, FrameAroundOptions, FrameEdge, FrameFit, FrameView, GeometryKind, HatchStyle, LabelFont, LabelLayer, LabelPlacement, LabelRule, Layer, LegendPlace, MapDocument, MapErrorCode, MapMargins, MapSpace, PaperPoint, PathOptions, PlacedLabel, PointStyle, PointSymbol, RenderOptions, ScaleBarLength, ScaleBarUnits, Source, StrokeStyle, Style };
550
605
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/frame.ts","../src/marks.ts","../src/atlas.ts","../src/errors.ts","../src/filter.ts","../src/labels.ts","../src/style.ts","../src/render.ts"],"mappings":";;;;;;;;;;UAWiB;;WAEN,YAAY;;WAEZ,QAAQ;;WAER;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;;UAIM;;WAEN,OAAO;;WAEP;;WAEA;;WAEA,UAAU,OAAO,WAAW;;WAE5B,YAAY,OAAO,eAAe;;WAElC;;;wBAIK,WAAW,OAAO;;;;;;;;;;;;wBAqBlB,UAAU,OAAO,QAAQ;;;;;;;wBA2BzB,UAAU,OAAO,QAAQ;;KCvF7B;;UAGK;;WAEN;;WAEA;;;wBAOK,WAAW;;;;;;;wBAeX,eAAe,mBAAmB,+BAA+B;;qBAepE;;wBAGG,YAAY,WAAW,WAAW,QAAQ,gBAAgB;;wBAW1D,cAAc,WAAW,WAAW;;KAUxC;;qBAGC,sBAAsB;;qBAGtB;;UASI;;WAEN,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;wBASK,UAAU,iBAAiB,kBAAkB,OAAO,SAAS,QAAQ,OAAO,sBAAsB,UAAU,0BAA0B;;UCrGrI;;WAEN,YAAY;;WAEZ,QAAQ;;WAER;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;;;;WAKN;;WAEA;;WAEA;;WAEA,OAAO;;;;;WAKP,W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,UAAU;;wBAQV,iBAAiB,QAAQ;;wBAMzB,aAAa,YAAY,OAAO;;wBAYhC,YAAY,OAAO,YAAY,WAAW;;UChIzC;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA,mBAAmB;;WAEnB,OAAO;;WAEP,QAAQ;;WAER,SAAS;;WAET;;WAEA;;WAEA,QAAQ;;;UAIF;;WAEN;;WAEA;;WAEA,OAAO;;WAEP,iBAAiB;;WAEjB,WAAW;;WAEX;;WAEA,cAAc;;;;;WAKd,QAAQ,SAAS,QAAQ,OAAO;;;KAI/B;;;;;;;wBAsBI,SAAS,KAAK;;UAyHb;;WAEN,YAAY;;;;;;;;wBAqCP,UAAU,KAAK,aAAa,UAAS,gBAAqB;;UA4EzD;;WAEN;;WAEA;;WAEA;;;;;;;;;;;wBAoBK,WAAW,KAAK,aAAa,UAAS,gBAAqB;;UAM1D;WACN;WACA;;;UAIM;;WAEN,YAAY;;WAEZ,kBAAkB;;;UAIZ;WACN;WACA;WACA,aAAa;;WAEb;;;;;;;;;;;;;wBAcK,SAAS,KAAK,aAAa,iBAAiB,YAAY,UAAS,aAAkB;;wBA2BnF,iBAAiB,KAAK;;;;;;;;;;;;;;;;wBA2BtB,UAAU,KAAK,aAAa,UAAS"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/frame.ts","../src/marks.ts","../src/atlas.ts","../src/errors.ts","../src/filter.ts","../src/labels.ts","../src/style.ts","../src/render.ts"],"mappings":";;;;;;;;;;UAWiB;;WAEN,YAAY;;WAEZ,QAAQ;;WAER;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;;UAIM;;WAEN,OAAO;;WAEP;;WAEA;;WAEA,UAAU,OAAO,WAAW;;WAE5B,YAAY,OAAO,eAAe;;WAElC;;;wBAIK,WAAW,OAAO;;;;;;;;;;;;wBAqBlB,UAAU,OAAO,QAAQ;;;;;;;wBA2BzB,UAAU,OAAO,QAAQ;;UAaxB;;WAEN,aAAa,QAAQ,W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AM1D;WACN;WACA;;;UAIM;;WAEN,YAAY;;WAEZ,kBAAkB;;;UAIZ;WACN;WACA;WACA,aAAa;;WAEb;;;;;;;;;;;;;wBAcK,SAAS,KAAK,aAAa,iBAAiB,YAAY,UAAS,aAAkB;;wBA2BnF,iBAAiB,KAAK;;;;;;;;;;;;;;;;wBA2BtB,UAAU,KAAK,aAAa,UAAS"}
package/dist/index.js CHANGED
@@ -100,6 +100,93 @@ function frameBBox(frame) {
100
100
  }
101
101
  return bboxOfPoints(points);
102
102
  }
103
+ /** The first digits of a round scale, for example 1:25,000 or 1:1,500,000. `frameAround` rounds a scale up to one of them. */
104
+ const NICE_SCALE_STEPS = [
105
+ 1,
106
+ 1.25,
107
+ 1.5,
108
+ 2,
109
+ 2.5,
110
+ 3,
111
+ 4,
112
+ 5,
113
+ 6,
114
+ 7.5
115
+ ];
116
+ /** This function gives the smallest round scale that is not less than the value, from `NICE_SCALE_STEPS`. */
117
+ function niceScale(value) {
118
+ if (!(Number.isFinite(value) && value > 0)) throw new MapError("frame", `The scale ${value} is not a finite number more than 0`);
119
+ const power = 10 ** Math.floor(Math.log10(value));
120
+ for (const step of [...NICE_SCALE_STEPS, 10]) if (step * power >= value * (1 - 1e-9)) return step * power;
121
+ return 10 * power;
122
+ }
123
+ /**
124
+ * This function gives the frame with the largest scale that shows each point inside the margin.
125
+ *
126
+ * - The center is the middle of the box of the points, or the option `center`. The frame has the center at the middle
127
+ * of the paper, so the space on the two sides of the center is the same.
128
+ * - The function finds the scale on the plane of the projection, as `frameView` uses it.
129
+ * - With `roundScale`, the scale goes up to a round value. A larger denominator shows more ground, so each point stays inside.
130
+ * - With no `heightMm`, the scale fits the width only, and the height follows from the points. For a box on the Earth,
131
+ * the points are its 4 corners and the middles of its north and south edges.
132
+ *
133
+ * @throws MapError - The code is `frame`. The reason is no point, a size or a margin that is not correct, or all the
134
+ * points at the center. With no height, the reason can also be all the points on one vertical line, or no height.
135
+ */
136
+ function frameAround(points, options) {
137
+ const { widthMm, heightMm } = options;
138
+ const margin = options.marginMm ?? 0;
139
+ if (points.length === 0) throw new MapError("frame", "The frame has no point to show");
140
+ if (!(Number.isFinite(margin) && margin >= 0)) throw new MapError("frame", `The margin ${margin} is not a finite number from 0`);
141
+ checkFrame({
142
+ projection: options.projection(points[0]),
143
+ center: points[0],
144
+ scale: 1,
145
+ widthMm,
146
+ heightMm: heightMm ?? 1
147
+ });
148
+ const halfWidth = widthMm / 2 - margin;
149
+ const halfHeight = heightMm === void 0 ? Number.POSITIVE_INFINITY : heightMm / 2 - margin;
150
+ if (halfWidth <= 0 || halfHeight <= 0) throw new MapError("frame", `The margin ${margin} mm leaves no space in the frame`);
151
+ const box = bboxOfPoints(points);
152
+ const center = options.center ?? {
153
+ lat: (box.south + box.north) / 2,
154
+ lon: (box.west + box.east) / 2
155
+ };
156
+ const projection = options.projection(center);
157
+ const origin = projection.toPlane(center);
158
+ let reachX = 0;
159
+ let reachY = 0;
160
+ for (const point of points) {
161
+ const plane = projection.toPlane(point);
162
+ reachX = Math.max(reachX, Math.abs(plane.x - origin.x));
163
+ reachY = Math.max(reachY, Math.abs(plane.y - origin.y));
164
+ }
165
+ if (reachX === 0 && reachY === 0) throw new MapError("frame", "All the points are at the center, so no scale fits them");
166
+ if (heightMm === void 0 && reachX === 0) throw new MapError("frame", "All the points are on one vertical line, so no scale fits the width");
167
+ const planeMetersPerMm = Math.max(reachX / halfWidth, reachY / halfHeight);
168
+ const factors = projection.scale(center);
169
+ const root = Math.sqrt(factors.max * factors.min);
170
+ const exact = planeMetersPerMm * 1e3 * root;
171
+ const scale = options.roundScale === false ? exact : niceScale(exact);
172
+ if (heightMm !== void 0) return {
173
+ projection,
174
+ center,
175
+ scale,
176
+ widthMm,
177
+ heightMm
178
+ };
179
+ const mmPerPlaneMeter = 1e3 / (scale * root);
180
+ const frame = {
181
+ projection,
182
+ center,
183
+ scale,
184
+ widthMm,
185
+ heightMm: Math.ceil((2 * reachY * mmPerPlaneMeter + 2 * margin) * (1 - 1e-9))
186
+ };
187
+ checkFrame(frame);
188
+ return frame;
189
+ }
103
190
  // src/atlas.ts
104
191
  /** The default width of the overlap of neighbor pages, in millimetres. */
105
192
  const ATLAS_OVERLAP_MM = 10;
@@ -382,7 +469,12 @@ function checkStyle(style, layer) {
382
469
  }
383
470
  /** This function gives a number for SVG, to 0.01 mm. */
384
471
  function mm(value) {
385
- return String(Math.round(value * 100) / 100 + 0);
472
+ return rounded(value, 2);
473
+ }
474
+ /** This function gives the text of a value with `decimals` digits after the point, or fewer. It gives `0`, not `-0`. */
475
+ function rounded(value, decimals) {
476
+ const factor = 10 ** decimals;
477
+ return String(Math.round(value * factor) / factor + 0);
386
478
  }
387
479
  /** This function gives the color of a gray level, from `#000000` to `#ffffff`. */
388
480
  function grayColor(gray) {
@@ -996,15 +1088,45 @@ function paperOf(position, view) {
996
1088
  lon: position[0]
997
1089
  });
998
1090
  }
999
- function linePath(positions, view, box, close) {
1091
+ function linePath(positions, view, box, close, decimals) {
1000
1092
  let d = "";
1001
1093
  positions.forEach((position, i) => {
1002
1094
  const point = paperOf(position, view);
1003
1095
  box.add(point);
1004
- d += `${i === 0 ? "M" : "L"}${mm(point.x)} ${mm(point.y)}`;
1096
+ d += `${i === 0 ? "M" : "L"}${rounded(point.x, decimals)} ${rounded(point.y, decimals)}`;
1005
1097
  });
1006
1098
  return close ? `${d}Z` : d;
1007
1099
  }
1100
+ /** This function gives the path data of a geometry, and adds each of its points to the box. */
1101
+ function pathOf(geometry, view, box, decimals) {
1102
+ switch (geometry.type) {
1103
+ case "Point":
1104
+ case "MultiPoint": return "";
1105
+ case "LineString": return linePath(geometry.coordinates, view, box, false, decimals);
1106
+ case "MultiLineString": return geometry.coordinates.map((line) => linePath(line, view, box, false, decimals)).join("");
1107
+ case "Polygon":
1108
+ case "MultiPolygon": return (geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates).flatMap((rings) => rings.map((ring) => linePath(ring, view, box, true, decimals))).join("");
1109
+ case "GeometryCollection": return geometry.geometries.map((item) => pathOf(item, view, box, decimals)).join("");
1110
+ }
1111
+ }
1112
+ /**
1113
+ * This function gives the SVG path data (the attribute `d`) of a geometry on the paper of a frame, in millimetres.
1114
+ * `renderMap` uses the same path data for its lines and areas.
1115
+ *
1116
+ * - Each ring of a polygon is `M` and its first point, `L` and each next point, and `Z`: `M10 20L30 20L30 40Z`.
1117
+ * - A line is the same with no `Z`.
1118
+ * - A polygon with holes and a multi-polygon give one path data. Use `fill-rule="evenodd"` to fill it.
1119
+ * - A point gives no path data. A geometry collection gives the path data of each of its geometries.
1120
+ * - The function does not clip. A point out of the frame gives values out of the frame.
1121
+ *
1122
+ * @throws MapError - The code is `style`. The number of decimals is not an integer from 0 to 10.
1123
+ * @throws GeoError - A position is not correct for the projection.
1124
+ */
1125
+ function geometryPath(view, geometry, options = {}) {
1126
+ const decimals = options.decimals ?? 2;
1127
+ if (!(Number.isInteger(decimals) && decimals >= 0 && decimals <= 10)) throw new MapError("style", `The number of decimals ${decimals} is not an integer from 0 to 10`);
1128
+ return pathOf(geometry, view, new PaperBox(), decimals);
1129
+ }
1008
1130
  /** This function gives the SVG of one geometry with a style. */
1009
1131
  function drawGeometry(geometry, style, view, fill) {
1010
1132
  const frame = view.frame;
@@ -1017,14 +1139,14 @@ function drawGeometry(geometry, style, view, fill) {
1017
1139
  case "MultiLineString": {
1018
1140
  if (style.stroke === void 0) return "";
1019
1141
  const box = new PaperBox();
1020
- const d = (geometry.type === "LineString" ? [geometry.coordinates] : geometry.coordinates).map((line) => linePath(line, view, box, false)).join("");
1142
+ const d = pathOf(geometry, view, box, 2);
1021
1143
  if (!box.touches(frame, style.stroke.widthMm)) return "";
1022
1144
  return `<path d="${d}" fill="none" ${strokeAttributes(style.stroke)}/>`;
1023
1145
  }
1024
1146
  case "Polygon":
1025
1147
  case "MultiPolygon": {
1026
1148
  const box = new PaperBox();
1027
- const d = (geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates).flatMap((rings) => rings.map((ring) => linePath(ring, view, box, true))).join("");
1149
+ const d = pathOf(geometry, view, box, 2);
1028
1150
  if (!box.touches(frame, style.stroke?.widthMm ?? 0)) return "";
1029
1151
  const stroke = style.stroke === void 0 ? `stroke="none"` : strokeAttributes(style.stroke);
1030
1152
  let svg = "";
@@ -1292,6 +1414,6 @@ function renderMap(map, options = {}) {
1292
1414
  const edges = edgeMarksOf(map, measureFontOf(options)).map((mark) => mark.svg).join("");
1293
1415
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${mm(width)}mm" height="${mm(total)}mm" viewBox="0 0 ${mm(width)} ${mm(total)}" role="img" aria-label="${escapeAttribute(map.title)}" font-family="sans-serif"><title>${escapeHtml(map.title)}</title><defs>${defs.join("")}</defs><rect width="${mm(width)}" height="${mm(total)}" fill="#ffffff"/><g clip-path="url(#${map.id}-clip)">${layers.join("")}</g>${labels}<rect width="${mm(w)}" height="${mm(h)}" fill="none" stroke="#000000" stroke-width="0.3"/>${arrow}${edges}<g class="legend">${scaleBars}${legend}</g><g class="attribution">${attribution}</g></svg>`;
1294
1416
  }
1295
- export { ATLAS_OVERLAP_MM, EDGE_TEXT_MM, FRAME_EDGES, MapError, SCALE_BAR_ROW_MM, atlasIndexFrame, atlasOutlines, atlasPages, attributionLines, checkFilter, checkFrame, checkLabelRule, checkMap, checkStyle, columnName, edgeMarks, fitFrame, frameBBox, frameView, geometryKind, grayColor, hatchPattern, labelText, labelsSvg, mapLabels, mapMargins, matchesFilter, mm, niceNumber, northArrowSvg, placeLabels, pointSymbol, renderMap, scaleBarLength, scaleBarSvg, strokeAttributes };
1417
+ export { ATLAS_OVERLAP_MM, EDGE_TEXT_MM, FRAME_EDGES, MapError, NICE_SCALE_STEPS, SCALE_BAR_ROW_MM, atlasIndexFrame, atlasOutlines, atlasPages, attributionLines, checkFilter, checkFrame, checkLabelRule, checkMap, checkStyle, columnName, edgeMarks, fitFrame, frameAround, frameBBox, frameView, geometryKind, geometryPath, grayColor, hatchPattern, labelText, labelsSvg, mapLabels, mapMargins, matchesFilter, mm, niceNumber, niceScale, northArrowSvg, placeLabels, pointSymbol, renderMap, scaleBarLength, scaleBarSvg, strokeAttributes };
1296
1418
 
1297
1419
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["paperOf"],"sources":["../src/errors.ts","../src/frame.ts","../src/atlas.ts","../src/filter.ts","../src/style.ts","../src/labels.ts","../src/marks.ts","../src/render.ts"],"sourcesContent":["/**\n * The error of this package. Each refusal has a code, so a caller can test the reason without the text of the message.\n *\n * @packageDocumentation\n */\n\n/**\n * The reason of a refusal.\n *\n * - `frame`: the scale or the size of a frame is not a finite number more than 0.\n * - `id`: an identifier is not lower case letters, digits and hyphens, or two layers have the same identifier.\n * - `filter`: a filter is not one of the forms of `Filter`.\n * - `style`: a style draws nothing, or a size, a gray level or a dash is not correct.\n * - `source`: a layer has no source, or its source has no title or no license.\n * - `label`: a label rule, a label font or an edge text is not correct.\n * - `atlas`: the radius or the overlap of an atlas is not correct.\n */\nexport type MapErrorCode = \"frame\" | \"id\" | \"filter\" | \"style\" | \"source\" | \"label\" | \"atlas\";\n\n/** The error that each function of this package throws for an incorrect map. */\nexport class MapError extends Error {\n /** The reason of the refusal. */\n readonly code: MapErrorCode;\n\n /**\n * @param code - The reason of the refusal.\n * @param message - The text for a person.\n */\n constructor(code: MapErrorCode, message: string) {\n super(message);\n this.name = \"MapError\";\n this.code = code;\n }\n}\n","/**\n * The frame of a map: the part of the Earth that the map shows, its scale and its size on the paper.\n *\n * @packageDocumentation\n */\n\nimport { bboxOfPoints, geodesicDirect, type BBox, type LatLon } from \"@mark1russell7/geo\";\nimport type { Projection } from \"@mark1russell7/geo/projection\";\nimport { MapError } from \"./errors.ts\";\n\n/** The frame of a map. The center of the frame is at the middle of the paper. */\nexport interface Frame {\n /** The projection from the Earth to the plane, from `@mark1russell7/geo/projection`. */\n readonly projection: Projection;\n /** The point on the Earth at the middle of the map. */\n readonly center: LatLon;\n /** The denominator of the scale at the center: 24000 for the scale 1:24,000. */\n readonly scale: number;\n /** The width of the map on the paper, in millimetres. */\n readonly widthMm: number;\n /** The height of the map on the paper, in millimetres. */\n readonly heightMm: number;\n}\n\n/** A point on the paper in millimetres, from the top left corner of the map. The y axis points down. */\nexport interface PaperPoint {\n /** The distance to the right, in millimetres. */\n readonly x: number;\n /** The distance down, in millimetres. */\n readonly y: number;\n}\n\n/** The functions of a frame between the Earth and the paper. */\nexport interface FrameView {\n /** The frame. */\n readonly frame: Frame;\n /** The millimetres of paper for one metre on the ground at the center. */\n readonly mmPerMeter: number;\n /** The millimetres of paper for one metre on the plane of the projection. */\n readonly mmPerPlaneMeter: number;\n /** This function gives the point on the paper for a point on the Earth. */\n readonly toPaper: (point: LatLon) => PaperPoint;\n /** This function gives the point on the Earth for a point on the paper. */\n readonly fromPaper: (point: PaperPoint) => LatLon;\n /** The direction of north at the center, in degrees clockwise from the top of the paper. */\n readonly northDegrees: number;\n}\n\n/** This function refuses a frame with a scale or a size that is not a finite number more than 0. */\nexport function checkFrame(frame: Frame): void {\n for (const [name, value] of [\n [\"scale\", frame.scale],\n [\"width\", frame.widthMm],\n [\"height\", frame.heightMm],\n ] as const) {\n if (!(Number.isFinite(value) && value > 0)) throw new MapError(\"frame\", `The ${name} ${value} of the frame is not a finite number more than 0`);\n }\n}\n\n/**\n * This function gives the functions of a frame between the Earth and the paper.\n *\n * - The scale of the frame is the true scale at the center. The function divides by the scale factor of the projection\n * at the center: the square root of `max * min` of `projection.scale`.\n * - For Web Mercator, the scale changes with the latitude. For `azimuthalEquidistant`, it is almost the same on all\n * the map.\n *\n * @throws MapError - The code is `frame`.\n * @throws GeoError - The center is not a correct point for the projection.\n */\nexport function frameView(frame: Frame): FrameView {\n checkFrame(frame);\n const { projection, center } = frame;\n const factors = projection.scale(center);\n const mmPerMeter = 1000 / frame.scale;\n const mmPerPlaneMeter = mmPerMeter / Math.sqrt(factors.max * factors.min);\n const origin = projection.toPlane(center);\n const middleX = frame.widthMm / 2;\n const middleY = frame.heightMm / 2;\n const toPaper = (point: LatLon): PaperPoint => {\n const plane = projection.toPlane(point);\n return { x: middleX + (plane.x - origin.x) * mmPerPlaneMeter, y: middleY - (plane.y - origin.y) * mmPerPlaneMeter };\n };\n const fromPaper = (point: PaperPoint): LatLon =>\n projection.fromPlane({ x: origin.x + (point.x - middleX) / mmPerPlaneMeter, y: origin.y - (point.y - middleY) / mmPerPlaneMeter });\n // The direction of a geodesic of 1 mm on the paper to the north.\n const north = toPaper(geodesicDirect(center, 0, 1 / mmPerMeter).point);\n const northDegrees = (Math.atan2(north.x - middleX, middleY - north.y) * 180) / Math.PI;\n return Object.freeze({ frame, mmPerMeter, mmPerPlaneMeter, toPaper, fromPaper, northDegrees: northDegrees + 0 });\n}\n\n/**\n * This function gives the box on the Earth around the frame, for a fetch of the data of a map. It is the box of 64\n * points on each side of the frame, so it contains the corners and the edges of the frame.\n *\n * @throws MapError - The code is `frame`.\n */\nexport function frameBBox(frame: Frame): BBox {\n const view = frameView(frame);\n const { widthMm: w, heightMm: h } = frame;\n const points: LatLon[] = [];\n const steps = 64;\n for (let i = 0; i < steps; i += 1) {\n const t = i / steps;\n points.push(view.fromPaper({ x: t * w, y: 0 }), view.fromPaper({ x: w, y: t * h }), view.fromPaper({ x: w - t * w, y: h }), view.fromPaper({ x: 0, y: h - t * h }));\n }\n return bboxOfPoints(points) as BBox;\n}\n","/**\n * An atlas: the pages of a large area at one scale, with the names of the neighbor pages and the outlines for an index map.\n *\n * @packageDocumentation\n */\n\nimport type { Feature, LatLon } from \"@mark1russell7/geo\";\nimport type { Projection } from \"@mark1russell7/geo/projection\";\nimport { MapError } from \"./errors.ts\";\nimport { checkFrame, frameView, type Frame } from \"./frame.ts\";\nimport type { FrameEdge } from \"./marks.ts\";\n\n/** The plan of an atlas: the area, the scale and the size of the map on each page. */\nexport interface AtlasPlan {\n /** The projection of all the pages. One projection puts the pages on one plane, so the edges of neighbor pages agree. */\n readonly projection: Projection;\n /** The center of the area on the Earth. The grid of the pages has its middle at this point. */\n readonly center: LatLon;\n /** The radius of the area on the ground, in metres. The atlas keeps each page that shows a part of the circle. */\n readonly radiusMeters: number;\n /** The denominator of the scale of each page: 63360 for the scale 1:63,360 (1 inch for 1 mile). */\n readonly scale: number;\n /** The width of the map on each page, in millimetres. */\n readonly widthMm: number;\n /** The height of the map on each page, in millimetres. */\n readonly heightMm: number;\n /** The width of the strip at each edge that the neighbor page also shows, in millimetres. The default is 10. */\n readonly overlapMm?: number | undefined;\n}\n\n/** One page of an atlas. */\nexport interface AtlasPage {\n /**\n * The name of the page: the letters of its column and the number of its row, for example `B3`.\n * The columns go from west to east, and the rows from north to south.\n */\n readonly id: string;\n /** The index of the column in the grid, from 0 at the west. */\n readonly column: number;\n /** The index of the row in the grid, from 0 at the north. */\n readonly row: number;\n /** The frame of the map of the page. */\n readonly frame: Frame;\n /**\n * The names of the neighbor pages at the edges of the page. An edge with no page in the atlas has no name.\n * The top edge is at the north of the center of the area.\n */\n readonly neighbors: Readonly<Partial<Record<FrameEdge, string>>>;\n}\n\n/** The pages of an atlas, in the order of the rows and then the columns. */\nexport interface Atlas {\n /** The plan of the atlas. */\n readonly plan: AtlasPlan;\n /** The number of columns of the grid. */\n readonly columns: number;\n /** The number of rows of the grid. */\n readonly rows: number;\n /** The pages that show a part of the area. A page of the grid outside the circle is not in the list. */\n readonly pages: readonly AtlasPage[];\n}\n\n/** The default width of the overlap of neighbor pages, in millimetres. */\nexport const ATLAS_OVERLAP_MM = 10;\n\n/**\n * This function gives the name of a column: A to Z, then AA, AB and the next names.\n *\n * @throws MapError - The code is `atlas`. The index is not an integer of 0 or more.\n */\nexport function columnName(index: number): string {\n if (!(Number.isInteger(index) && index >= 0)) throw new MapError(\"atlas\", `The column ${index} is not an integer of 0 or more`);\n let name = \"\";\n for (let rest = index + 1; rest > 0; rest = Math.floor((rest - 1) / 26)) name = String.fromCharCode(65 + ((rest - 1) % 26)) + name;\n return name;\n}\n\n/**\n * This function gives the pages of an atlas: a grid of frames on the plane of the projection.\n * The middle of the grid is at the center of the area.\n *\n * - Neighbor pages share a strip of `overlapMm` at their common edge.\n * - The grid has the smallest number of columns and rows that shows the full circle.\n * - Each page has the scale of the plan at its own center. For `azimuthalEquidistant` over 50 km, the edges of neighbor pages agree to 0.01 mm.\n *\n * @throws MapError - The code is `frame` or `atlas`.\n */\nexport function atlasPages(plan: AtlasPlan): Atlas {\n const overlapMm = plan.overlapMm ?? ATLAS_OVERLAP_MM;\n checkFrame(plan);\n if (!(Number.isFinite(plan.radiusMeters) && plan.radiusMeters > 0)) throw new MapError(\"atlas\", `The radius ${plan.radiusMeters} of the atlas is not a finite number more than 0`);\n if (!(Number.isFinite(overlapMm) && overlapMm >= 0 && overlapMm < Math.min(plan.widthMm, plan.heightMm) / 2)) {\n throw new MapError(\"atlas\", `The overlap ${overlapMm} of the atlas is not from 0 to less than half of the smaller side of the page`);\n }\n const middle = frameView(plan);\n const origin = plan.projection.toPlane(plan.center);\n // All the sizes are in millimetres on the paper, at the scale of the center of the area.\n const radiusMm = plan.radiusMeters * middle.mmPerMeter;\n const stepX = plan.widthMm - overlapMm;\n const stepY = plan.heightMm - overlapMm;\n const columns = Math.max(1, Math.ceil((2 * radiusMm - plan.widthMm) / stepX) + 1);\n const rows = Math.max(1, Math.ceil((2 * radiusMm - plan.heightMm) / stepY) + 1);\n const offsetX = (column: number): number => (column - (columns - 1) / 2) * stepX;\n const offsetY = (row: number): number => ((rows - 1) / 2 - row) * stepY;\n const shows = (column: number, row: number): boolean => {\n if (column < 0 || column >= columns || row < 0 || row >= rows) return false;\n const dx = Math.max(Math.abs(offsetX(column)) - plan.widthMm / 2, 0);\n const dy = Math.max(Math.abs(offsetY(row)) - plan.heightMm / 2, 0);\n return dx * dx + dy * dy < radiusMm * radiusMm;\n };\n const name = (column: number, row: number): string => `${columnName(column)}${row + 1}`;\n const pages: AtlasPage[] = [];\n for (let row = 0; row < rows; row += 1) {\n for (let column = 0; column < columns; column += 1) {\n if (!shows(column, row)) continue;\n const center = plan.projection.fromPlane({ x: origin.x + offsetX(column) / middle.mmPerPlaneMeter, y: origin.y + offsetY(row) / middle.mmPerPlaneMeter });\n const neighbors: Partial<Record<FrameEdge, string>> = {};\n for (const [edge, dc, dr] of [[\"top\", 0, -1], [\"right\", 1, 0], [\"bottom\", 0, 1], [\"left\", -1, 0]] as const) {\n if (shows(column + dc, row + dr)) neighbors[edge] = name(column + dc, row + dr);\n }\n const frame: Frame = { projection: plan.projection, center, scale: plan.scale, widthMm: plan.widthMm, heightMm: plan.heightMm };\n pages.push({ id: name(column, row), column, row, frame, neighbors });\n }\n }\n return { plan, columns, rows, pages };\n}\n\n/**\n * This function gives the outline of each page of an atlas as a polygon feature, with the name of the page in the property `id`.\n * A layer of an index map draws them. Each edge has `pointsPerEdge` points, because the edges of the pages are curves on the Earth.\n *\n * @throws MapError - The code is `atlas`. The number of points is not an integer of 1 or more.\n */\nexport function atlasOutlines(atlas: Atlas, pointsPerEdge = 16): Feature[] {\n if (!(Number.isInteger(pointsPerEdge) && pointsPerEdge >= 1)) throw new MapError(\"atlas\", `The number of points ${pointsPerEdge} of an edge is not an integer of 1 or more`);\n return atlas.pages.map((page) => {\n const view = frameView(page.frame);\n const { widthMm: w, heightMm: h } = page.frame;\n const ring: [number, number][] = [];\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: (i / pointsPerEdge) * w, y: 0 })));\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: w, y: (i / pointsPerEdge) * h })));\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: w - (i / pointsPerEdge) * w, y: h })));\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: 0, y: h - (i / pointsPerEdge) * h })));\n // GeoJSON gives the outer ring of a polygon in the counterclockwise direction. The walk on the paper is clockwise, so it is reversed.\n ring.reverse();\n ring.push(ring[0]!);\n return { type: \"Feature\", geometry: { type: \"Polygon\", coordinates: [ring] }, properties: { id: page.id } };\n });\n}\n\n/**\n * This function gives the frame of an index map of an atlas. The frame shows all the pages of the grid in the space, at the largest scale.\n * Its center is the middle of the grid.\n *\n * @throws MapError - The code is `frame`.\n */\nexport function atlasIndexFrame(atlas: Atlas, widthMm: number, heightMm: number): Frame {\n const { plan } = atlas;\n checkFrame({ ...plan, widthMm, heightMm });\n const overlapMm = plan.overlapMm ?? ATLAS_OVERLAP_MM;\n const gridWidthMm = (atlas.columns - 1) * (plan.widthMm - overlapMm) + plan.widthMm;\n const gridHeightMm = (atlas.rows - 1) * (plan.heightMm - overlapMm) + plan.heightMm;\n const scale = plan.scale * Math.max(gridWidthMm / widthMm, gridHeightMm / heightMm);\n return { projection: plan.projection, center: plan.center, scale, widthMm, heightMm };\n}\n\n/** This function gives the GeoJSON position `[lon, lat]` of a point. */\nfunction lonLat(point: LatLon): [number, number] {\n return [point.lon, point.lat];\n}\n","/**\n * The filters of the layers. A filter is data, so a map document can be JSON.\n *\n * @packageDocumentation\n */\n\nimport type { Feature, Geometry } from \"@mark1russell7/geo\";\nimport { MapError } from \"./errors.ts\";\n\n/** A value that a filter compares with a property of a feature. */\nexport type FilterValue = string | number | boolean;\n\n/** The kind of a geometry: points, lines or areas. A collection of two kinds is `mixed`. */\nexport type GeometryKind = \"point\" | \"line\" | \"area\" | \"mixed\";\n\n/**\n * A filter of the features of a layer.\n *\n * - `{ all }` matches when each filter matches. `{ any }` matches when one filter matches. `{ not }` reverses a filter.\n * - `{ property, in }` matches a feature whose property is equal to one of the values.\n * - `{ property, exists }` matches a feature that has the property, or that does not have it.\n * - `{ geometry }` matches a feature whose geometry has the kind.\n */\nexport type Filter =\n | { readonly all: readonly Filter[] }\n | { readonly any: readonly Filter[] }\n | { readonly not: Filter }\n | { readonly property: string; readonly in: readonly FilterValue[] }\n | { readonly property: string; readonly exists: boolean }\n | { readonly geometry: GeometryKind };\n\n/** This function gives the kind of a geometry. */\nexport function geometryKind(geometry: Geometry): GeometryKind {\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\":\n return \"point\";\n case \"LineString\":\n case \"MultiLineString\":\n return \"line\";\n case \"Polygon\":\n case \"MultiPolygon\":\n return \"area\";\n case \"GeometryCollection\": {\n const kinds = new Set(geometry.geometries.map(geometryKind));\n return kinds.size === 1 ? ([...kinds][0] as GeometryKind) : \"mixed\";\n }\n }\n}\n\n/** This function tells if a feature matches a filter. A feature with no geometry matches no `{ geometry }` filter. */\nexport function matchesFilter(filter: Filter, feature: Feature): boolean {\n if (\"all\" in filter) return filter.all.every((item) => matchesFilter(item, feature));\n if (\"any\" in filter) return filter.any.some((item) => matchesFilter(item, feature));\n if (\"not\" in filter) return !matchesFilter(filter.not, feature);\n if (\"geometry\" in filter) return feature.geometry !== null && geometryKind(feature.geometry) === filter.geometry;\n const properties = feature.properties ?? {};\n const has = Object.hasOwn(properties, filter.property);\n if (\"exists\" in filter) return has === filter.exists;\n return has && filter.in.includes(properties[filter.property] as FilterValue);\n}\n\nconst KINDS: readonly string[] = [\"point\", \"line\", \"area\", \"mixed\"];\n\n/**\n * This function refuses a value that is not a `Filter`, for example a filter from JSON.\n *\n * @throws MapError - The code is `filter`.\n */\nexport function checkFilter(filter: unknown, path = \"filter\"): asserts filter is Filter {\n const fail = (reason: string): never => {\n throw new MapError(\"filter\", `${path}: ${reason}`);\n };\n if (typeof filter !== \"object\" || filter === null || Array.isArray(filter)) fail(\"a filter must be an object\");\n const value = filter as Record<string, unknown>;\n const keys = Object.keys(value).toSorted().join(\",\");\n if (keys === \"all\" || keys === \"any\") {\n const items = value[keys];\n if (!Array.isArray(items)) fail(`the member ${keys} must be an array`);\n (items as unknown[]).forEach((item, i) => checkFilter(item, `${path}.${keys}[${i}]`));\n } else if (keys === \"not\") {\n checkFilter(value[\"not\"], `${path}.not`);\n } else if (keys === \"geometry\") {\n if (!KINDS.includes(value[\"geometry\"] as string)) fail(`the geometry must be one of ${KINDS.join(\", \")}`);\n } else if (keys === \"in,property\" || keys === \"exists,property\") {\n if (typeof value[\"property\"] !== \"string\") fail(\"the property must be a string\");\n if (keys === \"exists,property\" && typeof value[\"exists\"] !== \"boolean\") fail(\"the member exists must be true or false\");\n if (keys === \"in,property\") {\n const items = value[\"in\"];\n if (!Array.isArray(items) || !items.every((item) => [\"string\", \"number\", \"boolean\"].includes(typeof item))) {\n fail(\"the member in must be an array of strings, numbers and booleans\");\n }\n }\n } else {\n fail(`the members ${keys === \"\" ? \"(none)\" : keys} are not a form of a filter`);\n }\n}\n","/**\n * The black and white styles of the layers: lines with dashes, areas with gray levels and hatches, and point symbols.\n * The print of a map has no color, so each style uses black, white and gray only.\n *\n * @packageDocumentation\n */\n\nimport { MapError } from \"./errors.ts\";\n\n/**\n * A line. The gray level goes from 0 (black) to 1 (white). The default is 0.\n */\nexport interface StrokeStyle {\n /** The width of the line in millimetres. */\n readonly widthMm: number;\n /** The gray level from 0 (black) to 1 (white). The default is 0. */\n readonly gray?: number;\n /** The lengths of the dashes and the gaps in millimetres. No value gives a solid line. */\n readonly dashMm?: readonly number[];\n}\n\n/** Parallel lines in an area. A cross hatch adds the same lines at right angles. */\nexport interface HatchStyle {\n /** The angle of the lines in degrees, clockwise from horizontal. */\n readonly angleDegrees: number;\n /** The distance between two lines in millimetres. It is more than the width of a line. */\n readonly spacingMm: number;\n /** The width of a line in millimetres. */\n readonly widthMm: number;\n /** The value `true` adds the lines at right angles. The default is `false`. */\n readonly cross?: boolean;\n}\n\n/** The fill of an area: a gray level, a hatch, or the two. The hatch is on top of the gray level. */\nexport interface FillStyle {\n /** The gray level from 0 (black) to 1 (white). No value gives no solid fill. */\n readonly gray?: number;\n /** The hatch. No value gives no hatch. */\n readonly hatch?: HatchStyle;\n}\n\n/** The symbols of the points. */\nexport type PointSymbol = \"circle\" | \"square\" | \"triangle\" | \"diamond\" | \"cross\";\n\n/** The symbol of each point. */\nexport interface PointStyle {\n /** The shape of the symbol. */\n readonly symbol: PointSymbol;\n /** The size of the symbol in millimetres. */\n readonly sizeMm: number;\n /** The value `false` gives a white symbol with a black outline. The default is `true`, a black symbol. */\n readonly filled?: boolean;\n}\n\n/** The style of a layer. The line is for the lines and the edges of the areas. The fill is for the areas, and the symbol is for the points. */\nexport interface Style {\n /** The line. */\n readonly stroke?: StrokeStyle;\n /** The fill of the areas. */\n readonly fill?: FillStyle;\n /** The symbol of the points. */\n readonly point?: PointStyle;\n}\n\nconst SYMBOLS: readonly string[] = [\"circle\", \"square\", \"triangle\", \"diamond\", \"cross\"];\n\nfunction positive(value: unknown, name: string, layer: string): void {\n if (!(typeof value === \"number\" && Number.isFinite(value) && value > 0)) {\n throw new MapError(\"style\", `The layer \"${layer}\": the ${name} ${String(value)} is not a finite number more than 0`);\n }\n}\n\nfunction grayLevel(value: unknown, layer: string): void {\n if (value === undefined) return;\n if (!(typeof value === \"number\" && value >= 0 && value <= 1)) {\n throw new MapError(\"style\", `The layer \"${layer}\": the gray level ${String(value)} is not from 0 to 1`);\n }\n}\n\n/**\n * This function refuses a style that draws nothing, and a size, a gray level, a dash or a symbol that is not correct.\n *\n * @throws MapError - The code is `style`.\n */\nexport function checkStyle(style: Style, layer: string): void {\n if (style.stroke === undefined && style.fill === undefined && style.point === undefined) {\n throw new MapError(\"style\", `The layer \"${layer}\": the style has no stroke, no fill and no point, so it draws nothing`);\n }\n if (style.stroke !== undefined) {\n positive(style.stroke.widthMm, \"width of the line\", layer);\n grayLevel(style.stroke.gray, layer);\n for (const dash of style.stroke.dashMm ?? []) positive(dash, \"length of a dash\", layer);\n }\n if (style.fill !== undefined) {\n grayLevel(style.fill.gray, layer);\n if (style.fill.gray === undefined && style.fill.hatch === undefined) {\n throw new MapError(\"style\", `The layer \"${layer}\": the fill has no gray level and no hatch`);\n }\n const hatch = style.fill.hatch;\n if (hatch !== undefined) {\n positive(hatch.widthMm, \"width of a hatch line\", layer);\n positive(hatch.spacingMm, \"spacing of the hatch\", layer);\n if (!Number.isFinite(hatch.angleDegrees)) throw new MapError(\"style\", `The layer \"${layer}\": the angle ${hatch.angleDegrees} is not finite`);\n if (hatch.spacingMm <= hatch.widthMm) throw new MapError(\"style\", `The layer \"${layer}\": the spacing of the hatch is not more than its width`);\n }\n }\n if (style.point !== undefined) {\n positive(style.point.sizeMm, \"size of the symbol\", layer);\n if (!SYMBOLS.includes(style.point.symbol)) throw new MapError(\"style\", `The layer \"${layer}\": the symbol \"${style.point.symbol}\" is not one of ${SYMBOLS.join(\", \")}`);\n }\n}\n\n/** This function gives a number for SVG, to 0.01 mm. */\nexport function mm(value: number): string {\n return String(Math.round(value * 100) / 100 + 0);\n}\n\n/** This function gives the color of a gray level, from `#000000` to `#ffffff`. */\nexport function grayColor(gray: number): string {\n const hex = Math.round(gray * 255)\n .toString(16)\n .padStart(2, \"0\");\n return `#${hex}${hex}${hex}`;\n}\n\n/** This function gives the SVG attributes of a line. */\nexport function strokeAttributes(stroke: StrokeStyle): string {\n const dash = stroke.dashMm === undefined || stroke.dashMm.length === 0 ? \"\" : ` stroke-dasharray=\"${stroke.dashMm.map(mm).join(\" \")}\"`;\n return `stroke=\"${grayColor(stroke.gray ?? 0)}\" stroke-width=\"${mm(stroke.widthMm)}\"${dash} stroke-linecap=\"round\" stroke-linejoin=\"round\"`;\n}\n\n/** This function gives the SVG pattern of a hatch, with an identifier. */\nexport function hatchPattern(id: string, hatch: HatchStyle): string {\n const s = mm(hatch.spacingMm);\n const half = mm(hatch.spacingMm / 2);\n const line = `stroke=\"#000000\" stroke-width=\"${mm(hatch.widthMm)}\"`;\n const across = hatch.cross === true ? `<line x1=\"${half}\" y1=\"0\" x2=\"${half}\" y2=\"${s}\" ${line}/>` : \"\";\n return (\n `<pattern id=\"${id}\" patternUnits=\"userSpaceOnUse\" width=\"${s}\" height=\"${s}\" patternTransform=\"rotate(${mm(hatch.angleDegrees)})\">` +\n `<line x1=\"0\" y1=\"${half}\" x2=\"${s}\" y2=\"${half}\" ${line}/>${across}</pattern>`\n );\n}\n\n/** This function gives the SVG of a point symbol at a point on the paper. */\nexport function pointSymbol(point: PointStyle, x: number, y: number): string {\n const r = point.sizeMm / 2;\n const filled = point.filled !== false;\n const paint = filled ? `fill=\"#000000\"` : `fill=\"#ffffff\" stroke=\"#000000\" stroke-width=\"${mm(point.sizeMm / 8)}\"`;\n switch (point.symbol) {\n case \"circle\":\n return `<circle cx=\"${mm(x)}\" cy=\"${mm(y)}\" r=\"${mm(r)}\" ${paint}/>`;\n case \"square\":\n return `<rect x=\"${mm(x - r)}\" y=\"${mm(y - r)}\" width=\"${mm(2 * r)}\" height=\"${mm(2 * r)}\" ${paint}/>`;\n case \"triangle\":\n return `<path d=\"M${mm(x)} ${mm(y - r)}L${mm(x + r)} ${mm(y + r)}L${mm(x - r)} ${mm(y + r)}Z\" ${paint}/>`;\n case \"diamond\":\n return `<path d=\"M${mm(x)} ${mm(y - r)}L${mm(x + r)} ${mm(y)}L${mm(x)} ${mm(y + r)}L${mm(x - r)} ${mm(y)}Z\" ${paint}/>`;\n case \"cross\":\n return `<path d=\"M${mm(x - r)} ${mm(y)}L${mm(x + r)} ${mm(y)}M${mm(x)} ${mm(y - r)}L${mm(x)} ${mm(y + r)}\" stroke=\"#000000\" stroke-width=\"${mm(point.sizeMm / 5)}\" fill=\"none\"/>`;\n }\n}\n","/**\n * The labels of a map: the names of points, lines and areas, with no overlap.\n *\n * @packageDocumentation\n */\n\nimport { locatePoint, type Feature, type Geometry, type Polygon, type Position } from \"@mark1russell7/geo\";\nimport { escapeAttribute, escapeHtml } from \"@mark1russell7/text\";\nimport { MapError } from \"./errors.ts\";\nimport type { FrameView, PaperPoint } from \"./frame.ts\";\nimport { mm } from \"./style.ts\";\n\n/** The rule of the labels of a layer. */\nexport interface LabelRule {\n /** The properties of a feature, in sequence. The first property with a text that is not empty gives the label. */\n readonly properties: readonly string[];\n /** The size of the font in millimetres on the paper. */\n readonly sizeMm: number;\n /** The rank of the labels of the layer. A lower rank gets its places first. The default is 0. */\n readonly priority?: number;\n /** For a line: the distance in millimetres between two labels of the same text. No value gives one label for each text. */\n readonly repeatMm?: number;\n}\n\n/** The font of the labels. The width of a label comes from `measure`, so the font of the print must be the same font. */\nexport interface LabelFont {\n /** The CSS font family of the labels, for example `\"Liberation Sans\", Arial, sans-serif`. */\n readonly family: string;\n /** This function gives the width in millimetres of a text at a size of the font in millimetres. */\n readonly measure: (text: string, sizeMm: number) => number;\n}\n\n/** A label with its place: the middle of its box on the paper, and its angle. */\nexport interface PlacedLabel {\n /** The identifier of the layer of the label. */\n readonly layer: string;\n readonly text: string;\n /** The middle of the label on the paper, in millimetres from the top left corner of the frame. */\n readonly x: number;\n readonly y: number;\n /** The angle of the text in degrees, clockwise, more than -90 and not more than 90. So each label reads from the left. */\n readonly angle: number;\n readonly sizeMm: number;\n readonly widthMm: number;\n}\n\n/** The labels of a map: the labels with a place, and the texts with no place. */\nexport interface LabelPlacement {\n readonly placed: readonly PlacedLabel[];\n /** Each text that has no place with no overlap, inside the frame. */\n readonly skipped: readonly { readonly layer: string; readonly text: string }[];\n}\n\n/** A layer as the labels see it: its identifier, its features after its filter, its rule and the size of its points. */\nexport interface LabelLayer {\n readonly id: string;\n readonly features: readonly Feature[];\n readonly label?: LabelRule | undefined;\n /** The size in millimetres of the point symbol of the layer, when its style has points. */\n readonly pointSizeMm?: number | undefined;\n}\n\n/** The gap in millimetres between a point symbol and its label. */\nconst POINT_GAP_MM = 0.6;\n/** The margin in millimetres between a label and the edge of the frame. */\nconst FRAME_MARGIN_MM = 0.5;\n/** The height of the box of a label, as a part of the size of the font. */\nconst BOX_HEIGHT = 1.2;\n/** The room in millimetres at each end of a label along a line. */\nconst LINE_PAD_MM = 1;\n/** The largest distance from a line to the chord of a label, as a part of the size of the font. */\nconst LINE_BEND = 0.25;\n\n/**\n * This function examines the label rule of a layer.\n *\n * @throws MapError - The code is `label`.\n */\nexport function checkLabelRule(rule: LabelRule, layer: string): void {\n const fail = (reason: string): never => {\n throw new MapError(\"label\", `The labels of the layer \"${layer}\": ${reason}`);\n };\n if (!Array.isArray(rule.properties) || rule.properties.length === 0) fail(\"give at least one property\");\n for (const property of rule.properties) if (typeof property !== \"string\" || property === \"\") fail(\"each property is a text that is not empty\");\n if (!(Number.isFinite(rule.sizeMm) && rule.sizeMm > 0)) fail(`the size ${rule.sizeMm} is not a finite number more than 0`);\n if (rule.priority !== undefined && !Number.isFinite(rule.priority)) fail(`the priority ${rule.priority} is not a finite number`);\n if (rule.repeatMm !== undefined && !(Number.isFinite(rule.repeatMm) && rule.repeatMm > 0)) fail(`the distance ${rule.repeatMm} is not a finite number more than 0`);\n}\n\n/** This function gives the text of the label of a feature: the first property of the rule with a text. */\nexport function labelText(rule: LabelRule, feature: Feature): string | undefined {\n for (const property of rule.properties) {\n const value = feature.properties?.[property];\n if ((typeof value === \"string\" || typeof value === \"number\") && String(value).trim() !== \"\") return String(value).trim();\n }\n return undefined;\n}\n\n/** A box on the paper with an angle: its middle, its half width, its half height and its angle in radians. */\ninterface Box {\n readonly x: number;\n readonly y: number;\n readonly hw: number;\n readonly hh: number;\n readonly angle: number;\n}\n\nfunction corners(box: Box): PaperPoint[] {\n const c = Math.cos(box.angle);\n const s = Math.sin(box.angle);\n return [\n [-box.hw, -box.hh],\n [box.hw, -box.hh],\n [box.hw, box.hh],\n [-box.hw, box.hh],\n ].map(([u, v]) => ({ x: box.x + u! * c - v! * s, y: box.y + u! * s + v! * c }));\n}\n\n/** This function tells if two boxes overlap: the test of the separating axis for two rectangles. */\nfunction overlaps(a: Box, b: Box): boolean {\n const ca = corners(a);\n const cb = corners(b);\n for (const angle of [a.angle, a.angle + Math.PI / 2, b.angle, b.angle + Math.PI / 2]) {\n const ax = Math.cos(angle);\n const ay = Math.sin(angle);\n const pa = ca.map((p) => p.x * ax + p.y * ay);\n const pb = cb.map((p) => p.x * ax + p.y * ay);\n if (Math.max(...pa) <= Math.min(...pb) || Math.max(...pb) <= Math.min(...pa)) return false;\n }\n return true;\n}\n\n/** The boxes that a label must not overlap, and the frame. */\nclass Room {\n readonly boxes: Box[] = [];\n readonly widthMm: number;\n readonly heightMm: number;\n\n constructor(widthMm: number, heightMm: number) {\n this.widthMm = widthMm;\n this.heightMm = heightMm;\n }\n\n fits(box: Box): boolean {\n for (const p of corners(box)) {\n if (p.x < FRAME_MARGIN_MM || p.y < FRAME_MARGIN_MM || p.x > this.widthMm - FRAME_MARGIN_MM || p.y > this.heightMm - FRAME_MARGIN_MM) return false;\n }\n return !this.boxes.some((other) => overlaps(box, other));\n }\n}\n\nfunction paperOf(position: Position, view: FrameView): PaperPoint {\n return view.toPaper({ lat: position[1] as number, lon: position[0] as number });\n}\n\n/** This function gives the points, the lines and the areas of a geometry. */\nfunction parts(geometry: Geometry, out: { points: Position[]; lines: (readonly Position[])[]; areas: Polygon[] }): void {\n switch (geometry.type) {\n case \"Point\":\n out.points.push(geometry.coordinates);\n break;\n case \"MultiPoint\":\n out.points.push(...geometry.coordinates);\n break;\n case \"LineString\":\n out.lines.push(geometry.coordinates);\n break;\n case \"MultiLineString\":\n out.lines.push(...geometry.coordinates);\n break;\n case \"Polygon\":\n out.areas.push(geometry);\n break;\n case \"MultiPolygon\":\n for (const coordinates of geometry.coordinates) out.areas.push({ type: \"Polygon\", coordinates });\n break;\n case \"GeometryCollection\":\n for (const item of geometry.geometries) parts(item, out);\n break;\n }\n}\n\n/** This function gives the angle of a direction in radians, more than -pi/2 and not more than pi/2, so the text reads from the left. */\nfunction readable(dx: number, dy: number): number {\n let angle = Math.atan2(dy, dx);\n if (angle > Math.PI / 2) angle -= Math.PI;\n if (angle <= -Math.PI / 2) angle += Math.PI;\n return angle;\n}\n\n/**\n * This function gives the runs of a line on the paper: the parts with each segment in a box that touches the frame. So\n * a segment that crosses the frame stays in its run. A run can go past the frame, but a label box outside the frame\n * does not fit.\n */\nfunction runs(line: readonly Position[], view: FrameView): PaperPoint[][] {\n const { widthMm: w, heightMm: h } = view.frame;\n const points = line.map((position) => paperOf(position, view));\n const out: PaperPoint[][] = [];\n let run: PaperPoint[] = [];\n for (let i = 1; i < points.length; i += 1) {\n const a = points[i - 1]!;\n const b = points[i]!;\n if (Math.max(a.x, b.x) >= 0 && Math.min(a.x, b.x) <= w && Math.max(a.y, b.y) >= 0 && Math.min(a.y, b.y) <= h) {\n if (run.length === 0) run.push(a);\n run.push(b);\n } else {\n if (run.length > 1) out.push(run);\n run = [];\n }\n }\n if (run.length > 1) out.push(run);\n return out;\n}\n\n/** This function gives the length of a run on the paper. */\nfunction runLength(run: readonly PaperPoint[]): number {\n let total = 0;\n for (let i = 1; i < run.length; i += 1) total += Math.hypot(run[i]!.x - run[i - 1]!.x, run[i]!.y - run[i - 1]!.y);\n return total;\n}\n\n/** This function gives the point at a distance along a run, with the cumulative lengths of the run. */\nfunction along(run: readonly PaperPoint[], lengths: readonly number[], s: number): PaperPoint {\n let i = 1;\n while (i < run.length - 1 && lengths[i]! < s) i += 1;\n const a = run[i - 1]!;\n const b = run[i]!;\n const span = lengths[i]! - lengths[i - 1]!;\n const t = span === 0 ? 0 : (s - lengths[i - 1]!) / span;\n return { x: a.x + t * (b.x - a.x), y: a.y + t * (b.y - a.y) };\n}\n\n/**\n * This function gives the boxes of a label along a run, from the middle of the run to its ends. A box is on an almost\n * straight part of the run. No point of that part is farther from the chord than `LINE_BEND` of the size.\n */\nfunction lineCandidates(run: readonly PaperPoint[], width: number, size: number): Box[] {\n const lengths = [0];\n for (let i = 1; i < run.length; i += 1) lengths.push(lengths[i - 1]! + Math.hypot(run[i]!.x - run[i - 1]!.x, run[i]!.y - run[i - 1]!.y));\n const total = lengths.at(-1)!;\n const span = width + 2 * LINE_PAD_MM;\n if (total < span) return [];\n const step = Math.max(span / 4, 2);\n // The middles go from the middle of the run to its ends, one step at a time, first toward the start.\n const middles = [total / 2];\n for (let k = 1; k * step <= total / 2 - span / 2; k += 1) middles.push(total / 2 - k * step, total / 2 + k * step);\n const boxes: Box[] = [];\n for (const middle of middles) {\n const start = along(run, lengths, middle - span / 2);\n const end = along(run, lengths, middle + span / 2);\n const chord = Math.hypot(end.x - start.x, end.y - start.y);\n if (chord < 0.9 * span) continue;\n const inside = run.filter((_, i) => lengths[i]! > middle - span / 2 && lengths[i]! < middle + span / 2);\n const bend = Math.max(0, ...inside.map((p) => Math.abs((end.x - start.x) * (start.y - p.y) - (start.x - p.x) * (end.y - start.y)) / chord));\n if (bend > LINE_BEND * size) continue;\n boxes.push({ x: (start.x + end.x) / 2, y: (start.y + end.y) / 2, hw: width / 2, hh: (BOX_HEIGHT * size) / 2, angle: readable(end.x - start.x, end.y - start.y) });\n }\n return boxes;\n}\n\n/** This function gives the boxes of a label around a point, in the sequence of the preferred places. */\nfunction pointCandidates(p: PaperPoint, width: number, size: number, symbolMm: number): Box[] {\n const hw = width / 2;\n const hh = (BOX_HEIGHT * size) / 2;\n const d = symbolMm / 2 + POINT_GAP_MM;\n const k = d * Math.SQRT1_2;\n return [\n [d + hw, 0],\n [-d - hw, 0],\n [0, -d - hh],\n [0, d + hh],\n [k + hw, -k - hh],\n [k + hw, k + hh],\n [-k - hw, -k - hh],\n [-k - hw, k + hh],\n ].map(([dx, dy]) => ({ x: p.x + dx!, y: p.y + dy!, hw, hh, angle: 0 }));\n}\n\n/** This function gives the box of a label in the middle of an area, when the area has each corner of the box. */\nfunction areaCandidates(area: Polygon, view: FrameView, width: number, size: number): Box[] {\n const ring = area.coordinates[0] ?? [];\n if (ring.length < 4) return [];\n const points = ring.map((position) => paperOf(position, view));\n let doubled = 0;\n let cx = 0;\n let cy = 0;\n for (let i = 0; i + 1 < points.length; i += 1) {\n const a = points[i]!;\n const b = points[i + 1]!;\n const cross = a.x * b.y - b.x * a.y;\n doubled += cross;\n cx += (a.x + b.x) * cross;\n cy += (a.y + b.y) * cross;\n }\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n const middle = { x: (Math.min(...xs) + Math.max(...xs)) / 2, y: (Math.min(...ys) + Math.max(...ys)) / 2 };\n const centers = doubled === 0 ? [middle] : [{ x: cx / (3 * doubled), y: cy / (3 * doubled) }, middle];\n const hw = width / 2;\n const hh = (BOX_HEIGHT * size) / 2;\n return centers\n .map((c) => ({ x: c.x, y: c.y, hw, hh, angle: 0 }))\n .filter((box) => [...corners(box), { x: box.x, y: box.y }].every((p) => locatePoint(view.fromPaper(p), area) === \"inside\"));\n}\n\n/** This function tells if the box of the outer ring of an area on the paper touches the frame. */\nfunction areaOnFrame(area: Polygon, view: FrameView): boolean {\n const points = (area.coordinates[0] ?? []).map((position) => paperOf(position, view));\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n return points.length > 0 && Math.max(...xs) >= 0 && Math.min(...xs) <= view.frame.widthMm && Math.max(...ys) >= 0 && Math.min(...ys) <= view.frame.heightMm;\n}\n\n/** One text of a layer, and the parts of the features with that text. */\ninterface Job {\n readonly layer: LabelLayer;\n readonly rule: LabelRule;\n readonly text: string;\n readonly width: number;\n readonly points: Position[];\n readonly lines: (readonly Position[])[];\n readonly areas: Polygon[];\n}\n\n/**\n * This function gives the places of the labels of the layers. The labels do not overlap, and each label is inside the\n * frame.\n *\n * - The layers with a lower `priority` get their places first. With the same priority, a higher layer is first.\n * - In a layer, the features with the same text are one job. A longer line is first, then the sequence of the features.\n * - A point gets the first free place of 8 places around its symbol: right, left, above, below, then the corners.\n * - A line gets its text along an almost straight part. The longest run is first, and the middle of a run is first.\n * - With `repeatMm`, a line gets more labels of its text, at that distance or more from each other.\n * - An area gets its text at its centroid or at the middle of its box, when the area has the box of the text.\n * - Each point symbol of the layers and the north arrow are obstacles too.\n * - A text with a part on the frame and no free place is in `skipped`. A text with no part on the frame is in neither list.\n *\n * @param obstacles - The boxes on the paper that no label covers, as the middle and the half size in millimetres. A box with `halfHeight` has the half width `half`.\n * @throws MapError - The code is `label`: the width of a text from `measure` is not a finite number of 0 or more.\n */\nexport function placeLabels(layers: readonly LabelLayer[], view: FrameView, font: LabelFont, obstacles: readonly { x: number; y: number; half: number; halfHeight?: number }[] = []): LabelPlacement {\n const room = new Room(view.frame.widthMm, view.frame.heightMm);\n for (const o of obstacles) room.boxes.push({ x: o.x, y: o.y, hw: o.half, hh: o.halfHeight ?? o.half, angle: 0 });\n for (const layer of layers) {\n if (layer.pointSizeMm === undefined) continue;\n const out: { points: Position[]; lines: (readonly Position[])[]; areas: Polygon[] } = { points: [], lines: [], areas: [] };\n for (const feature of layer.features) if (feature.geometry !== null) parts(feature.geometry, out);\n for (const position of out.points) {\n const p = paperOf(position, view);\n room.boxes.push({ x: p.x, y: p.y, hw: layer.pointSizeMm / 2, hh: layer.pointSizeMm / 2, angle: 0 });\n }\n }\n\n const order = layers\n .map((layer, index) => ({ layer, index }))\n .filter((entry): entry is { layer: LabelLayer & { label: LabelRule }; index: number } => entry.layer.label !== undefined)\n .sort((a, b) => (a.layer.label.priority ?? 0) - (b.layer.label.priority ?? 0) || b.index - a.index);\n\n const placed: PlacedLabel[] = [];\n const skipped: { layer: string; text: string }[] = [];\n for (const { layer } of order) {\n const rule = layer.label;\n const jobs = new Map<string, Job>();\n for (const feature of layer.features) {\n if (feature.geometry === null) continue;\n const text = labelText(rule, feature);\n if (text === undefined) continue;\n let job = jobs.get(text);\n if (job === undefined) {\n const width = font.measure(text, rule.sizeMm);\n if (!(Number.isFinite(width) && width >= 0)) throw new MapError(\"label\", `The width ${width} of the label \"${text}\" is not a finite number of 0 or more`);\n job = { layer, rule, text, width, points: [], lines: [], areas: [] };\n jobs.set(text, job);\n }\n parts(feature.geometry, job);\n }\n // The runs of each job, the longest first. The jobs with the most length of line are first.\n const sorted = [...jobs.values()]\n .map((job) => {\n const lineRuns = job.lines\n .flatMap((line) => runs(line, view))\n .map((run) => ({ run, length: runLength(run) }))\n .sort((a, b) => b.length - a.length);\n return { job, lineRuns, length: lineRuns.reduce((t, entry) => t + entry.length, 0) };\n })\n .sort((a, b) => b.length - a.length);\n for (const { job, lineRuns } of sorted) {\n const mine: PlacedLabel[] = [];\n // A text is in `skipped` only when a part of its features is on the frame.\n let onFrame = false;\n const take = (box: Box): boolean => {\n if (!room.fits(box)) return false;\n if (job.rule.repeatMm !== undefined && mine.some((other) => Math.hypot(other.x - box.x, other.y - box.y) < job.rule.repeatMm!)) return false;\n room.boxes.push(box);\n mine.push({ layer: layer.id, text: job.text, x: box.x, y: box.y, angle: (box.angle * 180) / Math.PI + 0, sizeMm: job.rule.sizeMm, widthMm: job.width });\n return true;\n };\n for (const position of job.points) {\n const p = paperOf(position, view);\n if (p.x < 0 || p.y < 0 || p.x > view.frame.widthMm || p.y > view.frame.heightMm) continue;\n onFrame = true;\n pointCandidates(p, job.width, job.rule.sizeMm, layer.pointSizeMm ?? 0).some(take);\n }\n if (lineRuns.length > 0) onFrame = true;\n lines: for (const { run } of lineRuns) {\n for (const box of lineCandidates(run, job.width, job.rule.sizeMm)) {\n if (take(box) && job.rule.repeatMm === undefined) break lines;\n }\n }\n for (const area of job.areas) {\n if (!areaOnFrame(area, view)) continue;\n onFrame = true;\n areaCandidates(area, view, job.width, job.rule.sizeMm).some(take);\n }\n if (mine.length === 0 && onFrame) skipped.push({ layer: layer.id, text: job.text });\n placed.push(...mine);\n }\n }\n return { placed, skipped };\n}\n\n/** This function gives the SVG of the labels: black text with a white halo, so a label reads over the lines of the map. */\nexport function labelsSvg(placement: LabelPlacement, font: LabelFont): string {\n const texts = placement.placed.map((label) => {\n const rotate = label.angle === 0 ? \"\" : ` transform=\"rotate(${mm(label.angle)} ${mm(label.x)} ${mm(label.y)})\"`;\n return (\n `<text x=\"${mm(label.x)}\" y=\"${mm(label.y)}\" font-size=\"${mm(label.sizeMm)}\"${rotate} text-anchor=\"middle\" dominant-baseline=\"central\" ` +\n `fill=\"#000000\" stroke=\"#ffffff\" stroke-width=\"${mm(label.sizeMm * 0.25)}\" stroke-linejoin=\"round\" paint-order=\"stroke\">${escapeHtml(label.text)}</text>`\n );\n });\n return `<g class=\"labels\" font-family=\"${escapeAttribute(font.family)}\" data-skipped=\"${placement.skipped.length}\">${texts.join(\"\")}</g>`;\n}\n","/**\n * The marks of a map: the scale bar, the north arrow and the texts at the edges of the frame.\n *\n * @packageDocumentation\n */\n\nimport { escapeHtml } from \"@mark1russell7/text\";\nimport { mm } from \"./style.ts\";\n\n/** The units of the scale bars of a map. `both` gives a metric bar and an imperial bar. */\nexport type ScaleBarUnits = \"metric\" | \"imperial\" | \"both\" | \"none\";\n\n/** The length of a scale bar on the ground and its label. */\nexport interface ScaleBarLength {\n /** The length on the ground in metres. */\n readonly meters: number;\n /** The label, for example `500 m`, `2 km`, `0.5 mi` or `200 ft`. */\n readonly label: string;\n}\n\nconst METERS_PER_MILE = 1609.344;\nconst METERS_PER_FOOT = 0.3048;\n\n/** This function gives the largest number 1, 2 or 5 times a power of 10 that is not more than a number more than 0. */\nexport function niceNumber(max: number): number {\n const power = 10 ** Math.floor(Math.log10(max));\n for (const step of [5, 2, 1]) {\n const value = Number((step * power).toPrecision(1));\n if (value <= max) return value;\n }\n return Number((power / 2).toPrecision(1));\n}\n\n/**\n * This function gives the length of a scale bar that is not longer than a length on the ground.\n *\n * - The metric bar is in metres below 1 km, and in kilometres from 1 km.\n * - The imperial bar is in miles from a quarter of a mile, and in feet below that.\n */\nexport function scaleBarLength(maxMeters: number, units: \"metric\" | \"imperial\"): ScaleBarLength {\n if (units === \"metric\") {\n const meters = niceNumber(maxMeters);\n return { meters, label: meters >= 1000 ? `${meters / 1000} km` : `${meters} m` };\n }\n const miles = maxMeters / METERS_PER_MILE;\n if (miles >= 0.25) {\n const value = niceNumber(miles);\n return { meters: value * METERS_PER_MILE, label: `${value} mi` };\n }\n const feet = niceNumber(maxMeters / METERS_PER_FOOT);\n return { meters: feet * METERS_PER_FOOT, label: `${feet} ft` };\n}\n\n/** The height of one scale bar with its label, in millimetres. */\nexport const SCALE_BAR_ROW_MM = 4.5;\n\n/** This function gives the SVG of a scale bar of four parts, with its top left corner at a point on the paper. */\nexport function scaleBarSvg(x: number, y: number, length: ScaleBarLength, mmPerMeter: number): string {\n const total = length.meters * mmPerMeter;\n const part = total / 4;\n let parts = \"\";\n for (let i = 0; i < 4; i += 1) {\n parts += `<rect x=\"${mm(x + i * part)}\" y=\"${mm(y)}\" width=\"${mm(part)}\" height=\"1.5\" fill=\"${i % 2 === 0 ? \"#000000\" : \"#ffffff\"}\" stroke=\"#000000\" stroke-width=\"0.15\"/>`;\n }\n return `<g class=\"scale-bar\">${parts}<text x=\"${mm(x + total + 1.5)}\" y=\"${mm(y + 1.5)}\" font-size=\"2.4\">${escapeHtml(length.label)}</text></g>`;\n}\n\n/** This function gives the SVG of a north arrow at a point on the paper, with the direction of north in degrees. */\nexport function northArrowSvg(x: number, y: number, northDegrees: number): string {\n return (\n `<g class=\"north-arrow\" transform=\"translate(${mm(x)} ${mm(y)}) rotate(${mm(northDegrees)})\">` +\n `<circle r=\"4.5\" fill=\"#ffffff\" stroke=\"#000000\" stroke-width=\"0.2\"/>` +\n `<path d=\"M0 -3.6L1.6 1.2L0 0.4L-1.6 1.2Z\" fill=\"#000000\"/>` +\n `<text y=\"3.9\" font-size=\"2.2\" text-anchor=\"middle\">N</text></g>`\n );\n}\n\n/** The four edges of a frame. When north is up, the top edge is at the north. */\nexport type FrameEdge = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The four edges of a frame, in the sequence of the marks. */\nexport const FRAME_EDGES: readonly FrameEdge[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\n/** The size of the font of a text at an edge of the frame, in millimetres. */\nexport const EDGE_TEXT_MM = 2.6;\n\n/** The space in the box of an edge text around the arrow and the text, and the size of the arrow, in millimetres. */\nconst EDGE = { pad: 0.8, arrow: 1.8, gap: 0.7 } as const;\n\n/** The angle of the arrow of each edge. The arrow points out of the frame. */\nconst EDGE_TURN: Readonly<Record<FrameEdge, number>> = { top: 0, right: 90, bottom: 180, left: 270 };\n\n/** The mark of a text at an edge of the frame: its box on the paper and its SVG. */\nexport interface EdgeMark {\n /** The edge of the mark. */\n readonly edge: FrameEdge;\n /** The middle of the box on the paper, in millimetres from the top left corner of the frame. */\n readonly x: number;\n /** The middle of the box on the paper, in millimetres from the top left corner of the frame. */\n readonly y: number;\n /** The half width of the box, in millimetres. */\n readonly halfWidth: number;\n /** The half height of the box, in millimetres. */\n readonly halfHeight: number;\n /** The SVG of the mark: a white box at the middle of the edge, an arrow that points out of the frame, and the text. */\n readonly svg: string;\n}\n\n/**\n * This function gives the marks of the texts at the middle of the edges of a frame, in the sequence top, right, bottom and left.\n * An edge with no text has no mark.\n *\n * @param measure - This function gives the width of a text in millimetres at the size `EDGE_TEXT_MM`.\n */\nexport function edgeMarks(widthMm: number, heightMm: number, texts: Readonly<Partial<Record<FrameEdge, string>>>, measure: (text: string) => number): EdgeMark[] {\n return FRAME_EDGES.flatMap((edge) => {\n const text = texts[edge];\n if (text === undefined) return [];\n const boxWidth = 2 * EDGE.pad + EDGE.arrow + EDGE.gap + measure(text);\n const boxHeight = 2 * EDGE.pad + EDGE_TEXT_MM;\n const x = edge === \"left\" ? boxWidth / 2 : edge === \"right\" ? widthMm - boxWidth / 2 : widthMm / 2;\n const y = edge === \"top\" ? boxHeight / 2 : edge === \"bottom\" ? heightMm - boxHeight / 2 : heightMm / 2;\n const left = x - boxWidth / 2;\n const top = y - boxHeight / 2;\n const arrowX = left + EDGE.pad + EDGE.arrow / 2;\n const half = EDGE.arrow / 2;\n const svg =\n `<g class=\"edge-${edge}\"><rect x=\"${mm(left)}\" y=\"${mm(top)}\" width=\"${mm(boxWidth)}\" height=\"${mm(boxHeight)}\" fill=\"#ffffff\" stroke=\"#000000\" stroke-width=\"0.2\"/>` +\n `<path transform=\"translate(${mm(arrowX)} ${mm(y)}) rotate(${EDGE_TURN[edge]})\" d=\"M0 ${mm(-half)}L${mm(half)} ${mm(half)}L${mm(-half)} ${mm(half)}Z\" fill=\"#000000\"/>` +\n `<text x=\"${mm(arrowX + half + EDGE.gap)}\" y=\"${mm(y + EDGE_TEXT_MM * 0.35)}\" font-size=\"${EDGE_TEXT_MM}\" font-weight=\"bold\">${escapeHtml(text)}</text></g>`;\n return [{ edge, x, y, halfWidth: boxWidth / 2, halfHeight: boxHeight / 2, svg }];\n });\n}\n","/**\n * A map as data, and its render to SVG.\n *\n * @packageDocumentation\n */\n\nimport { simplifyRegions, type Feature, type Geometry, type Position, type Region } from \"@mark1russell7/geo\";\nimport { escapeAttribute, escapeHtml } from \"@mark1russell7/text\";\nimport { MapError } from \"./errors.ts\";\nimport { checkFilter, matchesFilter, type Filter } from \"./filter.ts\";\nimport { frameView, type Frame, type FrameView, type PaperPoint } from \"./frame.ts\";\nimport { checkLabelRule, labelsSvg, placeLabels, type LabelFont, type LabelPlacement, type LabelRule } from \"./labels.ts\";\nimport { EDGE_TEXT_MM, edgeMarks, FRAME_EDGES, northArrowSvg, SCALE_BAR_ROW_MM, scaleBarLength, scaleBarSvg, type EdgeMark, type FrameEdge, type ScaleBarUnits } from \"./marks.ts\";\nimport { checkStyle, grayColor, hatchPattern, mm, pointSymbol, strokeAttributes, type Style } from \"./style.ts\";\n\n/** The source of the data of a layer. The map prints each source in its attribution block. */\nexport interface Source {\n /** The name of the source, for example `© OpenStreetMap contributors`. */\n readonly title: string;\n /** The license of the data, for example `ODbL 1.0`. */\n readonly license: string;\n /** The web address of the source or of its license. */\n readonly url?: string;\n /** The date of the data, for example `2026-11-21`. */\n readonly date?: string;\n}\n\n/** A layer of a map: features, a filter, a style and the source of the features. */\nexport interface Layer {\n /** The identifier of the layer: lower case letters, digits and hyphens. It starts with a letter. */\n readonly id: string;\n /** The features. Their positions are `[lon, lat]` on WGS84. */\n readonly features: readonly Feature[];\n /** The style of the features. */\n readonly style: Style;\n /** The source of the features. */\n readonly source: Source;\n /** The filter of the features. No filter keeps each feature. */\n readonly filter?: Filter;\n /** The text of the layer in the legend. No text gives no entry in the legend. */\n readonly legend?: string;\n /** The tolerance in millimetres on the paper for the simplification of the areas. No value keeps each position. */\n readonly simplifyMm?: number;\n /** The rule of the labels of the features. No rule gives no labels. */\n readonly label?: LabelRule;\n}\n\n/** A map: a frame, layers from the bottom to the top, and its marks. */\nexport interface MapDocument {\n /** The identifier of the map: lower case letters, digits and hyphens. It starts each identifier in the SVG. */\n readonly id: string;\n /** The title of the map, for a reader of the screen. */\n readonly title: string;\n /** The frame. */\n readonly frame: Frame;\n /** The layers, from the bottom to the top. */\n readonly layers: readonly Layer[];\n /** The units of the scale bars. The default is `both`. */\n readonly scaleBar?: ScaleBarUnits;\n /** The value `false` gives no north arrow. The default is `true`. */\n readonly northArrow?: boolean;\n /** The place of the scale bars and the legend. The default is `below`. `fitFrame` finds the place with the largest frame. */\n readonly legendPlace?: LegendPlace;\n /**\n * The texts at the middle of the edges of the frame, for example the names of the neighbor pages of an atlas.\n * Each text is in a white box with an arrow that points out of the frame. No labels cover the boxes.\n */\n readonly edges?: Readonly<Partial<Record<FrameEdge, string>>>;\n}\n\n/** The place of the scale bars and the legend: below the frame, or in a column at the right side of the frame. */\nexport type LegendPlace = \"below\" | \"side\";\n\nconst LEGEND_PLACES: readonly LegendPlace[] = [\"below\", \"side\"];\n\nconst ID = /^[a-z][a-z0-9-]*$/;\n\nfunction checkId(id: string, what: string): void {\n if (!ID.test(id)) throw new MapError(\"id\", `The identifier \"${id}\" of the ${what} is not lower case letters, digits and hyphens that start with a letter`);\n}\n\nfunction checkSource(source: Source | undefined, layer: string): void {\n if (source === undefined || typeof source !== \"object\") throw new MapError(\"source\", `The layer \"${layer}\" has no source`);\n if (typeof source.title !== \"string\" || source.title.trim() === \"\") throw new MapError(\"source\", `The source of the layer \"${layer}\" has no title`);\n if (typeof source.license !== \"string\" || source.license.trim() === \"\") throw new MapError(\"source\", `The source of the layer \"${layer}\" has no license`);\n}\n\n/**\n * This function examines a map. It refuses a frame, an identifier, a style, a filter or a source that is not correct.\n * Each layer must have a source with a title and a license, so the attribution block names each source of the map.\n *\n * @throws MapError - The code tells the reason.\n */\nexport function checkMap(map: MapDocument): void {\n checkId(map.id, \"map\");\n frameView(map.frame);\n if (map.legendPlace !== undefined && !LEGEND_PLACES.includes(map.legendPlace)) {\n throw new MapError(\"style\", `The place of the legend \"${String(map.legendPlace)}\" is not \"below\" or \"side\"`);\n }\n const ids = new Set<string>();\n for (const layer of map.layers) {\n checkId(layer.id, \"layer\");\n if (ids.has(layer.id)) throw new MapError(\"id\", `Two layers have the identifier \"${layer.id}\"`);\n ids.add(layer.id);\n checkSource(layer.source, layer.id);\n checkStyle(layer.style, layer.id);\n if (layer.filter !== undefined) checkFilter(layer.filter, `layer \"${layer.id}\" filter`);\n if (layer.label !== undefined) checkLabelRule(layer.label, layer.id);\n if (layer.simplifyMm !== undefined && !(Number.isFinite(layer.simplifyMm) && layer.simplifyMm > 0)) {\n throw new MapError(\"style\", `The layer \"${layer.id}\": the tolerance ${layer.simplifyMm} is not a finite number more than 0`);\n }\n }\n if (map.edges !== undefined) {\n if (typeof map.edges !== \"object\" || map.edges === null) throw new MapError(\"label\", \"The edge texts of the map are not an object\");\n for (const [edge, text] of Object.entries(map.edges)) {\n if (!(FRAME_EDGES as readonly string[]).includes(edge)) throw new MapError(\"label\", `The edge \"${edge}\" is not top, right, bottom or left`);\n if (text !== undefined && (typeof text !== \"string\" || text.trim() === \"\")) throw new MapError(\"label\", `The text of the edge \"${edge}\" is not a text that is not empty`);\n }\n }\n}\n\n/** The box of the points on the paper that a feature uses. */\nclass PaperBox {\n minX = Number.POSITIVE_INFINITY;\n minY = Number.POSITIVE_INFINITY;\n maxX = Number.NEGATIVE_INFINITY;\n maxY = Number.NEGATIVE_INFINITY;\n\n add(point: PaperPoint): void {\n this.minX = Math.min(this.minX, point.x);\n this.minY = Math.min(this.minY, point.y);\n this.maxX = Math.max(this.maxX, point.x);\n this.maxY = Math.max(this.maxY, point.y);\n }\n\n /** It tells if the box touches the frame, with a margin in millimetres. */\n touches(frame: Frame, margin: number): boolean {\n return this.maxX >= -margin && this.minX <= frame.widthMm + margin && this.maxY >= -margin && this.minY <= frame.heightMm + margin;\n }\n}\n\nfunction paperOf(position: Position, view: FrameView): PaperPoint {\n return view.toPaper({ lat: position[1] as number, lon: position[0] as number });\n}\n\nfunction linePath(positions: readonly Position[], view: FrameView, box: PaperBox, close: boolean): string {\n let d = \"\";\n positions.forEach((position, i) => {\n const point = paperOf(position, view);\n box.add(point);\n d += `${i === 0 ? \"M\" : \"L\"}${mm(point.x)} ${mm(point.y)}`;\n });\n return close ? `${d}Z` : d;\n}\n\n/** This function gives the SVG of one geometry with a style. */\nfunction drawGeometry(geometry: Geometry, style: Style, view: FrameView, fill: string | undefined): string {\n const frame = view.frame;\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\": {\n if (style.point === undefined) return \"\";\n const positions = geometry.type === \"Point\" ? [geometry.coordinates] : geometry.coordinates;\n return positions\n .map((position) => paperOf(position, view))\n .filter((point) => point.x >= -style.point!.sizeMm && point.x <= frame.widthMm + style.point!.sizeMm && point.y >= -style.point!.sizeMm && point.y <= frame.heightMm + style.point!.sizeMm)\n .map((point) => pointSymbol(style.point!, point.x, point.y))\n .join(\"\");\n }\n case \"LineString\":\n case \"MultiLineString\": {\n if (style.stroke === undefined) return \"\";\n const box = new PaperBox();\n const lines = geometry.type === \"LineString\" ? [geometry.coordinates] : geometry.coordinates;\n const d = lines.map((line) => linePath(line, view, box, false)).join(\"\");\n if (!box.touches(frame, style.stroke.widthMm)) return \"\";\n return `<path d=\"${d}\" fill=\"none\" ${strokeAttributes(style.stroke)}/>`;\n }\n case \"Polygon\":\n case \"MultiPolygon\": {\n const box = new PaperBox();\n const polygons = geometry.type === \"Polygon\" ? [geometry.coordinates] : geometry.coordinates;\n const d = polygons.flatMap((rings) => rings.map((ring) => linePath(ring, view, box, true))).join(\"\");\n if (!box.touches(frame, style.stroke?.widthMm ?? 0)) return \"\";\n const stroke = style.stroke === undefined ? `stroke=\"none\"` : strokeAttributes(style.stroke);\n let svg = \"\";\n if (style.fill?.gray !== undefined) svg += `<path d=\"${d}\" fill=\"${grayColor(style.fill.gray)}\" fill-rule=\"evenodd\" stroke=\"none\"/>`;\n svg += `<path d=\"${d}\" fill=\"${fill ?? \"none\"}\" fill-rule=\"evenodd\" ${stroke}/>`;\n return svg;\n }\n case \"GeometryCollection\":\n return geometry.geometries.map((item) => drawGeometry(item, style, view, fill)).join(\"\");\n }\n}\n\n/** This function gives the features of a layer after its filter and its simplification. */\nfunction featuresOf(layer: Layer, frame: Frame): Feature[] {\n const kept = layer.features.filter((feature) => feature.geometry !== null && (layer.filter === undefined || matchesFilter(layer.filter, feature)));\n if (layer.simplifyMm === undefined) return kept;\n const areas = kept.flatMap((feature, i) => (feature.geometry?.type === \"Polygon\" || feature.geometry?.type === \"MultiPolygon\" ? [i] : []));\n if (areas.length === 0) return kept;\n // A tolerance of t mm on the paper is t * scale mm on the ground, and t * scale / 1e6 km.\n const simplified = simplifyRegions(\n areas.map((i) => kept[i]!.geometry as Region),\n (layer.simplifyMm * frame.scale) / 1e6,\n );\n const result = [...kept];\n areas.forEach((index, j) => {\n result[index] = { ...kept[index]!, geometry: simplified[j]! };\n });\n return result;\n}\n\n/** The options of `renderMap` and `mapLabels`. */\nexport interface RenderOptions {\n /** The font of the labels. A map with a label rule needs it. */\n readonly labelFont?: LabelFont;\n}\n\n/** The middle of the north arrow, from the top right corner of the frame, and the half size of its box, in millimetres. */\nconst NORTH_ARROW = { inset: 6.5, half: 4.7 };\n\n/** This function gives the marks of the edge texts of a map. Without a font, the width of a text is an estimate. */\nfunction edgeMarksOf(map: MapDocument, font: LabelFont | undefined): EdgeMark[] {\n const measure = (text: string): number => (font === undefined ? text.length * EDGE_TEXT_MM * CHARACTER_WIDTH : font.measure(text, EDGE_TEXT_MM));\n return edgeMarks(map.frame.widthMm, map.frame.heightMm, map.edges ?? {}, measure);\n}\n\nfunction placementOf(map: MapDocument, features: readonly Feature[][], view: FrameView, font: LabelFont): LabelPlacement {\n const obstacles = [\n ...(map.northArrow === false ? [] : [{ x: map.frame.widthMm - NORTH_ARROW.inset, y: NORTH_ARROW.inset, half: NORTH_ARROW.half }]),\n ...edgeMarksOf(map, font).map((mark) => ({ x: mark.x, y: mark.y, half: mark.halfWidth, halfHeight: mark.halfHeight })),\n ];\n const layers = map.layers.map((layer, i) => ({ id: layer.id, features: features[i]!, label: layer.label, pointSizeMm: layer.style.point?.sizeMm }));\n return placeLabels(layers, view, font, obstacles);\n}\n\nfunction labelFontOf(map: MapDocument, options: RenderOptions): LabelFont | undefined {\n const labelled = map.layers.find((layer) => layer.label !== undefined);\n if (labelled === undefined) return undefined;\n const font = options.labelFont;\n if (font === undefined || typeof font.measure !== \"function\" || typeof font.family !== \"string\" || font.family.trim() === \"\") {\n throw new MapError(\"label\", `The layer \"${labelled.id}\" has labels, so the options need a label font with a family and a measure`);\n }\n return font;\n}\n\n/**\n * This function gives the labels of a map with their places, and the texts with no place. `renderMap` draws the same\n * labels.\n *\n * @throws MapError - The map is not correct, as `checkMap` tells, or a layer has labels and the options have no font.\n */\nexport function mapLabels(map: MapDocument, options: RenderOptions = {}): LabelPlacement {\n checkMap(map);\n const font = labelFontOf(map, options);\n if (font === undefined) return { placed: [], skipped: [] };\n return placementOf(map, map.layers.map((layer) => featuresOf(layer, map.frame)), frameView(map.frame), font);\n}\n\n/** This function gives the swatch of a layer in the legend, with its top left corner at a point. */\nfunction swatch(style: Style, x: number, y: number, fill: string | undefined): string {\n if (style.point !== undefined) return pointSymbol(style.point, x + 3, y + 1.75);\n if (style.fill !== undefined) {\n const stroke = style.stroke === undefined ? `stroke=\"#000000\" stroke-width=\"0.1\"` : strokeAttributes(style.stroke);\n const base = style.fill.gray === undefined ? \"\" : `<rect x=\"${mm(x)}\" y=\"${mm(y)}\" width=\"6\" height=\"3.5\" fill=\"${grayColor(style.fill.gray)}\"/>`;\n return `${base}<rect x=\"${mm(x)}\" y=\"${mm(y)}\" width=\"6\" height=\"3.5\" fill=\"${fill ?? \"none\"}\" ${stroke}/>`;\n }\n return `<path d=\"M${mm(x)} ${mm(y + 1.75)}L${mm(x + 6)} ${mm(y + 1.75)}\" ${strokeAttributes(style.stroke!)}/>`;\n}\n\nfunction thousands(value: number): string {\n return String(Math.round(value)).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n}\n\n/** The space between the frame and the column of the legend at the side, in millimetres. */\nconst SIDE_GAP_MM = 3;\n/** The space above the first row of the column of the legend at the side, in millimetres. */\nconst SIDE_TOP_MM = 1;\n/** The least width of the column of the legend at the side, in millimetres. */\nconst SIDE_LEAST_WIDTH_MM = 30;\n/** The space between the scale bars and the legend in the column at the side, in millimetres. */\nconst SIDE_GROUP_GAP_MM = 1.5;\n/** The space at the right of a scale bar in the column at the side for its label, in millimetres. */\nconst SCALE_LABEL_MM = 12;\n/** The size of the font of the legend texts, in millimetres. */\nconst LEGEND_TEXT_MM = 2.4;\n/** The distance from the left side of a swatch to its text, in millimetres. */\nconst LEGEND_TEXT_X_MM = 7.5;\n/** The width of a character of a legend text, as a part of the size of the font, when the options have no font. */\nconst CHARACTER_WIDTH = 0.6;\n\n/** The parts of the legend of a map, with the space that they use. The size of the frame does not change them. */\ninterface LegendLayout {\n readonly bars: readonly (\"metric\" | \"imperial\")[];\n readonly lines: readonly string[];\n /** The width of the column at the side, or 0. */\n readonly columnMm: number;\n /** The height of the column at the side, or 0. */\n readonly columnHeightMm: number;\n /** The height of the block of the scale bars and the legend below the frame, or 0. */\n readonly blockMm: number;\n}\n\n/** This function gives the font that measures the legend texts: the label font of the options, if it has a measure. */\nfunction measureFontOf(options: RenderOptions): LabelFont | undefined {\n const font = options.labelFont;\n return font !== undefined && typeof font.measure === \"function\" ? font : undefined;\n}\n\nfunction legendLayout(map: MapDocument, font: LabelFont | undefined): LegendLayout {\n const units = map.scaleBar ?? \"both\";\n const bars = units === \"none\" ? [] : units === \"both\" ? ([\"metric\", \"imperial\"] as const) : [units];\n const texts = map.layers.flatMap((layer) => (layer.legend === undefined ? [] : [layer.legend]));\n const lines = attributionLines(map);\n const place = map.legendPlace ?? \"below\";\n if (place === \"below\" || bars.length + texts.length === 0) {\n const blockMm = place === \"below\" ? Math.max(bars.length, Math.ceil(texts.length / 2)) * SCALE_BAR_ROW_MM : 0;\n return { bars, lines, columnMm: 0, columnHeightMm: 0, blockMm };\n }\n const width = (text: string): number => (font === undefined ? text.length * LEGEND_TEXT_MM * CHARACTER_WIDTH : font.measure(text, LEGEND_TEXT_MM));\n const widest = Math.max(0, ...texts.map(width));\n const columnMm = Math.max(SIDE_LEAST_WIDTH_MM, LEGEND_TEXT_X_MM + widest + 1);\n const gap = bars.length > 0 && texts.length > 0 ? SIDE_GROUP_GAP_MM : 0;\n const columnHeightMm = SIDE_TOP_MM + (bars.length + texts.length) * SCALE_BAR_ROW_MM + gap;\n return { bars, lines, columnMm, columnHeightMm, blockMm: 0 };\n}\n\n/** The space of the SVG of a map around its frame, in millimetres. */\nexport interface MapMargins {\n /** The width at the right of the frame: the gap and the column of the legend at the side, or 0. */\n readonly rightMm: number;\n /** The height below the frame: the legend below the frame, if it is there, and the attribution block. */\n readonly belowMm: number;\n /** The height of the column of the legend at the side, or 0. A frame with less height makes the SVG taller. */\n readonly leastHeightMm: number;\n}\n\nfunction marginsOf(layout: LegendLayout): MapMargins {\n return {\n rightMm: layout.columnMm === 0 ? 0 : SIDE_GAP_MM + layout.columnMm,\n belowMm: 2 + layout.blockMm + 2.5 + (layout.lines.length - 1) * 3 + 1.5,\n leastHeightMm: layout.columnHeightMm,\n };\n}\n\n/**\n * This function gives the space of the SVG of a map around its frame, for the place of the legend of the map. The\n * size of the frame does not change it.\n *\n * - The label font of the options measures the legend texts. With no font, each character is 0.6 of the size of the font.\n * - The SVG of the map is `rightMm` wider and `belowMm` taller than its frame.\n *\n * @throws MapError - The map is not correct, as `checkMap` tells.\n */\nexport function mapMargins(map: MapDocument, options: RenderOptions = {}): MapMargins {\n checkMap(map);\n return marginsOf(legendLayout(map, measureFontOf(options)));\n}\n\n/** A space for the SVG of a map, in millimetres, for example the printable area of a paper below a heading. */\nexport interface MapSpace {\n readonly widthMm: number;\n readonly heightMm: number;\n}\n\n/** The options of `fitFrame`. */\nexport interface FitOptions {\n /** The font of the labels. It also measures the legend texts. */\n readonly labelFont?: LabelFont;\n /** The places of the legend to examine. The default is `below` and `side`. */\n readonly places?: readonly LegendPlace[];\n}\n\n/** The frame with the largest area for a map in one of a list of spaces. */\nexport interface FrameFit {\n readonly widthMm: number;\n readonly heightMm: number;\n readonly legendPlace: LegendPlace;\n /** The index of the space of the frame in the list of spaces. */\n readonly space: number;\n}\n\n/**\n * This function gives the frame with the largest area for a map in one of a list of spaces, and the place of its\n * legend. The SVG of the map with that frame and that place fits that space.\n *\n * - Give one space for each choice of the caller, for example a paper upright and the same paper in landscape.\n * - The scale of the map does not change, so a larger frame shows more ground.\n * - The size of the frame of the map does not change the result.\n * - With two choices of equal area, the first place of the options wins, and then the first space.\n *\n * @throws MapError - The map is not correct, a place or a space is not correct, or no choice leaves space for a frame.\n */\nexport function fitFrame(map: MapDocument, spaces: readonly MapSpace[], options: FitOptions = {}): FrameFit {\n checkMap(map);\n for (const { widthMm, heightMm } of spaces) {\n if (![widthMm, heightMm].every((value) => Number.isFinite(value) && value > 0)) {\n throw new MapError(\"frame\", `The space ${widthMm} by ${heightMm} mm is not two finite numbers more than 0`);\n }\n }\n const places = options.places ?? LEGEND_PLACES;\n const font = measureFontOf(options);\n let best: FrameFit | undefined;\n for (const place of places) {\n if (!LEGEND_PLACES.includes(place)) throw new MapError(\"style\", `The place of the legend \"${String(place)}\" is not \"below\" or \"side\"`);\n const margins = marginsOf(legendLayout({ ...map, legendPlace: place }, font));\n for (const [index, { widthMm, heightMm }] of spaces.entries()) {\n const frameWidth = widthMm - margins.rightMm;\n const frameHeight = heightMm - margins.belowMm;\n if (!(frameWidth > 0 && frameHeight > 0 && frameHeight >= margins.leastHeightMm)) continue;\n if (best === undefined || frameWidth * frameHeight > best.widthMm * best.heightMm) {\n best = { widthMm: frameWidth, heightMm: frameHeight, legendPlace: place, space: index };\n }\n }\n }\n if (best === undefined) throw new MapError(\"frame\", \"No space of the list has space for a frame after the legend\");\n return best;\n}\n\n/** This function gives the lines of the attribution block: the scale, the projection and each source one time. */\nexport function attributionLines(map: MapDocument): string[] {\n const lines = [`Scale 1:${thousands(map.frame.scale)} at the center. Projection: ${map.frame.projection.name}.`];\n const seen = new Set<string>();\n for (const { source } of map.layers) {\n const line = `Data: ${source.title}. License: ${source.license}.${source.url === undefined ? \"\" : ` ${source.url}`}${source.date === undefined ? \"\" : ` Date: ${source.date}.`}`;\n if (seen.has(line)) continue;\n seen.add(line);\n lines.push(line);\n }\n return lines;\n}\n\n/**\n * This function gives the SVG of a map. The units of the SVG are millimetres, for a print at the scale of the frame.\n *\n * - The map is at the top. Below it are the scale bars, the legend and the attribution block.\n * - With the place `side`, the scale bars and the legend are in a column at the right of the frame. The attribution\n * block stays below.\n * - The layers are in their sequence, from the bottom to the top. The frame clips each layer.\n * - A feature that is not on the frame is not in the SVG.\n * - Each identifier in the SVG starts with the identifier of the map. Thus two maps can be in one HTML page.\n * - The labels are above the layers. `placeLabels` tells their places. The group of the labels tells the number of\n * texts with no place in `data-skipped`.\n *\n * @throws MapError - The map is not correct, as `checkMap` tells, or a layer has labels and the options have no font.\n * @throws GeoError - A position is not correct for the projection.\n */\nexport function renderMap(map: MapDocument, options: RenderOptions = {}): string {\n checkMap(map);\n const font = labelFontOf(map, options);\n const view = frameView(map.frame);\n const { widthMm: w, heightMm: h } = map.frame;\n const defs: string[] = [`<clipPath id=\"${map.id}-clip\"><rect width=\"${mm(w)}\" height=\"${mm(h)}\"/></clipPath>`];\n const fills = map.layers.map((layer) => {\n const hatch = layer.style.fill?.hatch;\n if (hatch === undefined) return undefined;\n const id = `${map.id}-${layer.id}-hatch`;\n defs.push(hatchPattern(id, hatch));\n return `url(#${id})`;\n });\n const features = map.layers.map((layer) => featuresOf(layer, map.frame));\n const layers = map.layers.map((layer, i) => {\n const body = features[i]!\n .map((feature) => drawGeometry(feature.geometry as Geometry, layer.style, view, fills[i]))\n .join(\"\");\n return `<g id=\"${map.id}-${layer.id}\">${body}</g>`;\n });\n const labels = font === undefined ? \"\" : labelsSvg(placementOf(map, features, view, font), font);\n\n const layout = legendLayout(map, measureFontOf(options));\n const side = layout.columnMm > 0;\n const { bars, lines } = layout;\n const top = (side ? Math.max(h, layout.columnHeightMm) : h) + 2;\n const sideX = w + SIDE_GAP_MM;\n const maxMeters = (side ? layout.columnMm - SCALE_LABEL_MM : 0.3 * w) / view.mmPerMeter;\n const scaleBars = bars\n .map((unit, i) => {\n const length = scaleBarLength(maxMeters, unit);\n return side ? scaleBarSvg(sideX, SIDE_TOP_MM + i * SCALE_BAR_ROW_MM, length, view.mmPerMeter) : scaleBarSvg(0.5, top + i * SCALE_BAR_ROW_MM, length, view.mmPerMeter);\n })\n .join(\"\");\n const legendLayers = map.layers.flatMap((layer, i) => (layer.legend === undefined ? [] : [{ layer, fill: fills[i] }]));\n const columnWidth = w * 0.275;\n const sideTop = SIDE_TOP_MM + bars.length * SCALE_BAR_ROW_MM + (bars.length > 0 ? SIDE_GROUP_GAP_MM : 0);\n const legend = legendLayers\n .map(({ layer, fill }, i) => {\n const x = side ? sideX : w * 0.45 + (i % 2) * columnWidth;\n const y = side ? sideTop + i * SCALE_BAR_ROW_MM : top + Math.floor(i / 2) * SCALE_BAR_ROW_MM - 1;\n return `${swatch(layer.style, x, y, fill)}<text x=\"${mm(x + LEGEND_TEXT_X_MM)}\" y=\"${mm(y + 2.9)}\" font-size=\"${LEGEND_TEXT_MM}\">${escapeHtml(layer.legend!)}</text>`;\n })\n .join(\"\");\n const firstLine = top + layout.blockMm + 2.5;\n const attribution = lines.map((line, i) => `<text x=\"0.5\" y=\"${mm(firstLine + i * 3)}\" font-size=\"2.2\">${escapeHtml(line)}</text>`).join(\"\");\n const total = firstLine + (lines.length - 1) * 3 + 1.5;\n const width = side ? sideX + layout.columnMm : w;\n const arrow = map.northArrow === false ? \"\" : northArrowSvg(w - 6.5, 6.5, view.northDegrees);\n const edges = edgeMarksOf(map, measureFontOf(options))\n .map((mark) => mark.svg)\n .join(\"\");\n\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${mm(width)}mm\" height=\"${mm(total)}mm\" viewBox=\"0 0 ${mm(width)} ${mm(total)}\" ` +\n `role=\"img\" aria-label=\"${escapeAttribute(map.title)}\" font-family=\"sans-serif\">` +\n `<title>${escapeHtml(map.title)}</title><defs>${defs.join(\"\")}</defs>` +\n `<rect width=\"${mm(width)}\" height=\"${mm(total)}\" fill=\"#ffffff\"/>` +\n `<g clip-path=\"url(#${map.id}-clip)\">${layers.join(\"\")}</g>${labels}` +\n `<rect width=\"${mm(w)}\" height=\"${mm(h)}\" fill=\"none\" stroke=\"#000000\" stroke-width=\"0.3\"/>` +\n `${arrow}${edges}<g class=\"legend\">${scaleBars}${legend}</g><g class=\"attribution\">${attribution}</g></svg>`\n );\n}\n\n"],"mappings":";;;;AAoBA,IAAa,WAAb,cAA8B,MAAM;;CAEzB;;;;;CAMT,YAAY,MAAoB,SAAiB;EAC/C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;;;;;ACgBA,SAAgB,WAAW,OAAoB;CAC7C,KAAK,MAAM,CAAC,MAAM,UAAU;EAC1B,CAAC,SAAS,MAAM,KAAK;EACrB,CAAC,SAAS,MAAM,OAAO;EACvB,CAAC,UAAU,MAAM,QAAQ;CAC3B,GACE,IAAI,EAAE,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,SAAS,SAAS,OAAO,KAAK,GAAG,MAAM,iDAAiD;AAElJ;;;;;;;;;;;;AAaA,SAAgB,UAAU,OAAyB;CACjD,WAAW,KAAK;CAChB,MAAM,EAAE,YAAY,WAAW;CAC/B,MAAM,UAAU,WAAW,MAAM,MAAM;CACvC,MAAM,aAAa,MAAO,MAAM;CAChC,MAAM,kBAAkB,aAAa,KAAK,KAAK,QAAQ,MAAM,QAAQ,GAAG;CACxE,MAAM,SAAS,WAAW,QAAQ,MAAM;CACxC,MAA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G,GAAG,IAAI,EAAE,WAAW,GAAG,IAAI,gBAAgB,EAAE,OAAO,GAAG,IAAI,GAAG,EAAE,eAAe,eAAe,IAAI,WAAW,MAAM,MAAO,EAAE;CAC/J,CAAC,CAAC,CACD,KAAK,EAAE;CACV,MAAM,YAAY,MAAM,OAAO,UAAU;CACzC,MAAM,cAAc,MAAM,KAAK,MAAM,MAAM,oBAAoB,GAAG,YAAY,IAAI,CAAC,EAAE,oBAAoB,WAAW,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE;CAC3I,MAAM,QAAQ,aAAa,MAAM,SAAS,KAAK,IAAI;CACnD,MAAM,QAAQ,OAAO,QAAQ,OAAO,WAAW;CAC/C,MAAM,QAAQ,IAAI,eAAe,QAAQ,KAAK,cAAc,IAAI,KAAK,KAAK,KAAK,YAAY;CAC3F,MAAM,QAAQ,YAAY,KAAK,cAAc,OAAO,CAAC,CAAC,CACnD,KAAK,SAAS,KAAK,GAAG,CAAC,CACvB,KAAK,EAAE;CAEV,OACE,kDAAkD,GAAG,KAAK,EAAE,cAAc,GAAG,KAAK,EAAE,mBAAmB,GAAG,KAAK,EAAE,GAAG,GAAG,KAAK,EAAE,2BACpG,gBAAgB,IAAI,KAAK,EAAE,oCAC3C,WAAW,IAAI,KAAK,EAAE,gBAAgB,KAAK,KAAK,EAAE,EAAE,sBAC9C,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK,EAAE,uCAC1B,IAAI,GAAG,UAAU,OAAO,KAAK,EAAE,EAAE,MAAM,OAAA,eAC7C,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,qDACrC,QAAQ,MAAM,oBAAoB,YAAY,OAAO,6BAA6B,YAAY;AAErG"}
1
+ {"version":3,"file":"index.js","names":["paperOf"],"sources":["../src/errors.ts","../src/frame.ts","../src/atlas.ts","../src/filter.ts","../src/style.ts","../src/labels.ts","../src/marks.ts","../src/render.ts"],"sourcesContent":["/**\n * The error of this package. Each refusal has a code, so a caller can test the reason without the text of the message.\n *\n * @packageDocumentation\n */\n\n/**\n * The reason of a refusal.\n *\n * - `frame`: the scale or the size of a frame is not a finite number more than 0.\n * - `id`: an identifier is not lower case letters, digits and hyphens, or two layers have the same identifier.\n * - `filter`: a filter is not one of the forms of `Filter`.\n * - `style`: a style draws nothing, or a size, a gray level, a dash or the count of decimals is not correct.\n * - `source`: a layer has no source, or its source has no title or no license.\n * - `label`: a label rule, a label font or an edge text is not correct.\n * - `atlas`: the radius or the overlap of an atlas is not correct.\n */\nexport type MapErrorCode = \"frame\" | \"id\" | \"filter\" | \"style\" | \"source\" | \"label\" | \"atlas\";\n\n/** The error that each function of this package throws for an incorrect map. */\nexport class MapError extends Error {\n /** The reason of the refusal. */\n readonly code: MapErrorCode;\n\n /**\n * @param code - The reason of the refusal.\n * @param message - The text for a person.\n */\n constructor(code: MapErrorCode, message: string) {\n super(message);\n this.name = \"MapError\";\n this.code = code;\n }\n}\n","/**\n * The frame of a map: the part of the Earth that the map shows, its scale and its size on the paper.\n *\n * @packageDocumentation\n */\n\nimport { bboxOfPoints, geodesicDirect, type BBox, type LatLon } from \"@mark1russell7/geo\";\nimport type { Projection } from \"@mark1russell7/geo/projection\";\nimport { MapError } from \"./errors.ts\";\n\n/** The frame of a map. The center of the frame is at the middle of the paper. */\nexport interface Frame {\n /** The projection from the Earth to the plane, from `@mark1russell7/geo/projection`. */\n readonly projection: Projection;\n /** The point on the Earth at the middle of the map. */\n readonly center: LatLon;\n /** The denominator of the scale at the center: 24000 for the scale 1:24,000. */\n readonly scale: number;\n /** The width of the map on the paper, in millimetres. */\n readonly widthMm: number;\n /** The height of the map on the paper, in millimetres. */\n readonly heightMm: number;\n}\n\n/** A point on the paper in millimetres, from the top left corner of the map. The y axis points down. */\nexport interface PaperPoint {\n /** The distance to the right, in millimetres. */\n readonly x: number;\n /** The distance down, in millimetres. */\n readonly y: number;\n}\n\n/** The functions of a frame between the Earth and the paper. */\nexport interface FrameView {\n /** The frame. */\n readonly frame: Frame;\n /** The millimetres of paper for one metre on the ground at the center. */\n readonly mmPerMeter: number;\n /** The millimetres of paper for one metre on the plane of the projection. */\n readonly mmPerPlaneMeter: number;\n /** This function gives the point on the paper for a point on the Earth. */\n readonly toPaper: (point: LatLon) => PaperPoint;\n /** This function gives the point on the Earth for a point on the paper. */\n readonly fromPaper: (point: PaperPoint) => LatLon;\n /** The direction of north at the center, in degrees clockwise from the top of the paper. */\n readonly northDegrees: number;\n}\n\n/** This function refuses a frame with a scale or a size that is not a finite number more than 0. */\nexport function checkFrame(frame: Frame): void {\n for (const [name, value] of [\n [\"scale\", frame.scale],\n [\"width\", frame.widthMm],\n [\"height\", frame.heightMm],\n ] as const) {\n if (!(Number.isFinite(value) && value > 0)) throw new MapError(\"frame\", `The ${name} ${value} of the frame is not a finite number more than 0`);\n }\n}\n\n/**\n * This function gives the functions of a frame between the Earth and the paper.\n *\n * - The scale of the frame is the true scale at the center. The function divides by the scale factor of the projection\n * at the center: the square root of `max * min` of `projection.scale`.\n * - For Web Mercator, the scale changes with the latitude. For `azimuthalEquidistant`, it is almost the same on all\n * the map.\n *\n * @throws MapError - The code is `frame`.\n * @throws GeoError - The center is not a correct point for the projection.\n */\nexport function frameView(frame: Frame): FrameView {\n checkFrame(frame);\n const { projection, center } = frame;\n const factors = projection.scale(center);\n const mmPerMeter = 1000 / frame.scale;\n const mmPerPlaneMeter = mmPerMeter / Math.sqrt(factors.max * factors.min);\n const origin = projection.toPlane(center);\n const middleX = frame.widthMm / 2;\n const middleY = frame.heightMm / 2;\n const toPaper = (point: LatLon): PaperPoint => {\n const plane = projection.toPlane(point);\n return { x: middleX + (plane.x - origin.x) * mmPerPlaneMeter, y: middleY - (plane.y - origin.y) * mmPerPlaneMeter };\n };\n const fromPaper = (point: PaperPoint): LatLon =>\n projection.fromPlane({ x: origin.x + (point.x - middleX) / mmPerPlaneMeter, y: origin.y - (point.y - middleY) / mmPerPlaneMeter });\n // The direction of a geodesic of 1 mm on the paper to the north.\n const north = toPaper(geodesicDirect(center, 0, 1 / mmPerMeter).point);\n const northDegrees = (Math.atan2(north.x - middleX, middleY - north.y) * 180) / Math.PI;\n return Object.freeze({ frame, mmPerMeter, mmPerPlaneMeter, toPaper, fromPaper, northDegrees: northDegrees + 0 });\n}\n\n/**\n * This function gives the box on the Earth around the frame, for a fetch of the data of a map. It is the box of 64\n * points on each side of the frame, so it contains the corners and the edges of the frame.\n *\n * @throws MapError - The code is `frame`.\n */\nexport function frameBBox(frame: Frame): BBox {\n const view = frameView(frame);\n const { widthMm: w, heightMm: h } = frame;\n const points: LatLon[] = [];\n const steps = 64;\n for (let i = 0; i < steps; i += 1) {\n const t = i / steps;\n points.push(view.fromPaper({ x: t * w, y: 0 }), view.fromPaper({ x: w, y: t * h }), view.fromPaper({ x: w - t * w, y: h }), view.fromPaper({ x: 0, y: h - t * h }));\n }\n return bboxOfPoints(points) as BBox;\n}\n\n/** The options of `frameAround`. */\nexport interface FrameAroundOptions {\n /** This function gives the projection of the frame for its center, for example `azimuthalEquidistant` of geo. */\n readonly projection: (center: LatLon) => Projection;\n /** The width of the map on the paper, in millimetres. */\n readonly widthMm: number;\n /**\n * The height of the map on the paper, in millimetres. With no height, the scale fits the width only. Then the height\n * is the extent of the points in y at that scale, with the margins. It is rounded up to a whole millimetre.\n */\n readonly heightMm?: number;\n /** The space between each point and the edge of the frame, in millimetres. The default is 0. */\n readonly marginMm?: number;\n /** The center of the frame. The default is the middle of the box of the points. */\n readonly center?: LatLon;\n /** The value `true`, the default, rounds the scale up to a value of `NICE_SCALE_STEPS`. */\n readonly roundScale?: boolean;\n}\n\n/** The first digits of a round scale, for example 1:25,000 or 1:1,500,000. `frameAround` rounds a scale up to one of them. */\nexport const NICE_SCALE_STEPS: readonly number[] = [1, 1.25, 1.5, 2, 2.5, 3, 4, 5, 6, 7.5];\n\n/** This function gives the smallest round scale that is not less than the value, from `NICE_SCALE_STEPS`. */\nexport function niceScale(value: number): number {\n if (!(Number.isFinite(value) && value > 0)) throw new MapError(\"frame\", `The scale ${value} is not a finite number more than 0`);\n const power = 10 ** Math.floor(Math.log10(value));\n for (const step of [...NICE_SCALE_STEPS, 10]) {\n // The factor 1e-9 keeps a value that is already round, against the error of the floating point.\n if (step * power >= value * (1 - 1e-9)) return step * power;\n }\n return 10 * power;\n}\n\n/**\n * This function gives the frame with the largest scale that shows each point inside the margin.\n *\n * - The center is the middle of the box of the points, or the option `center`. The frame has the center at the middle\n * of the paper, so the space on the two sides of the center is the same.\n * - The function finds the scale on the plane of the projection, as `frameView` uses it.\n * - With `roundScale`, the scale goes up to a round value. A larger denominator shows more ground, so each point stays inside.\n * - With no `heightMm`, the scale fits the width only, and the height follows from the points. For a box on the Earth,\n * the points are its 4 corners and the middles of its north and south edges.\n *\n * @throws MapError - The code is `frame`. The reason is no point, a size or a margin that is not correct, or all the\n * points at the center. With no height, the reason can also be all the points on one vertical line, or no height.\n */\nexport function frameAround(points: readonly LatLon[], options: FrameAroundOptions): Frame {\n const { widthMm, heightMm } = options;\n const margin = options.marginMm ?? 0;\n if (points.length === 0) throw new MapError(\"frame\", \"The frame has no point to show\");\n if (!(Number.isFinite(margin) && margin >= 0)) throw new MapError(\"frame\", `The margin ${margin} is not a finite number from 0`);\n checkFrame({ projection: options.projection(points[0]!), center: points[0]!, scale: 1, widthMm, heightMm: heightMm ?? 1 });\n const halfWidth = widthMm / 2 - margin;\n const halfHeight = heightMm === undefined ? Number.POSITIVE_INFINITY : heightMm / 2 - margin;\n if (halfWidth <= 0 || halfHeight <= 0) throw new MapError(\"frame\", `The margin ${margin} mm leaves no space in the frame`);\n const box = bboxOfPoints(points) as BBox;\n const center = options.center ?? { lat: (box.south + box.north) / 2, lon: (box.west + box.east) / 2 };\n const projection = options.projection(center);\n const origin = projection.toPlane(center);\n let reachX = 0;\n let reachY = 0;\n for (const point of points) {\n const plane = projection.toPlane(point);\n reachX = Math.max(reachX, Math.abs(plane.x - origin.x));\n reachY = Math.max(reachY, Math.abs(plane.y - origin.y));\n }\n if (reachX === 0 && reachY === 0) throw new MapError(\"frame\", \"All the points are at the center, so no scale fits them\");\n if (heightMm === undefined && reachX === 0) throw new MapError(\"frame\", \"All the points are on one vertical line, so no scale fits the width\");\n // The plane metres for one millimetre of paper, then the true scale at the center, as frameView gives it.\n const planeMetersPerMm = Math.max(reachX / halfWidth, reachY / halfHeight);\n const factors = projection.scale(center);\n const root = Math.sqrt(factors.max * factors.min);\n const exact = planeMetersPerMm * 1000 * root;\n const scale = options.roundScale === false ? exact : niceScale(exact);\n if (heightMm !== undefined) return { projection, center, scale, widthMm, heightMm };\n // The frame has the center at its middle, so it needs the reach of the points in y on the two sides of the center.\n // The factor 1e-9 keeps a whole value, against the error of the floating point.\n const mmPerPlaneMeter = 1000 / (scale * root);\n const frame: Frame = { projection, center, scale, widthMm, heightMm: Math.ceil((2 * reachY * mmPerPlaneMeter + 2 * margin) * (1 - 1e-9)) };\n checkFrame(frame);\n return frame;\n}\n","/**\n * An atlas: the pages of a large area at one scale, with the names of the neighbor pages and the outlines for an index map.\n *\n * @packageDocumentation\n */\n\nimport type { Feature, LatLon } from \"@mark1russell7/geo\";\nimport type { Projection } from \"@mark1russell7/geo/projection\";\nimport { MapError } from \"./errors.ts\";\nimport { checkFrame, frameView, type Frame } from \"./frame.ts\";\nimport type { FrameEdge } from \"./marks.ts\";\n\n/** The plan of an atlas: the area, the scale and the size of the map on each page. */\nexport interface AtlasPlan {\n /** The projection of all the pages. One projection puts the pages on one plane, so the edges of neighbor pages agree. */\n readonly projection: Projection;\n /** The center of the area on the Earth. The grid of the pages has its middle at this point. */\n readonly center: LatLon;\n /** The radius of the area on the ground, in metres. The atlas keeps each page that shows a part of the circle. */\n readonly radiusMeters: number;\n /** The denominator of the scale of each page: 63360 for the scale 1:63,360 (1 inch for 1 mile). */\n readonly scale: number;\n /** The width of the map on each page, in millimetres. */\n readonly widthMm: number;\n /** The height of the map on each page, in millimetres. */\n readonly heightMm: number;\n /** The width of the strip at each edge that the neighbor page also shows, in millimetres. The default is 10. */\n readonly overlapMm?: number | undefined;\n}\n\n/** One page of an atlas. */\nexport interface AtlasPage {\n /**\n * The name of the page: the letters of its column and the number of its row, for example `B3`.\n * The columns go from west to east, and the rows from north to south.\n */\n readonly id: string;\n /** The index of the column in the grid, from 0 at the west. */\n readonly column: number;\n /** The index of the row in the grid, from 0 at the north. */\n readonly row: number;\n /** The frame of the map of the page. */\n readonly frame: Frame;\n /**\n * The names of the neighbor pages at the edges of the page. An edge with no page in the atlas has no name.\n * The top edge is at the north of the center of the area.\n */\n readonly neighbors: Readonly<Partial<Record<FrameEdge, string>>>;\n}\n\n/** The pages of an atlas, in the order of the rows and then the columns. */\nexport interface Atlas {\n /** The plan of the atlas. */\n readonly plan: AtlasPlan;\n /** The number of columns of the grid. */\n readonly columns: number;\n /** The number of rows of the grid. */\n readonly rows: number;\n /** The pages that show a part of the area. A page of the grid outside the circle is not in the list. */\n readonly pages: readonly AtlasPage[];\n}\n\n/** The default width of the overlap of neighbor pages, in millimetres. */\nexport const ATLAS_OVERLAP_MM = 10;\n\n/**\n * This function gives the name of a column: A to Z, then AA, AB and the next names.\n *\n * @throws MapError - The code is `atlas`. The index is not an integer of 0 or more.\n */\nexport function columnName(index: number): string {\n if (!(Number.isInteger(index) && index >= 0)) throw new MapError(\"atlas\", `The column ${index} is not an integer of 0 or more`);\n let name = \"\";\n for (let rest = index + 1; rest > 0; rest = Math.floor((rest - 1) / 26)) name = String.fromCharCode(65 + ((rest - 1) % 26)) + name;\n return name;\n}\n\n/**\n * This function gives the pages of an atlas: a grid of frames on the plane of the projection.\n * The middle of the grid is at the center of the area.\n *\n * - Neighbor pages share a strip of `overlapMm` at their common edge.\n * - The grid has the smallest number of columns and rows that shows the full circle.\n * - Each page has the scale of the plan at its own center. For `azimuthalEquidistant` over 50 km, the edges of neighbor pages agree to 0.01 mm.\n *\n * @throws MapError - The code is `frame` or `atlas`.\n */\nexport function atlasPages(plan: AtlasPlan): Atlas {\n const overlapMm = plan.overlapMm ?? ATLAS_OVERLAP_MM;\n checkFrame(plan);\n if (!(Number.isFinite(plan.radiusMeters) && plan.radiusMeters > 0)) throw new MapError(\"atlas\", `The radius ${plan.radiusMeters} of the atlas is not a finite number more than 0`);\n if (!(Number.isFinite(overlapMm) && overlapMm >= 0 && overlapMm < Math.min(plan.widthMm, plan.heightMm) / 2)) {\n throw new MapError(\"atlas\", `The overlap ${overlapMm} of the atlas is not from 0 to less than half of the smaller side of the page`);\n }\n const middle = frameView(plan);\n const origin = plan.projection.toPlane(plan.center);\n // All the sizes are in millimetres on the paper, at the scale of the center of the area.\n const radiusMm = plan.radiusMeters * middle.mmPerMeter;\n const stepX = plan.widthMm - overlapMm;\n const stepY = plan.heightMm - overlapMm;\n const columns = Math.max(1, Math.ceil((2 * radiusMm - plan.widthMm) / stepX) + 1);\n const rows = Math.max(1, Math.ceil((2 * radiusMm - plan.heightMm) / stepY) + 1);\n const offsetX = (column: number): number => (column - (columns - 1) / 2) * stepX;\n const offsetY = (row: number): number => ((rows - 1) / 2 - row) * stepY;\n const shows = (column: number, row: number): boolean => {\n if (column < 0 || column >= columns || row < 0 || row >= rows) return false;\n const dx = Math.max(Math.abs(offsetX(column)) - plan.widthMm / 2, 0);\n const dy = Math.max(Math.abs(offsetY(row)) - plan.heightMm / 2, 0);\n return dx * dx + dy * dy < radiusMm * radiusMm;\n };\n const name = (column: number, row: number): string => `${columnName(column)}${row + 1}`;\n const pages: AtlasPage[] = [];\n for (let row = 0; row < rows; row += 1) {\n for (let column = 0; column < columns; column += 1) {\n if (!shows(column, row)) continue;\n const center = plan.projection.fromPlane({ x: origin.x + offsetX(column) / middle.mmPerPlaneMeter, y: origin.y + offsetY(row) / middle.mmPerPlaneMeter });\n const neighbors: Partial<Record<FrameEdge, string>> = {};\n for (const [edge, dc, dr] of [[\"top\", 0, -1], [\"right\", 1, 0], [\"bottom\", 0, 1], [\"left\", -1, 0]] as const) {\n if (shows(column + dc, row + dr)) neighbors[edge] = name(column + dc, row + dr);\n }\n const frame: Frame = { projection: plan.projection, center, scale: plan.scale, widthMm: plan.widthMm, heightMm: plan.heightMm };\n pages.push({ id: name(column, row), column, row, frame, neighbors });\n }\n }\n return { plan, columns, rows, pages };\n}\n\n/**\n * This function gives the outline of each page of an atlas as a polygon feature, with the name of the page in the property `id`.\n * A layer of an index map draws them. Each edge has `pointsPerEdge` points, because the edges of the pages are curves on the Earth.\n *\n * @throws MapError - The code is `atlas`. The number of points is not an integer of 1 or more.\n */\nexport function atlasOutlines(atlas: Atlas, pointsPerEdge = 16): Feature[] {\n if (!(Number.isInteger(pointsPerEdge) && pointsPerEdge >= 1)) throw new MapError(\"atlas\", `The number of points ${pointsPerEdge} of an edge is not an integer of 1 or more`);\n return atlas.pages.map((page) => {\n const view = frameView(page.frame);\n const { widthMm: w, heightMm: h } = page.frame;\n const ring: [number, number][] = [];\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: (i / pointsPerEdge) * w, y: 0 })));\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: w, y: (i / pointsPerEdge) * h })));\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: w - (i / pointsPerEdge) * w, y: h })));\n for (let i = 0; i < pointsPerEdge; i += 1) ring.push(lonLat(view.fromPaper({ x: 0, y: h - (i / pointsPerEdge) * h })));\n // GeoJSON gives the outer ring of a polygon in the counterclockwise direction. The walk on the paper is clockwise, so it is reversed.\n ring.reverse();\n ring.push(ring[0]!);\n return { type: \"Feature\", geometry: { type: \"Polygon\", coordinates: [ring] }, properties: { id: page.id } };\n });\n}\n\n/**\n * This function gives the frame of an index map of an atlas. The frame shows all the pages of the grid in the space, at the largest scale.\n * Its center is the middle of the grid.\n *\n * @throws MapError - The code is `frame`.\n */\nexport function atlasIndexFrame(atlas: Atlas, widthMm: number, heightMm: number): Frame {\n const { plan } = atlas;\n checkFrame({ ...plan, widthMm, heightMm });\n const overlapMm = plan.overlapMm ?? ATLAS_OVERLAP_MM;\n const gridWidthMm = (atlas.columns - 1) * (plan.widthMm - overlapMm) + plan.widthMm;\n const gridHeightMm = (atlas.rows - 1) * (plan.heightMm - overlapMm) + plan.heightMm;\n const scale = plan.scale * Math.max(gridWidthMm / widthMm, gridHeightMm / heightMm);\n return { projection: plan.projection, center: plan.center, scale, widthMm, heightMm };\n}\n\n/** This function gives the GeoJSON position `[lon, lat]` of a point. */\nfunction lonLat(point: LatLon): [number, number] {\n return [point.lon, point.lat];\n}\n","/**\n * The filters of the layers. A filter is data, so a map document can be JSON.\n *\n * @packageDocumentation\n */\n\nimport type { Feature, Geometry } from \"@mark1russell7/geo\";\nimport { MapError } from \"./errors.ts\";\n\n/** A value that a filter compares with a property of a feature. */\nexport type FilterValue = string | number | boolean;\n\n/** The kind of a geometry: points, lines or areas. A collection of two kinds is `mixed`. */\nexport type GeometryKind = \"point\" | \"line\" | \"area\" | \"mixed\";\n\n/**\n * A filter of the features of a layer.\n *\n * - `{ all }` matches when each filter matches. `{ any }` matches when one filter matches. `{ not }` reverses a filter.\n * - `{ property, in }` matches a feature whose property is equal to one of the values.\n * - `{ property, exists }` matches a feature that has the property, or that does not have it.\n * - `{ geometry }` matches a feature whose geometry has the kind.\n */\nexport type Filter =\n | { readonly all: readonly Filter[] }\n | { readonly any: readonly Filter[] }\n | { readonly not: Filter }\n | { readonly property: string; readonly in: readonly FilterValue[] }\n | { readonly property: string; readonly exists: boolean }\n | { readonly geometry: GeometryKind };\n\n/** This function gives the kind of a geometry. */\nexport function geometryKind(geometry: Geometry): GeometryKind {\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\":\n return \"point\";\n case \"LineString\":\n case \"MultiLineString\":\n return \"line\";\n case \"Polygon\":\n case \"MultiPolygon\":\n return \"area\";\n case \"GeometryCollection\": {\n const kinds = new Set(geometry.geometries.map(geometryKind));\n return kinds.size === 1 ? ([...kinds][0] as GeometryKind) : \"mixed\";\n }\n }\n}\n\n/** This function tells if a feature matches a filter. A feature with no geometry matches no `{ geometry }` filter. */\nexport function matchesFilter(filter: Filter, feature: Feature): boolean {\n if (\"all\" in filter) return filter.all.every((item) => matchesFilter(item, feature));\n if (\"any\" in filter) return filter.any.some((item) => matchesFilter(item, feature));\n if (\"not\" in filter) return !matchesFilter(filter.not, feature);\n if (\"geometry\" in filter) return feature.geometry !== null && geometryKind(feature.geometry) === filter.geometry;\n const properties = feature.properties ?? {};\n const has = Object.hasOwn(properties, filter.property);\n if (\"exists\" in filter) return has === filter.exists;\n return has && filter.in.includes(properties[filter.property] as FilterValue);\n}\n\nconst KINDS: readonly string[] = [\"point\", \"line\", \"area\", \"mixed\"];\n\n/**\n * This function refuses a value that is not a `Filter`, for example a filter from JSON.\n *\n * @throws MapError - The code is `filter`.\n */\nexport function checkFilter(filter: unknown, path = \"filter\"): asserts filter is Filter {\n const fail = (reason: string): never => {\n throw new MapError(\"filter\", `${path}: ${reason}`);\n };\n if (typeof filter !== \"object\" || filter === null || Array.isArray(filter)) fail(\"a filter must be an object\");\n const value = filter as Record<string, unknown>;\n const keys = Object.keys(value).toSorted().join(\",\");\n if (keys === \"all\" || keys === \"any\") {\n const items = value[keys];\n if (!Array.isArray(items)) fail(`the member ${keys} must be an array`);\n (items as unknown[]).forEach((item, i) => checkFilter(item, `${path}.${keys}[${i}]`));\n } else if (keys === \"not\") {\n checkFilter(value[\"not\"], `${path}.not`);\n } else if (keys === \"geometry\") {\n if (!KINDS.includes(value[\"geometry\"] as string)) fail(`the geometry must be one of ${KINDS.join(\", \")}`);\n } else if (keys === \"in,property\" || keys === \"exists,property\") {\n if (typeof value[\"property\"] !== \"string\") fail(\"the property must be a string\");\n if (keys === \"exists,property\" && typeof value[\"exists\"] !== \"boolean\") fail(\"the member exists must be true or false\");\n if (keys === \"in,property\") {\n const items = value[\"in\"];\n if (!Array.isArray(items) || !items.every((item) => [\"string\", \"number\", \"boolean\"].includes(typeof item))) {\n fail(\"the member in must be an array of strings, numbers and booleans\");\n }\n }\n } else {\n fail(`the members ${keys === \"\" ? \"(none)\" : keys} are not a form of a filter`);\n }\n}\n","/**\n * The black and white styles of the layers: lines with dashes, areas with gray levels and hatches, and point symbols.\n * The print of a map has no color, so each style uses black, white and gray only.\n *\n * @packageDocumentation\n */\n\nimport { MapError } from \"./errors.ts\";\n\n/**\n * A line. The gray level goes from 0 (black) to 1 (white). The default is 0.\n */\nexport interface StrokeStyle {\n /** The width of the line in millimetres. */\n readonly widthMm: number;\n /** The gray level from 0 (black) to 1 (white). The default is 0. */\n readonly gray?: number;\n /** The lengths of the dashes and the gaps in millimetres. No value gives a solid line. */\n readonly dashMm?: readonly number[];\n}\n\n/** Parallel lines in an area. A cross hatch adds the same lines at right angles. */\nexport interface HatchStyle {\n /** The angle of the lines in degrees, clockwise from horizontal. */\n readonly angleDegrees: number;\n /** The distance between two lines in millimetres. It is more than the width of a line. */\n readonly spacingMm: number;\n /** The width of a line in millimetres. */\n readonly widthMm: number;\n /** The value `true` adds the lines at right angles. The default is `false`. */\n readonly cross?: boolean;\n}\n\n/** The fill of an area: a gray level, a hatch, or the two. The hatch is on top of the gray level. */\nexport interface FillStyle {\n /** The gray level from 0 (black) to 1 (white). No value gives no solid fill. */\n readonly gray?: number;\n /** The hatch. No value gives no hatch. */\n readonly hatch?: HatchStyle;\n}\n\n/** The symbols of the points. */\nexport type PointSymbol = \"circle\" | \"square\" | \"triangle\" | \"diamond\" | \"cross\";\n\n/** The symbol of each point. */\nexport interface PointStyle {\n /** The shape of the symbol. */\n readonly symbol: PointSymbol;\n /** The size of the symbol in millimetres. */\n readonly sizeMm: number;\n /** The value `false` gives a white symbol with a black outline. The default is `true`, a black symbol. */\n readonly filled?: boolean;\n}\n\n/** The style of a layer. The line is for the lines and the edges of the areas. The fill is for the areas, and the symbol is for the points. */\nexport interface Style {\n /** The line. */\n readonly stroke?: StrokeStyle;\n /** The fill of the areas. */\n readonly fill?: FillStyle;\n /** The symbol of the points. */\n readonly point?: PointStyle;\n}\n\nconst SYMBOLS: readonly string[] = [\"circle\", \"square\", \"triangle\", \"diamond\", \"cross\"];\n\nfunction positive(value: unknown, name: string, layer: string): void {\n if (!(typeof value === \"number\" && Number.isFinite(value) && value > 0)) {\n throw new MapError(\"style\", `The layer \"${layer}\": the ${name} ${String(value)} is not a finite number more than 0`);\n }\n}\n\nfunction grayLevel(value: unknown, layer: string): void {\n if (value === undefined) return;\n if (!(typeof value === \"number\" && value >= 0 && value <= 1)) {\n throw new MapError(\"style\", `The layer \"${layer}\": the gray level ${String(value)} is not from 0 to 1`);\n }\n}\n\n/**\n * This function refuses a style that draws nothing, and a size, a gray level, a dash or a symbol that is not correct.\n *\n * @throws MapError - The code is `style`.\n */\nexport function checkStyle(style: Style, layer: string): void {\n if (style.stroke === undefined && style.fill === undefined && style.point === undefined) {\n throw new MapError(\"style\", `The layer \"${layer}\": the style has no stroke, no fill and no point, so it draws nothing`);\n }\n if (style.stroke !== undefined) {\n positive(style.stroke.widthMm, \"width of the line\", layer);\n grayLevel(style.stroke.gray, layer);\n for (const dash of style.stroke.dashMm ?? []) positive(dash, \"length of a dash\", layer);\n }\n if (style.fill !== undefined) {\n grayLevel(style.fill.gray, layer);\n if (style.fill.gray === undefined && style.fill.hatch === undefined) {\n throw new MapError(\"style\", `The layer \"${layer}\": the fill has no gray level and no hatch`);\n }\n const hatch = style.fill.hatch;\n if (hatch !== undefined) {\n positive(hatch.widthMm, \"width of a hatch line\", layer);\n positive(hatch.spacingMm, \"spacing of the hatch\", layer);\n if (!Number.isFinite(hatch.angleDegrees)) throw new MapError(\"style\", `The layer \"${layer}\": the angle ${hatch.angleDegrees} is not finite`);\n if (hatch.spacingMm <= hatch.widthMm) throw new MapError(\"style\", `The layer \"${layer}\": the spacing of the hatch is not more than its width`);\n }\n }\n if (style.point !== undefined) {\n positive(style.point.sizeMm, \"size of the symbol\", layer);\n if (!SYMBOLS.includes(style.point.symbol)) throw new MapError(\"style\", `The layer \"${layer}\": the symbol \"${style.point.symbol}\" is not one of ${SYMBOLS.join(\", \")}`);\n }\n}\n\n/** This function gives a number for SVG, to 0.01 mm. */\nexport function mm(value: number): string {\n return rounded(value, 2);\n}\n\n/** This function gives the text of a value with `decimals` digits after the point, or fewer. It gives `0`, not `-0`. */\nexport function rounded(value: number, decimals: number): string {\n const factor = 10 ** decimals;\n return String(Math.round(value * factor) / factor + 0);\n}\n\n/** This function gives the color of a gray level, from `#000000` to `#ffffff`. */\nexport function grayColor(gray: number): string {\n const hex = Math.round(gray * 255)\n .toString(16)\n .padStart(2, \"0\");\n return `#${hex}${hex}${hex}`;\n}\n\n/** This function gives the SVG attributes of a line. */\nexport function strokeAttributes(stroke: StrokeStyle): string {\n const dash = stroke.dashMm === undefined || stroke.dashMm.length === 0 ? \"\" : ` stroke-dasharray=\"${stroke.dashMm.map(mm).join(\" \")}\"`;\n return `stroke=\"${grayColor(stroke.gray ?? 0)}\" stroke-width=\"${mm(stroke.widthMm)}\"${dash} stroke-linecap=\"round\" stroke-linejoin=\"round\"`;\n}\n\n/** This function gives the SVG pattern of a hatch, with an identifier. */\nexport function hatchPattern(id: string, hatch: HatchStyle): string {\n const s = mm(hatch.spacingMm);\n const half = mm(hatch.spacingMm / 2);\n const line = `stroke=\"#000000\" stroke-width=\"${mm(hatch.widthMm)}\"`;\n const across = hatch.cross === true ? `<line x1=\"${half}\" y1=\"0\" x2=\"${half}\" y2=\"${s}\" ${line}/>` : \"\";\n return (\n `<pattern id=\"${id}\" patternUnits=\"userSpaceOnUse\" width=\"${s}\" height=\"${s}\" patternTransform=\"rotate(${mm(hatch.angleDegrees)})\">` +\n `<line x1=\"0\" y1=\"${half}\" x2=\"${s}\" y2=\"${half}\" ${line}/>${across}</pattern>`\n );\n}\n\n/** This function gives the SVG of a point symbol at a point on the paper. */\nexport function pointSymbol(point: PointStyle, x: number, y: number): string {\n const r = point.sizeMm / 2;\n const filled = point.filled !== false;\n const paint = filled ? `fill=\"#000000\"` : `fill=\"#ffffff\" stroke=\"#000000\" stroke-width=\"${mm(point.sizeMm / 8)}\"`;\n switch (point.symbol) {\n case \"circle\":\n return `<circle cx=\"${mm(x)}\" cy=\"${mm(y)}\" r=\"${mm(r)}\" ${paint}/>`;\n case \"square\":\n return `<rect x=\"${mm(x - r)}\" y=\"${mm(y - r)}\" width=\"${mm(2 * r)}\" height=\"${mm(2 * r)}\" ${paint}/>`;\n case \"triangle\":\n return `<path d=\"M${mm(x)} ${mm(y - r)}L${mm(x + r)} ${mm(y + r)}L${mm(x - r)} ${mm(y + r)}Z\" ${paint}/>`;\n case \"diamond\":\n return `<path d=\"M${mm(x)} ${mm(y - r)}L${mm(x + r)} ${mm(y)}L${mm(x)} ${mm(y + r)}L${mm(x - r)} ${mm(y)}Z\" ${paint}/>`;\n case \"cross\":\n return `<path d=\"M${mm(x - r)} ${mm(y)}L${mm(x + r)} ${mm(y)}M${mm(x)} ${mm(y - r)}L${mm(x)} ${mm(y + r)}\" stroke=\"#000000\" stroke-width=\"${mm(point.sizeMm / 5)}\" fill=\"none\"/>`;\n }\n}\n","/**\n * The labels of a map: the names of points, lines and areas, with no overlap.\n *\n * @packageDocumentation\n */\n\nimport { locatePoint, type Feature, type Geometry, type Polygon, type Position } from \"@mark1russell7/geo\";\nimport { escapeAttribute, escapeHtml } from \"@mark1russell7/text\";\nimport { MapError } from \"./errors.ts\";\nimport type { FrameView, PaperPoint } from \"./frame.ts\";\nimport { mm } from \"./style.ts\";\n\n/** The rule of the labels of a layer. */\nexport interface LabelRule {\n /** The properties of a feature, in sequence. The first property with a text that is not empty gives the label. */\n readonly properties: readonly string[];\n /** The size of the font in millimetres on the paper. */\n readonly sizeMm: number;\n /** The rank of the labels of the layer. A lower rank gets its places first. The default is 0. */\n readonly priority?: number;\n /** For a line: the distance in millimetres between two labels of the same text. No value gives one label for each text. */\n readonly repeatMm?: number;\n}\n\n/** The font of the labels. The width of a label comes from `measure`, so the font of the print must be the same font. */\nexport interface LabelFont {\n /** The CSS font family of the labels, for example `\"Liberation Sans\", Arial, sans-serif`. */\n readonly family: string;\n /** This function gives the width in millimetres of a text at a size of the font in millimetres. */\n readonly measure: (text: string, sizeMm: number) => number;\n}\n\n/** A label with its place: the middle of its box on the paper, and its angle. */\nexport interface PlacedLabel {\n /** The identifier of the layer of the label. */\n readonly layer: string;\n readonly text: string;\n /** The middle of the label on the paper, in millimetres from the top left corner of the frame. */\n readonly x: number;\n readonly y: number;\n /** The angle of the text in degrees, clockwise, more than -90 and not more than 90. So each label reads from the left. */\n readonly angle: number;\n readonly sizeMm: number;\n readonly widthMm: number;\n}\n\n/** The labels of a map: the labels with a place, and the texts with no place. */\nexport interface LabelPlacement {\n readonly placed: readonly PlacedLabel[];\n /** Each text that has no place with no overlap, inside the frame. */\n readonly skipped: readonly { readonly layer: string; readonly text: string }[];\n}\n\n/** A layer as the labels see it: its identifier, its features after its filter, its rule and the size of its points. */\nexport interface LabelLayer {\n readonly id: string;\n readonly features: readonly Feature[];\n readonly label?: LabelRule | undefined;\n /** The size in millimetres of the point symbol of the layer, when its style has points. */\n readonly pointSizeMm?: number | undefined;\n}\n\n/** The gap in millimetres between a point symbol and its label. */\nconst POINT_GAP_MM = 0.6;\n/** The margin in millimetres between a label and the edge of the frame. */\nconst FRAME_MARGIN_MM = 0.5;\n/** The height of the box of a label, as a part of the size of the font. */\nconst BOX_HEIGHT = 1.2;\n/** The room in millimetres at each end of a label along a line. */\nconst LINE_PAD_MM = 1;\n/** The largest distance from a line to the chord of a label, as a part of the size of the font. */\nconst LINE_BEND = 0.25;\n\n/**\n * This function examines the label rule of a layer.\n *\n * @throws MapError - The code is `label`.\n */\nexport function checkLabelRule(rule: LabelRule, layer: string): void {\n const fail = (reason: string): never => {\n throw new MapError(\"label\", `The labels of the layer \"${layer}\": ${reason}`);\n };\n if (!Array.isArray(rule.properties) || rule.properties.length === 0) fail(\"give at least one property\");\n for (const property of rule.properties) if (typeof property !== \"string\" || property === \"\") fail(\"each property is a text that is not empty\");\n if (!(Number.isFinite(rule.sizeMm) && rule.sizeMm > 0)) fail(`the size ${rule.sizeMm} is not a finite number more than 0`);\n if (rule.priority !== undefined && !Number.isFinite(rule.priority)) fail(`the priority ${rule.priority} is not a finite number`);\n if (rule.repeatMm !== undefined && !(Number.isFinite(rule.repeatMm) && rule.repeatMm > 0)) fail(`the distance ${rule.repeatMm} is not a finite number more than 0`);\n}\n\n/** This function gives the text of the label of a feature: the first property of the rule with a text. */\nexport function labelText(rule: LabelRule, feature: Feature): string | undefined {\n for (const property of rule.properties) {\n const value = feature.properties?.[property];\n if ((typeof value === \"string\" || typeof value === \"number\") && String(value).trim() !== \"\") return String(value).trim();\n }\n return undefined;\n}\n\n/** A box on the paper with an angle: its middle, its half width, its half height and its angle in radians. */\ninterface Box {\n readonly x: number;\n readonly y: number;\n readonly hw: number;\n readonly hh: number;\n readonly angle: number;\n}\n\nfunction corners(box: Box): PaperPoint[] {\n const c = Math.cos(box.angle);\n const s = Math.sin(box.angle);\n return [\n [-box.hw, -box.hh],\n [box.hw, -box.hh],\n [box.hw, box.hh],\n [-box.hw, box.hh],\n ].map(([u, v]) => ({ x: box.x + u! * c - v! * s, y: box.y + u! * s + v! * c }));\n}\n\n/** This function tells if two boxes overlap: the test of the separating axis for two rectangles. */\nfunction overlaps(a: Box, b: Box): boolean {\n const ca = corners(a);\n const cb = corners(b);\n for (const angle of [a.angle, a.angle + Math.PI / 2, b.angle, b.angle + Math.PI / 2]) {\n const ax = Math.cos(angle);\n const ay = Math.sin(angle);\n const pa = ca.map((p) => p.x * ax + p.y * ay);\n const pb = cb.map((p) => p.x * ax + p.y * ay);\n if (Math.max(...pa) <= Math.min(...pb) || Math.max(...pb) <= Math.min(...pa)) return false;\n }\n return true;\n}\n\n/** The boxes that a label must not overlap, and the frame. */\nclass Room {\n readonly boxes: Box[] = [];\n readonly widthMm: number;\n readonly heightMm: number;\n\n constructor(widthMm: number, heightMm: number) {\n this.widthMm = widthMm;\n this.heightMm = heightMm;\n }\n\n fits(box: Box): boolean {\n for (const p of corners(box)) {\n if (p.x < FRAME_MARGIN_MM || p.y < FRAME_MARGIN_MM || p.x > this.widthMm - FRAME_MARGIN_MM || p.y > this.heightMm - FRAME_MARGIN_MM) return false;\n }\n return !this.boxes.some((other) => overlaps(box, other));\n }\n}\n\nfunction paperOf(position: Position, view: FrameView): PaperPoint {\n return view.toPaper({ lat: position[1] as number, lon: position[0] as number });\n}\n\n/** This function gives the points, the lines and the areas of a geometry. */\nfunction parts(geometry: Geometry, out: { points: Position[]; lines: (readonly Position[])[]; areas: Polygon[] }): void {\n switch (geometry.type) {\n case \"Point\":\n out.points.push(geometry.coordinates);\n break;\n case \"MultiPoint\":\n out.points.push(...geometry.coordinates);\n break;\n case \"LineString\":\n out.lines.push(geometry.coordinates);\n break;\n case \"MultiLineString\":\n out.lines.push(...geometry.coordinates);\n break;\n case \"Polygon\":\n out.areas.push(geometry);\n break;\n case \"MultiPolygon\":\n for (const coordinates of geometry.coordinates) out.areas.push({ type: \"Polygon\", coordinates });\n break;\n case \"GeometryCollection\":\n for (const item of geometry.geometries) parts(item, out);\n break;\n }\n}\n\n/** This function gives the angle of a direction in radians, more than -pi/2 and not more than pi/2, so the text reads from the left. */\nfunction readable(dx: number, dy: number): number {\n let angle = Math.atan2(dy, dx);\n if (angle > Math.PI / 2) angle -= Math.PI;\n if (angle <= -Math.PI / 2) angle += Math.PI;\n return angle;\n}\n\n/**\n * This function gives the runs of a line on the paper: the parts with each segment in a box that touches the frame. So\n * a segment that crosses the frame stays in its run. A run can go past the frame, but a label box outside the frame\n * does not fit.\n */\nfunction runs(line: readonly Position[], view: FrameView): PaperPoint[][] {\n const { widthMm: w, heightMm: h } = view.frame;\n const points = line.map((position) => paperOf(position, view));\n const out: PaperPoint[][] = [];\n let run: PaperPoint[] = [];\n for (let i = 1; i < points.length; i += 1) {\n const a = points[i - 1]!;\n const b = points[i]!;\n if (Math.max(a.x, b.x) >= 0 && Math.min(a.x, b.x) <= w && Math.max(a.y, b.y) >= 0 && Math.min(a.y, b.y) <= h) {\n if (run.length === 0) run.push(a);\n run.push(b);\n } else {\n if (run.length > 1) out.push(run);\n run = [];\n }\n }\n if (run.length > 1) out.push(run);\n return out;\n}\n\n/** This function gives the length of a run on the paper. */\nfunction runLength(run: readonly PaperPoint[]): number {\n let total = 0;\n for (let i = 1; i < run.length; i += 1) total += Math.hypot(run[i]!.x - run[i - 1]!.x, run[i]!.y - run[i - 1]!.y);\n return total;\n}\n\n/** This function gives the point at a distance along a run, with the cumulative lengths of the run. */\nfunction along(run: readonly PaperPoint[], lengths: readonly number[], s: number): PaperPoint {\n let i = 1;\n while (i < run.length - 1 && lengths[i]! < s) i += 1;\n const a = run[i - 1]!;\n const b = run[i]!;\n const span = lengths[i]! - lengths[i - 1]!;\n const t = span === 0 ? 0 : (s - lengths[i - 1]!) / span;\n return { x: a.x + t * (b.x - a.x), y: a.y + t * (b.y - a.y) };\n}\n\n/**\n * This function gives the boxes of a label along a run, from the middle of the run to its ends. A box is on an almost\n * straight part of the run. No point of that part is farther from the chord than `LINE_BEND` of the size.\n */\nfunction lineCandidates(run: readonly PaperPoint[], width: number, size: number): Box[] {\n const lengths = [0];\n for (let i = 1; i < run.length; i += 1) lengths.push(lengths[i - 1]! + Math.hypot(run[i]!.x - run[i - 1]!.x, run[i]!.y - run[i - 1]!.y));\n const total = lengths.at(-1)!;\n const span = width + 2 * LINE_PAD_MM;\n if (total < span) return [];\n const step = Math.max(span / 4, 2);\n // The middles go from the middle of the run to its ends, one step at a time, first toward the start.\n const middles = [total / 2];\n for (let k = 1; k * step <= total / 2 - span / 2; k += 1) middles.push(total / 2 - k * step, total / 2 + k * step);\n const boxes: Box[] = [];\n for (const middle of middles) {\n const start = along(run, lengths, middle - span / 2);\n const end = along(run, lengths, middle + span / 2);\n const chord = Math.hypot(end.x - start.x, end.y - start.y);\n if (chord < 0.9 * span) continue;\n const inside = run.filter((_, i) => lengths[i]! > middle - span / 2 && lengths[i]! < middle + span / 2);\n const bend = Math.max(0, ...inside.map((p) => Math.abs((end.x - start.x) * (start.y - p.y) - (start.x - p.x) * (end.y - start.y)) / chord));\n if (bend > LINE_BEND * size) continue;\n boxes.push({ x: (start.x + end.x) / 2, y: (start.y + end.y) / 2, hw: width / 2, hh: (BOX_HEIGHT * size) / 2, angle: readable(end.x - start.x, end.y - start.y) });\n }\n return boxes;\n}\n\n/** This function gives the boxes of a label around a point, in the sequence of the preferred places. */\nfunction pointCandidates(p: PaperPoint, width: number, size: number, symbolMm: number): Box[] {\n const hw = width / 2;\n const hh = (BOX_HEIGHT * size) / 2;\n const d = symbolMm / 2 + POINT_GAP_MM;\n const k = d * Math.SQRT1_2;\n return [\n [d + hw, 0],\n [-d - hw, 0],\n [0, -d - hh],\n [0, d + hh],\n [k + hw, -k - hh],\n [k + hw, k + hh],\n [-k - hw, -k - hh],\n [-k - hw, k + hh],\n ].map(([dx, dy]) => ({ x: p.x + dx!, y: p.y + dy!, hw, hh, angle: 0 }));\n}\n\n/** This function gives the box of a label in the middle of an area, when the area has each corner of the box. */\nfunction areaCandidates(area: Polygon, view: FrameView, width: number, size: number): Box[] {\n const ring = area.coordinates[0] ?? [];\n if (ring.length < 4) return [];\n const points = ring.map((position) => paperOf(position, view));\n let doubled = 0;\n let cx = 0;\n let cy = 0;\n for (let i = 0; i + 1 < points.length; i += 1) {\n const a = points[i]!;\n const b = points[i + 1]!;\n const cross = a.x * b.y - b.x * a.y;\n doubled += cross;\n cx += (a.x + b.x) * cross;\n cy += (a.y + b.y) * cross;\n }\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n const middle = { x: (Math.min(...xs) + Math.max(...xs)) / 2, y: (Math.min(...ys) + Math.max(...ys)) / 2 };\n const centers = doubled === 0 ? [middle] : [{ x: cx / (3 * doubled), y: cy / (3 * doubled) }, middle];\n const hw = width / 2;\n const hh = (BOX_HEIGHT * size) / 2;\n return centers\n .map((c) => ({ x: c.x, y: c.y, hw, hh, angle: 0 }))\n .filter((box) => [...corners(box), { x: box.x, y: box.y }].every((p) => locatePoint(view.fromPaper(p), area) === \"inside\"));\n}\n\n/** This function tells if the box of the outer ring of an area on the paper touches the frame. */\nfunction areaOnFrame(area: Polygon, view: FrameView): boolean {\n const points = (area.coordinates[0] ?? []).map((position) => paperOf(position, view));\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n return points.length > 0 && Math.max(...xs) >= 0 && Math.min(...xs) <= view.frame.widthMm && Math.max(...ys) >= 0 && Math.min(...ys) <= view.frame.heightMm;\n}\n\n/** One text of a layer, and the parts of the features with that text. */\ninterface Job {\n readonly layer: LabelLayer;\n readonly rule: LabelRule;\n readonly text: string;\n readonly width: number;\n readonly points: Position[];\n readonly lines: (readonly Position[])[];\n readonly areas: Polygon[];\n}\n\n/**\n * This function gives the places of the labels of the layers. The labels do not overlap, and each label is inside the\n * frame.\n *\n * - The layers with a lower `priority` get their places first. With the same priority, a higher layer is first.\n * - In a layer, the features with the same text are one job. A longer line is first, then the sequence of the features.\n * - A point gets the first free place of 8 places around its symbol: right, left, above, below, then the corners.\n * - A line gets its text along an almost straight part. The longest run is first, and the middle of a run is first.\n * - With `repeatMm`, a line gets more labels of its text, at that distance or more from each other.\n * - An area gets its text at its centroid or at the middle of its box, when the area has the box of the text.\n * - Each point symbol of the layers and the north arrow are obstacles too.\n * - A text with a part on the frame and no free place is in `skipped`. A text with no part on the frame is in neither list.\n *\n * @param obstacles - The boxes on the paper that no label covers, as the middle and the half size in millimetres. A box with `halfHeight` has the half width `half`.\n * @throws MapError - The code is `label`: the width of a text from `measure` is not a finite number of 0 or more.\n */\nexport function placeLabels(layers: readonly LabelLayer[], view: FrameView, font: LabelFont, obstacles: readonly { x: number; y: number; half: number; halfHeight?: number }[] = []): LabelPlacement {\n const room = new Room(view.frame.widthMm, view.frame.heightMm);\n for (const o of obstacles) room.boxes.push({ x: o.x, y: o.y, hw: o.half, hh: o.halfHeight ?? o.half, angle: 0 });\n for (const layer of layers) {\n if (layer.pointSizeMm === undefined) continue;\n const out: { points: Position[]; lines: (readonly Position[])[]; areas: Polygon[] } = { points: [], lines: [], areas: [] };\n for (const feature of layer.features) if (feature.geometry !== null) parts(feature.geometry, out);\n for (const position of out.points) {\n const p = paperOf(position, view);\n room.boxes.push({ x: p.x, y: p.y, hw: layer.pointSizeMm / 2, hh: layer.pointSizeMm / 2, angle: 0 });\n }\n }\n\n const order = layers\n .map((layer, index) => ({ layer, index }))\n .filter((entry): entry is { layer: LabelLayer & { label: LabelRule }; index: number } => entry.layer.label !== undefined)\n .sort((a, b) => (a.layer.label.priority ?? 0) - (b.layer.label.priority ?? 0) || b.index - a.index);\n\n const placed: PlacedLabel[] = [];\n const skipped: { layer: string; text: string }[] = [];\n for (const { layer } of order) {\n const rule = layer.label;\n const jobs = new Map<string, Job>();\n for (const feature of layer.features) {\n if (feature.geometry === null) continue;\n const text = labelText(rule, feature);\n if (text === undefined) continue;\n let job = jobs.get(text);\n if (job === undefined) {\n const width = font.measure(text, rule.sizeMm);\n if (!(Number.isFinite(width) && width >= 0)) throw new MapError(\"label\", `The width ${width} of the label \"${text}\" is not a finite number of 0 or more`);\n job = { layer, rule, text, width, points: [], lines: [], areas: [] };\n jobs.set(text, job);\n }\n parts(feature.geometry, job);\n }\n // The runs of each job, the longest first. The jobs with the most length of line are first.\n const sorted = [...jobs.values()]\n .map((job) => {\n const lineRuns = job.lines\n .flatMap((line) => runs(line, view))\n .map((run) => ({ run, length: runLength(run) }))\n .sort((a, b) => b.length - a.length);\n return { job, lineRuns, length: lineRuns.reduce((t, entry) => t + entry.length, 0) };\n })\n .sort((a, b) => b.length - a.length);\n for (const { job, lineRuns } of sorted) {\n const mine: PlacedLabel[] = [];\n // A text is in `skipped` only when a part of its features is on the frame.\n let onFrame = false;\n const take = (box: Box): boolean => {\n if (!room.fits(box)) return false;\n if (job.rule.repeatMm !== undefined && mine.some((other) => Math.hypot(other.x - box.x, other.y - box.y) < job.rule.repeatMm!)) return false;\n room.boxes.push(box);\n mine.push({ layer: layer.id, text: job.text, x: box.x, y: box.y, angle: (box.angle * 180) / Math.PI + 0, sizeMm: job.rule.sizeMm, widthMm: job.width });\n return true;\n };\n for (const position of job.points) {\n const p = paperOf(position, view);\n if (p.x < 0 || p.y < 0 || p.x > view.frame.widthMm || p.y > view.frame.heightMm) continue;\n onFrame = true;\n pointCandidates(p, job.width, job.rule.sizeMm, layer.pointSizeMm ?? 0).some(take);\n }\n if (lineRuns.length > 0) onFrame = true;\n lines: for (const { run } of lineRuns) {\n for (const box of lineCandidates(run, job.width, job.rule.sizeMm)) {\n if (take(box) && job.rule.repeatMm === undefined) break lines;\n }\n }\n for (const area of job.areas) {\n if (!areaOnFrame(area, view)) continue;\n onFrame = true;\n areaCandidates(area, view, job.width, job.rule.sizeMm).some(take);\n }\n if (mine.length === 0 && onFrame) skipped.push({ layer: layer.id, text: job.text });\n placed.push(...mine);\n }\n }\n return { placed, skipped };\n}\n\n/** This function gives the SVG of the labels: black text with a white halo, so a label reads over the lines of the map. */\nexport function labelsSvg(placement: LabelPlacement, font: LabelFont): string {\n const texts = placement.placed.map((label) => {\n const rotate = label.angle === 0 ? \"\" : ` transform=\"rotate(${mm(label.angle)} ${mm(label.x)} ${mm(label.y)})\"`;\n return (\n `<text x=\"${mm(label.x)}\" y=\"${mm(label.y)}\" font-size=\"${mm(label.sizeMm)}\"${rotate} text-anchor=\"middle\" dominant-baseline=\"central\" ` +\n `fill=\"#000000\" stroke=\"#ffffff\" stroke-width=\"${mm(label.sizeMm * 0.25)}\" stroke-linejoin=\"round\" paint-order=\"stroke\">${escapeHtml(label.text)}</text>`\n );\n });\n return `<g class=\"labels\" font-family=\"${escapeAttribute(font.family)}\" data-skipped=\"${placement.skipped.length}\">${texts.join(\"\")}</g>`;\n}\n","/**\n * The marks of a map: the scale bar, the north arrow and the texts at the edges of the frame.\n *\n * @packageDocumentation\n */\n\nimport { escapeHtml } from \"@mark1russell7/text\";\nimport { mm } from \"./style.ts\";\n\n/** The units of the scale bars of a map. `both` gives a metric bar and an imperial bar. */\nexport type ScaleBarUnits = \"metric\" | \"imperial\" | \"both\" | \"none\";\n\n/** The length of a scale bar on the ground and its label. */\nexport interface ScaleBarLength {\n /** The length on the ground in metres. */\n readonly meters: number;\n /** The label, for example `500 m`, `2 km`, `0.5 mi` or `200 ft`. */\n readonly label: string;\n}\n\nconst METERS_PER_MILE = 1609.344;\nconst METERS_PER_FOOT = 0.3048;\n\n/** This function gives the largest number 1, 2 or 5 times a power of 10 that is not more than a number more than 0. */\nexport function niceNumber(max: number): number {\n const power = 10 ** Math.floor(Math.log10(max));\n for (const step of [5, 2, 1]) {\n const value = Number((step * power).toPrecision(1));\n if (value <= max) return value;\n }\n return Number((power / 2).toPrecision(1));\n}\n\n/**\n * This function gives the length of a scale bar that is not longer than a length on the ground.\n *\n * - The metric bar is in metres below 1 km, and in kilometres from 1 km.\n * - The imperial bar is in miles from a quarter of a mile, and in feet below that.\n */\nexport function scaleBarLength(maxMeters: number, units: \"metric\" | \"imperial\"): ScaleBarLength {\n if (units === \"metric\") {\n const meters = niceNumber(maxMeters);\n return { meters, label: meters >= 1000 ? `${meters / 1000} km` : `${meters} m` };\n }\n const miles = maxMeters / METERS_PER_MILE;\n if (miles >= 0.25) {\n const value = niceNumber(miles);\n return { meters: value * METERS_PER_MILE, label: `${value} mi` };\n }\n const feet = niceNumber(maxMeters / METERS_PER_FOOT);\n return { meters: feet * METERS_PER_FOOT, label: `${feet} ft` };\n}\n\n/** The height of one scale bar with its label, in millimetres. */\nexport const SCALE_BAR_ROW_MM = 4.5;\n\n/** This function gives the SVG of a scale bar of four parts, with its top left corner at a point on the paper. */\nexport function scaleBarSvg(x: number, y: number, length: ScaleBarLength, mmPerMeter: number): string {\n const total = length.meters * mmPerMeter;\n const part = total / 4;\n let parts = \"\";\n for (let i = 0; i < 4; i += 1) {\n parts += `<rect x=\"${mm(x + i * part)}\" y=\"${mm(y)}\" width=\"${mm(part)}\" height=\"1.5\" fill=\"${i % 2 === 0 ? \"#000000\" : \"#ffffff\"}\" stroke=\"#000000\" stroke-width=\"0.15\"/>`;\n }\n return `<g class=\"scale-bar\">${parts}<text x=\"${mm(x + total + 1.5)}\" y=\"${mm(y + 1.5)}\" font-size=\"2.4\">${escapeHtml(length.label)}</text></g>`;\n}\n\n/** This function gives the SVG of a north arrow at a point on the paper, with the direction of north in degrees. */\nexport function northArrowSvg(x: number, y: number, northDegrees: number): string {\n return (\n `<g class=\"north-arrow\" transform=\"translate(${mm(x)} ${mm(y)}) rotate(${mm(northDegrees)})\">` +\n `<circle r=\"4.5\" fill=\"#ffffff\" stroke=\"#000000\" stroke-width=\"0.2\"/>` +\n `<path d=\"M0 -3.6L1.6 1.2L0 0.4L-1.6 1.2Z\" fill=\"#000000\"/>` +\n `<text y=\"3.9\" font-size=\"2.2\" text-anchor=\"middle\">N</text></g>`\n );\n}\n\n/** The four edges of a frame. When north is up, the top edge is at the north. */\nexport type FrameEdge = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The four edges of a frame, in the sequence of the marks. */\nexport const FRAME_EDGES: readonly FrameEdge[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\n/** The size of the font of a text at an edge of the frame, in millimetres. */\nexport const EDGE_TEXT_MM = 2.6;\n\n/** The space in the box of an edge text around the arrow and the text, and the size of the arrow, in millimetres. */\nconst EDGE = { pad: 0.8, arrow: 1.8, gap: 0.7 } as const;\n\n/** The angle of the arrow of each edge. The arrow points out of the frame. */\nconst EDGE_TURN: Readonly<Record<FrameEdge, number>> = { top: 0, right: 90, bottom: 180, left: 270 };\n\n/** The mark of a text at an edge of the frame: its box on the paper and its SVG. */\nexport interface EdgeMark {\n /** The edge of the mark. */\n readonly edge: FrameEdge;\n /** The middle of the box on the paper, in millimetres from the top left corner of the frame. */\n readonly x: number;\n /** The middle of the box on the paper, in millimetres from the top left corner of the frame. */\n readonly y: number;\n /** The half width of the box, in millimetres. */\n readonly halfWidth: number;\n /** The half height of the box, in millimetres. */\n readonly halfHeight: number;\n /** The SVG of the mark: a white box at the middle of the edge, an arrow that points out of the frame, and the text. */\n readonly svg: string;\n}\n\n/**\n * This function gives the marks of the texts at the middle of the edges of a frame, in the sequence top, right, bottom and left.\n * An edge with no text has no mark.\n *\n * @param measure - This function gives the width of a text in millimetres at the size `EDGE_TEXT_MM`.\n */\nexport function edgeMarks(widthMm: number, heightMm: number, texts: Readonly<Partial<Record<FrameEdge, string>>>, measure: (text: string) => number): EdgeMark[] {\n return FRAME_EDGES.flatMap((edge) => {\n const text = texts[edge];\n if (text === undefined) return [];\n const boxWidth = 2 * EDGE.pad + EDGE.arrow + EDGE.gap + measure(text);\n const boxHeight = 2 * EDGE.pad + EDGE_TEXT_MM;\n const x = edge === \"left\" ? boxWidth / 2 : edge === \"right\" ? widthMm - boxWidth / 2 : widthMm / 2;\n const y = edge === \"top\" ? boxHeight / 2 : edge === \"bottom\" ? heightMm - boxHeight / 2 : heightMm / 2;\n const left = x - boxWidth / 2;\n const top = y - boxHeight / 2;\n const arrowX = left + EDGE.pad + EDGE.arrow / 2;\n const half = EDGE.arrow / 2;\n const svg =\n `<g class=\"edge-${edge}\"><rect x=\"${mm(left)}\" y=\"${mm(top)}\" width=\"${mm(boxWidth)}\" height=\"${mm(boxHeight)}\" fill=\"#ffffff\" stroke=\"#000000\" stroke-width=\"0.2\"/>` +\n `<path transform=\"translate(${mm(arrowX)} ${mm(y)}) rotate(${EDGE_TURN[edge]})\" d=\"M0 ${mm(-half)}L${mm(half)} ${mm(half)}L${mm(-half)} ${mm(half)}Z\" fill=\"#000000\"/>` +\n `<text x=\"${mm(arrowX + half + EDGE.gap)}\" y=\"${mm(y + EDGE_TEXT_MM * 0.35)}\" font-size=\"${EDGE_TEXT_MM}\" font-weight=\"bold\">${escapeHtml(text)}</text></g>`;\n return [{ edge, x, y, halfWidth: boxWidth / 2, halfHeight: boxHeight / 2, svg }];\n });\n}\n","/**\n * A map as data, and its render to SVG.\n *\n * @packageDocumentation\n */\n\nimport { simplifyRegions, type Feature, type Geometry, type Position, type Region } from \"@mark1russell7/geo\";\nimport { escapeAttribute, escapeHtml } from \"@mark1russell7/text\";\nimport { MapError } from \"./errors.ts\";\nimport { checkFilter, matchesFilter, type Filter } from \"./filter.ts\";\nimport { frameView, type Frame, type FrameView, type PaperPoint } from \"./frame.ts\";\nimport { checkLabelRule, labelsSvg, placeLabels, type LabelFont, type LabelPlacement, type LabelRule } from \"./labels.ts\";\nimport { EDGE_TEXT_MM, edgeMarks, FRAME_EDGES, northArrowSvg, SCALE_BAR_ROW_MM, scaleBarLength, scaleBarSvg, type EdgeMark, type FrameEdge, type ScaleBarUnits } from \"./marks.ts\";\nimport { checkStyle, grayColor, hatchPattern, mm, pointSymbol, rounded, strokeAttributes, type Style } from \"./style.ts\";\n\n/** The source of the data of a layer. The map prints each source in its attribution block. */\nexport interface Source {\n /** The name of the source, for example `© OpenStreetMap contributors`. */\n readonly title: string;\n /** The license of the data, for example `ODbL 1.0`. */\n readonly license: string;\n /** The web address of the source or of its license. */\n readonly url?: string;\n /** The date of the data, for example `2026-11-21`. */\n readonly date?: string;\n}\n\n/** A layer of a map: features, a filter, a style and the source of the features. */\nexport interface Layer {\n /** The identifier of the layer: lower case letters, digits and hyphens. It starts with a letter. */\n readonly id: string;\n /** The features. Their positions are `[lon, lat]` on WGS84. */\n readonly features: readonly Feature[];\n /** The style of the features. */\n readonly style: Style;\n /** The source of the features. */\n readonly source: Source;\n /** The filter of the features. No filter keeps each feature. */\n readonly filter?: Filter;\n /** The text of the layer in the legend. No text gives no entry in the legend. */\n readonly legend?: string;\n /** The tolerance in millimetres on the paper for the simplification of the areas. No value keeps each position. */\n readonly simplifyMm?: number;\n /** The rule of the labels of the features. No rule gives no labels. */\n readonly label?: LabelRule;\n}\n\n/** A map: a frame, layers from the bottom to the top, and its marks. */\nexport interface MapDocument {\n /** The identifier of the map: lower case letters, digits and hyphens. It starts each identifier in the SVG. */\n readonly id: string;\n /** The title of the map, for a reader of the screen. */\n readonly title: string;\n /** The frame. */\n readonly frame: Frame;\n /** The layers, from the bottom to the top. */\n readonly layers: readonly Layer[];\n /** The units of the scale bars. The default is `both`. */\n readonly scaleBar?: ScaleBarUnits;\n /** The value `false` gives no north arrow. The default is `true`. */\n readonly northArrow?: boolean;\n /** The place of the scale bars and the legend. The default is `below`. `fitFrame` finds the place with the largest frame. */\n readonly legendPlace?: LegendPlace;\n /**\n * The texts at the middle of the edges of the frame, for example the names of the neighbor pages of an atlas.\n * Each text is in a white box with an arrow that points out of the frame. No labels cover the boxes.\n */\n readonly edges?: Readonly<Partial<Record<FrameEdge, string>>>;\n}\n\n/** The place of the scale bars and the legend: below the frame, or in a column at the right side of the frame. */\nexport type LegendPlace = \"below\" | \"side\";\n\nconst LEGEND_PLACES: readonly LegendPlace[] = [\"below\", \"side\"];\n\nconst ID = /^[a-z][a-z0-9-]*$/;\n\nfunction checkId(id: string, what: string): void {\n if (!ID.test(id)) throw new MapError(\"id\", `The identifier \"${id}\" of the ${what} is not lower case letters, digits and hyphens that start with a letter`);\n}\n\nfunction checkSource(source: Source | undefined, layer: string): void {\n if (source === undefined || typeof source !== \"object\") throw new MapError(\"source\", `The layer \"${layer}\" has no source`);\n if (typeof source.title !== \"string\" || source.title.trim() === \"\") throw new MapError(\"source\", `The source of the layer \"${layer}\" has no title`);\n if (typeof source.license !== \"string\" || source.license.trim() === \"\") throw new MapError(\"source\", `The source of the layer \"${layer}\" has no license`);\n}\n\n/**\n * This function examines a map. It refuses a frame, an identifier, a style, a filter or a source that is not correct.\n * Each layer must have a source with a title and a license, so the attribution block names each source of the map.\n *\n * @throws MapError - The code tells the reason.\n */\nexport function checkMap(map: MapDocument): void {\n checkId(map.id, \"map\");\n frameView(map.frame);\n if (map.legendPlace !== undefined && !LEGEND_PLACES.includes(map.legendPlace)) {\n throw new MapError(\"style\", `The place of the legend \"${String(map.legendPlace)}\" is not \"below\" or \"side\"`);\n }\n const ids = new Set<string>();\n for (const layer of map.layers) {\n checkId(layer.id, \"layer\");\n if (ids.has(layer.id)) throw new MapError(\"id\", `Two layers have the identifier \"${layer.id}\"`);\n ids.add(layer.id);\n checkSource(layer.source, layer.id);\n checkStyle(layer.style, layer.id);\n if (layer.filter !== undefined) checkFilter(layer.filter, `layer \"${layer.id}\" filter`);\n if (layer.label !== undefined) checkLabelRule(layer.label, layer.id);\n if (layer.simplifyMm !== undefined && !(Number.isFinite(layer.simplifyMm) && layer.simplifyMm > 0)) {\n throw new MapError(\"style\", `The layer \"${layer.id}\": the tolerance ${layer.simplifyMm} is not a finite number more than 0`);\n }\n }\n if (map.edges !== undefined) {\n if (typeof map.edges !== \"object\" || map.edges === null) throw new MapError(\"label\", \"The edge texts of the map are not an object\");\n for (const [edge, text] of Object.entries(map.edges)) {\n if (!(FRAME_EDGES as readonly string[]).includes(edge)) throw new MapError(\"label\", `The edge \"${edge}\" is not top, right, bottom or left`);\n if (text !== undefined && (typeof text !== \"string\" || text.trim() === \"\")) throw new MapError(\"label\", `The text of the edge \"${edge}\" is not a text that is not empty`);\n }\n }\n}\n\n/** The box of the points on the paper that a feature uses. */\nclass PaperBox {\n minX = Number.POSITIVE_INFINITY;\n minY = Number.POSITIVE_INFINITY;\n maxX = Number.NEGATIVE_INFINITY;\n maxY = Number.NEGATIVE_INFINITY;\n\n add(point: PaperPoint): void {\n this.minX = Math.min(this.minX, point.x);\n this.minY = Math.min(this.minY, point.y);\n this.maxX = Math.max(this.maxX, point.x);\n this.maxY = Math.max(this.maxY, point.y);\n }\n\n /** It tells if the box touches the frame, with a margin in millimetres. */\n touches(frame: Frame, margin: number): boolean {\n return this.maxX >= -margin && this.minX <= frame.widthMm + margin && this.maxY >= -margin && this.minY <= frame.heightMm + margin;\n }\n}\n\nfunction paperOf(position: Position, view: FrameView): PaperPoint {\n return view.toPaper({ lat: position[1] as number, lon: position[0] as number });\n}\n\nfunction linePath(positions: readonly Position[], view: FrameView, box: PaperBox, close: boolean, decimals: number): string {\n let d = \"\";\n positions.forEach((position, i) => {\n const point = paperOf(position, view);\n box.add(point);\n d += `${i === 0 ? \"M\" : \"L\"}${rounded(point.x, decimals)} ${rounded(point.y, decimals)}`;\n });\n return close ? `${d}Z` : d;\n}\n\n/** This function gives the path data of a geometry, and adds each of its points to the box. */\nfunction pathOf(geometry: Geometry, view: FrameView, box: PaperBox, decimals: number): string {\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\":\n return \"\";\n case \"LineString\":\n return linePath(geometry.coordinates, view, box, false, decimals);\n case \"MultiLineString\":\n return geometry.coordinates.map((line) => linePath(line, view, box, false, decimals)).join(\"\");\n case \"Polygon\":\n case \"MultiPolygon\": {\n const polygons = geometry.type === \"Polygon\" ? [geometry.coordinates] : geometry.coordinates;\n return polygons.flatMap((rings) => rings.map((ring) => linePath(ring, view, box, true, decimals))).join(\"\");\n }\n case \"GeometryCollection\":\n return geometry.geometries.map((item) => pathOf(item, view, box, decimals)).join(\"\");\n }\n}\n\n/** The options of `geometryPath`. */\nexport interface PathOptions {\n /** The number of decimals of each millimetre value: an integer from 0 to 10. The default is 2, as in `renderMap`. */\n readonly decimals?: number;\n}\n\n/**\n * This function gives the SVG path data (the attribute `d`) of a geometry on the paper of a frame, in millimetres.\n * `renderMap` uses the same path data for its lines and areas.\n *\n * - Each ring of a polygon is `M` and its first point, `L` and each next point, and `Z`: `M10 20L30 20L30 40Z`.\n * - A line is the same with no `Z`.\n * - A polygon with holes and a multi-polygon give one path data. Use `fill-rule=\"evenodd\"` to fill it.\n * - A point gives no path data. A geometry collection gives the path data of each of its geometries.\n * - The function does not clip. A point out of the frame gives values out of the frame.\n *\n * @throws MapError - The code is `style`. The number of decimals is not an integer from 0 to 10.\n * @throws GeoError - A position is not correct for the projection.\n */\nexport function geometryPath(view: FrameView, geometry: Geometry, options: PathOptions = {}): string {\n const decimals = options.decimals ?? 2;\n if (!(Number.isInteger(decimals) && decimals >= 0 && decimals <= 10)) throw new MapError(\"style\", `The number of decimals ${decimals} is not an integer from 0 to 10`);\n return pathOf(geometry, view, new PaperBox(), decimals);\n}\n\n/** This function gives the SVG of one geometry with a style. */\nfunction drawGeometry(geometry: Geometry, style: Style, view: FrameView, fill: string | undefined): string {\n const frame = view.frame;\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\": {\n if (style.point === undefined) return \"\";\n const positions = geometry.type === \"Point\" ? [geometry.coordinates] : geometry.coordinates;\n return positions\n .map((position) => paperOf(position, view))\n .filter((point) => point.x >= -style.point!.sizeMm && point.x <= frame.widthMm + style.point!.sizeMm && point.y >= -style.point!.sizeMm && point.y <= frame.heightMm + style.point!.sizeMm)\n .map((point) => pointSymbol(style.point!, point.x, point.y))\n .join(\"\");\n }\n case \"LineString\":\n case \"MultiLineString\": {\n if (style.stroke === undefined) return \"\";\n const box = new PaperBox();\n const d = pathOf(geometry, view, box, 2);\n if (!box.touches(frame, style.stroke.widthMm)) return \"\";\n return `<path d=\"${d}\" fill=\"none\" ${strokeAttributes(style.stroke)}/>`;\n }\n case \"Polygon\":\n case \"MultiPolygon\": {\n const box = new PaperBox();\n const d = pathOf(geometry, view, box, 2);\n if (!box.touches(frame, style.stroke?.widthMm ?? 0)) return \"\";\n const stroke = style.stroke === undefined ? `stroke=\"none\"` : strokeAttributes(style.stroke);\n let svg = \"\";\n if (style.fill?.gray !== undefined) svg += `<path d=\"${d}\" fill=\"${grayColor(style.fill.gray)}\" fill-rule=\"evenodd\" stroke=\"none\"/>`;\n svg += `<path d=\"${d}\" fill=\"${fill ?? \"none\"}\" fill-rule=\"evenodd\" ${stroke}/>`;\n return svg;\n }\n case \"GeometryCollection\":\n return geometry.geometries.map((item) => drawGeometry(item, style, view, fill)).join(\"\");\n }\n}\n\n/** This function gives the features of a layer after its filter and its simplification. */\nfunction featuresOf(layer: Layer, frame: Frame): Feature[] {\n const kept = layer.features.filter((feature) => feature.geometry !== null && (layer.filter === undefined || matchesFilter(layer.filter, feature)));\n if (layer.simplifyMm === undefined) return kept;\n const areas = kept.flatMap((feature, i) => (feature.geometry?.type === \"Polygon\" || feature.geometry?.type === \"MultiPolygon\" ? [i] : []));\n if (areas.length === 0) return kept;\n // A tolerance of t mm on the paper is t * scale mm on the ground, and t * scale / 1e6 km.\n const simplified = simplifyRegions(\n areas.map((i) => kept[i]!.geometry as Region),\n (layer.simplifyMm * frame.scale) / 1e6,\n );\n const result = [...kept];\n areas.forEach((index, j) => {\n result[index] = { ...kept[index]!, geometry: simplified[j]! };\n });\n return result;\n}\n\n/** The options of `renderMap` and `mapLabels`. */\nexport interface RenderOptions {\n /** The font of the labels. A map with a label rule needs it. */\n readonly labelFont?: LabelFont;\n}\n\n/** The middle of the north arrow, from the top right corner of the frame, and the half size of its box, in millimetres. */\nconst NORTH_ARROW = { inset: 6.5, half: 4.7 };\n\n/** This function gives the marks of the edge texts of a map. Without a font, the width of a text is an estimate. */\nfunction edgeMarksOf(map: MapDocument, font: LabelFont | undefined): EdgeMark[] {\n const measure = (text: string): number => (font === undefined ? text.length * EDGE_TEXT_MM * CHARACTER_WIDTH : font.measure(text, EDGE_TEXT_MM));\n return edgeMarks(map.frame.widthMm, map.frame.heightMm, map.edges ?? {}, measure);\n}\n\nfunction placementOf(map: MapDocument, features: readonly Feature[][], view: FrameView, font: LabelFont): LabelPlacement {\n const obstacles = [\n ...(map.northArrow === false ? [] : [{ x: map.frame.widthMm - NORTH_ARROW.inset, y: NORTH_ARROW.inset, half: NORTH_ARROW.half }]),\n ...edgeMarksOf(map, font).map((mark) => ({ x: mark.x, y: mark.y, half: mark.halfWidth, halfHeight: mark.halfHeight })),\n ];\n const layers = map.layers.map((layer, i) => ({ id: layer.id, features: features[i]!, label: layer.label, pointSizeMm: layer.style.point?.sizeMm }));\n return placeLabels(layers, view, font, obstacles);\n}\n\nfunction labelFontOf(map: MapDocument, options: RenderOptions): LabelFont | undefined {\n const labelled = map.layers.find((layer) => layer.label !== undefined);\n if (labelled === undefined) return undefined;\n const font = options.labelFont;\n if (font === undefined || typeof font.measure !== \"function\" || typeof font.family !== \"string\" || font.family.trim() === \"\") {\n throw new MapError(\"label\", `The layer \"${labelled.id}\" has labels, so the options need a label font with a family and a measure`);\n }\n return font;\n}\n\n/**\n * This function gives the labels of a map with their places, and the texts with no place. `renderMap` draws the same\n * labels.\n *\n * @throws MapError - The map is not correct, as `checkMap` tells, or a layer has labels and the options have no font.\n */\nexport function mapLabels(map: MapDocument, options: RenderOptions = {}): LabelPlacement {\n checkMap(map);\n const font = labelFontOf(map, options);\n if (font === undefined) return { placed: [], skipped: [] };\n return placementOf(map, map.layers.map((layer) => featuresOf(layer, map.frame)), frameView(map.frame), font);\n}\n\n/** This function gives the swatch of a layer in the legend, with its top left corner at a point. */\nfunction swatch(style: Style, x: number, y: number, fill: string | undefined): string {\n if (style.point !== undefined) return pointSymbol(style.point, x + 3, y + 1.75);\n if (style.fill !== undefined) {\n const stroke = style.stroke === undefined ? `stroke=\"#000000\" stroke-width=\"0.1\"` : strokeAttributes(style.stroke);\n const base = style.fill.gray === undefined ? \"\" : `<rect x=\"${mm(x)}\" y=\"${mm(y)}\" width=\"6\" height=\"3.5\" fill=\"${grayColor(style.fill.gray)}\"/>`;\n return `${base}<rect x=\"${mm(x)}\" y=\"${mm(y)}\" width=\"6\" height=\"3.5\" fill=\"${fill ?? \"none\"}\" ${stroke}/>`;\n }\n return `<path d=\"M${mm(x)} ${mm(y + 1.75)}L${mm(x + 6)} ${mm(y + 1.75)}\" ${strokeAttributes(style.stroke!)}/>`;\n}\n\nfunction thousands(value: number): string {\n return String(Math.round(value)).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n}\n\n/** The space between the frame and the column of the legend at the side, in millimetres. */\nconst SIDE_GAP_MM = 3;\n/** The space above the first row of the column of the legend at the side, in millimetres. */\nconst SIDE_TOP_MM = 1;\n/** The least width of the column of the legend at the side, in millimetres. */\nconst SIDE_LEAST_WIDTH_MM = 30;\n/** The space between the scale bars and the legend in the column at the side, in millimetres. */\nconst SIDE_GROUP_GAP_MM = 1.5;\n/** The space at the right of a scale bar in the column at the side for its label, in millimetres. */\nconst SCALE_LABEL_MM = 12;\n/** The size of the font of the legend texts, in millimetres. */\nconst LEGEND_TEXT_MM = 2.4;\n/** The distance from the left side of a swatch to its text, in millimetres. */\nconst LEGEND_TEXT_X_MM = 7.5;\n/** The width of a character of a legend text, as a part of the size of the font, when the options have no font. */\nconst CHARACTER_WIDTH = 0.6;\n\n/** The parts of the legend of a map, with the space that they use. The size of the frame does not change them. */\ninterface LegendLayout {\n readonly bars: readonly (\"metric\" | \"imperial\")[];\n readonly lines: readonly string[];\n /** The width of the column at the side, or 0. */\n readonly columnMm: number;\n /** The height of the column at the side, or 0. */\n readonly columnHeightMm: number;\n /** The height of the block of the scale bars and the legend below the frame, or 0. */\n readonly blockMm: number;\n}\n\n/** This function gives the font that measures the legend texts: the label font of the options, if it has a measure. */\nfunction measureFontOf(options: RenderOptions): LabelFont | undefined {\n const font = options.labelFont;\n return font !== undefined && typeof font.measure === \"function\" ? font : undefined;\n}\n\nfunction legendLayout(map: MapDocument, font: LabelFont | undefined): LegendLayout {\n const units = map.scaleBar ?? \"both\";\n const bars = units === \"none\" ? [] : units === \"both\" ? ([\"metric\", \"imperial\"] as const) : [units];\n const texts = map.layers.flatMap((layer) => (layer.legend === undefined ? [] : [layer.legend]));\n const lines = attributionLines(map);\n const place = map.legendPlace ?? \"below\";\n if (place === \"below\" || bars.length + texts.length === 0) {\n const blockMm = place === \"below\" ? Math.max(bars.length, Math.ceil(texts.length / 2)) * SCALE_BAR_ROW_MM : 0;\n return { bars, lines, columnMm: 0, columnHeightMm: 0, blockMm };\n }\n const width = (text: string): number => (font === undefined ? text.length * LEGEND_TEXT_MM * CHARACTER_WIDTH : font.measure(text, LEGEND_TEXT_MM));\n const widest = Math.max(0, ...texts.map(width));\n const columnMm = Math.max(SIDE_LEAST_WIDTH_MM, LEGEND_TEXT_X_MM + widest + 1);\n const gap = bars.length > 0 && texts.length > 0 ? SIDE_GROUP_GAP_MM : 0;\n const columnHeightMm = SIDE_TOP_MM + (bars.length + texts.length) * SCALE_BAR_ROW_MM + gap;\n return { bars, lines, columnMm, columnHeightMm, blockMm: 0 };\n}\n\n/** The space of the SVG of a map around its frame, in millimetres. */\nexport interface MapMargins {\n /** The width at the right of the frame: the gap and the column of the legend at the side, or 0. */\n readonly rightMm: number;\n /** The height below the frame: the legend below the frame, if it is there, and the attribution block. */\n readonly belowMm: number;\n /** The height of the column of the legend at the side, or 0. A frame with less height makes the SVG taller. */\n readonly leastHeightMm: number;\n}\n\nfunction marginsOf(layout: LegendLayout): MapMargins {\n return {\n rightMm: layout.columnMm === 0 ? 0 : SIDE_GAP_MM + layout.columnMm,\n belowMm: 2 + layout.blockMm + 2.5 + (layout.lines.length - 1) * 3 + 1.5,\n leastHeightMm: layout.columnHeightMm,\n };\n}\n\n/**\n * This function gives the space of the SVG of a map around its frame, for the place of the legend of the map. The\n * size of the frame does not change it.\n *\n * - The label font of the options measures the legend texts. With no font, each character is 0.6 of the size of the font.\n * - The SVG of the map is `rightMm` wider and `belowMm` taller than its frame.\n *\n * @throws MapError - The map is not correct, as `checkMap` tells.\n */\nexport function mapMargins(map: MapDocument, options: RenderOptions = {}): MapMargins {\n checkMap(map);\n return marginsOf(legendLayout(map, measureFontOf(options)));\n}\n\n/** A space for the SVG of a map, in millimetres, for example the printable area of a paper below a heading. */\nexport interface MapSpace {\n readonly widthMm: number;\n readonly heightMm: number;\n}\n\n/** The options of `fitFrame`. */\nexport interface FitOptions {\n /** The font of the labels. It also measures the legend texts. */\n readonly labelFont?: LabelFont;\n /** The places of the legend to examine. The default is `below` and `side`. */\n readonly places?: readonly LegendPlace[];\n}\n\n/** The frame with the largest area for a map in one of a list of spaces. */\nexport interface FrameFit {\n readonly widthMm: number;\n readonly heightMm: number;\n readonly legendPlace: LegendPlace;\n /** The index of the space of the frame in the list of spaces. */\n readonly space: number;\n}\n\n/**\n * This function gives the frame with the largest area for a map in one of a list of spaces, and the place of its\n * legend. The SVG of the map with that frame and that place fits that space.\n *\n * - Give one space for each choice of the caller, for example a paper upright and the same paper in landscape.\n * - The scale of the map does not change, so a larger frame shows more ground.\n * - The size of the frame of the map does not change the result.\n * - With two choices of equal area, the first place of the options wins, and then the first space.\n *\n * @throws MapError - The map is not correct, a place or a space is not correct, or no choice leaves space for a frame.\n */\nexport function fitFrame(map: MapDocument, spaces: readonly MapSpace[], options: FitOptions = {}): FrameFit {\n checkMap(map);\n for (const { widthMm, heightMm } of spaces) {\n if (![widthMm, heightMm].every((value) => Number.isFinite(value) && value > 0)) {\n throw new MapError(\"frame\", `The space ${widthMm} by ${heightMm} mm is not two finite numbers more than 0`);\n }\n }\n const places = options.places ?? LEGEND_PLACES;\n const font = measureFontOf(options);\n let best: FrameFit | undefined;\n for (const place of places) {\n if (!LEGEND_PLACES.includes(place)) throw new MapError(\"style\", `The place of the legend \"${String(place)}\" is not \"below\" or \"side\"`);\n const margins = marginsOf(legendLayout({ ...map, legendPlace: place }, font));\n for (const [index, { widthMm, heightMm }] of spaces.entries()) {\n const frameWidth = widthMm - margins.rightMm;\n const frameHeight = heightMm - margins.belowMm;\n if (!(frameWidth > 0 && frameHeight > 0 && frameHeight >= margins.leastHeightMm)) continue;\n if (best === undefined || frameWidth * frameHeight > best.widthMm * best.heightMm) {\n best = { widthMm: frameWidth, heightMm: frameHeight, legendPlace: place, space: index };\n }\n }\n }\n if (best === undefined) throw new MapError(\"frame\", \"No space of the list has space for a frame after the legend\");\n return best;\n}\n\n/** This function gives the lines of the attribution block: the scale, the projection and each source one time. */\nexport function attributionLines(map: MapDocument): string[] {\n const lines = [`Scale 1:${thousands(map.frame.scale)} at the center. Projection: ${map.frame.projection.name}.`];\n const seen = new Set<string>();\n for (const { source } of map.layers) {\n const line = `Data: ${source.title}. License: ${source.license}.${source.url === undefined ? \"\" : ` ${source.url}`}${source.date === undefined ? \"\" : ` Date: ${source.date}.`}`;\n if (seen.has(line)) continue;\n seen.add(line);\n lines.push(line);\n }\n return lines;\n}\n\n/**\n * This function gives the SVG of a map. The units of the SVG are millimetres, for a print at the scale of the frame.\n *\n * - The map is at the top. Below it are the scale bars, the legend and the attribution block.\n * - With the place `side`, the scale bars and the legend are in a column at the right of the frame. The attribution\n * block stays below.\n * - The layers are in their sequence, from the bottom to the top. The frame clips each layer.\n * - A feature that is not on the frame is not in the SVG.\n * - Each identifier in the SVG starts with the identifier of the map. Thus two maps can be in one HTML page.\n * - The labels are above the layers. `placeLabels` tells their places. The group of the labels tells the number of\n * texts with no place in `data-skipped`.\n *\n * @throws MapError - The map is not correct, as `checkMap` tells, or a layer has labels and the options have no font.\n * @throws GeoError - A position is not correct for the projection.\n */\nexport function renderMap(map: MapDocument, options: RenderOptions = {}): string {\n checkMap(map);\n const font = labelFontOf(map, options);\n const view = frameView(map.frame);\n const { widthMm: w, heightMm: h } = map.frame;\n const defs: string[] = [`<clipPath id=\"${map.id}-clip\"><rect width=\"${mm(w)}\" height=\"${mm(h)}\"/></clipPath>`];\n const fills = map.layers.map((layer) => {\n const hatch = layer.style.fill?.hatch;\n if (hatch === undefined) return undefined;\n const id = `${map.id}-${layer.id}-hatch`;\n defs.push(hatchPattern(id, hatch));\n return `url(#${id})`;\n });\n const features = map.layers.map((layer) => featuresOf(layer, map.frame));\n const layers = map.layers.map((layer, i) => {\n const body = features[i]!\n .map((feature) => drawGeometry(feature.geometry as Geometry, layer.style, view, fills[i]))\n .join(\"\");\n return `<g id=\"${map.id}-${layer.id}\">${body}</g>`;\n });\n const labels = font === undefined ? \"\" : labelsSvg(placementOf(map, features, view, font), font);\n\n const layout = legendLayout(map, measureFontOf(options));\n const side = layout.columnMm > 0;\n const { bars, lines } = layout;\n const top = (side ? Math.max(h, layout.columnHeightMm) : h) + 2;\n const sideX = w + SIDE_GAP_MM;\n const maxMeters = (side ? layout.columnMm - SCALE_LABEL_MM : 0.3 * w) / view.mmPerMeter;\n const scaleBars = bars\n .map((unit, i) => {\n const length = scaleBarLength(maxMeters, unit);\n return side ? scaleBarSvg(sideX, SIDE_TOP_MM + i * SCALE_BAR_ROW_MM, length, view.mmPerMeter) : scaleBarSvg(0.5, top + i * SCALE_BAR_ROW_MM, length, view.mmPerMeter);\n })\n .join(\"\");\n const legendLayers = map.layers.flatMap((layer, i) => (layer.legend === undefined ? [] : [{ layer, fill: fills[i] }]));\n const columnWidth = w * 0.275;\n const sideTop = SIDE_TOP_MM + bars.length * SCALE_BAR_ROW_MM + (bars.length > 0 ? SIDE_GROUP_GAP_MM : 0);\n const legend = legendLayers\n .map(({ layer, fill }, i) => {\n const x = side ? sideX : w * 0.45 + (i % 2) * columnWidth;\n const y = side ? sideTop + i * SCALE_BAR_ROW_MM : top + Math.floor(i / 2) * SCALE_BAR_ROW_MM - 1;\n return `${swatch(layer.style, x, y, fill)}<text x=\"${mm(x + LEGEND_TEXT_X_MM)}\" y=\"${mm(y + 2.9)}\" font-size=\"${LEGEND_TEXT_MM}\">${escapeHtml(layer.legend!)}</text>`;\n })\n .join(\"\");\n const firstLine = top + layout.blockMm + 2.5;\n const attribution = lines.map((line, i) => `<text x=\"0.5\" y=\"${mm(firstLine + i * 3)}\" font-size=\"2.2\">${escapeHtml(line)}</text>`).join(\"\");\n const total = firstLine + (lines.length - 1) * 3 + 1.5;\n const width = side ? sideX + layout.columnMm : w;\n const arrow = map.northArrow === false ? \"\" : northArrowSvg(w - 6.5, 6.5, view.northDegrees);\n const edges = edgeMarksOf(map, measureFontOf(options))\n .map((mark) => mark.svg)\n .join(\"\");\n\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${mm(width)}mm\" height=\"${mm(total)}mm\" viewBox=\"0 0 ${mm(width)} ${mm(total)}\" ` +\n `role=\"img\" aria-label=\"${escapeAttribute(map.title)}\" font-family=\"sans-serif\">` +\n `<title>${escapeHtml(map.title)}</title><defs>${defs.join(\"\")}</defs>` +\n `<rect width=\"${mm(width)}\" height=\"${mm(total)}\" fill=\"#ffffff\"/>` +\n `<g clip-path=\"url(#${map.id}-clip)\">${layers.join(\"\")}</g>${labels}` +\n `<rect width=\"${mm(w)}\" height=\"${mm(h)}\" fill=\"none\" stroke=\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,GAAG,IAAI,EAAE,WAAW,GAAG,IAAI,gBAAgB,EAAE,OAAO,GAAG,IAAI,GAAG,EAAE,eAAe,eAAe,IAAI,WAAW,MAAM,MAAO,EAAE;CAC/J,CAAC,CAAC,CACD,KAAK,EAAE;CACV,MAAM,YAAY,MAAM,OAAO,UAAU;CACzC,MAAM,cAAc,MAAM,KAAK,MAAM,MAAM,oBAAoB,GAAG,YAAY,IAAI,CAAC,EAAE,oBAAoB,WAAW,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE;CAC3I,MAAM,QAAQ,aAAa,MAAM,SAAS,KAAK,IAAI;CACnD,MAAM,QAAQ,OAAO,QAAQ,OAAO,WAAW;CAC/C,MAAM,QAAQ,IAAI,eAAe,QAAQ,KAAK,cAAc,IAAI,KAAK,KAAK,KAAK,YAAY;CAC3F,MAAM,QAAQ,YAAY,KAAK,cAAc,OAAO,CAAC,CAAC,CACnD,KAAK,SAAS,KAAK,GAAG,CAAC,CACvB,KAAK,EAAE;CAEV,OACE,kDAAkD,GAAG,KAAK,EAAE,cAAc,GAAG,KAAK,EAAE,mBAAmB,GAAG,KAAK,EAAE,GAAG,GAAG,KAAK,EAAE,2BACpG,gBAAgB,IAAI,KAAK,EAAE,oCAC3C,WAAW,IAAI,KAAK,EAAE,gBAAgB,KAAK,KAAK,EAAE,EAAE,sBAC9C,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK,EAAE,uCAC1B,IAAI,GAAG,UAAU,OAAO,KAAK,EAAE,EAAE,MAAM,OAAA,eAC7C,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,qDACrC,QAAQ,MAAM,oBAAoB,YAAY,OAAO,6BAA6B,YAAY;AAErG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/cartography",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "Maps as data: a frame, layers with filters and black and white styles, and a render to SVG in millimetres with a scale bar, a north arrow, a legend and the attribution of each source.",
6
6
  "keywords": [
7
7
  "map",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@mark1russell7/cue": "^2.0.0",
44
- "@mark1russell7/layout-contract": "^0.10.6",
44
+ "@mark1russell7/layout-contract": "^0.11.1",
45
45
  "@mark1russell7/rigor-generators": "^0.2.0",
46
46
  "@types/node": "^26.6.5",
47
47
  "@vitest/coverage-v8": "^5.0.3",