ol 7.5.1 → 8.0.0-dev.1692053484481

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/DataTile.d.ts +2 -2
  2. package/DataTile.d.ts.map +1 -1
  3. package/DataTile.js +3 -2
  4. package/Image.d.ts +139 -40
  5. package/Image.d.ts.map +1 -1
  6. package/Image.js +194 -96
  7. package/ImageCanvas.d.ts +2 -2
  8. package/ImageCanvas.d.ts.map +1 -1
  9. package/ImageCanvas.js +2 -2
  10. package/Object.d.ts +7 -0
  11. package/Object.d.ts.map +1 -1
  12. package/Object.js +8 -0
  13. package/dist/ol.js +2 -2
  14. package/dist/ol.js.map +1 -1
  15. package/expr/cpu.d.ts +71 -0
  16. package/expr/cpu.d.ts.map +1 -0
  17. package/expr/cpu.js +312 -0
  18. package/expr/expression.d.ts +97 -0
  19. package/expr/expression.d.ts.map +1 -0
  20. package/expr/expression.js +373 -0
  21. package/has.d.ts +5 -0
  22. package/has.d.ts.map +1 -1
  23. package/has.js +6 -0
  24. package/index.d.ts +1 -2
  25. package/index.js +1 -1
  26. package/layer/Base.d.ts +12 -8
  27. package/layer/Base.d.ts.map +1 -1
  28. package/layer/Base.js +12 -8
  29. package/layer/BaseVector.d.ts.map +1 -1
  30. package/layer/BaseVector.js +67 -33
  31. package/layer/Heatmap.d.ts.map +1 -1
  32. package/layer/Heatmap.js +16 -55
  33. package/layer/Layer.d.ts +2 -2
  34. package/layer/Layer.d.ts.map +1 -1
  35. package/layer/Layer.js +1 -1
  36. package/layer/WebGLPoints.d.ts +7 -12
  37. package/layer/WebGLPoints.d.ts.map +1 -1
  38. package/layer/WebGLPoints.js +7 -12
  39. package/package.json +1 -1
  40. package/render/Feature.d.ts +8 -0
  41. package/render/Feature.d.ts.map +1 -1
  42. package/render/Feature.js +9 -0
  43. package/render/canvas/Immediate.d.ts.map +1 -1
  44. package/render/canvas/Immediate.js +5 -3
  45. package/render/canvas/TextBuilder.js +2 -2
  46. package/render/canvas/style.d.ts +69 -0
  47. package/render/canvas/style.d.ts.map +1 -0
  48. package/render/canvas/style.js +1192 -0
  49. package/render/canvas.js +1 -1
  50. package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
  51. package/render/webgl/VectorStyleRenderer.js +4 -0
  52. package/renderer/Layer.d.ts +2 -2
  53. package/renderer/Layer.d.ts.map +1 -1
  54. package/renderer/Layer.js +1 -1
  55. package/renderer/canvas/ImageLayer.d.ts +4 -4
  56. package/renderer/canvas/ImageLayer.d.ts.map +1 -1
  57. package/renderer/canvas/ImageLayer.js +17 -12
  58. package/renderer/canvas/Layer.d.ts +2 -2
  59. package/renderer/canvas/Layer.d.ts.map +1 -1
  60. package/renderer/canvas/Layer.js +1 -1
  61. package/renderer/canvas/VectorImageLayer.d.ts.map +1 -1
  62. package/renderer/canvas/VectorImageLayer.js +3 -2
  63. package/renderer/webgl/VectorLayer.d.ts +1 -2
  64. package/renderer/webgl/VectorLayer.d.ts.map +1 -1
  65. package/reproj/Image.d.ts +5 -5
  66. package/reproj/Image.d.ts.map +1 -1
  67. package/reproj/Image.js +6 -6
  68. package/reproj.d.ts +2 -2
  69. package/reproj.d.ts.map +1 -1
  70. package/reproj.js +1 -1
  71. package/resolution.d.ts +13 -0
  72. package/resolution.d.ts.map +1 -0
  73. package/resolution.js +18 -0
  74. package/source/Image.d.ts +44 -7
  75. package/source/Image.d.ts.map +1 -1
  76. package/source/Image.js +97 -8
  77. package/source/ImageArcGISRest.d.ts +0 -23
  78. package/source/ImageArcGISRest.d.ts.map +1 -1
  79. package/source/ImageArcGISRest.js +18 -120
  80. package/source/ImageMapGuide.d.ts +0 -24
  81. package/source/ImageMapGuide.d.ts.map +1 -1
  82. package/source/ImageMapGuide.js +21 -113
  83. package/source/ImageStatic.d.ts +2 -27
  84. package/source/ImageStatic.d.ts.map +1 -1
  85. package/source/ImageStatic.js +20 -70
  86. package/source/ImageWMS.d.ts +2 -46
  87. package/source/ImageWMS.d.ts.map +1 -1
  88. package/source/ImageWMS.js +43 -201
  89. package/source/{Stamen.d.ts → StadiaMaps.d.ts} +17 -7
  90. package/source/StadiaMaps.d.ts.map +1 -0
  91. package/source/{Stamen.js → StadiaMaps.js} +85 -38
  92. package/source/TileArcGISRest.d.ts.map +1 -1
  93. package/source/TileArcGISRest.js +11 -22
  94. package/source/TileWMS.d.ts +0 -1
  95. package/source/TileWMS.d.ts.map +1 -1
  96. package/source/TileWMS.js +43 -106
  97. package/source/arcgisRest.d.ts +88 -0
  98. package/source/arcgisRest.d.ts.map +1 -0
  99. package/source/arcgisRest.js +131 -0
  100. package/source/common.d.ts +5 -0
  101. package/source/common.d.ts.map +1 -1
  102. package/source/common.js +6 -0
  103. package/source/mapguide.d.ts +52 -0
  104. package/source/mapguide.d.ts.map +1 -0
  105. package/source/mapguide.js +116 -0
  106. package/source/static.d.ts +45 -0
  107. package/source/static.d.ts.map +1 -0
  108. package/source/static.js +44 -0
  109. package/source/wms.d.ts +109 -1
  110. package/source/wms.d.ts.map +1 -1
  111. package/source/wms.js +170 -0
  112. package/source.d.ts +5 -1
  113. package/source.d.ts.map +1 -1
  114. package/source.js +5 -1
  115. package/style/flat.d.ts +332 -173
  116. package/style/flat.d.ts.map +1 -1
  117. package/style/flat.js +176 -248
  118. package/style/literal.d.ts +27 -72
  119. package/style/literal.d.ts.map +1 -1
  120. package/style/literal.js +14 -35
  121. package/util.d.ts.map +1 -1
  122. package/util.js +1 -1
  123. package/webgl/Helper.d.ts +7 -2
  124. package/webgl/Helper.d.ts.map +1 -1
  125. package/webgl/Helper.js +16 -27
  126. package/webgl/ShaderBuilder.d.ts +4 -14
  127. package/webgl/ShaderBuilder.d.ts.map +1 -1
  128. package/webgl/ShaderBuilder.js +72 -72
  129. package/webgl/styleparser.d.ts +3 -9
  130. package/webgl/styleparser.d.ts.map +1 -1
  131. package/webgl/styleparser.js +503 -88
  132. package/ImageBase.d.ts +0 -65
  133. package/ImageBase.d.ts.map +0 -1
  134. package/ImageBase.js +0 -98
  135. package/source/Stamen.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ImageStatic.d.ts","sourceRoot":"","sources":["ImageStatic.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;SAGnC,MAAM;;AAdpB;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAqDjB;IApCC;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,qBAAuC;IAEvC;;;OAGG;IACH,eAQC;IAED;;;OAGG;IACH,mBAA8D;IAQhE;;;;OAIG;IACH,kBAHY,OAAO,cAAc,EAAE,MAAM,CAKxC;IAED;;;;;;OAMG;IACH,yBANW,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACtC,OAAO,aAAa,EAAE,OAAO,CAOxC;IAED;;;;OAIG;IACH,UAHY,MAAM,CAKjB;CAkDF;wBAtKmD,YAAY"}
1
+ {"version":3,"file":"ImageStatic.d.ts","sourceRoot":"","sources":["ImageStatic.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;iBAiBc,OAAO,cAAc,EAAE,MAAM;;;;;;;;;;;;;iBAK7B,OAAO,YAAY,EAAE,cAAc;;;;SACnC,MAAM;;AAZpB;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAuDjB;IAtCC;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,qBAAuC;IA8BzC;;;;OAIG;IACH,kBAHY,OAAO,cAAc,EAAE,MAAM,CAKxC;IAgBD;;;;OAIG;IACH,UAHY,MAAM,CAKjB;CACF;wBApHmD,YAAY"}
@@ -4,11 +4,10 @@
4
4
 
5
5
  import EventType from '../events/EventType.js';
6
6
  import ImageSource, {defaultImageLoadFunction} from './Image.js';
7
- import ImageState from '../ImageState.js';
8
- import ImageWrapper from '../Image.js';
9
- import {createCanvasContext2D} from '../dom.js';
10
- import {getHeight, getWidth, intersects} from '../extent.js';
7
+ import ImageWrapper, {decode} from '../Image.js';
8
+ import {createLoader} from './static.js';
11
9
  import {get as getProjection} from '../proj.js';
10
+ import {intersects} from '../extent.js';
12
11
 
13
12
  /**
14
13
  * @typedef {Object} Options
@@ -16,14 +15,12 @@ import {get as getProjection} from '../proj.js';
16
15
  * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
17
16
  * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
18
17
  * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
19
- * @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
18
+ * @property {import("../extent.js").Extent} imageExtent Extent of the image in map coordinates.
20
19
  * This is the [left, bottom, right, top] map coordinates of your image.
21
20
  * @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
22
21
  * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
23
22
  * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
24
23
  * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
25
- * @property {import("../size.js").Size} [imageSize] Size of the image in pixels. Usually the image size is auto-detected, so this
26
- * only needs to be set if auto-detection fails for some reason.
27
24
  * @property {string} url Image URL.
28
25
  */
29
26
 
@@ -67,23 +64,25 @@ class Static extends ImageSource {
67
64
  * @private
68
65
  * @type {import("../Image.js").default}
69
66
  */
70
- this.image_ = new ImageWrapper(
67
+ this.image = null;
68
+
69
+ this.image = new ImageWrapper(
71
70
  this.imageExtent_,
72
71
  undefined,
73
72
  1,
74
- this.url_,
75
- crossOrigin,
76
- imageLoadFunction,
77
- createCanvasContext2D(1, 1)
73
+ createLoader({
74
+ url: options.url,
75
+ imageExtent: options.imageExtent,
76
+ crossOrigin,
77
+ load: (image, src) => {
78
+ this.image.setImage(image);
79
+ imageLoadFunction(this.image, src);
80
+ return decode(image);
81
+ },
82
+ })
78
83
  );
79
84
 
80
- /**
81
- * @private
82
- * @type {import("../size.js").Size|null}
83
- */
84
- this.imageSize_ = options.imageSize ? options.imageSize : null;
85
-
86
- this.image_.addEventListener(
85
+ this.image.addEventListener(
87
86
  EventType.CHANGE,
88
87
  this.handleImageChange.bind(this)
89
88
  );
@@ -106,8 +105,8 @@ class Static extends ImageSource {
106
105
  * @return {import("../Image.js").default} Single image.
107
106
  */
108
107
  getImageInternal(extent, resolution, pixelRatio, projection) {
109
- if (intersects(extent, this.image_.getExtent())) {
110
- return this.image_;
108
+ if (intersects(extent, this.image.getExtent())) {
109
+ return this.image;
111
110
  }
112
111
  return null;
113
112
  }
@@ -120,55 +119,6 @@ class Static extends ImageSource {
120
119
  getUrl() {
121
120
  return this.url_;
122
121
  }
123
-
124
- /**
125
- * @param {import("../events/Event.js").default} evt Event.
126
- */
127
- handleImageChange(evt) {
128
- if (this.image_.getState() == ImageState.LOADED) {
129
- const imageExtent = this.image_.getExtent();
130
- const image = this.image_.getImage();
131
- let imageWidth, imageHeight;
132
- if (this.imageSize_) {
133
- imageWidth = this.imageSize_[0];
134
- imageHeight = this.imageSize_[1];
135
- } else {
136
- imageWidth = image.width;
137
- imageHeight = image.height;
138
- }
139
- const extentWidth = getWidth(imageExtent);
140
- const extentHeight = getHeight(imageExtent);
141
- const xResolution = extentWidth / imageWidth;
142
- const yResolution = extentHeight / imageHeight;
143
- let targetWidth = imageWidth;
144
- let targetHeight = imageHeight;
145
- if (xResolution > yResolution) {
146
- targetWidth = Math.round(extentWidth / yResolution);
147
- } else {
148
- targetHeight = Math.round(extentHeight / xResolution);
149
- }
150
- if (targetWidth !== imageWidth || targetHeight !== imageHeight) {
151
- const context = createCanvasContext2D(targetWidth, targetHeight);
152
- if (!this.getInterpolate()) {
153
- context.imageSmoothingEnabled = false;
154
- }
155
- const canvas = context.canvas;
156
- context.drawImage(
157
- image,
158
- 0,
159
- 0,
160
- imageWidth,
161
- imageHeight,
162
- 0,
163
- 0,
164
- canvas.width,
165
- canvas.height
166
- );
167
- this.image_.setImage(canvas);
168
- }
169
- }
170
- super.handleImageChange(evt);
171
- }
172
122
  }
173
123
 
174
124
  export default Static;
@@ -45,8 +45,7 @@ export type Options = {
45
45
  projection?: import("../proj.js").ProjectionLike;
46
46
  /**
47
47
  * Ratio. `1` means image requests are the size of the map viewport, `2` means
48
- * twice the width and height of the map viewport, and so on. Must be `1` or
49
- * higher.
48
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
50
49
  */
51
50
  ratio?: number | undefined;
52
51
  /**
@@ -79,8 +78,7 @@ export type Options = {
79
78
  * and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
80
79
  * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
81
80
  * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
82
- * twice the width and height of the map viewport, and so on. Must be `1` or
83
- * higher.
81
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
84
82
  * @property {Array<number>} [resolutions] Resolutions.
85
83
  * If specified, requests will be made for these resolutions only.
86
84
  * @property {string} [url] WMS service URL.
@@ -97,11 +95,6 @@ declare class ImageWMS extends ImageSource {
97
95
  * @param {Options} [options] ImageWMS options.
98
96
  */
99
97
  constructor(options?: Options | undefined);
100
- /**
101
- * @private
102
- * @type {CanvasRenderingContext2D}
103
- */
104
- private context_;
105
98
  /**
106
99
  * @private
107
100
  * @type {?string}
@@ -122,11 +115,6 @@ declare class ImageWMS extends ImageSource {
122
115
  * @type {!Object}
123
116
  */
124
117
  private params_;
125
- /**
126
- * @private
127
- * @type {boolean}
128
- */
129
- private v13_;
130
118
  /**
131
119
  * @private
132
120
  * @type {import("./wms.js").ServerType}
@@ -137,16 +125,6 @@ declare class ImageWMS extends ImageSource {
137
125
  * @type {boolean}
138
126
  */
139
127
  private hidpi_;
140
- /**
141
- * @private
142
- * @type {import("../Image.js").default}
143
- */
144
- private image_;
145
- /**
146
- * @private
147
- * @type {import("../size.js").Size}
148
- */
149
- private imageSize_;
150
128
  /**
151
129
  * @private
152
130
  * @type {number}
@@ -194,30 +172,12 @@ declare class ImageWMS extends ImageSource {
194
172
  * @api
195
173
  */
196
174
  getParams(): any;
197
- /**
198
- * @param {import("../extent.js").Extent} extent Extent.
199
- * @param {number} resolution Resolution.
200
- * @param {number} pixelRatio Pixel ratio.
201
- * @param {import("../proj/Projection.js").default} projection Projection.
202
- * @return {import("../Image.js").default} Single image.
203
- */
204
- getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../Image.js").default;
205
175
  /**
206
176
  * Return the image load function of the source.
207
177
  * @return {import("../Image.js").LoadFunction} The image load function.
208
178
  * @api
209
179
  */
210
180
  getImageLoadFunction(): import("../Image.js").LoadFunction;
211
- /**
212
- * @param {import("../extent.js").Extent} extent Extent.
213
- * @param {import("../size.js").Size} size Size.
214
- * @param {number} pixelRatio Pixel ratio.
215
- * @param {import("../proj/Projection.js").default} projection Projection.
216
- * @param {Object} params Params.
217
- * @return {string} Request URL.
218
- * @private
219
- */
220
- private getRequestUrl_;
221
181
  /**
222
182
  * Return the URL used for this WMS source.
223
183
  * @return {string|undefined} URL.
@@ -242,10 +202,6 @@ declare class ImageWMS extends ImageSource {
242
202
  * @api
243
203
  */
244
204
  updateParams(params: any): void;
245
- /**
246
- * @private
247
- */
248
- private updateV13_;
249
205
  }
250
206
  import ImageSource from './Image.js';
251
207
  //# sourceMappingURL=ImageWMS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImageWMS.d.ts","sourceRoot":"","sources":["ImageWMS.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqDc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;AAlBjD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,2CAsFC;IA5EC;;;OAGG;IACH,iBAA2C;IAE3C;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,2BAG8B;IAE9B;;;OAGG;IACH,gBAAgD;IAEhD;;;OAGG;IACH,aAAgB;IAGhB;;;OAGG;IACH,oBAAqC;IAErC;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,mBAAwB;IAExB;;;OAGG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,eAA+D;IAGjE;;;;;;;;;;;;;OAaG;IACH,8BAVW,OAAO,kBAAkB,EAAE,UAAU,cACrC,MAAM,cACN,OAAO,YAAY,EAAE,cAAc,gBAKlC,MAAM,GAAC,SAAS,CAiD3B;IAED;;;;;;;;;;;;;OAaG;IACH,6DAHY,MAAM,GAAC,SAAS,CAmC3B;IAED;;;;;OAKG;IACH,iBAEC;IAED;;;;;;OAMG;IACH,yBANW,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACtC,OAAO,aAAa,EAAE,OAAO,CAsFxC;IAED;;;;OAIG;IACH,wBAHY,OAAO,aAAa,EAAE,YAAY,CAK7C;IAED;;;;;;;;OAQG;IACH,uBA6CC;IAED;;;;OAIG;IACH,UAHY,MAAM,GAAC,SAAS,CAK3B;IAED;;;;OAIG;IACH,wCAHW,OAAO,aAAa,EAAE,YAAY,QAO5C;IAED;;;;OAIG;IACH,YAHW,MAAM,GAAC,SAAS,QAS1B;IAED;;;;OAIG;IACH,gCAKC;IAED;;OAEG;IACH,mBAGC;CACF;wBAtemD,YAAY"}
1
+ {"version":3,"file":"ImageWMS.d.ts","sourceRoot":"","sources":["ImageWMS.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Cc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;AAlBjD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,2CA6DC;IAnDC;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,2BAG8B;IAE9B;;;OAGG;IACH,gBAA6B;IAE7B;;;OAGG;IACH,oBAAqC;IAErC;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,eAA+D;IAGjE;;;;;;;;;;;;;OAaG;IACH,8BAVW,OAAO,kBAAkB,EAAE,UAAU,cACrC,MAAM,cACN,OAAO,YAAY,EAAE,cAAc,gBAKlC,MAAM,GAAC,SAAS,CAiD3B;IAED;;;;;;;;;;;;;OAaG;IACH,6DAHY,MAAM,GAAC,SAAS,CAmC3B;IAED;;;;;OAKG;IACH,iBAEC;IAkCD;;;;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,gCAGC;CAMF;wBAzUmD,YAAY"}
@@ -2,31 +2,22 @@
2
2
  * @module ol/source/ImageWMS
3
3
  */
4
4
 
5
- import EventType from '../events/EventType.js';
6
5
  import ImageSource, {defaultImageLoadFunction} from './Image.js';
7
- import ImageWrapper from '../Image.js';
8
- import {DEFAULT_VERSION} from './wms.js';
6
+ import {DECIMALS} from './common.js';
7
+ import {
8
+ DEFAULT_VERSION,
9
+ createLoader,
10
+ getRequestParams,
11
+ getRequestUrl,
12
+ } from './wms.js';
9
13
  import {appendParams} from '../uri.js';
10
- import {assert} from '../asserts.js';
11
14
  import {calculateSourceResolution} from '../reproj.js';
12
- import {ceil, floor, round} from '../math.js';
13
15
  import {compareVersions} from '../string.js';
14
- import {
15
- containsExtent,
16
- getCenter,
17
- getForViewAndSize,
18
- getHeight,
19
- getWidth,
20
- } from '../extent.js';
21
- import {createCanvasContext2D} from '../dom.js';
16
+ import {decode} from '../Image.js';
17
+ import {floor} from '../math.js';
18
+ import {getForViewAndSize} from '../extent.js';
22
19
  import {get as getProjection, transform} from '../proj.js';
23
20
 
24
- /**
25
- * Number of decimal digits to consider in integer values when rounding.
26
- * @type {number}
27
- */
28
- const DECIMALS = 4;
29
-
30
21
  /**
31
22
  * @const
32
23
  * @type {import("../size.js").Size}
@@ -53,8 +44,7 @@ const GETFEATUREINFO_IMAGE_SIZE = [101, 101];
53
44
  * and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
54
45
  * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
55
46
  * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
56
- * twice the width and height of the map viewport, and so on. Must be `1` or
57
- * higher.
47
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
58
48
  * @property {Array<number>} [resolutions] Resolutions.
59
49
  * If specified, requests will be made for these resolutions only.
60
50
  * @property {string} [url] WMS service URL.
@@ -81,12 +71,6 @@ class ImageWMS extends ImageSource {
81
71
  resolutions: options.resolutions,
82
72
  });
83
73
 
84
- /**
85
- * @private
86
- * @type {CanvasRenderingContext2D}
87
- */
88
- this.context_ = createCanvasContext2D(1, 1);
89
-
90
74
  /**
91
75
  * @private
92
76
  * @type {?string}
@@ -113,14 +97,7 @@ class ImageWMS extends ImageSource {
113
97
  * @private
114
98
  * @type {!Object}
115
99
  */
116
- this.params_ = Object.assign({}, options.params);
117
-
118
- /**
119
- * @private
120
- * @type {boolean}
121
- */
122
- this.v13_ = true;
123
- this.updateV13_();
100
+ this.params_ = options.params;
124
101
 
125
102
  /**
126
103
  * @private
@@ -134,18 +111,6 @@ class ImageWMS extends ImageSource {
134
111
  */
135
112
  this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
136
113
 
137
- /**
138
- * @private
139
- * @type {import("../Image.js").default}
140
- */
141
- this.image_ = null;
142
-
143
- /**
144
- * @private
145
- * @type {import("../size.js").Size}
146
- */
147
- this.imageSize_ = [0, 0];
148
-
149
114
  /**
150
115
  * @private
151
116
  * @type {number}
@@ -198,24 +163,24 @@ class ImageWMS extends ImageSource {
198
163
  );
199
164
 
200
165
  const baseParams = {
201
- 'SERVICE': 'WMS',
202
- 'VERSION': DEFAULT_VERSION,
203
- 'REQUEST': 'GetFeatureInfo',
204
- 'FORMAT': 'image/png',
205
- 'TRANSPARENT': true,
206
166
  'QUERY_LAYERS': this.params_['LAYERS'],
207
167
  };
208
- Object.assign(baseParams, this.params_, params);
168
+ Object.assign(
169
+ baseParams,
170
+ getRequestParams(this.params_, 'GetFeatureInfo'),
171
+ params
172
+ );
209
173
 
210
174
  const x = floor((coordinate[0] - extent[0]) / resolution, DECIMALS);
211
175
  const y = floor((extent[3] - coordinate[1]) / resolution, DECIMALS);
212
- baseParams[this.v13_ ? 'I' : 'X'] = x;
213
- baseParams[this.v13_ ? 'J' : 'Y'] = y;
176
+ const v13 = compareVersions(baseParams['VERSION'], '1.3') >= 0;
177
+ baseParams[v13 ? 'I' : 'X'] = x;
178
+ baseParams[v13 ? 'J' : 'Y'] = y;
214
179
 
215
- return this.getRequestUrl_(
180
+ return getRequestUrl(
181
+ this.url_,
216
182
  extent,
217
183
  GETFEATUREINFO_IMAGE_SIZE,
218
- 1,
219
184
  sourceProjectionObj || projectionObj,
220
185
  baseParams
221
186
  );
@@ -290,86 +255,25 @@ class ImageWMS extends ImageSource {
290
255
  if (this.url_ === undefined) {
291
256
  return null;
292
257
  }
293
-
294
- resolution = this.findNearestResolution(resolution);
295
-
296
- if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) {
297
- pixelRatio = 1;
298
- }
299
-
300
- const imageResolution = resolution / pixelRatio;
301
-
302
- const center = getCenter(extent);
303
- const viewWidth = ceil(getWidth(extent) / imageResolution, DECIMALS);
304
- const viewHeight = ceil(getHeight(extent) / imageResolution, DECIMALS);
305
- const viewExtent = getForViewAndSize(center, imageResolution, 0, [
306
- viewWidth,
307
- viewHeight,
308
- ]);
309
- const marginWidth = ceil(((this.ratio_ - 1) * viewWidth) / 2, DECIMALS);
310
- const requestWidth = viewWidth + 2 * marginWidth;
311
- const marginHeight = ceil(((this.ratio_ - 1) * viewHeight) / 2, DECIMALS);
312
- const requestHeight = viewHeight + 2 * marginHeight;
313
- const requestExtent = getForViewAndSize(center, imageResolution, 0, [
314
- requestWidth,
315
- requestHeight,
316
- ]);
317
-
318
- const image = this.image_;
319
- if (
320
- image &&
321
- this.renderedRevision_ == this.getRevision() &&
322
- image.getResolution() == resolution &&
323
- image.getPixelRatio() == pixelRatio &&
324
- containsExtent(image.getExtent(), viewExtent)
325
- ) {
326
- return image;
258
+ if (!this.loader) {
259
+ // Lazily create loader to pick up the view projection and to allow `params` updates
260
+ this.loader = createLoader({
261
+ crossOrigin: this.crossOrigin_,
262
+ params: this.params_,
263
+ projection: projection,
264
+ serverType: this.serverType_,
265
+ hidpi: this.hidpi_,
266
+ url: this.url_,
267
+ ratio: this.ratio_,
268
+ load: (image, src) => {
269
+ this.image.setImage(image);
270
+ this.imageLoadFunction_(this.image, src);
271
+ return decode(image);
272
+ },
273
+ });
327
274
  }
328
275
 
329
- const params = {
330
- 'SERVICE': 'WMS',
331
- 'VERSION': DEFAULT_VERSION,
332
- 'REQUEST': 'GetMap',
333
- 'FORMAT': 'image/png',
334
- 'TRANSPARENT': true,
335
- };
336
- Object.assign(params, this.params_);
337
-
338
- this.imageSize_[0] = round(
339
- getWidth(requestExtent) / imageResolution,
340
- DECIMALS
341
- );
342
- this.imageSize_[1] = round(
343
- getHeight(requestExtent) / imageResolution,
344
- DECIMALS
345
- );
346
-
347
- const url = this.getRequestUrl_(
348
- requestExtent,
349
- this.imageSize_,
350
- pixelRatio,
351
- projection,
352
- params
353
- );
354
-
355
- this.image_ = new ImageWrapper(
356
- requestExtent,
357
- resolution,
358
- pixelRatio,
359
- url,
360
- this.crossOrigin_,
361
- this.imageLoadFunction_,
362
- this.context_
363
- );
364
-
365
- this.renderedRevision_ = this.getRevision();
366
-
367
- this.image_.addEventListener(
368
- EventType.CHANGE,
369
- this.handleImageChange.bind(this)
370
- );
371
-
372
- return this.image_;
276
+ return super.getImageInternal(extent, resolution, pixelRatio, projection);
373
277
  }
374
278
 
375
279
  /**
@@ -381,62 +285,6 @@ class ImageWMS extends ImageSource {
381
285
  return this.imageLoadFunction_;
382
286
  }
383
287
 
384
- /**
385
- * @param {import("../extent.js").Extent} extent Extent.
386
- * @param {import("../size.js").Size} size Size.
387
- * @param {number} pixelRatio Pixel ratio.
388
- * @param {import("../proj/Projection.js").default} projection Projection.
389
- * @param {Object} params Params.
390
- * @return {string} Request URL.
391
- * @private
392
- */
393
- getRequestUrl_(extent, size, pixelRatio, projection, params) {
394
- assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()`
395
-
396
- params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
397
-
398
- if (!('STYLES' in this.params_)) {
399
- params['STYLES'] = '';
400
- }
401
-
402
- if (pixelRatio != 1) {
403
- switch (this.serverType_) {
404
- case 'geoserver':
405
- const dpi = (90 * pixelRatio + 0.5) | 0;
406
- if ('FORMAT_OPTIONS' in params) {
407
- params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
408
- } else {
409
- params['FORMAT_OPTIONS'] = 'dpi:' + dpi;
410
- }
411
- break;
412
- case 'mapserver':
413
- params['MAP_RESOLUTION'] = 90 * pixelRatio;
414
- break;
415
- case 'carmentaserver':
416
- case 'qgis':
417
- params['DPI'] = 90 * pixelRatio;
418
- break;
419
- default: // Unknown `serverType` configured
420
- assert(false, 8);
421
- break;
422
- }
423
- }
424
-
425
- params['WIDTH'] = size[0];
426
- params['HEIGHT'] = size[1];
427
-
428
- const axisOrientation = projection.getAxisOrientation();
429
- let bbox;
430
- if (this.v13_ && axisOrientation.substr(0, 2) == 'ne') {
431
- bbox = [extent[1], extent[0], extent[3], extent[2]];
432
- } else {
433
- bbox = extent;
434
- }
435
- params['BBOX'] = bbox.join(',');
436
-
437
- return appendParams(/** @type {string} */ (this.url_), params);
438
- }
439
-
440
288
  /**
441
289
  * Return the URL used for this WMS source.
442
290
  * @return {string|undefined} URL.
@@ -452,7 +300,6 @@ class ImageWMS extends ImageSource {
452
300
  * @api
453
301
  */
454
302
  setImageLoadFunction(imageLoadFunction) {
455
- this.image_ = null;
456
303
  this.imageLoadFunction_ = imageLoadFunction;
457
304
  this.changed();
458
305
  }
@@ -465,7 +312,7 @@ class ImageWMS extends ImageSource {
465
312
  setUrl(url) {
466
313
  if (url != this.url_) {
467
314
  this.url_ = url;
468
- this.image_ = null;
315
+ this.loader = null;
469
316
  this.changed();
470
317
  }
471
318
  }
@@ -477,17 +324,12 @@ class ImageWMS extends ImageSource {
477
324
  */
478
325
  updateParams(params) {
479
326
  Object.assign(this.params_, params);
480
- this.updateV13_();
481
- this.image_ = null;
482
327
  this.changed();
483
328
  }
484
329
 
485
- /**
486
- * @private
487
- */
488
- updateV13_() {
489
- const version = this.params_['VERSION'] || DEFAULT_VERSION;
490
- this.v13_ = compareVersions(version, '1.3') >= 0;
330
+ changed() {
331
+ this.image = null;
332
+ super.changed();
491
333
  }
492
334
  }
493
335
 
@@ -1,4 +1,4 @@
1
- export default Stamen;
1
+ export default StadiaMaps;
2
2
  export type Options = {
3
3
  /**
4
4
  * Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
@@ -10,7 +10,7 @@ export type Options = {
10
10
  */
11
11
  interpolate?: boolean | undefined;
12
12
  /**
13
- * Layer name.
13
+ * Layer name. Valid values: `alidade_smooth`, `alidade_smooth_dark`, `stadia_outdoors`, `stamen_terrain`, `stamen_terrain_background`, `stamen_terrain_labels`, `stamen_terrain_lines`, `stamen_toner_background`, `stamen_toner`, `stamen_toner_labels`, `stamen_toner_lines`, `stamen_toner_lite`, `stamen_watercolor`, and `osm_bright`.
14
14
  */
15
15
  layer: string;
16
16
  /**
@@ -53,13 +53,21 @@ export type Options = {
53
53
  * zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
54
54
  */
55
55
  zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
56
+ /**
57
+ * Stadia Maps API key. Not required for localhost or most public web deployments. See https://docs.stadiamaps.com/authentication/ for details.
58
+ */
59
+ apiKey: string;
60
+ /**
61
+ * Use retina tiles (if available; not available for Stamen Watercolor).
62
+ */
63
+ retina: boolean;
56
64
  };
57
65
  /**
58
66
  * @typedef {Object} Options
59
67
  * @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
60
68
  * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
61
69
  * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
62
- * @property {string} layer Layer name.
70
+ * @property {string} layer Layer name. Valid values: `alidade_smooth`, `alidade_smooth_dark`, `stadia_outdoors`, `stamen_terrain`, `stamen_terrain_background`, `stamen_terrain_labels`, `stamen_terrain_lines`, `stamen_toner_background`, `stamen_toner`, `stamen_toner_labels`, `stamen_toner_lines`, `stamen_toner_lite`, `stamen_watercolor`, and `osm_bright`.
63
71
  * @property {number} [minZoom] Minimum zoom.
64
72
  * @property {number} [maxZoom] Maximum zoom.
65
73
  * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
@@ -78,17 +86,19 @@ export type Options = {
78
86
  * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
79
87
  * Choose whether to use tiles with a higher or lower zoom level when between integer
80
88
  * zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
89
+ * @property {string} apiKey Stadia Maps API key. Not required for localhost or most public web deployments. See https://docs.stadiamaps.com/authentication/ for details.
90
+ * @property {boolean} retina Use retina tiles (if available; not available for Stamen Watercolor).
81
91
  */
82
92
  /**
83
93
  * @classdesc
84
- * Layer source for the Stamen tile server.
94
+ * Layer source for the Stadia Maps tile server.
85
95
  * @api
86
96
  */
87
- declare class Stamen extends XYZ {
97
+ declare class StadiaMaps extends XYZ {
88
98
  /**
89
- * @param {Options} options Stamen options.
99
+ * @param {Options} options StadiaMaps options.
90
100
  */
91
101
  constructor(options: Options);
92
102
  }
93
103
  import XYZ from './XYZ.js';
94
- //# sourceMappingURL=Stamen.d.ts.map
104
+ //# sourceMappingURL=StadiaMaps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StadiaMaps.d.ts","sourceRoot":"","sources":["StadiaMaps.js"],"names":[],"mappings":";;;;;;;;;;;;;;WAoHc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAmBN,MAAM;;;;YACN,OAAO;;AAzBrB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAsDjB;CACF;gBArMe,UAAU"}