ol 7.5.1 → 8.0.0-dev.1692052111884
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/DataTile.d.ts +2 -2
- package/DataTile.d.ts.map +1 -1
- package/DataTile.js +3 -2
- package/Image.d.ts +139 -40
- package/Image.d.ts.map +1 -1
- package/Image.js +194 -96
- package/ImageCanvas.d.ts +2 -2
- package/ImageCanvas.d.ts.map +1 -1
- package/ImageCanvas.js +2 -2
- package/Object.d.ts +7 -0
- package/Object.d.ts.map +1 -1
- package/Object.js +8 -0
- package/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/expr/cpu.d.ts +71 -0
- package/expr/cpu.d.ts.map +1 -0
- package/expr/cpu.js +312 -0
- package/expr/expression.d.ts +97 -0
- package/expr/expression.d.ts.map +1 -0
- package/expr/expression.js +373 -0
- package/has.d.ts +5 -0
- package/has.d.ts.map +1 -1
- package/has.js +6 -0
- package/index.d.ts +1 -2
- package/index.js +1 -1
- package/layer/Base.d.ts +12 -8
- package/layer/Base.d.ts.map +1 -1
- package/layer/Base.js +12 -8
- package/layer/BaseVector.d.ts.map +1 -1
- package/layer/BaseVector.js +67 -33
- package/layer/Heatmap.d.ts.map +1 -1
- package/layer/Heatmap.js +16 -55
- package/layer/Layer.d.ts +2 -2
- package/layer/Layer.d.ts.map +1 -1
- package/layer/Layer.js +1 -1
- package/layer/WebGLPoints.d.ts +7 -12
- package/layer/WebGLPoints.d.ts.map +1 -1
- package/layer/WebGLPoints.js +7 -12
- package/package.json +1 -1
- package/render/Feature.d.ts +8 -0
- package/render/Feature.d.ts.map +1 -1
- package/render/Feature.js +9 -0
- package/render/canvas/Immediate.d.ts.map +1 -1
- package/render/canvas/Immediate.js +5 -3
- package/render/canvas/TextBuilder.js +2 -2
- package/render/canvas/style.d.ts +69 -0
- package/render/canvas/style.d.ts.map +1 -0
- package/render/canvas/style.js +1192 -0
- package/render/canvas.js +1 -1
- package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
- package/render/webgl/VectorStyleRenderer.js +4 -0
- package/renderer/Layer.d.ts +2 -2
- package/renderer/Layer.d.ts.map +1 -1
- package/renderer/Layer.js +1 -1
- package/renderer/canvas/ImageLayer.d.ts +4 -4
- package/renderer/canvas/ImageLayer.d.ts.map +1 -1
- package/renderer/canvas/ImageLayer.js +17 -12
- package/renderer/canvas/Layer.d.ts +2 -2
- package/renderer/canvas/Layer.d.ts.map +1 -1
- package/renderer/canvas/Layer.js +1 -1
- package/renderer/canvas/VectorImageLayer.d.ts.map +1 -1
- package/renderer/canvas/VectorImageLayer.js +3 -2
- package/renderer/webgl/VectorLayer.d.ts +1 -2
- package/renderer/webgl/VectorLayer.d.ts.map +1 -1
- package/reproj/Image.d.ts +5 -5
- package/reproj/Image.d.ts.map +1 -1
- package/reproj/Image.js +6 -6
- package/reproj.d.ts +2 -2
- package/reproj.d.ts.map +1 -1
- package/reproj.js +1 -1
- package/resolution.d.ts +13 -0
- package/resolution.d.ts.map +1 -0
- package/resolution.js +18 -0
- package/source/Image.d.ts +44 -7
- package/source/Image.d.ts.map +1 -1
- package/source/Image.js +97 -8
- package/source/ImageArcGISRest.d.ts +0 -23
- package/source/ImageArcGISRest.d.ts.map +1 -1
- package/source/ImageArcGISRest.js +18 -120
- package/source/ImageMapGuide.d.ts +0 -24
- package/source/ImageMapGuide.d.ts.map +1 -1
- package/source/ImageMapGuide.js +21 -113
- package/source/ImageStatic.d.ts +2 -27
- package/source/ImageStatic.d.ts.map +1 -1
- package/source/ImageStatic.js +20 -70
- package/source/ImageWMS.d.ts +2 -46
- package/source/ImageWMS.d.ts.map +1 -1
- package/source/ImageWMS.js +43 -201
- package/source/{Stamen.d.ts → StadiaMaps.d.ts} +17 -7
- package/source/StadiaMaps.d.ts.map +1 -0
- package/source/{Stamen.js → StadiaMaps.js} +85 -38
- package/source/TileArcGISRest.d.ts.map +1 -1
- package/source/TileArcGISRest.js +11 -22
- package/source/TileWMS.d.ts +0 -1
- package/source/TileWMS.d.ts.map +1 -1
- package/source/TileWMS.js +43 -106
- package/source/arcgisRest.d.ts +88 -0
- package/source/arcgisRest.d.ts.map +1 -0
- package/source/arcgisRest.js +131 -0
- package/source/common.d.ts +5 -0
- package/source/common.d.ts.map +1 -1
- package/source/common.js +6 -0
- package/source/mapguide.d.ts +52 -0
- package/source/mapguide.d.ts.map +1 -0
- package/source/mapguide.js +116 -0
- package/source/static.d.ts +45 -0
- package/source/static.d.ts.map +1 -0
- package/source/static.js +44 -0
- package/source/wms.d.ts +109 -1
- package/source/wms.d.ts.map +1 -1
- package/source/wms.js +170 -0
- package/source.d.ts +5 -1
- package/source.d.ts.map +1 -1
- package/source.js +5 -1
- package/style/flat.d.ts +332 -173
- package/style/flat.d.ts.map +1 -1
- package/style/flat.js +176 -248
- package/style/literal.d.ts +27 -72
- package/style/literal.d.ts.map +1 -1
- package/style/literal.js +14 -35
- package/util.d.ts.map +1 -1
- package/util.js +1 -1
- package/webgl/Helper.d.ts +7 -2
- package/webgl/Helper.d.ts.map +1 -1
- package/webgl/Helper.js +16 -27
- package/webgl/ShaderBuilder.d.ts +4 -14
- package/webgl/ShaderBuilder.d.ts.map +1 -1
- package/webgl/ShaderBuilder.js +72 -72
- package/webgl/styleparser.d.ts +3 -9
- package/webgl/styleparser.d.ts.map +1 -1
- package/webgl/styleparser.js +503 -88
- package/ImageBase.d.ts +0 -65
- package/ImageBase.d.ts.map +0 -1
- package/ImageBase.js +0 -98
- package/source/Stamen.d.ts.map +0 -1
package/DataTile.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} ImageLike
|
|
2
|
+
* @typedef {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|ImageBitmap} ImageLike
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {Uint8Array|Uint8ClampedArray|Float32Array|DataView} ArrayLike
|
|
@@ -24,7 +24,7 @@ export function asArrayLike(data: Data): ArrayLike | null;
|
|
|
24
24
|
*/
|
|
25
25
|
export function toArray(image: ImageLike): Uint8ClampedArray;
|
|
26
26
|
export default DataTile;
|
|
27
|
-
export type ImageLike = HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;
|
|
27
|
+
export type ImageLike = HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;
|
|
28
28
|
export type ArrayLike = Uint8Array | Uint8ClampedArray | Float32Array | DataView;
|
|
29
29
|
/**
|
|
30
30
|
* Data that can be used with a DataTile.
|
package/DataTile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["DataTile.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AACH,kCAHW,IAAI,GACH,SAAS,GAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["DataTile.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AACH,kCAHW,IAAI,GACH,SAAS,GAAC,IAAI,CASzB;AAED;;;GAGG;AACH,kCAHW,IAAI,GACH,SAAS,GAAC,IAAI,CASzB;AAOD;;;GAGG;AACH,+BAHW,SAAS,GACR,iBAAiB,CAuB5B;;wBApEY,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,WAAW;wBAI/D,UAAU,GAAC,iBAAiB,GAAC,YAAY,GAAC,QAAQ;;;;mBAKlD,SAAS,GAAC,SAAS;;;;;eAoElB,OAAO,gBAAgB,EAAE,SAAS;;;;;kBACtB,QAAQ,IAAI,CAAC;;;;;;;;;;;;;;;;AAHvC;;;;;;;;;;;GAWG;AAEH;IACE;;OAEG;IACH,qBAFW,OAAO,EAiCjB;IAvBC;;;OAGG;IACH,gBAA6B;IAE7B;;;OAGG;IACH,cAAiB;IAEjB;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,cAAiC;IAGnC;;;OAGG;IACH,WAFY,OAAO,WAAW,EAAE,IAAI,CAWnC;IAED;;;;OAIG;IACH,WAHY,IAAI,CAKf;IAED;;;;OAIG;IACH,YAHY,KAAK,CAKhB;CA0BF;iBA3LgB,WAAW"}
|
package/DataTile.js
CHANGED
|
@@ -6,7 +6,7 @@ import TileState from './TileState.js';
|
|
|
6
6
|
import {createCanvasContext2D} from './dom.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @typedef {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} ImageLike
|
|
9
|
+
* @typedef {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|ImageBitmap} ImageLike
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -25,7 +25,8 @@ import {createCanvasContext2D} from './dom.js';
|
|
|
25
25
|
export function asImageLike(data) {
|
|
26
26
|
return data instanceof Image ||
|
|
27
27
|
data instanceof HTMLCanvasElement ||
|
|
28
|
-
data instanceof HTMLVideoElement
|
|
28
|
+
data instanceof HTMLVideoElement ||
|
|
29
|
+
data instanceof ImageBitmap
|
|
29
30
|
? data
|
|
30
31
|
: null;
|
|
31
32
|
}
|
package/Image.d.ts
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {
|
|
2
|
+
* @param {import('./DataTile.js').ImageLike} image Image element.
|
|
3
3
|
* @param {function():any} loadHandler Load callback function.
|
|
4
4
|
* @param {function():any} errorHandler Error callback function.
|
|
5
5
|
* @return {function():void} Callback to stop listening.
|
|
6
6
|
*/
|
|
7
|
-
export function listenImage(image:
|
|
7
|
+
export function listenImage(image: import('./DataTile.js').ImageLike, loadHandler: () => any, errorHandler: () => any): () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Loads an image.
|
|
10
|
+
* @param {HTMLImageElement} image Image, not yet loaded.
|
|
11
|
+
* @param {string} [src] `src` attribute of the image. Optional, not required if already present.
|
|
12
|
+
* @return {Promise<HTMLImageElement>} Promise resolving to an `HTMLImageElement`.
|
|
13
|
+
* @api
|
|
14
|
+
*/
|
|
15
|
+
export function load(image: HTMLImageElement, src?: string | undefined): Promise<HTMLImageElement>;
|
|
16
|
+
/**
|
|
17
|
+
* @param {HTMLImageElement} image Image, not yet loaded.
|
|
18
|
+
* @param {string} [src] `src` attribute of the image. Optional, not required if already present.
|
|
19
|
+
* @return {Promise<HTMLImageElement>} Promise resolving to an `HTMLImageElement`.
|
|
20
|
+
*/
|
|
21
|
+
export function decodeFallback(image: HTMLImageElement, src?: string | undefined): Promise<HTMLImageElement>;
|
|
22
|
+
/**
|
|
23
|
+
* Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns
|
|
24
|
+
* the laoded image otherwise.
|
|
25
|
+
* @param {HTMLImageElement} image Image, not yet loaded.
|
|
26
|
+
* @param {string} [src] `src` attribute of the image. Optional, not required if already present.
|
|
27
|
+
* @return {Promise<ImageBitmap|HTMLImageElement>} Promise resolving to an `ImageBitmap` or an
|
|
28
|
+
* `HTMLImageElement` if `createImageBitmap()` is not supported.
|
|
29
|
+
* @api
|
|
30
|
+
*/
|
|
31
|
+
export function decode(image: HTMLImageElement, src?: string | undefined): Promise<ImageBitmap | HTMLImageElement>;
|
|
8
32
|
export default ImageWrapper;
|
|
9
33
|
/**
|
|
10
34
|
* A function that takes an {@link module :ol/Image~ImageWrapper} for the image and a
|
|
@@ -20,7 +44,41 @@ export default ImageWrapper;
|
|
|
20
44
|
* post requests or - in general - through XHR requests, where the src of the
|
|
21
45
|
* image element would be set to a data URI when the content is loaded.
|
|
22
46
|
*/
|
|
23
|
-
export type LoadFunction = (arg0:
|
|
47
|
+
export type LoadFunction = (arg0: import("./Image.js").default, arg1: string) => void;
|
|
48
|
+
export type ImageObject = {
|
|
49
|
+
/**
|
|
50
|
+
* Extent, if different from the requested one.
|
|
51
|
+
*/
|
|
52
|
+
extent?: import("./extent.js").Extent | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Resolution, if different from the requested one.
|
|
55
|
+
* When x and y resolution are different, use the array type (`[xResolution, yResolution]`).
|
|
56
|
+
*/
|
|
57
|
+
resolution?: import("./resolution.js").ResolutionLike | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Pixel ratio, if different from the requested one.
|
|
60
|
+
*/
|
|
61
|
+
pixelRatio?: number | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Image.
|
|
64
|
+
*/
|
|
65
|
+
image: import('./DataTile.js').ImageLike;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.
|
|
69
|
+
* The function returns an {@link import ("./DataTile.js").ImageLike image}, an
|
|
70
|
+
* {@link import ("./Image.js").ImageObject image object}, or a promise for the same.
|
|
71
|
+
* For loaders that generate images, the promise should not resolve until the image is loaded.
|
|
72
|
+
* If the returned image does not match the extent, resolution or pixel ratio passed to the loader,
|
|
73
|
+
* it has to return an {@link import ("./Image.js").ImageObject image object} with the `image` and the
|
|
74
|
+
* correct `extent`, `resolution` and `pixelRatio`.
|
|
75
|
+
*/
|
|
76
|
+
export type Loader = (arg0: import("./extent.js").Extent, arg1: number, arg2: number, arg3: ((arg0: HTMLImageElement, arg1: string) => void) | undefined) => import("./DataTile.js").ImageLike | ImageObject | Promise<import("./DataTile.js").ImageLike | ImageObject>;
|
|
77
|
+
/**
|
|
78
|
+
* Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.
|
|
79
|
+
* The function returns a promise for an {@link import ("./Image.js").ImageObject image object}.
|
|
80
|
+
*/
|
|
81
|
+
export type ImageObjectPromiseLoader = (arg0: import("./extent.js").Extent, arg1: number, arg2: number, arg3: ((arg0: HTMLImageElement, arg1: string) => void) | undefined) => import("./DataTile.js").ImageLike | ImageObject | Promise<import("./DataTile.js").ImageLike | ImageObject>;
|
|
24
82
|
/**
|
|
25
83
|
* A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a
|
|
26
84
|
* `{string}` for the src as arguments. It is supposed to make it so the
|
|
@@ -35,69 +93,110 @@ export type LoadFunction = (arg0: ImageWrapper, arg1: string) => void;
|
|
|
35
93
|
* post requests or - in general - through XHR requests, where the src of the
|
|
36
94
|
* image element would be set to a data URI when the content is loaded.
|
|
37
95
|
*
|
|
38
|
-
* @typedef {function(
|
|
96
|
+
* @typedef {function(import("./Image.js").default, string): void} LoadFunction
|
|
39
97
|
* @api
|
|
40
98
|
*/
|
|
41
|
-
|
|
99
|
+
/**
|
|
100
|
+
* @typedef {Object} ImageObject
|
|
101
|
+
* @property {import("./extent.js").Extent} [extent] Extent, if different from the requested one.
|
|
102
|
+
* @property {import("./resolution.js").ResolutionLike} [resolution] Resolution, if different from the requested one.
|
|
103
|
+
* When x and y resolution are different, use the array type (`[xResolution, yResolution]`).
|
|
104
|
+
* @property {number} [pixelRatio] Pixel ratio, if different from the requested one.
|
|
105
|
+
* @property {import('./DataTile.js').ImageLike} image Image.
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.
|
|
109
|
+
* The function returns an {@link import("./DataTile.js").ImageLike image}, an
|
|
110
|
+
* {@link import("./Image.js").ImageObject image object}, or a promise for the same.
|
|
111
|
+
* For loaders that generate images, the promise should not resolve until the image is loaded.
|
|
112
|
+
* If the returned image does not match the extent, resolution or pixel ratio passed to the loader,
|
|
113
|
+
* it has to return an {@link import("./Image.js").ImageObject image object} with the `image` and the
|
|
114
|
+
* correct `extent`, `resolution` and `pixelRatio`.
|
|
115
|
+
*
|
|
116
|
+
* @typedef {function(import("./extent.js").Extent, number, number, (function(HTMLImageElement, string): void)=): import("./DataTile.js").ImageLike|ImageObject|Promise<import("./DataTile.js").ImageLike|ImageObject>} Loader
|
|
117
|
+
* @api
|
|
118
|
+
*/
|
|
119
|
+
/**
|
|
120
|
+
* Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.
|
|
121
|
+
* The function returns a promise for an {@link import("./Image.js").ImageObject image object}.
|
|
122
|
+
*
|
|
123
|
+
* @typedef {function(import("./extent.js").Extent, number, number, (function(HTMLImageElement, string): void)=): import("./DataTile.js").ImageLike|ImageObject|Promise<import("./DataTile.js").ImageLike|ImageObject>} ImageObjectPromiseLoader
|
|
124
|
+
*/
|
|
125
|
+
declare class ImageWrapper extends EventTarget {
|
|
42
126
|
/**
|
|
43
127
|
* @param {import("./extent.js").Extent} extent Extent.
|
|
44
|
-
* @param {number|undefined} resolution Resolution.
|
|
128
|
+
* @param {number|Array<number>|undefined} resolution Resolution. If provided as array, x and y
|
|
129
|
+
* resolution will be assumed.
|
|
45
130
|
* @param {number} pixelRatio Pixel ratio.
|
|
46
|
-
* @param {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
*
|
|
131
|
+
* @param {import("./ImageState.js").default|import("./Image.js").Loader} stateOrLoader State.
|
|
132
|
+
*/
|
|
133
|
+
constructor(extent: import("./extent.js").Extent, resolution: number | Array<number> | undefined, pixelRatio: number, stateOrLoader: any | import("./Image.js").Loader);
|
|
134
|
+
/**
|
|
135
|
+
* @protected
|
|
136
|
+
* @type {import("./extent.js").Extent}
|
|
52
137
|
*/
|
|
53
|
-
|
|
138
|
+
protected extent: import("./extent.js").Extent;
|
|
54
139
|
/**
|
|
55
140
|
* @private
|
|
56
|
-
* @type {
|
|
141
|
+
* @type {number}
|
|
142
|
+
*/
|
|
143
|
+
private pixelRatio_;
|
|
144
|
+
/**
|
|
145
|
+
* @protected
|
|
146
|
+
* @type {number|Array<number>|undefined}
|
|
57
147
|
*/
|
|
58
|
-
|
|
148
|
+
protected resolution: number | Array<number> | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* @protected
|
|
151
|
+
* @type {import("./ImageState.js").default}
|
|
152
|
+
*/
|
|
153
|
+
protected state: any;
|
|
59
154
|
/**
|
|
60
155
|
* @private
|
|
61
|
-
* @type {
|
|
156
|
+
* @type {import('./DataTile.js').ImageLike|null}
|
|
62
157
|
*/
|
|
63
158
|
private image_;
|
|
64
159
|
/**
|
|
65
|
-
* @
|
|
66
|
-
* @type {
|
|
160
|
+
* @protected
|
|
161
|
+
* @type {import("./Image.js").Loader}
|
|
67
162
|
*/
|
|
68
|
-
|
|
163
|
+
protected loader: import("./Image.js").Loader;
|
|
69
164
|
/**
|
|
70
|
-
* @
|
|
71
|
-
* @type {?function():void}
|
|
165
|
+
* @protected
|
|
72
166
|
*/
|
|
73
|
-
|
|
167
|
+
protected changed(): void;
|
|
74
168
|
/**
|
|
75
|
-
* @
|
|
76
|
-
* @type {LoadFunction}
|
|
169
|
+
* @return {import("./extent.js").Extent} Extent.
|
|
77
170
|
*/
|
|
78
|
-
|
|
171
|
+
getExtent(): import("./extent.js").Extent;
|
|
79
172
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @private
|
|
173
|
+
* @return {import('./DataTile.js').ImageLike} Image.
|
|
83
174
|
*/
|
|
84
|
-
|
|
175
|
+
getImage(): import('./DataTile.js').ImageLike;
|
|
85
176
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @private
|
|
177
|
+
* @return {number} PixelRatio.
|
|
89
178
|
*/
|
|
90
|
-
|
|
179
|
+
getPixelRatio(): number;
|
|
91
180
|
/**
|
|
92
|
-
* @
|
|
181
|
+
* @return {number|Array<number>} Resolution.
|
|
93
182
|
*/
|
|
94
|
-
|
|
183
|
+
getResolution(): number | Array<number>;
|
|
95
184
|
/**
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
185
|
+
* @return {import("./ImageState.js").default} State.
|
|
186
|
+
*/
|
|
187
|
+
getState(): any;
|
|
188
|
+
/**
|
|
189
|
+
* Load not yet loaded URI.
|
|
190
|
+
*/
|
|
191
|
+
load(): void;
|
|
192
|
+
/**
|
|
193
|
+
* @param {import('./DataTile.js').ImageLike} image The image.
|
|
194
|
+
*/
|
|
195
|
+
setImage(image: import('./DataTile.js').ImageLike): void;
|
|
196
|
+
/**
|
|
197
|
+
* @param {number|Array<number>} resolution Resolution.
|
|
99
198
|
*/
|
|
100
|
-
|
|
199
|
+
setResolution(resolution: number | Array<number>): void;
|
|
101
200
|
}
|
|
102
|
-
import
|
|
201
|
+
import EventTarget from './events/Target.js';
|
|
103
202
|
//# sourceMappingURL=Image.d.ts.map
|
package/Image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["Image.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["Image.js"],"names":[],"mappings":"AAkNA;;;;;GAKG;AACH,mCALW,OAAO,eAAe,EAAE,SAAS,qBACtB,GAAG,sBACH,GAAG,SACF,IAAI,CA2C1B;AAED;;;;;;GAMG;AACH,4BALW,gBAAgB,6BAEf,QAAQ,gBAAgB,CAAC,CAuBpC;AAED;;;;GAIG;AACH,sCAJW,gBAAgB,6BAEf,QAAQ,gBAAgB,CAAC,CAWpC;AAED;;;;;;;;GAQG;AACH,8BANW,gBAAgB,6BAEf,QAAQ,WAAW,GAAC,gBAAgB,CAAC,CAWhD;;;;;;;;;;;;;;;;kCAxSqB,OAAO,YAAY,EAAE,OAAO,QAAE,MAAM,KAAG,IAAI;;;;;;;;;;;;;;;;;;WAUnD,OAAO,eAAe,EAAE,SAAS;;;;;;;;;;;4BAYzB,OAAO,aAAa,EAAE,MAAM,QAAE,MAAM,QAAE,MAAM,QAAE,QAAU,gBAAgB,QAAE,MAAM,KAAG,IAAI,CAAC,iBAAI,OAAO,eAAe,EAAE,SAAS,GAAC,WAAW,GAAC,QAAQ,OAAO,eAAe,EAAE,SAAS,GAAC,WAAW,CAAC;;;;;8CAQhM,OAAO,aAAa,EAAE,MAAM,QAAE,MAAM,QAAE,MAAM,QAAE,QAAU,gBAAgB,QAAE,MAAM,KAAG,IAAI,CAAC,iBAAI,OAAO,eAAe,EAAE,SAAS,GAAC,WAAW,GAAC,QAAQ,OAAO,eAAe,EAAE,SAAS,GAAC,WAAW,CAAC;AA5CtN;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AAEH;IACE;;;;;;OAMG;IACH,oBANW,OAAO,aAAa,EAAE,MAAM,cAC5B,MAAM,GAAC,MAAM,MAAM,CAAC,GAAC,SAAS,cAE9B,MAAM,iBACN,MAAkC,OAAO,YAAY,EAAE,MAAM,EAyCvE;IApCC;;;OAGG;IACH,kBAFU,OAAO,aAAa,EAAE,MAAM,CAElB;IAEpB;;;OAGG;IACH,oBAA6B;IAE7B;;;OAGG;IACH,sBAFU,MAAM,GAAC,MAAM,MAAM,CAAC,GAAC,SAAS,CAEZ;IAE5B;;;OAGG;IACH,qBACuE;IAEvE;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,kBAFU,OAAO,YAAY,EAAE,MAAM,CAEmC;IAG1E;;OAEG;IACH,0BAEC;IAED;;OAEG;IACH,aAFY,OAAO,aAAa,EAAE,MAAM,CAIvC;IAED;;OAEG;IACH,YAFY,OAAO,eAAe,EAAE,SAAS,CAI5C;IAED;;OAEG;IACH,iBAFY,MAAM,CAIjB;IAED;;OAEG;IACH,iBAFY,MAAM,GAAC,MAAM,MAAM,CAAC,CAI/B;IAED;;OAEG;IACH,gBAEC;IAED;;OAEG;IACH,aA0CC;IAED;;OAEG;IACH,gBAFW,OAAO,eAAe,EAAE,SAAS,QAI3C;IAED;;OAEG;IACH,0BAFW,MAAM,GAAC,MAAM,MAAM,CAAC,QAI9B;CACF;wBA7MuB,oBAAoB"}
|
package/Image.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module ol/Image
|
|
3
3
|
*/
|
|
4
|
+
import EventTarget from './events/Target.js';
|
|
4
5
|
import EventType from './events/EventType.js';
|
|
5
|
-
import ImageBase from './ImageBase.js';
|
|
6
6
|
import ImageState from './ImageState.js';
|
|
7
|
-
import {IMAGE_DECODE} from './has.js';
|
|
8
|
-
import {getHeight} from './extent.js';
|
|
7
|
+
import {CREATE_IMAGE_BITMAP, IMAGE_DECODE} from './has.js';
|
|
9
8
|
import {listenOnce, unlistenByKey} from './events.js';
|
|
9
|
+
import {toPromise} from './functions.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a
|
|
@@ -22,159 +22,194 @@ import {listenOnce, unlistenByKey} from './events.js';
|
|
|
22
22
|
* post requests or - in general - through XHR requests, where the src of the
|
|
23
23
|
* image element would be set to a data URI when the content is loaded.
|
|
24
24
|
*
|
|
25
|
-
* @typedef {function(
|
|
25
|
+
* @typedef {function(import("./Image.js").default, string): void} LoadFunction
|
|
26
26
|
* @api
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {Object} ImageObject
|
|
31
|
+
* @property {import("./extent.js").Extent} [extent] Extent, if different from the requested one.
|
|
32
|
+
* @property {import("./resolution.js").ResolutionLike} [resolution] Resolution, if different from the requested one.
|
|
33
|
+
* When x and y resolution are different, use the array type (`[xResolution, yResolution]`).
|
|
34
|
+
* @property {number} [pixelRatio] Pixel ratio, if different from the requested one.
|
|
35
|
+
* @property {import('./DataTile.js').ImageLike} image Image.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.
|
|
40
|
+
* The function returns an {@link import("./DataTile.js").ImageLike image}, an
|
|
41
|
+
* {@link import("./Image.js").ImageObject image object}, or a promise for the same.
|
|
42
|
+
* For loaders that generate images, the promise should not resolve until the image is loaded.
|
|
43
|
+
* If the returned image does not match the extent, resolution or pixel ratio passed to the loader,
|
|
44
|
+
* it has to return an {@link import("./Image.js").ImageObject image object} with the `image` and the
|
|
45
|
+
* correct `extent`, `resolution` and `pixelRatio`.
|
|
46
|
+
*
|
|
47
|
+
* @typedef {function(import("./extent.js").Extent, number, number, (function(HTMLImageElement, string): void)=): import("./DataTile.js").ImageLike|ImageObject|Promise<import("./DataTile.js").ImageLike|ImageObject>} Loader
|
|
48
|
+
* @api
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.
|
|
53
|
+
* The function returns a promise for an {@link import("./Image.js").ImageObject image object}.
|
|
54
|
+
*
|
|
55
|
+
* @typedef {function(import("./extent.js").Extent, number, number, (function(HTMLImageElement, string): void)=): import("./DataTile.js").ImageLike|ImageObject|Promise<import("./DataTile.js").ImageLike|ImageObject>} ImageObjectPromiseLoader
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
class ImageWrapper extends EventTarget {
|
|
30
59
|
/**
|
|
31
60
|
* @param {import("./extent.js").Extent} extent Extent.
|
|
32
|
-
* @param {number|undefined} resolution Resolution.
|
|
61
|
+
* @param {number|Array<number>|undefined} resolution Resolution. If provided as array, x and y
|
|
62
|
+
* resolution will be assumed.
|
|
33
63
|
* @param {number} pixelRatio Pixel ratio.
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {?string} crossOrigin Cross origin.
|
|
36
|
-
* @param {LoadFunction} imageLoadFunction Image load function.
|
|
37
|
-
* @param {CanvasRenderingContext2D} [context] Canvas context. When provided, the image will be
|
|
38
|
-
* drawn into the context's canvas, and `getImage()` will return the canvas once the image
|
|
39
|
-
* has finished loading.
|
|
64
|
+
* @param {import("./ImageState.js").default|import("./Image.js").Loader} stateOrLoader State.
|
|
40
65
|
*/
|
|
41
|
-
constructor(
|
|
42
|
-
|
|
43
|
-
resolution,
|
|
44
|
-
pixelRatio,
|
|
45
|
-
src,
|
|
46
|
-
crossOrigin,
|
|
47
|
-
imageLoadFunction,
|
|
48
|
-
context
|
|
49
|
-
) {
|
|
50
|
-
super(extent, resolution, pixelRatio, ImageState.IDLE);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @private
|
|
54
|
-
* @type {string}
|
|
55
|
-
*/
|
|
56
|
-
this.src_ = src;
|
|
66
|
+
constructor(extent, resolution, pixelRatio, stateOrLoader) {
|
|
67
|
+
super();
|
|
57
68
|
|
|
58
69
|
/**
|
|
59
|
-
* @
|
|
60
|
-
* @type {
|
|
70
|
+
* @protected
|
|
71
|
+
* @type {import("./extent.js").Extent}
|
|
61
72
|
*/
|
|
62
|
-
this.
|
|
63
|
-
if (crossOrigin !== null) {
|
|
64
|
-
this.image_.crossOrigin = crossOrigin;
|
|
65
|
-
}
|
|
73
|
+
this.extent = extent;
|
|
66
74
|
|
|
67
75
|
/**
|
|
68
76
|
* @private
|
|
69
|
-
* @type {
|
|
77
|
+
* @type {number}
|
|
70
78
|
*/
|
|
71
|
-
this.
|
|
79
|
+
this.pixelRatio_ = pixelRatio;
|
|
72
80
|
|
|
73
81
|
/**
|
|
74
|
-
* @
|
|
75
|
-
* @type {
|
|
82
|
+
* @protected
|
|
83
|
+
* @type {number|Array<number>|undefined}
|
|
76
84
|
*/
|
|
77
|
-
this.
|
|
85
|
+
this.resolution = resolution;
|
|
78
86
|
|
|
79
87
|
/**
|
|
80
88
|
* @protected
|
|
81
89
|
* @type {import("./ImageState.js").default}
|
|
82
90
|
*/
|
|
83
|
-
this.state =
|
|
91
|
+
this.state =
|
|
92
|
+
typeof stateOrLoader === 'function' ? ImageState.IDLE : stateOrLoader;
|
|
84
93
|
|
|
85
94
|
/**
|
|
86
95
|
* @private
|
|
87
|
-
* @type {
|
|
96
|
+
* @type {import('./DataTile.js').ImageLike|null}
|
|
88
97
|
*/
|
|
89
|
-
this.
|
|
98
|
+
this.image_ = null;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @protected
|
|
102
|
+
* @type {import("./Image.js").Loader}
|
|
103
|
+
*/
|
|
104
|
+
this.loader = typeof stateOrLoader === 'function' ? stateOrLoader : null;
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
/**
|
|
93
|
-
* @
|
|
94
|
-
|
|
108
|
+
* @protected
|
|
109
|
+
*/
|
|
110
|
+
changed() {
|
|
111
|
+
this.dispatchEvent(EventType.CHANGE);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @return {import("./extent.js").Extent} Extent.
|
|
116
|
+
*/
|
|
117
|
+
getExtent() {
|
|
118
|
+
return this.extent;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @return {import('./DataTile.js').ImageLike} Image.
|
|
95
123
|
*/
|
|
96
124
|
getImage() {
|
|
97
|
-
if (
|
|
98
|
-
this.state == ImageState.LOADED &&
|
|
99
|
-
this.context_ &&
|
|
100
|
-
!(this.image_ instanceof HTMLCanvasElement)
|
|
101
|
-
) {
|
|
102
|
-
const canvas = this.context_.canvas;
|
|
103
|
-
canvas.width = this.image_.width;
|
|
104
|
-
canvas.height = this.image_.height;
|
|
105
|
-
this.context_.drawImage(this.image_, 0, 0);
|
|
106
|
-
this.image_ = this.context_.canvas;
|
|
107
|
-
}
|
|
108
125
|
return this.image_;
|
|
109
126
|
}
|
|
110
127
|
|
|
111
128
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @private
|
|
129
|
+
* @return {number} PixelRatio.
|
|
115
130
|
*/
|
|
116
|
-
|
|
117
|
-
this.
|
|
118
|
-
this.unlistenImage_();
|
|
119
|
-
this.changed();
|
|
131
|
+
getPixelRatio() {
|
|
132
|
+
return this.pixelRatio_;
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @private
|
|
136
|
+
* @return {number|Array<number>} Resolution.
|
|
126
137
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
getResolution() {
|
|
139
|
+
return /** @type {number} */ (this.resolution);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @return {import("./ImageState.js").default} State.
|
|
144
|
+
*/
|
|
145
|
+
getState() {
|
|
146
|
+
return this.state;
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
/**
|
|
137
|
-
* Load
|
|
138
|
-
* Loading is taken care of by the tile queue, and calling this method is
|
|
139
|
-
* only needed for preloading or for reloading in case of an error.
|
|
140
|
-
* @api
|
|
150
|
+
* Load not yet loaded URI.
|
|
141
151
|
*/
|
|
142
152
|
load() {
|
|
143
|
-
if (this.state == ImageState.IDLE
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
if (this.state == ImageState.IDLE) {
|
|
154
|
+
if (this.loader) {
|
|
155
|
+
this.state = ImageState.LOADING;
|
|
156
|
+
this.changed();
|
|
157
|
+
const resolution = this.getResolution();
|
|
158
|
+
const requestResolution = Array.isArray(resolution)
|
|
159
|
+
? resolution[0]
|
|
160
|
+
: resolution;
|
|
161
|
+
toPromise(() =>
|
|
162
|
+
this.loader(this.getExtent(), requestResolution, this.getPixelRatio())
|
|
163
|
+
)
|
|
164
|
+
.then((image) => {
|
|
165
|
+
if ('image' in image) {
|
|
166
|
+
this.image_ = image.image;
|
|
167
|
+
}
|
|
168
|
+
if ('extent' in image) {
|
|
169
|
+
this.extent = image.extent;
|
|
170
|
+
}
|
|
171
|
+
if ('resolution' in image) {
|
|
172
|
+
this.resolution = image.resolution;
|
|
173
|
+
}
|
|
174
|
+
if ('pixelRatio' in image) {
|
|
175
|
+
this.pixelRatio_ = image.pixelRatio;
|
|
176
|
+
}
|
|
177
|
+
if (
|
|
178
|
+
image instanceof HTMLImageElement ||
|
|
179
|
+
image instanceof ImageBitmap ||
|
|
180
|
+
image instanceof HTMLCanvasElement ||
|
|
181
|
+
image instanceof HTMLVideoElement
|
|
182
|
+
) {
|
|
183
|
+
this.image_ = image;
|
|
184
|
+
}
|
|
185
|
+
this.state = ImageState.LOADED;
|
|
186
|
+
})
|
|
187
|
+
.catch((error) => {
|
|
188
|
+
this.state = ImageState.ERROR;
|
|
189
|
+
console.error(error); // eslint-disable-line no-console
|
|
190
|
+
})
|
|
191
|
+
.finally(() => this.changed());
|
|
192
|
+
}
|
|
152
193
|
}
|
|
153
194
|
}
|
|
154
195
|
|
|
155
196
|
/**
|
|
156
|
-
* @param {
|
|
197
|
+
* @param {import('./DataTile.js').ImageLike} image The image.
|
|
157
198
|
*/
|
|
158
199
|
setImage(image) {
|
|
159
200
|
this.image_ = image;
|
|
160
|
-
this.resolution = getHeight(this.extent) / this.image_.height;
|
|
161
201
|
}
|
|
162
202
|
|
|
163
203
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* @private
|
|
204
|
+
* @param {number|Array<number>} resolution Resolution.
|
|
167
205
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.unlisten_();
|
|
171
|
-
this.unlisten_ = null;
|
|
172
|
-
}
|
|
206
|
+
setResolution(resolution) {
|
|
207
|
+
this.resolution = resolution;
|
|
173
208
|
}
|
|
174
209
|
}
|
|
175
210
|
|
|
176
211
|
/**
|
|
177
|
-
* @param {
|
|
212
|
+
* @param {import('./DataTile.js').ImageLike} image Image element.
|
|
178
213
|
* @param {function():any} loadHandler Load callback function.
|
|
179
214
|
* @param {function():any} errorHandler Error callback function.
|
|
180
215
|
* @return {function():void} Callback to stop listening.
|
|
@@ -222,4 +257,67 @@ export function listenImage(image, loadHandler, errorHandler) {
|
|
|
222
257
|
};
|
|
223
258
|
}
|
|
224
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Loads an image.
|
|
262
|
+
* @param {HTMLImageElement} image Image, not yet loaded.
|
|
263
|
+
* @param {string} [src] `src` attribute of the image. Optional, not required if already present.
|
|
264
|
+
* @return {Promise<HTMLImageElement>} Promise resolving to an `HTMLImageElement`.
|
|
265
|
+
* @api
|
|
266
|
+
*/
|
|
267
|
+
export function load(image, src) {
|
|
268
|
+
return new Promise((resolve, reject) => {
|
|
269
|
+
function handleLoad() {
|
|
270
|
+
unlisten();
|
|
271
|
+
resolve(image);
|
|
272
|
+
}
|
|
273
|
+
function handleError() {
|
|
274
|
+
unlisten();
|
|
275
|
+
reject(new Error('Image load error'));
|
|
276
|
+
}
|
|
277
|
+
function unlisten() {
|
|
278
|
+
image.removeEventListener('load', handleLoad);
|
|
279
|
+
image.removeEventListener('error', handleError);
|
|
280
|
+
}
|
|
281
|
+
image.addEventListener('load', handleLoad);
|
|
282
|
+
image.addEventListener('error', handleError);
|
|
283
|
+
if (src) {
|
|
284
|
+
image.src = src;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @param {HTMLImageElement} image Image, not yet loaded.
|
|
291
|
+
* @param {string} [src] `src` attribute of the image. Optional, not required if already present.
|
|
292
|
+
* @return {Promise<HTMLImageElement>} Promise resolving to an `HTMLImageElement`.
|
|
293
|
+
*/
|
|
294
|
+
export function decodeFallback(image, src) {
|
|
295
|
+
if (src) {
|
|
296
|
+
image.src = src;
|
|
297
|
+
}
|
|
298
|
+
return IMAGE_DECODE
|
|
299
|
+
? new Promise((resolve, reject) =>
|
|
300
|
+
image.decode().then(() => resolve(image), reject)
|
|
301
|
+
)
|
|
302
|
+
: load(image);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns
|
|
307
|
+
* the laoded image otherwise.
|
|
308
|
+
* @param {HTMLImageElement} image Image, not yet loaded.
|
|
309
|
+
* @param {string} [src] `src` attribute of the image. Optional, not required if already present.
|
|
310
|
+
* @return {Promise<ImageBitmap|HTMLImageElement>} Promise resolving to an `ImageBitmap` or an
|
|
311
|
+
* `HTMLImageElement` if `createImageBitmap()` is not supported.
|
|
312
|
+
* @api
|
|
313
|
+
*/
|
|
314
|
+
export function decode(image, src) {
|
|
315
|
+
if (src) {
|
|
316
|
+
image.src = src;
|
|
317
|
+
}
|
|
318
|
+
return IMAGE_DECODE && CREATE_IMAGE_BITMAP
|
|
319
|
+
? image.decode().then(() => createImageBitmap(image))
|
|
320
|
+
: decodeFallback(image);
|
|
321
|
+
}
|
|
322
|
+
|
|
225
323
|
export default ImageWrapper;
|
package/ImageCanvas.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type Loader = (arg0: (arg0: Error | undefined) => void) => void;
|
|
|
14
14
|
*
|
|
15
15
|
* @typedef {function(function(Error=): void): void} Loader
|
|
16
16
|
*/
|
|
17
|
-
declare class ImageCanvas extends
|
|
17
|
+
declare class ImageCanvas extends ImageWrapper {
|
|
18
18
|
/**
|
|
19
19
|
* @param {import("./extent.js").Extent} extent Extent.
|
|
20
20
|
* @param {number} resolution Resolution.
|
|
@@ -56,5 +56,5 @@ declare class ImageCanvas extends ImageBase {
|
|
|
56
56
|
*/
|
|
57
57
|
getImage(): HTMLCanvasElement;
|
|
58
58
|
}
|
|
59
|
-
import
|
|
59
|
+
import ImageWrapper from './Image.js';
|
|
60
60
|
//# sourceMappingURL=ImageCanvas.d.ts.map
|