itowns 2.44.3-next.30 → 2.44.3-next.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/examples/config.json +1 -0
- package/examples/source_file_kml_raster_usgs.html +0 -1
- package/examples/vector_tile_mapbox_raster.html +91 -0
- package/lib/Converter/Feature2Texture.js +3 -0
- package/lib/Core/Style.js +57 -39
- package/lib/Layer/LabelLayer.js +26 -18
- package/lib/Parser/VectorTileParser.js +41 -28
- package/lib/Renderer/Label2DRenderer.js +9 -7
- package/lib/Source/VectorTilesSource.js +29 -17
- package/package.json +1 -1
|
@@ -20,6 +20,15 @@ function mergeCollections(collections) {
|
|
|
20
20
|
return collection;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// A deprecated (but still in use) Mapbox spec allows using 'ref' as a propertie to reference an other layer
|
|
24
|
+
// instead of duplicating the following properties: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'
|
|
25
|
+
function getPropertiesFromRefLayer(layers, layer) {
|
|
26
|
+
const refLayer = layers.filter(l => l.id === layer.ref)[0];
|
|
27
|
+
['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'].forEach(prop => {
|
|
28
|
+
layer[prop] = refLayer[prop];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
/**
|
|
24
33
|
* VectorTilesSource are object containing informations on how to fetch vector
|
|
25
34
|
* tiles resources.
|
|
@@ -69,36 +78,41 @@ class VectorTilesSource extends TMSSource {
|
|
|
69
78
|
let promise;
|
|
70
79
|
this.isVectorTileSource = true;
|
|
71
80
|
this.accessToken = source.accessToken;
|
|
81
|
+
let mvtStyleUrl;
|
|
72
82
|
if (source.style) {
|
|
73
83
|
if (typeof source.style == 'string') {
|
|
74
|
-
|
|
75
|
-
promise = Fetcher.json(
|
|
84
|
+
mvtStyleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken);
|
|
85
|
+
promise = Fetcher.json(mvtStyleUrl, this.networkOptions);
|
|
76
86
|
} else {
|
|
77
87
|
promise = Promise.resolve(source.style);
|
|
78
88
|
}
|
|
79
89
|
} else {
|
|
80
90
|
throw new Error('New VectorTilesSource: style is required');
|
|
81
91
|
}
|
|
82
|
-
this.whenReady = promise.then(
|
|
83
|
-
this.jsonStyle =
|
|
84
|
-
|
|
92
|
+
this.whenReady = promise.then(mvtStyle => {
|
|
93
|
+
this.jsonStyle = mvtStyle;
|
|
94
|
+
let baseurl = source.sprite || mvtStyle.sprite;
|
|
85
95
|
if (baseurl) {
|
|
96
|
+
baseurl = new URL(baseurl, mvtStyleUrl).toString();
|
|
86
97
|
const spriteUrl = urlParser.normalizeSpriteURL(baseurl, '', '.json', this.accessToken);
|
|
87
98
|
return Fetcher.json(spriteUrl, this.networkOptions).then(sprites => {
|
|
88
99
|
this.sprites = sprites;
|
|
89
100
|
const imgUrl = urlParser.normalizeSpriteURL(baseurl, '', '.png', this.accessToken);
|
|
90
101
|
this.sprites.source = imgUrl;
|
|
91
|
-
return
|
|
102
|
+
return mvtStyle;
|
|
92
103
|
});
|
|
93
104
|
}
|
|
94
|
-
return
|
|
95
|
-
}).then(
|
|
96
|
-
|
|
105
|
+
return mvtStyle;
|
|
106
|
+
}).then(mvtStyle => {
|
|
107
|
+
mvtStyle.layers.forEach((layer, order) => {
|
|
97
108
|
layer.sourceUid = this.uid;
|
|
98
109
|
if (layer.type === 'background') {
|
|
99
110
|
this.backgroundLayer = layer;
|
|
100
111
|
} else if (ffilter(layer)) {
|
|
101
|
-
|
|
112
|
+
if (layer['source-layer'] === undefined) {
|
|
113
|
+
getPropertiesFromRefLayer(mvtStyle.layers, layer);
|
|
114
|
+
}
|
|
115
|
+
const style = Style.setFromVectorTileLayer(layer, this.sprites, this.symbolToCircle);
|
|
102
116
|
this.styles[layer.id] = style;
|
|
103
117
|
if (!this.layers[layer['source-layer']]) {
|
|
104
118
|
this.layers[layer['source-layer']] = [];
|
|
@@ -106,20 +120,18 @@ class VectorTilesSource extends TMSSource {
|
|
|
106
120
|
this.layers[layer['source-layer']].push({
|
|
107
121
|
id: layer.id,
|
|
108
122
|
order,
|
|
109
|
-
filterExpression: featureFilter(layer.filter)
|
|
110
|
-
zoom: {
|
|
111
|
-
min: layer.minzoom || 0,
|
|
112
|
-
max: layer.maxzoom || 24
|
|
113
|
-
}
|
|
123
|
+
filterExpression: featureFilter(layer.filter)
|
|
114
124
|
});
|
|
115
125
|
}
|
|
116
126
|
});
|
|
117
127
|
if (this.url == '.') {
|
|
118
|
-
const TMSUrlList = Object.values(
|
|
128
|
+
const TMSUrlList = Object.values(mvtStyle.sources).map(sourceVT => {
|
|
119
129
|
if (sourceVT.url) {
|
|
130
|
+
sourceVT.url = new URL(sourceVT.url, mvtStyleUrl).toString();
|
|
120
131
|
const urlSource = urlParser.normalizeSourceURL(sourceVT.url, this.accessToken);
|
|
121
132
|
return Fetcher.json(urlSource, this.networkOptions).then(tileJSON => {
|
|
122
133
|
if (tileJSON.tiles[0]) {
|
|
134
|
+
tileJSON.tiles[0] = decodeURIComponent(new URL(tileJSON.tiles[0], urlSource).toString());
|
|
123
135
|
return toTMSUrl(tileJSON.tiles[0]);
|
|
124
136
|
}
|
|
125
137
|
});
|
|
@@ -130,7 +142,7 @@ class VectorTilesSource extends TMSSource {
|
|
|
130
142
|
});
|
|
131
143
|
return Promise.all(TMSUrlList);
|
|
132
144
|
}
|
|
133
|
-
return Promise.resolve([this.url]);
|
|
145
|
+
return Promise.resolve([toTMSUrl(this.url)]);
|
|
134
146
|
}).then(TMSUrlList => {
|
|
135
147
|
this.urls = Array.from(new Set(TMSUrlList));
|
|
136
148
|
});
|