@versatiles/style 4.4.1 → 5.0.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 +78 -88
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/guess_style/guess_style.js +5 -5
- package/dist/guess_style/random_color.js +0 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/utils.d.ts +4 -3
- package/dist/lib/utils.js +14 -4
- package/dist/shortbread/layers.d.ts +2 -2
- package/dist/shortbread/layers.js +2 -3
- package/dist/shortbread/template.js +2 -3
- package/dist/style_builder/decorator.js +0 -1
- package/dist/style_builder/index.d.ts +1 -1
- package/dist/style_builder/recolor.d.ts +0 -8
- package/dist/style_builder/style_builder.js +14 -10
- package/dist/style_builder/types.d.ts +7 -13
- package/dist/styles/colorful.js +158 -156
- package/dist/styles/neutrino.js +3 -1
- package/package.json +24 -23
package/README.MD
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
# VersaTiles Style
|
|
7
7
|
|
|
8
|
+
> [!WARNING]
|
|
9
|
+
> We are currently migrating to the [VersaTiles Frontend Specification](https://github.com/versatiles-org/versatiles-documentation/blob/main/compendium/specification_frontend.md). While this is good for the long term, it does mean that there will be breaking changes in the short term. You can find the [old v4.4.1 release here](https://github.com/versatiles-org/versatiles-style/releases/tag/v4.4.1).
|
|
10
|
+
|
|
8
11
|
Generates styles and sprites for MapLibre.
|
|
9
12
|
|
|
10
13
|

|
|
@@ -13,6 +16,7 @@ Generates styles and sprites for MapLibre.
|
|
|
13
16
|
|
|
14
17
|
* Colorful - colorful, full featured map
|
|
15
18
|
* Graybeard - gray, full featured map
|
|
19
|
+
* Eclipse - dark, full featured map
|
|
16
20
|
* Neutrino - light basemap
|
|
17
21
|
|
|
18
22
|
# Use styles for versatiles.org
|
|
@@ -23,12 +27,14 @@ Be aware that these styles use `tiles.versatiles.org` as source for tiles, fonts
|
|
|
23
27
|
- [`sprites.tar.gz`](https://github.com/versatiles-org/versatiles-style/releases/latest/download/sprites.tar.gz) containing sprites, used e.g. for map icons
|
|
24
28
|
- [`versatiles-style.tar.gz`](https://github.com/versatiles-org/versatiles-style/releases/latest/download/versatiles-style.tar.gz) containing a JavaScript file to generate your own style in the browser.
|
|
25
29
|
|
|
26
|
-
#
|
|
30
|
+
# Generating styles on-the-fly
|
|
31
|
+
|
|
32
|
+
## Generating styles in the frontend (web browser)
|
|
27
33
|
|
|
28
34
|
Download latest release:
|
|
29
35
|
|
|
30
36
|
```bash
|
|
31
|
-
|
|
37
|
+
curl -Ls "https://github.com/versatiles-org/versatiles-style/releases/latest/download/versatiles-style.tar.gz" | gzip -d | tar -xf -
|
|
32
38
|
```
|
|
33
39
|
|
|
34
40
|
Use it in:
|
|
@@ -38,12 +44,8 @@ Use it in:
|
|
|
38
44
|
<script src="maplibre-gl.js"></script>
|
|
39
45
|
<script src="versatiles-style.js"></script>
|
|
40
46
|
<script>
|
|
41
|
-
const style = VersaTilesStyle.
|
|
42
|
-
|
|
43
|
-
sprite: '/assets/styles/swr-bright/sprite',
|
|
44
|
-
glyphs: '/assets/fonts/{fontstack}/{range}.pbf',
|
|
45
|
-
baseUrl: 'https://example.org/',
|
|
46
|
-
languageSuffix: '_de',
|
|
47
|
+
const style = VersaTilesStyle.graybeard({
|
|
48
|
+
language: 'de',
|
|
47
49
|
colors: { label: '#222' },
|
|
48
50
|
recolor: { gamma: 0.5 }
|
|
49
51
|
});
|
|
@@ -55,7 +57,7 @@ Use it in:
|
|
|
55
57
|
</script>
|
|
56
58
|
```
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
## Generating styles in the backend (Node.js)
|
|
59
61
|
|
|
60
62
|
Install `@versatiles/style` via NPM:
|
|
61
63
|
|
|
@@ -66,111 +68,101 @@ npm install @versatiles/style
|
|
|
66
68
|
Use it in Node.js:
|
|
67
69
|
|
|
68
70
|
```javascript
|
|
69
|
-
import {
|
|
70
|
-
let style =
|
|
71
|
-
|
|
71
|
+
import { colorful } from '@versatiles/style';
|
|
72
|
+
let style = colorful({
|
|
73
|
+
language: 'en',
|
|
72
74
|
});
|
|
73
75
|
writeFileSync('style.json', JSON.stringify(style));
|
|
74
76
|
```
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<!--- This chapter is generated automatically --->
|
|
79
|
-
|
|
80
|
-
## Interfaces
|
|
81
|
-
|
|
82
|
-
### Interface: `TileJSONSpecificationRaster`<a id="interface_tilejsonspecificationraster"></a>
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
interface {
|
|
86
|
-
attribution?: string;
|
|
87
|
-
bounds?: [number, number, number, number];
|
|
88
|
-
center?: [number, number];
|
|
89
|
-
description?: string;
|
|
90
|
-
fillzoom?: number;
|
|
91
|
-
format: "avif" | "jpg" | "png" | "webp";
|
|
92
|
-
grids?: string[];
|
|
93
|
-
legend?: string;
|
|
94
|
-
maxzoom?: number;
|
|
95
|
-
minzoom?: number;
|
|
96
|
-
name?: string;
|
|
97
|
-
scheme?: "xyz" | "tms";
|
|
98
|
-
template?: string;
|
|
99
|
-
tilejson?: "3.0.0";
|
|
100
|
-
tiles: string[];
|
|
101
|
-
type: "raster";
|
|
102
|
-
}
|
|
103
|
-
```
|
|
78
|
+
### Methods for generating styles
|
|
104
79
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
bounds?: [number, number, number, number];
|
|
111
|
-
center?: [number, number];
|
|
112
|
-
description?: string;
|
|
113
|
-
fillzoom?: number;
|
|
114
|
-
format: "pbf";
|
|
115
|
-
grids?: string[];
|
|
116
|
-
legend?: string;
|
|
117
|
-
maxzoom?: number;
|
|
118
|
-
minzoom?: number;
|
|
119
|
-
name?: string;
|
|
120
|
-
scheme?: "xyz" | "tms";
|
|
121
|
-
template?: string;
|
|
122
|
-
tilejson?: "3.0.0";
|
|
123
|
-
tiles: string[];
|
|
124
|
-
type: "vector";
|
|
125
|
-
vector_layers: VectorLayer[];
|
|
126
|
-
}
|
|
127
|
-
```
|
|
80
|
+
This library provides:
|
|
81
|
+
- `style = colorful(options);`
|
|
82
|
+
- `style = eclipse(options);`
|
|
83
|
+
- `style = graybeard(options);`
|
|
84
|
+
- `style = neutrino(options);`
|
|
128
85
|
|
|
129
|
-
|
|
86
|
+
Where `options` is an optional object:
|
|
130
87
|
|
|
131
|
-
|
|
88
|
+
```javascript
|
|
89
|
+
const options: StyleBuilderOptions<Colorful> = {
|
|
90
|
+
// The base URL for loading external resources like tiles, sprites, and fonts.
|
|
91
|
+
// Default: document.location.origin (in the browser), or 'https://tiles.versatiles.org'
|
|
92
|
+
baseUrl?: string;
|
|
132
93
|
|
|
133
|
-
|
|
94
|
+
// The URL template for loading font glyphs, formatted with '{fontstack}' and '{range}' placeholders.
|
|
95
|
+
// Default: '/assets/glyphs/{fontstack}/{range}.pbf'
|
|
96
|
+
glyphs?: string;
|
|
134
97
|
|
|
135
|
-
|
|
98
|
+
// The URL for loading sprite images and metadata.
|
|
99
|
+
// Default: [{ id: 'basics', url: '/assets/sprites/basics/sprites' }]
|
|
100
|
+
sprite?: string | { id: string; url: string }[];
|
|
136
101
|
|
|
137
|
-
|
|
102
|
+
// An array of URL templates for loading map tiles, using '{z}', '{x}', and '{y}' placeholders.
|
|
103
|
+
// Default: ['/tiles/osm/{z}/{x}/{y}']
|
|
104
|
+
tiles?: string[];
|
|
138
105
|
|
|
139
|
-
|
|
106
|
+
// If set to true, hides all map labels.
|
|
107
|
+
// Default: false
|
|
108
|
+
hideLabels?: boolean;
|
|
140
109
|
|
|
141
|
-
|
|
110
|
+
// Set the language ('en', 'de') of all map labels.
|
|
111
|
+
// A null value means that the language of the country in which the label is drawn will be used.
|
|
112
|
+
// Default: null
|
|
113
|
+
language?: Language;
|
|
142
114
|
|
|
143
|
-
|
|
115
|
+
// An object specifying overrides for default color values, keyed by the color names.
|
|
116
|
+
colors?: Partial<StyleBuilderColorStrings<T>>;
|
|
144
117
|
|
|
145
|
-
|
|
118
|
+
// An object specifying overrides for default font names, keyed by the font names.
|
|
119
|
+
fonts?: Partial<StyleBuilderFontStrings<T>>;
|
|
146
120
|
|
|
147
|
-
|
|
121
|
+
// Options for color adjustments and transformations applied to the entire style.
|
|
122
|
+
recolor?: RecolorOptions;
|
|
123
|
+
}
|
|
148
124
|
|
|
149
|
-
|
|
125
|
+
export interface RecolorOptions {
|
|
126
|
+
// If true, inverts all colors.
|
|
127
|
+
invertBrightness?: boolean;
|
|
150
128
|
|
|
151
|
-
|
|
129
|
+
// Rotate the hue of all colors (in degrees).
|
|
130
|
+
rotate?: number;
|
|
152
131
|
|
|
153
|
-
|
|
132
|
+
// Adjusts the saturation level of all colors. Positive values increase saturation, negative values decrease it.
|
|
133
|
+
saturate?: number;
|
|
154
134
|
|
|
155
|
-
|
|
135
|
+
// Adjusts the gamma of all colors. Affects the brightness in a non-linear manner.
|
|
136
|
+
gamma?: number;
|
|
156
137
|
|
|
157
|
-
|
|
138
|
+
// Adjusts the contrast of all colors. Higher values produce more contrast.
|
|
139
|
+
contrast?: number;
|
|
158
140
|
|
|
159
|
-
|
|
141
|
+
// Adjusts the brightness of all colors. Positive values make it brighter, negative values make it darker.
|
|
142
|
+
brightness?: number;
|
|
160
143
|
|
|
161
|
-
|
|
144
|
+
// Specifies the intensity of the tinting effect. Ranges from 0 (no effect) to 1 (full effect).
|
|
145
|
+
tint?: number;
|
|
162
146
|
|
|
163
|
-
|
|
147
|
+
// Specifies the color used for tinting, in a string format (e.g., '#FF0000').
|
|
148
|
+
tintColor?: string;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
164
151
|
|
|
165
|
-
|
|
152
|
+
### Method: `guessStyle(options)`
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
const style = guessStyle(options);
|
|
156
|
+
```
|
|
166
157
|
|
|
167
|
-
### Method: `neutrino(options)`
|
|
168
158
|
|
|
169
|
-
|
|
159
|
+
GuessStyleOptions
|
|
160
|
+
|
|
161
|
+
<sup><a href="https://github.com/versatiles-org/versatiles-style/blob/be6dcfe/src/lib/style_guesser.ts#L13">\[src]</a></sup>
|
|
170
162
|
|
|
171
163
|
**Parameters:**
|
|
172
164
|
|
|
173
|
-
* <code>
|
|
165
|
+
* <code>opt: TileJSONOption</code>
|
|
174
166
|
|
|
175
167
|
**Returns:** <code>MaplibreStyle</code>
|
|
176
168
|
|
|
@@ -186,9 +178,7 @@ Please note that for building new sprites you need `optipng`.
|
|
|
186
178
|
|
|
187
179
|
## Configuration
|
|
188
180
|
|
|
189
|
-
Iconsets can be defined in [`scripts/config-sprites.ts`](./scripts/config-sprites.ts)
|
|
190
|
-
* `colors` are applied to each path in the order they appear in the source SVG.
|
|
191
|
-
* `size` applies to the height
|
|
181
|
+
Iconsets can be defined in [`scripts/config-sprites.ts`](./scripts/config-sprites.ts)
|
|
192
182
|
|
|
193
183
|
# Licenses
|
|
194
184
|
|
package/dist/browser.d.ts
CHANGED
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
1
|
+
export * from './styles/index.js';
|
|
2
2
|
export { guessStyle } from './guess_style/index.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
import { isTileJSONSpecification, isVectorLayers } from '../types/index.js';
|
|
3
2
|
import { resolveUrl } from '../lib/utils.js';
|
|
4
3
|
import randomColorGenerator from './random_color.js';
|
|
@@ -27,11 +26,11 @@ export function guessStyle(opt) {
|
|
|
27
26
|
}
|
|
28
27
|
let k;
|
|
29
28
|
for (k in tilejsonBasic) {
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
31
29
|
if (tilejsonBasic[k] === undefined)
|
|
32
30
|
delete tilejsonBasic[k];
|
|
33
31
|
}
|
|
34
32
|
let tilejson;
|
|
33
|
+
let vectorLayers;
|
|
35
34
|
switch (format) {
|
|
36
35
|
case 'avif':
|
|
37
36
|
case 'jpg':
|
|
@@ -40,7 +39,7 @@ export function guessStyle(opt) {
|
|
|
40
39
|
tilejson = { ...tilejsonBasic, type: 'raster', format };
|
|
41
40
|
break;
|
|
42
41
|
case 'pbf':
|
|
43
|
-
|
|
42
|
+
vectorLayers = opt.vectorLayers;
|
|
44
43
|
if (!isVectorLayers(vectorLayers))
|
|
45
44
|
throw Error('property vector_layers is invalid');
|
|
46
45
|
tilejson = { ...tilejsonBasic, type: 'vector', format, vector_layers: vectorLayers };
|
|
@@ -95,7 +94,9 @@ export async function guessStyleFromContainer(container, options) {
|
|
|
95
94
|
if (('vector_layers' in t) && Array.isArray(t.vector_layers))
|
|
96
95
|
vectorLayers = t.vector_layers;
|
|
97
96
|
}
|
|
98
|
-
catch (
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.log(error);
|
|
99
|
+
}
|
|
99
100
|
}
|
|
100
101
|
const guessStyleOptions = {
|
|
101
102
|
...options,
|
|
@@ -120,7 +121,6 @@ function isShortbread(spec) {
|
|
|
120
121
|
}
|
|
121
122
|
function getShortbreadStyle(spec, builderOption) {
|
|
122
123
|
return colorful({
|
|
123
|
-
hideLabels: true,
|
|
124
124
|
tiles: spec.tiles,
|
|
125
125
|
baseUrl: builderOption.baseUrl,
|
|
126
126
|
glyphs: builderOption.glyphs,
|
|
@@ -84,7 +84,6 @@ export default function randomColorGenerator(startSeed) {
|
|
|
84
84
|
}
|
|
85
85
|
if (typeof hue === 'string') {
|
|
86
86
|
const color = colorDictionary[hue];
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
88
87
|
if (color?.hueRange)
|
|
89
88
|
return color.hueRange;
|
|
90
89
|
}
|
|
@@ -132,7 +131,6 @@ export default function randomColorGenerator(startSeed) {
|
|
|
132
131
|
defineColor('pink', [282, 334], [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]]);
|
|
133
132
|
return dic;
|
|
134
133
|
}
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
136
134
|
function HSVtoHSL(hsv) {
|
|
137
135
|
const s = hsv[1] / 100, v = hsv[2] / 100, k = (2 - s) * v;
|
|
138
136
|
return [hsv[0], 100 * s * v / (k < 1 ? k : 2 - k), 100 * k / 2];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type * from './styles/index.js';
|
|
2
|
-
export *
|
|
2
|
+
export * from './styles/index.js';
|
|
3
3
|
export { guessStyle, guessStyleFromContainer } from './guess_style/index.js';
|
|
4
4
|
export type { GuessStyleOptions, GuessContainerOptions } from './guess_style/index.js';
|
|
5
5
|
export type { VectorLayer } from './types/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
1
|
+
export * from './styles/index.js';
|
|
2
2
|
export { guessStyle, guessStyleFromContainer } from './guess_style/index.js';
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function deepClone<T>(obj: T): T;
|
|
2
|
-
export declare function isSimpleObject(item: unknown):
|
|
3
|
-
export declare function isBasicType(item: unknown): boolean;
|
|
4
|
-
export declare function deepMerge<T extends object>(source0: T, ...sources: T[]): T;
|
|
2
|
+
export declare function isSimpleObject(item: unknown): item is object;
|
|
3
|
+
export declare function isBasicType(item: unknown): item is boolean | number | string | undefined;
|
|
4
|
+
export declare function deepMerge<T extends object>(source0: T, ...sources: Partial<T>[]): T;
|
|
5
5
|
export declare function resolveUrl(base: string, url: string): string;
|
|
6
|
+
export declare function basename(url: string): string;
|
package/dist/lib/utils.js
CHANGED
|
@@ -63,7 +63,7 @@ export function deepMerge(source0, ...sources) {
|
|
|
63
63
|
if (typeof source !== 'object')
|
|
64
64
|
continue;
|
|
65
65
|
for (const key in source) {
|
|
66
|
-
if (!
|
|
66
|
+
if (!(key in source))
|
|
67
67
|
continue;
|
|
68
68
|
const sourceValue = source[key];
|
|
69
69
|
// *********
|
|
@@ -87,7 +87,6 @@ export function deepMerge(source0, ...sources) {
|
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
89
|
if (isSimpleObject(target[key]) && isSimpleObject(sourceValue)) {
|
|
90
|
-
// @ts-expect-error: Too complicated to handle
|
|
91
90
|
target[key] = deepMerge(target[key], sourceValue);
|
|
92
91
|
continue;
|
|
93
92
|
}
|
|
@@ -95,7 +94,6 @@ export function deepMerge(source0, ...sources) {
|
|
|
95
94
|
// merge
|
|
96
95
|
// *********
|
|
97
96
|
if (isSimpleObject(target[key]) && isSimpleObject(sourceValue)) {
|
|
98
|
-
// @ts-expect-error: Too complicated to handle
|
|
99
97
|
target[key] = deepMerge(target[key], sourceValue);
|
|
100
98
|
continue;
|
|
101
99
|
}
|
|
@@ -107,10 +105,22 @@ export function deepMerge(source0, ...sources) {
|
|
|
107
105
|
return target;
|
|
108
106
|
}
|
|
109
107
|
export function resolveUrl(base, url) {
|
|
110
|
-
if (!
|
|
108
|
+
if (!base)
|
|
111
109
|
return url;
|
|
112
110
|
url = new URL(url, base).href;
|
|
113
111
|
url = url.replace(/%7B/gi, '{');
|
|
114
112
|
url = url.replace(/%7D/gi, '}');
|
|
115
113
|
return url;
|
|
116
114
|
}
|
|
115
|
+
export function basename(url) {
|
|
116
|
+
if (!url)
|
|
117
|
+
return '';
|
|
118
|
+
try {
|
|
119
|
+
url = new URL(url, 'http://example.org').pathname;
|
|
120
|
+
}
|
|
121
|
+
catch (_) {
|
|
122
|
+
// ignore
|
|
123
|
+
}
|
|
124
|
+
url = url.replace(/\/+$/, '');
|
|
125
|
+
return url.split('/').pop() ?? '';
|
|
126
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Language } from '../style_builder/index.js';
|
|
2
2
|
import type { MaplibreLayerDefinition } from '../types/index.js';
|
|
3
3
|
export declare function getShortbreadLayers(option: {
|
|
4
|
-
readonly
|
|
4
|
+
readonly language: Language;
|
|
5
5
|
}): MaplibreLayerDefinition[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
export function getShortbreadLayers(option) {
|
|
3
|
-
const {
|
|
4
|
-
const nameField =
|
|
2
|
+
const { language } = option;
|
|
3
|
+
const nameField = language ? '{name_' + language + '}' : '{name}';
|
|
5
4
|
return [
|
|
6
5
|
// background
|
|
7
6
|
{ id: 'background', type: 'background' },
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
const maxzoom = 14;
|
|
3
2
|
export function getShortbreadTemplate() {
|
|
4
3
|
return {
|
|
@@ -8,8 +7,8 @@ export function getShortbreadTemplate() {
|
|
|
8
7
|
'maputnik:renderer': 'mbgljs',
|
|
9
8
|
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
10
9
|
},
|
|
11
|
-
glyphs: 'https://tiles.versatiles.org/
|
|
12
|
-
sprite: 'https://tiles.versatiles.org/sprites/sprites',
|
|
10
|
+
glyphs: 'https://tiles.versatiles.org/assets/glyphs/{fontstack}/{range}.pbf',
|
|
11
|
+
sprite: [{ id: 'basics', url: 'https://tiles.versatiles.org/assets/sprites/basics/sprites' }],
|
|
13
12
|
sources: {
|
|
14
13
|
'versatiles-shortbread': {
|
|
15
14
|
tilejson: '3.0.0',
|
|
@@ -87,7 +87,6 @@ export function decorate(layers, rules, recolor) {
|
|
|
87
87
|
layer.paint[key] = value;
|
|
88
88
|
break;
|
|
89
89
|
default:
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
91
90
|
throw new Error(`unknown parent "${propertyDef.parent}" for key "${key}"`);
|
|
92
91
|
}
|
|
93
92
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { Language } from './types.js';
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import Color from 'color';
|
|
2
2
|
export interface RecolorOptions {
|
|
3
|
-
/** If true, inverts the colors. */
|
|
4
3
|
invertBrightness?: boolean;
|
|
5
|
-
/** The degree to rotate the hue of the color (in degrees). */
|
|
6
4
|
rotate?: number;
|
|
7
|
-
/** Adjusts the saturation level of the color. Positive values increase saturation, negative values decrease it. */
|
|
8
5
|
saturate?: number;
|
|
9
|
-
/** Adjusts the gamma of the color. Affects the brightness in a non-linear manner. */
|
|
10
6
|
gamma?: number;
|
|
11
|
-
/** Adjusts the contrast of the color. Higher values produce more contrast. */
|
|
12
7
|
contrast?: number;
|
|
13
|
-
/** Adjusts the brightness of the color. Positive values make it brighter, negative values make it darker. */
|
|
14
8
|
brightness?: number;
|
|
15
|
-
/** Specifies the intensity of the tinting effect. Ranges from 0 (no effect) to 1 (full effect). */
|
|
16
9
|
tint?: number;
|
|
17
|
-
/** Specifies the color used for tinting, in a string format (e.g., '#FF0000'). */
|
|
18
10
|
tintColor?: string;
|
|
19
11
|
}
|
|
20
12
|
export declare function getDefaultRecolorFlags(): RecolorOptions;
|
|
@@ -2,19 +2,18 @@ import Color from 'color';
|
|
|
2
2
|
import { getShortbreadTemplate, getShortbreadLayers } from '../shortbread/index.js';
|
|
3
3
|
import { decorate } from './decorator.js';
|
|
4
4
|
import { CachedRecolor, getDefaultRecolorFlags } from './recolor.js';
|
|
5
|
-
import { deepClone, resolveUrl } from '../lib/utils.js';
|
|
5
|
+
import { basename, deepClone, resolveUrl } from '../lib/utils.js';
|
|
6
6
|
// StyleBuilder class definition
|
|
7
7
|
export default class StyleBuilder {
|
|
8
8
|
#sourceName = 'versatiles-shortbread';
|
|
9
9
|
build(options) {
|
|
10
10
|
options ??= {};
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const sprite = options.sprite ?? '/assets/sprites/sprites';
|
|
11
|
+
const baseUrl = options.baseUrl ?? globalThis?.document?.location?.origin ?? 'https://tiles.versatiles.org';
|
|
12
|
+
const glyphs = options.glyphs ?? '/assets/glyphs/{fontstack}/{range}.pbf';
|
|
13
|
+
const sprite = options.sprite ?? [{ id: 'basics', url: '/assets/sprites/basics/sprites' }];
|
|
15
14
|
const tiles = options.tiles ?? ['/tiles/osm/{z}/{x}/{y}'];
|
|
16
15
|
const hideLabels = options.hideLabels ?? false;
|
|
17
|
-
const
|
|
16
|
+
const language = options.language ?? null;
|
|
18
17
|
const recolorOptions = options.recolor ?? getDefaultRecolorFlags();
|
|
19
18
|
const colors = this.getColors(this.defaultColors);
|
|
20
19
|
if (options.colors) {
|
|
@@ -34,12 +33,12 @@ export default class StyleBuilder {
|
|
|
34
33
|
const styleRuleOptions = {
|
|
35
34
|
colors,
|
|
36
35
|
fonts,
|
|
37
|
-
|
|
36
|
+
language,
|
|
38
37
|
};
|
|
39
38
|
// get layer style rules from child class
|
|
40
39
|
const layerStyleRules = this.getStyleRules(styleRuleOptions);
|
|
41
40
|
// get shortbread layers
|
|
42
|
-
const layerDefinitions = getShortbreadLayers({
|
|
41
|
+
const layerDefinitions = getShortbreadLayers({ language });
|
|
43
42
|
let layers = layerDefinitions.map(layer => {
|
|
44
43
|
switch (layer.type) {
|
|
45
44
|
case 'background':
|
|
@@ -62,7 +61,12 @@ export default class StyleBuilder {
|
|
|
62
61
|
style.layers = layers;
|
|
63
62
|
style.name = 'versatiles-' + this.name.toLowerCase();
|
|
64
63
|
style.glyphs = resolveUrl(baseUrl, glyphs);
|
|
65
|
-
|
|
64
|
+
if (typeof sprite == 'string') {
|
|
65
|
+
style.sprite = [{ id: basename(sprite), url: resolveUrl(baseUrl, sprite) }];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
style.sprite = sprite.map(({ id, url }) => ({ id, url: resolveUrl(baseUrl, url) }));
|
|
69
|
+
}
|
|
66
70
|
const source = style.sources[this.#sourceName];
|
|
67
71
|
if ('tiles' in source)
|
|
68
72
|
source.tiles = tiles.map(url => resolveUrl(baseUrl, url));
|
|
@@ -81,7 +85,7 @@ export default class StyleBuilder {
|
|
|
81
85
|
sprite: '',
|
|
82
86
|
tiles: [],
|
|
83
87
|
hideLabels: false,
|
|
84
|
-
|
|
88
|
+
language: undefined,
|
|
85
89
|
colors: deepClone(this.defaultColors),
|
|
86
90
|
fonts: deepClone(this.defaultFonts),
|
|
87
91
|
recolor: getDefaultRecolorFlags(),
|
|
@@ -2,25 +2,19 @@ import type Color from 'color';
|
|
|
2
2
|
import type StyleBuilder from './style_builder.js';
|
|
3
3
|
import type { RecolorOptions } from './recolor.js';
|
|
4
4
|
/** Represents language suffixes used in map styles. */
|
|
5
|
-
export type
|
|
5
|
+
export type Language = 'de' | 'en' | null;
|
|
6
6
|
export interface StyleBuilderOptions<T extends StyleBuilder<T>> {
|
|
7
|
-
/** The base URL for loading external resources like tiles, sprites, and fonts. */
|
|
8
7
|
baseUrl?: string;
|
|
9
|
-
/** The URL template for loading font glyphs, formatted with `{fontstack}` and `{range}` placeholders. */
|
|
10
8
|
glyphs?: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
sprite?: string | {
|
|
10
|
+
id: string;
|
|
11
|
+
url: string;
|
|
12
|
+
}[];
|
|
14
13
|
tiles?: string[];
|
|
15
|
-
/** If true, hides all map labels. */
|
|
16
14
|
hideLabels?: boolean;
|
|
17
|
-
|
|
18
|
-
languageSuffix?: LanguageSuffix;
|
|
19
|
-
/** An object specifying overrides for default color values, keyed by the color names. */
|
|
15
|
+
language?: Language;
|
|
20
16
|
colors?: Partial<StyleBuilderColorStrings<T>>;
|
|
21
|
-
/** An object specifying overrides for default font names, keyed by the font names. */
|
|
22
17
|
fonts?: Partial<StyleBuilderFontStrings<T>>;
|
|
23
|
-
/** Options for color adjustments and transformations applied to the entire style. */
|
|
24
18
|
recolor?: RecolorOptions;
|
|
25
19
|
}
|
|
26
20
|
/** Defines the keys for color properties in a style builder. */
|
|
@@ -39,7 +33,7 @@ export type StyleBuilderFonts<T extends StyleBuilder<T>> = Record<StyleBuilderFo
|
|
|
39
33
|
export interface StyleRulesOptions<T extends StyleBuilder<T>> {
|
|
40
34
|
colors: StyleBuilderColors<T>;
|
|
41
35
|
fonts: StyleBuilderFontStrings<T>;
|
|
42
|
-
|
|
36
|
+
language: Language;
|
|
43
37
|
}
|
|
44
38
|
/** Defines the value type for a style rule. */
|
|
45
39
|
export type StyleRuleValue = boolean | number | object | string;
|
package/dist/styles/colorful.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
import StyleBuilder from '../style_builder/style_builder.js';
|
|
3
2
|
export default class Colorful extends StyleBuilder {
|
|
4
3
|
name = 'Colorful';
|
|
@@ -145,6 +144,9 @@ export default class Colorful extends StyleBuilder {
|
|
|
145
144
|
color: colors.land,
|
|
146
145
|
opacity: { 12: 0, 13: 1 },
|
|
147
146
|
},
|
|
147
|
+
'water-pier': {
|
|
148
|
+
color: colors.land,
|
|
149
|
+
},
|
|
148
150
|
'water-river': {
|
|
149
151
|
lineWidth: { 9: 0, 10: 3, 15: 5, 17: 9, 18: 20, 20: 60 },
|
|
150
152
|
},
|
|
@@ -217,7 +219,7 @@ export default class Colorful extends StyleBuilder {
|
|
|
217
219
|
color: colors.danger,
|
|
218
220
|
fillOutlineColor: colors.danger,
|
|
219
221
|
opacity: 0.3,
|
|
220
|
-
image: 'pattern-warning',
|
|
222
|
+
image: 'basics:pattern-warning',
|
|
221
223
|
},
|
|
222
224
|
'site-hospital': {
|
|
223
225
|
color: colors.hospital,
|
|
@@ -225,12 +227,12 @@ export default class Colorful extends StyleBuilder {
|
|
|
225
227
|
},
|
|
226
228
|
'site-prison': {
|
|
227
229
|
color: colors.prison,
|
|
228
|
-
image: 'pattern-striped',
|
|
230
|
+
image: 'basics:pattern-striped',
|
|
229
231
|
opacity: 0.1,
|
|
230
232
|
},
|
|
231
233
|
'site-construction': {
|
|
232
234
|
color: colors.construction,
|
|
233
|
-
image: 'pattern-hatched_thin',
|
|
235
|
+
image: 'basics:pattern-hatched_thin',
|
|
234
236
|
opacity: 0.1,
|
|
235
237
|
},
|
|
236
238
|
'site-{university,college,school}': {
|
|
@@ -650,7 +652,7 @@ export default class Colorful extends StyleBuilder {
|
|
|
650
652
|
// markings
|
|
651
653
|
'marking-oneway{-reverse,}': {
|
|
652
654
|
minzoom: 16,
|
|
653
|
-
image: 'marking-arrow',
|
|
655
|
+
image: 'basics:marking-arrow',
|
|
654
656
|
opacity: { 16: 0, 17: 0.7 },
|
|
655
657
|
font: fonts.regular,
|
|
656
658
|
},
|
|
@@ -672,37 +674,37 @@ export default class Colorful extends StyleBuilder {
|
|
|
672
674
|
},
|
|
673
675
|
'symbol-transit-airport': {
|
|
674
676
|
minzoom: 12,
|
|
675
|
-
image: 'icon-airport',
|
|
677
|
+
image: 'basics:icon-airport',
|
|
676
678
|
iconSize: { 12: 0.5, 14: 1 },
|
|
677
679
|
},
|
|
678
680
|
'symbol-transit-airfield': {
|
|
679
681
|
minzoom: 13,
|
|
680
|
-
image: 'icon-airfield',
|
|
682
|
+
image: 'basics:icon-airfield',
|
|
681
683
|
iconSize: { 13: 0.5, 15: 1 },
|
|
682
684
|
},
|
|
683
685
|
'symbol-transit-station': {
|
|
684
686
|
minzoom: 13,
|
|
685
|
-
image: 'icon-rail',
|
|
687
|
+
image: 'basics:icon-rail',
|
|
686
688
|
iconSize: { 13: 0.5, 15: 1 },
|
|
687
689
|
},
|
|
688
690
|
'symbol-transit-lightrail': {
|
|
689
691
|
minzoom: 14,
|
|
690
|
-
image: 'icon-rail_light',
|
|
692
|
+
image: 'basics:icon-rail_light',
|
|
691
693
|
iconSize: { 14: 0.5, 16: 1 },
|
|
692
694
|
},
|
|
693
695
|
'symbol-transit-subway': {
|
|
694
696
|
minzoom: 14,
|
|
695
|
-
image: 'icon-rail_metro',
|
|
697
|
+
image: 'basics:icon-rail_metro',
|
|
696
698
|
iconSize: { 14: 0.5, 16: 1 },
|
|
697
699
|
},
|
|
698
700
|
'symbol-transit-tram': {
|
|
699
701
|
minzoom: 15,
|
|
700
|
-
image: 'transport-tram',
|
|
702
|
+
image: 'basics:transport-tram',
|
|
701
703
|
iconSize: { 15: 0.5, 17: 1 },
|
|
702
704
|
},
|
|
703
705
|
'symbol-transit-bus': {
|
|
704
706
|
minzoom: 16,
|
|
705
|
-
image: 'icon-bus',
|
|
707
|
+
image: 'basics:icon-bus',
|
|
706
708
|
iconSize: { 16: 0.5, 18: 1 },
|
|
707
709
|
},
|
|
708
710
|
// TODO: localized symbols? depends on shortbread
|
|
@@ -719,191 +721,191 @@ export default class Colorful extends StyleBuilder {
|
|
|
719
721
|
'poi-amenity': {
|
|
720
722
|
image: ['match',
|
|
721
723
|
['get', 'amenity'],
|
|
722
|
-
'arts_centre', 'icon-art_gallery',
|
|
723
|
-
'atm', 'icon-atm',
|
|
724
|
-
'bank', 'icon-bank',
|
|
725
|
-
'bar', 'icon-bar',
|
|
726
|
-
'bench', 'icon-bench',
|
|
727
|
-
'bicycle_rental', 'icon-bicycle_share',
|
|
728
|
-
'biergarten', 'icon-beergarden',
|
|
729
|
-
'cafe', 'icon-cafe',
|
|
730
|
-
'car_rental', 'icon-car_rental',
|
|
731
|
-
'car_sharing', 'icon-car_rental',
|
|
732
|
-
'car_wash', 'icon-car_wash',
|
|
733
|
-
'cinema', 'icon-cinema',
|
|
734
|
-
//'clinic', 'icon-clinic',
|
|
735
|
-
'college', 'icon-college',
|
|
736
|
-
'community_centre', 'icon-community',
|
|
737
|
-
//'courthouse', 'icon-courthouse',
|
|
738
|
-
'dentist', 'icon-dentist',
|
|
739
|
-
'doctors', 'icon-doctor',
|
|
740
|
-
'dog_park', 'icon-dog_park',
|
|
741
|
-
'drinking_water', 'icon-drinking_water',
|
|
742
|
-
'embassy', 'icon-embassy',
|
|
743
|
-
'fast_food', 'icon-fast_food',
|
|
744
|
-
'fire_station', 'icon-fire_station',
|
|
745
|
-
//'food_court', 'icon-food_court',
|
|
746
|
-
'fountain', 'icon-fountain',
|
|
747
|
-
'grave_yard', 'icon-cemetery',
|
|
748
|
-
'hospital', 'icon-hospital',
|
|
749
|
-
'hunting_stand', 'icon-huntingstand',
|
|
750
|
-
'library', 'icon-library',
|
|
751
|
-
'marketplace', 'icon-marketplace',
|
|
752
|
-
'nightclub', 'icon-nightclub',
|
|
753
|
-
'nursing_home', 'icon-nursinghome',
|
|
754
|
-
'pharmacy', 'icon-pharmacy',
|
|
755
|
-
'place_of_worship', 'icon-place_of_worship',
|
|
756
|
-
'playground', 'icon-playground',
|
|
757
|
-
'police', 'icon-police',
|
|
758
|
-
'post_box', 'icon-postbox',
|
|
759
|
-
'post_office', 'icon-post',
|
|
760
|
-
'prison', 'icon-prison',
|
|
761
|
-
'pub', 'icon-beer',
|
|
762
|
-
//'public_building', 'icon-public_building',
|
|
763
|
-
'recycling', 'icon-recycling',
|
|
764
|
-
'restaurant', 'icon-restaurant',
|
|
765
|
-
'school', 'icon-school',
|
|
766
|
-
'shelter', 'icon-shelter',
|
|
767
|
-
'telephone', 'icon-telephone',
|
|
768
|
-
'theatre', 'icon-theatre',
|
|
769
|
-
'toilets', 'icon-toilet',
|
|
770
|
-
'townhall', 'icon-town_hall',
|
|
771
|
-
//'university', 'icon-university',
|
|
772
|
-
'vending_machine', 'icon-vendingmachine',
|
|
773
|
-
'veterinary', 'icon-veterinary',
|
|
774
|
-
'waste_basket', 'icon-waste_basket',
|
|
775
|
-
'
|
|
724
|
+
'arts_centre', 'basics:icon-art_gallery',
|
|
725
|
+
'atm', 'basics:icon-atm',
|
|
726
|
+
'bank', 'basics:icon-bank',
|
|
727
|
+
'bar', 'basics:icon-bar',
|
|
728
|
+
'bench', 'basics:icon-bench',
|
|
729
|
+
'bicycle_rental', 'basics:icon-bicycle_share',
|
|
730
|
+
'biergarten', 'basics:icon-beergarden',
|
|
731
|
+
'cafe', 'basics:icon-cafe',
|
|
732
|
+
'car_rental', 'basics:icon-car_rental',
|
|
733
|
+
'car_sharing', 'basics:icon-car_rental',
|
|
734
|
+
'car_wash', 'basics:icon-car_wash',
|
|
735
|
+
'cinema', 'basics:icon-cinema',
|
|
736
|
+
//'clinic', 'basics:icon-clinic',
|
|
737
|
+
'college', 'basics:icon-college',
|
|
738
|
+
'community_centre', 'basics:icon-community',
|
|
739
|
+
//'courthouse', 'basics:icon-courthouse',
|
|
740
|
+
'dentist', 'basics:icon-dentist',
|
|
741
|
+
'doctors', 'basics:icon-doctor',
|
|
742
|
+
'dog_park', 'basics:icon-dog_park',
|
|
743
|
+
'drinking_water', 'basics:icon-drinking_water',
|
|
744
|
+
'embassy', 'basics:icon-embassy',
|
|
745
|
+
'fast_food', 'basics:icon-fast_food',
|
|
746
|
+
'fire_station', 'basics:icon-fire_station',
|
|
747
|
+
//'food_court', 'basics:icon-food_court',
|
|
748
|
+
'fountain', 'basics:icon-fountain',
|
|
749
|
+
'grave_yard', 'basics:icon-cemetery',
|
|
750
|
+
'hospital', 'basics:icon-hospital',
|
|
751
|
+
'hunting_stand', 'basics:icon-huntingstand',
|
|
752
|
+
'library', 'basics:icon-library',
|
|
753
|
+
'marketplace', 'basics:icon-marketplace',
|
|
754
|
+
'nightclub', 'basics:icon-nightclub',
|
|
755
|
+
'nursing_home', 'basics:icon-nursinghome',
|
|
756
|
+
'pharmacy', 'basics:icon-pharmacy',
|
|
757
|
+
'place_of_worship', 'basics:icon-place_of_worship',
|
|
758
|
+
'playground', 'basics:icon-playground',
|
|
759
|
+
'police', 'basics:icon-police',
|
|
760
|
+
'post_box', 'basics:icon-postbox',
|
|
761
|
+
'post_office', 'basics:icon-post',
|
|
762
|
+
'prison', 'basics:icon-prison',
|
|
763
|
+
'pub', 'basics:icon-beer',
|
|
764
|
+
//'public_building', 'basics:icon-public_building',
|
|
765
|
+
'recycling', 'basics:icon-recycling',
|
|
766
|
+
'restaurant', 'basics:icon-restaurant',
|
|
767
|
+
'school', 'basics:icon-school',
|
|
768
|
+
'shelter', 'basics:icon-shelter',
|
|
769
|
+
'telephone', 'basics:icon-telephone',
|
|
770
|
+
'theatre', 'basics:icon-theatre',
|
|
771
|
+
'toilets', 'basics:icon-toilet',
|
|
772
|
+
'townhall', 'basics:icon-town_hall',
|
|
773
|
+
//'university', 'basics:icon-university',
|
|
774
|
+
'vending_machine', 'basics:icon-vendingmachine',
|
|
775
|
+
'veterinary', 'basics:icon-veterinary',
|
|
776
|
+
'waste_basket', 'basics:icon-waste_basket',
|
|
777
|
+
'',
|
|
776
778
|
],
|
|
777
779
|
},
|
|
778
780
|
'poi-leisure': {
|
|
779
781
|
image: ['match',
|
|
780
782
|
['get', 'leisure'],
|
|
781
|
-
'golf_course', 'icon-golf',
|
|
782
|
-
'ice_rink', 'icon-icerink',
|
|
783
|
-
'pitch', 'icon-pitch',
|
|
784
|
-
//'sports_centre', 'icon-sports_centre',
|
|
785
|
-
'stadium', 'icon-stadium',
|
|
786
|
-
'swimming_pool', 'icon-swimming',
|
|
787
|
-
'water_park', 'icon-waterpark',
|
|
788
|
-
'icon-sports',
|
|
783
|
+
'golf_course', 'basics:icon-golf',
|
|
784
|
+
'ice_rink', 'basics:icon-icerink',
|
|
785
|
+
'pitch', 'basics:icon-pitch',
|
|
786
|
+
//'sports_centre', 'basics:icon-sports_centre',
|
|
787
|
+
'stadium', 'basics:icon-stadium',
|
|
788
|
+
'swimming_pool', 'basics:icon-swimming',
|
|
789
|
+
'water_park', 'basics:icon-waterpark',
|
|
790
|
+
'basics:icon-sports',
|
|
789
791
|
],
|
|
790
792
|
},
|
|
791
793
|
'poi-tourism': {
|
|
792
794
|
image: ['match',
|
|
793
795
|
['get', 'tourism'],
|
|
794
|
-
//'alpine_hut', 'icon-alpine_hut',
|
|
795
|
-
//'bed_and_breakfast', 'icon-bed_and_breakfast',
|
|
796
|
-
//'camp_site', 'icon-camp_site',
|
|
797
|
-
//'caravan_site', 'icon-caravan_site',
|
|
798
|
-
'chalet', 'icon-chalet',
|
|
799
|
-
//'guest_house', 'icon-guest_house',
|
|
800
|
-
//'hostel', 'icon-hostel',
|
|
801
|
-
//'hotel', 'icon-hotel',
|
|
802
|
-
'information', 'transport-information',
|
|
803
|
-
//'motel', 'icon-motel',
|
|
804
|
-
'picnic_site', 'icon-picnic_site',
|
|
805
|
-
//'theme_park', 'icon-theme_park',
|
|
806
|
-
'viewpoint', 'icon-viewpoint',
|
|
807
|
-
'zoo', 'icon-zoo',
|
|
808
|
-
'
|
|
796
|
+
//'alpine_hut', 'basics:icon-alpine_hut',
|
|
797
|
+
//'bed_and_breakfast', 'basics:icon-bed_and_breakfast',
|
|
798
|
+
//'camp_site', 'basics:icon-camp_site',
|
|
799
|
+
//'caravan_site', 'basics:icon-caravan_site',
|
|
800
|
+
'chalet', 'basics:icon-chalet',
|
|
801
|
+
//'guest_house', 'basics:icon-guest_house',
|
|
802
|
+
//'hostel', 'basics:icon-hostel',
|
|
803
|
+
//'hotel', 'basics:icon-hotel',
|
|
804
|
+
'information', 'basics:transport-information',
|
|
805
|
+
//'motel', 'basics:icon-motel',
|
|
806
|
+
'picnic_site', 'basics:icon-picnic_site',
|
|
807
|
+
//'theme_park', 'basics:icon-theme_park',
|
|
808
|
+
'viewpoint', 'basics:icon-viewpoint',
|
|
809
|
+
'zoo', 'basics:icon-zoo',
|
|
810
|
+
'',
|
|
809
811
|
],
|
|
810
812
|
},
|
|
811
813
|
'poi-shop': {
|
|
812
814
|
image: ['match',
|
|
813
815
|
['get', 'shop'],
|
|
814
|
-
'alcohol', 'icon-alcohol_shop',
|
|
815
|
-
'bakery', 'icon-bakery',
|
|
816
|
-
'beauty', 'icon-beauty',
|
|
817
|
-
'beverages', 'icon-beverages',
|
|
818
|
-
//'bicycle', 'icon-bicycle',
|
|
819
|
-
'books', 'icon-books',
|
|
820
|
-
'butcher', 'icon-butcher',
|
|
821
|
-
//'car', 'icon-car',
|
|
822
|
-
'chemist', 'icon-chemist',
|
|
823
|
-
'clothes', 'icon-clothes',
|
|
824
|
-
//'computer', 'icon-computer',
|
|
825
|
-
//'convinience', 'icon-convinience',
|
|
826
|
-
//'department_store', 'icon-department_store',
|
|
827
|
-
'doityourself', 'icon-doityourself',
|
|
828
|
-
'dry_cleaning', 'icon-drycleaning',
|
|
829
|
-
'florist', 'icon-florist',
|
|
830
|
-
'furniture', 'icon-furniture',
|
|
831
|
-
'garden_centre', 'icon-garden_centre',
|
|
832
|
-
'general', 'icon-shop',
|
|
833
|
-
'gift', 'icon-gift',
|
|
834
|
-
'greengrocer', 'icon-greengrocer',
|
|
835
|
-
'hairdresser', 'icon-hairdresser',
|
|
836
|
-
'hardware', 'icon-hardware',
|
|
837
|
-
'jewelry', 'icon-jewelry_store',
|
|
838
|
-
'kiosk', 'icon-kiosk',
|
|
839
|
-
'laundry', 'icon-laundry',
|
|
840
|
-
//'mall', 'icon-mall',
|
|
841
|
-
//'mobile_phone', 'icon-mobile_phone',
|
|
842
|
-
'newsagent', 'icon-newsagent',
|
|
843
|
-
'optican', 'icon-optician',
|
|
844
|
-
'outdoor', 'icon-outdoor',
|
|
845
|
-
'shoes', 'icon-shoes',
|
|
846
|
-
'sports', 'icon-sports',
|
|
847
|
-
'stationery', 'icon-stationery',
|
|
848
|
-
//'supermarket', 'icon-supermarket',
|
|
849
|
-
'toys', 'icon-toys',
|
|
850
|
-
'travel_agency', 'icon-travel_agent',
|
|
851
|
-
'video', 'icon-video',
|
|
852
|
-
'icon-shop',
|
|
816
|
+
'alcohol', 'basics:icon-alcohol_shop',
|
|
817
|
+
'bakery', 'basics:icon-bakery',
|
|
818
|
+
'beauty', 'basics:icon-beauty',
|
|
819
|
+
'beverages', 'basics:icon-beverages',
|
|
820
|
+
//'bicycle', 'basics:icon-bicycle',
|
|
821
|
+
'books', 'basics:icon-books',
|
|
822
|
+
'butcher', 'basics:icon-butcher',
|
|
823
|
+
//'car', 'basics:icon-car',
|
|
824
|
+
'chemist', 'basics:icon-chemist',
|
|
825
|
+
'clothes', 'basics:icon-clothes',
|
|
826
|
+
//'computer', 'basics:icon-computer',
|
|
827
|
+
//'convinience', 'basics:icon-convinience',
|
|
828
|
+
//'department_store', 'basics:icon-department_store',
|
|
829
|
+
'doityourself', 'basics:icon-doityourself',
|
|
830
|
+
'dry_cleaning', 'basics:icon-drycleaning',
|
|
831
|
+
'florist', 'basics:icon-florist',
|
|
832
|
+
'furniture', 'basics:icon-furniture',
|
|
833
|
+
'garden_centre', 'basics:icon-garden_centre',
|
|
834
|
+
'general', 'basics:icon-shop',
|
|
835
|
+
'gift', 'basics:icon-gift',
|
|
836
|
+
'greengrocer', 'basics:icon-greengrocer',
|
|
837
|
+
'hairdresser', 'basics:icon-hairdresser',
|
|
838
|
+
'hardware', 'basics:icon-hardware',
|
|
839
|
+
'jewelry', 'basics:icon-jewelry_store',
|
|
840
|
+
'kiosk', 'basics:icon-kiosk',
|
|
841
|
+
'laundry', 'basics:icon-laundry',
|
|
842
|
+
//'mall', 'basics:icon-mall',
|
|
843
|
+
//'mobile_phone', 'basics:icon-mobile_phone',
|
|
844
|
+
'newsagent', 'basics:icon-newsagent',
|
|
845
|
+
'optican', 'basics:icon-optician',
|
|
846
|
+
'outdoor', 'basics:icon-outdoor',
|
|
847
|
+
'shoes', 'basics:icon-shoes',
|
|
848
|
+
'sports', 'basics:icon-sports',
|
|
849
|
+
'stationery', 'basics:icon-stationery',
|
|
850
|
+
//'supermarket', 'basics:icon-supermarket',
|
|
851
|
+
'toys', 'basics:icon-toys',
|
|
852
|
+
'travel_agency', 'basics:icon-travel_agent',
|
|
853
|
+
'video', 'basics:icon-video',
|
|
854
|
+
'basics:icon-shop',
|
|
853
855
|
],
|
|
854
856
|
},
|
|
855
857
|
'poi-man_made': {
|
|
856
858
|
image: ['match',
|
|
857
859
|
['get', 'man_made'],
|
|
858
|
-
'lighthouse', 'icon-lighthouse',
|
|
859
|
-
'surveillance', 'icon-surveillance',
|
|
860
|
-
'tower', 'icon-observation_tower',
|
|
861
|
-
//'wastewater_plant', 'icon-wastewater_plant',
|
|
862
|
-
//'water_well', 'icon-water_well',
|
|
863
|
-
//'water_works', 'icon-water_works',
|
|
864
|
-
'watermill', 'icon-watermill',
|
|
865
|
-
'windmill', 'icon-windmill',
|
|
866
|
-
'
|
|
860
|
+
'lighthouse', 'basics:icon-lighthouse',
|
|
861
|
+
'surveillance', 'basics:icon-surveillance',
|
|
862
|
+
'tower', 'basics:icon-observation_tower',
|
|
863
|
+
//'wastewater_plant', 'basics:icon-wastewater_plant',
|
|
864
|
+
//'water_well', 'basics:icon-water_well',
|
|
865
|
+
//'water_works', 'basics:icon-water_works',
|
|
866
|
+
'watermill', 'basics:icon-watermill',
|
|
867
|
+
'windmill', 'basics:icon-windmill',
|
|
868
|
+
'',
|
|
867
869
|
],
|
|
868
870
|
},
|
|
869
871
|
'poi-historic': {
|
|
870
872
|
image: ['match',
|
|
871
873
|
['get', 'historic'],
|
|
872
|
-
//'archaelogical_site', 'icon-archaelogical_site',
|
|
873
|
-
'artwork', 'icon-artwork',
|
|
874
|
-
//'battlefield', 'icon-battlefield',
|
|
875
|
-
'castle', 'icon-castle',
|
|
876
|
-
//'fort', 'icon-fort',
|
|
877
|
-
//'memorial', 'icon-memorial',
|
|
878
|
-
'monument', 'icon-monument',
|
|
879
|
-
//'ruins', 'icon-ruins',
|
|
880
|
-
//'wayside_cross', 'icon-wayside_cross',
|
|
881
|
-
'wayside_shrine', 'icon-shrine',
|
|
882
|
-
'icon-historic',
|
|
874
|
+
//'archaelogical_site', 'basics:icon-archaelogical_site',
|
|
875
|
+
'artwork', 'basics:icon-artwork',
|
|
876
|
+
//'battlefield', 'basics:icon-battlefield',
|
|
877
|
+
'castle', 'basics:icon-castle',
|
|
878
|
+
//'fort', 'basics:icon-fort',
|
|
879
|
+
//'memorial', 'basics:icon-memorial',
|
|
880
|
+
'monument', 'basics:icon-monument',
|
|
881
|
+
//'ruins', 'basics:icon-ruins',
|
|
882
|
+
//'wayside_cross', 'basics:icon-wayside_cross',
|
|
883
|
+
'wayside_shrine', 'basics:icon-shrine',
|
|
884
|
+
'basics:icon-historic',
|
|
883
885
|
],
|
|
884
886
|
},
|
|
885
887
|
'poi-emergency': {
|
|
886
888
|
image: ['match',
|
|
887
889
|
['get', 'emergency'],
|
|
888
|
-
'defibrillator', 'icon-defibrillator',
|
|
889
|
-
'fire_hydrant', 'icon-hydrant',
|
|
890
|
-
'phone', 'icon-emergency_phone',
|
|
891
|
-
'
|
|
890
|
+
'defibrillator', 'basics:icon-defibrillator',
|
|
891
|
+
'fire_hydrant', 'basics:icon-hydrant',
|
|
892
|
+
'phone', 'basics:icon-emergency_phone',
|
|
893
|
+
'',
|
|
892
894
|
],
|
|
893
895
|
},
|
|
894
896
|
/*
|
|
895
897
|
'poi-highway': {
|
|
896
898
|
image: ['match',
|
|
897
899
|
['get', 'highway'],
|
|
898
|
-
//'emergency_access_point', 'icon-emergency_access_point',
|
|
899
|
-
'
|
|
900
|
+
//'emergency_access_point', 'basics:icon-emergency_access_point',
|
|
901
|
+
''
|
|
900
902
|
]
|
|
901
903
|
},
|
|
902
904
|
'poi-office': {
|
|
903
905
|
image: ['match',
|
|
904
906
|
['get', 'office'],
|
|
905
|
-
//'diplomatic', 'icon-diplomatic',
|
|
906
|
-
'
|
|
907
|
+
//'diplomatic', 'basics:icon-diplomatic',
|
|
908
|
+
''
|
|
907
909
|
]
|
|
908
910
|
},
|
|
909
911
|
*/
|
package/dist/styles/neutrino.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
import StyleBuilder from '../style_builder/style_builder.js';
|
|
3
2
|
export default class Neutrino extends StyleBuilder {
|
|
4
3
|
name = 'Neutrino';
|
|
@@ -77,6 +76,9 @@ export default class Neutrino extends StyleBuilder {
|
|
|
77
76
|
color: colors.land,
|
|
78
77
|
opacity: { 12: 0, 13: 1 },
|
|
79
78
|
},
|
|
79
|
+
'water-pier': {
|
|
80
|
+
color: colors.land,
|
|
81
|
+
},
|
|
80
82
|
'land-*': {
|
|
81
83
|
color: colors.land,
|
|
82
84
|
},
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versatiles/style",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Generate StyleJSON for MapLibre",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"check": "npm run lint && npm run
|
|
8
|
+
"check": "npm run lint && npm run test && npm run build",
|
|
9
9
|
"build": "rm -rf release; npm run build-browser && npm run build-node && npm run build-styles && npm run build-sprites",
|
|
10
|
-
"build-browser": "rollup -c=rollup.config.js
|
|
10
|
+
"build-browser": "rollup -c=rollup.config.js && $(cd release/versatiles-style; tar -cf - versatiles-style.* | gzip -9 > ../versatiles-style.tar.gz)",
|
|
11
11
|
"build-node": "rm -rf dist && tsc -p tsconfig.node.json && chmod +x dist/index.js",
|
|
12
12
|
"build-styles": "tsx scripts/build-styles.ts",
|
|
13
13
|
"build-sprites": "tsx scripts/build-sprites.ts",
|
|
14
|
-
"
|
|
14
|
+
"dev": "tsx scripts/dev.ts",
|
|
15
15
|
"// doc": "vrt ts2md src/index.ts tsconfig.node.json | vrt insertmd README.md '# API'",
|
|
16
16
|
"lint": "eslint --color .",
|
|
17
17
|
"prepack": "npm run build",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"type": "module",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@types/color": "^
|
|
32
|
+
"@types/color": "^4.2.0",
|
|
33
33
|
"brace-expansion": "^4.0.0",
|
|
34
34
|
"color": "^4.2.3"
|
|
35
35
|
},
|
|
@@ -38,35 +38,36 @@
|
|
|
38
38
|
"dist/**/*.d.ts"
|
|
39
39
|
],
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@maplibre/maplibre-gl-style-spec": "^
|
|
42
|
-
"@rollup/plugin-commonjs": "^
|
|
43
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
41
|
+
"@maplibre/maplibre-gl-style-spec": "^21.2.0",
|
|
42
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
44
44
|
"@rollup/plugin-terser": "^0.4.4",
|
|
45
|
-
"@rollup/plugin-typescript": "^
|
|
45
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
46
46
|
"@types/bin-pack": "^1.0.3",
|
|
47
47
|
"@types/brace-expansion": "^1.1.2",
|
|
48
48
|
"@types/inquirer": "^9.0.7",
|
|
49
|
-
"@types/jest": "^29.5.
|
|
50
|
-
"@types/node": "^
|
|
49
|
+
"@types/jest": "^29.5.14",
|
|
50
|
+
"@types/node": "^22.9.0",
|
|
51
51
|
"@types/tar-stream": "^3.1.3",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
53
|
-
"@typescript-eslint/parser": "^
|
|
54
|
-
"@versatiles/container": "^1.2.
|
|
55
|
-
"@versatiles/release-tool": "^1.2.
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^8.14.0",
|
|
53
|
+
"@typescript-eslint/parser": "^8.14.0",
|
|
54
|
+
"@versatiles/container": "^1.2.3",
|
|
55
|
+
"@versatiles/release-tool": "^1.2.6",
|
|
56
56
|
"bin-pack": "^1.0.2",
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"inquirer": "^
|
|
57
|
+
"eslint": "^9.14.0",
|
|
58
|
+
"inquirer": "^12.1.0",
|
|
59
59
|
"jest": "^29.7.0",
|
|
60
60
|
"jest-environment-jsdom": "^29.7.0",
|
|
61
61
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
62
|
-
"npm-check-updates": "^
|
|
63
|
-
"rollup": "^4.
|
|
62
|
+
"npm-check-updates": "^17.1.11",
|
|
63
|
+
"rollup": "^4.26.0",
|
|
64
64
|
"rollup-plugin-dts": "^6.1.1",
|
|
65
|
-
"sharp": "^0.33.
|
|
65
|
+
"sharp": "^0.33.5",
|
|
66
66
|
"tar-stream": "^3.1.7",
|
|
67
|
-
"ts-jest": "^29.
|
|
67
|
+
"ts-jest": "^29.2.5",
|
|
68
68
|
"ts-node": "^10.9.2",
|
|
69
|
-
"tsx": "^4.
|
|
70
|
-
"typescript": "^5.
|
|
69
|
+
"tsx": "^4.19.2",
|
|
70
|
+
"typescript": "^5.6.3",
|
|
71
|
+
"typescript-eslint": "^8.14.0"
|
|
71
72
|
}
|
|
72
73
|
}
|