ol 10.7.1-dev.1766142301376 → 10.7.1-dev.1766335921056
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/Feature.d.ts +2 -2
- package/Feature.d.ts.map +1 -1
- package/Map.d.ts +4 -4
- package/dist/ol.d.ts +4 -0
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/format/EsriJSON.d.ts +1 -1
- package/format/GeoJSON.d.ts +2 -2
- package/format/JSONFeature.d.ts +1 -1
- package/format/TextFeature.d.ts +1 -1
- package/format/TopoJSON.d.ts +1 -1
- package/format/WKB.d.ts +1 -1
- package/format/XMLFeature.d.ts +1 -1
- package/interaction/DragAndDrop.d.ts +1 -1
- package/interaction/Draw.d.ts +3 -3
- package/interaction/Modify.d.ts +5 -5
- package/interaction/Modify.d.ts.map +1 -1
- package/interaction/Select.d.ts +1 -1
- package/interaction/Select.d.ts.map +1 -1
- package/interaction/Snap.d.ts +12 -12
- package/interaction/Snap.d.ts.map +1 -1
- package/interaction/Translate.d.ts +1 -1
- package/interaction/Translate.d.ts.map +1 -1
- package/layer/Flow.d.ts +2 -2
- package/layer/Heatmap.d.ts +2 -2
- package/layer/Layer.d.ts +2 -2
- package/layer/Layer.d.ts.map +1 -1
- package/layer/Tile.d.ts +1 -1
- package/layer/Vector.d.ts +2 -2
- package/layer/Vector.d.ts.map +1 -1
- package/layer/VectorImage.d.ts +2 -2
- package/layer/VectorImage.d.ts.map +1 -1
- package/layer/VectorTile.d.ts +2 -2
- package/layer/VectorTile.d.ts.map +1 -1
- package/layer/WebGLTile.d.ts +3 -3
- package/layer/WebGLTile.d.ts.map +1 -1
- package/layer/WebGLVector.d.ts +2 -2
- package/layer/WebGLVector.d.ts.map +1 -1
- package/layer/WebGLVectorTile.d.ts +2 -2
- package/layer/WebGLVectorTile.d.ts.map +1 -1
- package/package.json +1 -1
- package/render/canvas.d.ts +2 -2
- package/renderer/canvas/ImageLayer.d.ts +1 -1
- package/renderer/canvas/ImageLayer.d.ts.map +1 -1
- package/renderer/canvas/TileLayer.d.ts +1 -1
- package/renderer/canvas/VectorTileLayer.d.ts +1 -1
- package/source/Cluster.d.ts +2 -2
- package/source/GeoZarr.d.ts +163 -0
- package/source/GeoZarr.d.ts.map +1 -0
- package/source/GeoZarr.js +437 -0
- package/source/ImageTile.d.ts +1 -1
- package/source/TileArcGISRest.d.ts +1 -1
- package/source/TileDebug.d.ts +1 -1
- package/source/TileWMS.d.ts +1 -1
- package/source/UrlTile.d.ts +1 -1
- package/source/ogcTileUtil.d.ts +20 -12
- package/source/ogcTileUtil.d.ts.map +1 -1
- package/source/ogcTileUtil.js +27 -15
- package/style/Style.d.ts +1 -1
- package/tilegrid/TileGrid.d.ts +5 -0
- package/tilegrid/TileGrid.d.ts.map +1 -1
- package/tilegrid/TileGrid.js +8 -0
- package/util.js +1 -1
package/render/canvas.d.ts
CHANGED
|
@@ -351,11 +351,11 @@ export type TextState = {
|
|
|
351
351
|
/**
|
|
352
352
|
* BackgroundFill.
|
|
353
353
|
*/
|
|
354
|
-
backgroundFill?: import("../style
|
|
354
|
+
backgroundFill?: import("../style.js").Fill | undefined;
|
|
355
355
|
/**
|
|
356
356
|
* BackgroundStroke.
|
|
357
357
|
*/
|
|
358
|
-
backgroundStroke?: import("../style
|
|
358
|
+
backgroundStroke?: import("../style.js").Stroke | undefined;
|
|
359
359
|
/**
|
|
360
360
|
* Scale.
|
|
361
361
|
*/
|
|
@@ -8,7 +8,7 @@ declare class CanvasImageLayerRenderer extends CanvasLayerRenderer<any> {
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {import("../../layer/Image.js").default} imageLayer Image layer.
|
|
10
10
|
*/
|
|
11
|
-
constructor(imageLayer: import("../../layer
|
|
11
|
+
constructor(imageLayer: import("../../layer.js").Image<any>);
|
|
12
12
|
/**
|
|
13
13
|
* @protected
|
|
14
14
|
* @type {?import("../../Image.js").default}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageLayer.d.ts","sourceRoot":"","sources":["ImageLayer.js"],"names":[],"mappings":";AAqBA;;;;GAIG;AACH;IACE;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"ImageLayer.d.ts","sourceRoot":"","sources":["ImageLayer.js"],"names":[],"mappings":";AAqBA;;;;GAIG;AACH;IACE;;OAEG;IACH,6DAQC;IALC;;;OAGG;IACH,iBAFW,OAAO,gBAAgB,EAAE,OAAO,OAAA,CAE1B;IAGnB;;OAEG;IACH,YAFY,OAAO,mBAAmB,EAAE,SAAS,CAIhD;IAsDD;;;;OAIG;IACH,wBAJW,OAAO,gBAAgB,EAAE,KAAK,GAC7B,iBAAiB,CA0C5B;IAED;;;;;;OAMG;IACH,iCALW,OAAO,cAAc,EAAE,UAAU,UACjC,WAAW,GACV,WAAW,CAuFtB;CACF;gCA1N+B,YAAY"}
|
|
@@ -19,7 +19,7 @@ export type Options = {
|
|
|
19
19
|
* @template {import("../../layer/Tile.js").default|import("../../layer/VectorTile.js").default} [LayerType=import("../../layer/Tile.js").default<import("../../source/Tile.js").default>|import("../../layer/VectorTile.js").default]
|
|
20
20
|
* @extends {CanvasLayerRenderer<LayerType>}
|
|
21
21
|
*/
|
|
22
|
-
declare class CanvasTileLayerRenderer<LayerType extends import("../../layer/Tile.js").default | import("../../layer/VectorTile.js").default = import("../../layer
|
|
22
|
+
declare class CanvasTileLayerRenderer<LayerType extends import("../../layer/Tile.js").default | import("../../layer/VectorTile.js").default = import("../../layer.js").Tile<import("../../source.js").Tile<import("../../Tile.js").default>> | import("../../layer.js").VectorTile<import("../../source.js").VectorTile<any>, any>> extends CanvasLayerRenderer<LayerType> {
|
|
23
23
|
/**
|
|
24
24
|
* @param {LayerType} tileLayer Tile layer.
|
|
25
25
|
* @param {Options} [options] Options.
|
|
@@ -5,7 +5,7 @@ export default CanvasVectorTileLayerRenderer;
|
|
|
5
5
|
* @api
|
|
6
6
|
* @extends {CanvasTileLayerRenderer<import("../../layer/VectorTile.js").default<import('../../source/VectorTile.js').default<import('../../Feature.js').FeatureLike>>>}
|
|
7
7
|
*/
|
|
8
|
-
declare class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer<import("../../layer
|
|
8
|
+
declare class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer<import("../../layer.js").VectorTile<import("../../source.js").VectorTile<import("../../Feature.js").FeatureLike>, import("../../Feature.js").FeatureLike>> {
|
|
9
9
|
/**
|
|
10
10
|
* @param {import("../../layer/VectorTile.js").default} layer VectorTile layer.
|
|
11
11
|
* @param {import("./TileLayer.js").Options} options Options.
|
package/source/Cluster.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default Cluster;
|
|
2
2
|
export type GeometryFunction<FeatureType extends import("../Feature.js").FeatureLike = import("../Feature.js").FeatureLike> = (feature: FeatureType) => (Point | null);
|
|
3
|
-
export type Options<FeatureType extends import("../Feature.js").FeatureLike = Feature<import("../geom
|
|
3
|
+
export type Options<FeatureType extends import("../Feature.js").FeatureLike = Feature<import("../geom.js").Geometry>> = {
|
|
4
4
|
/**
|
|
5
5
|
* Attributions.
|
|
6
6
|
*/
|
|
@@ -112,7 +112,7 @@ export type Options<FeatureType extends import("../Feature.js").FeatureLike = Fe
|
|
|
112
112
|
* @template {import('../Feature.js').FeatureLike} [FeatureType=import('../Feature.js').default]
|
|
113
113
|
* @extends {VectorSource<Feature<import("../geom/Geometry.js").default>>}
|
|
114
114
|
*/
|
|
115
|
-
declare class Cluster<FeatureType extends import("../Feature.js").FeatureLike = Feature<import("../geom
|
|
115
|
+
declare class Cluster<FeatureType extends import("../Feature.js").FeatureLike = Feature<import("../geom.js").Geometry>> extends VectorSource<Feature<import("../geom.js").Geometry>> {
|
|
116
116
|
/**
|
|
117
117
|
* @param {Options<FeatureType>} [options] Cluster options.
|
|
118
118
|
*/
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {'nearest'|'linear'} ResampleMethod
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Options
|
|
6
|
+
* @property {string} url The Zarr URL.
|
|
7
|
+
* @property {string} group The group with arrays to render.
|
|
8
|
+
* @property {Array<string>} bands The band names to render.
|
|
9
|
+
* @property {import("../proj.js").ProjectionLike} [projection] Source projection. If not provided, the GeoTIFF metadata
|
|
10
|
+
* will be read for projection information.
|
|
11
|
+
* @property {number} [transition=250] Duration of the opacity transition for rendering.
|
|
12
|
+
* To disable the opacity transition, pass `transition: 0`.
|
|
13
|
+
* @property {boolean} [wrapX=false] Render tiles beyond the tile grid extent.
|
|
14
|
+
* @property {ResampleMethod} [resample='nearest'] Resamplilng method if bands are not available for all multi-scale levels.
|
|
15
|
+
*/
|
|
16
|
+
export default class GeoZarr extends DataTileSource<import("../DataTile.js").default> {
|
|
17
|
+
/**
|
|
18
|
+
* @param {Options} options The options.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options: Options);
|
|
21
|
+
/**
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
url_: string;
|
|
25
|
+
/**
|
|
26
|
+
* @type {string}
|
|
27
|
+
*/
|
|
28
|
+
group_: string;
|
|
29
|
+
/**
|
|
30
|
+
* @type {Error|null}
|
|
31
|
+
*/
|
|
32
|
+
error_: Error | null;
|
|
33
|
+
/**
|
|
34
|
+
* @type {import('zarrita').Group<any>}
|
|
35
|
+
*/
|
|
36
|
+
root_: import("zarrita").Group<any>;
|
|
37
|
+
/**
|
|
38
|
+
* @type {any|null}
|
|
39
|
+
*/
|
|
40
|
+
consolidatedMetadata_: any | null;
|
|
41
|
+
/**
|
|
42
|
+
* @type {Array<string>}
|
|
43
|
+
*/
|
|
44
|
+
bands_: Array<string>;
|
|
45
|
+
/**
|
|
46
|
+
* @type {Object<string, Array<string>> | null}
|
|
47
|
+
*/
|
|
48
|
+
bandsByLevel_: {
|
|
49
|
+
[x: string]: Array<string>;
|
|
50
|
+
} | null;
|
|
51
|
+
/**
|
|
52
|
+
* @type {number|undefined}
|
|
53
|
+
*/
|
|
54
|
+
fillValue_: number | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* @type {ResampleMethod}
|
|
57
|
+
*/
|
|
58
|
+
resampleMethod_: ResampleMethod;
|
|
59
|
+
/**
|
|
60
|
+
* @type {import("../tilegrid/WMTS.js").default}
|
|
61
|
+
*/
|
|
62
|
+
tileGrid: import("../tilegrid/WMTS.js").default;
|
|
63
|
+
configure_(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* @param {number} z The z tile index.
|
|
66
|
+
* @param {number} x The x tile index.
|
|
67
|
+
* @param {number} y The y tile index.
|
|
68
|
+
* @param {import('./DataTile.js').LoaderOptions} options The loader options.
|
|
69
|
+
* @return {Promise} The composed tile data.
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
private loadTile_;
|
|
73
|
+
}
|
|
74
|
+
export type DatasetAttributes = {
|
|
75
|
+
/**
|
|
76
|
+
* The multiscales attribute.
|
|
77
|
+
*/
|
|
78
|
+
multiscales: Multiscales;
|
|
79
|
+
/**
|
|
80
|
+
* The zarr conventions attribute.
|
|
81
|
+
*/
|
|
82
|
+
zarr_conventions: Array<{
|
|
83
|
+
uuid: string;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
export type Multiscales = {
|
|
87
|
+
/**
|
|
88
|
+
* The layout.
|
|
89
|
+
*/
|
|
90
|
+
layout: any;
|
|
91
|
+
};
|
|
92
|
+
export type LegacyDatasetAttributes = {
|
|
93
|
+
/**
|
|
94
|
+
* The multiscales attribute.
|
|
95
|
+
*/
|
|
96
|
+
multiscales: LegacyMultiscales;
|
|
97
|
+
};
|
|
98
|
+
export type LegacyMultiscales = {
|
|
99
|
+
/**
|
|
100
|
+
* The tile matrix limits.
|
|
101
|
+
*/
|
|
102
|
+
tile_matrix_limits: any;
|
|
103
|
+
/**
|
|
104
|
+
* The tile matrix set.
|
|
105
|
+
*/
|
|
106
|
+
tile_matrix_set: any;
|
|
107
|
+
};
|
|
108
|
+
export type TileGridInfo = {
|
|
109
|
+
/**
|
|
110
|
+
* The tile grid.
|
|
111
|
+
*/
|
|
112
|
+
tileGrid: WMTSTileGrid;
|
|
113
|
+
/**
|
|
114
|
+
* The projection.
|
|
115
|
+
*/
|
|
116
|
+
projection: import("../proj/Projection.js").default;
|
|
117
|
+
/**
|
|
118
|
+
* Available bands by level.
|
|
119
|
+
*/
|
|
120
|
+
bandsByLevel?: {
|
|
121
|
+
[x: string]: string[];
|
|
122
|
+
} | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* The fill value.
|
|
125
|
+
*/
|
|
126
|
+
fillValue?: number | undefined;
|
|
127
|
+
};
|
|
128
|
+
export type ResampleMethod = "nearest" | "linear";
|
|
129
|
+
export type Options = {
|
|
130
|
+
/**
|
|
131
|
+
* The Zarr URL.
|
|
132
|
+
*/
|
|
133
|
+
url: string;
|
|
134
|
+
/**
|
|
135
|
+
* The group with arrays to render.
|
|
136
|
+
*/
|
|
137
|
+
group: string;
|
|
138
|
+
/**
|
|
139
|
+
* The band names to render.
|
|
140
|
+
*/
|
|
141
|
+
bands: Array<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Source projection. If not provided, the GeoTIFF metadata
|
|
144
|
+
* will be read for projection information.
|
|
145
|
+
*/
|
|
146
|
+
projection?: import("../proj.js").ProjectionLike;
|
|
147
|
+
/**
|
|
148
|
+
* Duration of the opacity transition for rendering.
|
|
149
|
+
* To disable the opacity transition, pass `transition: 0`.
|
|
150
|
+
*/
|
|
151
|
+
transition?: number | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Render tiles beyond the tile grid extent.
|
|
154
|
+
*/
|
|
155
|
+
wrapX?: boolean | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Resamplilng method if bands are not available for all multi-scale levels.
|
|
158
|
+
*/
|
|
159
|
+
resample?: ResampleMethod | undefined;
|
|
160
|
+
};
|
|
161
|
+
import DataTileSource from './DataTile.js';
|
|
162
|
+
import WMTSTileGrid from '../tilegrid/WMTS.js';
|
|
163
|
+
//# sourceMappingURL=GeoZarr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeoZarr.d.ts","sourceRoot":"","sources":["GeoZarr.js"],"names":[],"mappings":"AAkBA;;GAEG;AAEH;;;;;;;;;;;GAWG;AAEH;IACE;;OAEG;IACH,qBAFW,OAAO,EAuEjB;IA5DC;;OAEG;IACH,MAFU,MAAM,CAEO;IAEvB;;OAEG;IACH,QAFU,MAAM,CAEW;IAE3B;;OAEG;IACH,QAFU,KAAK,GAAC,IAAI,CAEF;IAElB;;OAEG;IACH,OAFU,OAAO,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAErB;IAEjB;;OAEG;IACH,uBAFU,GAAG,GAAC,IAAI,CAEe;IAEjC;;OAEG;IACH,QAFU,KAAK,CAAC,MAAM,CAAC,CAEI;IAE3B;;OAEG;IACH,eAFU;YAAO,MAAM,GAAE,KAAK,CAAC,MAAM,CAAC;KAAC,GAAG,IAAI,CAErB;IAEzB;;OAEG;IACH,YAFU,MAAM,GAAC,SAAS,CAEX;IAEf;;OAEG;IACH,iBAFU,cAAc,CAE2B;IAInD;;OAEG;IACH,UAFU,OAAO,qBAAqB,EAAE,OAAO,CAElC;IAYf,4BA0DC;IAED;;;;;;;OAOG;IACH,kBAkEC;CACF;;;;;iBAIa,WAAW;;;;sBACX,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC;;;;;;;;;;;;iBAUrB,iBAAiB;;;;;;wBAKjB,GAAG;;;;qBACH,GAAG;;;;;;cAKH,YAAY;;;;gBACZ,OAAO,uBAAuB,EAAE,OAAO;;;;;;;;;;;;6BA7PxC,SAAS,GAAC,QAAQ;;;;;SAKjB,MAAM;;;;WACN,MAAM;;;;WACN,KAAK,CAAC,MAAM,CAAC;;;;;iBACb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;2BAlBtB,eAAe;yBADjB,qBAAqB"}
|
|
@@ -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
|
+
}
|
package/source/ImageTile.d.ts
CHANGED
|
@@ -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
|
|
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 :
|