@versatiles/style 5.2.6 → 5.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +274 -14
- package/dist/index.js +3650 -11
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/color/abstract.ts +83 -0
- package/src/color/hsl.test.ts +182 -0
- package/src/color/hsl.ts +122 -0
- package/src/color/hsv.test.ts +174 -0
- package/src/color/hsv.ts +100 -0
- package/src/color/index.test.ts +119 -0
- package/src/color/index.ts +38 -0
- package/src/color/random.test.ts +35 -0
- package/src/color/random.ts +165 -0
- package/src/color/rgb.test.ts +227 -0
- package/src/color/rgb.ts +248 -0
- package/src/color/utils.test.ts +86 -0
- package/src/color/utils.ts +13 -0
- package/src/guess_style/guess_style.test.ts +134 -0
- package/src/guess_style/guess_style.ts +166 -0
- package/{dist/guess_style/index.d.ts → src/guess_style/index.ts} +1 -0
- package/src/index.test.ts +77 -0
- package/src/index.ts +18 -0
- package/src/lib/utils.test.ts +197 -0
- package/src/lib/utils.ts +134 -0
- package/{dist/shortbread/index.d.ts → src/shortbread/index.ts} +1 -0
- package/src/shortbread/layers.test.ts +36 -0
- package/src/shortbread/layers.ts +564 -0
- package/src/shortbread/properties.test.ts +44 -0
- package/src/shortbread/properties.ts +142 -0
- package/src/shortbread/template.test.ts +43 -0
- package/src/shortbread/template.ts +343 -0
- package/src/style_builder/decorator.test.ts +67 -0
- package/src/style_builder/decorator.ts +135 -0
- package/src/style_builder/recolor.test.ts +306 -0
- package/src/style_builder/recolor.ts +110 -0
- package/src/style_builder/style_builder.test.ts +103 -0
- package/src/style_builder/style_builder.ts +134 -0
- package/src/style_builder/types.ts +141 -0
- package/src/styles/LICENSE.md +41 -0
- package/src/styles/colorful.ts +1041 -0
- package/src/styles/eclipse.ts +11 -0
- package/{dist/styles/empty.d.ts → src/styles/empty.ts} +7 -3
- package/src/styles/graybeard.ts +11 -0
- package/src/styles/index.ts +33 -0
- package/src/styles/neutrino.ts +429 -0
- package/{dist/types/index.d.ts → src/types/index.ts} +1 -0
- package/{dist/types/maplibre.d.ts → src/types/maplibre.ts} +3 -0
- package/src/types/tilejson.test.ts +94 -0
- package/src/types/tilejson.ts +125 -0
- package/src/types/vector_layer.test.ts +64 -0
- package/src/types/vector_layer.ts +69 -0
- package/dist/color/abstract.d.ts +0 -34
- package/dist/color/abstract.js +0 -53
- package/dist/color/abstract.js.map +0 -1
- package/dist/color/hsl.d.ts +0 -23
- package/dist/color/hsl.js +0 -98
- package/dist/color/hsl.js.map +0 -1
- package/dist/color/hsv.d.ts +0 -20
- package/dist/color/hsv.js +0 -100
- package/dist/color/hsv.js.map +0 -1
- package/dist/color/index.d.ts +0 -6
- package/dist/color/index.js +0 -29
- package/dist/color/index.js.map +0 -1
- package/dist/color/random.d.ts +0 -9
- package/dist/color/random.js +0 -134
- package/dist/color/random.js.map +0 -1
- package/dist/color/rgb.d.ts +0 -28
- package/dist/color/rgb.js +0 -195
- package/dist/color/rgb.js.map +0 -1
- package/dist/color/utils.d.ts +0 -3
- package/dist/color/utils.js +0 -10
- package/dist/color/utils.js.map +0 -1
- package/dist/guess_style/guess_style.d.ts +0 -8
- package/dist/guess_style/guess_style.js +0 -147
- package/dist/guess_style/guess_style.js.map +0 -1
- package/dist/guess_style/index.js +0 -2
- package/dist/guess_style/index.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -6
- package/dist/lib/utils.js +0 -126
- package/dist/lib/utils.js.map +0 -1
- package/dist/shortbread/index.js +0 -3
- package/dist/shortbread/index.js.map +0 -1
- package/dist/shortbread/layers.d.ts +0 -5
- package/dist/shortbread/layers.js +0 -521
- package/dist/shortbread/layers.js.map +0 -1
- package/dist/shortbread/properties.d.ts +0 -7
- package/dist/shortbread/properties.js +0 -125
- package/dist/shortbread/properties.js.map +0 -1
- package/dist/shortbread/template.d.ts +0 -4
- package/dist/shortbread/template.js +0 -339
- package/dist/shortbread/template.js.map +0 -1
- package/dist/style_builder/decorator.d.ts +0 -4
- package/dist/style_builder/decorator.js +0 -127
- package/dist/style_builder/decorator.js.map +0 -1
- package/dist/style_builder/recolor.d.ts +0 -22
- package/dist/style_builder/recolor.js +0 -89
- package/dist/style_builder/recolor.js.map +0 -1
- package/dist/style_builder/style_builder.d.ts +0 -15
- package/dist/style_builder/style_builder.js +0 -106
- package/dist/style_builder/style_builder.js.map +0 -1
- package/dist/style_builder/types.d.ts +0 -122
- package/dist/style_builder/types.js +0 -3
- package/dist/style_builder/types.js.map +0 -1
- package/dist/styles/colorful.d.ts +0 -11
- package/dist/styles/colorful.js +0 -956
- package/dist/styles/colorful.js.map +0 -1
- package/dist/styles/eclipse.d.ts +0 -5
- package/dist/styles/eclipse.js +0 -9
- package/dist/styles/eclipse.js.map +0 -1
- package/dist/styles/empty.js +0 -8
- package/dist/styles/empty.js.map +0 -1
- package/dist/styles/graybeard.d.ts +0 -5
- package/dist/styles/graybeard.js +0 -9
- package/dist/styles/graybeard.js.map +0 -1
- package/dist/styles/index.d.ts +0 -11
- package/dist/styles/index.js +0 -20
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/neutrino.d.ts +0 -11
- package/dist/styles/neutrino.js +0 -401
- package/dist/styles/neutrino.js.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types/maplibre.js +0 -2
- package/dist/types/maplibre.js.map +0 -1
- package/dist/types/tilejson.d.ts +0 -32
- package/dist/types/tilejson.js +0 -87
- package/dist/types/tilejson.js.map +0 -1
- package/dist/types/vector_layer.d.ts +0 -14
- package/dist/types/vector_layer.js +0 -51
- package/dist/types/vector_layer.js.map +0 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { StyleRules, StyleRulesOptions } from '../style_builder/types.js';
|
|
2
2
|
import Colorful from './colorful.js';
|
|
3
|
+
|
|
3
4
|
export default class Empty extends Colorful {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
public readonly name: string = 'Empty';
|
|
6
|
+
|
|
7
|
+
protected getStyleRules(_options: StyleRulesOptions): StyleRules {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { StyleBuilder } from '../style_builder/style_builder.js';
|
|
2
|
+
import type { StyleBuilderOptions } from '../style_builder/types.js';
|
|
3
|
+
import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// import styles
|
|
8
|
+
import Colorful from './colorful.js';
|
|
9
|
+
import Eclipse from './eclipse.js';
|
|
10
|
+
import Graybeard from './graybeard.js';
|
|
11
|
+
import Neutrino from './neutrino.js';
|
|
12
|
+
import Empty from './empty.js';
|
|
13
|
+
|
|
14
|
+
export interface StyleBuilderFunction {
|
|
15
|
+
(options?: StyleBuilderOptions): StyleSpecification;
|
|
16
|
+
getOptions(): StyleBuilderOptions;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getStyleBuilder(styleBuilder: new () => StyleBuilder): StyleBuilderFunction {
|
|
20
|
+
const fn = function (options?: StyleBuilderOptions): StyleSpecification {
|
|
21
|
+
return new styleBuilder().build(options);
|
|
22
|
+
};
|
|
23
|
+
fn.getOptions = (): StyleBuilderOptions => new styleBuilder().getDefaultOptions();
|
|
24
|
+
return fn;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// generate style builders
|
|
29
|
+
export const colorful = getStyleBuilder(Colorful);
|
|
30
|
+
export const eclipse = getStyleBuilder(Eclipse);
|
|
31
|
+
export const graybeard = getStyleBuilder(Graybeard);
|
|
32
|
+
export const neutrino = getStyleBuilder(Neutrino);
|
|
33
|
+
export const empty = getStyleBuilder(Empty);
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { StyleBuilderColors, StyleRules, StyleRulesOptions } from '../style_builder/types.js';
|
|
2
|
+
import Colorful from './colorful.js';
|
|
3
|
+
|
|
4
|
+
export default class Neutrino extends Colorful {
|
|
5
|
+
public readonly name: string = 'Neutrino';
|
|
6
|
+
|
|
7
|
+
public defaultFonts = {
|
|
8
|
+
regular: 'noto_sans_regular',
|
|
9
|
+
bold: 'noto_sans_bold',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
public defaultColors: StyleBuilderColors = {
|
|
13
|
+
|
|
14
|
+
/** Color representing land areas. */
|
|
15
|
+
land: '#f6f0f6',
|
|
16
|
+
|
|
17
|
+
/** Color representing bodies of water such as lakes and rivers. */
|
|
18
|
+
water: '#cbd2df',
|
|
19
|
+
|
|
20
|
+
/** Color for grassy areas and fields. */
|
|
21
|
+
grass: '#e7e9e5',
|
|
22
|
+
|
|
23
|
+
/** Color for wooded or forested areas. */
|
|
24
|
+
wood: '#d9e3d9',
|
|
25
|
+
|
|
26
|
+
/** Color used for agricultural land. */
|
|
27
|
+
agriculture: '#f8eeee',
|
|
28
|
+
|
|
29
|
+
/** Color for site areas such as parks or recreational facilities. */
|
|
30
|
+
commercial: '#ebe8e6',
|
|
31
|
+
|
|
32
|
+
/** Primary color for buildings. */
|
|
33
|
+
building: '#e0d1d9',
|
|
34
|
+
|
|
35
|
+
/** Color for streets and roads. */
|
|
36
|
+
street: '#ffffff',
|
|
37
|
+
|
|
38
|
+
/** Color used for boundaries, such as national or state lines. */
|
|
39
|
+
boundary: '#e6ccd8',
|
|
40
|
+
|
|
41
|
+
/** Color for footpaths and pedestrian areas. */
|
|
42
|
+
foot: '#fef8ff',
|
|
43
|
+
|
|
44
|
+
/** Color used for railways. */
|
|
45
|
+
rail: '#e8d5e0',
|
|
46
|
+
|
|
47
|
+
/** Primary color used for text labels. */
|
|
48
|
+
label: '#cbb7b7',
|
|
49
|
+
|
|
50
|
+
// Don't need these colors:
|
|
51
|
+
buildingbg: '#000',
|
|
52
|
+
burial: '#000',
|
|
53
|
+
construction: '#000',
|
|
54
|
+
cycle: '#000',
|
|
55
|
+
danger: '#000',
|
|
56
|
+
disputed: '#000',
|
|
57
|
+
education: '#000',
|
|
58
|
+
glacier: '#000',
|
|
59
|
+
hospital: '#000',
|
|
60
|
+
industrial: '#000',
|
|
61
|
+
labelHalo: '#000',
|
|
62
|
+
leisure: '#000',
|
|
63
|
+
motorway: '#000',
|
|
64
|
+
motorwaybg: '#000',
|
|
65
|
+
park: '#000',
|
|
66
|
+
parking: '#000',
|
|
67
|
+
poi: '#000',
|
|
68
|
+
prison: '#000',
|
|
69
|
+
residential: '#000',
|
|
70
|
+
rock: '#000',
|
|
71
|
+
sand: '#000',
|
|
72
|
+
shield: '#000',
|
|
73
|
+
streetbg: '#000',
|
|
74
|
+
subway: '#000',
|
|
75
|
+
symbol: '#000',
|
|
76
|
+
trunk: '#000',
|
|
77
|
+
trunkbg: '#000',
|
|
78
|
+
waste: '#000',
|
|
79
|
+
wetland: '#000',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
protected getStyleRules(options: StyleRulesOptions): StyleRules {
|
|
84
|
+
const { colors, fonts } = options;
|
|
85
|
+
return {
|
|
86
|
+
'background': {
|
|
87
|
+
color: colors.land,
|
|
88
|
+
},
|
|
89
|
+
'boundary-{country,state}': {
|
|
90
|
+
color: colors.boundary,
|
|
91
|
+
},
|
|
92
|
+
'boundary-country:outline': {
|
|
93
|
+
size: { 2: 2, 10: 6 },
|
|
94
|
+
opacity: { 2: 0, 4: 0.3 },
|
|
95
|
+
color: colors.land.lighten(0.05),
|
|
96
|
+
lineBlur: 1,
|
|
97
|
+
},
|
|
98
|
+
'boundary-country': {
|
|
99
|
+
size: { 2: 1, 10: 4 },
|
|
100
|
+
opacity: { 2: 0, 4: 1 },
|
|
101
|
+
},
|
|
102
|
+
'boundary-state:outline': {
|
|
103
|
+
size: { 7: 3, 10: 5 },
|
|
104
|
+
opacity: { 7: 0, 8: 0.3 },
|
|
105
|
+
color: colors.land.lighten(0.05),
|
|
106
|
+
lineBlur: 1,
|
|
107
|
+
},
|
|
108
|
+
'boundary-state': {
|
|
109
|
+
size: { 7: 2, 10: 3 },
|
|
110
|
+
opacity: { 7: 0, 8: 1 },
|
|
111
|
+
lineDasharray: [0, 1.5, 1, 1.5],
|
|
112
|
+
lineCap: 'round',
|
|
113
|
+
lineJoin: 'round',
|
|
114
|
+
},
|
|
115
|
+
'water-*': {
|
|
116
|
+
color: colors.water,
|
|
117
|
+
},
|
|
118
|
+
'water-area': {
|
|
119
|
+
opacity: { 4: 0, 6: 1 },
|
|
120
|
+
},
|
|
121
|
+
'water-area-*': {
|
|
122
|
+
opacity: { 4: 0, 6: 1 },
|
|
123
|
+
},
|
|
124
|
+
'water-{pier,dam}-area': {
|
|
125
|
+
color: colors.land,
|
|
126
|
+
opacity: { 12: 0, 13: 1 },
|
|
127
|
+
},
|
|
128
|
+
'water-pier': {
|
|
129
|
+
color: colors.land,
|
|
130
|
+
},
|
|
131
|
+
'land-*': {
|
|
132
|
+
color: colors.land,
|
|
133
|
+
},
|
|
134
|
+
'land-forest': {
|
|
135
|
+
color: colors.wood,
|
|
136
|
+
opacity: { 7: 0, 8: 1 },
|
|
137
|
+
},
|
|
138
|
+
'land-grass': {
|
|
139
|
+
color: colors.grass,
|
|
140
|
+
opacity: { 11: 0, 12: 1 },
|
|
141
|
+
},
|
|
142
|
+
'land-{park,garden,vegetation}': {
|
|
143
|
+
color: colors.grass.darken(0.05).saturate(0.05),
|
|
144
|
+
opacity: { 11: 0, 12: 1 },
|
|
145
|
+
},
|
|
146
|
+
'land-agriculture': {
|
|
147
|
+
color: colors.agriculture,
|
|
148
|
+
opacity: { 10: 0, 11: 1 },
|
|
149
|
+
},
|
|
150
|
+
'land-{commercial,industrial,residential}': {
|
|
151
|
+
color: colors.land.darken(0.03),
|
|
152
|
+
opacity: { 10: 0, 11: 1 },
|
|
153
|
+
},
|
|
154
|
+
'site-{bicycleparking,parking}': {
|
|
155
|
+
color: colors.commercial,
|
|
156
|
+
},
|
|
157
|
+
'building': {
|
|
158
|
+
color: colors.building,
|
|
159
|
+
opacity: { 14: 0, 15: 1 },
|
|
160
|
+
},
|
|
161
|
+
'bridge': {
|
|
162
|
+
color: colors.land.darken(0.01),
|
|
163
|
+
},
|
|
164
|
+
'{tunnel-,bridge-,}street-*': {
|
|
165
|
+
color: colors.street,
|
|
166
|
+
size: 1,
|
|
167
|
+
lineJoin: 'round',
|
|
168
|
+
lineCap: 'round',
|
|
169
|
+
},
|
|
170
|
+
'{tunnel-,}street-*:outline': {
|
|
171
|
+
color: colors.street.darken(0.1),
|
|
172
|
+
lineJoin: 'round',
|
|
173
|
+
lineCap: 'round',
|
|
174
|
+
},
|
|
175
|
+
'tunnel-street-*': {
|
|
176
|
+
color: colors.street.darken(0.03),
|
|
177
|
+
},
|
|
178
|
+
'tunnel-street-*:outline': {
|
|
179
|
+
color: colors.street.darken(0.13),
|
|
180
|
+
lineDasharray: [1, 2],
|
|
181
|
+
},
|
|
182
|
+
'bridge-street-*:outline': {
|
|
183
|
+
color: colors.street.darken(0.15),
|
|
184
|
+
},
|
|
185
|
+
// motorway
|
|
186
|
+
'{bridge-street,tunnel-street,street}-motorway:outline': {
|
|
187
|
+
size: { 5: 2, 10: 5, 14: 5, 16: 14, 18: 38, 19: 84, 20: 168 },
|
|
188
|
+
opacity: { 5: 0, 6: 1 },
|
|
189
|
+
},
|
|
190
|
+
'{bridge-street,tunnel-street,street}-motorway': {
|
|
191
|
+
size: { 5: 1, 10: 4, 14: 4, 16: 12, 18: 36, 19: 80, 20: 160 },
|
|
192
|
+
opacity: { 5: 0, 6: 1 },
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
// trunk
|
|
196
|
+
'{bridge-street,tunnel-street,street}-trunk:outline': {
|
|
197
|
+
size: { 7: 2, 10: 4, 14: 6, 16: 12, 18: 36, 19: 74, 20: 144 },
|
|
198
|
+
opacity: { 7: 0, 8: 1 },
|
|
199
|
+
},
|
|
200
|
+
'{bridge-street,tunnel-street,street}-trunk': {
|
|
201
|
+
size: { 7: 1, 10: 3, 14: 5, 16: 10, 18: 34, 19: 70, 20: 140 },
|
|
202
|
+
opacity: { 7: 0, 8: 1 },
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
// primary
|
|
206
|
+
'{bridge-street,tunnel-street,street}-primary:outline': {
|
|
207
|
+
size: { 7: 2, 10: 4, 14: 6, 16: 12, 18: 36, 19: 74, 20: 144 },
|
|
208
|
+
opacity: { 7: 0, 8: 1 },
|
|
209
|
+
},
|
|
210
|
+
'{bridge-street,tunnel-street,street}-primary': {
|
|
211
|
+
size: { 7: 1, 10: 3, 14: 5, 16: 10, 18: 34, 19: 70, 20: 140 },
|
|
212
|
+
opacity: { 7: 0, 8: 1 },
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
// secondary
|
|
216
|
+
'{bridge-street,tunnel-street,street}-secondary:outline': {
|
|
217
|
+
size: { 11: 2, 14: 5, 16: 8, 18: 30, 19: 68, 20: 138 },
|
|
218
|
+
opacity: { 11: 0, 12: 1 },
|
|
219
|
+
},
|
|
220
|
+
'{bridge-street,tunnel-street,street}-secondary': {
|
|
221
|
+
size: { 11: 1, 14: 4, 16: 6, 18: 28, 19: 64, 20: 130 },
|
|
222
|
+
opacity: { 11: 0, 12: 1 },
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
// links
|
|
226
|
+
'{bridge-street,tunnel-street,street}-motorway-link:outline': {
|
|
227
|
+
minzoom: 12,
|
|
228
|
+
size: { 12: 2, 14: 3, 16: 7, 18: 14, 20: 40 },
|
|
229
|
+
opacity: { 12: 0, 13: 1 },
|
|
230
|
+
},
|
|
231
|
+
'{bridge-street,tunnel-street,street}-motorway-link': {
|
|
232
|
+
minzoom: 12,
|
|
233
|
+
size: { 12: 1, 14: 2, 16: 5, 18: 12, 20: 38 },
|
|
234
|
+
opacity: { 12: 0, 13: 1 },
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
'{bridge-street,tunnel-street,street}-{trunk,primary,secondary}-link:outline': {
|
|
238
|
+
minzoom: 13,
|
|
239
|
+
size: { 12: 2, 14: 3, 16: 7, 18: 14, 20: 40 },
|
|
240
|
+
opacity: { 13: 0, 14: 1 },
|
|
241
|
+
},
|
|
242
|
+
'{bridge-street,tunnel-street,street}-{trunk,primary,secondary}-link': {
|
|
243
|
+
minzoom: 13,
|
|
244
|
+
size: { 12: 1, 14: 2, 16: 5, 18: 12, 20: 38 },
|
|
245
|
+
opacity: { 13: 0, 14: 1 },
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
// minor streets
|
|
249
|
+
'{bridge-street,tunnel-street,street}-{tertiary,tertiary-link,unclassified,residential,living_street,pedestrian}:outline': {
|
|
250
|
+
size: { 12: 2, 14: 3, 16: 6, 18: 26, 19: 64, 20: 128 },
|
|
251
|
+
opacity: { 12: 0, 13: 1 },
|
|
252
|
+
},
|
|
253
|
+
'{bridge-street,tunnel-street,street}-{tertiary,tertiary-link,unclassified,residential,living_street,pedestrian}': {
|
|
254
|
+
size: { 12: 1, 14: 2, 16: 5, 18: 24, 19: 60, 20: 120 },
|
|
255
|
+
opacity: { 12: 0, 13: 1 },
|
|
256
|
+
},
|
|
257
|
+
// service and tracks
|
|
258
|
+
'{bridge-street,tunnel-street,street}-{service,track}:outline': {
|
|
259
|
+
size: { 14: 2, 16: 4, 18: 18, 19: 48, 20: 96 },
|
|
260
|
+
opacity: { 14: 0, 15: 1 },
|
|
261
|
+
},
|
|
262
|
+
'{bridge-street,tunnel-street,street}-{service,track}': {
|
|
263
|
+
size: { 14: 1, 16: 3, 18: 16, 19: 44, 20: 88 },
|
|
264
|
+
opacity: { 14: 0, 15: 1 },
|
|
265
|
+
},
|
|
266
|
+
// ways, surface only
|
|
267
|
+
'way-{footway,path,steps}:outline': {
|
|
268
|
+
size: { 17: 0, 18: 3 },
|
|
269
|
+
opacity: { 17: 0, 18: 1 },
|
|
270
|
+
minzoom: 17,
|
|
271
|
+
color: colors.foot.darken(0.05),
|
|
272
|
+
},
|
|
273
|
+
'way-{footway,path,steps}': {
|
|
274
|
+
size: { 17: 0, 18: 2 },
|
|
275
|
+
opacity: { 17: 0, 18: 1 },
|
|
276
|
+
minzoom: 17,
|
|
277
|
+
color: colors.foot,
|
|
278
|
+
},
|
|
279
|
+
'street-pedestrian': {
|
|
280
|
+
size: { 13: 1, 15: 3 },
|
|
281
|
+
opacity: { 13: 0, 14: 1 },
|
|
282
|
+
color: colors.foot,
|
|
283
|
+
},
|
|
284
|
+
'street-pedestrian-zone': {
|
|
285
|
+
color: colors.foot,
|
|
286
|
+
opacity: { 14: 0, 15: 1 },
|
|
287
|
+
},
|
|
288
|
+
// rail
|
|
289
|
+
'{tunnel-,bridge-,}transport-{rail,lightrail}:outline': {
|
|
290
|
+
color: colors.rail,
|
|
291
|
+
size: { 8: 1, 12: 1, 15: 3 },
|
|
292
|
+
},
|
|
293
|
+
'{tunnel-,bridge-,}transport-{rail,lightrail}': {
|
|
294
|
+
color: colors.rail.lighten(0.1),
|
|
295
|
+
size: { 8: 1, 12: 1, 15: 2 },
|
|
296
|
+
lineDasharray: [2, 2],
|
|
297
|
+
},
|
|
298
|
+
// bridge
|
|
299
|
+
'{bridge-,}transport-rail:outline': {
|
|
300
|
+
opacity: { 8: 0, 9: 1 },
|
|
301
|
+
},
|
|
302
|
+
'{bridge-,}transport-rail': {
|
|
303
|
+
opacity: { 14: 0, 15: 1 },
|
|
304
|
+
},
|
|
305
|
+
'{bridge-,}transport-lightrail:outline': {
|
|
306
|
+
opacity: { 11: 0, 12: 1 },
|
|
307
|
+
},
|
|
308
|
+
'{bridge-,}transport-lightrail': {
|
|
309
|
+
opacity: { 14: 0, 15: 1 },
|
|
310
|
+
},
|
|
311
|
+
// tunnel
|
|
312
|
+
'tunnel-transport-rail:outline': {
|
|
313
|
+
opacity: { 8: 0, 9: 0.3 },
|
|
314
|
+
},
|
|
315
|
+
'tunnel-transport-rail': {
|
|
316
|
+
opacity: { 14: 0, 15: 0.3 },
|
|
317
|
+
},
|
|
318
|
+
'tunnel-transport-lightrail:outline': {
|
|
319
|
+
opacity: { 11: 0, 12: 0.3 },
|
|
320
|
+
},
|
|
321
|
+
'tunnel-transport-lightrail': {
|
|
322
|
+
opacity: { 14: 0, 15: 0.3 },
|
|
323
|
+
},
|
|
324
|
+
// labels
|
|
325
|
+
'label-boundary-*': {
|
|
326
|
+
color: colors.label,
|
|
327
|
+
font: fonts.bold,
|
|
328
|
+
textTransform: 'uppercase',
|
|
329
|
+
textHaloColor: colors.label.lighten(0.5),
|
|
330
|
+
textHaloWidth: 0.1,
|
|
331
|
+
textHaloBlur: 1,
|
|
332
|
+
},
|
|
333
|
+
'label-boundary-country-large': {
|
|
334
|
+
minzoom: 2,
|
|
335
|
+
size: { 2: 11, 5: 16 },
|
|
336
|
+
},
|
|
337
|
+
'label-boundary-country-medium': {
|
|
338
|
+
minzoom: 3,
|
|
339
|
+
size: { 3: 11, 5: 15 },
|
|
340
|
+
},
|
|
341
|
+
'label-boundary-country-small': {
|
|
342
|
+
minzoom: 4,
|
|
343
|
+
size: { 4: 11, 5: 14 },
|
|
344
|
+
},
|
|
345
|
+
'label-boundary-state': {
|
|
346
|
+
minzoom: 5,
|
|
347
|
+
color: colors.label.lighten(0.05),
|
|
348
|
+
size: { 5: 8, 8: 12 },
|
|
349
|
+
},
|
|
350
|
+
'label-place-*': {
|
|
351
|
+
color: colors.label.rotateHue(-15).saturate(1).darken(0.05),
|
|
352
|
+
font: fonts.regular,
|
|
353
|
+
textHaloColor: colors.label.lighten(0.5),
|
|
354
|
+
textHaloWidth: 0.1,
|
|
355
|
+
textHaloBlur: 1,
|
|
356
|
+
size: 1,
|
|
357
|
+
},
|
|
358
|
+
'label-place-capital': {
|
|
359
|
+
minzoom: 5,
|
|
360
|
+
size: { 5: 12, 10: 16 },
|
|
361
|
+
},
|
|
362
|
+
'label-place-statecapital': {
|
|
363
|
+
minzoom: 6,
|
|
364
|
+
size: { 6: 11, 10: 15 },
|
|
365
|
+
},
|
|
366
|
+
'label-place-city': {
|
|
367
|
+
minzoom: 7,
|
|
368
|
+
size: { 7: 11, 10: 14 },
|
|
369
|
+
},
|
|
370
|
+
'label-place-town': {
|
|
371
|
+
minzoom: 8,
|
|
372
|
+
size: { 8: 11, 12: 14 },
|
|
373
|
+
},
|
|
374
|
+
'label-place-village': {
|
|
375
|
+
minzoom: 9,
|
|
376
|
+
size: { 9: 11, 12: 14 },
|
|
377
|
+
},
|
|
378
|
+
'label-place-hamlet': {
|
|
379
|
+
minzoom: 10,
|
|
380
|
+
size: { 10: 11, 12: 14 },
|
|
381
|
+
},
|
|
382
|
+
// all the city things
|
|
383
|
+
'label-place-suburb': {
|
|
384
|
+
minzoom: 11,
|
|
385
|
+
size: { 11: 11, 13: 14 },
|
|
386
|
+
textTransform: 'uppercase',
|
|
387
|
+
color: colors.label.rotateHue(-30).saturate(1).darken(0.05),
|
|
388
|
+
},
|
|
389
|
+
'label-place-quarter': {
|
|
390
|
+
minzoom: 13,
|
|
391
|
+
size: { 13: 13 },
|
|
392
|
+
textTransform: 'uppercase',
|
|
393
|
+
color: colors.label.rotateHue(-40).saturate(1).darken(0.05),
|
|
394
|
+
},
|
|
395
|
+
'label-place-neighbourhood': {
|
|
396
|
+
minzoom: 14,
|
|
397
|
+
size: { 14: 12 },
|
|
398
|
+
textTransform: 'uppercase',
|
|
399
|
+
color: colors.label.rotateHue(-50).saturate(1).darken(0.05),
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
'label-motorway-shield': {
|
|
403
|
+
color: colors.label,
|
|
404
|
+
font: fonts.regular,
|
|
405
|
+
textHaloColor: colors.label.saturate(-0.5).lighten(0.1),
|
|
406
|
+
textHaloWidth: 0.1,
|
|
407
|
+
textHaloBlur: 1,
|
|
408
|
+
symbolPlacement: 'line',
|
|
409
|
+
textAnchor: 'center',
|
|
410
|
+
minzoom: 14,
|
|
411
|
+
size: { 14: 8, 18: 10, 20: 16 },
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
'label-street-*': {
|
|
416
|
+
color: colors.label,
|
|
417
|
+
font: fonts.regular,
|
|
418
|
+
textHaloColor: colors.label.saturate(-0.5).lighten(0.1),
|
|
419
|
+
textHaloWidth: 0.1,
|
|
420
|
+
textHaloBlur: 1,
|
|
421
|
+
symbolPlacement: 'line',
|
|
422
|
+
textAnchor: 'center',
|
|
423
|
+
minzoom: 12,
|
|
424
|
+
size: { 12: 10, 15: 13 },
|
|
425
|
+
},
|
|
426
|
+
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { BackgroundLayerSpecification, FillLayerSpecification, FilterSpecification, LineLayerSpecification, SymbolLayerSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
2
|
export type { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
3
|
+
|
|
3
4
|
/** Type for Maplibre layers, including background, fill, line, and symbol specifications. */
|
|
4
5
|
export type MaplibreLayer = BackgroundLayerSpecification | FillLayerSpecification | LineLayerSpecification | SymbolLayerSpecification;
|
|
6
|
+
|
|
5
7
|
/** Defines the structure of Maplibre layer definitions, omitting the 'source' property for fill, line, and symbol specifications. */
|
|
6
8
|
export type MaplibreLayerDefinition = BackgroundLayerSpecification | Omit<FillLayerSpecification, 'source'> | Omit<LineLayerSpecification, 'source'> | Omit<SymbolLayerSpecification, 'source'>;
|
|
9
|
+
|
|
7
10
|
/** Represents a filter specification in Maplibre styles. */
|
|
8
11
|
export type MaplibreFilter = FilterSpecification;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { isTileJSONSpecification } from './tilejson.js';
|
|
4
|
+
|
|
5
|
+
describe('isTileJSONSpecification', () => {
|
|
6
|
+
const validVectorSpec = {
|
|
7
|
+
tilejson: '3.0.0',
|
|
8
|
+
type: 'vector',
|
|
9
|
+
format: 'pbf',
|
|
10
|
+
tiles: ['http://example.com/{z}/{x}/{y}.pbf'],
|
|
11
|
+
vector_layers: [{ id: 'layer1', fields: { property1: 'Number' }, description: 'A test layer' }],
|
|
12
|
+
};
|
|
13
|
+
const validRasterSpec = {
|
|
14
|
+
tilejson: '3.0.0',
|
|
15
|
+
type: 'raster',
|
|
16
|
+
format: 'png',
|
|
17
|
+
tiles: ['http://example.com/{z}/{x}/{y}.png'],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
it('should return true for a valid raster source', () => {
|
|
21
|
+
expect(isTileJSONSpecification({ ...validRasterSpec })).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return true for a valid vector source', () => {
|
|
25
|
+
expect(isTileJSONSpecification({ ...validVectorSpec })).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should throw an error if not object', () => {
|
|
29
|
+
expect(() => isTileJSONSpecification(null)).toThrow('spec must be an object');
|
|
30
|
+
expect(() => isTileJSONSpecification(1)).toThrow('spec must be an object');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should throw an error if the tiles property is missing', () => {
|
|
34
|
+
expect(() => isTileJSONSpecification({ ...validRasterSpec, tiles: undefined })).toThrow('spec.tiles must be an array of strings');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should throw an error if the bounds property is invalid', () => {
|
|
38
|
+
[
|
|
39
|
+
{ bounds: [-181, -90, 180, 90], errorMessage: 'spec.bounds[0] must be between -180 and 180' },
|
|
40
|
+
{ bounds: [-180, -91, 180, 90], errorMessage: 'spec.bounds[1] must be between -90 and 90' },
|
|
41
|
+
{ bounds: [-180, -90, 181, 90], errorMessage: 'spec.bounds[2] must be between -180 and 180' },
|
|
42
|
+
{ bounds: [-180, -90, 180, 91], errorMessage: 'spec.bounds[3] must be between -90 and 90' },
|
|
43
|
+
{ bounds: [180, -90, -180, 90], errorMessage: 'spec.bounds[0] must be smaller than spec.bounds[2]' },
|
|
44
|
+
{ bounds: [-180, 90, 180, -90], errorMessage: 'spec.bounds[1] must be smaller than spec.bounds[3]' },
|
|
45
|
+
].forEach(({ bounds, errorMessage }) => {
|
|
46
|
+
expect(() => isTileJSONSpecification({ ...validVectorSpec, bounds })).toThrow(errorMessage);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should throw an error if the center property is invalid', () => {
|
|
51
|
+
[
|
|
52
|
+
{ center: [-181, 0], errorMessage: 'spec.center[0] must be between -180 and 180' },
|
|
53
|
+
{ center: [181, 0], errorMessage: 'spec.center[0] must be between -180 and 180' },
|
|
54
|
+
{ center: [0, -91], errorMessage: 'spec.center[1] must be between -90 and 90' },
|
|
55
|
+
{ center: [0, 91], errorMessage: 'spec.center[1] must be between -90 and 90' },
|
|
56
|
+
].forEach(({ center, errorMessage }) => {
|
|
57
|
+
expect(() => isTileJSONSpecification({ ...validVectorSpec, center })).toThrow(errorMessage);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('check every property', () => {
|
|
62
|
+
[
|
|
63
|
+
['tiles', 'an array of strings', ['url'], 'url', [], [1], 1],
|
|
64
|
+
['attribution', 'a string if present', 'valid', 1],
|
|
65
|
+
['bounds', 'an array of four numbers if present', [1, 2, 3, 4], ['1', '2', '3', '4'], [1, 2, 3], [], 'invalid'],
|
|
66
|
+
['center', 'an array of two numbers if present', [1, 2], ['1', '2'], [1, 2, 3], [], 'invalid'],
|
|
67
|
+
['data', 'an array of strings if present', ['url'], 'url', [1], 1],
|
|
68
|
+
['description', 'a string if present', 'valid', 1],
|
|
69
|
+
['fillzoom', 'a positive integer if present', 5, 'invalid', -1],
|
|
70
|
+
['grids', 'an array of strings if present', ['1', '2', '3', '4'], [1, 2, 3, 4], 'invalid'],
|
|
71
|
+
['legend', 'a string if present', 'valid', 1],
|
|
72
|
+
['maxzoom', 'a positive integer if present', 5, 'invalid', -1],
|
|
73
|
+
['minzoom', 'a positive integer if present', 5, 'invalid', -1],
|
|
74
|
+
['name', 'a string if present', 'valid', 1],
|
|
75
|
+
['scheme', '"tms" or "xyz" if present', 'xyz', 'invalid', 1],
|
|
76
|
+
['template', 'a string if present', 'valid', 1],
|
|
77
|
+
].forEach(test => {
|
|
78
|
+
const key = test[0] as string;
|
|
79
|
+
const errorMessage = test[1] as string;
|
|
80
|
+
const values = test.slice(2) as unknown[];
|
|
81
|
+
it(key, () => {
|
|
82
|
+
for (let i = 0; i < values.length; i++) {
|
|
83
|
+
const value = values[i];
|
|
84
|
+
if (i === 0) {
|
|
85
|
+
expect(isTileJSONSpecification({ ...validVectorSpec, [key]: value })).toBe(true);
|
|
86
|
+
} else {
|
|
87
|
+
expect(() => isTileJSONSpecification({ ...validVectorSpec, [key]: value }))
|
|
88
|
+
.toThrow(`spec.${key} must be ${errorMessage}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|