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,5 +1,5 @@
1
1
  /**
2
- * @module ol/source/Stamen
2
+ * @module ol/source/StadiaMaps
3
3
  */
4
4
 
5
5
  import XYZ from './XYZ.js';
@@ -7,80 +7,105 @@ import {ATTRIBUTION as OSM_ATTRIBUTION} from './OSM.js';
7
7
 
8
8
  /**
9
9
  * @const
10
- * @type {Array<string>}
10
+ * @type string
11
11
  */
12
- const ATTRIBUTIONS = [
13
- 'Map tiles by <a href="https://stamen.com/" target="_blank">Stamen Design</a>, ' +
14
- 'under <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC BY' +
15
- ' 3.0</a>.',
16
- OSM_ATTRIBUTION,
17
- ];
12
+ const STADIA_ATTRIBUTION =
13
+ '&copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>';
14
+
15
+ /**
16
+ * @const
17
+ * @type string
18
+ */
19
+ const OMT_ATTRIBUTION =
20
+ '&copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>';
21
+
22
+ /**
23
+ * @const
24
+ * @type string
25
+ */
26
+ const STAMEN_ATTRIBUTION =
27
+ '&copy; <a href="https://stamen.com/" target="_blank">Stamen Design</a>';
18
28
 
19
29
  /**
20
30
  * @type {Object<string, {extension: string, opaque: boolean}>}
21
31
  */
22
32
  const LayerConfig = {
23
- 'terrain': {
33
+ 'stamen_terrain': {
24
34
  extension: 'png',
25
35
  opaque: true,
26
36
  },
27
- 'terrain-background': {
37
+ 'stamen_terrain_background': {
28
38
  extension: 'png',
29
39
  opaque: true,
30
40
  },
31
- 'terrain-labels': {
41
+ 'stamen_terrain_labels': {
32
42
  extension: 'png',
33
43
  opaque: false,
34
44
  },
35
- 'terrain-lines': {
45
+ 'stamen_terrain_lines': {
36
46
  extension: 'png',
37
47
  opaque: false,
38
48
  },
39
- 'toner-background': {
49
+ 'stamen_toner_background': {
40
50
  extension: 'png',
41
51
  opaque: true,
42
52
  },
43
- 'toner': {
53
+ 'stamen_toner': {
44
54
  extension: 'png',
45
55
  opaque: true,
46
56
  },
47
- 'toner-hybrid': {
57
+ 'stamen_toner_labels': {
48
58
  extension: 'png',
49
59
  opaque: false,
50
60
  },
51
- 'toner-labels': {
61
+ 'stamen_toner_lines': {
52
62
  extension: 'png',
53
63
  opaque: false,
54
64
  },
55
- 'toner-lines': {
65
+ 'stamen_toner_lite': {
56
66
  extension: 'png',
57
- opaque: false,
67
+ opaque: true,
68
+ },
69
+ 'stamen_watercolor': {
70
+ extension: 'jpg',
71
+ opaque: true,
58
72
  },
59
- 'toner-lite': {
73
+ 'alidade_smooth': {
60
74
  extension: 'png',
61
75
  opaque: true,
62
76
  },
63
- 'watercolor': {
64
- extension: 'jpg',
77
+ 'alidade_smooth_dark': {
78
+ extension: 'png',
79
+ opaque: true,
80
+ },
81
+ 'stadia_outdoors': {
82
+ extension: 'png',
83
+ opaque: true,
84
+ },
85
+ 'osm_bright': {
86
+ extension: 'png',
65
87
  opaque: true,
66
88
  },
67
89
  };
68
90
 
69
91
  /**
70
- * @type {Object<string, {minZoom: number, maxZoom: number}>}
92
+ * @type {Object<string, {minZoom: number, maxZoom: number, retina: boolean}>}
71
93
  */
72
94
  const ProviderConfig = {
73
- 'terrain': {
95
+ 'stamen_terrain': {
74
96
  minZoom: 0,
75
97
  maxZoom: 18,
98
+ retina: true,
76
99
  },
77
- 'toner': {
100
+ 'stamen_toner': {
78
101
  minZoom: 0,
79
102
  maxZoom: 20,
103
+ retina: true,
80
104
  },
81
- 'watercolor': {
82
- minZoom: 0,
105
+ 'stamen_watercolor': {
106
+ minZoom: 1,
83
107
  maxZoom: 18,
108
+ retina: false,
84
109
  },
85
110
  };
86
111
 
@@ -89,7 +114,7 @@ const ProviderConfig = {
89
114
  * @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
90
115
  * @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
91
116
  * linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
92
- * @property {string} layer Layer name.
117
+ * @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`.
93
118
  * @property {number} [minZoom] Minimum zoom.
94
119
  * @property {number} [maxZoom] Maximum zoom.
95
120
  * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
@@ -108,50 +133,72 @@ const ProviderConfig = {
108
133
  * @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
109
134
  * Choose whether to use tiles with a higher or lower zoom level when between integer
110
135
  * zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
136
+ * @property {string} apiKey Stadia Maps API key. Not required for localhost or most public web deployments. See https://docs.stadiamaps.com/authentication/ for details.
137
+ * @property {boolean} retina Use retina tiles (if available; not available for Stamen Watercolor).
111
138
  */
112
139
 
113
140
  /**
114
141
  * @classdesc
115
- * Layer source for the Stamen tile server.
142
+ * Layer source for the Stadia Maps tile server.
116
143
  * @api
117
144
  */
118
- class Stamen extends XYZ {
145
+ class StadiaMaps extends XYZ {
119
146
  /**
120
- * @param {Options} options Stamen options.
147
+ * @param {Options} options StadiaMaps options.
121
148
  */
122
149
  constructor(options) {
123
150
  const i = options.layer.indexOf('-');
124
151
  const provider = i == -1 ? options.layer : options.layer.slice(0, i);
125
- const providerConfig = ProviderConfig[provider];
152
+ const providerConfig = ProviderConfig[provider] || {
153
+ 'minZoom': 0,
154
+ 'maxZoom': 20,
155
+ 'retina': true,
156
+ };
126
157
 
127
158
  const layerConfig = LayerConfig[options.layer];
159
+ const query = options.apiKey ? '?api_key=' + options.apiKey : '';
160
+ const retina = providerConfig.retina && options.retina ? '@2x' : '';
128
161
 
129
162
  const url =
130
163
  options.url !== undefined
131
164
  ? options.url
132
- : 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' +
165
+ : 'https://tiles.stadiamaps.com/tiles/' +
133
166
  options.layer +
134
- '/{z}/{x}/{y}.' +
135
- layerConfig.extension;
167
+ '/{z}/{x}/{y}' +
168
+ retina +
169
+ '.' +
170
+ layerConfig.extension +
171
+ query;
172
+
173
+ const attributions = [STADIA_ATTRIBUTION, OMT_ATTRIBUTION, OSM_ATTRIBUTION];
174
+
175
+ if (options.layer.startsWith('stamen_')) {
176
+ attributions.splice(1, 0, STAMEN_ATTRIBUTION);
177
+ }
136
178
 
137
179
  super({
138
- attributions: ATTRIBUTIONS,
180
+ attributions: attributions,
139
181
  cacheSize: options.cacheSize,
140
182
  crossOrigin: 'anonymous',
141
183
  interpolate: options.interpolate,
142
184
  maxZoom:
143
- options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom,
185
+ options.maxZoom !== undefined
186
+ ? options.maxZoom
187
+ : providerConfig.maxZoom,
144
188
  minZoom:
145
- options.minZoom != undefined ? options.minZoom : providerConfig.minZoom,
189
+ options.minZoom !== undefined
190
+ ? options.minZoom
191
+ : providerConfig.minZoom,
146
192
  opaque: layerConfig.opaque,
147
193
  reprojectionErrorThreshold: options.reprojectionErrorThreshold,
148
194
  tileLoadFunction: options.tileLoadFunction,
149
195
  transition: options.transition,
150
196
  url: url,
197
+ tilePixelRatio: retina ? 2 : 1,
151
198
  wrapX: options.wrapX,
152
199
  zDirection: options.zDirection,
153
200
  });
154
201
  }
155
202
  }
156
203
 
157
- export default Stamen;
204
+ export default StadiaMaps;
@@ -1 +1 @@
1
- {"version":3,"file":"TileArcGISRest.d.ts","sourceRoot":"","sources":["TileArcGISRest.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,2CAsCC;IAnBC;;;OAGG;IACH,gBAAmC;IAEnC;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,mBAA+B;IAKjC;;;OAGG;IACH,yBAOC;IAED;;;;;OAKG;IACH,iBAEC;IAED;;;;;;;;;OASG;IACH,uBAyCC;IAWD;;;;OAIG;IACH,gCAGC;CA+CF;sBAvPqB,gBAAgB"}
1
+ {"version":3,"file":"TileArcGISRest.d.ts","sourceRoot":"","sources":["TileArcGISRest.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,2CAsCC;IAnBC;;;OAGG;IACH,gBAAmC;IAEnC;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,mBAA+B;IAKjC;;;OAGG;IACH,yBAOC;IAED;;;;;OAKG;IACH,iBAEC;IAED;;;;;;;;;OASG;IACH,uBA8BC;IAWD;;;;OAIG;IACH,gCAGC;CA+CF;sBA5OqB,gBAAgB"}
@@ -3,8 +3,8 @@
3
3
  */
4
4
 
5
5
  import TileImage from './TileImage.js';
6
- import {appendParams} from '../uri.js';
7
6
  import {createEmpty} from '../extent.js';
7
+ import {getRequestUrl} from './arcgisRest.js';
8
8
  import {modulo} from '../math.js';
9
9
  import {scale as scaleSize, toSize} from '../size.js';
10
10
  import {hash as tileCoordHash} from '../tilecoord.js';
@@ -154,23 +154,6 @@ class TileArcGISRest extends TileImage {
154
154
  if (!urls) {
155
155
  return undefined;
156
156
  }
157
-
158
- // ArcGIS Server only wants the numeric portion of the projection ID.
159
- // (if there is no numeric portion the entire projection code must
160
- // form a valid ArcGIS SpatialReference definition).
161
- const srid = projection
162
- .getCode()
163
- .split(/:(?=\d+$)/)
164
- .pop();
165
-
166
- params['SIZE'] = tileSize[0] + ',' + tileSize[1];
167
- params['BBOX'] = tileExtent.join(',');
168
- params['BBOXSR'] = srid;
169
- params['IMAGESR'] = srid;
170
- params['DPI'] = Math.round(
171
- params['DPI'] ? params['DPI'] * pixelRatio : 90 * pixelRatio
172
- );
173
-
174
157
  let url;
175
158
  if (urls.length == 1) {
176
159
  url = urls[0];
@@ -179,10 +162,16 @@ class TileArcGISRest extends TileImage {
179
162
  url = urls[index];
180
163
  }
181
164
 
182
- const modifiedUrl = url
183
- .replace(/MapServer\/?$/, 'MapServer/export')
184
- .replace(/ImageServer\/?$/, 'ImageServer/exportImage');
185
- return appendParams(modifiedUrl, params);
165
+ return getRequestUrl(
166
+ url,
167
+ tileExtent,
168
+ (
169
+ this.tileGrid || this.getTileGridForProjection(projection)
170
+ ).getResolution(tileCoord[0]),
171
+ pixelRatio,
172
+ projection,
173
+ params
174
+ );
186
175
  }
187
176
 
188
177
  /**
@@ -248,7 +248,6 @@ declare class TileWMS extends TileImage {
248
248
  getParams(): any;
249
249
  /**
250
250
  * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
251
- * @param {import("../size.js").Size} tileSize Tile size.
252
251
  * @param {import("../extent.js").Extent} tileExtent Tile extent.
253
252
  * @param {number} pixelRatio Pixel ratio.
254
253
  * @param {import("../proj/Projection.js").default} projection Projection.
@@ -1 +1 @@
1
- {"version":3,"file":"TileWMS.d.ts","sourceRoot":"","sources":["TileWMS.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA0BqB,MAAM;;;;;;;;;;;;;;;;;;;;;iBAeb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,2CAgEC;IAtCC;;;OAGG;IACH,gBAAgE;IAEhE;;;OAGG;IACH,gBAAqB;IAErB;;;OAGG;IACH,aAAgB;IAEhB;;;OAGG;IACH,oBAAqC;IAErC;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,mBAA+B;IAMjC;;;;;;;;;;;;;OAaG;IACH,8BAVW,OAAO,kBAAkB,EAAE,UAAU,cACrC,MAAM,cACN,OAAO,YAAY,EAAE,cAAc,gBAKlC,MAAM,GAAC,SAAS,CAoE3B;IAED;;;;;;;;;;;;;OAaG;IACH,6DAHY,MAAM,GAAC,SAAS,CAmC3B;IASD;;;;;OAKG;IACH,iBAEC;IAED;;;;;;;;;OASG;IACH,uBAkEC;IAWD;;;OAGG;IACH,yBAOC;IAED;;;;OAIG;IACH,gCAIC;IAED;;OAEG;IACH,mBAGC;CAuDF;sBA/cqB,gBAAgB"}
1
+ {"version":3,"file":"TileWMS.d.ts","sourceRoot":"","sources":["TileWMS.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAwBqB,MAAM;;;;;;;;;;;;;;;;;;;;;iBAeb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,2CAgEC;IAtCC;;;OAGG;IACH,gBAAgE;IAEhE;;;OAGG;IACH,gBAAqB;IAErB;;;OAGG;IACH,aAAgB;IAEhB;;;OAGG;IACH,oBAAqC;IAErC;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,mBAA+B;IAMjC;;;;;;;;;;;;;OAaG;IACH,8BAVW,OAAO,kBAAkB,EAAE,UAAU,cACrC,MAAM,cACN,OAAO,YAAY,EAAE,cAAc,gBAKlC,MAAM,GAAC,SAAS,CA6D3B;IAED;;;;;;;;;;;;;OAaG;IACH,6DAHY,MAAM,GAAC,SAAS,CAmC3B;IASD;;;;;OAKG;IACH,iBAEC;IAED;;;;;;;;OAQG;IACH,uBAwBC;IAWD;;;OAGG;IACH,yBAOC;IAED;;;;OAIG;IACH,gCAIC;IAED;;OAEG;IACH,mBAGC;CA4CF;sBAhZqB,gBAAgB"}
package/source/TileWMS.js CHANGED
@@ -3,14 +3,12 @@
3
3
  */
4
4
 
5
5
  import TileImage from './TileImage.js';
6
- import {DEFAULT_VERSION} from './wms.js';
6
+ import {DEFAULT_VERSION, getImageSrc, getRequestParams} from './wms.js';
7
7
  import {appendParams} from '../uri.js';
8
- import {assert} from '../asserts.js';
9
8
  import {buffer, createEmpty} from '../extent.js';
10
- import {buffer as bufferSize, scale as scaleSize, toSize} from '../size.js';
11
9
  import {calculateSourceResolution} from '../reproj.js';
12
10
  import {compareVersions} from '../string.js';
13
- import {get as getProjection, transform, transformExtent} from '../proj.js';
11
+ import {get as getProjection, transform} from '../proj.js';
14
12
  import {modulo} from '../math.js';
15
13
  import {hash as tileCoordHash} from '../tilecoord.js';
16
14
 
@@ -163,64 +161,57 @@ class TileWMS extends TileImage {
163
161
  */
164
162
  getFeatureInfoUrl(coordinate, resolution, projection, params) {
165
163
  const projectionObj = getProjection(projection);
166
- const sourceProjectionObj = this.getProjection();
164
+ const sourceProjectionObj = this.getProjection() || projectionObj;
167
165
 
168
166
  let tileGrid = this.getTileGrid();
169
167
  if (!tileGrid) {
170
- tileGrid = this.getTileGridForProjection(projectionObj);
168
+ tileGrid = this.getTileGridForProjection(sourceProjectionObj);
171
169
  }
172
170
 
173
- const z = tileGrid.getZForResolution(resolution, this.zDirection);
174
- const tileCoord = tileGrid.getTileCoordForCoordAndZ(coordinate, z);
171
+ const sourceProjCoord = transform(
172
+ coordinate,
173
+ projectionObj,
174
+ sourceProjectionObj
175
+ );
176
+ const sourceResolution = calculateSourceResolution(
177
+ sourceProjectionObj,
178
+ projectionObj,
179
+ coordinate,
180
+ resolution
181
+ );
182
+
183
+ const z = tileGrid.getZForResolution(sourceResolution, this.zDirection);
184
+ const tileResolution = tileGrid.getResolution(z);
185
+ const tileCoord = tileGrid.getTileCoordForCoordAndZ(sourceProjCoord, z);
175
186
 
176
187
  if (tileGrid.getResolutions().length <= tileCoord[0]) {
177
188
  return undefined;
178
189
  }
179
190
 
180
- let tileResolution = tileGrid.getResolution(tileCoord[0]);
181
191
  let tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
182
- let tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
183
192
 
184
193
  const gutter = this.gutter_;
185
194
  if (gutter !== 0) {
186
- tileSize = bufferSize(tileSize, gutter, this.tmpSize);
187
195
  tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
188
196
  }
189
197
 
190
- if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
191
- tileResolution = calculateSourceResolution(
192
- sourceProjectionObj,
193
- projectionObj,
194
- coordinate,
195
- tileResolution
196
- );
197
- tileExtent = transformExtent(
198
- tileExtent,
199
- projectionObj,
200
- sourceProjectionObj
201
- );
202
- coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
203
- }
204
-
205
198
  const baseParams = {
206
- 'SERVICE': 'WMS',
207
- 'VERSION': DEFAULT_VERSION,
208
- 'REQUEST': 'GetFeatureInfo',
209
- 'FORMAT': 'image/png',
210
- 'TRANSPARENT': true,
211
199
  'QUERY_LAYERS': this.params_['LAYERS'],
212
200
  };
213
- Object.assign(baseParams, this.params_, params);
201
+ Object.assign(
202
+ baseParams,
203
+ getRequestParams(this.params_, 'GetFeatureInfo'),
204
+ params
205
+ );
214
206
 
215
- const x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution);
216
- const y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution);
207
+ const x = Math.floor((sourceProjCoord[0] - tileExtent[0]) / tileResolution);
208
+ const y = Math.floor((tileExtent[3] - sourceProjCoord[1]) / tileResolution);
217
209
 
218
210
  baseParams[this.v13_ ? 'I' : 'X'] = x;
219
211
  baseParams[this.v13_ ? 'J' : 'Y'] = y;
220
212
 
221
213
  return this.getRequestUrl_(
222
214
  tileCoord,
223
- tileSize,
224
215
  tileExtent,
225
216
  1,
226
217
  sourceProjectionObj || projectionObj,
@@ -295,7 +286,6 @@ class TileWMS extends TileImage {
295
286
 
296
287
  /**
297
288
  * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
298
- * @param {import("../size.js").Size} tileSize Tile size.
299
289
  * @param {import("../extent.js").Extent} tileExtent Tile extent.
300
290
  * @param {number} pixelRatio Pixel ratio.
301
291
  * @param {import("../proj/Projection.js").default} projection Projection.
@@ -303,64 +293,11 @@ class TileWMS extends TileImage {
303
293
  * @return {string|undefined} Request URL.
304
294
  * @private
305
295
  */
306
- getRequestUrl_(
307
- tileCoord,
308
- tileSize,
309
- tileExtent,
310
- pixelRatio,
311
- projection,
312
- params
313
- ) {
296
+ getRequestUrl_(tileCoord, tileExtent, pixelRatio, projection, params) {
314
297
  const urls = this.urls;
315
298
  if (!urls) {
316
299
  return undefined;
317
300
  }
318
-
319
- params['WIDTH'] = tileSize[0];
320
- params['HEIGHT'] = tileSize[1];
321
-
322
- params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
323
-
324
- if (!('STYLES' in this.params_)) {
325
- params['STYLES'] = '';
326
- }
327
-
328
- if (pixelRatio != 1) {
329
- switch (this.serverType_) {
330
- case 'geoserver':
331
- const dpi = (90 * pixelRatio + 0.5) | 0;
332
- if ('FORMAT_OPTIONS' in params) {
333
- params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
334
- } else {
335
- params['FORMAT_OPTIONS'] = 'dpi:' + dpi;
336
- }
337
- break;
338
- case 'mapserver':
339
- params['MAP_RESOLUTION'] = 90 * pixelRatio;
340
- break;
341
- case 'carmentaserver':
342
- case 'qgis':
343
- params['DPI'] = 90 * pixelRatio;
344
- break;
345
- default: // Unknown `serverType` configured
346
- assert(false, 52);
347
- break;
348
- }
349
- }
350
-
351
- const axisOrientation = projection.getAxisOrientation();
352
- const bbox = tileExtent;
353
- if (this.v13_ && axisOrientation.substr(0, 2) == 'ne') {
354
- let tmp;
355
- tmp = tileExtent[0];
356
- bbox[0] = tileExtent[1];
357
- bbox[1] = tmp;
358
- tmp = tileExtent[2];
359
- bbox[2] = tileExtent[3];
360
- bbox[3] = tmp;
361
- }
362
- params['BBOX'] = bbox.join(',');
363
-
364
301
  let url;
365
302
  if (urls.length == 1) {
366
303
  url = urls[0];
@@ -368,7 +305,18 @@ class TileWMS extends TileImage {
368
305
  const index = modulo(tileCoordHash(tileCoord), urls.length);
369
306
  url = urls[index];
370
307
  }
371
- return appendParams(url, params);
308
+
309
+ return getImageSrc(
310
+ tileExtent,
311
+ (
312
+ this.tileGrid || this.getTileGridForProjection(projection)
313
+ ).getResolution(tileCoord[0]),
314
+ pixelRatio,
315
+ projection,
316
+ url,
317
+ params,
318
+ this.serverType_
319
+ );
372
320
  }
373
321
 
374
322
  /**
@@ -435,30 +383,19 @@ class TileWMS extends TileImage {
435
383
 
436
384
  const tileResolution = tileGrid.getResolution(tileCoord[0]);
437
385
  let tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
438
- let tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
439
386
 
440
387
  const gutter = this.gutter_;
441
388
  if (gutter !== 0) {
442
- tileSize = bufferSize(tileSize, gutter, this.tmpSize);
443
389
  tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
444
390
  }
445
391
 
446
- if (pixelRatio != 1) {
447
- tileSize = scaleSize(tileSize, pixelRatio, this.tmpSize);
448
- }
449
-
450
- const baseParams = {
451
- 'SERVICE': 'WMS',
452
- 'VERSION': DEFAULT_VERSION,
453
- 'REQUEST': 'GetMap',
454
- 'FORMAT': 'image/png',
455
- 'TRANSPARENT': true,
456
- };
457
- Object.assign(baseParams, this.params_);
392
+ const baseParams = Object.assign(
393
+ {},
394
+ getRequestParams(this.params_, 'GetMap')
395
+ );
458
396
 
459
397
  return this.getRequestUrl_(
460
398
  tileCoord,
461
- tileSize,
462
399
  tileExtent,
463
400
  pixelRatio,
464
401
  projection,
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @param {string} baseUrl Base URL for the ArcGIS Rest service.
3
+ * @param {import("../extent.js").Extent} extent Extent.
4
+ * @param {number} resolution Resolution.
5
+ * @param {number} pixelRatio Pixel ratio.
6
+ * @param {import("../proj/Projection.js").default} projection Projection.
7
+ * @param {Object} params Params.
8
+ * @return {string} Request URL.
9
+ */
10
+ export function getRequestUrl(baseUrl: string, extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default, params: any): string;
11
+ /**
12
+ * @typedef {Object} LoaderOptions
13
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
14
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
15
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
16
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting the image from
17
+ * the remote server.
18
+ * @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service
19
+ * defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
20
+ * `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
21
+ * will be set dynamically. Set `LAYERS` to override the default service layer visibility. See
22
+ * https://developers.arcgis.com/rest/services-reference/export-map.htm
23
+ * for further reference.
24
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is 'EPSG:3857'.
25
+ * The projection code must contain a numeric end portion separated by :
26
+ * or the entire code must form a valid ArcGIS SpatialReference definition.
27
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport,
28
+ * `2` means twice the size of the map viewport, and so on.
29
+ * @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The url
30
+ * should include /MapServer or /ImageServer.
31
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
32
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
33
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
34
+ */
35
+ /**
36
+ * Creates a loader for ArcGIS Rest images.
37
+ * @param {LoaderOptions} options Image ArcGIS Rest Options.
38
+ * @return {import('../Image.js').ImageObjectPromiseLoader} ArcGIS Rest image.
39
+ * @api
40
+ */
41
+ export function createLoader(options: LoaderOptions): import('../Image.js').ImageObjectPromiseLoader;
42
+ export type LoaderOptions = {
43
+ /**
44
+ * The `crossOrigin` attribute for loaded images. Note that
45
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
46
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
47
+ */
48
+ crossOrigin?: string | null | undefined;
49
+ /**
50
+ * Use the `ol/Map#pixelRatio` value when requesting the image from
51
+ * the remote server.
52
+ */
53
+ hidpi?: boolean | undefined;
54
+ /**
55
+ * ArcGIS Rest parameters. This field is optional. Service
56
+ * defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
57
+ * `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
58
+ * will be set dynamically. Set `LAYERS` to override the default service layer visibility. See
59
+ * https://developers.arcgis.com/rest/services-reference/export-map.htm
60
+ * for further reference.
61
+ */
62
+ params?: {
63
+ [x: string]: any;
64
+ } | undefined;
65
+ /**
66
+ * Projection. Default is 'EPSG:3857'.
67
+ * The projection code must contain a numeric end portion separated by :
68
+ * or the entire code must form a valid ArcGIS SpatialReference definition.
69
+ */
70
+ projection?: import("../proj.js").ProjectionLike;
71
+ /**
72
+ * Ratio. `1` means image requests are the size of the map viewport,
73
+ * `2` means twice the size of the map viewport, and so on.
74
+ */
75
+ ratio?: number | undefined;
76
+ /**
77
+ * ArcGIS Rest service URL for a Map Service or Image Service. The url
78
+ * should include /MapServer or /ImageServer.
79
+ */
80
+ url?: string | undefined;
81
+ /**
82
+ * 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
+ load?: ((arg0: HTMLImageElement, arg1: string) => Promise<import('../DataTile.js').ImageLike>) | undefined;
87
+ };
88
+ //# sourceMappingURL=arcgisRest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgisRest.d.ts","sourceRoot":"","sources":["arcgisRest.js"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH,uCARW,MAAM,UACN,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,gBAEtC,MAAM,CAwCjB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;GAKG;AACH,sCAJW,aAAa,GACZ,OAAO,aAAa,EAAE,wBAAwB,CAwCzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAvDa,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;mBAO1B,gBAAgB,QAAE,MAAM,KAAG,QAAQ,OAAO,gBAAgB,EAAE,SAAS,CAAC"}