@geogdev/styles 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -0
- package/dist/cjs/index.cjs +16 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +325 -0
- package/dist/esm/index.d.ts +325 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/styles/dark.json +2909 -0
- package/dist/styles/gray.json +2909 -0
- package/dist/styles/light.json +2909 -0
- package/dist/styles/warm.json +2909 -0
- package/dist/styles.js +16 -0
- package/dist/styles.js.map +1 -0
- package/package.json +52 -0
- package/src/cli.ts +27 -0
- package/src/config/features.json +48 -0
- package/src/config/languages.json +207 -0
- package/src/config/poi.json +205 -0
- package/src/config/styles/dark.json +129 -0
- package/src/config/styles/gray.json +129 -0
- package/src/config/styles/light.json +129 -0
- package/src/config/styles/warm.json +129 -0
- package/src/config/zoom.json +40 -0
- package/src/constants.ts +243 -0
- package/src/generateStyle.ts +70 -0
- package/src/index.ts +76 -0
- package/src/language.ts +320 -0
- package/src/layers/background.ts +91 -0
- package/src/layers/boundaries.ts +51 -0
- package/src/layers/buildings.ts +23 -0
- package/src/layers/index.ts +132 -0
- package/src/layers/labels.ts +775 -0
- package/src/layers/landcover.ts +323 -0
- package/src/layers/pois.ts +165 -0
- package/src/layers/roads.ts +688 -0
- package/src/layers/transit.ts +232 -0
- package/src/styles.ts +182 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"background": "#f8f9f7",
|
|
3
|
+
"earth": "#e9e9e6",
|
|
4
|
+
"park_a": "#b8d9b8",
|
|
5
|
+
"park_b": "#a8d4a8",
|
|
6
|
+
"hospital": "#e4dad9",
|
|
7
|
+
"industrial": "#d1dde1",
|
|
8
|
+
"school": "#e4ded7",
|
|
9
|
+
"wood_a": "#b0d0b0",
|
|
10
|
+
"wood_b": "#a0c8a0",
|
|
11
|
+
"pedestrian": "#d8ead8",
|
|
12
|
+
"scrub_a": "#c0dcc0",
|
|
13
|
+
"scrub_b": "#b0d4b0",
|
|
14
|
+
"glacier": "#f0f8ff",
|
|
15
|
+
"sand": "#f5e8d0",
|
|
16
|
+
"beach": "#f0e4c8",
|
|
17
|
+
"aerodrome": "#dadbdf",
|
|
18
|
+
"runway": "#e0e0e0",
|
|
19
|
+
"water": "#88c5e0",
|
|
20
|
+
"zoo": "#b8d9b8",
|
|
21
|
+
"military": "#dcdcdc",
|
|
22
|
+
|
|
23
|
+
"tunnel_other_casing": "#e5e5e2",
|
|
24
|
+
"tunnel_minor_casing": "#e5e5e2",
|
|
25
|
+
"tunnel_link_casing": "#e0e0dd",
|
|
26
|
+
"tunnel_major_casing": "#dcdcd9",
|
|
27
|
+
"tunnel_highway_casing": "#d8d8d5",
|
|
28
|
+
"tunnel_other": "#d0d0d0",
|
|
29
|
+
"tunnel_minor": "#c8c8c8",
|
|
30
|
+
"tunnel_link": "#c0c0c0",
|
|
31
|
+
"tunnel_major": "#b8b8b8",
|
|
32
|
+
"tunnel_highway": "#b0b0b0",
|
|
33
|
+
|
|
34
|
+
"pier": "#d0d0d0",
|
|
35
|
+
"buildings": "#c0bcb8",
|
|
36
|
+
|
|
37
|
+
"minor_service_casing": "#e5e5e2",
|
|
38
|
+
"minor_casing": "#e5e5e2",
|
|
39
|
+
"link_casing": "#e0e0dd",
|
|
40
|
+
"major_casing_late": "#dcdcd9",
|
|
41
|
+
"highway_casing_late": "#d8d8d5",
|
|
42
|
+
"other": "#d0d0d0",
|
|
43
|
+
"minor_service": "#c8c8c8",
|
|
44
|
+
"minor_a": "#c8c8c8",
|
|
45
|
+
"minor_b": "#c8c8c8",
|
|
46
|
+
"link": "#c0c0c0",
|
|
47
|
+
"major_casing_early": "#dcdcd9",
|
|
48
|
+
"major": "#b8b8b8",
|
|
49
|
+
"highway_casing_early": "#d8d8d5",
|
|
50
|
+
"highway": "#b0b0b0",
|
|
51
|
+
|
|
52
|
+
"railway": "#d5d5d5",
|
|
53
|
+
"boundaries": "#d4b8bc",
|
|
54
|
+
|
|
55
|
+
"bridges_other_casing": "#e5e5e2",
|
|
56
|
+
"bridges_minor_casing": "#e5e5e2",
|
|
57
|
+
"bridges_link_casing": "#e0e0dd",
|
|
58
|
+
"bridges_major_casing": "#dcdcd9",
|
|
59
|
+
"bridges_highway_casing": "#d8d8d5",
|
|
60
|
+
"bridges_other": "#d0d0d0",
|
|
61
|
+
"bridges_minor": "#c8c8c8",
|
|
62
|
+
"bridges_link": "#c0c0c0",
|
|
63
|
+
"bridges_major": "#b8b8b8",
|
|
64
|
+
"bridges_highway": "#b0b0b0",
|
|
65
|
+
|
|
66
|
+
"roads_label_minor": "#8a9299",
|
|
67
|
+
"roads_label_minor_halo": "#ffffff",
|
|
68
|
+
"roads_label_major": "#5a6570",
|
|
69
|
+
"roads_label_major_halo": "#ffffff",
|
|
70
|
+
"ocean_label": "#7a8a92",
|
|
71
|
+
"subplace_label": "#8a9299",
|
|
72
|
+
"subplace_label_halo": "#ffffff",
|
|
73
|
+
"city_label": "#5a6570",
|
|
74
|
+
"city_label_halo": "#ffffff",
|
|
75
|
+
"state_label": "#8a9299",
|
|
76
|
+
"state_label_halo": "#ffffff",
|
|
77
|
+
"country_label": "#5a6570",
|
|
78
|
+
|
|
79
|
+
"address_label": "#8a9299",
|
|
80
|
+
"address_label_halo": "#ffffff",
|
|
81
|
+
|
|
82
|
+
"pois": {
|
|
83
|
+
"blue": "#3498db",
|
|
84
|
+
"green": "#27ae60",
|
|
85
|
+
"lapis": "#9b59b6",
|
|
86
|
+
"pink": "#d63384",
|
|
87
|
+
"red": "#e74c3c",
|
|
88
|
+
"slategray": "#5a6570",
|
|
89
|
+
"tangerine": "#e76f51",
|
|
90
|
+
"turquoise": "#2a9d8f"
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
"landcover": {
|
|
94
|
+
"grassland": "#c8e0c8",
|
|
95
|
+
"barren": "#f5ddb8",
|
|
96
|
+
"urban_area": "#e9e9e6",
|
|
97
|
+
"farmland": "#d0e8d0",
|
|
98
|
+
"glacier": "#f0f8ff",
|
|
99
|
+
"scrub": "#c0dcc0",
|
|
100
|
+
"forest": "#a8d0a8",
|
|
101
|
+
"rock": "#d0ccc8",
|
|
102
|
+
"wetland": "#b8d8d0"
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
"transit_rail": "#888888",
|
|
106
|
+
"transit_freight": "#666666",
|
|
107
|
+
"transit_bus": "#cc7700",
|
|
108
|
+
"transit_heritage": "#9999bb",
|
|
109
|
+
|
|
110
|
+
"shields": {
|
|
111
|
+
"interstate_fill": "#5a7090",
|
|
112
|
+
"interstate_stroke": "#907070",
|
|
113
|
+
"interstate_text": "#f0f0ee",
|
|
114
|
+
"us_highway_fill": "#f0f0ee",
|
|
115
|
+
"us_highway_stroke": "#808080",
|
|
116
|
+
"us_highway_text": "#505050",
|
|
117
|
+
"state_fill": "#f0f0ee",
|
|
118
|
+
"state_stroke": "#808080",
|
|
119
|
+
"state_text": "#505050",
|
|
120
|
+
"county_fill": "#d8d8a0",
|
|
121
|
+
"county_stroke": "#808080",
|
|
122
|
+
"county_text": "#505050",
|
|
123
|
+
"default_fill": "#f0f0ee",
|
|
124
|
+
"default_stroke": "#808080",
|
|
125
|
+
"default_text": "#505050",
|
|
126
|
+
"banner_text": "#505050",
|
|
127
|
+
"banner_text_halo": "#f0f0ee"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"background": "#f8f4f0",
|
|
3
|
+
"earth": "#e9e4df",
|
|
4
|
+
"park_a": "#c8e6c9",
|
|
5
|
+
"park_b": "#c8e6c9",
|
|
6
|
+
"hospital": "#f0e8e8",
|
|
7
|
+
"industrial": "#e0e0e0",
|
|
8
|
+
"school": "#e4ded7",
|
|
9
|
+
"wood_a": "#b8d4a8",
|
|
10
|
+
"wood_b": "#b8d4a8",
|
|
11
|
+
"pedestrian": "#e8e8e8",
|
|
12
|
+
"scrub_a": "#c8d9a8",
|
|
13
|
+
"scrub_b": "#c8d9a8",
|
|
14
|
+
"glacier": "#f0f8ff",
|
|
15
|
+
"sand": "#f4e4c8",
|
|
16
|
+
"beach": "#f4e4c8",
|
|
17
|
+
"aerodrome": "#dadbdf",
|
|
18
|
+
"runway": "#d0ccc8",
|
|
19
|
+
"water": "#a8d5f2",
|
|
20
|
+
"zoo": "#c8e6c9",
|
|
21
|
+
"military": "#dcdcdc",
|
|
22
|
+
|
|
23
|
+
"tunnel_other_casing": "#e5e5e2",
|
|
24
|
+
"tunnel_minor_casing": "#e5e5e2",
|
|
25
|
+
"tunnel_link_casing": "#e0e0dd",
|
|
26
|
+
"tunnel_major_casing": "#dcdcd9",
|
|
27
|
+
"tunnel_highway_casing": "#d8d8d5",
|
|
28
|
+
"tunnel_other": "#cccccc",
|
|
29
|
+
"tunnel_minor": "#ffffff",
|
|
30
|
+
"tunnel_link": "#ffa94d",
|
|
31
|
+
"tunnel_major": "#ffa94d",
|
|
32
|
+
"tunnel_highway": "#ff6b6b",
|
|
33
|
+
|
|
34
|
+
"pier": "#d0d0d0",
|
|
35
|
+
"buildings": "#d0d0d0",
|
|
36
|
+
|
|
37
|
+
"minor_service_casing": "#e5e5e2",
|
|
38
|
+
"minor_casing": "#e5e5e2",
|
|
39
|
+
"link_casing": "#e0e0dd",
|
|
40
|
+
"major_casing_late": "#dcdcd9",
|
|
41
|
+
"highway_casing_late": "#d8d8d5",
|
|
42
|
+
"other": "#888888",
|
|
43
|
+
"minor_service": "#ffffff",
|
|
44
|
+
"minor_a": "#ffffff",
|
|
45
|
+
"minor_b": "#ffffff",
|
|
46
|
+
"link": "#ffa94d",
|
|
47
|
+
"major_casing_early": "#dcdcd9",
|
|
48
|
+
"major": "#ffa94d",
|
|
49
|
+
"highway_casing_early": "#d8d8d5",
|
|
50
|
+
"highway": "#ff6b6b",
|
|
51
|
+
|
|
52
|
+
"railway": "#d5d5d5",
|
|
53
|
+
"boundaries": "#d4b8bc",
|
|
54
|
+
|
|
55
|
+
"bridges_other_casing": "#e5e5e2",
|
|
56
|
+
"bridges_minor_casing": "#e5e5e2",
|
|
57
|
+
"bridges_link_casing": "#e0e0dd",
|
|
58
|
+
"bridges_major_casing": "#dcdcd9",
|
|
59
|
+
"bridges_highway_casing": "#d8d8d5",
|
|
60
|
+
"bridges_other": "#cccccc",
|
|
61
|
+
"bridges_minor": "#ffffff",
|
|
62
|
+
"bridges_link": "#ffa94d",
|
|
63
|
+
"bridges_major": "#ffa94d",
|
|
64
|
+
"bridges_highway": "#ff6b6b",
|
|
65
|
+
|
|
66
|
+
"roads_label_minor": "#8a9299",
|
|
67
|
+
"roads_label_minor_halo": "#ffffff",
|
|
68
|
+
"roads_label_major": "#5a6570",
|
|
69
|
+
"roads_label_major_halo": "#ffffff",
|
|
70
|
+
"ocean_label": "#7a8a92",
|
|
71
|
+
"subplace_label": "#333333",
|
|
72
|
+
"subplace_label_halo": "#ffffff",
|
|
73
|
+
"city_label": "#333333",
|
|
74
|
+
"city_label_halo": "#ffffff",
|
|
75
|
+
"state_label": "#8a9299",
|
|
76
|
+
"state_label_halo": "#ffffff",
|
|
77
|
+
"country_label": "#5a6570",
|
|
78
|
+
|
|
79
|
+
"address_label": "#8a9299",
|
|
80
|
+
"address_label_halo": "#ffffff",
|
|
81
|
+
|
|
82
|
+
"pois": {
|
|
83
|
+
"blue": "#5a7a9a",
|
|
84
|
+
"green": "#6b8e23",
|
|
85
|
+
"lapis": "#8b668b",
|
|
86
|
+
"pink": "#cd5c5c",
|
|
87
|
+
"red": "#b22222",
|
|
88
|
+
"slategray": "#7a6a5a",
|
|
89
|
+
"tangerine": "#d2691e",
|
|
90
|
+
"turquoise": "#5f9ea0"
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
"landcover": {
|
|
94
|
+
"grassland": "#d4e7b8",
|
|
95
|
+
"barren": "#f4e4c8",
|
|
96
|
+
"urban_area": "#e9e4df",
|
|
97
|
+
"farmland": "#d4e7b8",
|
|
98
|
+
"glacier": "#f0f8ff",
|
|
99
|
+
"scrub": "#c8d9a8",
|
|
100
|
+
"forest": "#b8d4a8",
|
|
101
|
+
"rock": "#d8d0c8",
|
|
102
|
+
"wetland": "#c0e0d8"
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
"transit_rail": "#888888",
|
|
106
|
+
"transit_freight": "#666666",
|
|
107
|
+
"transit_bus": "#cc7700",
|
|
108
|
+
"transit_heritage": "#9999bb",
|
|
109
|
+
|
|
110
|
+
"shields": {
|
|
111
|
+
"interstate_fill": "#4a7090",
|
|
112
|
+
"interstate_stroke": "#e07050",
|
|
113
|
+
"interstate_text": "#fff8f0",
|
|
114
|
+
"us_highway_fill": "#fff8f0",
|
|
115
|
+
"us_highway_stroke": "#c06030",
|
|
116
|
+
"us_highway_text": "#5a3020",
|
|
117
|
+
"state_fill": "#fff8f0",
|
|
118
|
+
"state_stroke": "#c06030",
|
|
119
|
+
"state_text": "#5a3020",
|
|
120
|
+
"county_fill": "#ffd060",
|
|
121
|
+
"county_stroke": "#a05020",
|
|
122
|
+
"county_text": "#5a3020",
|
|
123
|
+
"default_fill": "#fff8f0",
|
|
124
|
+
"default_stroke": "#c06030",
|
|
125
|
+
"default_text": "#5a3020",
|
|
126
|
+
"banner_text": "#5a3020",
|
|
127
|
+
"banner_text_halo": "#fff8f0"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"LANDCOVER_FADE_START": 5,
|
|
3
|
+
"LANDCOVER_FADE_END": 7,
|
|
4
|
+
"LANDCOVER_GREEN_START": 5,
|
|
5
|
+
"LANDCOVER_GREEN_END": 8,
|
|
6
|
+
|
|
7
|
+
"PARK_FADE_START": 5,
|
|
8
|
+
"PARK_FADE_END": 8,
|
|
9
|
+
"LANDUSE_FADE_START": 6,
|
|
10
|
+
"LANDUSE_FADE_END": 11,
|
|
11
|
+
|
|
12
|
+
"AEROWAY_MIN": 11,
|
|
13
|
+
|
|
14
|
+
"WATERWAY_STREAM_MIN": 14,
|
|
15
|
+
"WATERWAY_RIVER_MIN": 9,
|
|
16
|
+
|
|
17
|
+
"ROADS_MINOR_SERVICE_MIN": 16,
|
|
18
|
+
"ROADS_LINK_MIN": 13,
|
|
19
|
+
"ROADS_MAJOR_CASING_LATE_MIN": 12,
|
|
20
|
+
"ROADS_MAJOR_CASING_EARLY_MAX": 12,
|
|
21
|
+
"ROADS_HIGHWAY_CASING_LATE_MIN": 12,
|
|
22
|
+
"ROADS_HIGHWAY_CASING_EARLY_MAX": 12,
|
|
23
|
+
"ROADS_BRIDGES_MIN": 12,
|
|
24
|
+
|
|
25
|
+
"TRANSIT_PASSENGER_RAIL_MIN": 10,
|
|
26
|
+
"TRANSIT_FREIGHT_RAIL_MIN": 11,
|
|
27
|
+
"TRANSIT_URBAN_RAIL_MIN": 11,
|
|
28
|
+
"TRANSIT_MIXED_RAIL_MIN": 11,
|
|
29
|
+
"TRANSIT_HERITAGE_MIN": 13,
|
|
30
|
+
"TRANSIT_BUS_MIN": 13,
|
|
31
|
+
"TRANSIT_SERVICE_TRACKS_MIN": 14,
|
|
32
|
+
"TRANSIT_FERRY_MIN": 4,
|
|
33
|
+
|
|
34
|
+
"LABELS_ADDRESS_MIN": 18,
|
|
35
|
+
"LABELS_WATERWAY_MIN": 13,
|
|
36
|
+
"LABELS_ROADS_ONEWAY_MIN": 16,
|
|
37
|
+
"LABELS_ROADS_MINOR_MIN": 15,
|
|
38
|
+
"LABELS_ROADS_MAJOR_MIN": 11,
|
|
39
|
+
"LABELS_POI_MIN": 10
|
|
40
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import type { ExpressionSpecification } from "@maplibre/maplibre-gl-style-spec";
|
|
2
|
+
import featuresConfig from "./config/features.json";
|
|
3
|
+
import poiConfig from "./config/poi.json";
|
|
4
|
+
import zoomConfig from "./config/zoom.json";
|
|
5
|
+
|
|
6
|
+
// ============================================
|
|
7
|
+
// ZOOM LEVEL CONSTANTS (from JSON config)
|
|
8
|
+
// ============================================
|
|
9
|
+
|
|
10
|
+
export const ZOOM = zoomConfig;
|
|
11
|
+
|
|
12
|
+
// ============================================
|
|
13
|
+
// ROAD CLASS CONSTANTS (from JSON config)
|
|
14
|
+
// ============================================
|
|
15
|
+
|
|
16
|
+
export const ROAD_CLASSES = featuresConfig.roadClasses;
|
|
17
|
+
|
|
18
|
+
// ============================================
|
|
19
|
+
// POI TIER CONSTANTS (from JSON config)
|
|
20
|
+
// For progressive disclosure based on zoom level
|
|
21
|
+
// ============================================
|
|
22
|
+
|
|
23
|
+
export const POI_TIERS = poiConfig.tiers;
|
|
24
|
+
|
|
25
|
+
// ============================================
|
|
26
|
+
// POI COLOR CATEGORIES (from JSON config)
|
|
27
|
+
// For matching subclasses to colors
|
|
28
|
+
// ============================================
|
|
29
|
+
|
|
30
|
+
export const POI_CATEGORIES = poiConfig.categories;
|
|
31
|
+
|
|
32
|
+
// ============================================
|
|
33
|
+
// COMMON FILTER PATTERNS
|
|
34
|
+
// ============================================
|
|
35
|
+
|
|
36
|
+
export const FILTERS = {
|
|
37
|
+
// Brunnel (bridge/tunnel) filters
|
|
38
|
+
IS_TUNNEL: ["==", ["get", "brunnel"], "tunnel"] as ExpressionSpecification,
|
|
39
|
+
IS_BRIDGE: ["==", ["get", "brunnel"], "bridge"] as ExpressionSpecification,
|
|
40
|
+
NOT_BRUNNEL: ["!", ["has", "brunnel"]] as ExpressionSpecification,
|
|
41
|
+
|
|
42
|
+
// Ramp (link roads) filter
|
|
43
|
+
IS_RAMP: ["==", ["get", "ramp"], 1] as ExpressionSpecification,
|
|
44
|
+
NOT_RAMP: ["!=", ["get", "ramp"], 1] as ExpressionSpecification,
|
|
45
|
+
|
|
46
|
+
// Geometry type filters
|
|
47
|
+
IS_POLYGON: ["==", "$type", "Polygon"] as ExpressionSpecification,
|
|
48
|
+
IS_LINESTRING: [
|
|
49
|
+
"==",
|
|
50
|
+
["geometry-type"],
|
|
51
|
+
"LineString",
|
|
52
|
+
] as ExpressionSpecification,
|
|
53
|
+
IS_POINT: ["==", ["geometry-type"], "Point"] as ExpressionSpecification,
|
|
54
|
+
} as const;
|
|
55
|
+
|
|
56
|
+
// ============================================
|
|
57
|
+
// LINE WIDTH INTERPOLATIONS
|
|
58
|
+
// Common patterns for road widths
|
|
59
|
+
// ============================================
|
|
60
|
+
|
|
61
|
+
export const LINE_WIDTHS = {
|
|
62
|
+
// Other/path roads
|
|
63
|
+
OTHER: [
|
|
64
|
+
"interpolate",
|
|
65
|
+
["exponential", 1.6],
|
|
66
|
+
["zoom"],
|
|
67
|
+
14,
|
|
68
|
+
0,
|
|
69
|
+
20,
|
|
70
|
+
7,
|
|
71
|
+
] as ExpressionSpecification,
|
|
72
|
+
|
|
73
|
+
// Minor roads
|
|
74
|
+
MINOR: [
|
|
75
|
+
"interpolate",
|
|
76
|
+
["exponential", 1.6],
|
|
77
|
+
["zoom"],
|
|
78
|
+
11,
|
|
79
|
+
0,
|
|
80
|
+
12.5,
|
|
81
|
+
0.5,
|
|
82
|
+
15,
|
|
83
|
+
2,
|
|
84
|
+
18,
|
|
85
|
+
11,
|
|
86
|
+
] as ExpressionSpecification,
|
|
87
|
+
|
|
88
|
+
// Link roads
|
|
89
|
+
LINK: [
|
|
90
|
+
"interpolate",
|
|
91
|
+
["exponential", 1.6],
|
|
92
|
+
["zoom"],
|
|
93
|
+
13,
|
|
94
|
+
0,
|
|
95
|
+
13.5,
|
|
96
|
+
1,
|
|
97
|
+
18,
|
|
98
|
+
11,
|
|
99
|
+
] as ExpressionSpecification,
|
|
100
|
+
|
|
101
|
+
// Major roads
|
|
102
|
+
MAJOR: [
|
|
103
|
+
"interpolate",
|
|
104
|
+
["exponential", 1.6],
|
|
105
|
+
["zoom"],
|
|
106
|
+
6,
|
|
107
|
+
0,
|
|
108
|
+
12,
|
|
109
|
+
1.6,
|
|
110
|
+
15,
|
|
111
|
+
3,
|
|
112
|
+
18,
|
|
113
|
+
13,
|
|
114
|
+
] as ExpressionSpecification,
|
|
115
|
+
|
|
116
|
+
// Highway
|
|
117
|
+
HIGHWAY: [
|
|
118
|
+
"interpolate",
|
|
119
|
+
["exponential", 1.6],
|
|
120
|
+
["zoom"],
|
|
121
|
+
3,
|
|
122
|
+
0,
|
|
123
|
+
6,
|
|
124
|
+
1.1,
|
|
125
|
+
12,
|
|
126
|
+
1.6,
|
|
127
|
+
15,
|
|
128
|
+
5,
|
|
129
|
+
18,
|
|
130
|
+
15,
|
|
131
|
+
] as ExpressionSpecification,
|
|
132
|
+
|
|
133
|
+
// Minor casing gap
|
|
134
|
+
MINOR_CASING_GAP: [
|
|
135
|
+
"interpolate",
|
|
136
|
+
["exponential", 1.6],
|
|
137
|
+
["zoom"],
|
|
138
|
+
11,
|
|
139
|
+
0,
|
|
140
|
+
12.5,
|
|
141
|
+
0.5,
|
|
142
|
+
15,
|
|
143
|
+
2,
|
|
144
|
+
18,
|
|
145
|
+
11,
|
|
146
|
+
] as ExpressionSpecification,
|
|
147
|
+
|
|
148
|
+
// Link casing gap
|
|
149
|
+
LINK_CASING_GAP: [
|
|
150
|
+
"interpolate",
|
|
151
|
+
["exponential", 1.6],
|
|
152
|
+
["zoom"],
|
|
153
|
+
13,
|
|
154
|
+
0,
|
|
155
|
+
13.5,
|
|
156
|
+
1,
|
|
157
|
+
18,
|
|
158
|
+
11,
|
|
159
|
+
] as ExpressionSpecification,
|
|
160
|
+
|
|
161
|
+
// Major casing gap
|
|
162
|
+
MAJOR_CASING_GAP: [
|
|
163
|
+
"interpolate",
|
|
164
|
+
["exponential", 1.6],
|
|
165
|
+
["zoom"],
|
|
166
|
+
7,
|
|
167
|
+
0,
|
|
168
|
+
7.5,
|
|
169
|
+
0.5,
|
|
170
|
+
18,
|
|
171
|
+
13,
|
|
172
|
+
] as ExpressionSpecification,
|
|
173
|
+
|
|
174
|
+
// Highway casing gap
|
|
175
|
+
HIGHWAY_CASING_GAP: [
|
|
176
|
+
"interpolate",
|
|
177
|
+
["exponential", 1.6],
|
|
178
|
+
["zoom"],
|
|
179
|
+
3,
|
|
180
|
+
0,
|
|
181
|
+
3.5,
|
|
182
|
+
0.5,
|
|
183
|
+
18,
|
|
184
|
+
15,
|
|
185
|
+
] as ExpressionSpecification,
|
|
186
|
+
|
|
187
|
+
// Casing width (thin outline)
|
|
188
|
+
CASING_THIN: [
|
|
189
|
+
"interpolate",
|
|
190
|
+
["exponential", 1.6],
|
|
191
|
+
["zoom"],
|
|
192
|
+
12,
|
|
193
|
+
0,
|
|
194
|
+
12.5,
|
|
195
|
+
1,
|
|
196
|
+
] as ExpressionSpecification,
|
|
197
|
+
|
|
198
|
+
CASING_MEDIUM: [
|
|
199
|
+
"interpolate",
|
|
200
|
+
["exponential", 1.6],
|
|
201
|
+
["zoom"],
|
|
202
|
+
9,
|
|
203
|
+
0,
|
|
204
|
+
9.5,
|
|
205
|
+
1,
|
|
206
|
+
] as ExpressionSpecification,
|
|
207
|
+
|
|
208
|
+
CASING_THICK: [
|
|
209
|
+
"interpolate",
|
|
210
|
+
["exponential", 1.6],
|
|
211
|
+
["zoom"],
|
|
212
|
+
7,
|
|
213
|
+
0,
|
|
214
|
+
7.5,
|
|
215
|
+
1,
|
|
216
|
+
20,
|
|
217
|
+
15,
|
|
218
|
+
] as ExpressionSpecification,
|
|
219
|
+
} as const;
|
|
220
|
+
|
|
221
|
+
// ============================================
|
|
222
|
+
// LANDCOVER SUBCLASSES (from JSON config)
|
|
223
|
+
// ============================================
|
|
224
|
+
|
|
225
|
+
export const LANDCOVER_SUBCLASSES = featuresConfig.landcoverSubclasses;
|
|
226
|
+
|
|
227
|
+
// ============================================
|
|
228
|
+
// LANDUSE CLASSES (from JSON config)
|
|
229
|
+
// ============================================
|
|
230
|
+
|
|
231
|
+
export const LANDUSE_CLASSES = featuresConfig.landuseClasses;
|
|
232
|
+
|
|
233
|
+
// ============================================
|
|
234
|
+
// PLACE CLASSES (from JSON config)
|
|
235
|
+
// ============================================
|
|
236
|
+
|
|
237
|
+
export const PLACE_CLASSES = featuresConfig.placeClasses;
|
|
238
|
+
|
|
239
|
+
// ============================================
|
|
240
|
+
// WATER CLASSES (from JSON config)
|
|
241
|
+
// ============================================
|
|
242
|
+
|
|
243
|
+
export const WATER_CLASSES = featuresConfig.waterClasses;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import type { StyleSpecification } from "@maplibre/maplibre-gl-style-spec";
|
|
4
|
+
import {
|
|
5
|
+
type Style,
|
|
6
|
+
type StyleName,
|
|
7
|
+
isValidStyleName,
|
|
8
|
+
layers,
|
|
9
|
+
namedStyle,
|
|
10
|
+
} from "./index";
|
|
11
|
+
|
|
12
|
+
const DEFAULT_ASSETS_URL = "https://assets-dev.geog.dev";
|
|
13
|
+
|
|
14
|
+
export interface GenerateStyleOptions {
|
|
15
|
+
assetsUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function generateStyle(
|
|
19
|
+
args: string[],
|
|
20
|
+
options?: GenerateStyleOptions,
|
|
21
|
+
) {
|
|
22
|
+
if (args.length < 2) {
|
|
23
|
+
throw new TypeError(
|
|
24
|
+
"usage: generate-style OUTPUT TILEJSON_URL [STYLE.js|STYLE.ts|STYLE.json|STYLE_NAME] LANG",
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const assetsUrl = (options?.assetsUrl ?? DEFAULT_ASSETS_URL).replace(
|
|
29
|
+
/\/$/,
|
|
30
|
+
"",
|
|
31
|
+
);
|
|
32
|
+
const tileJson = args[0];
|
|
33
|
+
const styleArg = args[1];
|
|
34
|
+
let spriteValue: StyleName | undefined;
|
|
35
|
+
|
|
36
|
+
let styleObj: Style;
|
|
37
|
+
if (styleArg.endsWith(".json")) {
|
|
38
|
+
styleObj = JSON.parse(fs.readFileSync(styleArg, "utf-8"));
|
|
39
|
+
} else if (styleArg.endsWith(".js") || styleArg.endsWith(".ts")) {
|
|
40
|
+
styleObj = (await import(path.resolve(styleArg))).default;
|
|
41
|
+
} else {
|
|
42
|
+
// Map each style to its corresponding sprite set
|
|
43
|
+
if (isValidStyleName(styleArg)) {
|
|
44
|
+
spriteValue = styleArg;
|
|
45
|
+
}
|
|
46
|
+
styleObj = namedStyle(styleArg);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const lang = args[2];
|
|
50
|
+
|
|
51
|
+
const style: StyleSpecification = {
|
|
52
|
+
version: 8,
|
|
53
|
+
sources: {
|
|
54
|
+
geog: {
|
|
55
|
+
type: "vector",
|
|
56
|
+
attribution:
|
|
57
|
+
'<a href="https://github.com/geogdev/tiles">Geog</a> © <a href="https://osm.org/copyright">OpenStreetMap</a>',
|
|
58
|
+
url: tileJson,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
layers: layers("geog", styleObj, { lang: lang }),
|
|
62
|
+
glyphs: `${assetsUrl}/fonts/{fontstack}/{range}.pbf`,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (spriteValue) {
|
|
66
|
+
style.sprite = `${assetsUrl}/sprites/v0/${spriteValue}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return JSON.stringify(style, null, 2);
|
|
70
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { LayerSpecification } from "@maplibre/maplibre-gl-style-spec";
|
|
2
|
+
import {
|
|
3
|
+
LANGUAGE_SCRIPT_PAIRS,
|
|
4
|
+
getCountryName,
|
|
5
|
+
getMultilineName,
|
|
6
|
+
} from "./language";
|
|
7
|
+
import { labelsLayers, nolabelsLayers } from "./layers";
|
|
8
|
+
import {
|
|
9
|
+
DARK,
|
|
10
|
+
GRAY,
|
|
11
|
+
LIGHT,
|
|
12
|
+
type Landcover,
|
|
13
|
+
type Pois,
|
|
14
|
+
STYLE_NAMES,
|
|
15
|
+
type Shields,
|
|
16
|
+
type Style,
|
|
17
|
+
type StyleName,
|
|
18
|
+
WARM,
|
|
19
|
+
isValidStyleName,
|
|
20
|
+
} from "./styles";
|
|
21
|
+
|
|
22
|
+
// Re-export language utilities
|
|
23
|
+
export { LANGUAGE_SCRIPT_PAIRS, getMultilineName, getCountryName };
|
|
24
|
+
|
|
25
|
+
// Re-export style types and constants
|
|
26
|
+
export type { Landcover, Pois, Shields, Style, StyleName };
|
|
27
|
+
export { LIGHT, DARK, GRAY, WARM, STYLE_NAMES, isValidStyleName };
|
|
28
|
+
|
|
29
|
+
// Re-export layer factories for advanced usage
|
|
30
|
+
export { labelsLayers, nolabelsLayers } from "./layers";
|
|
31
|
+
export * from "./layers";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns a named style by string identifier
|
|
35
|
+
* @throws Error if style name is not found
|
|
36
|
+
*/
|
|
37
|
+
export function namedStyle(name: string): Style {
|
|
38
|
+
if (isValidStyleName(name)) {
|
|
39
|
+
switch (name) {
|
|
40
|
+
case "light":
|
|
41
|
+
return LIGHT;
|
|
42
|
+
case "dark":
|
|
43
|
+
return DARK;
|
|
44
|
+
case "gray":
|
|
45
|
+
return GRAY;
|
|
46
|
+
case "warm":
|
|
47
|
+
return WARM;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Style not found: ${name}. Valid styles are: ${STYLE_NAMES.join(", ")}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Generates all MapLibre GL layers for a given style
|
|
57
|
+
* @param source - The source ID to use for layers
|
|
58
|
+
* @param style - The style theme to apply
|
|
59
|
+
* @param options - Optional configuration
|
|
60
|
+
* @param options.labelsOnly - If true, only generate label layers
|
|
61
|
+
* @param options.lang - Language code for labels (required for label layers)
|
|
62
|
+
*/
|
|
63
|
+
export function layers(
|
|
64
|
+
source: string,
|
|
65
|
+
style: Style,
|
|
66
|
+
options?: { labelsOnly?: boolean; lang?: string },
|
|
67
|
+
): LayerSpecification[] {
|
|
68
|
+
let result: LayerSpecification[] = [];
|
|
69
|
+
if (!options?.labelsOnly) {
|
|
70
|
+
result = nolabelsLayers(source, style);
|
|
71
|
+
}
|
|
72
|
+
if (options?.lang) {
|
|
73
|
+
result = result.concat(labelsLayers(source, style, options.lang));
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|