@mark1russell7/cartography 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -1
- package/dist/index.d.ts +199 -83
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +307 -72
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ const svg = renderMap(map);
|
|
|
34
34
|
| Filter | `Filter` | Data, so a map can be JSON: `all`, `any`, `not`, `property` with `in` or `exists`, and `geometry`. |
|
|
35
35
|
| Style | `Style` | Black, white and gray only: lines with dashes, areas with gray levels and hatches, and point symbols. |
|
|
36
36
|
| Source | `Source` | A title and a license. Each layer must have a source. The attribution block names each source one time. |
|
|
37
|
+
| Edge texts | `edges` | A text at the middle of an edge of the frame, for example the name of the neighbor page in an atlas. |
|
|
37
38
|
|
|
38
39
|
## The functions
|
|
39
40
|
|
|
@@ -52,6 +53,9 @@ const svg = renderMap(map);
|
|
|
52
53
|
| `fitFrame(map, spaces, options)` | The frame with the largest area in one of a list of spaces, for example a paper, and the place of its legend. |
|
|
53
54
|
| `placeLabels(layers, view, font)` | The places of the labels of the layers, with no overlap, inside the frame. |
|
|
54
55
|
| `labelText(rule, feature)` | The text of the label of a feature, or `undefined`. |
|
|
56
|
+
| `atlasPages(plan)` | The pages of an atlas of a large area at one scale, with the names of their neighbor pages. |
|
|
57
|
+
| `atlasOutlines(atlas)` | The outline of each page of an atlas as a polygon feature, for an index map. |
|
|
58
|
+
| `atlasIndexFrame(atlas, widthMm, heightMm)` | The frame of an index map that shows all the pages of an atlas. |
|
|
55
59
|
|
|
56
60
|
## Labels
|
|
57
61
|
|
|
@@ -76,7 +80,7 @@ const svg = renderMap({ ...map, layers: [roads] }, { labelFont });
|
|
|
76
80
|
- A line label goes along an almost straight part of the line, near its middle. `repeatMm` gives more labels on a long line.
|
|
77
81
|
- An area label goes to the middle of the area, when the area has the full box of the text.
|
|
78
82
|
- A layer with a lower `priority` gets its places first. With the same priority, a higher layer is first.
|
|
79
|
-
- The point symbols
|
|
83
|
+
- The point symbols, the north arrow and the edge texts are obstacles. No label covers them.
|
|
80
84
|
- The render puts the labels above the layers, in black with a white halo.
|
|
81
85
|
- A text with no free place is in the list `skipped` of `mapLabels`. The SVG gives the count in `data-skipped`.
|
|
82
86
|
|
|
@@ -109,3 +113,28 @@ const svg = renderMap({ ...map, frame, legendPlace: fit.legendPlace }, { labelFo
|
|
|
109
113
|
- The place `side` puts them in one column at the right of the frame. The attribution block stays below the frame.
|
|
110
114
|
- `mapMargins` gives the space around the frame for each place. The label font measures the legend texts.
|
|
111
115
|
- `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
|
+
|
|
117
|
+
## An atlas of a large area
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
// A made-up center. The circle of 25 km at 1:63,360 on pages with a map of 190 by 230 mm.
|
|
123
|
+
const center = { lat: 45, lon: 10 };
|
|
124
|
+
const atlas = atlasPages({ projection: azimuthalEquidistant(center), center, radiusMeters: 25_000, scale: 63_360, widthMm: 190, heightMm: 230 });
|
|
125
|
+
for (const page of atlas.pages) {
|
|
126
|
+
// page.id is the name of the page, for example "C2". page.neighbors.right is the name of the page at its right edge.
|
|
127
|
+
const edges = Object.fromEntries(Object.entries(page.neighbors).map(([edge, id]) => [edge, `Page ${id}`]));
|
|
128
|
+
const svg = renderMap({ ...map, frame: page.frame, edges }, { labelFont });
|
|
129
|
+
}
|
|
130
|
+
const index = atlasIndexFrame(atlas, 190, 120);
|
|
131
|
+
const pagesLayer = { id: "pages", features: atlasOutlines(atlas), style: outlineStyle, source, label: { properties: ["id"], sizeMm: 4 } };
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- The grid has its middle at the center of the area. It has the smallest number of columns and rows that shows the full circle.
|
|
135
|
+
- Neighbor pages share a strip of `overlapMm` at their common edge. The default is 10 mm.
|
|
136
|
+
- A page of the grid that shows no part of the circle is not in the atlas. Its neighbors do not name it.
|
|
137
|
+
- The columns have the letters A, B and the next letters from the west. The rows have the numbers 1, 2 and the next numbers from the north.
|
|
138
|
+
- Each page has the scale of the plan at its own center. With one azimuthal equidistant projection over 50 km, the edges of neighbor pages agree to 0.01 mm.
|
|
139
|
+
- The field `edges` of a map puts a text at the middle of each edge of the frame, with an arrow. No label covers it.
|
|
140
|
+
- `atlasOutlines` gives each outline with the name of its page in the property `id`. A label rule can show the names on the index map.
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,194 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { BBox, Feature, Geometry, LatLon } from "@mark1russell7/geo";
|
|
9
9
|
import { Projection } from "@mark1russell7/geo/projection";
|
|
10
|
+
/** The frame of a map. The center of the frame is at the middle of the paper. */
|
|
11
|
+
interface Frame {
|
|
12
|
+
/** The projection from the Earth to the plane, from `@mark1russell7/geo/projection`. */
|
|
13
|
+
readonly projection: Projection;
|
|
14
|
+
/** The point on the Earth at the middle of the map. */
|
|
15
|
+
readonly center: LatLon;
|
|
16
|
+
/** The denominator of the scale at the center: 24000 for the scale 1:24,000. */
|
|
17
|
+
readonly scale: number;
|
|
18
|
+
/** The width of the map on the paper, in millimetres. */
|
|
19
|
+
readonly widthMm: number;
|
|
20
|
+
/** The height of the map on the paper, in millimetres. */
|
|
21
|
+
readonly heightMm: number;
|
|
22
|
+
}
|
|
23
|
+
/** A point on the paper in millimetres, from the top left corner of the map. The y axis points down. */
|
|
24
|
+
interface PaperPoint {
|
|
25
|
+
/** The distance to the right, in millimetres. */
|
|
26
|
+
readonly x: number;
|
|
27
|
+
/** The distance down, in millimetres. */
|
|
28
|
+
readonly y: number;
|
|
29
|
+
}
|
|
30
|
+
/** The functions of a frame between the Earth and the paper. */
|
|
31
|
+
interface FrameView {
|
|
32
|
+
/** The frame. */
|
|
33
|
+
readonly frame: Frame;
|
|
34
|
+
/** The millimetres of paper for one metre on the ground at the center. */
|
|
35
|
+
readonly mmPerMeter: number;
|
|
36
|
+
/** The millimetres of paper for one metre on the plane of the projection. */
|
|
37
|
+
readonly mmPerPlaneMeter: number;
|
|
38
|
+
/** This function gives the point on the paper for a point on the Earth. */
|
|
39
|
+
readonly toPaper: (point: LatLon) => PaperPoint;
|
|
40
|
+
/** This function gives the point on the Earth for a point on the paper. */
|
|
41
|
+
readonly fromPaper: (point: PaperPoint) => LatLon;
|
|
42
|
+
/** The direction of north at the center, in degrees clockwise from the top of the paper. */
|
|
43
|
+
readonly northDegrees: number;
|
|
44
|
+
}
|
|
45
|
+
/** This function refuses a frame with a scale or a size that is not a finite number more than 0. */
|
|
46
|
+
export declare function checkFrame(frame: Frame): void;
|
|
47
|
+
/**
|
|
48
|
+
* This function gives the functions of a frame between the Earth and the paper.
|
|
49
|
+
*
|
|
50
|
+
* - The scale of the frame is the true scale at the center. The function divides by the scale factor of the projection
|
|
51
|
+
* at the center: the square root of `max * min` of `projection.scale`.
|
|
52
|
+
* - For Web Mercator, the scale changes with the latitude. For `azimuthalEquidistant`, it is almost the same on all
|
|
53
|
+
* the map.
|
|
54
|
+
*
|
|
55
|
+
* @throws MapError - The code is `frame`.
|
|
56
|
+
* @throws GeoError - The center is not a correct point for the projection.
|
|
57
|
+
*/
|
|
58
|
+
export declare function frameView(frame: Frame): FrameView;
|
|
59
|
+
/**
|
|
60
|
+
* 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
|
|
61
|
+
* points on each side of the frame, so it contains the corners and the edges of the frame.
|
|
62
|
+
*
|
|
63
|
+
* @throws MapError - The code is `frame`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function frameBBox(frame: Frame): BBox;
|
|
66
|
+
/** The units of the scale bars of a map. `both` gives a metric bar and an imperial bar. */
|
|
67
|
+
type ScaleBarUnits = "metric" | "imperial" | "both" | "none";
|
|
68
|
+
/** The length of a scale bar on the ground and its label. */
|
|
69
|
+
interface ScaleBarLength {
|
|
70
|
+
/** The length on the ground in metres. */
|
|
71
|
+
readonly meters: number;
|
|
72
|
+
/** The label, for example `500 m`, `2 km`, `0.5 mi` or `200 ft`. */
|
|
73
|
+
readonly label: string;
|
|
74
|
+
}
|
|
75
|
+
/** 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. */
|
|
76
|
+
export declare function niceNumber(max: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* This function gives the length of a scale bar that is not longer than a length on the ground.
|
|
79
|
+
*
|
|
80
|
+
* - The metric bar is in metres below 1 km, and in kilometres from 1 km.
|
|
81
|
+
* - The imperial bar is in miles from a quarter of a mile, and in feet below that.
|
|
82
|
+
*/
|
|
83
|
+
export declare function scaleBarLength(maxMeters: number, units: "metric" | "imperial"): ScaleBarLength;
|
|
84
|
+
/** The height of one scale bar with its label, in millimetres. */
|
|
85
|
+
export declare const SCALE_BAR_ROW_MM = 4.5;
|
|
86
|
+
/** This function gives the SVG of a scale bar of four parts, with its top left corner at a point on the paper. */
|
|
87
|
+
export declare function scaleBarSvg(x: number, y: number, length: ScaleBarLength, mmPerMeter: number): string;
|
|
88
|
+
/** This function gives the SVG of a north arrow at a point on the paper, with the direction of north in degrees. */
|
|
89
|
+
export declare function northArrowSvg(x: number, y: number, northDegrees: number): string;
|
|
90
|
+
/** The four edges of a frame. When north is up, the top edge is at the north. */
|
|
91
|
+
type FrameEdge = "top" | "right" | "bottom" | "left";
|
|
92
|
+
/** The four edges of a frame, in the sequence of the marks. */
|
|
93
|
+
export declare const FRAME_EDGES: readonly FrameEdge[];
|
|
94
|
+
/** The size of the font of a text at an edge of the frame, in millimetres. */
|
|
95
|
+
export declare const EDGE_TEXT_MM = 2.6;
|
|
96
|
+
/** The mark of a text at an edge of the frame: its box on the paper and its SVG. */
|
|
97
|
+
interface EdgeMark {
|
|
98
|
+
/** The edge of the mark. */
|
|
99
|
+
readonly edge: FrameEdge;
|
|
100
|
+
/** The middle of the box on the paper, in millimetres from the top left corner of the frame. */
|
|
101
|
+
readonly x: number;
|
|
102
|
+
/** The middle of the box on the paper, in millimetres from the top left corner of the frame. */
|
|
103
|
+
readonly y: number;
|
|
104
|
+
/** The half width of the box, in millimetres. */
|
|
105
|
+
readonly halfWidth: number;
|
|
106
|
+
/** The half height of the box, in millimetres. */
|
|
107
|
+
readonly halfHeight: number;
|
|
108
|
+
/** 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. */
|
|
109
|
+
readonly svg: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 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.
|
|
113
|
+
* An edge with no text has no mark.
|
|
114
|
+
*
|
|
115
|
+
* @param measure - This function gives the width of a text in millimetres at the size `EDGE_TEXT_MM`.
|
|
116
|
+
*/
|
|
117
|
+
export declare function edgeMarks(widthMm: number, heightMm: number, texts: Readonly<Partial<Record<FrameEdge, string>>>, measure: (text: string) => number): EdgeMark[];
|
|
118
|
+
/** The plan of an atlas: the area, the scale and the size of the map on each page. */
|
|
119
|
+
interface AtlasPlan {
|
|
120
|
+
/** The projection of all the pages. One projection puts the pages on one plane, so the edges of neighbor pages agree. */
|
|
121
|
+
readonly projection: Projection;
|
|
122
|
+
/** The center of the area on the Earth. The grid of the pages has its middle at this point. */
|
|
123
|
+
readonly center: LatLon;
|
|
124
|
+
/** The radius of the area on the ground, in metres. The atlas keeps each page that shows a part of the circle. */
|
|
125
|
+
readonly radiusMeters: number;
|
|
126
|
+
/** The denominator of the scale of each page: 63360 for the scale 1:63,360 (1 inch for 1 mile). */
|
|
127
|
+
readonly scale: number;
|
|
128
|
+
/** The width of the map on each page, in millimetres. */
|
|
129
|
+
readonly widthMm: number;
|
|
130
|
+
/** The height of the map on each page, in millimetres. */
|
|
131
|
+
readonly heightMm: number;
|
|
132
|
+
/** The width of the strip at each edge that the neighbor page also shows, in millimetres. The default is 10. */
|
|
133
|
+
readonly overlapMm?: number | undefined;
|
|
134
|
+
}
|
|
135
|
+
/** One page of an atlas. */
|
|
136
|
+
interface AtlasPage {
|
|
137
|
+
/**
|
|
138
|
+
* The name of the page: the letters of its column and the number of its row, for example `B3`.
|
|
139
|
+
* The columns go from west to east, and the rows from north to south.
|
|
140
|
+
*/
|
|
141
|
+
readonly id: string;
|
|
142
|
+
/** The index of the column in the grid, from 0 at the west. */
|
|
143
|
+
readonly column: number;
|
|
144
|
+
/** The index of the row in the grid, from 0 at the north. */
|
|
145
|
+
readonly row: number;
|
|
146
|
+
/** The frame of the map of the page. */
|
|
147
|
+
readonly frame: Frame;
|
|
148
|
+
/**
|
|
149
|
+
* The names of the neighbor pages at the edges of the page. An edge with no page in the atlas has no name.
|
|
150
|
+
* The top edge is at the north of the center of the area.
|
|
151
|
+
*/
|
|
152
|
+
readonly neighbors: Readonly<Partial<Record<FrameEdge, string>>>;
|
|
153
|
+
}
|
|
154
|
+
/** The pages of an atlas, in the order of the rows and then the columns. */
|
|
155
|
+
interface Atlas {
|
|
156
|
+
/** The plan of the atlas. */
|
|
157
|
+
readonly plan: AtlasPlan;
|
|
158
|
+
/** The number of columns of the grid. */
|
|
159
|
+
readonly columns: number;
|
|
160
|
+
/** The number of rows of the grid. */
|
|
161
|
+
readonly rows: number;
|
|
162
|
+
/** The pages that show a part of the area. A page of the grid outside the circle is not in the list. */
|
|
163
|
+
readonly pages: readonly AtlasPage[];
|
|
164
|
+
}
|
|
165
|
+
/** The default width of the overlap of neighbor pages, in millimetres. */
|
|
166
|
+
export declare const ATLAS_OVERLAP_MM = 10;
|
|
167
|
+
/**
|
|
168
|
+
* This function gives the name of a column: A to Z, then AA, AB and the next names.
|
|
169
|
+
*
|
|
170
|
+
* @throws MapError - The code is `atlas`. The index is not an integer of 0 or more.
|
|
171
|
+
*/
|
|
172
|
+
export declare function columnName(index: number): string;
|
|
173
|
+
/**
|
|
174
|
+
* This function gives the pages of an atlas: a grid of frames on the plane of the projection.
|
|
175
|
+
* The middle of the grid is at the center of the area.
|
|
176
|
+
*
|
|
177
|
+
* - Neighbor pages share a strip of `overlapMm` at their common edge.
|
|
178
|
+
* - The grid has the smallest number of columns and rows that shows the full circle.
|
|
179
|
+
* - 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.
|
|
180
|
+
*
|
|
181
|
+
* @throws MapError - The code is `frame` or `atlas`.
|
|
182
|
+
*/
|
|
183
|
+
export declare function atlasPages(plan: AtlasPlan): Atlas;
|
|
184
|
+
/**
|
|
185
|
+
* 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`.
|
|
186
|
+
* A layer of an index map draws them. Each edge has `pointsPerEdge` points, because the edges of the pages are curves on the Earth.
|
|
187
|
+
*
|
|
188
|
+
* @throws MapError - The code is `atlas`. The number of points is not an integer of 1 or more.
|
|
189
|
+
*/
|
|
190
|
+
export declare function atlasOutlines(atlas: Atlas, pointsPerEdge?: number): Feature[];
|
|
191
|
+
/**
|
|
192
|
+
* 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.
|
|
193
|
+
* Its center is the middle of the grid.
|
|
194
|
+
*
|
|
195
|
+
* @throws MapError - The code is `frame`.
|
|
196
|
+
*/
|
|
197
|
+
export declare function atlasIndexFrame(atlas: Atlas, widthMm: number, heightMm: number): Frame;
|
|
10
198
|
/**
|
|
11
199
|
* The error of this package. Each refusal has a code, so a caller can test the reason without the text of the message.
|
|
12
200
|
*
|
|
@@ -20,8 +208,10 @@ import { Projection } from "@mark1russell7/geo/projection";
|
|
|
20
208
|
* - `filter`: a filter is not one of the forms of `Filter`.
|
|
21
209
|
* - `style`: a style draws nothing, or a size, a gray level or a dash is not correct.
|
|
22
210
|
* - `source`: a layer has no source, or its source has no title or no license.
|
|
211
|
+
* - `label`: a label rule, a label font or an edge text is not correct.
|
|
212
|
+
* - `atlas`: the radius or the overlap of an atlas is not correct.
|
|
23
213
|
*/
|
|
24
|
-
type MapErrorCode = "frame" | "id" | "filter" | "style" | "source" | "label";
|
|
214
|
+
type MapErrorCode = "frame" | "id" | "filter" | "style" | "source" | "label" | "atlas";
|
|
25
215
|
/** The error that each function of this package throws for an incorrect map. */
|
|
26
216
|
export declare class MapError extends Error {
|
|
27
217
|
/** The reason of the refusal. */
|
|
@@ -69,62 +259,6 @@ export declare function matchesFilter(filter: Filter, feature: Feature): boolean
|
|
|
69
259
|
* @throws MapError - The code is `filter`.
|
|
70
260
|
*/
|
|
71
261
|
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
262
|
/** The rule of the labels of a layer. */
|
|
129
263
|
interface LabelRule {
|
|
130
264
|
/** The properties of a feature, in sequence. The first property with a text that is not empty gives the label. */
|
|
@@ -194,40 +328,17 @@ export declare function labelText(rule: LabelRule, feature: Feature): string | u
|
|
|
194
328
|
* - Each point symbol of the layers and the north arrow are obstacles too.
|
|
195
329
|
* - 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
330
|
*
|
|
197
|
-
* @param obstacles - The boxes on the paper that no label covers, as the middle and the half size in millimetres.
|
|
331
|
+
* @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`.
|
|
198
332
|
* @throws MapError - The code is `label`: the width of a text from `measure` is not a finite number of 0 or more.
|
|
199
333
|
*/
|
|
200
334
|
export declare function placeLabels(layers: readonly LabelLayer[], view: FrameView, font: LabelFont, obstacles?: readonly {
|
|
201
335
|
x: number;
|
|
202
336
|
y: number;
|
|
203
337
|
half: number;
|
|
338
|
+
halfHeight?: number;
|
|
204
339
|
}[]): LabelPlacement;
|
|
205
340
|
/** 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
341
|
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
342
|
/**
|
|
232
343
|
* A line. The gray level goes from 0 (black) to 1 (white). The default is 0.
|
|
233
344
|
*/
|
|
@@ -339,6 +450,11 @@ interface MapDocument {
|
|
|
339
450
|
readonly northArrow?: boolean;
|
|
340
451
|
/** The place of the scale bars and the legend. The default is `below`. `fitFrame` finds the place with the largest frame. */
|
|
341
452
|
readonly legendPlace?: LegendPlace;
|
|
453
|
+
/**
|
|
454
|
+
* The texts at the middle of the edges of the frame, for example the names of the neighbor pages of an atlas.
|
|
455
|
+
* Each text is in a white box with an arrow that points out of the frame. No labels cover the boxes.
|
|
456
|
+
*/
|
|
457
|
+
readonly edges?: Readonly<Partial<Record<FrameEdge, string>>>;
|
|
342
458
|
}
|
|
343
459
|
/** The place of the scale bars and the legend: below the frame, or in a column at the right side of the frame. */
|
|
344
460
|
type LegendPlace = "below" | "side";
|
|
@@ -430,5 +546,5 @@ export declare function attributionLines(map: MapDocument): string[];
|
|
|
430
546
|
* @throws GeoError - A position is not correct for the projection.
|
|
431
547
|
*/
|
|
432
548
|
export declare function renderMap(map: MapDocument, options?: RenderOptions): string;
|
|
433
|
-
export type { FillStyle, Filter, FilterValue, FitOptions, Frame, FrameFit, FrameView, GeometryKind, HatchStyle, LabelFont, LabelLayer, LabelPlacement, LabelRule, Layer, LegendPlace, MapDocument, MapErrorCode, MapMargins, MapSpace, PaperPoint, PlacedLabel, PointStyle, PointSymbol, RenderOptions, ScaleBarLength, ScaleBarUnits, Source, StrokeStyle, Style };
|
|
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 };
|
|
434
550
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
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,WAAW,SAAS,QAAQ,OAAO;;;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