@versatiles/style 3.6.1 → 3.8.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/README.MD +6 -6
- package/dist/index.test.js +3 -3
- package/dist/lib/shortbread/template.js +1 -0
- package/dist/lib/style_builder.js +6 -6
- package/dist/lib/style_guesser.d.ts +1 -1
- package/dist/lib/style_guesser.js +48 -22
- package/dist/lib/style_guesser.test.js +71 -4
- package/dist/lib/types.d.ts +57 -4
- package/dist/lib/types.js +9 -1
- package/dist/style/colorful.d.ts +41 -0
- package/dist/style/colorful.js +41 -0
- package/dist/style/neutrino.d.ts +12 -0
- package/dist/style/neutrino.js +12 -0
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -125,7 +125,7 @@ interface {
|
|
|
125
125
|
|
|
126
126
|
### Method: `colorful(options)`
|
|
127
127
|
|
|
128
|
-
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/
|
|
128
|
+
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/326466c/src/index.ts#L4">\[src]</a></sup>
|
|
129
129
|
|
|
130
130
|
**Parameters:**
|
|
131
131
|
|
|
@@ -135,7 +135,7 @@ interface {
|
|
|
135
135
|
|
|
136
136
|
### Method: `graybeard(options)`
|
|
137
137
|
|
|
138
|
-
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/
|
|
138
|
+
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/326466c/src/index.ts#L9">\[src]</a></sup>
|
|
139
139
|
|
|
140
140
|
**Parameters:**
|
|
141
141
|
|
|
@@ -143,19 +143,19 @@ interface {
|
|
|
143
143
|
|
|
144
144
|
**Returns:** <code>MaplibreStyle</code>
|
|
145
145
|
|
|
146
|
-
### Method: `guessStyle(
|
|
146
|
+
### Method: `guessStyle(opt)`
|
|
147
147
|
|
|
148
|
-
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/
|
|
148
|
+
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/326466c/src/lib/style_guesser.ts#L12">\[src]</a></sup>
|
|
149
149
|
|
|
150
150
|
**Parameters:**
|
|
151
151
|
|
|
152
|
-
* <code>
|
|
152
|
+
* <code>opt: TileJSONOption</code>
|
|
153
153
|
|
|
154
154
|
**Returns:** <code>MaplibreStyle</code>
|
|
155
155
|
|
|
156
156
|
### Method: `neutrino(options)`
|
|
157
157
|
|
|
158
|
-
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/
|
|
158
|
+
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/326466c/src/index.ts#L14">\[src]</a></sup>
|
|
159
159
|
|
|
160
160
|
**Parameters:**
|
|
161
161
|
|
package/dist/index.test.js
CHANGED
|
@@ -36,7 +36,7 @@ describe('Colorful', () => {
|
|
|
36
36
|
});
|
|
37
37
|
describe('guessStyle', () => {
|
|
38
38
|
const tiles = ['https://fancy.map/tiles/{z}/{x}/{y}'];
|
|
39
|
-
const
|
|
39
|
+
const vectorLayers = [{ id: 'hallo', fields: { label: 'String' } }];
|
|
40
40
|
it('should build raster styles', () => {
|
|
41
41
|
const style = builders.guessStyle({
|
|
42
42
|
tiles,
|
|
@@ -52,7 +52,7 @@ describe('guessStyle', () => {
|
|
|
52
52
|
const style = builders.guessStyle({
|
|
53
53
|
tiles,
|
|
54
54
|
format: 'pbf',
|
|
55
|
-
|
|
55
|
+
vectorLayers,
|
|
56
56
|
});
|
|
57
57
|
expect(style).toStrictEqual({
|
|
58
58
|
layers: [
|
|
@@ -61,7 +61,7 @@ describe('guessStyle', () => {
|
|
|
61
61
|
{ id: 'vectorSource-hallo-line', filter: ['==', '$type', 'LineString'], layout: { 'line-cap': 'round', 'line-join': 'round' }, paint: { 'line-color': 'hsla(14,50%,52%,0.6)' }, source: 'vectorSource', 'source-layer': 'hallo', type: 'line' },
|
|
62
62
|
{ id: 'vectorSource-hallo-circle', filter: ['==', '$type', 'Point'], paint: { 'circle-color': 'hsla(14,50%,52%,0.6)', 'circle-radius': 2 }, source: 'vectorSource', 'source-layer': 'hallo', type: 'circle' },
|
|
63
63
|
],
|
|
64
|
-
sources: { vectorSource: { format: 'pbf', tilejson: '3.0.0', tiles, type: 'vector', vector_layers } },
|
|
64
|
+
sources: { vectorSource: { format: 'pbf', tilejson: '3.0.0', tiles, type: 'vector', vector_layers: vectorLayers } },
|
|
65
65
|
'version': 8,
|
|
66
66
|
});
|
|
67
67
|
});
|
|
@@ -12,6 +12,7 @@ export default function getTemplate() {
|
|
|
12
12
|
sprite: 'https://tiles.versatiles.org/sprites/sprites',
|
|
13
13
|
sources: {
|
|
14
14
|
'versatiles-shortbread': {
|
|
15
|
+
tilejson: '3.0.0',
|
|
15
16
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
16
17
|
tiles: [
|
|
17
18
|
'https://tiles.versatiles.org/tiles/osm/{z}/{x}/{y}',
|
|
@@ -11,9 +11,9 @@ export default class StyleBuilder {
|
|
|
11
11
|
options ??= {};
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
13
13
|
const baseUrl = options.baseUrl ?? globalThis?.document?.location?.href ?? 'https://tiles.versatiles.org';
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const glyphs = options.glyphs ?? '/assets/fonts/{fontstack}/{range}.pbf';
|
|
15
|
+
const sprite = options.sprite ?? '/assets/sprites/sprites';
|
|
16
|
+
const tiles = options.tiles ?? ['/tiles/osm/{z}/{x}/{y}'];
|
|
17
17
|
const hideLabels = options.hideLabels ?? false;
|
|
18
18
|
const languageSuffix = options.languageSuffix ?? '';
|
|
19
19
|
const recolorOptions = options.recolor ?? getDefaultRecolorFlags();
|
|
@@ -64,11 +64,11 @@ export default class StyleBuilder {
|
|
|
64
64
|
layers = layers.filter(l => l.type !== 'symbol');
|
|
65
65
|
style.layers = layers;
|
|
66
66
|
style.name = 'versatiles-' + this.name.toLowerCase();
|
|
67
|
-
style.glyphs = resolveUrl(baseUrl,
|
|
68
|
-
style.sprite = resolveUrl(baseUrl,
|
|
67
|
+
style.glyphs = resolveUrl(baseUrl, glyphs);
|
|
68
|
+
style.sprite = resolveUrl(baseUrl, sprite);
|
|
69
69
|
const source = style.sources[this.#sourceName];
|
|
70
70
|
if ('tiles' in source)
|
|
71
|
-
source.tiles =
|
|
71
|
+
source.tiles = tiles.map(url => resolveUrl(baseUrl, url));
|
|
72
72
|
return style;
|
|
73
73
|
function resolveUrl(base, url) {
|
|
74
74
|
if (!Boolean(base))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { MaplibreStyle, TileJSONOption } from './types.js';
|
|
2
|
-
export default function guess(
|
|
2
|
+
export default function guess(opt: TileJSONOption): MaplibreStyle;
|
|
@@ -3,48 +3,71 @@
|
|
|
3
3
|
import { isTileJSONSpecification } from './types.js';
|
|
4
4
|
import randomColorGenerator from './random_color.js';
|
|
5
5
|
import Colorful from '../style/colorful.js';
|
|
6
|
-
export default function guess(
|
|
6
|
+
export default function guess(opt) {
|
|
7
|
+
const { format } = opt;
|
|
8
|
+
const tilejsonBasic = {
|
|
9
|
+
tilejson: opt.tilejson ?? '3.0.0',
|
|
10
|
+
attribution: opt.attribution,
|
|
11
|
+
tiles: opt.tiles,
|
|
12
|
+
scheme: opt.scheme,
|
|
13
|
+
bounds: opt.bounds,
|
|
14
|
+
center: opt.center,
|
|
15
|
+
description: opt.description,
|
|
16
|
+
fillzoom: opt.fillzoom,
|
|
17
|
+
grids: opt.grids,
|
|
18
|
+
legend: opt.legend,
|
|
19
|
+
minzoom: opt.minzoom,
|
|
20
|
+
maxzoom: opt.maxzoom,
|
|
21
|
+
name: opt.name,
|
|
22
|
+
template: opt.template,
|
|
23
|
+
};
|
|
24
|
+
let k;
|
|
25
|
+
for (k in tilejsonBasic) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
27
|
+
if (tilejsonBasic[k] === undefined)
|
|
28
|
+
delete tilejsonBasic[k];
|
|
29
|
+
}
|
|
7
30
|
let tilejson;
|
|
8
|
-
const { format } = spec;
|
|
9
31
|
switch (format) {
|
|
10
32
|
case 'avif':
|
|
11
33
|
case 'jpg':
|
|
12
34
|
case 'png':
|
|
13
35
|
case 'webp':
|
|
14
|
-
tilejson = {
|
|
15
|
-
tilejson: '3.0.0',
|
|
16
|
-
type: 'raster',
|
|
17
|
-
...spec,
|
|
18
|
-
format,
|
|
19
|
-
};
|
|
36
|
+
tilejson = { ...tilejsonBasic, type: 'raster', format };
|
|
20
37
|
break;
|
|
21
38
|
case 'pbf':
|
|
22
|
-
const {
|
|
23
|
-
if (
|
|
39
|
+
const { vectorLayers } = opt;
|
|
40
|
+
if (vectorLayers == null) {
|
|
24
41
|
throw Error('property vector_layers is required for vector tiles');
|
|
25
42
|
}
|
|
26
|
-
tilejson = {
|
|
27
|
-
tilejson: '3.0.0',
|
|
28
|
-
type: 'vector',
|
|
29
|
-
...spec,
|
|
30
|
-
format,
|
|
31
|
-
vector_layers,
|
|
32
|
-
};
|
|
43
|
+
tilejson = { ...tilejsonBasic, type: 'vector', format, vector_layers: vectorLayers };
|
|
33
44
|
break;
|
|
34
45
|
}
|
|
35
46
|
if (!isTileJSONSpecification(tilejson))
|
|
36
47
|
throw Error();
|
|
48
|
+
let style;
|
|
37
49
|
switch (tilejson.type) {
|
|
38
50
|
case 'raster':
|
|
39
|
-
|
|
51
|
+
style = getImageStyle(tilejson);
|
|
52
|
+
break;
|
|
40
53
|
case 'vector':
|
|
41
54
|
if (isShortbread(tilejson)) {
|
|
42
|
-
|
|
55
|
+
style = getShortbreadStyle(tilejson, { baseUrl: opt.baseUrl, glyphs: opt.glyphs, sprite: opt.sprite });
|
|
43
56
|
}
|
|
44
57
|
else {
|
|
45
|
-
|
|
58
|
+
style = getInspectorStyle(tilejson);
|
|
46
59
|
}
|
|
47
60
|
}
|
|
61
|
+
if (opt.minzoom ?? 0)
|
|
62
|
+
style.zoom ??= opt.minzoom;
|
|
63
|
+
if (opt.bounds)
|
|
64
|
+
style.center ??= [
|
|
65
|
+
(opt.bounds[0] + opt.bounds[2]) / 2,
|
|
66
|
+
(opt.bounds[1] + opt.bounds[3]) / 2,
|
|
67
|
+
];
|
|
68
|
+
if (opt.center)
|
|
69
|
+
style.center = opt.center;
|
|
70
|
+
return style;
|
|
48
71
|
}
|
|
49
72
|
function isShortbread(spec) {
|
|
50
73
|
if (typeof spec !== 'object')
|
|
@@ -57,10 +80,13 @@ function isShortbread(spec) {
|
|
|
57
80
|
const shortbreadIds = ['place_labels', 'boundaries', 'boundary_labels', 'addresses', 'water_lines', 'water_lines_labels', 'dam_lines', 'dam_polygons', 'pier_lines', 'pier_polygons', 'bridges', 'street_polygons', 'streets_polygons_labels', 'ferries', 'streets', 'street_labels', 'street_labels_points', 'aerialways', 'public_transport', 'buildings', 'water_polygons', 'ocean', 'water_polygons_labels', 'land', 'sites', 'pois'];
|
|
58
81
|
return shortbreadIds.every(id => layerIds.has(id));
|
|
59
82
|
}
|
|
60
|
-
function getShortbreadStyle(spec) {
|
|
83
|
+
function getShortbreadStyle(spec, builderOption) {
|
|
61
84
|
return new Colorful().build({
|
|
62
85
|
hideLabels: true,
|
|
63
|
-
|
|
86
|
+
tiles: spec.tiles,
|
|
87
|
+
baseUrl: builderOption.baseUrl,
|
|
88
|
+
glyphs: builderOption.glyphs,
|
|
89
|
+
sprite: builderOption.sprite,
|
|
64
90
|
});
|
|
65
91
|
}
|
|
66
92
|
function getInspectorStyle(spec) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import getTemplate from './shortbread/template.js';
|
|
2
3
|
import guessStyle from './style_guesser.js';
|
|
3
4
|
describe('guessStyle', () => {
|
|
4
5
|
const tiles = ['https://example.com/tiles/{z}/{x}/{y}'];
|
|
6
|
+
const vectorLayersSomething = [{ id: 'geometry', fields: { label: 'String', height: 'Number' } }];
|
|
7
|
+
const vectorLayersShortbread = getTemplate().sources['versatiles-shortbread'].vector_layers;
|
|
5
8
|
it('should build raster styles', () => {
|
|
6
9
|
const type = 'raster';
|
|
7
10
|
const format = 'avif';
|
|
@@ -12,14 +15,13 @@ describe('guessStyle', () => {
|
|
|
12
15
|
layers: [{ id: 'raster', source: 'rasterSource', type }],
|
|
13
16
|
});
|
|
14
17
|
});
|
|
15
|
-
it('should build vector styles', () => {
|
|
18
|
+
it('should build vector inspector styles', () => {
|
|
16
19
|
const type = 'vector';
|
|
17
20
|
const format = 'pbf';
|
|
18
|
-
|
|
19
|
-
expect(guessStyle({ tiles, format, vector_layers }))
|
|
21
|
+
expect(guessStyle({ tiles, format, vectorLayers: vectorLayersSomething }))
|
|
20
22
|
.toStrictEqual({
|
|
21
23
|
version: 8,
|
|
22
|
-
sources: { vectorSource: { format, tilejson: '3.0.0', tiles, type, vector_layers } },
|
|
24
|
+
sources: { vectorSource: { format, tilejson: '3.0.0', tiles, type, vector_layers: vectorLayersSomething } },
|
|
23
25
|
layers: [
|
|
24
26
|
{
|
|
25
27
|
id: 'background',
|
|
@@ -54,4 +56,69 @@ describe('guessStyle', () => {
|
|
|
54
56
|
],
|
|
55
57
|
});
|
|
56
58
|
});
|
|
59
|
+
it('should build shortbread vector styles', () => {
|
|
60
|
+
const type = 'vector';
|
|
61
|
+
const format = 'pbf';
|
|
62
|
+
const style = guessStyle({ tiles, format, vectorLayers: vectorLayersShortbread, baseUrl: 'http://example.com' });
|
|
63
|
+
expect(style.layers.length).toBe(236);
|
|
64
|
+
style.layers = [];
|
|
65
|
+
expect(style).toStrictEqual({
|
|
66
|
+
glyphs: 'http://example.com/assets/fonts/{fontstack}/{range}.pbf',
|
|
67
|
+
metadata: {
|
|
68
|
+
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
69
|
+
'maputnik:renderer': 'mbgljs',
|
|
70
|
+
},
|
|
71
|
+
name: 'versatiles-colorful',
|
|
72
|
+
sprite: 'http://example.com/assets/sprites/sprites',
|
|
73
|
+
layers: [],
|
|
74
|
+
sources: {
|
|
75
|
+
'versatiles-shortbread': {
|
|
76
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
77
|
+
bounds: [-180, -85.0511287798066, 180, 85.0511287798066],
|
|
78
|
+
format,
|
|
79
|
+
maxzoom: 14,
|
|
80
|
+
minzoom: 0,
|
|
81
|
+
scheme: 'xyz',
|
|
82
|
+
tilejson: '3.0.0',
|
|
83
|
+
tiles,
|
|
84
|
+
type,
|
|
85
|
+
vector_layers: vectorLayersShortbread,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
version: 8,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
const cases = [
|
|
92
|
+
{ type: 'image', options: { tiles, format: 'png' } },
|
|
93
|
+
{ type: 'inspector', options: { tiles, format: 'pbf', vectorLayers: vectorLayersSomething } },
|
|
94
|
+
{ type: 'shortbread', options: { tiles, format: 'pbf', vectorLayers: vectorLayersShortbread } },
|
|
95
|
+
];
|
|
96
|
+
describe('minzoom sets zoom', () => {
|
|
97
|
+
cases.forEach(({ type, options }) => {
|
|
98
|
+
it(type, () => {
|
|
99
|
+
expect(guessStyle({ ...options, minzoom: 5 })).toHaveProperty('zoom', 5);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe('bounds sets center', () => {
|
|
104
|
+
cases.forEach(({ type, options }) => {
|
|
105
|
+
it(type, () => {
|
|
106
|
+
expect(guessStyle({ ...options, bounds: [1, 2, 3, 4] })).toHaveProperty('center', [2, 3]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe('center sets center', () => {
|
|
111
|
+
cases.forEach(({ type, options }) => {
|
|
112
|
+
it(type, () => {
|
|
113
|
+
expect(guessStyle({ ...options, center: [12, 34] })).toHaveProperty('center', [12, 34]);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe('center overrides bounds', () => {
|
|
118
|
+
cases.forEach(({ type, options }) => {
|
|
119
|
+
it(type, () => {
|
|
120
|
+
expect(guessStyle({ ...options, bounds: [1, 2, 3, 4], center: [12, 34] })).toHaveProperty('center', [12, 34]);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
57
124
|
});
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { BackgroundLayerSpecification, FillLayerSpecification, FilterSpecification, LineLayerSpecification, StyleSpecification, SymbolLayerSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
2
|
import type Color from 'color';
|
|
3
3
|
import type StyleBuilder from './style_builder.ts';
|
|
4
|
+
/** Represents the available tile formats. */
|
|
4
5
|
export type TileFormat = 'avif' | 'bin' | 'geojson' | 'jpg' | 'json' | 'pbf' | 'png' | 'svg' | 'topojson' | 'webp';
|
|
6
|
+
/** Type for Maplibre layers, including background, fill, line, and symbol specifications. */
|
|
5
7
|
export type MaplibreLayer = BackgroundLayerSpecification | FillLayerSpecification | LineLayerSpecification | SymbolLayerSpecification;
|
|
8
|
+
/** Defines the structure of Maplibre layer definitions, omitting the 'source' property for fill, line, and symbol specifications. */
|
|
6
9
|
export type MaplibreLayerDefinition = BackgroundLayerSpecification | Omit<FillLayerSpecification, 'source'> | Omit<LineLayerSpecification, 'source'> | Omit<SymbolLayerSpecification, 'source'>;
|
|
10
|
+
/** Represents a filter specification in Maplibre styles. */
|
|
7
11
|
export type MaplibreFilter = FilterSpecification;
|
|
12
|
+
/** Represents the structure of a vector layer in a TileJSON specification. */
|
|
8
13
|
export interface VectorLayer {
|
|
9
14
|
id: string;
|
|
10
15
|
fields: Record<string, 'Boolean' | 'Number' | 'String'>;
|
|
@@ -12,6 +17,7 @@ export interface VectorLayer {
|
|
|
12
17
|
minzoom?: number;
|
|
13
18
|
maxzoom?: number;
|
|
14
19
|
}
|
|
20
|
+
/** Basic structure for TileJSON specification, applicable to both raster and vector types. */
|
|
15
21
|
export interface TileJSONSpecificationBasic {
|
|
16
22
|
tilejson?: '3.0.0';
|
|
17
23
|
attribution?: string;
|
|
@@ -28,65 +34,112 @@ export interface TileJSONSpecificationBasic {
|
|
|
28
34
|
name?: string;
|
|
29
35
|
template?: string;
|
|
30
36
|
}
|
|
37
|
+
/** Structure for TileJSON specification of raster type, specifying raster-specific properties. */
|
|
31
38
|
export interface TileJSONSpecificationRaster extends TileJSONSpecificationBasic {
|
|
32
39
|
type: 'raster';
|
|
33
40
|
format: 'avif' | 'jpg' | 'png' | 'webp';
|
|
34
41
|
}
|
|
42
|
+
/** Structure for TileJSON specification of vector type, specifying vector-specific properties. */
|
|
35
43
|
export interface TileJSONSpecificationVector extends TileJSONSpecificationBasic {
|
|
36
44
|
type: 'vector';
|
|
37
45
|
format: 'pbf';
|
|
38
46
|
vector_layers: VectorLayer[];
|
|
39
47
|
}
|
|
48
|
+
/** Represents a TileJSON specification, which can be either raster or vector. */
|
|
40
49
|
export type TileJSONSpecification = TileJSONSpecificationRaster | TileJSONSpecificationVector;
|
|
50
|
+
/** Options for creating TileJSON, extending the basic specification with format and optional vector layers. */
|
|
41
51
|
export interface TileJSONOption extends TileJSONSpecificationBasic {
|
|
42
52
|
format: 'avif' | 'jpg' | 'pbf' | 'png' | 'webp';
|
|
43
|
-
|
|
53
|
+
vectorLayers?: VectorLayer[];
|
|
54
|
+
baseUrl?: string;
|
|
55
|
+
glyphs?: string;
|
|
56
|
+
sprite?: string;
|
|
44
57
|
}
|
|
58
|
+
/** Type for Maplibre styles specifically designed for raster sources. */
|
|
45
59
|
export type MaplibreStyleRaster = Omit<StyleSpecification, 'sources'> & {
|
|
46
60
|
'sources': {
|
|
47
61
|
[_: string]: TileJSONSpecificationRaster;
|
|
48
62
|
};
|
|
49
63
|
};
|
|
64
|
+
/** Type for Maplibre styles specifically designed for vector sources. */
|
|
50
65
|
export type MaplibreStyleVector = Omit<StyleSpecification, 'sources'> & {
|
|
51
66
|
'sources': {
|
|
52
67
|
[_: string]: TileJSONSpecificationVector;
|
|
53
68
|
};
|
|
54
69
|
};
|
|
70
|
+
/** Represents a Maplibre style, which can be either raster or vector. */
|
|
55
71
|
export type MaplibreStyle = MaplibreStyleRaster | MaplibreStyleVector;
|
|
72
|
+
/** Defines the value type for a style rule. */
|
|
56
73
|
export type StyleRuleValue = boolean | number | object | string;
|
|
74
|
+
/** Defines the structure of a style rule, which is a record of properties to style values. */
|
|
57
75
|
export type StyleRule = Record<string, StyleRuleValue | undefined>;
|
|
76
|
+
/** Defines the structure of style rules, which is a record of selectors to style rules. */
|
|
58
77
|
export type StyleRules = Record<string, StyleRule | undefined>;
|
|
78
|
+
/** Represents language suffixes used in map styles. */
|
|
59
79
|
export type LanguageSuffix = '_de' | '_en' | '';
|
|
80
|
+
/** Defines the keys for color properties in a style builder. */
|
|
60
81
|
export type StylemakerColorKeys<T extends StyleBuilder<T>> = keyof T['defaultColors'];
|
|
82
|
+
/** Defines the keys for font properties in a style builder. */
|
|
61
83
|
export type StylemakerFontKeys<T extends StyleBuilder<T>> = keyof T['defaultFonts'];
|
|
84
|
+
/** Records string values for color properties in a style builder. */
|
|
62
85
|
export type StylemakerColorStrings<T extends StyleBuilder<T>> = Record<StylemakerColorKeys<T>, string>;
|
|
86
|
+
/** Records string values for font properties in a style builder. */
|
|
63
87
|
export type StylemakerFontStrings<T extends StyleBuilder<T>> = Record<StylemakerFontKeys<T>, string>;
|
|
88
|
+
/** Records Color objects for color properties in a style builder. */
|
|
64
89
|
export type StylemakerColors<T extends StyleBuilder<T>> = Record<StylemakerColorKeys<T>, Color>;
|
|
90
|
+
/** Records string values for font properties in a style builder. */
|
|
65
91
|
export type StylemakerFonts<T extends StyleBuilder<T>> = Record<StylemakerFontKeys<T>, string>;
|
|
92
|
+
/** Defines options for style rules in a style builder. */
|
|
66
93
|
export interface StyleRulesOptions<T extends StyleBuilder<T>> {
|
|
67
94
|
colors: StylemakerColors<T>;
|
|
68
95
|
fonts: StylemakerFontStrings<T>;
|
|
69
96
|
languageSuffix: string;
|
|
70
97
|
}
|
|
71
98
|
export interface RecolorOptions {
|
|
99
|
+
/** If true, inverts the colors. */
|
|
72
100
|
invert?: boolean;
|
|
101
|
+
/** The degree to rotate the hue of the color (in degrees). */
|
|
73
102
|
rotate?: number;
|
|
103
|
+
/** Adjusts the saturation level of the color. Positive values increase saturation, negative values decrease it. */
|
|
74
104
|
saturate?: number;
|
|
105
|
+
/** Adjusts the gamma of the color. Affects the brightness in a non-linear manner. */
|
|
75
106
|
gamma?: number;
|
|
107
|
+
/** Adjusts the contrast of the color. Higher values produce more contrast. */
|
|
76
108
|
contrast?: number;
|
|
109
|
+
/** Adjusts the brightness of the color. Positive values make it brighter, negative values make it darker. */
|
|
77
110
|
brightness?: number;
|
|
111
|
+
/** Specifies the intensity of the tinting effect. Ranges from 0 (no effect) to 1 (full effect). */
|
|
78
112
|
tint?: number;
|
|
113
|
+
/** Specifies the color used for tinting, in a string format (e.g., '#FF0000'). */
|
|
79
114
|
tintColor?: string;
|
|
80
115
|
}
|
|
81
116
|
export interface StylemakerOptions<T extends StyleBuilder<T>> {
|
|
117
|
+
/** The base URL for loading external resources like tiles, sprites, and fonts. */
|
|
82
118
|
baseUrl?: string;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
119
|
+
/** The URL template for loading font glyphs, formatted with `{fontstack}` and `{range}` placeholders. */
|
|
120
|
+
glyphs?: string;
|
|
121
|
+
/** The URL for loading sprite images and metadata. */
|
|
122
|
+
sprite?: string;
|
|
123
|
+
/** An array of URL templates for loading map tiles, with `{z}`, `{x}`, and `{y}` placeholders. */
|
|
124
|
+
tiles?: string[];
|
|
125
|
+
/** If true, hides all map labels. */
|
|
86
126
|
hideLabels?: boolean;
|
|
127
|
+
/** Suffix to append to language-specific resources, such as `"-en"` for English. */
|
|
87
128
|
languageSuffix?: LanguageSuffix;
|
|
129
|
+
/** An object specifying overrides for default color values, keyed by the color names. */
|
|
88
130
|
colors?: Partial<StylemakerColorStrings<T>>;
|
|
131
|
+
/** An object specifying overrides for default font names, keyed by the font names. */
|
|
89
132
|
fonts?: Partial<StylemakerFontStrings<T>>;
|
|
133
|
+
/** Options for color adjustments and transformations applied to the entire style. */
|
|
90
134
|
recolor?: RecolorOptions;
|
|
91
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Checks if an object adheres to the TileJSON specification.
|
|
138
|
+
* Throws errors if the object does not conform to the expected structure or types.
|
|
139
|
+
*/
|
|
92
140
|
export declare function isTileJSONSpecification(obj: unknown): obj is TileJSONSpecification;
|
|
141
|
+
/**
|
|
142
|
+
* Validates if an object conforms to the VectorLayer structure.
|
|
143
|
+
* Throws errors for any deviations from the expected structure or types.
|
|
144
|
+
*/
|
|
145
|
+
export declare function validateVectorLayer(obj: unknown): boolean;
|
package/dist/lib/types.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
2
|
+
/**
|
|
3
|
+
* Checks if an object adheres to the TileJSON specification.
|
|
4
|
+
* Throws errors if the object does not conform to the expected structure or types.
|
|
5
|
+
*/
|
|
2
6
|
export function isTileJSONSpecification(obj) {
|
|
3
7
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
8
|
throw Error('spec must be an object');
|
|
@@ -65,7 +69,11 @@ export function isTileJSONSpecification(obj) {
|
|
|
65
69
|
}
|
|
66
70
|
return true;
|
|
67
71
|
}
|
|
68
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Validates if an object conforms to the VectorLayer structure.
|
|
74
|
+
* Throws errors for any deviations from the expected structure or types.
|
|
75
|
+
*/
|
|
76
|
+
export function validateVectorLayer(obj) {
|
|
69
77
|
if (typeof obj !== 'object' || obj === null) {
|
|
70
78
|
throw Error('layer must be an object');
|
|
71
79
|
}
|
package/dist/style/colorful.d.ts
CHANGED
|
@@ -7,46 +7,87 @@ export default class Colorful extends StyleBuilder<Colorful> {
|
|
|
7
7
|
bold: string;
|
|
8
8
|
};
|
|
9
9
|
defaultColors: {
|
|
10
|
+
/** Color for land areas on the map. */
|
|
10
11
|
land: string;
|
|
12
|
+
/** Color for water bodies like lakes and rivers. */
|
|
11
13
|
water: string;
|
|
14
|
+
/** Color for glacier areas, usually shown as white. */
|
|
12
15
|
glacier: string;
|
|
16
|
+
/** Color for wooded or forested areas. */
|
|
13
17
|
wood: string;
|
|
18
|
+
/** Color for grasslands or open fields. */
|
|
14
19
|
grass: string;
|
|
20
|
+
/** Color for parks and recreational areas. */
|
|
15
21
|
park: string;
|
|
22
|
+
/** Color for streets and roads on the map. */
|
|
16
23
|
street: string;
|
|
24
|
+
/** Background color for streets. */
|
|
17
25
|
streetbg: string;
|
|
26
|
+
/** Color for major highways or motorways. */
|
|
18
27
|
motorway: string;
|
|
28
|
+
/** Background color for motorways. */
|
|
19
29
|
motorwaybg: string;
|
|
30
|
+
/** Color for trunk roads. */
|
|
20
31
|
trunk: string;
|
|
32
|
+
/** Background color for trunk roads. */
|
|
21
33
|
trunkbg: string;
|
|
34
|
+
/** Background color for buildings. */
|
|
22
35
|
buildingbg: string;
|
|
36
|
+
/** Primary color for buildings. */
|
|
23
37
|
building: string;
|
|
38
|
+
/** Color used for boundaries. */
|
|
24
39
|
boundary: string;
|
|
40
|
+
/** Color used for disputed boundaries. */
|
|
25
41
|
disputed: string;
|
|
42
|
+
/** Color used for residential areas. */
|
|
26
43
|
residential: string;
|
|
44
|
+
/** Color used for commercial areas. */
|
|
27
45
|
commercial: string;
|
|
46
|
+
/** Color used for industrial areas. */
|
|
28
47
|
industrial: string;
|
|
48
|
+
/** Color used for footpaths and pedestrian areas. */
|
|
29
49
|
foot: string;
|
|
50
|
+
/** Primary color used for labels. */
|
|
30
51
|
label: string;
|
|
52
|
+
/** Color used for label halos. */
|
|
31
53
|
labelHalo: string;
|
|
54
|
+
/** Color used for shields on maps. */
|
|
32
55
|
shield: string;
|
|
56
|
+
/** Color used for agriculture areas. */
|
|
33
57
|
agriculture: string;
|
|
58
|
+
/** Color used for railways. */
|
|
34
59
|
rail: string;
|
|
60
|
+
/** Color used for subways and underground systems. */
|
|
35
61
|
subway: string;
|
|
62
|
+
/** Color used for cycle paths. */
|
|
36
63
|
cycle: string;
|
|
64
|
+
/** Color used for waste areas. */
|
|
37
65
|
waste: string;
|
|
66
|
+
/** Color used for burial and cemetery areas. */
|
|
38
67
|
burial: string;
|
|
68
|
+
/** Color used for sand areas like beaches. */
|
|
39
69
|
sand: string;
|
|
70
|
+
/** Color used for rocky terrain. */
|
|
40
71
|
rock: string;
|
|
72
|
+
/** Color used for leisure areas like parks and gardens. */
|
|
41
73
|
leisure: string;
|
|
74
|
+
/** Color used for wetland areas like marshes. */
|
|
42
75
|
wetland: string;
|
|
76
|
+
/** Color used for various symbols on the map. */
|
|
43
77
|
symbol: string;
|
|
78
|
+
/** Color indicating danger or warning areas. */
|
|
44
79
|
danger: string;
|
|
80
|
+
/** Color used for prison areas. */
|
|
45
81
|
prison: string;
|
|
82
|
+
/** Color used for parking areas. */
|
|
46
83
|
parking: string;
|
|
84
|
+
/** Color used for construction sites. */
|
|
47
85
|
construction: string;
|
|
86
|
+
/** Color used for educational facilities. */
|
|
48
87
|
education: string;
|
|
88
|
+
/** Color used for hospitals and medical facilities. */
|
|
49
89
|
hospital: string;
|
|
90
|
+
/** Color used for points of interest. */
|
|
50
91
|
poi: string;
|
|
51
92
|
};
|
|
52
93
|
protected getStyleRules(options: StyleRulesOptions<Colorful>): StyleRules;
|
package/dist/style/colorful.js
CHANGED
|
@@ -7,46 +7,87 @@ export default class Colorful extends StyleBuilder {
|
|
|
7
7
|
bold: 'noto_sans_bold',
|
|
8
8
|
};
|
|
9
9
|
defaultColors = {
|
|
10
|
+
/** Color for land areas on the map. */
|
|
10
11
|
land: '#F9F4EE',
|
|
12
|
+
/** Color for water bodies like lakes and rivers. */
|
|
11
13
|
water: '#BEDDF3',
|
|
14
|
+
/** Color for glacier areas, usually shown as white. */
|
|
12
15
|
glacier: '#FFFFFF',
|
|
16
|
+
/** Color for wooded or forested areas. */
|
|
13
17
|
wood: '#66AA44',
|
|
18
|
+
/** Color for grasslands or open fields. */
|
|
14
19
|
grass: '#D8E8C8',
|
|
20
|
+
/** Color for parks and recreational areas. */
|
|
15
21
|
park: '#D9D9A5',
|
|
22
|
+
/** Color for streets and roads on the map. */
|
|
16
23
|
street: '#FFFFFF',
|
|
24
|
+
/** Background color for streets. */
|
|
17
25
|
streetbg: '#CFCDCA',
|
|
26
|
+
/** Color for major highways or motorways. */
|
|
18
27
|
motorway: '#FFCC88',
|
|
28
|
+
/** Background color for motorways. */
|
|
19
29
|
motorwaybg: '#E9AC77',
|
|
30
|
+
/** Color for trunk roads. */
|
|
20
31
|
trunk: '#FFEEAA',
|
|
32
|
+
/** Background color for trunk roads. */
|
|
21
33
|
trunkbg: '#E9AC77',
|
|
34
|
+
/** Background color for buildings. */
|
|
22
35
|
buildingbg: '#DFDBD7',
|
|
36
|
+
/** Primary color for buildings. */
|
|
23
37
|
building: '#F2EAE2',
|
|
38
|
+
/** Color used for boundaries. */
|
|
24
39
|
boundary: '#A6A6C8',
|
|
40
|
+
/** Color used for disputed boundaries. */
|
|
25
41
|
disputed: '#BEBCCF',
|
|
42
|
+
/** Color used for residential areas. */
|
|
26
43
|
residential: '#EAE6E133',
|
|
44
|
+
/** Color used for commercial areas. */
|
|
27
45
|
commercial: '#F7DEED40',
|
|
46
|
+
/** Color used for industrial areas. */
|
|
28
47
|
industrial: '#FFF4C255',
|
|
48
|
+
/** Color used for footpaths and pedestrian areas. */
|
|
29
49
|
foot: '#FBEBFF',
|
|
50
|
+
/** Primary color used for labels. */
|
|
30
51
|
label: '#333344',
|
|
52
|
+
/** Color used for label halos. */
|
|
31
53
|
labelHalo: '#FFFFFFCC',
|
|
54
|
+
/** Color used for shields on maps. */
|
|
32
55
|
shield: '#FFFFFF',
|
|
56
|
+
/** Color used for agriculture areas. */
|
|
33
57
|
agriculture: '#F0E7D1',
|
|
58
|
+
/** Color used for railways. */
|
|
34
59
|
rail: '#B1BBC4',
|
|
60
|
+
/** Color used for subways and underground systems. */
|
|
35
61
|
subway: '#A6B8C7',
|
|
62
|
+
/** Color used for cycle paths. */
|
|
36
63
|
cycle: '#EFF9FF',
|
|
64
|
+
/** Color used for waste areas. */
|
|
37
65
|
waste: '#DBD6BD',
|
|
66
|
+
/** Color used for burial and cemetery areas. */
|
|
38
67
|
burial: '#DDDBCA',
|
|
68
|
+
/** Color used for sand areas like beaches. */
|
|
39
69
|
sand: '#FAFAED',
|
|
70
|
+
/** Color used for rocky terrain. */
|
|
40
71
|
rock: '#E0E4E5',
|
|
72
|
+
/** Color used for leisure areas like parks and gardens. */
|
|
41
73
|
leisure: '#E7EDDE',
|
|
74
|
+
/** Color used for wetland areas like marshes. */
|
|
42
75
|
wetland: '#D3E6DB',
|
|
76
|
+
/** Color used for various symbols on the map. */
|
|
43
77
|
symbol: '#66626A',
|
|
78
|
+
/** Color indicating danger or warning areas. */
|
|
44
79
|
danger: '#FF0000',
|
|
80
|
+
/** Color used for prison areas. */
|
|
45
81
|
prison: '#FDF2FC',
|
|
82
|
+
/** Color used for parking areas. */
|
|
46
83
|
parking: '#EBE8E6',
|
|
84
|
+
/** Color used for construction sites. */
|
|
47
85
|
construction: '#A9A9A9',
|
|
86
|
+
/** Color used for educational facilities. */
|
|
48
87
|
education: '#FFFF80',
|
|
88
|
+
/** Color used for hospitals and medical facilities. */
|
|
49
89
|
hospital: '#FF6666',
|
|
90
|
+
/** Color used for points of interest. */
|
|
50
91
|
poi: '#555555',
|
|
51
92
|
};
|
|
52
93
|
getStyleRules(options) {
|
package/dist/style/neutrino.d.ts
CHANGED
|
@@ -7,17 +7,29 @@ export default class Neutrino extends StyleBuilder<Neutrino> {
|
|
|
7
7
|
bold: string;
|
|
8
8
|
};
|
|
9
9
|
defaultColors: {
|
|
10
|
+
/** Color representing land areas. */
|
|
10
11
|
land: string;
|
|
12
|
+
/** Color representing bodies of water such as lakes and rivers. */
|
|
11
13
|
water: string;
|
|
14
|
+
/** Color for grassy areas and fields. */
|
|
12
15
|
grass: string;
|
|
16
|
+
/** Color for wooded or forested areas. */
|
|
13
17
|
wood: string;
|
|
18
|
+
/** Color used for agricultural land. */
|
|
14
19
|
agriculture: string;
|
|
20
|
+
/** Color for site areas such as parks or recreational facilities. */
|
|
15
21
|
site: string;
|
|
22
|
+
/** Primary color for buildings. */
|
|
16
23
|
building: string;
|
|
24
|
+
/** Color for streets and roads. */
|
|
17
25
|
street: string;
|
|
26
|
+
/** Color used for boundaries, such as national or state lines. */
|
|
18
27
|
boundary: string;
|
|
28
|
+
/** Color for footpaths and pedestrian areas. */
|
|
19
29
|
foot: string;
|
|
30
|
+
/** Color used for railways. */
|
|
20
31
|
rail: string;
|
|
32
|
+
/** Primary color used for text labels. */
|
|
21
33
|
label: string;
|
|
22
34
|
};
|
|
23
35
|
protected getStyleRules(options: StyleRulesOptions<Neutrino>): StyleRules;
|
package/dist/style/neutrino.js
CHANGED
|
@@ -7,17 +7,29 @@ export default class Neutrino extends StyleBuilder {
|
|
|
7
7
|
bold: 'noto_sans_bold',
|
|
8
8
|
};
|
|
9
9
|
defaultColors = {
|
|
10
|
+
/** Color representing land areas. */
|
|
10
11
|
land: '#f6f0f6',
|
|
12
|
+
/** Color representing bodies of water such as lakes and rivers. */
|
|
11
13
|
water: '#cbd2df',
|
|
14
|
+
/** Color for grassy areas and fields. */
|
|
12
15
|
grass: '#e7e9e5',
|
|
16
|
+
/** Color for wooded or forested areas. */
|
|
13
17
|
wood: '#d9e3d9',
|
|
18
|
+
/** Color used for agricultural land. */
|
|
14
19
|
agriculture: '#f8eeee',
|
|
20
|
+
/** Color for site areas such as parks or recreational facilities. */
|
|
15
21
|
site: '#ebe8e6',
|
|
22
|
+
/** Primary color for buildings. */
|
|
16
23
|
building: '#e0d1d9',
|
|
24
|
+
/** Color for streets and roads. */
|
|
17
25
|
street: '#ffffff',
|
|
26
|
+
/** Color used for boundaries, such as national or state lines. */
|
|
18
27
|
boundary: '#e6ccd8',
|
|
28
|
+
/** Color for footpaths and pedestrian areas. */
|
|
19
29
|
foot: '#fef8ff',
|
|
30
|
+
/** Color used for railways. */
|
|
20
31
|
rail: '#e8d5e0',
|
|
32
|
+
/** Primary color used for text labels. */
|
|
21
33
|
label: '#cbb7b7',
|
|
22
34
|
};
|
|
23
35
|
getStyleRules(options) {
|