ol 10.7.1-dev.1768898466014 → 10.7.1-dev.1769081428801

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "10.7.1-dev.1768898466014",
3
+ "version": "10.7.1-dev.1769081428801",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
@@ -26,7 +26,8 @@
26
26
  "earcut": "^3.0.0",
27
27
  "geotiff": "^2.1.3",
28
28
  "pbf": "4.0.1",
29
- "rbush": "^4.0.0"
29
+ "rbush": "^4.0.0",
30
+ "zarrita": "^0.5.4"
30
31
  },
31
32
  "browserslist": [
32
33
  "> 1%",
@@ -1 +1 @@
1
- {"version":3,"file":"GeoZarr.d.ts","sourceRoot":"","sources":["GeoZarr.js"],"names":[],"mappings":"AAkBA;;GAEG;AAEH;;;;;;;;;;;GAWG;AAEH;IACE;;OAEG;IACH,qBAFW,OAAO,EA4EjB;IAjEC;;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;IASnD;;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;;;;;;;;;;;;6BAlQxC,SAAS,GAAC,QAAQ;;;;;SAKjB,MAAM;;;;WACN,MAAM;;;;WACN,KAAK,CAAC,MAAM,CAAC;;;;;iBACb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;2BAlBtB,eAAe;yBADjB,qBAAqB"}
1
+ {"version":3,"file":"GeoZarr.d.ts","sourceRoot":"","sources":["GeoZarr.js"],"names":[],"mappings":"AAkBA;;GAEG;AAEH;;;;;;;;;;;GAWG;AAEH;IACE;;OAEG;IACH,qBAFW,OAAO,EA4EjB;IAjEC;;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;IASnD;;OAEG;IACH,UAFU,OAAO,qBAAqB,EAAE,OAAO,CAElC;IAYf,4BAmEC;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;;;;;;;;;;;;6BA3QxC,SAAS,GAAC,QAAQ;;;;;SAKjB,MAAM;;;;WACN,MAAM;;;;WACN,KAAK,CAAC,MAAM,CAAC;;;;;iBACb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;2BAlBtB,eAAe;yBADjB,qBAAqB"}
package/source/GeoZarr.js CHANGED
@@ -152,12 +152,21 @@ export default class GeoZarr extends DataTileSource {
152
152
  this.tileGrid = tileGrid;
153
153
  this.projection = projection;
154
154
  this.fillValue_ = fillValue;
155
- } else if ('tile_matrix_set' in attributes.multiscales) {
155
+ }
156
+ if ('tile_matrix_set' in attributes.multiscales) {
157
+ // If available, use tile_matrix_set (legacy attributes) to get a tile grid, because it
158
+ // provides a better mapping of tiles to zarr chunks.
156
159
  const {tileGrid, projection} = getTileGridInfoFromLegacyAttributes(
157
160
  /** @type {LegacyDatasetAttributes} */ (attributes),
158
161
  );
159
162
  this.tileGrid = tileGrid;
160
- this.projection = projection;
163
+ if (!this.projection) {
164
+ // If there were no required zarr conventions, we don't have a projection yet
165
+ this.projection = projection;
166
+ }
167
+ }
168
+ if (!this.tileGrid) {
169
+ throw new Error('Could not determine tile grid');
161
170
  }
162
171
 
163
172
  const extent = this.tileGrid.getExtent();
@@ -426,6 +435,27 @@ function composeData(
426
435
  }
427
436
  break;
428
437
  }
438
+ case 'linear': {
439
+ const row0 = Math.floor(chunkRow);
440
+ const col0 = Math.floor(chunkCol);
441
+ if (row0 < chunkRowCount && col0 < chunkColCount) {
442
+ const row1 = Math.min(row0 + 1, chunkRowCount - 1);
443
+ const col1 = Math.min(col0 + 1, chunkColCount - 1);
444
+
445
+ const v00 = chunk.data[row0 * chunkColCount + col0];
446
+ const v01 = chunk.data[row0 * chunkColCount + col1];
447
+ const v10 = chunk.data[row1 * chunkColCount + col0];
448
+ const v11 = chunk.data[row1 * chunkColCount + col1];
449
+
450
+ const dx = chunkCol - col0;
451
+ const dy = chunkRow - row0;
452
+
453
+ value =
454
+ (1 - dy) * ((1 - dx) * v00 + dx * v01) +
455
+ dy * ((1 - dx) * v10 + dx * v11);
456
+ }
457
+ break;
458
+ }
429
459
  default: {
430
460
  throw new Error(`Unsupported resample method: ${resampleMethod}`);
431
461
  }
@@ -0,0 +1,170 @@
1
+ export default OGCMap;
2
+ export type Options = {
3
+ /**
4
+ * Attributions.
5
+ */
6
+ attributions?: import("./Source.js").AttributionLike | undefined;
7
+ /**
8
+ * The `crossOrigin` attribute for loaded images. Note that
9
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
10
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
11
+ */
12
+ crossOrigin?: string | null | undefined;
13
+ /**
14
+ * Use the `ol/Map#pixelRatio` value when requesting
15
+ * the image from the remote server.
16
+ */
17
+ hidpi?: boolean | undefined;
18
+ /**
19
+ * Optional function to load an image given a URL.
20
+ */
21
+ imageLoadFunction?: import("../Image.js").LoadFunction | undefined;
22
+ /**
23
+ * Use interpolated values when resampling. By default,
24
+ * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
25
+ */
26
+ interpolate?: boolean | undefined;
27
+ /**
28
+ * OGC Maps request parameters.
29
+ * No param is required by default. `width`, `height`, `bbox`, `crs` and `bbox-crs` will be set dynamically.
30
+ */
31
+ params?: {
32
+ [x: string]: any;
33
+ } | undefined;
34
+ /**
35
+ * Projection. Default is the view projection.
36
+ */
37
+ projection?: import("../proj.js").ProjectionLike;
38
+ /**
39
+ * Ratio. `1` means image requests are the size of the map viewport, `2` means
40
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
41
+ */
42
+ ratio?: number | undefined;
43
+ /**
44
+ * Resolutions.
45
+ * If specified, requests will be made for these resolutions only.
46
+ */
47
+ resolutions?: number[] | undefined;
48
+ /**
49
+ * OGC Maps service URL.
50
+ */
51
+ url?: string | undefined;
52
+ };
53
+ /**
54
+ * @typedef {Object} Options
55
+ * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
56
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
57
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
58
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
59
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
60
+ * the image from the remote server.
61
+ * @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
62
+ * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
63
+ * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
64
+ * @property {Object<string,*>} [params] OGC Maps request parameters.
65
+ * No param is required by default. `width`, `height`, `bbox`, `crs` and `bbox-crs` will be set dynamically.
66
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
67
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
68
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
69
+ * @property {Array<number>} [resolutions] Resolutions.
70
+ * If specified, requests will be made for these resolutions only.
71
+ * @property {string} [url] OGC Maps service URL.
72
+ */
73
+ /**
74
+ * @classdesc
75
+ * Source for OGC Maps servers providing single, untiled images.
76
+ *
77
+ * @fires module:ol/source/Image.ImageSourceEvent
78
+ * @api
79
+ */
80
+ declare class OGCMap extends ImageSource {
81
+ /**
82
+ * @param {Options} [options] OGCMapOptions options.
83
+ */
84
+ constructor(options?: Options);
85
+ /**
86
+ * @private
87
+ * @type {?string}
88
+ */
89
+ private crossOrigin_;
90
+ /**
91
+ * @private
92
+ * @type {string|undefined}
93
+ */
94
+ private url_;
95
+ /**
96
+ * @private
97
+ * @type {import("../Image.js").LoadFunction}
98
+ */
99
+ private imageLoadFunction_;
100
+ /**
101
+ * @private
102
+ * @type {!Object}
103
+ */
104
+ private params_;
105
+ /**
106
+ * @private
107
+ * @type {boolean}
108
+ */
109
+ private hidpi_;
110
+ /**
111
+ * @private
112
+ * @type {number}
113
+ */
114
+ private renderedRevision_;
115
+ /**
116
+ * @private
117
+ * @type {number}
118
+ */
119
+ private ratio_;
120
+ /**
121
+ * @private
122
+ * @type {import("../proj/Projection.js").default}
123
+ */
124
+ private loaderProjection_;
125
+ /**
126
+ * Get the user-provided params, i.e. those passed to the constructor through
127
+ * the "params" option, and possibly updated using the updateParams method.
128
+ * @return {Object} Params.
129
+ * @api
130
+ */
131
+ getParams(): any;
132
+ /**
133
+ * Return the image load function of the source.
134
+ * @return {import("../Image.js").LoadFunction} The image load function.
135
+ * @api
136
+ */
137
+ getImageLoadFunction(): import("../Image.js").LoadFunction;
138
+ /**
139
+ * Return the URL used for this OGC Maps source.
140
+ * @return {string|undefined} URL.
141
+ * @api
142
+ */
143
+ getUrl(): string | undefined;
144
+ /**
145
+ * Set the image load function of the source.
146
+ * @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
147
+ * @api
148
+ */
149
+ setImageLoadFunction(imageLoadFunction: import("../Image.js").LoadFunction): void;
150
+ /**
151
+ * Set the URL to use for requests.
152
+ * @param {string|undefined} url URL.
153
+ * @api
154
+ */
155
+ setUrl(url: string | undefined): void;
156
+ /**
157
+ * Set the user-provided params.
158
+ * @param {Object} params Params.
159
+ * @api
160
+ */
161
+ setParams(params: any): void;
162
+ /**
163
+ * Update the user-provided params.
164
+ * @param {Object} params Params.
165
+ * @api
166
+ */
167
+ updateParams(params: any): void;
168
+ }
169
+ import ImageSource from './Image.js';
170
+ //# sourceMappingURL=OGCMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OGCMap.d.ts","sourceRoot":"","sources":["OGCMap.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqBc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;AAbjD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,sBAFW,OAAO,EA+DjB;IAnDC;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,2BAG8B;IAE9B;;;OAGG;IACH,gBAAgD;IAEhD;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,eAA+D;IAE/D;;;OAGG;IACH,0BAA6B;IAG/B;;;;;OAKG;IACH,iBAEC;IAmCD;;;;OAIG;IACH,wBAHY,OAAO,aAAa,EAAE,YAAY,CAK7C;IAED;;;;OAIG;IACH,UAHY,MAAM,GAAC,SAAS,CAK3B;IAED;;;;OAIG;IACH,wCAHW,OAAO,aAAa,EAAE,YAAY,QAM5C;IAED;;;;OAIG;IACH,YAHW,MAAM,GAAC,SAAS,QAS1B;IAED;;;;OAIG;IACH,6BAKC;IAED;;;;OAIG;IACH,gCAGC;CASF;wBAnNmD,YAAY"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @module ol/source/OGCMap
3
+ */
4
+
5
+ import {decode} from '../Image.js';
6
+ import ImageSource, {defaultImageLoadFunction} from './Image.js';
7
+ import {createLoader} from './ogcMapUtil.js';
8
+
9
+ /**
10
+ * @typedef {Object} Options
11
+ * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
12
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
13
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
14
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
15
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
16
+ * the image from the remote server.
17
+ * @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
18
+ * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
19
+ * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
20
+ * @property {Object<string,*>} [params] OGC Maps request parameters.
21
+ * No param is required by default. `width`, `height`, `bbox`, `crs` and `bbox-crs` will be set dynamically.
22
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
23
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
24
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
25
+ * @property {Array<number>} [resolutions] Resolutions.
26
+ * If specified, requests will be made for these resolutions only.
27
+ * @property {string} [url] OGC Maps service URL.
28
+ */
29
+
30
+ /**
31
+ * @classdesc
32
+ * Source for OGC Maps servers providing single, untiled images.
33
+ *
34
+ * @fires module:ol/source/Image.ImageSourceEvent
35
+ * @api
36
+ */
37
+ class OGCMap extends ImageSource {
38
+ /**
39
+ * @param {Options} [options] OGCMapOptions options.
40
+ */
41
+ constructor(options) {
42
+ options = options ? options : {};
43
+
44
+ super({
45
+ attributions: options.attributions,
46
+ interpolate: options.interpolate,
47
+ projection: options.projection,
48
+ resolutions: options.resolutions,
49
+ });
50
+
51
+ /**
52
+ * @private
53
+ * @type {?string}
54
+ */
55
+ this.crossOrigin_ =
56
+ options.crossOrigin !== undefined ? options.crossOrigin : null;
57
+
58
+ /**
59
+ * @private
60
+ * @type {string|undefined}
61
+ */
62
+ this.url_ = options.url;
63
+
64
+ /**
65
+ * @private
66
+ * @type {import("../Image.js").LoadFunction}
67
+ */
68
+ this.imageLoadFunction_ =
69
+ options.imageLoadFunction !== undefined
70
+ ? options.imageLoadFunction
71
+ : defaultImageLoadFunction;
72
+
73
+ /**
74
+ * @private
75
+ * @type {!Object}
76
+ */
77
+ this.params_ = Object.assign({}, options.params);
78
+
79
+ /**
80
+ * @private
81
+ * @type {boolean}
82
+ */
83
+ this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
84
+
85
+ /**
86
+ * @private
87
+ * @type {number}
88
+ */
89
+ this.renderedRevision_ = 0;
90
+
91
+ /**
92
+ * @private
93
+ * @type {number}
94
+ */
95
+ this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
96
+
97
+ /**
98
+ * @private
99
+ * @type {import("../proj/Projection.js").default}
100
+ */
101
+ this.loaderProjection_ = null;
102
+ }
103
+
104
+ /**
105
+ * Get the user-provided params, i.e. those passed to the constructor through
106
+ * the "params" option, and possibly updated using the updateParams method.
107
+ * @return {Object} Params.
108
+ * @api
109
+ */
110
+ getParams() {
111
+ return this.params_;
112
+ }
113
+
114
+ /**
115
+ * @param {import("../extent.js").Extent} extent Extent.
116
+ * @param {number} resolution Resolution.
117
+ * @param {number} pixelRatio Pixel ratio.
118
+ * @param {import("../proj/Projection.js").default} projection Projection.
119
+ * @return {import("../Image.js").default} Single image.
120
+ * @override
121
+ */
122
+ getImageInternal(extent, resolution, pixelRatio, projection) {
123
+ if (this.url_ === undefined) {
124
+ return null;
125
+ }
126
+ if (!this.loader || this.loaderProjection_ !== projection) {
127
+ // Lazily create loader to pick up the view projection and to allow `params` updates
128
+ this.loaderProjection_ = projection;
129
+ this.loader = createLoader({
130
+ crossOrigin: this.crossOrigin_,
131
+ params: this.params_,
132
+ projection: projection,
133
+ hidpi: this.hidpi_,
134
+ url: this.url_,
135
+ ratio: this.ratio_,
136
+ load: (image, src) => {
137
+ this.image.setImage(image);
138
+ this.imageLoadFunction_(this.image, src);
139
+ return decode(image);
140
+ },
141
+ });
142
+ }
143
+
144
+ return super.getImageInternal(extent, resolution, pixelRatio, projection);
145
+ }
146
+
147
+ /**
148
+ * Return the image load function of the source.
149
+ * @return {import("../Image.js").LoadFunction} The image load function.
150
+ * @api
151
+ */
152
+ getImageLoadFunction() {
153
+ return this.imageLoadFunction_;
154
+ }
155
+
156
+ /**
157
+ * Return the URL used for this OGC Maps source.
158
+ * @return {string|undefined} URL.
159
+ * @api
160
+ */
161
+ getUrl() {
162
+ return this.url_;
163
+ }
164
+
165
+ /**
166
+ * Set the image load function of the source.
167
+ * @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
168
+ * @api
169
+ */
170
+ setImageLoadFunction(imageLoadFunction) {
171
+ this.imageLoadFunction_ = imageLoadFunction;
172
+ this.changed();
173
+ }
174
+
175
+ /**
176
+ * Set the URL to use for requests.
177
+ * @param {string|undefined} url URL.
178
+ * @api
179
+ */
180
+ setUrl(url) {
181
+ if (url != this.url_) {
182
+ this.url_ = url;
183
+ this.loader = null;
184
+ this.changed();
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Set the user-provided params.
190
+ * @param {Object} params Params.
191
+ * @api
192
+ */
193
+ setParams(params) {
194
+ this.params_ = Object.assign({}, params);
195
+ // Reset loader to pick up new params
196
+ this.loader = null;
197
+ this.changed();
198
+ }
199
+
200
+ /**
201
+ * Update the user-provided params.
202
+ * @param {Object} params Params.
203
+ * @api
204
+ */
205
+ updateParams(params) {
206
+ Object.assign(this.params_, params);
207
+ this.changed();
208
+ }
209
+
210
+ /**
211
+ * @override
212
+ */
213
+ changed() {
214
+ this.image = null;
215
+ super.changed();
216
+ }
217
+ }
218
+
219
+ export default OGCMap;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @param {string} baseUrl Base URL.
3
+ * @param {import("../extent.js").Extent} extent Extent.
4
+ * @param {import("../size.js").Size} size Size.
5
+ * @param {import("../proj/Projection.js").default} projection Projection.
6
+ * @param {Object} params OGC Map params. Will be modified in place.
7
+ * @return {string} Request URL.
8
+ */
9
+ export function getRequestUrl(baseUrl: string, extent: import("../extent.js").Extent, size: import("../size.js").Size, projection: import("../proj/Projection.js").default, params: any): string;
10
+ /**
11
+ * @param {import("../extent").Extent} extent Extent.
12
+ * @param {number} resolution Resolution.
13
+ * @param {number} pixelRatio pixel ratio.
14
+ * @param {import("../proj.js").Projection} projection Projection.
15
+ * @param {string} url OGC Map service url.
16
+ * @param {Object} params OGC Map params.
17
+ * @return {string} Image src.
18
+ */
19
+ export function getImageSrc(extent: import("../extent").Extent, resolution: number, pixelRatio: number, projection: import("../proj.js").Projection, url: string, params: any): string;
20
+ /**
21
+ * @typedef {Object} LoaderOptions
22
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
23
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
24
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
25
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
26
+ * the image from the remote server.
27
+ * @property {Object<string,*>} [params] OGC Map request parameters.
28
+ * No param is required by default. `width`, `height`, `bbox`, `crs` and `bbox-crs` will be set dynamically.
29
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is 'EPSG:3857'.
30
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
31
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
32
+ * @property {string} url OGC Map service URL.
33
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
34
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
35
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
36
+ */
37
+ /**
38
+ * Creates a loader for OGC Map images.
39
+ * @param {LoaderOptions} options Loader options.
40
+ * @return {import("../Image.js").ImageObjectPromiseLoader} Loader.
41
+ * @api
42
+ */
43
+ export function createLoader(options: LoaderOptions): import("../Image.js").ImageObjectPromiseLoader;
44
+ export type LoaderOptions = {
45
+ /**
46
+ * The `crossOrigin` attribute for loaded images. Note that
47
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
48
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
49
+ */
50
+ crossOrigin?: string | null | undefined;
51
+ /**
52
+ * Use the `ol/Map#pixelRatio` value when requesting
53
+ * the image from the remote server.
54
+ */
55
+ hidpi?: boolean | undefined;
56
+ /**
57
+ * OGC Map request parameters.
58
+ * No param is required by default. `width`, `height`, `bbox`, `crs` and `bbox-crs` will be set dynamically.
59
+ */
60
+ params?: {
61
+ [x: string]: any;
62
+ } | undefined;
63
+ /**
64
+ * Projection. Default is 'EPSG:3857'.
65
+ */
66
+ projection?: import("../proj.js").ProjectionLike;
67
+ /**
68
+ * Ratio. `1` means image requests are the size of the map viewport, `2` means
69
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
70
+ */
71
+ ratio?: number | undefined;
72
+ /**
73
+ * OGC Map service URL.
74
+ */
75
+ url: string;
76
+ /**
77
+ * Function
78
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
79
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module :ol/Image.decode}.
80
+ */
81
+ load?: ((arg0: HTMLImageElement, arg1: string) => Promise<import("../DataTile.js").ImageLike>) | undefined;
82
+ };
83
+ //# sourceMappingURL=ogcMapUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ogcMapUtil.d.ts","sourceRoot":"","sources":["ogcMapUtil.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,uCAPW,MAAM,UACN,OAAO,cAAc,EAAE,MAAM,QAC7B,OAAO,YAAY,EAAE,IAAI,cACzB,OAAO,uBAAuB,EAAE,OAAO,gBAEtC,MAAM,CAejB;AAED;;;;;;;;GAQG;AACH,oCARW,OAAO,WAAW,EAAE,MAAM,cAC1B,MAAM,cACN,MAAM,cACN,OAAO,YAAY,EAAE,UAAU,OAC/B,MAAM,gBAEL,MAAM,CAwBjB;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AACH,sCAJW,aAAa,GACZ,OAAO,aAAa,EAAE,wBAAwB,CA2BzD;;;;;;;;;;;;;;;;;;;;;;;iBAvCa,OAAO,YAAY,EAAE,cAAc;;;;;;;;;SAGnC,MAAM;;;;;;mBACG,gBAAgB,QAAE,MAAM,KAAG,OAAO,CAAC,OAAO,gBAAgB,EAAE,SAAS,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @module ol/source/ogcMapUtil
3
+ */
4
+
5
+ import {decode} from '../Image.js';
6
+ import {getHeight, getWidth} from '../extent.js';
7
+ import {round} from '../math.js';
8
+ import {get as getProjection} from '../proj.js';
9
+ import {appendParams} from '../uri.js';
10
+ import {getRequestExtent} from './Image.js';
11
+ import {DECIMALS} from './common.js';
12
+
13
+ /**
14
+ * @param {string} baseUrl Base URL.
15
+ * @param {import("../extent.js").Extent} extent Extent.
16
+ * @param {import("../size.js").Size} size Size.
17
+ * @param {import("../proj/Projection.js").default} projection Projection.
18
+ * @param {Object} params OGC Map params. Will be modified in place.
19
+ * @return {string} Request URL.
20
+ */
21
+ export function getRequestUrl(baseUrl, extent, size, projection, params) {
22
+ params['width'] = size[0];
23
+ params['height'] = size[1];
24
+
25
+ const axisOrientation = projection.getAxisOrientation();
26
+ params['crs'] = projection.getCode();
27
+ params['bbox-crs'] = projection.getCode();
28
+ const bbox = axisOrientation.startsWith('ne')
29
+ ? [extent[1], extent[0], extent[3], extent[2]]
30
+ : extent;
31
+ params['bbox'] = bbox.join(',');
32
+
33
+ return appendParams(baseUrl, params);
34
+ }
35
+
36
+ /**
37
+ * @param {import("../extent").Extent} extent Extent.
38
+ * @param {number} resolution Resolution.
39
+ * @param {number} pixelRatio pixel ratio.
40
+ * @param {import("../proj.js").Projection} projection Projection.
41
+ * @param {string} url OGC Map service url.
42
+ * @param {Object} params OGC Map params.
43
+ * @return {string} Image src.
44
+ */
45
+ export function getImageSrc(
46
+ extent,
47
+ resolution,
48
+ pixelRatio,
49
+ projection,
50
+ url,
51
+ params,
52
+ ) {
53
+ params = Object.assign({}, params);
54
+
55
+ const imageResolution = resolution / pixelRatio;
56
+
57
+ const imageSize = [
58
+ round(getWidth(extent) / imageResolution, DECIMALS),
59
+ round(getHeight(extent) / imageResolution, DECIMALS),
60
+ ];
61
+
62
+ if (pixelRatio !== 1) {
63
+ params['mm-per-pixel'] = 0.28 / pixelRatio;
64
+ }
65
+
66
+ return getRequestUrl(url, extent, imageSize, projection, params);
67
+ }
68
+
69
+ /**
70
+ * @typedef {Object} LoaderOptions
71
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
72
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
73
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
74
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
75
+ * the image from the remote server.
76
+ * @property {Object<string,*>} [params] OGC Map request parameters.
77
+ * No param is required by default. `width`, `height`, `bbox`, `crs` and `bbox-crs` will be set dynamically.
78
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is 'EPSG:3857'.
79
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
80
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
81
+ * @property {string} url OGC Map service URL.
82
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
83
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
84
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
85
+ */
86
+
87
+ /**
88
+ * Creates a loader for OGC Map images.
89
+ * @param {LoaderOptions} options Loader options.
90
+ * @return {import("../Image.js").ImageObjectPromiseLoader} Loader.
91
+ * @api
92
+ */
93
+ export function createLoader(options) {
94
+ const hidpi = options.hidpi === undefined ? true : options.hidpi;
95
+ const projection = getProjection(options.projection || 'EPSG:3857');
96
+ const ratio = options.ratio || 1.5;
97
+ const load = options.load || decode;
98
+ const crossOrigin = options.crossOrigin ?? null;
99
+
100
+ return (extent, resolution, pixelRatio) => {
101
+ extent = getRequestExtent(extent, resolution, pixelRatio, ratio);
102
+ if (pixelRatio !== 1 && !hidpi) {
103
+ pixelRatio = 1;
104
+ }
105
+ const src = getImageSrc(
106
+ extent,
107
+ resolution,
108
+ pixelRatio,
109
+ projection,
110
+ options.url,
111
+ options.params,
112
+ );
113
+ const image = new Image();
114
+ image.crossOrigin = crossOrigin;
115
+ return load(image, src).then((image) => ({image, extent, pixelRatio}));
116
+ };
117
+ }
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '10.7.1-dev.1768898466014';
36
+ export const VERSION = '10.7.1-dev.1769081428801';