@mark1russell7/cartography 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mark Russell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,92 @@
1
- # Temporary Holding Version
1
+ # @mark1russell7/cartography
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Maps as data for print and screen. A map is a frame, layers from the bottom to the top, and its marks. The render gives an SVG in millimetres, for a print at the scale of the frame. The core names no topic. An add-on gives the layers and the styles of a topic, for example `@mark1russell7/cartography-emergency`.
4
+
5
+ ```ts
6
+ import { renderMap, type MapDocument } from "@mark1russell7/cartography";
7
+ import { azimuthalEquidistant } from "@mark1russell7/geo/projection";
8
+
9
+ const center = { lat: 45, lon: 10 };
10
+ const map: MapDocument = {
11
+ id: "town",
12
+ title: "The roads of the town",
13
+ frame: { projection: azimuthalEquidistant(center), center, scale: 24000, widthMm: 180, heightMm: 240 },
14
+ layers: [
15
+ {
16
+ id: "roads",
17
+ features: roads, // GeoJSON features, positions [lon, lat] on WGS84
18
+ filter: { property: "highway", in: ["primary", "secondary"] },
19
+ style: { stroke: { widthMm: 0.6 } },
20
+ source: { title: "© OpenStreetMap contributors", license: "ODbL 1.0", url: "https://www.openstreetmap.org/copyright" },
21
+ legend: "Main road",
22
+ },
23
+ ],
24
+ };
25
+ const svg = renderMap(map);
26
+ ```
27
+
28
+ ## The parts of a map
29
+
30
+ | Part | Type | Rules |
31
+ | --- | --- | --- |
32
+ | Frame | `Frame` | A projection, a center, the denominator of the scale, and the width and the height on the paper in millimetres. |
33
+ | Layer | `Layer` | Features, a filter, a style, a source and a legend text. The tolerance `simplifyMm` simplifies the areas. |
34
+ | Filter | `Filter` | Data, so a map can be JSON: `all`, `any`, `not`, `property` with `in` or `exists`, and `geometry`. |
35
+ | Style | `Style` | Black, white and gray only: lines with dashes, areas with gray levels and hatches, and point symbols. |
36
+ | Source | `Source` | A title and a license. Each layer must have a source. The attribution block names each source one time. |
37
+
38
+ ## The functions
39
+
40
+ | Function | Result |
41
+ | --- | --- |
42
+ | `renderMap(map, options)` | The SVG of the map, with the scale bars, the legend, the north arrow, the labels and the attribution block. |
43
+ | `checkMap(map)` | Nothing. It throws a `MapError` for a map that is not correct. |
44
+ | `frameView(frame)` | The functions between the Earth and the paper, and the direction of north. |
45
+ | `frameBBox(frame)` | The box on the Earth around the frame, for a fetch of the data of a map. |
46
+ | `matchesFilter(filter, feature)` | `true` when the feature matches the filter. |
47
+ | `checkFilter(value)` | Nothing. It throws a `MapError` for a value that is not a `Filter`. |
48
+ | `attributionLines(map)` | The lines of the attribution block: the scale, the projection and each source. |
49
+ | `scaleBarLength(meters, units)` | The longest round length of a scale bar that is not longer than a length on the ground. |
50
+ | `mapLabels(map, options)` | The labels of the map with their places, and the texts with no place. |
51
+ | `placeLabels(layers, view, font)` | The places of the labels of the layers, with no overlap, inside the frame. |
52
+ | `labelText(rule, feature)` | The text of the label of a feature, or `undefined`. |
53
+
54
+ ## Labels
55
+
56
+ A layer with a `label` rule shows the names of its features. The labels do not overlap, and each label is inside the frame.
57
+
58
+ ```ts
59
+ import { readFileSync } from "node:fs";
60
+ import { measureWidth, readFont } from "@mark1russell7/typeset/fonts";
61
+
62
+ const font = readFont(readFileSync("LiberationSans-Regular.ttf"));
63
+ const labelFont = {
64
+ family: '"Liberation Sans", Arial, sans-serif',
65
+ measure: (text: string, sizeMm: number) => measureWidth(font, text, sizeMm),
66
+ };
67
+ const roads = { ...layer, label: { properties: ["ref", "name"], sizeMm: 2.5, repeatMm: 80 } };
68
+ const svg = renderMap({ ...map, layers: [roads] }, { labelFont });
69
+ ```
70
+
71
+ - The core has no font tables. The caller gives the font family and a function that measures a text in millimetres.
72
+ - Use the same font for the print. Liberation Sans has the same widths as Arial.
73
+ - A point label goes to the first free place of 8 places around its symbol.
74
+ - A line label goes along an almost straight part of the line, near its middle. `repeatMm` gives more labels on a long line.
75
+ - An area label goes to the middle of the area, when the area has the full box of the text.
76
+ - A layer with a lower `priority` gets its places first. With the same priority, a higher layer is first.
77
+ - The point symbols and the north arrow are obstacles. No label covers them.
78
+ - The render puts the labels above the layers, in black with a white halo.
79
+ - A text with no free place is in the list `skipped` of `mapLabels`. The SVG gives the count in `data-skipped`.
80
+
81
+ ## Rules
82
+
83
+ - The scale of the frame is the true scale at the center. Use `azimuthalEquidistant` for a map of a small area.
84
+ - Web Mercator changes its scale with the latitude. On the ellipsoid, it also changes its scale with the direction: at 45 degrees, by approximately 0.34 %.
85
+ - The render removes a feature that is not on the frame, and the frame clips each layer.
86
+ - Each identifier in the SVG starts with the identifier of the map. Thus two maps can be in one HTML page.
87
+ - The simplification uses `simplifyRegions` of `@mark1russell7/geo`. A tolerance of 0.2 mm on the paper at 1:24,000 is 4.8 m on the ground.
88
+ - Each refusal is a `MapError` with a code: `frame`, `id`, `filter`, `style`, `source` or `label`.
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,377 @@
1
+ /**
2
+ * A map as data for print and screen: a frame, and layers with black and white styles. The render gives an SVG with
3
+ * a scale bar, a north arrow, a legend, labels with no overlap and the attribution of each source. The core names no
4
+ * topic. An add-on gives the layers and the styles of a topic.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import { BBox, Feature, Geometry, LatLon } from "@mark1russell7/geo";
9
+ import { Projection } from "@mark1russell7/geo/projection";
10
+ /**
11
+ * The error of this package. Each refusal has a code, so a caller can test the reason without the text of the message.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ /**
16
+ * The reason of a refusal.
17
+ *
18
+ * - `frame`: the scale or the size of a frame is not a finite number more than 0.
19
+ * - `id`: an identifier is not lower case letters, digits and hyphens, or two layers have the same identifier.
20
+ * - `filter`: a filter is not one of the forms of `Filter`.
21
+ * - `style`: a style draws nothing, or a size, a gray level or a dash is not correct.
22
+ * - `source`: a layer has no source, or its source has no title or no license.
23
+ */
24
+ type MapErrorCode = "frame" | "id" | "filter" | "style" | "source" | "label";
25
+ /** The error that each function of this package throws for an incorrect map. */
26
+ export declare class MapError extends Error {
27
+ /** The reason of the refusal. */
28
+ readonly code: MapErrorCode;
29
+ /**
30
+ * @param code - The reason of the refusal.
31
+ * @param message - The text for a person.
32
+ */
33
+ constructor(code: MapErrorCode, message: string);
34
+ }
35
+ /** A value that a filter compares with a property of a feature. */
36
+ type FilterValue = string | number | boolean;
37
+ /** The kind of a geometry: points, lines or areas. A collection of two kinds is `mixed`. */
38
+ type GeometryKind = "point" | "line" | "area" | "mixed";
39
+ /**
40
+ * A filter of the features of a layer.
41
+ *
42
+ * - `{ all }` matches when each filter matches. `{ any }` matches when one filter matches. `{ not }` reverses a filter.
43
+ * - `{ property, in }` matches a feature whose property is equal to one of the values.
44
+ * - `{ property, exists }` matches a feature that has the property, or that does not have it.
45
+ * - `{ geometry }` matches a feature whose geometry has the kind.
46
+ */
47
+ type Filter = {
48
+ readonly all: readonly Filter[];
49
+ } | {
50
+ readonly any: readonly Filter[];
51
+ } | {
52
+ readonly not: Filter;
53
+ } | {
54
+ readonly property: string;
55
+ readonly in: readonly FilterValue[];
56
+ } | {
57
+ readonly property: string;
58
+ readonly exists: boolean;
59
+ } | {
60
+ readonly geometry: GeometryKind;
61
+ };
62
+ /** This function gives the kind of a geometry. */
63
+ export declare function geometryKind(geometry: Geometry): GeometryKind;
64
+ /** This function tells if a feature matches a filter. A feature with no geometry matches no `{ geometry }` filter. */
65
+ export declare function matchesFilter(filter: Filter, feature: Feature): boolean;
66
+ /**
67
+ * This function refuses a value that is not a `Filter`, for example a filter from JSON.
68
+ *
69
+ * @throws MapError - The code is `filter`.
70
+ */
71
+ export declare function checkFilter(filter: unknown, path?: string): asserts filter is Filter;
72
+ /** The frame of a map. The center of the frame is at the middle of the paper. */
73
+ interface Frame {
74
+ /** The projection from the Earth to the plane, from `@mark1russell7/geo/projection`. */
75
+ readonly projection: Projection;
76
+ /** The point on the Earth at the middle of the map. */
77
+ readonly center: LatLon;
78
+ /** The denominator of the scale at the center: 24000 for the scale 1:24,000. */
79
+ readonly scale: number;
80
+ /** The width of the map on the paper, in millimetres. */
81
+ readonly widthMm: number;
82
+ /** The height of the map on the paper, in millimetres. */
83
+ readonly heightMm: number;
84
+ }
85
+ /** A point on the paper in millimetres, from the top left corner of the map. The y axis points down. */
86
+ interface PaperPoint {
87
+ /** The distance to the right, in millimetres. */
88
+ readonly x: number;
89
+ /** The distance down, in millimetres. */
90
+ readonly y: number;
91
+ }
92
+ /** The functions of a frame between the Earth and the paper. */
93
+ interface FrameView {
94
+ /** The frame. */
95
+ readonly frame: Frame;
96
+ /** The millimetres of paper for one metre on the ground at the center. */
97
+ readonly mmPerMeter: number;
98
+ /** The millimetres of paper for one metre on the plane of the projection. */
99
+ readonly mmPerPlaneMeter: number;
100
+ /** This function gives the point on the paper for a point on the Earth. */
101
+ readonly toPaper: (point: LatLon) => PaperPoint;
102
+ /** This function gives the point on the Earth for a point on the paper. */
103
+ readonly fromPaper: (point: PaperPoint) => LatLon;
104
+ /** The direction of north at the center, in degrees clockwise from the top of the paper. */
105
+ readonly northDegrees: number;
106
+ }
107
+ /** This function refuses a frame with a scale or a size that is not a finite number more than 0. */
108
+ export declare function checkFrame(frame: Frame): void;
109
+ /**
110
+ * This function gives the functions of a frame between the Earth and the paper.
111
+ *
112
+ * - The scale of the frame is the true scale at the center. The function divides by the scale factor of the projection
113
+ * at the center: the square root of `max * min` of `projection.scale`.
114
+ * - For Web Mercator, the scale changes with the latitude. For `azimuthalEquidistant`, it is almost the same on all
115
+ * the map.
116
+ *
117
+ * @throws MapError - The code is `frame`.
118
+ * @throws GeoError - The center is not a correct point for the projection.
119
+ */
120
+ export declare function frameView(frame: Frame): FrameView;
121
+ /**
122
+ * 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
123
+ * points on each side of the frame, so it contains the corners and the edges of the frame.
124
+ *
125
+ * @throws MapError - The code is `frame`.
126
+ */
127
+ export declare function frameBBox(frame: Frame): BBox;
128
+ /** The rule of the labels of a layer. */
129
+ interface LabelRule {
130
+ /** The properties of a feature, in sequence. The first property with a text that is not empty gives the label. */
131
+ readonly properties: readonly string[];
132
+ /** The size of the font in millimetres on the paper. */
133
+ readonly sizeMm: number;
134
+ /** The rank of the labels of the layer. A lower rank gets its places first. The default is 0. */
135
+ readonly priority?: number;
136
+ /** For a line: the distance in millimetres between two labels of the same text. No value gives one label for each text. */
137
+ readonly repeatMm?: number;
138
+ }
139
+ /** The font of the labels. The width of a label comes from `measure`, so the font of the print must be the same font. */
140
+ interface LabelFont {
141
+ /** The CSS font family of the labels, for example `"Liberation Sans", Arial, sans-serif`. */
142
+ readonly family: string;
143
+ /** This function gives the width in millimetres of a text at a size of the font in millimetres. */
144
+ readonly measure: (text: string, sizeMm: number) => number;
145
+ }
146
+ /** A label with its place: the middle of its box on the paper, and its angle. */
147
+ interface PlacedLabel {
148
+ /** The identifier of the layer of the label. */
149
+ readonly layer: string;
150
+ readonly text: string;
151
+ /** The middle of the label on the paper, in millimetres from the top left corner of the frame. */
152
+ readonly x: number;
153
+ readonly y: number;
154
+ /** The angle of the text in degrees, clockwise, more than -90 and not more than 90. So each label reads from the left. */
155
+ readonly angle: number;
156
+ readonly sizeMm: number;
157
+ readonly widthMm: number;
158
+ }
159
+ /** The labels of a map: the labels with a place, and the texts with no place. */
160
+ interface LabelPlacement {
161
+ readonly placed: readonly PlacedLabel[];
162
+ /** Each text that has no place with no overlap, inside the frame. */
163
+ readonly skipped: readonly {
164
+ readonly layer: string;
165
+ readonly text: string;
166
+ }[];
167
+ }
168
+ /** A layer as the labels see it: its identifier, its features after its filter, its rule and the size of its points. */
169
+ interface LabelLayer {
170
+ readonly id: string;
171
+ readonly features: readonly Feature[];
172
+ readonly label?: LabelRule | undefined;
173
+ /** The size in millimetres of the point symbol of the layer, when its style has points. */
174
+ readonly pointSizeMm?: number | undefined;
175
+ }
176
+ /**
177
+ * This function examines the label rule of a layer.
178
+ *
179
+ * @throws MapError - The code is `label`.
180
+ */
181
+ export declare function checkLabelRule(rule: LabelRule, layer: string): void;
182
+ /** This function gives the text of the label of a feature: the first property of the rule with a text. */
183
+ export declare function labelText(rule: LabelRule, feature: Feature): string | undefined;
184
+ /**
185
+ * This function gives the places of the labels of the layers. The labels do not overlap, and each label is inside the
186
+ * frame.
187
+ *
188
+ * - The layers with a lower `priority` get their places first. With the same priority, a higher layer is first.
189
+ * - In a layer, the features with the same text are one job. A longer line is first, then the sequence of the features.
190
+ * - A point gets the first free place of 8 places around its symbol: right, left, above, below, then the corners.
191
+ * - A line gets its text along an almost straight part. The longest run is first, and the middle of a run is first.
192
+ * - With `repeatMm`, a line gets more labels of its text, at that distance or more from each other.
193
+ * - An area gets its text at its centroid or at the middle of its box, when the area has the box of the text.
194
+ * - Each point symbol of the layers and the north arrow are obstacles too.
195
+ * - 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.
196
+ *
197
+ * @param obstacles - The boxes on the paper that no label covers, as the middle and the half size in millimetres.
198
+ * @throws MapError - The code is `label`: the width of a text from `measure` is not a finite number of 0 or more.
199
+ */
200
+ export declare function placeLabels(layers: readonly LabelLayer[], view: FrameView, font: LabelFont, obstacles?: readonly {
201
+ x: number;
202
+ y: number;
203
+ half: number;
204
+ }[]): LabelPlacement;
205
+ /** This function gives the SVG of the labels: black text with a white halo, so a label reads over the lines of the map. */
206
+ export declare function labelsSvg(placement: LabelPlacement, font: LabelFont): string;
207
+ /** The units of the scale bars of a map. `both` gives a metric bar and an imperial bar. */
208
+ type ScaleBarUnits = "metric" | "imperial" | "both" | "none";
209
+ /** The length of a scale bar on the ground and its label. */
210
+ interface ScaleBarLength {
211
+ /** The length on the ground in metres. */
212
+ readonly meters: number;
213
+ /** The label, for example `500 m`, `2 km`, `0.5 mi` or `200 ft`. */
214
+ readonly label: string;
215
+ }
216
+ /** 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. */
217
+ export declare function niceNumber(max: number): number;
218
+ /**
219
+ * This function gives the length of a scale bar that is not longer than a length on the ground.
220
+ *
221
+ * - The metric bar is in metres below 1 km, and in kilometres from 1 km.
222
+ * - The imperial bar is in miles from a quarter of a mile, and in feet below that.
223
+ */
224
+ export declare function scaleBarLength(maxMeters: number, units: "metric" | "imperial"): ScaleBarLength;
225
+ /** The height of one scale bar with its label, in millimetres. */
226
+ export declare const SCALE_BAR_ROW_MM = 4.5;
227
+ /** This function gives the SVG of a scale bar of four parts, with its top left corner at a point on the paper. */
228
+ export declare function scaleBarSvg(x: number, y: number, length: ScaleBarLength, mmPerMeter: number): string;
229
+ /** This function gives the SVG of a north arrow at a point on the paper, with the direction of north in degrees. */
230
+ export declare function northArrowSvg(x: number, y: number, northDegrees: number): string;
231
+ /**
232
+ * A line. The gray level goes from 0 (black) to 1 (white). The default is 0.
233
+ */
234
+ interface StrokeStyle {
235
+ /** The width of the line in millimetres. */
236
+ readonly widthMm: number;
237
+ /** The gray level from 0 (black) to 1 (white). The default is 0. */
238
+ readonly gray?: number;
239
+ /** The lengths of the dashes and the gaps in millimetres. No value gives a solid line. */
240
+ readonly dashMm?: readonly number[];
241
+ }
242
+ /** Parallel lines in an area. A cross hatch adds the same lines at right angles. */
243
+ interface HatchStyle {
244
+ /** The angle of the lines in degrees, clockwise from horizontal. */
245
+ readonly angleDegrees: number;
246
+ /** The distance between two lines in millimetres. It is more than the width of a line. */
247
+ readonly spacingMm: number;
248
+ /** The width of a line in millimetres. */
249
+ readonly widthMm: number;
250
+ /** The value `true` adds the lines at right angles. The default is `false`. */
251
+ readonly cross?: boolean;
252
+ }
253
+ /** The fill of an area: a gray level, a hatch, or the two. The hatch is on top of the gray level. */
254
+ interface FillStyle {
255
+ /** The gray level from 0 (black) to 1 (white). No value gives no solid fill. */
256
+ readonly gray?: number;
257
+ /** The hatch. No value gives no hatch. */
258
+ readonly hatch?: HatchStyle;
259
+ }
260
+ /** The symbols of the points. */
261
+ type PointSymbol = "circle" | "square" | "triangle" | "diamond" | "cross";
262
+ /** The symbol of each point. */
263
+ interface PointStyle {
264
+ /** The shape of the symbol. */
265
+ readonly symbol: PointSymbol;
266
+ /** The size of the symbol in millimetres. */
267
+ readonly sizeMm: number;
268
+ /** The value `false` gives a white symbol with a black outline. The default is `true`, a black symbol. */
269
+ readonly filled?: boolean;
270
+ }
271
+ /** 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. */
272
+ interface Style {
273
+ /** The line. */
274
+ readonly stroke?: StrokeStyle;
275
+ /** The fill of the areas. */
276
+ readonly fill?: FillStyle;
277
+ /** The symbol of the points. */
278
+ readonly point?: PointStyle;
279
+ }
280
+ /**
281
+ * This function refuses a style that draws nothing, and a size, a gray level, a dash or a symbol that is not correct.
282
+ *
283
+ * @throws MapError - The code is `style`.
284
+ */
285
+ export declare function checkStyle(style: Style, layer: string): void;
286
+ /** This function gives a number for SVG, to 0.01 mm. */
287
+ export declare function mm(value: number): string;
288
+ /** This function gives the color of a gray level, from `#000000` to `#ffffff`. */
289
+ export declare function grayColor(gray: number): string;
290
+ /** This function gives the SVG attributes of a line. */
291
+ export declare function strokeAttributes(stroke: StrokeStyle): string;
292
+ /** This function gives the SVG pattern of a hatch, with an identifier. */
293
+ export declare function hatchPattern(id: string, hatch: HatchStyle): string;
294
+ /** This function gives the SVG of a point symbol at a point on the paper. */
295
+ export declare function pointSymbol(point: PointStyle, x: number, y: number): string;
296
+ /** The source of the data of a layer. The map prints each source in its attribution block. */
297
+ interface Source {
298
+ /** The name of the source, for example `© OpenStreetMap contributors`. */
299
+ readonly title: string;
300
+ /** The license of the data, for example `ODbL 1.0`. */
301
+ readonly license: string;
302
+ /** The web address of the source or of its license. */
303
+ readonly url?: string;
304
+ /** The date of the data, for example `2026-11-21`. */
305
+ readonly date?: string;
306
+ }
307
+ /** A layer of a map: features, a filter, a style and the source of the features. */
308
+ interface Layer {
309
+ /** The identifier of the layer: lower case letters, digits and hyphens. It starts with a letter. */
310
+ readonly id: string;
311
+ /** The features. Their positions are `[lon, lat]` on WGS84. */
312
+ readonly features: readonly Feature[];
313
+ /** The style of the features. */
314
+ readonly style: Style;
315
+ /** The source of the features. */
316
+ readonly source: Source;
317
+ /** The filter of the features. No filter keeps each feature. */
318
+ readonly filter?: Filter;
319
+ /** The text of the layer in the legend. No text gives no entry in the legend. */
320
+ readonly legend?: string;
321
+ /** The tolerance in millimetres on the paper for the simplification of the areas. No value keeps each position. */
322
+ readonly simplifyMm?: number;
323
+ /** The rule of the labels of the features. No rule gives no labels. */
324
+ readonly label?: LabelRule;
325
+ }
326
+ /** A map: a frame, layers from the bottom to the top, and its marks. */
327
+ interface MapDocument {
328
+ /** The identifier of the map: lower case letters, digits and hyphens. It starts each identifier in the SVG. */
329
+ readonly id: string;
330
+ /** The title of the map, for a reader of the screen. */
331
+ readonly title: string;
332
+ /** The frame. */
333
+ readonly frame: Frame;
334
+ /** The layers, from the bottom to the top. */
335
+ readonly layers: readonly Layer[];
336
+ /** The units of the scale bars. The default is `both`. */
337
+ readonly scaleBar?: ScaleBarUnits;
338
+ /** The value `false` gives no north arrow. The default is `true`. */
339
+ readonly northArrow?: boolean;
340
+ }
341
+ /**
342
+ * This function examines a map. It refuses a frame, an identifier, a style, a filter or a source that is not correct.
343
+ * Each layer must have a source with a title and a license, so the attribution block names each source of the map.
344
+ *
345
+ * @throws MapError - The code tells the reason.
346
+ */
347
+ export declare function checkMap(map: MapDocument): void;
348
+ /** The options of `renderMap` and `mapLabels`. */
349
+ interface RenderOptions {
350
+ /** The font of the labels. A map with a label rule needs it. */
351
+ readonly labelFont?: LabelFont;
352
+ }
353
+ /**
354
+ * This function gives the labels of a map with their places, and the texts with no place. `renderMap` draws the same
355
+ * labels.
356
+ *
357
+ * @throws MapError - The map is not correct, as `checkMap` tells, or a layer has labels and the options have no font.
358
+ */
359
+ export declare function mapLabels(map: MapDocument, options?: RenderOptions): LabelPlacement;
360
+ /** This function gives the lines of the attribution block: the scale, the projection and each source one time. */
361
+ export declare function attributionLines(map: MapDocument): string[];
362
+ /**
363
+ * This function gives the SVG of a map. The units of the SVG are millimetres, for a print at the scale of the frame.
364
+ *
365
+ * - The map is at the top. Below it are the scale bars, the legend and the attribution block.
366
+ * - The layers are in their sequence, from the bottom to the top. The frame clips each layer.
367
+ * - A feature that is not on the frame is not in the SVG.
368
+ * - Each identifier in the SVG starts with the identifier of the map. Thus two maps can be in one HTML page.
369
+ * - The labels are above the layers. `placeLabels` tells their places. The group of the labels tells the number of
370
+ * texts with no place in `data-skipped`.
371
+ *
372
+ * @throws MapError - The map is not correct, as `checkMap` tells, or a layer has labels and the options have no font.
373
+ * @throws GeoError - A position is not correct for the projection.
374
+ */
375
+ export declare function renderMap(map: MapDocument, options?: RenderOptions): string;
376
+ export type { FillStyle, Filter, FilterValue, Frame, FrameView, GeometryKind, HatchStyle, LabelFont, LabelLayer, LabelPlacement, LabelRule, Layer, MapDocument, MapErrorCode, PaperPoint, PlacedLabel, PointStyle, PointSymbol, RenderOptions, ScaleBarLength, ScaleBarUnits, Source, StrokeStyle, Style };
377
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors.ts","../src/filter.ts","../src/frame.ts","../src/labels.ts","../src/marks.ts","../src/style.ts","../src/render.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KAeY;;qBAGC,iBAAiB;;WAEnB,MAAM;;;;;EAMf,YAAY,MAAM,cAAc;;;KChBtB;;KAGA;;;;;;;;;KAUA;WACG,cAAc;;WACd,cAAc;;WACd,KAAK;;WACL;WAA2B,aAAa;;WACxC;WAA2B;;WAC3B,UAAU;;;wBAGT,aAAa,UAAU,WAAW;;wBAmBlC,cAAc,QAAQ,QAAQ,SAAS;;;;;;wBAkBvC,YAAY,iBAAiB,wBAA0B,UAAU;;UC1DhE;;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;;UCpFxB;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA,UAAU,cAAc;;;UAIlB;;WAEN;WACA;;WAEA;WACA;;WAEA;WACA;WACA;;;UAIM;WACN,iBAAiB;;WAEjB;aAA6B;aAAwB;;;;UAI/C;WACN;WACA,mBAAmB;WACnB,QAAQ;;WAER;;;;;;;wBAmBK,eAAe,MAAM,WAAW;;wBAYhC,UAAU,MAAM,WAAW,SAAS;;;;;;;;;;;;;;;;;wBA2PpC,YAAY,iBAAiB,cAAc,MAAM,WAAW,MAAM,WAAW;EAAsB;EAAW;EAAW;MAAwB;;wBAkFjJ,UAAU,WAAW,gBAAgB,MAAM;;KC7Z/C;;UAGK;;WAEN;;WAEA;;;wBAOK,WAAW;;;;;;;wBAeX,eAAe,mBAAmB,+BAA+B;;qBAepE;;wBAGG,YAAY,WAAW,WAAW,QAAQ,gBAAgB;;wBAW1D,cAAc,WAAW,WAAW;;;;UCxDnC;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA,QAAQ;;;KAIP;;UAGK;;WAEN,QAAQ;;WAER;;WAEA;;;UAIM;;WAEN,SAAS;;WAET,OAAO;;WAEP,QAAQ;;;;;;;wBAuBH,WAAW,OAAO,OAAO;;wBA6BzB,GAAG;;wBAKH,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;;;;;;;;wBAqBK,SAAS,KAAK;;UA+Gb;;WAEN,YAAY;;;;;;;;wBA4BP,UAAU,KAAK,aAAa,UAAS,gBAAqB;;wBAuB1D,iBAAiB,KAAK;;;;;;;;;;;;;;wBAyBtB,UAAU,KAAK,aAAa,UAAS"}