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
@@ -0,0 +1,131 @@
1
+ /**
2
+ * @module ol/source/arcgisRest
3
+ */
4
+
5
+ import {DECIMALS} from './common.js';
6
+ import {appendParams} from '../uri.js';
7
+ import {assert} from '../asserts.js';
8
+ import {decode} from '../Image.js';
9
+ import {getHeight, getWidth} from '../extent.js';
10
+ import {get as getProjection} from '../proj.js';
11
+ import {getRequestExtent} from './Image.js';
12
+ import {round} from '../math.js';
13
+
14
+ /**
15
+ * @param {string} baseUrl Base URL for the ArcGIS Rest service.
16
+ * @param {import("../extent.js").Extent} extent Extent.
17
+ * @param {number} resolution Resolution.
18
+ * @param {number} pixelRatio Pixel ratio.
19
+ * @param {import("../proj/Projection.js").default} projection Projection.
20
+ * @param {Object} params Params.
21
+ * @return {string} Request URL.
22
+ */
23
+ export function getRequestUrl(
24
+ baseUrl,
25
+ extent,
26
+ resolution,
27
+ pixelRatio,
28
+ projection,
29
+ params
30
+ ) {
31
+ // ArcGIS Server only wants the numeric portion of the projection ID.
32
+ // (if there is no numeric portion the entire projection code must
33
+ // form a valid ArcGIS SpatialReference definition).
34
+ const srid = projection
35
+ .getCode()
36
+ .split(/:(?=\d+$)/)
37
+ .pop();
38
+
39
+ const imageResolution = resolution / pixelRatio;
40
+
41
+ const imageSize = [
42
+ round(getWidth(extent) / imageResolution, DECIMALS),
43
+ round(getHeight(extent) / imageResolution, DECIMALS),
44
+ ];
45
+
46
+ params['SIZE'] = imageSize[0] + ',' + imageSize[1];
47
+ params['BBOX'] = extent.join(',');
48
+ params['BBOXSR'] = srid;
49
+ params['IMAGESR'] = srid;
50
+ params['DPI'] = Math.round(
51
+ params['DPI'] ? params['DPI'] * pixelRatio : 90 * pixelRatio
52
+ );
53
+
54
+ const modifiedUrl = baseUrl
55
+ .replace(/MapServer\/?$/, 'MapServer/export')
56
+ .replace(/ImageServer\/?$/, 'ImageServer/exportImage');
57
+ if (modifiedUrl == baseUrl) {
58
+ assert(false, 50); // `options.featureTypes` should be an Array
59
+ }
60
+ return appendParams(modifiedUrl, params);
61
+ }
62
+
63
+ /**
64
+ * @typedef {Object} LoaderOptions
65
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
66
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
67
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
68
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting the image from
69
+ * the remote server.
70
+ * @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service
71
+ * defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
72
+ * `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
73
+ * will be set dynamically. Set `LAYERS` to override the default service layer visibility. See
74
+ * https://developers.arcgis.com/rest/services-reference/export-map.htm
75
+ * for further reference.
76
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is 'EPSG:3857'.
77
+ * The projection code must contain a numeric end portion separated by :
78
+ * or the entire code must form a valid ArcGIS SpatialReference definition.
79
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport,
80
+ * `2` means twice the size of the map viewport, and so on.
81
+ * @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The url
82
+ * should include /MapServer or /ImageServer.
83
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
84
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
85
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
86
+ */
87
+
88
+ /**
89
+ * Creates a loader for ArcGIS Rest images.
90
+ * @param {LoaderOptions} options Image ArcGIS Rest Options.
91
+ * @return {import('../Image.js').ImageObjectPromiseLoader} ArcGIS Rest image.
92
+ * @api
93
+ */
94
+ export function createLoader(options) {
95
+ const load = options.load ? options.load : decode;
96
+ const projection = getProjection(options.projection || 'EPSG:3857');
97
+
98
+ /** @type {import('../Image.js').ImageObjectPromiseLoader} */
99
+ return function (extent, resolution, pixelRatio) {
100
+ pixelRatio = options.hidpi ? pixelRatio : 1;
101
+
102
+ const params = {
103
+ 'F': 'image',
104
+ 'FORMAT': 'PNG32',
105
+ 'TRANSPARENT': true,
106
+ };
107
+ Object.assign(params, options.params);
108
+
109
+ extent = getRequestExtent(extent, resolution, pixelRatio, options.ratio);
110
+
111
+ const src = getRequestUrl(
112
+ options.url,
113
+ extent,
114
+ resolution,
115
+ pixelRatio,
116
+ projection,
117
+ params
118
+ );
119
+
120
+ const image = new Image();
121
+ if (options.crossOrigin !== null) {
122
+ image.crossOrigin = options.crossOrigin;
123
+ }
124
+
125
+ return load(image, src).then((image) => {
126
+ // Update resolution, because the server may return a smaller size than requested
127
+ const resolution = (getWidth(extent) / image.width) * pixelRatio;
128
+ return {image, extent, resolution, pixelRatio};
129
+ });
130
+ };
131
+ }
@@ -6,4 +6,9 @@
6
6
  * @type {string}
7
7
  */
8
8
  export const DEFAULT_WMS_VERSION: string;
9
+ /**
10
+ * Number of decimal digits to consider in integer values when rounding.
11
+ * @type {number}
12
+ */
13
+ export const DECIMALS: number;
9
14
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,kCAFU,MAAM,CAE2B"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,kCAFU,MAAM,CAE2B;AAE3C;;;GAGG;AACH,uBAFU,MAAM,CAEU"}
package/source/common.js CHANGED
@@ -7,3 +7,9 @@
7
7
  * @type {string}
8
8
  */
9
9
  export const DEFAULT_WMS_VERSION = '1.3.0';
10
+
11
+ /**
12
+ * Number of decimal digits to consider in integer values when rounding.
13
+ * @type {number}
14
+ */
15
+ export const DECIMALS = 4;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Creates a loader for MapGuide images.
3
+ * @param {LoaderOptions} options Image ArcGIS Rest Options.
4
+ * @return {import('../Image.js').ImageObjectPromiseLoader} ArcGIS Rest image.
5
+ * @api
6
+ */
7
+ export function createLoader(options: LoaderOptions): import('../Image.js').ImageObjectPromiseLoader;
8
+ export type LoaderOptions = {
9
+ /**
10
+ * The mapagent url.
11
+ */
12
+ url?: string | undefined;
13
+ /**
14
+ * The `crossOrigin` attribute for loaded images. Note that
15
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
16
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
17
+ */
18
+ crossOrigin?: string | null | undefined;
19
+ /**
20
+ * The display resolution.
21
+ */
22
+ displayDpi?: number | undefined;
23
+ /**
24
+ * The meters-per-unit value.
25
+ */
26
+ metersPerUnit?: number | undefined;
27
+ /**
28
+ * Use the `ol/Map#pixelRatio` value when requesting
29
+ * the image from the remote server.
30
+ */
31
+ hidpi?: boolean | undefined;
32
+ /**
33
+ * If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
34
+ */
35
+ useOverlay?: boolean | undefined;
36
+ /**
37
+ * Ratio. `1` means image requests are the size of the map viewport, `2` means
38
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
39
+ */
40
+ ratio?: number | undefined;
41
+ /**
42
+ * Additional query parameters.
43
+ */
44
+ params?: any;
45
+ /**
46
+ * Function
47
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
48
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module :ol/Image.decode}.
49
+ */
50
+ load?: ((arg0: HTMLImageElement, arg1: string) => Promise<import('../DataTile.js').ImageLike>) | undefined;
51
+ };
52
+ //# sourceMappingURL=mapguide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapguide.d.ts","sourceRoot":"","sources":["mapguide.js"],"names":[],"mappings":"AAqFA;;;;;GAKG;AACH,sCAJW,aAAa,GACZ,OAAO,aAAa,EAAE,wBAAwB,CA2BzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA5FsB,gBAAgB,QAAE,MAAM,KAAG,QAAQ,OAAO,gBAAgB,EAAE,SAAS,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @module ol/source/mapguide
3
+ */
4
+
5
+ import {appendParams} from '../uri.js';
6
+ import {decode} from '../Image.js';
7
+ import {getCenter, getHeight, getWidth} from '../extent.js';
8
+ import {getRequestExtent} from './Image.js';
9
+
10
+ /**
11
+ * @typedef {Object} LoaderOptions
12
+ * @property {string} [url] The mapagent url.
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 {number} [displayDpi=96] The display resolution.
17
+ * @property {number} [metersPerUnit=1] The meters-per-unit value.
18
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
19
+ * the image from the remote server.
20
+ * @property {boolean} [useOverlay] If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
21
+ * @property {number} [ratio=1] Ratio. `1` means image requests are the size of the map viewport, `2` means
22
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
23
+ * @property {Object} [params] Additional query parameters.
24
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
25
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
26
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
27
+ */
28
+
29
+ /**
30
+ * @param {import("../extent.js").Extent} extent The map extents.
31
+ * @param {import("../size.js").Size} size The viewport size.
32
+ * @param {number} metersPerUnit The meters-per-unit value.
33
+ * @param {number} dpi The display resolution.
34
+ * @return {number} The computed map scale.
35
+ */
36
+ function getScale(extent, size, metersPerUnit, dpi) {
37
+ const mcsW = getWidth(extent);
38
+ const mcsH = getHeight(extent);
39
+ const devW = size[0];
40
+ const devH = size[1];
41
+ const mpp = 0.0254 / dpi;
42
+ if (devH * mcsW > devW * mcsH) {
43
+ return (mcsW * metersPerUnit) / (devW * mpp); // width limited
44
+ }
45
+ return (mcsH * metersPerUnit) / (devH * mpp); // height limited
46
+ }
47
+
48
+ /**
49
+ * @param {string} baseUrl The mapagent url.
50
+ * @param {Object<string, string|number>} params Request parameters.
51
+ * @param {import("../extent.js").Extent} extent Extent.
52
+ * @param {import("../size.js").Size} size Size.
53
+ * @param {boolean} useOverlay If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
54
+ * @param {number} metersPerUnit The meters-per-unit value.
55
+ * @param {number} displayDpi The display resolution.
56
+ * @return {string} The mapagent map image request URL.
57
+ */
58
+ function getUrl(
59
+ baseUrl,
60
+ params,
61
+ extent,
62
+ size,
63
+ useOverlay,
64
+ metersPerUnit,
65
+ displayDpi
66
+ ) {
67
+ const scale = getScale(extent, size, metersPerUnit, displayDpi);
68
+ const center = getCenter(extent);
69
+ const baseParams = {
70
+ 'OPERATION': useOverlay ? 'GETDYNAMICMAPOVERLAYIMAGE' : 'GETMAPIMAGE',
71
+ 'VERSION': '2.0.0',
72
+ 'LOCALE': 'en',
73
+ 'CLIENTAGENT': 'ol/source/ImageMapGuide source',
74
+ 'CLIP': '1',
75
+ 'SETDISPLAYDPI': displayDpi,
76
+ 'SETDISPLAYWIDTH': Math.round(size[0]),
77
+ 'SETDISPLAYHEIGHT': Math.round(size[1]),
78
+ 'SETVIEWSCALE': scale,
79
+ 'SETVIEWCENTERX': center[0],
80
+ 'SETVIEWCENTERY': center[1],
81
+ };
82
+ Object.assign(baseParams, params);
83
+ return appendParams(baseUrl, baseParams);
84
+ }
85
+
86
+ /**
87
+ * Creates a loader for MapGuide images.
88
+ * @param {LoaderOptions} options Image ArcGIS Rest Options.
89
+ * @return {import('../Image.js').ImageObjectPromiseLoader} ArcGIS Rest image.
90
+ * @api
91
+ */
92
+ export function createLoader(options) {
93
+ const load = options.load || decode;
94
+
95
+ /** @type {import('../Image.js').ImageObjectPromiseLoader} */
96
+ return function (extent, resolution, pixelRatio) {
97
+ const image = new Image();
98
+ if (options.crossOrigin !== null) {
99
+ image.crossOrigin = options.crossOrigin;
100
+ }
101
+ extent = getRequestExtent(extent, resolution, pixelRatio, options.ratio);
102
+ const width = getWidth(extent) / resolution;
103
+ const height = getHeight(extent) / resolution;
104
+ const size = [width * pixelRatio, height * pixelRatio];
105
+ const src = getUrl(
106
+ options.url,
107
+ options.params,
108
+ extent,
109
+ size,
110
+ options.useOverlay,
111
+ options.metersPerUnit || 1,
112
+ options.displayDpi || 96
113
+ );
114
+ return load(image, src).then((image) => ({image, extent, pixelRatio}));
115
+ };
116
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @typedef {Object} LoaderOptions
3
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
4
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
5
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
6
+ * @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
7
+ * This is the [left, bottom, right, top] map coordinates of your image. When using this loader with an
8
+ * `ol/source/Image`, the same extent must be set as `extent` of the `ol/layer/Image`.
9
+ * @property {string} url Image URL.
10
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
11
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
12
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
13
+ */
14
+ /**
15
+ * Creates a loader for static images.
16
+ * @param {LoaderOptions} options Loader options.
17
+ * @return {import("../Image.js").ImageObjectPromiseLoader} Loader.
18
+ * @api
19
+ */
20
+ export function createLoader(options: LoaderOptions): import("../Image.js").ImageObjectPromiseLoader;
21
+ export type LoaderOptions = {
22
+ /**
23
+ * The `crossOrigin` attribute for loaded images. Note that
24
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
25
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
26
+ */
27
+ crossOrigin?: string | null | undefined;
28
+ /**
29
+ * Extent of the image in map coordinates.
30
+ * This is the [left, bottom, right, top] map coordinates of your image. When using this loader with an
31
+ * `ol/source/Image`, the same extent must be set as `extent` of the `ol/layer/Image`.
32
+ */
33
+ imageExtent?: import("../extent.js").Extent | undefined;
34
+ /**
35
+ * Image URL.
36
+ */
37
+ url: string;
38
+ /**
39
+ * Function
40
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
41
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module :ol/Image.decode}.
42
+ */
43
+ load?: ((arg0: HTMLImageElement, arg1: string) => Promise<import('../DataTile.js').ImageLike>) | undefined;
44
+ };
45
+ //# sourceMappingURL=static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["static.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,sCAJW,aAAa,GACZ,OAAO,aAAa,EAAE,wBAAwB,CAmBzD;;;;;;;;;;;;;;;;;SA5Ba,MAAM;;;;;;mBACG,gBAAgB,QAAE,MAAM,KAAG,QAAQ,OAAO,gBAAgB,EAAE,SAAS,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @module ol/source/static
3
+ */
4
+
5
+ import {decode} from '../Image.js';
6
+ import {getHeight, getWidth} from '../extent.js';
7
+
8
+ /**
9
+ * @typedef {Object} LoaderOptions
10
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
11
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
12
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
13
+ * @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
14
+ * This is the [left, bottom, right, top] map coordinates of your image. When using this loader with an
15
+ * `ol/source/Image`, the same extent must be set as `extent` of the `ol/layer/Image`.
16
+ * @property {string} url Image URL.
17
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
18
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
19
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
20
+ */
21
+
22
+ /**
23
+ * Creates a loader for static images.
24
+ * @param {LoaderOptions} options Loader options.
25
+ * @return {import("../Image.js").ImageObjectPromiseLoader} Loader.
26
+ * @api
27
+ */
28
+ export function createLoader(options) {
29
+ const load = options.load || decode;
30
+ const extent = options.imageExtent;
31
+ const image = new Image();
32
+ if (options.crossOrigin !== null) {
33
+ image.crossOrigin = options.crossOrigin;
34
+ }
35
+
36
+ return () =>
37
+ load(image, options.url).then((image) => {
38
+ const resolutionX = getWidth(extent) / image.width;
39
+ const resolutionY = getHeight(extent) / image.height;
40
+ const resolution =
41
+ resolutionX !== resolutionY ? [resolutionX, resolutionY] : resolutionY;
42
+ return {image, extent, resolution, pixelRatio: 1};
43
+ });
44
+ }
package/source/wms.d.ts CHANGED
@@ -1,6 +1,67 @@
1
1
  /**
2
- * @module ol/source/wms
2
+ * @api
3
+ * @typedef {'carmentaserver' | 'geoserver' | 'mapserver' | 'qgis'} ServerType
4
+ * Set the server type to use implementation-specific parameters beyond the WMS specification.
5
+ * - `'carmentaserver'`: HiDPI support for [Carmenta Server](https://www.carmenta.com/en/products/carmenta-server)
6
+ * - `'geoserver'`: HiDPI support for [GeoServer](https://geoserver.org/)
7
+ * - `'mapserver'`: HiDPI support for [MapServer](https://mapserver.org/)
8
+ * - `'qgis'`: HiDPI support for [QGIS](https://qgis.org/)
9
+ */
10
+ /**
11
+ * @param {string} baseUrl Base URL.
12
+ * @param {import("../extent.js").Extent} extent Extent.
13
+ * @param {import("../size.js").Size} size Size.
14
+ * @param {import("../proj/Projection.js").default} projection Projection.
15
+ * @param {Object} params WMS params. Will be modified in place.
16
+ * @return {string} Request URL.
17
+ */
18
+ export function getRequestUrl(baseUrl: string, extent: import("../extent.js").Extent, size: import("../size.js").Size, projection: import("../proj/Projection.js").default, params: any): string;
19
+ /**
20
+ * @param {import("../extent").Extent} extent Extent.
21
+ * @param {number} resolution Resolution.
22
+ * @param {number} pixelRatio pixel ratio.
23
+ * @param {import("../proj.js").Projection} projection Projection.
24
+ * @param {string} url WMS service url.
25
+ * @param {Object} params WMS params.
26
+ * @param {import("./wms.js").ServerType} serverType The type of the remote WMS server.
27
+ * @return {string} Image src.
28
+ */
29
+ export function getImageSrc(extent: import("../extent").Extent, resolution: number, pixelRatio: number, projection: import("../proj.js").Projection, url: string, params: any, serverType: import("./wms.js").ServerType): string;
30
+ /**
31
+ * @param {Object} params WMS params.
32
+ * @param {string} request WMS `REQUEST`.
33
+ * @return {Object} WMS params with required properties set.
34
+ */
35
+ export function getRequestParams(params: any, request: string): any;
36
+ /**
37
+ * @typedef {Object} LoaderOptions
38
+ * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
39
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
40
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
41
+ * @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
42
+ * the image from the remote server.
43
+ * @property {Object<string,*>} [params] WMS request parameters.
44
+ * At least a `LAYERS` param is required. `STYLES` is
45
+ * `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT` and `BBOX` will be set
46
+ * dynamically. `CRS` (`SRS` for WMS version < 1.3.0) will is derived from the `proection` config.
47
+ * @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is 'EPSG:3857'.
48
+ * @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
49
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
50
+ * @property {import("./wms.js").ServerType} [serverType] The type of
51
+ * the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
52
+ * Only needed if `hidpi` is `true`.
53
+ * @property {string} url WMS service URL.
54
+ * @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
55
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
56
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
57
+ */
58
+ /**
59
+ * Creates a loader for WMS images.
60
+ * @param {LoaderOptions} options Loader options.
61
+ * @return {import("../Image.js").ImageObjectPromiseLoader} Loader.
62
+ * @api
3
63
  */
64
+ export function createLoader(options: LoaderOptions): import("../Image.js").ImageObjectPromiseLoader;
4
65
  /**
5
66
  * Default WMS version.
6
67
  * @type {string}
@@ -14,4 +75,51 @@ export const DEFAULT_VERSION: string;
14
75
  * - `'qgis'`: HiDPI support for [QGIS](https://qgis.org/)
15
76
  */
16
77
  export type ServerType = 'carmentaserver' | 'geoserver' | 'mapserver' | 'qgis';
78
+ export type LoaderOptions = {
79
+ /**
80
+ * The `crossOrigin` attribute for loaded images. Note that
81
+ * you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
82
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
83
+ */
84
+ crossOrigin?: string | null | undefined;
85
+ /**
86
+ * Use the `ol/Map#pixelRatio` value when requesting
87
+ * the image from the remote server.
88
+ */
89
+ hidpi?: boolean | undefined;
90
+ /**
91
+ * WMS request parameters.
92
+ * At least a `LAYERS` param is required. `STYLES` is
93
+ * `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT` and `BBOX` will be set
94
+ * dynamically. `CRS` (`SRS` for WMS version < 1.3.0) will is derived from the `proection` config.
95
+ */
96
+ params?: {
97
+ [x: string]: any;
98
+ } | undefined;
99
+ /**
100
+ * Projection. Default is 'EPSG:3857'.
101
+ */
102
+ projection?: import("../proj.js").ProjectionLike;
103
+ /**
104
+ * Ratio. `1` means image requests are the size of the map viewport, `2` means
105
+ * twice the width and height of the map viewport, and so on. Must be `1` or higher.
106
+ */
107
+ ratio?: number | undefined;
108
+ /**
109
+ * The type of
110
+ * the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
111
+ * Only needed if `hidpi` is `true`.
112
+ */
113
+ serverType?: ServerType | undefined;
114
+ /**
115
+ * WMS service URL.
116
+ */
117
+ url: string;
118
+ /**
119
+ * Function
120
+ * to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
121
+ * returns a promise resolving to the loaded or decoded image. Default is {@link module :ol/Image.decode}.
122
+ */
123
+ load?: ((arg0: HTMLImageElement, arg1: string) => Promise<import('../DataTile.js').ImageLike>) | undefined;
124
+ };
17
125
  //# sourceMappingURL=wms.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wms.d.ts","sourceRoot":"","sources":["wms.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,8BAFU,MAAM,CAEuB;;;;;;;;yBAI1B,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM"}
1
+ {"version":3,"file":"wms.d.ts","sourceRoot":"","sources":["wms.js"],"names":[],"mappings":"AAoBA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,uCAPW,MAAM,UACN,OAAO,cAAc,EAAE,MAAM,QAC7B,OAAO,YAAY,EAAE,IAAI,cACzB,OAAO,uBAAuB,EAAE,OAAO,gBAEtC,MAAM,CAkBjB;AAED;;;;;;;;;GASG;AACH,oCATW,OAAO,WAAW,EAAE,MAAM,cAC1B,MAAM,cACN,MAAM,cACN,OAAO,YAAY,EAAE,UAAU,OAC/B,MAAM,2BAEN,OAAO,UAAU,EAAE,UAAU,GAC5B,MAAM,CA6CjB;AAED;;;;GAIG;AACH,uDAHW,MAAM,OAehB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,sCAJW,aAAa,GACZ,OAAO,aAAa,EAAE,wBAAwB,CAgCzD;AA9KD;;;GAGG;AACH,8BAFU,MAAM,CAEuB;;;;;;;;yBAI1B,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;iBAuHpD,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;SAMnC,MAAM;;;;;;mBACG,gBAAgB,QAAE,MAAM,KAAG,QAAQ,OAAO,gBAAgB,EAAE,SAAS,CAAC"}