ol 10.7.1-dev.1766068548052 → 10.7.1-dev.1766181275580

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.
Files changed (67) hide show
  1. package/Feature.d.ts +2 -2
  2. package/Feature.d.ts.map +1 -1
  3. package/Map.d.ts +4 -4
  4. package/dist/ol.d.ts +4 -0
  5. package/dist/ol.d.ts.map +1 -1
  6. package/dist/ol.js +1 -1
  7. package/dist/ol.js.map +1 -1
  8. package/format/EsriJSON.d.ts +1 -1
  9. package/format/GeoJSON.d.ts +2 -2
  10. package/format/JSONFeature.d.ts +1 -1
  11. package/format/TextFeature.d.ts +1 -1
  12. package/format/TopoJSON.d.ts +1 -1
  13. package/format/WKB.d.ts +1 -1
  14. package/format/XMLFeature.d.ts +1 -1
  15. package/interaction/DragAndDrop.d.ts +1 -1
  16. package/interaction/Draw.d.ts +3 -3
  17. package/interaction/Modify.d.ts +5 -5
  18. package/interaction/Modify.d.ts.map +1 -1
  19. package/interaction/Select.d.ts +1 -1
  20. package/interaction/Select.d.ts.map +1 -1
  21. package/interaction/Snap.d.ts +12 -12
  22. package/interaction/Snap.d.ts.map +1 -1
  23. package/interaction/Translate.d.ts +1 -1
  24. package/interaction/Translate.d.ts.map +1 -1
  25. package/layer/Flow.d.ts +2 -2
  26. package/layer/Heatmap.d.ts +2 -2
  27. package/layer/Layer.d.ts +2 -2
  28. package/layer/Layer.d.ts.map +1 -1
  29. package/layer/Tile.d.ts +1 -1
  30. package/layer/Vector.d.ts +2 -2
  31. package/layer/Vector.d.ts.map +1 -1
  32. package/layer/VectorImage.d.ts +2 -2
  33. package/layer/VectorImage.d.ts.map +1 -1
  34. package/layer/VectorTile.d.ts +2 -2
  35. package/layer/VectorTile.d.ts.map +1 -1
  36. package/layer/WebGLTile.d.ts +3 -3
  37. package/layer/WebGLTile.d.ts.map +1 -1
  38. package/layer/WebGLVector.d.ts +2 -2
  39. package/layer/WebGLVector.d.ts.map +1 -1
  40. package/layer/WebGLVectorTile.d.ts +2 -2
  41. package/layer/WebGLVectorTile.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/render/canvas.d.ts +2 -2
  44. package/renderer/canvas/ImageLayer.d.ts +1 -1
  45. package/renderer/canvas/ImageLayer.d.ts.map +1 -1
  46. package/renderer/canvas/TileLayer.d.ts +1 -1
  47. package/renderer/canvas/VectorTileLayer.d.ts +1 -1
  48. package/source/Cluster.d.ts +2 -2
  49. package/source/GeoTIFF.d.ts +5 -0
  50. package/source/GeoTIFF.d.ts.map +1 -1
  51. package/source/GeoTIFF.js +2 -0
  52. package/source/GeoZarr.d.ts +163 -0
  53. package/source/GeoZarr.d.ts.map +1 -0
  54. package/source/GeoZarr.js +437 -0
  55. package/source/ImageTile.d.ts +1 -1
  56. package/source/TileArcGISRest.d.ts +1 -1
  57. package/source/TileDebug.d.ts +1 -1
  58. package/source/TileWMS.d.ts +1 -1
  59. package/source/UrlTile.d.ts +1 -1
  60. package/source/ogcTileUtil.d.ts +20 -12
  61. package/source/ogcTileUtil.d.ts.map +1 -1
  62. package/source/ogcTileUtil.js +27 -15
  63. package/style/Style.d.ts +1 -1
  64. package/tilegrid/TileGrid.d.ts +5 -0
  65. package/tilegrid/TileGrid.d.ts.map +1 -1
  66. package/tilegrid/TileGrid.js +8 -0
  67. package/util.js +1 -1
@@ -0,0 +1,437 @@
1
+ /**
2
+ * @module ol/source/GeoZarr
3
+ */
4
+
5
+ import {FetchStore, get, open, slice} from 'zarrita';
6
+ import {getCenter} from '../extent.js';
7
+ import {get as getProjection, toUserCoordinate, toUserExtent} from '../proj.js';
8
+ import {toSize} from '../size.js';
9
+ import WMTSTileGrid from '../tilegrid/WMTS.js';
10
+ import DataTileSource from './DataTile.js';
11
+ import {parseTileMatrixSet} from './ogcTileUtil.js';
12
+
13
+ const REQUIRED_ZARR_CONVENTIONS = [
14
+ 'd35379db-88df-4056-af3a-620245f8e347', // multisacles
15
+ 'f17cb550-5864-4468-aeb7-f3180cfb622f', // proj:
16
+ '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', // spatial:
17
+ ];
18
+
19
+ /**
20
+ * @typedef {'nearest'|'linear'} ResampleMethod
21
+ */
22
+
23
+ /**
24
+ * @typedef {Object} Options
25
+ * @property {string} url The Zarr URL.
26
+ * @property {string} group The group with arrays to render.
27
+ * @property {Array<string>} bands The band names to render.
28
+ * @property {import("../proj.js").ProjectionLike} [projection] Source projection. If not provided, the GeoTIFF metadata
29
+ * will be read for projection information.
30
+ * @property {number} [transition=250] Duration of the opacity transition for rendering.
31
+ * To disable the opacity transition, pass `transition: 0`.
32
+ * @property {boolean} [wrapX=false] Render tiles beyond the tile grid extent.
33
+ * @property {ResampleMethod} [resample='nearest'] Resamplilng method if bands are not available for all multi-scale levels.
34
+ */
35
+
36
+ export default class GeoZarr extends DataTileSource {
37
+ /**
38
+ * @param {Options} options The options.
39
+ */
40
+ constructor(options) {
41
+ super({
42
+ state: 'loading',
43
+ tileGrid: null,
44
+ projection: options.projection || null,
45
+ transition: options.transition,
46
+ wrapX: options.wrapX,
47
+ });
48
+
49
+ /**
50
+ * @type {string}
51
+ */
52
+ this.url_ = options.url;
53
+
54
+ /**
55
+ * @type {string}
56
+ */
57
+ this.group_ = options.group;
58
+
59
+ /**
60
+ * @type {Error|null}
61
+ */
62
+ this.error_ = null;
63
+
64
+ /**
65
+ * @type {import('zarrita').Group<any>}
66
+ */
67
+ this.root_ = null;
68
+
69
+ /**
70
+ * @type {any|null}
71
+ */
72
+ this.consolidatedMetadata_ = null;
73
+
74
+ /**
75
+ * @type {Array<string>}
76
+ */
77
+ this.bands_ = options.bands;
78
+
79
+ /**
80
+ * @type {Object<string, Array<string>> | null}
81
+ */
82
+ this.bandsByLevel_ = null;
83
+
84
+ /**
85
+ * @type {number|undefined}
86
+ */
87
+ this.fillValue_;
88
+
89
+ /**
90
+ * @type {ResampleMethod}
91
+ */
92
+ this.resampleMethod_ = options.resample || 'linear';
93
+
94
+ this.setLoader(this.loadTile_.bind(this));
95
+
96
+ /**
97
+ * @type {import("../tilegrid/WMTS.js").default}
98
+ */
99
+ this.tileGrid;
100
+
101
+ this.configure_()
102
+ .then(() => {
103
+ this.setState('ready');
104
+ })
105
+ .catch((err) => {
106
+ this.error_ = err;
107
+ this.setState('error');
108
+ });
109
+ }
110
+
111
+ async configure_() {
112
+ const store = new FetchStore(this.url_);
113
+
114
+ this.root_ = await open(store, {kind: 'group'});
115
+
116
+ try {
117
+ this.consolidatedMetadata_ = JSON.parse(
118
+ new TextDecoder().decode(
119
+ await store.get(this.root_.resolve('zarr.json').path),
120
+ ),
121
+ ).consolidated_metadata.metadata;
122
+ } catch {
123
+ // empty catch block
124
+ }
125
+
126
+ const group = await open(this.root_.resolve(this.group_), {kind: 'group'});
127
+
128
+ const attributes =
129
+ /** @type {LegacyDatasetAttributes | DatasetAttributes} */ (group.attrs);
130
+
131
+ if (
132
+ 'zarr_conventions' in attributes &&
133
+ Array.isArray(attributes.zarr_conventions) &&
134
+ REQUIRED_ZARR_CONVENTIONS.every((uuid) =>
135
+ attributes.zarr_conventions.find((c) => c.uuid === uuid),
136
+ ) &&
137
+ 'layout' in attributes.multiscales
138
+ ) {
139
+ const {tileGrid, projection, bandsByLevel, fillValue} =
140
+ getTileGridInfoFromAttributes(
141
+ /** @type {DatasetAttributes} */ (attributes),
142
+ this.consolidatedMetadata_,
143
+ this.group_,
144
+ this.bands_,
145
+ );
146
+ this.bandsByLevel_ = bandsByLevel;
147
+ this.tileGrid = tileGrid;
148
+ this.projection = projection;
149
+ this.fillValue_ = fillValue;
150
+ } else if ('tile_matrix_set' in attributes.multiscales) {
151
+ const {tileGrid, projection} = getTileGridInfoFromLegacyAttributes(
152
+ /** @type {LegacyDatasetAttributes} */ (attributes),
153
+ );
154
+ this.tileGrid = tileGrid;
155
+ this.projection = projection;
156
+ }
157
+
158
+ const extent = this.tileGrid.getExtent();
159
+ setTimeout(() => {
160
+ this.viewResolver({
161
+ showFullExtent: true,
162
+ projection: this.projection,
163
+ resolutions: this.tileGrid.getResolutions(),
164
+ center: toUserCoordinate(getCenter(extent), this.projection),
165
+ extent: toUserExtent(extent, this.projection),
166
+ zoom: 1,
167
+ });
168
+ });
169
+ }
170
+
171
+ /**
172
+ * @param {number} z The z tile index.
173
+ * @param {number} x The x tile index.
174
+ * @param {number} y The y tile index.
175
+ * @param {import('./DataTile.js').LoaderOptions} options The loader options.
176
+ * @return {Promise} The composed tile data.
177
+ * @private
178
+ */
179
+ async loadTile_(z, x, y, options) {
180
+ const resolutions = this.tileGrid.getResolutions();
181
+ const tileResolution = this.tileGrid.getResolution(z);
182
+ const tileExtent = this.tileGrid.getTileCoordExtent([z, x, y]);
183
+
184
+ const bandPromises = [];
185
+ const bandResolutions = [];
186
+ for (const band of this.bands_) {
187
+ let bandMatrixId;
188
+ let bandResolution;
189
+ let bandZ = 0;
190
+
191
+ if (!this.bandsByLevel_) {
192
+ // TODO: remove this if we stop supporting legacy attributes
193
+ bandMatrixId = this.tileGrid.getMatrixId(z);
194
+ bandResolution = tileResolution;
195
+ bandZ = z;
196
+ } else {
197
+ for (
198
+ let candidateZ = 0;
199
+ candidateZ < resolutions.length;
200
+ candidateZ += 1
201
+ ) {
202
+ const candidateResolution = resolutions[candidateZ];
203
+ if (bandMatrixId && candidateResolution < tileResolution) {
204
+ break;
205
+ }
206
+ const candidateMatrixId = this.tileGrid.getMatrixId(candidateZ);
207
+ if (this.bandsByLevel_[candidateMatrixId].includes(band)) {
208
+ bandMatrixId = candidateMatrixId;
209
+ bandResolution = this.tileGrid.getResolution(candidateZ);
210
+ bandZ = candidateZ;
211
+ }
212
+ }
213
+ }
214
+
215
+ if (!bandMatrixId || !bandResolution) {
216
+ throw new Error(`Could not find available resolution for band ${band}`);
217
+ }
218
+
219
+ const origin = this.tileGrid.getOrigin(bandZ);
220
+ const minCol = Math.round((tileExtent[0] - origin[0]) / bandResolution);
221
+ const maxCol = Math.round((tileExtent[2] - origin[0]) / bandResolution);
222
+
223
+ const minRow = Math.round((origin[1] - tileExtent[3]) / bandResolution);
224
+ const maxRow = Math.round((origin[1] - tileExtent[1]) / bandResolution);
225
+
226
+ const path = `${this.group_}/${bandMatrixId}/${band}`;
227
+ const array = await open(this.root_.resolve(path), {kind: 'array'});
228
+ bandPromises.push(
229
+ get(array, [slice(minRow, maxRow), slice(minCol, maxCol)]),
230
+ );
231
+ bandResolutions.push(bandResolution);
232
+ }
233
+
234
+ const bandChunks = await Promise.all(bandPromises);
235
+ const [tileColCount, tileRowCount] = toSize(this.tileGrid.getTileSize(z));
236
+ return composeData(
237
+ bandChunks,
238
+ bandResolutions,
239
+ tileColCount,
240
+ tileRowCount,
241
+ tileResolution,
242
+ this.resampleMethod_,
243
+ this.fillValue_ || 0,
244
+ );
245
+ }
246
+ }
247
+
248
+ /**
249
+ * @typedef {Object} DatasetAttributes
250
+ * @property {Multiscales} multiscales The multiscales attribute.
251
+ * @property {Array<{uuid: string}>} zarr_conventions The zarr conventions attribute.
252
+ */
253
+
254
+ /**
255
+ * @typedef {Object} Multiscales
256
+ * @property {Object} layout The layout.
257
+ */
258
+
259
+ /**
260
+ * @typedef {Object} LegacyDatasetAttributes
261
+ * @property {LegacyMultiscales} multiscales The multiscales attribute.
262
+ */
263
+
264
+ /**
265
+ * @typedef {Object} LegacyMultiscales
266
+ * @property {any} tile_matrix_limits The tile matrix limits.
267
+ * @property {any} tile_matrix_set The tile matrix set.
268
+ */
269
+
270
+ /**
271
+ * @typedef {Object} TileGridInfo
272
+ * @property {WMTSTileGrid} tileGrid The tile grid.
273
+ * @property {import("../proj/Projection.js").default} projection The projection.
274
+ * @property {Object<string, Array<string>>} [bandsByLevel] Available bands by level.
275
+ * @property {number} [fillValue] The fill value.
276
+ */
277
+
278
+ /**
279
+ * @param {DatasetAttributes} attributes The dataset attributes.
280
+ * @param {any} consolidatedMetadata The consolidated metadata.
281
+ * @param {string} wantedGroup The path to the wanted group.
282
+ * @param {Array<string>} wantedBands The wanted bands.
283
+ * @return {TileGridInfo} The tile grid info.
284
+ */
285
+ function getTileGridInfoFromAttributes(
286
+ attributes,
287
+ consolidatedMetadata,
288
+ wantedGroup,
289
+ wantedBands,
290
+ ) {
291
+ const multiscales = attributes.multiscales;
292
+ const extent = attributes['spatial:bbox'];
293
+ const projection = getProjection(attributes['proj:code']);
294
+ /** @type {Array<{matrixId: string, resolution: number, origin: import("ol/coordinate").Coordinate}>} */
295
+ const groupInfo = [];
296
+ const bandsByLevel = consolidatedMetadata ? {} : null;
297
+ let fillValue;
298
+ for (const groupMetadata of multiscales.layout) {
299
+ //TODO Handle the complete transform (rotation and different x/y resolutions)
300
+ const transform = groupMetadata['spatial:transform'];
301
+ const resolution = transform[0];
302
+ const origin = [transform[2], transform[5]];
303
+ const matrixId = groupMetadata.asset;
304
+ groupInfo.push({
305
+ matrixId,
306
+ resolution,
307
+ origin,
308
+ });
309
+ if (consolidatedMetadata) {
310
+ const availableBands = [];
311
+ for (const band of wantedBands) {
312
+ const bandArray =
313
+ consolidatedMetadata[`${wantedGroup}/${matrixId}/${band}`];
314
+ if (bandArray) {
315
+ availableBands.push(band);
316
+ if (fillValue === undefined) {
317
+ fillValue = bandArray['fill_value'];
318
+ }
319
+ }
320
+ }
321
+ bandsByLevel[matrixId] = availableBands;
322
+ }
323
+ }
324
+ groupInfo.sort((a, b) => b.resolution - a.resolution);
325
+ const tileGrid = new WMTSTileGrid({
326
+ extent: extent,
327
+ origins: groupInfo.map((g) => g.origin),
328
+ resolutions: groupInfo.map((g) => g.resolution),
329
+ matrixIds: groupInfo.map((g) => g.matrixId),
330
+ });
331
+
332
+ return {tileGrid, projection, bandsByLevel, fillValue};
333
+ }
334
+
335
+ /**
336
+ * @param {LegacyDatasetAttributes} attributes The dataset attributes.
337
+ * @return {TileGridInfo} The tile grid info.
338
+ */
339
+ function getTileGridInfoFromLegacyAttributes(attributes) {
340
+ const multiscales = attributes.multiscales;
341
+ const tileMatrixSet = multiscales.tile_matrix_set;
342
+ const tileMatrixLimitsObject = multiscales.tile_matrix_limits;
343
+
344
+ const numMatrices = tileMatrixSet.tileMatrices.length;
345
+ const tileMatrixLimits = new Array(numMatrices);
346
+ let overrideTileSize = false;
347
+ for (let i = 0; i < numMatrices; i += 1) {
348
+ const tileMatrix = tileMatrixSet.tileMatrices[i];
349
+ const tilematrixId = tileMatrix.id;
350
+ if (tileMatrix.tileWidth > 512 || tileMatrix.tileHeight > 512) {
351
+ // Avoid tile sizes that are too large for rendering
352
+ overrideTileSize = true;
353
+ }
354
+ tileMatrixLimits[i] = tileMatrixLimitsObject[tilematrixId];
355
+ }
356
+
357
+ const info = parseTileMatrixSet(
358
+ {},
359
+ tileMatrixSet,
360
+ undefined,
361
+ tileMatrixLimits,
362
+ );
363
+
364
+ let tileGrid = info.grid;
365
+
366
+ // Tile size sanity
367
+ if (overrideTileSize) {
368
+ tileGrid = new WMTSTileGrid({
369
+ tileSize: 512,
370
+ extent: tileGrid.getExtent(),
371
+ origins: tileGrid.getOrigins(),
372
+ resolutions: tileGrid.getResolutions(),
373
+ matrixIds: tileGrid.getMatrixIds(),
374
+ });
375
+ }
376
+ return {tileGrid, projection: info.projection};
377
+ }
378
+
379
+ /**
380
+ * @param {Array<import("zarrita").Chunk<import("zarrita").DataType>>} chunks The input chunks.
381
+ * @param {Array<number>} chunkResolutions The resolutions for each band.
382
+ * @param {number} tileColCount The number of columns in the output data.
383
+ * @param {number} tileRowCount The number of rows in the output data.
384
+ * @param {number} tileResolution The tile resolution.
385
+ * @param {ResampleMethod} resampleMethod The resampling method.
386
+ * @param {number} fillValue The fill value.
387
+ * @return {Float32Array} The tile data.
388
+ */
389
+ function composeData(
390
+ chunks,
391
+ chunkResolutions,
392
+ tileColCount,
393
+ tileRowCount,
394
+ tileResolution,
395
+ resampleMethod,
396
+ fillValue,
397
+ ) {
398
+ const bandCount = chunks.length;
399
+ const tileData = new Float32Array(tileColCount * tileRowCount * bandCount);
400
+ for (let tileRow = 0; tileRow < tileRowCount; tileRow++) {
401
+ for (let tileCol = 0; tileCol < tileColCount; tileCol++) {
402
+ for (let band = 0; band < bandCount; ++band) {
403
+ const chunk = chunks[band];
404
+ const chunkRowCount = chunk.shape[0];
405
+ const chunkColCount = chunk.shape[1];
406
+ const scaleFactor = tileResolution / chunkResolutions[band];
407
+ let value = fillValue;
408
+ if (scaleFactor === 1) {
409
+ if (tileRow < chunkRowCount && tileCol < chunkColCount) {
410
+ value = chunk.data[tileRow * chunkColCount + tileCol];
411
+ }
412
+ } else {
413
+ const chunkRow = tileRow * scaleFactor;
414
+ const chunkCol = tileCol * scaleFactor;
415
+ switch (resampleMethod) {
416
+ case 'nearest': {
417
+ const valueRow = Math.round(chunkRow);
418
+ const valueCol = Math.round(chunkCol);
419
+ if (valueRow < chunkRowCount && valueCol < chunkColCount) {
420
+ value = chunk.data[valueRow * chunkColCount + valueCol];
421
+ }
422
+ break;
423
+ }
424
+ default: {
425
+ throw new Error(`Unsupported resample method: ${resampleMethod}`);
426
+ }
427
+ }
428
+ }
429
+ if (isNaN(value)) {
430
+ value = fillValue;
431
+ }
432
+ tileData[bandCount * (tileRow * tileColCount + tileCol) + band] = value;
433
+ }
434
+ }
435
+ }
436
+ return tileData;
437
+ }
@@ -57,7 +57,7 @@ export type Options = {
57
57
  /**
58
58
  * Tile grid.
59
59
  */
60
- tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
60
+ tileGrid?: import("../tilegrid.js").TileGrid | undefined;
61
61
  /**
62
62
  * The source state.
63
63
  */
@@ -43,7 +43,7 @@ export type Options = {
43
43
  * extent, the grid will be based on that; if not, a grid based on a global
44
44
  * extent with origin at 0,0 will be used.
45
45
  */
46
- tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
46
+ tileGrid?: import("../tilegrid.js").TileGrid | undefined;
47
47
  /**
48
48
  * Projection. Default is the view projection.
49
49
  * The projection code must contain a numeric end portion separated by :
@@ -7,7 +7,7 @@ export type Options = {
7
7
  /**
8
8
  * Tile grid.
9
9
  */
10
- tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
10
+ tileGrid?: import("../tilegrid.js").TileGrid | undefined;
11
11
  /**
12
12
  * Whether to wrap the world horizontally.
13
13
  */
@@ -69,7 +69,7 @@ export type Options = {
69
69
  * extent, the grid will be based on that; if not, a grid based on a global
70
70
  * extent with origin at 0,0 will be used.
71
71
  */
72
- tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
72
+ tileGrid?: import("../tilegrid.js").TileGrid | undefined;
73
73
  /**
74
74
  * The type of
75
75
  * the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
@@ -23,7 +23,7 @@ export type Options = {
23
23
  /**
24
24
  * TileGrid.
25
25
  */
26
- tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
26
+ tileGrid?: import("../tilegrid.js").TileGrid | undefined;
27
27
  /**
28
28
  * TileLoadFunction.
29
29
  */
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * @typedef {Object} TileSetInfo
3
- * @property {string} urlTemplate The tile URL template.
3
+ * @property {string} [urlTemplate] The tile URL template.
4
4
  * @property {import("../proj/Projection.js").default} projection The source projection.
5
- * @property {import("../tilegrid/TileGrid.js").default} grid The tile grid.
6
- * @property {import("../Tile.js").UrlFunction} urlFunction The tile URL function.
5
+ * @property {import("../tilegrid/WMTS.js").default} grid The tile grid.
6
+ * @property {import("../Tile.js").UrlFunction} [urlFunction] The tile URL function.
7
7
  */
8
8
  /**
9
9
  * @typedef {Object} SourceInfo
10
- * @property {string} url The tile set URL.
11
- * @property {string} mediaType The preferred tile media type.
10
+ * @property {string} [url] The tile set URL.
11
+ * @property {string} [mediaType] The preferred tile media type.
12
12
  * @property {Array<string>} [supportedMediaTypes] The supported media types.
13
- * @property {import("../proj/Projection.js").default} projection The source projection.
13
+ * @property {import("../proj/Projection.js").default} [projection] The source projection.
14
14
  * @property {Object} [context] Optional context for constructing the URL.
15
15
  * @property {Array<string>} [collections] Optional collections to append the URL with.
16
16
  */
@@ -35,6 +35,14 @@ export function getMapTileUrlTemplate(links: Array<Link>, mediaType?: string, co
35
35
  * @return {string} The tile URL template.
36
36
  */
37
37
  export function getVectorTileUrlTemplate(links: Array<Link>, mediaType?: string, supportedMediaTypes?: Array<string>, collections?: Array<string>): string;
38
+ /**
39
+ * @param {SourceInfo} sourceInfo The source info.
40
+ * @param {TileMatrixSet} tileMatrixSet Tile matrix set.
41
+ * @param {string} [tileUrlTemplate] Tile URL template.
42
+ * @param {Array<TileMatrixSetLimit>} [tileMatrixSetLimits] Tile matrix set limits.
43
+ * @return {TileSetInfo} Tile set info.
44
+ */
45
+ export function parseTileMatrixSet(sourceInfo: SourceInfo, tileMatrixSet: TileMatrixSet, tileUrlTemplate?: string, tileMatrixSetLimits?: Array<TileMatrixSetLimit>): TileSetInfo;
38
46
  /**
39
47
  * @param {SourceInfo} sourceInfo Source info.
40
48
  * @return {Promise<TileSetInfo>} Tile set info.
@@ -44,7 +52,7 @@ export type TileSetInfo = {
44
52
  /**
45
53
  * The tile URL template.
46
54
  */
47
- urlTemplate: string;
55
+ urlTemplate?: string | undefined;
48
56
  /**
49
57
  * The source projection.
50
58
  */
@@ -52,21 +60,21 @@ export type TileSetInfo = {
52
60
  /**
53
61
  * The tile grid.
54
62
  */
55
- grid: import("../tilegrid/TileGrid.js").default;
63
+ grid: import("../tilegrid/WMTS.js").default;
56
64
  /**
57
65
  * The tile URL function.
58
66
  */
59
- urlFunction: import("../Tile.js").UrlFunction;
67
+ urlFunction?: import("../Tile.js").UrlFunction | undefined;
60
68
  };
61
69
  export type SourceInfo = {
62
70
  /**
63
71
  * The tile set URL.
64
72
  */
65
- url: string;
73
+ url?: string | undefined;
66
74
  /**
67
75
  * The preferred tile media type.
68
76
  */
69
- mediaType: string;
77
+ mediaType?: string | undefined;
70
78
  /**
71
79
  * The supported media types.
72
80
  */
@@ -74,7 +82,7 @@ export type SourceInfo = {
74
82
  /**
75
83
  * The source projection.
76
84
  */
77
- projection: import("../proj/Projection.js").default;
85
+ projection?: import("../proj.js").Projection | undefined;
78
86
  /**
79
87
  * Optional context for constructing the URL.
80
88
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ogcTileUtil.d.ts","sourceRoot":"","sources":["ogcTileUtil.js"],"names":[],"mappings":"AAoGA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,6DAJW,MAAM,eACN,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CA6BjB;AAED;;;;;GAKG;AACH,6CALW,KAAK,CAAC,IAAI,CAAC,cACX,MAAM,gBACN,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CAiCjB;AAED;;;;;;GAMG;AACH,gDANW,KAAK,CAAC,IAAI,CAAC,cACX,MAAM,wBACN,KAAK,CAAC,MAAM,CAAC,gBACb,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CAsDjB;AA0OD;;;GAGG;AACH,2CAHW,UAAU,GACT,OAAO,CAAC,WAAW,CAAC,CAM/B;;;;;iBAtYa,MAAM;;;;gBACN,OAAO,uBAAuB,EAAE,OAAO;;;;UACvC,OAAO,yBAAyB,EAAE,OAAO;;;;iBACzC,OAAO,YAAY,EAAE,WAAW;;;;;;SAKhC,MAAM;;;;eACN,MAAM;;;;;;;;gBAEN,OAAO,uBAAuB,EAAE,OAAO;;;;;;;;;;uBAlGxC,KAAK,GAAG,QAAQ;6BAIhB,SAAS,GAAG,YAAY;;;;;cAKvB,QAAQ;;;;;;;;;;;;;;;;WAIR,KAAK,CAAC,IAAI,CAAC;;;;;;SAKX,MAAM;;;;UACN,MAAM;;;;UACN,MAAM;;;;;;gBAKN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;;;QAKN,MAAM;;;;SACN,MAAM,GAAC,MAAM,GAAC,MAAM,GAAC,kBAAkB;;;;;;;;kBAEvC,KAAK,CAAC,UAAU,CAAC;;;;;;SAKjB,MAAM;;;;;;;;;;;;;;;;;;QAeN,MAAM;;;;cACN,MAAM;;;;mBACN,KAAK,CAAC,MAAM,CAAC;;;;;;;;iBAEb,MAAM;;;;kBACN,MAAM;;;;eACN,MAAM;;;;gBACN,MAAM"}
1
+ {"version":3,"file":"ogcTileUtil.d.ts","sourceRoot":"","sources":["ogcTileUtil.js"],"names":[],"mappings":"AAoGA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,6DAJW,MAAM,eACN,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CA6BjB;AAED;;;;;GAKG;AACH,6CALW,KAAK,CAAC,IAAI,CAAC,cACX,MAAM,gBACN,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CAiCjB;AAED;;;;;;GAMG;AACH,gDANW,KAAK,CAAC,IAAI,CAAC,cACX,MAAM,wBACN,KAAK,CAAC,MAAM,CAAC,gBACb,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CAsDjB;AAED;;;;;;GAMG;AACH,+CANW,UAAU,iBACV,aAAa,oBACb,MAAM,wBACN,KAAK,CAAC,kBAAkB,CAAC,GACxB,WAAW,CAmLtB;AA4DD;;;GAGG;AACH,2CAHW,UAAU,GACT,OAAO,CAAC,WAAW,CAAC,CAM/B;;;;;;;;;gBAjZa,OAAO,uBAAuB,EAAE,OAAO;;;;UACvC,OAAO,qBAAqB,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAzFtC,KAAK,GAAG,QAAQ;6BAIhB,SAAS,GAAG,YAAY;;;;;cAKvB,QAAQ;;;;;;;;;;;;;;;;WAIR,KAAK,CAAC,IAAI,CAAC;;;;;;SAKX,MAAM;;;;UACN,MAAM;;;;UACN,MAAM;;;;;;gBAKN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;;;QAKN,MAAM;;;;SACN,MAAM,GAAC,MAAM,GAAC,MAAM,GAAC,kBAAkB;;;;;;;;kBAEvC,KAAK,CAAC,UAAU,CAAC;;;;;;SAKjB,MAAM;;;;;;;;;;;;;;;;;;QAeN,MAAM;;;;cACN,MAAM;;;;mBACN,KAAK,CAAC,MAAM,CAAC;;;;;;;;iBAEb,MAAM;;;;kBACN,MAAM;;;;eACN,MAAM;;;;gBACN,MAAM"}
@@ -6,7 +6,7 @@ import {error as logError} from '../console.js';
6
6
  import {getIntersection as intersectExtents} from '../extent.js';
7
7
  import {getJSON, resolveUrl} from '../net.js';
8
8
  import {get as getProjection} from '../proj.js';
9
- import TileGrid from '../tilegrid/TileGrid.js';
9
+ import TileGrid from '../tilegrid/WMTS.js';
10
10
 
11
11
  /**
12
12
  * See https://ogcapi.ogc.org/tiles/.
@@ -100,18 +100,18 @@ const knownVectorMediaTypes = {
100
100
 
101
101
  /**
102
102
  * @typedef {Object} TileSetInfo
103
- * @property {string} urlTemplate The tile URL template.
103
+ * @property {string} [urlTemplate] The tile URL template.
104
104
  * @property {import("../proj/Projection.js").default} projection The source projection.
105
- * @property {import("../tilegrid/TileGrid.js").default} grid The tile grid.
106
- * @property {import("../Tile.js").UrlFunction} urlFunction The tile URL function.
105
+ * @property {import("../tilegrid/WMTS.js").default} grid The tile grid.
106
+ * @property {import("../Tile.js").UrlFunction} [urlFunction] The tile URL function.
107
107
  */
108
108
 
109
109
  /**
110
110
  * @typedef {Object} SourceInfo
111
- * @property {string} url The tile set URL.
112
- * @property {string} mediaType The preferred tile media type.
111
+ * @property {string} [url] The tile set URL.
112
+ * @property {string} [mediaType] The preferred tile media type.
113
113
  * @property {Array<string>} [supportedMediaTypes] The supported media types.
114
- * @property {import("../proj/Projection.js").default} projection The source projection.
114
+ * @property {import("../proj/Projection.js").default} [projection] The source projection.
115
115
  * @property {Object} [context] Optional context for constructing the URL.
116
116
  * @property {Array<string>} [collections] Optional collections to append the URL with.
117
117
  */
@@ -253,11 +253,11 @@ export function getVectorTileUrlTemplate(
253
253
  /**
254
254
  * @param {SourceInfo} sourceInfo The source info.
255
255
  * @param {TileMatrixSet} tileMatrixSet Tile matrix set.
256
- * @param {string} tileUrlTemplate Tile URL template.
256
+ * @param {string} [tileUrlTemplate] Tile URL template.
257
257
  * @param {Array<TileMatrixSetLimit>} [tileMatrixSetLimits] Tile matrix set limits.
258
258
  * @return {TileSetInfo} Tile set info.
259
259
  */
260
- function parseTileMatrixSet(
260
+ export function parseTileMatrixSet(
261
261
  sourceInfo,
262
262
  tileMatrixSet,
263
263
  tileUrlTemplate,
@@ -283,7 +283,9 @@ function parseTileMatrixSet(
283
283
  : projection.getAxisOrientation();
284
284
  const backwards = !axisOrientation.startsWith('en');
285
285
 
286
- const matrices = tileMatrixSet.tileMatrices;
286
+ const matrices = tileMatrixSet.tileMatrices.sort(function (a, b) {
287
+ return b.cellSize - a.cellSize;
288
+ });
287
289
 
288
290
  /**
289
291
  * @type {Object<string, TileMatrix>}
@@ -308,7 +310,9 @@ function parseTileMatrixSet(
308
310
  for (let i = 0; i < tileMatrixSetLimits.length; ++i) {
309
311
  const limit = tileMatrixSetLimits[i];
310
312
  const id = limit.tileMatrix;
311
- matrixIds.push(id);
313
+ const matrix = matrixLookup[id];
314
+ const zoomLevel = matrices.indexOf(matrix);
315
+ matrixIds[zoomLevel] = id;
312
316
  limitLookup[id] = limit;
313
317
  }
314
318
  } else {
@@ -361,13 +365,21 @@ function parseTileMatrixSet(
361
365
  }
362
366
 
363
367
  const tileGrid = new TileGrid({
364
- origins: origins,
365
- resolutions: resolutions,
366
- sizes: sizes,
367
- tileSizes: tileSizes,
368
+ origins,
369
+ resolutions,
370
+ sizes,
371
+ tileSizes,
368
372
  extent: tileMatrixSetLimits ? extent : undefined,
373
+ matrixIds,
369
374
  });
370
375
 
376
+ if (!tileUrlTemplate) {
377
+ return {
378
+ grid: tileGrid,
379
+ projection: projection,
380
+ };
381
+ }
382
+
371
383
  const context = sourceInfo.context;
372
384
  const base = sourceInfo.url;
373
385
 
package/style/Style.d.ts CHANGED
@@ -56,7 +56,7 @@ export type Options = {
56
56
  * Feature property or geometry
57
57
  * or function returning a geometry to render for this style.
58
58
  */
59
- geometry?: string | import("../geom/Geometry.js").default | GeometryFunction | undefined;
59
+ geometry?: string | import("../geom.js").Geometry | GeometryFunction | undefined;
60
60
  /**
61
61
  * Fill style.
62
62
  */