ol 10.3.2-dev.1738093069363 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.d.ts +4 -0
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/package.json +1 -1
- package/source/mapserver.d.ts +38 -0
- package/source/mapserver.d.ts.map +1 -0
- package/source/mapserver.js +76 -0
- package/util.d.ts.map +1 -1
- package/util.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a loader for MapServer images generated using the CGI interface,
|
|
3
|
+
* which predates OGC services. It is **strongly** recommended to configure
|
|
4
|
+
* MapServer to use WMS, and use the WMS createLoader.
|
|
5
|
+
* @param {LoaderOptions} options LoaderOptions Options.
|
|
6
|
+
* @return {import('../Image.js').ImageObjectPromiseLoader} MapServer image.
|
|
7
|
+
* @api
|
|
8
|
+
*/
|
|
9
|
+
export function createLoader(options: LoaderOptions): import("../Image.js").ImageObjectPromiseLoader;
|
|
10
|
+
export type LoaderOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* The MapServer url.
|
|
13
|
+
*/
|
|
14
|
+
url: string;
|
|
15
|
+
/**
|
|
16
|
+
* The `crossOrigin` attribute for loaded images. Note that
|
|
17
|
+
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
|
18
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
|
19
|
+
* the image from the remote server.
|
|
20
|
+
*/
|
|
21
|
+
crossOrigin?: string | null | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Ratio. `1` means image requests are the size of the map viewport, `2` means
|
|
24
|
+
* twice the width and height of the map viewport, and so on. Must be `1` or higher.
|
|
25
|
+
*/
|
|
26
|
+
ratio?: number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Additional query parameters.
|
|
29
|
+
*/
|
|
30
|
+
params?: any;
|
|
31
|
+
/**
|
|
32
|
+
* Function
|
|
33
|
+
* to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
|
|
34
|
+
* returns a promise resolving to the loaded or decoded image. Default is {@link module :ol/Image.decode}.
|
|
35
|
+
*/
|
|
36
|
+
load?: ((arg0: HTMLImageElement, arg1: string) => Promise<import("../DataTile.js").ImageLike>) | undefined;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=mapserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapserver.d.ts","sourceRoot":"","sources":["mapserver.js"],"names":[],"mappings":"AAmDA;;;;;;;GAOG;AACH,sCAJW,aAAa,GACZ,OAAO,aAAa,EAAE,wBAAwB,CAmBzD;;;;;SAhEa,MAAM;;;;;;;;;;;;;;;;;;;;;;mBAQG,gBAAgB,QAAE,MAAM,KAAG,OAAO,CAAC,OAAO,gBAAgB,EAAE,SAAS,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ol/source/mapserver
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {decode} from '../Image.js';
|
|
6
|
+
import {getHeight, getWidth} from '../extent.js';
|
|
7
|
+
import {appendParams} from '../uri.js';
|
|
8
|
+
import {getRequestExtent} from './Image.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} LoaderOptions
|
|
12
|
+
* @property {string} url The MapServer 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
|
+
* the image from the remote server.
|
|
17
|
+
* @property {number} [ratio=1] Ratio. `1` means image requests are the size of the map viewport, `2` means
|
|
18
|
+
* twice the width and height of the map viewport, and so on. Must be `1` or higher.
|
|
19
|
+
* @property {Object} [params] Additional query parameters.
|
|
20
|
+
* @property {function(HTMLImageElement, string): Promise<import('../DataTile.js').ImageLike>} [load] Function
|
|
21
|
+
* to perform loading of the image. Receives the created `HTMLImageElement` and the desired `src` as argument and
|
|
22
|
+
* returns a promise resolving to the loaded or decoded image. Default is {@link module:ol/Image.decode}.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} baseUrl The MapServer url.
|
|
27
|
+
* @param {Object<string, string|number>} params Request parameters.
|
|
28
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
29
|
+
* @param {import("../size.js").Size} size Size.
|
|
30
|
+
* @return {string} The MapServer map image request URL.
|
|
31
|
+
*/
|
|
32
|
+
function getUrl(baseUrl, params, extent, size) {
|
|
33
|
+
const width = Math.round(size[0]);
|
|
34
|
+
const height = Math.round(size[1]);
|
|
35
|
+
const mapSize = `${width} ${height}`;
|
|
36
|
+
const mapExt = `${extent[0]} ${extent[1]} ${extent[2]} ${extent[3]}`;
|
|
37
|
+
|
|
38
|
+
const baseParams = {
|
|
39
|
+
mode: 'map',
|
|
40
|
+
map_imagetype: 'png',
|
|
41
|
+
mapext: mapExt,
|
|
42
|
+
imgext: mapExt,
|
|
43
|
+
map_size: mapSize,
|
|
44
|
+
imgx: width / 2,
|
|
45
|
+
imgy: height / 2,
|
|
46
|
+
imgxy: mapSize,
|
|
47
|
+
};
|
|
48
|
+
Object.assign(baseParams, params);
|
|
49
|
+
return appendParams(baseUrl, baseParams);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates a loader for MapServer images generated using the CGI interface,
|
|
54
|
+
* which predates OGC services. It is **strongly** recommended to configure
|
|
55
|
+
* MapServer to use WMS, and use the WMS createLoader.
|
|
56
|
+
* @param {LoaderOptions} options LoaderOptions Options.
|
|
57
|
+
* @return {import('../Image.js').ImageObjectPromiseLoader} MapServer image.
|
|
58
|
+
* @api
|
|
59
|
+
*/
|
|
60
|
+
export function createLoader(options) {
|
|
61
|
+
const load = options.load || decode;
|
|
62
|
+
const ratio = options.ratio ?? 1;
|
|
63
|
+
const crossOrigin = options.crossOrigin ?? null;
|
|
64
|
+
|
|
65
|
+
/** @type {import('../Image.js').ImageObjectPromiseLoader} */
|
|
66
|
+
return function (extent, resolution, pixelRatio) {
|
|
67
|
+
const image = new Image();
|
|
68
|
+
image.crossOrigin = crossOrigin;
|
|
69
|
+
extent = getRequestExtent(extent, resolution, pixelRatio, ratio);
|
|
70
|
+
const width = getWidth(extent) / resolution;
|
|
71
|
+
const height = getHeight(extent) / resolution;
|
|
72
|
+
const size = [width * pixelRatio, height * pixelRatio];
|
|
73
|
+
const src = getUrl(options.url, options.params, extent, size);
|
|
74
|
+
return load(image, src).then((image) => ({image, extent, pixelRatio}));
|
|
75
|
+
};
|
|
76
|
+
}
|
package/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["util.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,4BAFY,KAAK,CAIhB;AASD;;;;;;;;GAQG;AACH,kCAHY,MAAM,CAKjB;AAED;;;GAGG;AACH,sBAFU,MAAM,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["util.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,4BAFY,KAAK,CAIhB;AASD;;;;;;;;GAQG;AACH,kCAHY,MAAM,CAKjB;AAED;;;GAGG;AACH,sBAFU,MAAM,CAEgB"}
|
package/util.js
CHANGED