planning
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions
+261
View File
@@ -0,0 +1,261 @@
/**
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coord.
* @return {string} Quad key.
*/
export function quadKey(tileCoord: import('../tilecoord.js').TileCoord): string;
export default BingMaps;
export type Options = {
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* If `true` hidpi tiles will be requested.
*/
hidpi?: boolean | undefined;
/**
* Culture code.
*/
culture?: string | undefined;
/**
* Bing Maps API key. Get yours at https://www.bingmapsportal.com/.
*/
key: string;
/**
* Type of imagery.
*/
imagerySet: string;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Max zoom. Default is what's advertized by the BingMaps service.
*/
maxZoom?: number | undefined;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
export type BingMapsImageryMetadataResponse = {
/**
* The response status code
*/
statusCode: number;
/**
* The response status description
*/
statusDescription: string;
/**
* The authentication result code
*/
authenticationResultCode: string;
/**
* The array of resource sets
*/
resourceSets: Array<ResourceSet>;
};
export type ResourceSet = {
/**
* Resources.
*/
resources: Array<Resource>;
};
export type Resource = {
/**
* The image height
*/
imageHeight: number;
/**
* The image width
*/
imageWidth: number;
/**
* The minimum zoom level
*/
zoomMin: number;
/**
* The maximum zoom level
*/
zoomMax: number;
/**
* The image URL
*/
imageUrl: string;
/**
* The image URL subdomains for rotation
*/
imageUrlSubdomains: Array<string>;
/**
* The array of ImageryProviders
*/
imageryProviders?: ImageryProvider[] | undefined;
};
export type ImageryProvider = {
/**
* The coverage areas
*/
coverageAreas: Array<CoverageArea>;
/**
* The attribution
*/
attribution?: string | undefined;
};
export type CoverageArea = {
/**
* The minimum zoom
*/
zoomMin: number;
/**
* The maximum zoom
*/
zoomMax: number;
/**
* The coverage bounding box
*/
bbox: Array<number>;
};
/**
* @typedef {Object} Options
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {boolean} [hidpi=false] If `true` hidpi tiles will be requested.
* @property {string} [culture='en-us'] Culture code.
* @property {string} key Bing Maps API key. Get yours at https://www.bingmapsportal.com/.
* @property {string} imagerySet Type of imagery.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {number} [maxZoom=21] Max zoom. Default is what's advertized by the BingMaps service.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @typedef {Object} BingMapsImageryMetadataResponse
* @property {number} statusCode The response status code
* @property {string} statusDescription The response status description
* @property {string} authenticationResultCode The authentication result code
* @property {Array<ResourceSet>} resourceSets The array of resource sets
*/
/**
* @typedef {Object} ResourceSet
* @property {Array<Resource>} resources Resources.
*/
/**
* @typedef {Object} Resource
* @property {number} imageHeight The image height
* @property {number} imageWidth The image width
* @property {number} zoomMin The minimum zoom level
* @property {number} zoomMax The maximum zoom level
* @property {string} imageUrl The image URL
* @property {Array<string>} imageUrlSubdomains The image URL subdomains for rotation
* @property {Array<ImageryProvider>} [imageryProviders] The array of ImageryProviders
*/
/**
* @typedef {Object} ImageryProvider
* @property {Array<CoverageArea>} coverageAreas The coverage areas
* @property {string} [attribution] The attribution
*/
/**
* @typedef {Object} CoverageArea
* @property {number} zoomMin The minimum zoom
* @property {number} zoomMax The maximum zoom
* @property {Array<number>} bbox The coverage bounding box
*/
/**
* @classdesc
* Layer source for Bing Maps tile data.
* @api
*/
declare class BingMaps extends TileImage {
/**
* @param {Options} options Bing Maps options.
*/
constructor(options: Options);
/**
* @private
* @type {boolean}
*/
private hidpi_;
/**
* @private
* @type {string}
*/
private culture_;
/**
* @private
* @type {number}
*/
private maxZoom_;
/**
* @private
* @type {string}
*/
private apiKey_;
/**
* @private
* @type {string}
*/
private imagerySet_;
/**
* Get the api key used for this source.
*
* @return {string} The api key.
* @api
*/
getApiKey(): string;
/**
* Get the imagery set associated with this source.
*
* @return {string} The imagery set.
* @api
*/
getImagerySet(): string;
/**
* @param {BingMapsImageryMetadataResponse} response Response.
*/
handleImageryMetadataResponse(response: BingMapsImageryMetadataResponse): void;
}
import TileImage from "./TileImage.js";
//# sourceMappingURL=BingMaps.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BingMaps.d.ts","sourceRoot":"","sources":["../src/source/BingMaps.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH,mCAHW,OAAO,iBAAiB,EAAE,SAAS,GAClC,MAAM,CAoBjB;;;;;;;;;;;;;;;;;;SAkBa,MAAM;;;;gBACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAuBN,MAAM;;;;uBACN,MAAM;;;;8BACN,MAAM;;;;kBACN,MAAM,WAAW,CAAC;;;;;;eAKlB,MAAM,QAAQ,CAAC;;;;;;iBAKf,MAAM;;;;gBACN,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;;;;cACN,MAAM;;;;wBACN,MAAM,MAAM,CAAC;;;;;;;;;;mBAMb,MAAM,YAAY,CAAC;;;;;;;;;;aAMnB,MAAM;;;;aACN,MAAM;;;;UACN,MAAM,MAAM,CAAC;;AA7D3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;;;;;;;GASG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAsEjB;IA5CC;;;OAGG;IACH,eAAmB;IAEnB;;;OAGG;IACH,iBAAyE;IAEzE;;;OAGG;IACH,iBAAoE;IAEpE;;;OAGG;IACH,gBAA0B;IAE1B;;;OAGG;IACH,oBAAqC;IAkBvC;;;;;OAKG;IACH,aAHY,MAAM,CAKjB;IAED;;;;;OAKG;IACH,iBAHY,MAAM,CAKjB;IAED;;OAEG;IACH,wCAFW,+BAA+B,QAwHzC;CACF"}
+293
View File
@@ -0,0 +1,293 @@
/**
* @module ol/source/BingMaps
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import TileImage from './TileImage.js';
import { applyTransform, intersects } from '../extent.js';
import { createFromTileUrlFunctions } from '../tileurlfunction.js';
import { createOrUpdate } from '../tilecoord.js';
import { createXYZ, extentFromProjection } from '../tilegrid.js';
import { get as getProjection, getTransformFromProjections } from '../proj.js';
import { jsonp as requestJSONP } from '../net.js';
/**
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coord.
* @return {string} Quad key.
*/
export function quadKey(tileCoord) {
var z = tileCoord[0];
var digits = new Array(z);
var mask = 1 << (z - 1);
var i, charCode;
for (i = 0; i < z; ++i) {
// 48 is charCode for 0 - '0'.charCodeAt(0)
charCode = 48;
if (tileCoord[1] & mask) {
charCode += 1;
}
if (tileCoord[2] & mask) {
charCode += 2;
}
digits[i] = String.fromCharCode(charCode);
mask >>= 1;
}
return digits.join('');
}
/**
* The attribution containing a link to the Microsoft® Bing™ Maps Platform APIs
* Terms Of Use.
* @const
* @type {string}
*/
var TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
'href="https://www.microsoft.com/maps/product/terms.html" target="_blank">' +
'Terms of Use</a>';
/**
* @typedef {Object} Options
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {boolean} [hidpi=false] If `true` hidpi tiles will be requested.
* @property {string} [culture='en-us'] Culture code.
* @property {string} key Bing Maps API key. Get yours at https://www.bingmapsportal.com/.
* @property {string} imagerySet Type of imagery.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {number} [maxZoom=21] Max zoom. Default is what's advertized by the BingMaps service.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @typedef {Object} BingMapsImageryMetadataResponse
* @property {number} statusCode The response status code
* @property {string} statusDescription The response status description
* @property {string} authenticationResultCode The authentication result code
* @property {Array<ResourceSet>} resourceSets The array of resource sets
*/
/**
* @typedef {Object} ResourceSet
* @property {Array<Resource>} resources Resources.
*/
/**
* @typedef {Object} Resource
* @property {number} imageHeight The image height
* @property {number} imageWidth The image width
* @property {number} zoomMin The minimum zoom level
* @property {number} zoomMax The maximum zoom level
* @property {string} imageUrl The image URL
* @property {Array<string>} imageUrlSubdomains The image URL subdomains for rotation
* @property {Array<ImageryProvider>} [imageryProviders] The array of ImageryProviders
*/
/**
* @typedef {Object} ImageryProvider
* @property {Array<CoverageArea>} coverageAreas The coverage areas
* @property {string} [attribution] The attribution
*/
/**
* @typedef {Object} CoverageArea
* @property {number} zoomMin The minimum zoom
* @property {number} zoomMax The maximum zoom
* @property {Array<number>} bbox The coverage bounding box
*/
/**
* @classdesc
* Layer source for Bing Maps tile data.
* @api
*/
var BingMaps = /** @class */ (function (_super) {
__extends(BingMaps, _super);
/**
* @param {Options} options Bing Maps options.
*/
function BingMaps(options) {
var _this = this;
var hidpi = options.hidpi !== undefined ? options.hidpi : false;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
interpolate: interpolate,
opaque: true,
projection: getProjection('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: 'loading',
tileLoadFunction: options.tileLoadFunction,
tilePixelRatio: hidpi ? 2 : 1,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition,
zDirection: options.zDirection,
}) || this;
/**
* @private
* @type {boolean}
*/
_this.hidpi_ = hidpi;
/**
* @private
* @type {string}
*/
_this.culture_ = options.culture !== undefined ? options.culture : 'en-us';
/**
* @private
* @type {number}
*/
_this.maxZoom_ = options.maxZoom !== undefined ? options.maxZoom : -1;
/**
* @private
* @type {string}
*/
_this.apiKey_ = options.key;
/**
* @private
* @type {string}
*/
_this.imagerySet_ = options.imagerySet;
var url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
_this.imagerySet_ +
'?uriScheme=https&include=ImageryProviders&key=' +
_this.apiKey_ +
'&c=' +
_this.culture_;
requestJSONP(url, _this.handleImageryMetadataResponse.bind(_this), undefined, 'jsonp');
return _this;
}
/**
* Get the api key used for this source.
*
* @return {string} The api key.
* @api
*/
BingMaps.prototype.getApiKey = function () {
return this.apiKey_;
};
/**
* Get the imagery set associated with this source.
*
* @return {string} The imagery set.
* @api
*/
BingMaps.prototype.getImagerySet = function () {
return this.imagerySet_;
};
/**
* @param {BingMapsImageryMetadataResponse} response Response.
*/
BingMaps.prototype.handleImageryMetadataResponse = function (response) {
if (response.statusCode != 200 ||
response.statusDescription != 'OK' ||
response.authenticationResultCode != 'ValidCredentials' ||
response.resourceSets.length != 1 ||
response.resourceSets[0].resources.length != 1) {
this.setState('error');
return;
}
var resource = response.resourceSets[0].resources[0];
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
var sourceProjection = this.getProjection();
var extent = extentFromProjection(sourceProjection);
var scale = this.hidpi_ ? 2 : 1;
var tileSize = resource.imageWidth == resource.imageHeight
? resource.imageWidth / scale
: [resource.imageWidth / scale, resource.imageHeight / scale];
var tileGrid = createXYZ({
extent: extent,
minZoom: resource.zoomMin,
maxZoom: maxZoom,
tileSize: tileSize,
});
this.tileGrid = tileGrid;
var culture = this.culture_;
var hidpi = this.hidpi_;
this.tileUrlFunction = createFromTileUrlFunctions(resource.imageUrlSubdomains.map(function (subdomain) {
/** @type {import('../tilecoord.js').TileCoord} */
var quadKeyTileCoord = [0, 0, 0];
var imageUrl = resource.imageUrl
.replace('{subdomain}', subdomain)
.replace('{culture}', culture);
return (
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {string|undefined} Tile URL.
*/
function (tileCoord, pixelRatio, projection) {
if (!tileCoord) {
return undefined;
}
else {
createOrUpdate(tileCoord[0], tileCoord[1], tileCoord[2], quadKeyTileCoord);
var url = imageUrl;
if (hidpi) {
url += '&dpi=d1&device=mobile';
}
return url.replace('{quadkey}', quadKey(quadKeyTileCoord));
}
});
}));
if (resource.imageryProviders) {
var transform_1 = getTransformFromProjections(getProjection('EPSG:4326'), this.getProjection());
this.setAttributions(function (frameState) {
var attributions = [];
var viewState = frameState.viewState;
var tileGrid = this.getTileGrid();
var z = tileGrid.getZForResolution(viewState.resolution, this.zDirection);
var tileCoord = tileGrid.getTileCoordForCoordAndZ(viewState.center, z);
var zoom = tileCoord[0];
resource.imageryProviders.map(function (imageryProvider) {
var intersecting = false;
var coverageAreas = imageryProvider.coverageAreas;
for (var i = 0, ii = coverageAreas.length; i < ii; ++i) {
var coverageArea = coverageAreas[i];
if (zoom >= coverageArea.zoomMin &&
zoom <= coverageArea.zoomMax) {
var bbox = coverageArea.bbox;
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
var extent_1 = applyTransform(epsg4326Extent, transform_1);
if (intersects(extent_1, frameState.extent)) {
intersecting = true;
break;
}
}
}
if (intersecting) {
attributions.push(imageryProvider.attribution);
}
});
attributions.push(TOS_ATTRIBUTION);
return attributions;
}.bind(this));
}
this.setState('ready');
};
return BingMaps;
}(TileImage));
export default BingMaps;
//# sourceMappingURL=BingMaps.js.map
+1
View File
File diff suppressed because one or more lines are too long
+184
View File
@@ -0,0 +1,184 @@
export default CartoDB;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Max zoom.
*/
maxZoom?: number | undefined;
/**
* Minimum zoom.
*/
minZoom?: number | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* If using anonymous maps, the CartoDB config to use. See
* https://carto.com/developers/maps-api/guides/anonymous-maps/
* for more detail.
* If using named maps, a key-value lookup with the template parameters.
* See https://carto.com/developers/maps-api/guides/named-maps/
* for more detail.
*/
config?: any;
/**
* If using named maps, this will be the name of the template to load.
* See https://carto.com/developers/maps-api/guides/named-maps/
* for more detail.
*/
map?: string | undefined;
/**
* Username as used to access public Carto dashboard at https://{username}.carto.com/.
*/
account?: string | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
export type CartoDBLayerInfo = {
/**
* The layer group ID
*/
layergroupid: string;
/**
* The CDN URL
*/
cdn_url: {
https: string;
};
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection.
* @property {number} [maxZoom=18] Max zoom.
* @property {number} [minZoom] Minimum zoom.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {Object} [config] If using anonymous maps, the CartoDB config to use. See
* https://carto.com/developers/maps-api/guides/anonymous-maps/
* for more detail.
* If using named maps, a key-value lookup with the template parameters.
* See https://carto.com/developers/maps-api/guides/named-maps/
* for more detail.
* @property {string} [map] If using named maps, this will be the name of the template to load.
* See https://carto.com/developers/maps-api/guides/named-maps/
* for more detail.
* @property {string} [account] Username as used to access public Carto dashboard at https://{username}.carto.com/.
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @typedef {Object} CartoDBLayerInfo
* @property {string} layergroupid The layer group ID
* @property {{https: string}} cdn_url The CDN URL
*/
/**
* @classdesc
* Layer source for the CartoDB Maps API.
* @api
*/
declare class CartoDB extends XYZ {
/**
* @param {Options} options CartoDB options.
*/
constructor(options: Options);
/**
* @type {string}
* @private
*/
private account_;
/**
* @type {string}
* @private
*/
private mapId_;
/**
* @type {!Object}
* @private
*/
private config_;
/**
* @type {!Object<string, CartoDBLayerInfo>}
* @private
*/
private templateCache_;
/**
* Returns the current config.
* @return {!Object} The current configuration.
* @api
*/
getConfig(): any;
/**
* Updates the carto db config.
* @param {Object} config a key-value lookup. Values will replace current values
* in the config.
* @api
*/
updateConfig(config: any): void;
/**
* Sets the CartoDB config
* @param {Object} config In the case of anonymous maps, a CartoDB configuration
* object.
* If using named maps, a key-value lookup with the template parameters.
* @api
*/
setConfig(config: any): void;
/**
* Issue a request to initialize the CartoDB map.
* @private
*/
private initializeMap_;
/**
* Handle map initialization response.
* @param {string} paramHash a hash representing the parameter set that was used
* for the request
* @param {Event} event Event.
* @private
*/
private handleInitResponse_;
/**
* @private
* @param {Event} event Event.
*/
private handleInitError_;
/**
* Apply the new tile urls returned by carto db
* @param {CartoDBLayerInfo} data Result of carto db call.
* @private
*/
private applyTemplate_;
}
import XYZ from "./XYZ.js";
//# sourceMappingURL=CartoDB.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"CartoDB.d.ts","sourceRoot":"","sources":["../src/source/CartoDB.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;iBAcc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuBnC,MAAM;;;;aACN;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC;;AA/B7B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAwCjB;IAzBC;;;OAGG;IACH,iBAA+B;IAE/B;;;OAGG;IACH,eAA+B;IAE/B;;;OAGG;IACH,gBAAmC;IAEnC;;;OAGG;IACH,uBAAwB;IAK1B;;;;OAIG;IACH,iBAEC;IAED;;;;;OAKG;IACH,gCAGC;IAED;;;;;;OAMG;IACH,6BAGC;IAED;;;OAGG;IACH,uBAqBC;IAED;;;;;;OAMG;IACH,4BAmBC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;OAIG;IACH,uBAUC;CACF"}
+200
View File
@@ -0,0 +1,200 @@
/**
* @module ol/source/CartoDB
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import XYZ from './XYZ.js';
import { assign } from '../obj.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection.
* @property {number} [maxZoom=18] Max zoom.
* @property {number} [minZoom] Minimum zoom.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {Object} [config] If using anonymous maps, the CartoDB config to use. See
* https://carto.com/developers/maps-api/guides/anonymous-maps/
* for more detail.
* If using named maps, a key-value lookup with the template parameters.
* See https://carto.com/developers/maps-api/guides/named-maps/
* for more detail.
* @property {string} [map] If using named maps, this will be the name of the template to load.
* See https://carto.com/developers/maps-api/guides/named-maps/
* for more detail.
* @property {string} [account] Username as used to access public Carto dashboard at https://{username}.carto.com/.
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @typedef {Object} CartoDBLayerInfo
* @property {string} layergroupid The layer group ID
* @property {{https: string}} cdn_url The CDN URL
*/
/**
* @classdesc
* Layer source for the CartoDB Maps API.
* @api
*/
var CartoDB = /** @class */ (function (_super) {
__extends(CartoDB, _super);
/**
* @param {Options} options CartoDB options.
*/
function CartoDB(options) {
var _this = _super.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 18,
minZoom: options.minZoom,
projection: options.projection,
transition: options.transition,
wrapX: options.wrapX,
zDirection: options.zDirection,
}) || this;
/**
* @type {string}
* @private
*/
_this.account_ = options.account;
/**
* @type {string}
* @private
*/
_this.mapId_ = options.map || '';
/**
* @type {!Object}
* @private
*/
_this.config_ = options.config || {};
/**
* @type {!Object<string, CartoDBLayerInfo>}
* @private
*/
_this.templateCache_ = {};
_this.initializeMap_();
return _this;
}
/**
* Returns the current config.
* @return {!Object} The current configuration.
* @api
*/
CartoDB.prototype.getConfig = function () {
return this.config_;
};
/**
* Updates the carto db config.
* @param {Object} config a key-value lookup. Values will replace current values
* in the config.
* @api
*/
CartoDB.prototype.updateConfig = function (config) {
assign(this.config_, config);
this.initializeMap_();
};
/**
* Sets the CartoDB config
* @param {Object} config In the case of anonymous maps, a CartoDB configuration
* object.
* If using named maps, a key-value lookup with the template parameters.
* @api
*/
CartoDB.prototype.setConfig = function (config) {
this.config_ = config || {};
this.initializeMap_();
};
/**
* Issue a request to initialize the CartoDB map.
* @private
*/
CartoDB.prototype.initializeMap_ = function () {
var paramHash = JSON.stringify(this.config_);
if (this.templateCache_[paramHash]) {
this.applyTemplate_(this.templateCache_[paramHash]);
return;
}
var mapUrl = 'https://' + this.account_ + '.carto.com/api/v1/map';
if (this.mapId_) {
mapUrl += '/named/' + this.mapId_;
}
var client = new XMLHttpRequest();
client.addEventListener('load', this.handleInitResponse_.bind(this, paramHash));
client.addEventListener('error', this.handleInitError_.bind(this));
client.open('POST', mapUrl);
client.setRequestHeader('Content-type', 'application/json');
client.send(JSON.stringify(this.config_));
};
/**
* Handle map initialization response.
* @param {string} paramHash a hash representing the parameter set that was used
* for the request
* @param {Event} event Event.
* @private
*/
CartoDB.prototype.handleInitResponse_ = function (paramHash, event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || (client.status >= 200 && client.status < 300)) {
var response = void 0;
try {
response = /** @type {CartoDBLayerInfo} */ (JSON.parse(client.responseText));
}
catch (err) {
this.setState('error');
return;
}
this.applyTemplate_(response);
this.templateCache_[paramHash] = response;
this.setState('ready');
}
else {
this.setState('error');
}
};
/**
* @private
* @param {Event} event Event.
*/
CartoDB.prototype.handleInitError_ = function (event) {
this.setState('error');
};
/**
* Apply the new tile urls returned by carto db
* @param {CartoDBLayerInfo} data Result of carto db call.
* @private
*/
CartoDB.prototype.applyTemplate_ = function (data) {
var tilesUrl = 'https://' +
data.cdn_url.https +
'/' +
this.account_ +
'/api/v1/map/' +
data.layergroupid +
'/{z}/{x}/{y}.png';
this.setUrl(tilesUrl);
};
return CartoDB;
}(XYZ));
export default CartoDB;
//# sourceMappingURL=CartoDB.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"CartoDB.js","sourceRoot":"","sources":["../src/source/CartoDB.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH;IAAsB,2BAAG;IACvB;;OAEG;IACH,iBAAY,OAAO;QAAnB,YACE,kBAAM;YACJ,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC7D,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,UAAU,EAAE,OAAO,CAAC,UAAU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,CAAC,OAAO,CAAC,CAAC;SACxB;IACH,CAAC;IAED;;;OAGG;IACH,kCAAgB,GAAhB,UAAiB,KAAK;QACpB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,gCAAc,GAAd,UAAe,IAAI;QACjB,IAAM,QAAQ,GACZ,UAAU;YACV,IAAI,CAAC,OAAO,CAAC,KAAK;YAClB,GAAG;YACH,IAAI,CAAC,QAAQ;YACb,cAAc;YACd,IAAI,CAAC,YAAY;YACjB,kBAAkB,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IACH,cAAC;AAAD,CAAC,AA3JD,CAAsB,GAAG,GA2JxB;AAED,eAAe,OAAO,CAAC"}
+215
View File
@@ -0,0 +1,215 @@
export default Cluster;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Distance in pixels within which features will
* be clustered together.
*/
distance?: number | undefined;
/**
* Minimum distance in pixels between clusters.
* Will be capped at the configured distance.
* By default no minimum distance is guaranteed. This config can be used to avoid
* overlapping icons. As a tradoff, the cluster feature's position will no longer be
* the center of all its features.
*/
minDistance?: number | undefined;
/**
* Function that takes an {@link module :ol/Feature~Feature} as argument and returns an
* {@link module :ol/geom/Point~Point} as cluster calculation point for the feature. When a
* feature should not be considered for clustering, the function should return
* `null`. The default, which works when the underlying source contains point
* features only, is
* ```js
* function(feature) {
* return feature.getGeometry();
* }
* ```
* See {@link module :ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster
* calculation point for polygons.
*/
geometryFunction?: ((arg0: Feature) => Point) | undefined;
/**
* Function that takes the cluster's center {@link module :ol/geom/Point~Point} and an array
* of {@link module :ol/Feature~Feature} included in this cluster. Must return a
* {@link module :ol/Feature~Feature} that will be used to render. Default implementation is:
* ```js
* function(point, features) {
* return new Feature({
* geometry: point,
* features: features
* });
* }
* ```
*/
createCluster?: ((arg0: Point, arg1: Array<Feature>) => Feature) | undefined;
/**
* Source.
*/
source?: VectorSource<import("../geom/Geometry.js").default> | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [distance=20] Distance in pixels within which features will
* be clustered together.
* @property {number} [minDistance=0] Minimum distance in pixels between clusters.
* Will be capped at the configured distance.
* By default no minimum distance is guaranteed. This config can be used to avoid
* overlapping icons. As a tradoff, the cluster feature's position will no longer be
* the center of all its features.
* @property {function(Feature):Point} [geometryFunction]
* Function that takes an {@link module:ol/Feature~Feature} as argument and returns an
* {@link module:ol/geom/Point~Point} as cluster calculation point for the feature. When a
* feature should not be considered for clustering, the function should return
* `null`. The default, which works when the underlying source contains point
* features only, is
* ```js
* function(feature) {
* return feature.getGeometry();
* }
* ```
* See {@link module:ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster
* calculation point for polygons.
* @property {function(Point, Array<Feature>):Feature} [createCluster]
* Function that takes the cluster's center {@link module:ol/geom/Point~Point} and an array
* of {@link module:ol/Feature~Feature} included in this cluster. Must return a
* {@link module:ol/Feature~Feature} that will be used to render. Default implementation is:
* ```js
* function(point, features) {
* return new Feature({
* geometry: point,
* features: features
* });
* }
* ```
* @property {VectorSource} [source=null] Source.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
*/
/**
* @classdesc
* Layer source to cluster vector data. Works out of the box with point
* geometries. For other geometry types, or if not all geometries should be
* considered for clustering, a custom `geometryFunction` can be defined.
*
* If the instance is disposed without also disposing the underlying
* source `setSource(null)` has to be called to remove the listener reference
* from the wrapped source.
* @api
*/
declare class Cluster extends VectorSource<import("../geom/Geometry.js").default> {
/**
* @param {Options} options Cluster options.
*/
constructor(options: Options);
/**
* @type {number|undefined}
* @protected
*/
protected resolution: number | undefined;
/**
* @type {number}
* @protected
*/
protected distance: number;
/**
* @type {number}
* @protected
*/
protected minDistance: number;
/**
* @type {number}
* @protected
*/
protected interpolationRatio: number;
/**
* @type {Array<Feature>}
* @protected
*/
protected features: Array<Feature>;
/**
* @param {Feature} feature Feature.
* @return {Point} Cluster calculation point.
* @protected
*/
protected geometryFunction: (arg0: Feature) => Point;
/**
* @type {function(Point, Array<Feature>):Feature}
* @private
*/
private createCustomCluster_;
/**
* @type {VectorSource|null}
* @protected
*/
protected source: VectorSource | null;
/**
* @private
*/
private boundRefresh_;
/**
* Get the distance in pixels between clusters.
* @return {number} Distance.
* @api
*/
getDistance(): number;
/**
* Get a reference to the wrapped source.
* @return {VectorSource|null} Source.
* @api
*/
getSource(): VectorSource | null;
/**
* Set the distance within which features will be clusterd together.
* @param {number} distance The distance in pixels.
* @api
*/
setDistance(distance: number): void;
/**
* Set the minimum distance between clusters. Will be capped at the
* configured distance.
* @param {number} minDistance The minimum distance in pixels.
* @api
*/
setMinDistance(minDistance: number): void;
/**
* The configured minimum distance between clusters.
* @return {number} The minimum distance in pixels.
* @api
*/
getMinDistance(): number;
/**
* Replace the wrapped source.
* @param {VectorSource|null} source The new source for this instance.
* @api
*/
setSource(source: VectorSource | null): void;
/**
* Update the distances and refresh the source if necessary.
* @param {number} distance The new distance.
* @param {number} minDistance The new minimum distance.
*/
updateDistance(distance: number, minDistance: number): void;
/**
* @protected
*/
protected cluster(): void;
/**
* @param {Array<Feature>} features Features
* @param {import("../extent.js").Extent} extent The searched extent for these features.
* @return {Feature} The cluster feature.
* @protected
*/
protected createCluster(features: Array<Feature>, extent: import("../extent.js").Extent): Feature;
}
import Feature from "../Feature.js";
import Point from "../geom/Point.js";
import VectorSource from "./Vector.js";
//# sourceMappingURL=Cluster.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../src/source/Cluster.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA4BuB,OAAO,KAAE,KAAK;;;;;;;;;;;;;;4BAad,KAAK,QAAE,MAAM,OAAO,CAAC,KAAE,OAAO;;;;;;;;;;AAvBrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;GAUG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAsEjB;IA9DC;;;OAGG;IACH,sBAHU,MAAM,GAAC,SAAS,CAGC;IAE3B;;;OAGG;IACH,oBAHU,MAAM,CAGsD;IAEtE;;;OAGG;IACH,uBAHU,MAAM,CAG2B;IAE3C;;;OAGG;IACH,8BAHU,MAAM,CAGW;IAE3B;;;OAGG;IACH,oBAHU,MAAM,OAAO,CAAC,CAGN;IAElB;;;;OAIG;IACH,mCArFmB,OAAO,KAAE,KAAK,CA2F9B;IAEH;;;OAGG;IACH,6BAAiD;IAEjD;;;OAGG;IACH,kBAHU,YAAY,GAAC,IAAI,CAGT;IAElB;;OAEG;IACH,sBAA4C;IAgB9C;;;;OAIG;IACH,eAHY,MAAM,CAKjB;IAED;;;;OAIG;IACH,aAHY,YAAY,GAAC,IAAI,CAK5B;IAeD;;;;OAIG;IACH,sBAHW,MAAM,QAKhB;IAED;;;;;OAKG;IACH,4BAHW,MAAM,QAKhB;IAED;;;;OAIG;IACH,kBAHY,MAAM,CAKjB;IAED;;;;OAIG;IACH,kBAHW,YAAY,GAAC,IAAI,QAY3B;IAWD;;;;OAIG;IACH,yBAHW,MAAM,eACN,MAAM,QAahB;IAED;;OAEG;IACH,0BAkCC;IAED;;;;;OAKG;IACH,kCALW,MAAM,OAAO,CAAC,UACd,OAAO,cAAc,EAAE,MAAM,GAC5B,OAAO,CA4BlB;CACF"}
+313
View File
@@ -0,0 +1,313 @@
/**
* @module ol/source/Cluster
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import EventType from '../events/EventType.js';
import Feature from '../Feature.js';
import Point from '../geom/Point.js';
import VectorSource from './Vector.js';
import { add as addCoordinate, scale as scaleCoordinate } from '../coordinate.js';
import { assert } from '../asserts.js';
import { buffer, createEmpty, createOrUpdateFromCoordinate, getCenter, } from '../extent.js';
import { getUid } from '../util.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [distance=20] Distance in pixels within which features will
* be clustered together.
* @property {number} [minDistance=0] Minimum distance in pixels between clusters.
* Will be capped at the configured distance.
* By default no minimum distance is guaranteed. This config can be used to avoid
* overlapping icons. As a tradoff, the cluster feature's position will no longer be
* the center of all its features.
* @property {function(Feature):Point} [geometryFunction]
* Function that takes an {@link module:ol/Feature~Feature} as argument and returns an
* {@link module:ol/geom/Point~Point} as cluster calculation point for the feature. When a
* feature should not be considered for clustering, the function should return
* `null`. The default, which works when the underlying source contains point
* features only, is
* ```js
* function(feature) {
* return feature.getGeometry();
* }
* ```
* See {@link module:ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster
* calculation point for polygons.
* @property {function(Point, Array<Feature>):Feature} [createCluster]
* Function that takes the cluster's center {@link module:ol/geom/Point~Point} and an array
* of {@link module:ol/Feature~Feature} included in this cluster. Must return a
* {@link module:ol/Feature~Feature} that will be used to render. Default implementation is:
* ```js
* function(point, features) {
* return new Feature({
* geometry: point,
* features: features
* });
* }
* ```
* @property {VectorSource} [source=null] Source.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
*/
/**
* @classdesc
* Layer source to cluster vector data. Works out of the box with point
* geometries. For other geometry types, or if not all geometries should be
* considered for clustering, a custom `geometryFunction` can be defined.
*
* If the instance is disposed without also disposing the underlying
* source `setSource(null)` has to be called to remove the listener reference
* from the wrapped source.
* @api
*/
var Cluster = /** @class */ (function (_super) {
__extends(Cluster, _super);
/**
* @param {Options} options Cluster options.
*/
function Cluster(options) {
var _this = _super.call(this, {
attributions: options.attributions,
wrapX: options.wrapX,
}) || this;
/**
* @type {number|undefined}
* @protected
*/
_this.resolution = undefined;
/**
* @type {number}
* @protected
*/
_this.distance = options.distance !== undefined ? options.distance : 20;
/**
* @type {number}
* @protected
*/
_this.minDistance = options.minDistance || 0;
/**
* @type {number}
* @protected
*/
_this.interpolationRatio = 0;
/**
* @type {Array<Feature>}
* @protected
*/
_this.features = [];
/**
* @param {Feature} feature Feature.
* @return {Point} Cluster calculation point.
* @protected
*/
_this.geometryFunction =
options.geometryFunction ||
function (feature) {
var geometry = /** @type {Point} */ (feature.getGeometry());
assert(geometry.getType() == 'Point', 10); // The default `geometryFunction` can only handle `Point` geometries
return geometry;
};
/**
* @type {function(Point, Array<Feature>):Feature}
* @private
*/
_this.createCustomCluster_ = options.createCluster;
/**
* @type {VectorSource|null}
* @protected
*/
_this.source = null;
/**
* @private
*/
_this.boundRefresh_ = _this.refresh.bind(_this);
_this.updateDistance(_this.distance, _this.minDistance);
_this.setSource(options.source || null);
return _this;
}
/**
* Remove all features from the source.
* @param {boolean} [opt_fast] Skip dispatching of {@link module:ol/source/VectorEventType~VectorEventType#removefeature} events.
* @api
*/
Cluster.prototype.clear = function (opt_fast) {
this.features.length = 0;
_super.prototype.clear.call(this, opt_fast);
};
/**
* Get the distance in pixels between clusters.
* @return {number} Distance.
* @api
*/
Cluster.prototype.getDistance = function () {
return this.distance;
};
/**
* Get a reference to the wrapped source.
* @return {VectorSource|null} Source.
* @api
*/
Cluster.prototype.getSource = function () {
return this.source;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
Cluster.prototype.loadFeatures = function (extent, resolution, projection) {
this.source.loadFeatures(extent, resolution, projection);
if (resolution !== this.resolution) {
this.resolution = resolution;
this.refresh();
}
};
/**
* Set the distance within which features will be clusterd together.
* @param {number} distance The distance in pixels.
* @api
*/
Cluster.prototype.setDistance = function (distance) {
this.updateDistance(distance, this.minDistance);
};
/**
* Set the minimum distance between clusters. Will be capped at the
* configured distance.
* @param {number} minDistance The minimum distance in pixels.
* @api
*/
Cluster.prototype.setMinDistance = function (minDistance) {
this.updateDistance(this.distance, minDistance);
};
/**
* The configured minimum distance between clusters.
* @return {number} The minimum distance in pixels.
* @api
*/
Cluster.prototype.getMinDistance = function () {
return this.minDistance;
};
/**
* Replace the wrapped source.
* @param {VectorSource|null} source The new source for this instance.
* @api
*/
Cluster.prototype.setSource = function (source) {
if (this.source) {
this.source.removeEventListener(EventType.CHANGE, this.boundRefresh_);
}
this.source = source;
if (source) {
source.addEventListener(EventType.CHANGE, this.boundRefresh_);
}
this.refresh();
};
/**
* Handle the source changing.
*/
Cluster.prototype.refresh = function () {
this.clear();
this.cluster();
this.addFeatures(this.features);
};
/**
* Update the distances and refresh the source if necessary.
* @param {number} distance The new distance.
* @param {number} minDistance The new minimum distance.
*/
Cluster.prototype.updateDistance = function (distance, minDistance) {
var ratio = distance === 0 ? 0 : Math.min(minDistance, distance) / distance;
var changed = distance !== this.distance || this.interpolationRatio !== ratio;
this.distance = distance;
this.minDistance = minDistance;
this.interpolationRatio = ratio;
if (changed) {
this.refresh();
}
};
/**
* @protected
*/
Cluster.prototype.cluster = function () {
if (this.resolution === undefined || !this.source) {
return;
}
var extent = createEmpty();
var mapDistance = this.distance * this.resolution;
var features = this.source.getFeatures();
/** @type {Object<string, true>} */
var clustered = {};
for (var i = 0, ii = features.length; i < ii; i++) {
var feature = features[i];
if (!(getUid(feature) in clustered)) {
var geometry = this.geometryFunction(feature);
if (geometry) {
var coordinates = geometry.getCoordinates();
createOrUpdateFromCoordinate(coordinates, extent);
buffer(extent, mapDistance, extent);
var neighbors = this.source
.getFeaturesInExtent(extent)
.filter(function (neighbor) {
var uid = getUid(neighbor);
if (uid in clustered) {
return false;
}
clustered[uid] = true;
return true;
});
this.features.push(this.createCluster(neighbors, extent));
}
}
}
};
/**
* @param {Array<Feature>} features Features
* @param {import("../extent.js").Extent} extent The searched extent for these features.
* @return {Feature} The cluster feature.
* @protected
*/
Cluster.prototype.createCluster = function (features, extent) {
var centroid = [0, 0];
for (var i = features.length - 1; i >= 0; --i) {
var geometry_1 = this.geometryFunction(features[i]);
if (geometry_1) {
addCoordinate(centroid, geometry_1.getCoordinates());
}
else {
features.splice(i, 1);
}
}
scaleCoordinate(centroid, 1 / features.length);
var searchCenter = getCenter(extent);
var ratio = this.interpolationRatio;
var geometry = new Point([
centroid[0] * (1 - ratio) + searchCenter[0] * ratio,
centroid[1] * (1 - ratio) + searchCenter[1] * ratio,
]);
if (this.createCustomCluster_) {
return this.createCustomCluster_(geometry, features);
}
else {
return new Feature({
geometry: geometry,
features: features,
});
}
};
return Cluster;
}(VectorSource));
export default Cluster;
//# sourceMappingURL=Cluster.js.map
+1
View File
File diff suppressed because one or more lines are too long
+191
View File
@@ -0,0 +1,191 @@
export default DataTileSource;
/**
* Data tile loading function. The function is called with z, x, and y tile coordinates and
* returns {@link import ("../DataTile.js").Data data} for a tile or a promise for the same.
*/
export type Loader = (arg0: number, arg1: number, arg2: number) => (import("../DataTile.js").Data | Promise<import("../DataTile.js").Data>);
export type Options = {
/**
* Data loader. Called with z, x, and y tile coordinates.
* Returns {@link import ("../DataTile.js").Data data} for a tile or a promise for the same.
*/
loader?: Loader | undefined;
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* Optional max zoom level. Not used if `tileGrid` is provided.
*/
maxZoom?: number | undefined;
/**
* Optional min zoom level. Not used if `tileGrid` is provided.
*/
minZoom?: number | undefined;
/**
* The pixel width and height of the source tiles.
* This may be different than the rendered pixel size if a `tileGrid` is provided.
*/
tileSize?: number | import("../size.js").Size | undefined;
/**
* The size in pixels of the gutter around data tiles to ignore.
* This allows artifacts of rendering at tile edges to be ignored.
* Supported data should be wider and taller than the tile size by a value of `2 x gutter`.
*/
gutter?: number | undefined;
/**
* Optional tile grid resolution at level zero. Not used if `tileGrid` is provided.
*/
maxResolution?: number | undefined;
/**
* Tile projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Tile grid.
*/
tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
/**
* Whether the layer is opaque.
*/
opaque?: boolean | undefined;
/**
* The source state.
*/
state?: import("./Source.js").State | undefined;
/**
* Deprecated. To have tiles scaled, pass a `tileSize` representing
* the source tile size and a `tileGrid` with the desired rendered tile size.
*/
tilePixelRatio?: number | undefined;
/**
* Render tiles beyond the antimeridian.
*/
wrapX?: boolean | undefined;
/**
* Transition time when fading in new tiles (in miliseconds).
*/
transition?: number | undefined;
/**
* Number of bands represented in the data.
*/
bandCount?: number | undefined;
/**
* Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
interpolate?: boolean | undefined;
};
/**
* Data tile loading function. The function is called with z, x, and y tile coordinates and
* returns {@link import("../DataTile.js").Data data} for a tile or a promise for the same.
* @typedef {function(number, number, number) : (import("../DataTile.js").Data|Promise<import("../DataTile.js").Data>)} Loader
*/
/**
* @typedef {Object} Options
* @property {Loader} [loader] Data loader. Called with z, x, and y tile coordinates.
* Returns {@link import("../DataTile.js").Data data} for a tile or a promise for the same.
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [maxZoom=42] Optional max zoom level. Not used if `tileGrid` is provided.
* @property {number} [minZoom=0] Optional min zoom level. Not used if `tileGrid` is provided.
* @property {number|import("../size.js").Size} [tileSize=[256, 256]] The pixel width and height of the source tiles.
* This may be different than the rendered pixel size if a `tileGrid` is provided.
* @property {number} [gutter=0] The size in pixels of the gutter around data tiles to ignore.
* This allows artifacts of rendering at tile edges to be ignored.
* Supported data should be wider and taller than the tile size by a value of `2 x gutter`.
* @property {number} [maxResolution] Optional tile grid resolution at level zero. Not used if `tileGrid` is provided.
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Tile projection.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {import("./Source.js").State} [state] The source state.
* @property {number} [tilePixelRatio] Deprecated. To have tiles scaled, pass a `tileSize` representing
* the source tile size and a `tileGrid` with the desired rendered tile size.
* @property {boolean} [wrapX=false] Render tiles beyond the antimeridian.
* @property {number} [transition] Transition time when fading in new tiles (in miliseconds).
* @property {number} [bandCount=4] Number of bands represented in the data.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
* @classdesc
* A source for typed array data tiles.
*
* @fires import("./Tile.js").TileSourceEvent
* @api
*/
declare class DataTileSource extends TileSource {
/**
* @param {Options} options Image tile options.
*/
constructor(options: Options);
/**
* @private
* @type {number}
*/
private gutter_;
/**
* @private
* @type {import('../size.js').Size|null}
*/
private tileSize_;
/**
* @private
* @type {Array<import('../size.js').Size>|null}
*/
private tileSizes_;
/**
* @private
* @type {!Object<string, boolean>}
*/
private tileLoadingKeys_;
/**
* @private
*/
private loader_;
/**
* Handle tile change events.
* @param {import("../events/Event.js").default} event Event.
*/
handleTileChange_(event: import("../events/Event.js").default): void;
/**
* @type {number}
*/
bandCount: number;
/**
* Set the source tile sizes. The length of the array is expected to match the number of
* levels in the tile grid.
* @protected
* @param {Array<import('../size.js').Size>} tileSizes An array of tile sizes.
*/
protected setTileSizes(tileSizes: Array<import('../size.js').Size>): void;
/**
* Get the source tile size at the given zoom level. This may be different than the rendered tile
* size.
* @protected
* @param {number} z Tile zoom level.
* @return {import('../size.js').Size} The source tile size.
*/
protected getTileSize(z: number): import('../size.js').Size;
/**
* @param {Loader} loader The data loader.
* @protected
*/
protected setLoader(loader: Loader): void;
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!DataTile} Tile.
*/
getTile(z: number, x: number, y: number, pixelRatio: number, projection: import("../proj/Projection.js").default): DataTile;
}
import TileSource from "./Tile.js";
import DataTile from "../DataTile.js";
//# sourceMappingURL=DataTile.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["../src/source/DataTile.js"],"names":[],"mappings":";;;;;4BAkBsB,MAAM,QAAE,MAAM,QAAE,MAAM,KAAI,CAAC,OAAO,gBAAgB,EAAE,IAAI,GAAC,QAAQ,OAAO,gBAAgB,EAAE,IAAI,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBxG,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AApBjD;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAyEjB;IA1CC;;;OAGG;IACH,gBAAgE;IAEhE;;;OAGG;IACH,kBAAmE;IASnE;;;OAGG;IACH,mBAAsB;IAEtB;;;OAGG;IACH,yBAA0B;IAE1B;;OAEG;IACH,gBAA6B;IA8F/B;;;OAGG;IACH,yBAFW,OAAO,oBAAoB,EAAE,OAAO,QAsB9C;IAlHC;;OAEG;IACH,WAFU,MAAM,CAEwD;IAG1E;;;;;OAKG;IACH,kCAFW,MAAM,OAAO,YAAY,EAAE,IAAI,CAAC,QAI1C;IAED;;;;;;OAMG;IACH,yBAHW,MAAM,GACL,OAAO,YAAY,EAAE,IAAI,CAWpC;IAUD;;;OAGG;IACH,4BAHW,MAAM,QAKhB;IAED;;;;;;;OAOG;IACH,WAPW,MAAM,KACN,MAAM,KACN,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACrC,QAAQ,CAgCpB;CA2BF"}
+237
View File
@@ -0,0 +1,237 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/DataTile
*/
import DataTile from '../DataTile.js';
import EventType from '../events/EventType.js';
import TileEventType from './TileEventType.js';
import TileSource, { TileSourceEvent } from './Tile.js';
import TileState from '../TileState.js';
import { assign } from '../obj.js';
import { createXYZ, extentFromProjection } from '../tilegrid.js';
import { getKeyZXY } from '../tilecoord.js';
import { getUid } from '../util.js';
import { toPromise } from '../functions.js';
import { toSize } from '../size.js';
/**
* Data tile loading function. The function is called with z, x, and y tile coordinates and
* returns {@link import("../DataTile.js").Data data} for a tile or a promise for the same.
* @typedef {function(number, number, number) : (import("../DataTile.js").Data|Promise<import("../DataTile.js").Data>)} Loader
*/
/**
* @typedef {Object} Options
* @property {Loader} [loader] Data loader. Called with z, x, and y tile coordinates.
* Returns {@link import("../DataTile.js").Data data} for a tile or a promise for the same.
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [maxZoom=42] Optional max zoom level. Not used if `tileGrid` is provided.
* @property {number} [minZoom=0] Optional min zoom level. Not used if `tileGrid` is provided.
* @property {number|import("../size.js").Size} [tileSize=[256, 256]] The pixel width and height of the source tiles.
* This may be different than the rendered pixel size if a `tileGrid` is provided.
* @property {number} [gutter=0] The size in pixels of the gutter around data tiles to ignore.
* This allows artifacts of rendering at tile edges to be ignored.
* Supported data should be wider and taller than the tile size by a value of `2 x gutter`.
* @property {number} [maxResolution] Optional tile grid resolution at level zero. Not used if `tileGrid` is provided.
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Tile projection.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {import("./Source.js").State} [state] The source state.
* @property {number} [tilePixelRatio] Deprecated. To have tiles scaled, pass a `tileSize` representing
* the source tile size and a `tileGrid` with the desired rendered tile size.
* @property {boolean} [wrapX=false] Render tiles beyond the antimeridian.
* @property {number} [transition] Transition time when fading in new tiles (in miliseconds).
* @property {number} [bandCount=4] Number of bands represented in the data.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
* @classdesc
* A source for typed array data tiles.
*
* @fires import("./Tile.js").TileSourceEvent
* @api
*/
var DataTileSource = /** @class */ (function (_super) {
__extends(DataTileSource, _super);
/**
* @param {Options} options Image tile options.
*/
function DataTileSource(options) {
var _this = this;
var projection = options.projection === undefined ? 'EPSG:3857' : options.projection;
var tileGrid = options.tileGrid;
if (tileGrid === undefined && projection) {
tileGrid = createXYZ({
extent: extentFromProjection(projection),
maxResolution: options.maxResolution,
maxZoom: options.maxZoom,
minZoom: options.minZoom,
tileSize: options.tileSize,
});
}
_this = _super.call(this, {
cacheSize: 0.1,
attributions: options.attributions,
attributionsCollapsible: options.attributionsCollapsible,
projection: projection,
tileGrid: tileGrid,
opaque: options.opaque,
state: options.state,
tilePixelRatio: options.tilePixelRatio,
wrapX: options.wrapX,
transition: options.transition,
interpolate: options.interpolate,
}) || this;
/**
* @private
* @type {number}
*/
_this.gutter_ = options.gutter !== undefined ? options.gutter : 0;
/**
* @private
* @type {import('../size.js').Size|null}
*/
_this.tileSize_ = options.tileSize ? toSize(options.tileSize) : null;
if (!_this.tileSize_ && options.tilePixelRatio && tileGrid) {
var renderTileSize = toSize(tileGrid.getTileSize(0));
_this.tileSize_ = [
renderTileSize[0] * options.tilePixelRatio,
renderTileSize[1] * options.tilePixelRatio,
];
}
/**
* @private
* @type {Array<import('../size.js').Size>|null}
*/
_this.tileSizes_ = null;
/**
* @private
* @type {!Object<string, boolean>}
*/
_this.tileLoadingKeys_ = {};
/**
* @private
*/
_this.loader_ = options.loader;
_this.handleTileChange_ = _this.handleTileChange_.bind(_this);
/**
* @type {number}
*/
_this.bandCount = options.bandCount === undefined ? 4 : options.bandCount; // assume RGBA if undefined
return _this;
}
/**
* Set the source tile sizes. The length of the array is expected to match the number of
* levels in the tile grid.
* @protected
* @param {Array<import('../size.js').Size>} tileSizes An array of tile sizes.
*/
DataTileSource.prototype.setTileSizes = function (tileSizes) {
this.tileSizes_ = tileSizes;
};
/**
* Get the source tile size at the given zoom level. This may be different than the rendered tile
* size.
* @protected
* @param {number} z Tile zoom level.
* @return {import('../size.js').Size} The source tile size.
*/
DataTileSource.prototype.getTileSize = function (z) {
if (this.tileSizes_) {
return this.tileSizes_[z];
}
if (this.tileSize_) {
return this.tileSize_;
}
var tileGrid = this.getTileGrid();
return tileGrid ? toSize(tileGrid.getTileSize(z)) : [256, 256];
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {number} Gutter.
*/
DataTileSource.prototype.getGutterForProjection = function (projection) {
return this.gutter_;
};
/**
* @param {Loader} loader The data loader.
* @protected
*/
DataTileSource.prototype.setLoader = function (loader) {
this.loader_ = loader;
};
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!DataTile} Tile.
*/
DataTileSource.prototype.getTile = function (z, x, y, pixelRatio, projection) {
var size = this.getTileSize(z);
var tileCoordKey = getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
return this.tileCache.get(tileCoordKey);
}
var sourceLoader = this.loader_;
function loader() {
return toPromise(function () {
return sourceLoader(z, x, y);
});
}
var options = assign({
tileCoord: [z, x, y],
loader: loader,
size: size,
}, this.tileOptions);
var tile = new DataTile(options);
tile.key = this.getKey();
tile.addEventListener(EventType.CHANGE, this.handleTileChange_);
this.tileCache.set(tileCoordKey, tile);
return tile;
};
/**
* Handle tile change events.
* @param {import("../events/Event.js").default} event Event.
*/
DataTileSource.prototype.handleTileChange_ = function (event) {
var tile = /** @type {import("../Tile.js").default} */ (event.target);
var uid = getUid(tile);
var tileState = tile.getState();
var type;
if (tileState == TileState.LOADING) {
this.tileLoadingKeys_[uid] = true;
type = TileEventType.TILELOADSTART;
}
else if (uid in this.tileLoadingKeys_) {
delete this.tileLoadingKeys_[uid];
type =
tileState == TileState.ERROR
? TileEventType.TILELOADERROR
: tileState == TileState.LOADED
? TileEventType.TILELOADEND
: undefined;
}
if (type) {
this.dispatchEvent(new TileSourceEvent(type, tile));
}
};
return DataTileSource;
}(TileSource));
export default DataTileSource;
//# sourceMappingURL=DataTile.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DataTile.js","sourceRoot":"","sources":["../src/source/DataTile.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;GAEG;AACH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,UAAU,EAAE,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AACtD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,SAAS,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAElC;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AAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEhE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,0CAAiB,GAAjB,UAAkB,KAAK;QACrB,IAAM,IAAI,GAAG,2CAA2C,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxE,IAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,IAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC;QACT,IAAI,SAAS,IAAI,SAAS,CAAC,OAAO,EAAE;YAClC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;YAClC,IAAI,GAAG,aAAa,CAAC,aAAa,CAAC;SACpC;aAAM,IAAI,GAAG,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvC,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI;gBACF,SAAS,IAAI,SAAS,CAAC,KAAK;oBAC1B,CAAC,CAAC,aAAa,CAAC,aAAa;oBAC7B,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM;wBAC/B,CAAC,CAAC,aAAa,CAAC,WAAW;wBAC3B,CAAC,CAAC,SAAS,CAAC;SACjB;QACD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,aAAa,CAAC,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;SACrD;IACH,CAAC;IACH,qBAAC;AAAD,CAAC,AA1LD,CAA6B,UAAU,GA0LtC;AAED,eAAe,cAAc,CAAC"}
+299
View File
@@ -0,0 +1,299 @@
export default GeoTIFFSource;
export type SourceInfo = {
/**
* URL for the source GeoTIFF.
*/
url?: string | undefined;
/**
* List of any overview URLs, only applies if the url parameter is given.
*/
overviews?: string[] | undefined;
/**
* Blob containing the source GeoTIFF. `blob` and `url` are mutually exclusive.
*/
blob?: Blob | undefined;
/**
* The minimum source data value. Rendered values are scaled from 0 to 1 based on
* the configured min and max. If not provided and raster statistics are available, those will be used instead.
* If neither are available, the minimum for the data type will be used. To disable this behavior, set
* the `normalize` option to `false` in the constructor.
*/
min?: number | undefined;
/**
* The maximum source data value. Rendered values are scaled from 0 to 1 based on
* the configured min and max. If not provided and raster statistics are available, those will be used instead.
* If neither are available, the maximum for the data type will be used. To disable this behavior, set
* the `normalize` option to `false` in the constructor.
*/
max?: number | undefined;
/**
* Values to discard (overriding any nodata values in the metadata).
* When provided, an additional alpha band will be added to the data. Often the GeoTIFF metadata
* will include information about nodata values, so you should only need to set this property if
* you find that it is not already extracted from the metadata.
*/
nodata?: number | undefined;
/**
* Band numbers to be read from (where the first band is `1`). If not provided, all bands will
* be read. For example, if a GeoTIFF has blue (1), green (2), red (3), and near-infrared (4) bands, and you only need the
* near-infrared band, configure `bands: [4]`.
*/
bands?: number[] | undefined;
};
export type GeoKeys = {
/**
* Model type.
*/
GTModelTypeGeoKey: number;
/**
* Raster type.
*/
GTRasterTypeGeoKey: number;
/**
* Angular units.
*/
GeogAngularUnitsGeoKey: number;
/**
* Inverse flattening.
*/
GeogInvFlatteningGeoKey: number;
/**
* Semi-major axis.
*/
GeogSemiMajorAxisGeoKey: number;
/**
* Geographic coordinate system code.
*/
GeographicTypeGeoKey: number;
/**
* Projected linear unit code.
*/
ProjLinearUnitsGeoKey: number;
/**
* Projected coordinate system code.
*/
ProjectedCSTypeGeoKey: number;
};
export type GeoTIFF = import("geotiff").GeoTIFF;
export type MultiGeoTIFF = import("geotiff").MultiGeoTIFF;
export type GDALMetadata = {
/**
* The minimum value (as a string).
*/
STATISTICS_MINIMUM: string;
/**
* The maximum value (as a string).
*/
STATISTICS_MAXIMUM: string;
};
export type GeoTIFFImage = import("geotiff").GeoTIFFImage;
export type GeoTIFFSourceOptions = {
/**
* Whether to force the usage of the browsers XMLHttpRequest API.
*/
forceXHR?: boolean | undefined;
/**
* additional key-value pairs of headers to be passed with each request. Key is the header name, value the header value.
*/
headers?: {
[x: string]: string;
} | undefined;
/**
* How credentials shall be handled. See
* https://developer.mozilla.org/en-US/docs/Web/API/fetch for reference and possible values
*/
credentials?: string | undefined;
/**
* The maximum amount of ranges to request in a single multi-range request.
* By default only a single range is used.
*/
maxRanges?: number | undefined;
/**
* Whether or not a full file is accepted when only a portion is
* requested. Only use this when you know the source image to be small enough to fit in memory.
*/
allowFullFile?: boolean | undefined;
/**
* The block size to use.
*/
blockSize?: number | undefined;
/**
* The number of blocks that shall be held in a LRU cache.
*/
cacheSize?: number | undefined;
};
export type Options = {
/**
* List of information about GeoTIFF sources.
* Multiple sources can be combined when their resolution sets are equal after applying a scale.
* The list of sources defines a mapping between input bands as they are read from each GeoTIFF and
* the output bands that are provided by data tiles. To control which bands to read from each GeoTIFF,
* use the {@link import ("./GeoTIFF.js").SourceInfo bands} property. If, for example, you specify two
* sources, one with 3 bands and {@link import ("./GeoTIFF.js").SourceInfo nodata} configured, and
* another with 1 band, the resulting data tiles will have 5 bands: 3 from the first source, 1 alpha
* band from the first source, and 1 band from the second source.
*/
sources: Array<SourceInfo>;
/**
* Additional options to be passed to [geotiff.js](https://geotiffjs.github.io/geotiff.js/module-geotiff.html)'s `fromUrl` or `fromUrls` methods.
*/
sourceOptions?: GeoTIFFSourceOptions | undefined;
/**
* By default, bands from the sources are read as-is. When
* reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
* convert other color spaces (YCbCr, CMYK) to RGB.
*/
convertToRGB?: boolean | undefined;
/**
* By default, the source data is normalized to values between
* 0 and 1 with scaling factors based on the raster statistics or `min` and `max` properties of each source.
* If instead you want to work with the raw values in a style expression, set this to `false`. Setting this option
* to `false` will make it so any `min` and `max` properties on sources are ignored.
*/
normalize?: boolean | undefined;
/**
* Whether the layer is opaque.
*/
opaque?: boolean | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* Render tiles beyond the tile grid extent.
*/
wrapX?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* the linear interpolation is used to resample the data. If false, nearest neighbor is used.
*/
interpolate?: boolean | undefined;
};
/**
* @typedef {Object} GeoTIFFSourceOptions
* @property {boolean} [forceXHR=false] Whether to force the usage of the browsers XMLHttpRequest API.
* @property {Object<string, string>} [headers] additional key-value pairs of headers to be passed with each request. Key is the header name, value the header value.
* @property {string} [credentials] How credentials shall be handled. See
* https://developer.mozilla.org/en-US/docs/Web/API/fetch for reference and possible values
* @property {number} [maxRanges] The maximum amount of ranges to request in a single multi-range request.
* By default only a single range is used.
* @property {boolean} [allowFullFile=false] Whether or not a full file is accepted when only a portion is
* requested. Only use this when you know the source image to be small enough to fit in memory.
* @property {number} [blockSize=65536] The block size to use.
* @property {number} [cacheSize=100] The number of blocks that shall be held in a LRU cache.
*/
/**
* @typedef {Object} Options
* @property {Array<SourceInfo>} sources List of information about GeoTIFF sources.
* Multiple sources can be combined when their resolution sets are equal after applying a scale.
* The list of sources defines a mapping between input bands as they are read from each GeoTIFF and
* the output bands that are provided by data tiles. To control which bands to read from each GeoTIFF,
* use the {@link import("./GeoTIFF.js").SourceInfo bands} property. If, for example, you specify two
* sources, one with 3 bands and {@link import("./GeoTIFF.js").SourceInfo nodata} configured, and
* another with 1 band, the resulting data tiles will have 5 bands: 3 from the first source, 1 alpha
* band from the first source, and 1 band from the second source.
* @property {GeoTIFFSourceOptions} [sourceOptions] Additional options to be passed to [geotiff.js](https://geotiffjs.github.io/geotiff.js/module-geotiff.html)'s `fromUrl` or `fromUrls` methods.
* @property {boolean} [convertToRGB = false] By default, bands from the sources are read as-is. When
* reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
* convert other color spaces (YCbCr, CMYK) to RGB.
* @property {boolean} [normalize=true] By default, the source data is normalized to values between
* 0 and 1 with scaling factors based on the raster statistics or `min` and `max` properties of each source.
* If instead you want to work with the raw values in a style expression, set this to `false`. Setting this option
* to `false` will make it so any `min` and `max` properties on sources are ignored.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {boolean} [wrapX=false] Render tiles beyond the tile grid extent.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* the linear interpolation is used to resample the data. If false, nearest neighbor is used.
*/
/**
* @classdesc
* A source for working with GeoTIFF data.
* @api
*/
declare class GeoTIFFSource extends DataTile {
/**
* @param {Options} options Data tile options.
*/
constructor(options: Options);
/**
* @type {Array<SourceInfo>}
* @private
*/
private sourceInfo_;
/**
* @type {Object}
* @private
*/
private sourceOptions_;
/**
* @type {Array<Array<GeoTIFFImage>>}
* @private
*/
private sourceImagery_;
/**
* @type {Array<number>}
* @private
*/
private resolutionFactors_;
/**
* @type {Array<number>}
* @private
*/
private samplesPerPixel_;
/**
* @type {Array<Array<number>>}
* @private
*/
private nodataValues_;
/**
* @type {Array<Array<GDALMetadata>>}
* @private
*/
private metadata_;
/**
* @type {boolean}
* @private
*/
private normalize_;
/**
* @type {boolean}
* @private
*/
private addAlpha_;
/**
* @type {Error}
* @private
*/
private error_;
/**
* @type {'readRasters' | 'readRGB'}
*/
readMethod_: 'readRasters' | 'readRGB';
/**
* @return {Error} A source loading error. When the source state is `error`, use this function
* to get more information about the error. To debug a faulty configuration, you may want to use
* a listener like
* ```js
* geotiffSource.on('change', () => {
* if (geotiffSource.getState() === 'error') {
* console.error(geotiffSource.getError());
* }
* });
* ```
*/
getError(): Error;
/**
* Configure the tile grid based on images within the source GeoTIFFs. Each GeoTIFF
* must have the same internal tiled structure.
* @param {Array<Array<GeoTIFFImage>>} sources Each source is a list of images
* from a single GeoTIFF.
* @private
*/
private configure_;
loadTile_(z: any, x: any, y: any): Promise<Uint8Array | Float32Array>;
}
import DataTile from "./DataTile.js";
//# sourceMappingURL=GeoTIFF.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GeoTIFF.d.ts","sourceRoot":"","sources":["../src/source/GeoTIFF.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA6Cc,MAAM;;;;wBACN,MAAM;;;;4BACN,MAAM;;;;6BACN,MAAM;;;;6BACN,MAAM;;;;0BACN,MAAM;;;;2BACN,MAAM;;;;2BACN,MAAM;;sBAIP,OAAO,SAAS,EAAE,OAAO;2BAIzB,OAAO,SAAS,EAAE,YAAY;;;;;wBAK7B,MAAM;;;;wBACN,MAAM;;2BAOP,OAAO,SAAS,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAoO7B,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAhB/B;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAmGjB;IAtFC;;;OAGG;IACH,oBAAkC;IAIlC;;;OAGG;IACH,uBAA2C;IAE3C;;;OAGG;IACH,uBAA2C;IAE3C;;;OAGG;IACH,2BAA+C;IAE/C;;;OAGG;IACH,yBAAqB;IAErB;;;OAGG;IACH,sBAAkB;IAElB;;;OAGG;IACH,kBAAc;IAEd;;;OAGG;IACH,mBAA6C;IAE7C;;;OAGG;IACH,kBAAsB;IAEtB;;;OAGG;IACH,eAAkB;IAElB;;OAEG;IACH,aAFU,aAAa,GAAG,SAAS,CAEgC;IAuBrE;;;;;;;;;;;OAWG;IACH,YAXY,KAAK,CAahB;IAED;;;;;;OAMG;IACH,mBA2MC;IAED,sEAwJC;CACF"}
+762
View File
@@ -0,0 +1,762 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/GeoTIFF
*/
import DataTile from './DataTile.js';
import TileGrid from '../tilegrid/TileGrid.js';
import { Pool, fromBlob as tiffFromBlob, fromUrl as tiffFromUrl, fromUrls as tiffFromUrls, } from 'geotiff';
import { Projection, get as getCachedProjection, toUserCoordinate, toUserExtent, } from '../proj.js';
import { clamp } from '../math.js';
import { getCenter, getIntersection } from '../extent.js';
import { fromCode as unitsFromCode } from '../proj/Units.js';
/**
* @typedef {Object} SourceInfo
* @property {string} [url] URL for the source GeoTIFF.
* @property {Array<string>} [overviews] List of any overview URLs, only applies if the url parameter is given.
* @property {Blob} [blob] Blob containing the source GeoTIFF. `blob` and `url` are mutually exclusive.
* @property {number} [min=0] The minimum source data value. Rendered values are scaled from 0 to 1 based on
* the configured min and max. If not provided and raster statistics are available, those will be used instead.
* If neither are available, the minimum for the data type will be used. To disable this behavior, set
* the `normalize` option to `false` in the constructor.
* @property {number} [max] The maximum source data value. Rendered values are scaled from 0 to 1 based on
* the configured min and max. If not provided and raster statistics are available, those will be used instead.
* If neither are available, the maximum for the data type will be used. To disable this behavior, set
* the `normalize` option to `false` in the constructor.
* @property {number} [nodata] Values to discard (overriding any nodata values in the metadata).
* When provided, an additional alpha band will be added to the data. Often the GeoTIFF metadata
* will include information about nodata values, so you should only need to set this property if
* you find that it is not already extracted from the metadata.
* @property {Array<number>} [bands] Band numbers to be read from (where the first band is `1`). If not provided, all bands will
* be read. For example, if a GeoTIFF has blue (1), green (2), red (3), and near-infrared (4) bands, and you only need the
* near-infrared band, configure `bands: [4]`.
*/
/**
* @typedef {Object} GeoKeys
* @property {number} GTModelTypeGeoKey Model type.
* @property {number} GTRasterTypeGeoKey Raster type.
* @property {number} GeogAngularUnitsGeoKey Angular units.
* @property {number} GeogInvFlatteningGeoKey Inverse flattening.
* @property {number} GeogSemiMajorAxisGeoKey Semi-major axis.
* @property {number} GeographicTypeGeoKey Geographic coordinate system code.
* @property {number} ProjLinearUnitsGeoKey Projected linear unit code.
* @property {number} ProjectedCSTypeGeoKey Projected coordinate system code.
*/
/**
* @typedef {import("geotiff").GeoTIFF} GeoTIFF
*/
/**
* @typedef {import("geotiff").MultiGeoTIFF} MultiGeoTIFF
*/
/**
* @typedef {Object} GDALMetadata
* @property {string} STATISTICS_MINIMUM The minimum value (as a string).
* @property {string} STATISTICS_MAXIMUM The maximum value (as a string).
*/
var STATISTICS_MAXIMUM = 'STATISTICS_MAXIMUM';
var STATISTICS_MINIMUM = 'STATISTICS_MINIMUM';
/**
* @typedef {import("geotiff").GeoTIFFImage} GeoTIFFImage
*/
var workerPool;
function getWorkerPool() {
if (!workerPool) {
workerPool = new Pool();
}
return workerPool;
}
/**
* Get the bounding box of an image. If the image does not have an affine transform,
* the pixel bounds are returned.
* @param {GeoTIFFImage} image The image.
* @return {Array<number>} The image bounding box.
*/
function getBoundingBox(image) {
try {
return image.getBoundingBox();
}
catch (_) {
var fileDirectory = image.fileDirectory;
return [0, 0, fileDirectory.ImageWidth, fileDirectory.ImageLength];
}
}
/**
* Get the origin of an image. If the image does not have an affine transform,
* the top-left corner of the pixel bounds is returned.
* @param {GeoTIFFImage} image The image.
* @return {Array<number>} The image origin.
*/
function getOrigin(image) {
try {
return image.getOrigin().slice(0, 2);
}
catch (_) {
return [0, image.fileDirectory.ImageLength];
}
}
/**
* Get the resolution of an image. If the image does not have an affine transform,
* the width of the image is compared with the reference image.
* @param {GeoTIFFImage} image The image.
* @param {GeoTIFFImage} referenceImage The reference image.
* @return {Array<number>} The map x and y units per pixel.
*/
function getResolutions(image, referenceImage) {
try {
return image.getResolution(referenceImage);
}
catch (_) {
return [
referenceImage.fileDirectory.ImageWidth / image.fileDirectory.ImageWidth,
referenceImage.fileDirectory.ImageHeight /
image.fileDirectory.ImageHeight,
];
}
}
/**
* @param {GeoTIFFImage} image A GeoTIFF.
* @return {import("../proj/Projection.js").default} The image projection.
*/
function getProjection(image) {
var geoKeys = image.geoKeys;
if (!geoKeys) {
return null;
}
if (geoKeys.ProjectedCSTypeGeoKey) {
var code = 'EPSG:' + geoKeys.ProjectedCSTypeGeoKey;
var projection = getCachedProjection(code);
if (!projection) {
var units = unitsFromCode(geoKeys.ProjLinearUnitsGeoKey);
if (units) {
projection = new Projection({
code: code,
units: units,
});
}
}
return projection;
}
if (geoKeys.GeographicTypeGeoKey) {
var code = 'EPSG:' + geoKeys.GeographicTypeGeoKey;
var projection = getCachedProjection(code);
if (!projection) {
var units = unitsFromCode(geoKeys.GeogAngularUnitsGeoKey);
if (units) {
projection = new Projection({
code: code,
units: units,
});
}
}
return projection;
}
return null;
}
/**
* @param {GeoTIFF|MultiGeoTIFF} tiff A GeoTIFF.
* @return {Promise<Array<GeoTIFFImage>>} Resolves to a list of images.
*/
function getImagesForTIFF(tiff) {
return tiff.getImageCount().then(function (count) {
var requests = new Array(count);
for (var i = 0; i < count; ++i) {
requests[i] = tiff.getImage(i);
}
return Promise.all(requests);
});
}
/**
* @param {SourceInfo} source The GeoTIFF source.
* @param {Object} options Options for the GeoTIFF source.
* @return {Promise<Array<GeoTIFFImage>>} Resolves to a list of images.
*/
function getImagesForSource(source, options) {
var request;
if (source.blob) {
request = tiffFromBlob(source.blob);
}
else if (source.overviews) {
request = tiffFromUrls(source.url, source.overviews, options);
}
else {
request = tiffFromUrl(source.url, options);
}
return request.then(getImagesForTIFF);
}
/**
* @param {number|Array<number>|Array<Array<number>>} expected Expected value.
* @param {number|Array<number>|Array<Array<number>>} got Actual value.
* @param {number} tolerance Accepted tolerance in fraction of expected between expected and got.
* @param {string} message The error message.
* @param {function(Error):void} rejector A function to be called with any error.
*/
function assertEqual(expected, got, tolerance, message, rejector) {
if (Array.isArray(expected)) {
var length_1 = expected.length;
if (!Array.isArray(got) || length_1 != got.length) {
var error = new Error(message);
rejector(error);
throw error;
}
for (var i = 0; i < length_1; ++i) {
assertEqual(expected[i], got[i], tolerance, message, rejector);
}
return;
}
got = /** @type {number} */ (got);
if (Math.abs(expected - got) > tolerance * expected) {
throw new Error(message);
}
}
/**
* @param {Array} array The data array.
* @return {number} The minimum value.
*/
function getMinForDataType(array) {
if (array instanceof Int8Array) {
return -128;
}
if (array instanceof Int16Array) {
return -32768;
}
if (array instanceof Int32Array) {
return -2147483648;
}
if (array instanceof Float32Array) {
return 1.2e-38;
}
return 0;
}
/**
* @param {Array} array The data array.
* @return {number} The maximum value.
*/
function getMaxForDataType(array) {
if (array instanceof Int8Array) {
return 127;
}
if (array instanceof Uint8Array) {
return 255;
}
if (array instanceof Uint8ClampedArray) {
return 255;
}
if (array instanceof Int16Array) {
return 32767;
}
if (array instanceof Uint16Array) {
return 65535;
}
if (array instanceof Int32Array) {
return 2147483647;
}
if (array instanceof Uint32Array) {
return 4294967295;
}
if (array instanceof Float32Array) {
return 3.4e38;
}
return 255;
}
/**
* @typedef {Object} GeoTIFFSourceOptions
* @property {boolean} [forceXHR=false] Whether to force the usage of the browsers XMLHttpRequest API.
* @property {Object<string, string>} [headers] additional key-value pairs of headers to be passed with each request. Key is the header name, value the header value.
* @property {string} [credentials] How credentials shall be handled. See
* https://developer.mozilla.org/en-US/docs/Web/API/fetch for reference and possible values
* @property {number} [maxRanges] The maximum amount of ranges to request in a single multi-range request.
* By default only a single range is used.
* @property {boolean} [allowFullFile=false] Whether or not a full file is accepted when only a portion is
* requested. Only use this when you know the source image to be small enough to fit in memory.
* @property {number} [blockSize=65536] The block size to use.
* @property {number} [cacheSize=100] The number of blocks that shall be held in a LRU cache.
*/
/**
* @typedef {Object} Options
* @property {Array<SourceInfo>} sources List of information about GeoTIFF sources.
* Multiple sources can be combined when their resolution sets are equal after applying a scale.
* The list of sources defines a mapping between input bands as they are read from each GeoTIFF and
* the output bands that are provided by data tiles. To control which bands to read from each GeoTIFF,
* use the {@link import("./GeoTIFF.js").SourceInfo bands} property. If, for example, you specify two
* sources, one with 3 bands and {@link import("./GeoTIFF.js").SourceInfo nodata} configured, and
* another with 1 band, the resulting data tiles will have 5 bands: 3 from the first source, 1 alpha
* band from the first source, and 1 band from the second source.
* @property {GeoTIFFSourceOptions} [sourceOptions] Additional options to be passed to [geotiff.js](https://geotiffjs.github.io/geotiff.js/module-geotiff.html)'s `fromUrl` or `fromUrls` methods.
* @property {boolean} [convertToRGB = false] By default, bands from the sources are read as-is. When
* reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
* convert other color spaces (YCbCr, CMYK) to RGB.
* @property {boolean} [normalize=true] By default, the source data is normalized to values between
* 0 and 1 with scaling factors based on the raster statistics or `min` and `max` properties of each source.
* If instead you want to work with the raw values in a style expression, set this to `false`. Setting this option
* to `false` will make it so any `min` and `max` properties on sources are ignored.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {boolean} [wrapX=false] Render tiles beyond the tile grid extent.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* the linear interpolation is used to resample the data. If false, nearest neighbor is used.
*/
/**
* @classdesc
* A source for working with GeoTIFF data.
* @api
*/
var GeoTIFFSource = /** @class */ (function (_super) {
__extends(GeoTIFFSource, _super);
/**
* @param {Options} options Data tile options.
*/
function GeoTIFFSource(options) {
var _this = _super.call(this, {
state: 'loading',
tileGrid: null,
projection: null,
opaque: options.opaque,
transition: options.transition,
interpolate: options.interpolate !== false,
wrapX: options.wrapX,
}) || this;
/**
* @type {Array<SourceInfo>}
* @private
*/
_this.sourceInfo_ = options.sources;
var numSources = _this.sourceInfo_.length;
/**
* @type {Object}
* @private
*/
_this.sourceOptions_ = options.sourceOptions;
/**
* @type {Array<Array<GeoTIFFImage>>}
* @private
*/
_this.sourceImagery_ = new Array(numSources);
/**
* @type {Array<number>}
* @private
*/
_this.resolutionFactors_ = new Array(numSources);
/**
* @type {Array<number>}
* @private
*/
_this.samplesPerPixel_;
/**
* @type {Array<Array<number>>}
* @private
*/
_this.nodataValues_;
/**
* @type {Array<Array<GDALMetadata>>}
* @private
*/
_this.metadata_;
/**
* @type {boolean}
* @private
*/
_this.normalize_ = options.normalize !== false;
/**
* @type {boolean}
* @private
*/
_this.addAlpha_ = false;
/**
* @type {Error}
* @private
*/
_this.error_ = null;
/**
* @type {'readRasters' | 'readRGB'}
*/
_this.readMethod_ = options.convertToRGB ? 'readRGB' : 'readRasters';
_this.setKey(_this.sourceInfo_.map(function (source) { return source.url; }).join(','));
var self = _this;
var requests = new Array(numSources);
for (var i = 0; i < numSources; ++i) {
requests[i] = getImagesForSource(_this.sourceInfo_[i], _this.sourceOptions_);
}
Promise.all(requests)
.then(function (sources) {
self.configure_(sources);
})
.catch(function (error) {
console.error(error); // eslint-disable-line no-console
self.error_ = error;
self.setState('error');
});
return _this;
}
/**
* @return {Error} A source loading error. When the source state is `error`, use this function
* to get more information about the error. To debug a faulty configuration, you may want to use
* a listener like
* ```js
* geotiffSource.on('change', () => {
* if (geotiffSource.getState() === 'error') {
* console.error(geotiffSource.getError());
* }
* });
* ```
*/
GeoTIFFSource.prototype.getError = function () {
return this.error_;
};
/**
* Configure the tile grid based on images within the source GeoTIFFs. Each GeoTIFF
* must have the same internal tiled structure.
* @param {Array<Array<GeoTIFFImage>>} sources Each source is a list of images
* from a single GeoTIFF.
* @private
*/
GeoTIFFSource.prototype.configure_ = function (sources) {
var extent;
var origin;
var commonRenderTileSizes;
var commonSourceTileSizes;
var resolutions;
var samplesPerPixel = new Array(sources.length);
var nodataValues = new Array(sources.length);
var metadata = new Array(sources.length);
var minZoom = 0;
var sourceCount = sources.length;
var _loop_1 = function (sourceIndex) {
var images = sources[sourceIndex];
var imageCount = images.length;
var sourceExtent = void 0;
var sourceOrigin = void 0;
var sourceTileSizes = new Array(imageCount);
var renderTileSizes = new Array(imageCount);
var sourceResolutions = new Array(imageCount);
nodataValues[sourceIndex] = new Array(imageCount);
metadata[sourceIndex] = new Array(imageCount);
for (var imageIndex = 0; imageIndex < imageCount; ++imageIndex) {
var image = images[imageIndex];
var nodataValue = image.getGDALNoData();
metadata[sourceIndex][imageIndex] = image.getGDALMetadata(0);
nodataValues[sourceIndex][imageIndex] = nodataValue;
var wantedSamples = this_1.sourceInfo_[sourceIndex].bands;
samplesPerPixel[sourceIndex] = wantedSamples
? wantedSamples.length
: image.getSamplesPerPixel();
var level = imageCount - (imageIndex + 1);
if (!sourceExtent) {
sourceExtent = getBoundingBox(image);
}
if (!sourceOrigin) {
sourceOrigin = getOrigin(image);
}
var imageResolutions = getResolutions(image, images[0]);
sourceResolutions[level] = imageResolutions[0];
var sourceTileSize = [image.getTileWidth(), image.getTileHeight()];
sourceTileSizes[level] = sourceTileSize;
var aspectRatio = imageResolutions[0] / Math.abs(imageResolutions[1]);
renderTileSizes[level] = [
sourceTileSize[0],
sourceTileSize[1] / aspectRatio,
];
}
if (!extent) {
extent = sourceExtent;
}
else {
getIntersection(extent, sourceExtent, extent);
}
if (!origin) {
origin = sourceOrigin;
}
else {
var message = "Origin mismatch for source ".concat(sourceIndex, ", got [").concat(sourceOrigin, "] but expected [").concat(origin, "]");
assertEqual(origin, sourceOrigin, 0, message, this_1.viewRejector);
}
if (!resolutions) {
resolutions = sourceResolutions;
this_1.resolutionFactors_[sourceIndex] = 1;
}
else {
if (resolutions.length - minZoom > sourceResolutions.length) {
minZoom = resolutions.length - sourceResolutions.length;
}
var resolutionFactor_1 = resolutions[resolutions.length - 1] /
sourceResolutions[sourceResolutions.length - 1];
this_1.resolutionFactors_[sourceIndex] = resolutionFactor_1;
var scaledSourceResolutions = sourceResolutions.map(function (resolution) { return (resolution *= resolutionFactor_1); });
var message = "Resolution mismatch for source ".concat(sourceIndex, ", got [").concat(scaledSourceResolutions, "] but expected [").concat(resolutions, "]");
assertEqual(resolutions.slice(minZoom, resolutions.length), scaledSourceResolutions, 0.02, message, this_1.viewRejector);
}
if (!commonRenderTileSizes) {
commonRenderTileSizes = renderTileSizes;
}
else {
assertEqual(commonRenderTileSizes.slice(minZoom, commonRenderTileSizes.length), renderTileSizes, 0.01, "Tile size mismatch for source ".concat(sourceIndex), this_1.viewRejector);
}
if (!commonSourceTileSizes) {
commonSourceTileSizes = sourceTileSizes;
}
else {
assertEqual(commonSourceTileSizes.slice(minZoom, commonSourceTileSizes.length), sourceTileSizes, 0, "Tile size mismatch for source ".concat(sourceIndex), this_1.viewRejector);
}
this_1.sourceImagery_[sourceIndex] = images.reverse();
};
var this_1 = this;
for (var sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
_loop_1(sourceIndex);
}
for (var i = 0, ii = this.sourceImagery_.length; i < ii; ++i) {
var sourceImagery = this.sourceImagery_[i];
while (sourceImagery.length < resolutions.length) {
sourceImagery.unshift(undefined);
}
}
if (!this.getProjection()) {
var firstSource = sources[0];
for (var i = firstSource.length - 1; i >= 0; --i) {
var image = firstSource[i];
var projection = getProjection(image);
if (projection) {
this.projection = projection;
break;
}
}
}
this.samplesPerPixel_ = samplesPerPixel;
this.nodataValues_ = nodataValues;
this.metadata_ = metadata;
// decide if we need to add an alpha band to handle nodata
outer: for (var sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
// option 1: source is configured with a nodata value
if (this.sourceInfo_[sourceIndex].nodata !== undefined) {
this.addAlpha_ = true;
break;
}
var values = nodataValues[sourceIndex];
// option 2: check image metadata for limited bands
var bands = this.sourceInfo_[sourceIndex].bands;
if (bands) {
for (var i = 0; i < bands.length; ++i) {
if (values[bands[i] - 1] !== null) {
this.addAlpha_ = true;
break outer;
}
}
continue;
}
// option 3: check image metadata for all bands
for (var imageIndex = 0; imageIndex < values.length; ++imageIndex) {
if (values[imageIndex] !== null) {
this.addAlpha_ = true;
break outer;
}
}
}
var additionalBands = this.addAlpha_ ? 1 : 0;
this.bandCount =
samplesPerPixel.reduce(function (accumulator, value) {
accumulator += value;
return accumulator;
}, 0) + additionalBands;
var tileGrid = new TileGrid({
extent: extent,
minZoom: minZoom,
origin: origin,
resolutions: resolutions,
tileSizes: commonRenderTileSizes,
});
this.tileGrid = tileGrid;
this.setTileSizes(commonSourceTileSizes);
this.setLoader(this.loadTile_.bind(this));
this.setState('ready');
this.viewResolver({
projection: this.projection,
resolutions: resolutions,
center: toUserCoordinate(getCenter(extent), this.projection),
extent: toUserExtent(extent, this.projection),
zoom: 0,
});
};
GeoTIFFSource.prototype.loadTile_ = function (z, x, y) {
var sourceTileSize = this.getTileSize(z);
var sourceCount = this.sourceImagery_.length;
var requests = new Array(sourceCount);
var addAlpha = this.addAlpha_;
var bandCount = this.bandCount;
var samplesPerPixel = this.samplesPerPixel_;
var nodataValues = this.nodataValues_;
var sourceInfo = this.sourceInfo_;
var _loop_2 = function (sourceIndex) {
var source = sourceInfo[sourceIndex];
var resolutionFactor = this_2.resolutionFactors_[sourceIndex];
var pixelBounds = [
Math.round(x * (sourceTileSize[0] * resolutionFactor)),
Math.round(y * (sourceTileSize[1] * resolutionFactor)),
Math.round((x + 1) * (sourceTileSize[0] * resolutionFactor)),
Math.round((y + 1) * (sourceTileSize[1] * resolutionFactor)),
];
var image = this_2.sourceImagery_[sourceIndex][z];
var samples = void 0;
if (source.bands) {
samples = source.bands.map(function (bandNumber) {
return bandNumber - 1;
});
}
/** @type {number|Array<number>} */
var fillValue = void 0;
if ('nodata' in source && source.nodata !== null) {
fillValue = source.nodata;
}
else {
if (!samples) {
fillValue = nodataValues[sourceIndex];
}
else {
fillValue = samples.map(function (sampleIndex) {
return nodataValues[sourceIndex][sampleIndex];
});
}
}
requests[sourceIndex] = image[this_2.readMethod_]({
window: pixelBounds,
width: sourceTileSize[0],
height: sourceTileSize[1],
samples: samples,
fillValue: fillValue,
pool: getWorkerPool(),
interleave: false,
});
};
var this_2 = this;
for (var sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
_loop_2(sourceIndex);
}
var pixelCount = sourceTileSize[0] * sourceTileSize[1];
var dataLength = pixelCount * bandCount;
var normalize = this.normalize_;
var metadata = this.metadata_;
return Promise.all(requests)
.then(function (sourceSamples) {
/** @type {Uint8Array|Float32Array} */
var data;
if (normalize) {
data = new Uint8Array(dataLength);
}
else {
data = new Float32Array(dataLength);
}
var dataIndex = 0;
for (var pixelIndex = 0; pixelIndex < pixelCount; ++pixelIndex) {
var transparent = addAlpha;
for (var sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
var source = sourceInfo[sourceIndex];
var min = source.min;
var max = source.max;
var gain = void 0, bias = void 0;
if (normalize) {
var stats = metadata[sourceIndex][0];
if (min === undefined) {
if (stats && STATISTICS_MINIMUM in stats) {
min = parseFloat(stats[STATISTICS_MINIMUM]);
}
else {
min = getMinForDataType(sourceSamples[sourceIndex][0]);
}
}
if (max === undefined) {
if (stats && STATISTICS_MAXIMUM in stats) {
max = parseFloat(stats[STATISTICS_MAXIMUM]);
}
else {
max = getMaxForDataType(sourceSamples[sourceIndex][0]);
}
}
gain = 255 / (max - min);
bias = -min * gain;
}
for (var sampleIndex = 0; sampleIndex < samplesPerPixel[sourceIndex]; ++sampleIndex) {
var sourceValue = sourceSamples[sourceIndex][sampleIndex][pixelIndex];
var value = void 0;
if (normalize) {
value = clamp(gain * sourceValue + bias, 0, 255);
}
else {
value = sourceValue;
}
if (!addAlpha) {
data[dataIndex] = value;
}
else {
var nodata = source.nodata;
if (nodata === undefined) {
var bandIndex = void 0;
if (source.bands) {
bandIndex = source.bands[sampleIndex] - 1;
}
else {
bandIndex = sampleIndex;
}
nodata = nodataValues[sourceIndex][bandIndex];
}
var nodataIsNaN = isNaN(nodata);
if ((!nodataIsNaN && sourceValue !== nodata) ||
(nodataIsNaN && !isNaN(sourceValue))) {
transparent = false;
data[dataIndex] = value;
}
}
dataIndex++;
}
}
if (addAlpha) {
if (!transparent) {
data[dataIndex] = 255;
}
dataIndex++;
}
}
return data;
})
.catch(function (error) {
// output then rethrow
console.error(error); // eslint-disable-line no-console
throw error;
});
};
return GeoTIFFSource;
}(DataTile));
/**
* Get a promise for view properties based on the source. Use the result of this function
* as the `view` option in a map constructor.
*
* const source = new GeoTIFF(options);
*
* const map = new Map({
* target: 'map',
* layers: [
* new TileLayer({
* source: source,
* }),
* ],
* view: source.getView(),
* });
*
* @function
* @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
* @api
*
*/
GeoTIFFSource.prototype.getView;
export default GeoTIFFSource;
//# sourceMappingURL=GeoTIFF.js.map
+1
View File
File diff suppressed because one or more lines are too long
+117
View File
@@ -0,0 +1,117 @@
export default IIIF;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* Size of the cache.
*/
cacheSize?: number | undefined;
/**
* The value for the crossOrigin option of the request.
*/
crossOrigin?: string | null | undefined;
/**
* The extent.
*/
extent?: import("../extent.js").Extent | undefined;
/**
* Requested image format.
*/
format?: string | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Requested IIIF image quality. Default is 'native'
* for version 1, 'default' for versions 2 and 3.
*/
quality?: string | undefined;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Supported resolutions as given in IIIF 'scaleFactors'
*/
resolutions?: number[] | undefined;
/**
* Size of the image [width, height].
*/
size: import("../size.js").Size;
/**
* Supported scaled image sizes.
* Content of the IIIF info.json 'sizes' property, but as array of Size objects.
*/
sizes?: import("../size.js").Size[] | undefined;
/**
* Source state.
*/
state?: import("./Source.js").State | undefined;
/**
* Supported IIIF region and size calculation
* features.
*/
supports?: string[] | undefined;
/**
* Tile pixel ratio.
*/
tilePixelRatio?: number | undefined;
/**
* Tile size.
* Same tile size is used for all zoom levels. If tile size is a number,
* a square tile is assumed. If the IIIF image service supports arbitrary
* tiling (sizeByH, sizeByW, sizeByWh or sizeByPct as well as regionByPx or regionByPct
* are supported), the default tilesize is 256.
*/
tileSize?: number | import("../size.js").Size | undefined;
/**
* Transition.
*/
transition?: number | undefined;
/**
* Base URL of the IIIF Image service.
* This should be the same as the IIIF Image ID.
*/
url?: string | undefined;
/**
* Service's IIIF Image API version.
*/
version?: string | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @classdesc
* Layer source for IIIF Image API services.
* @api
*/
declare class IIIF extends TileImage {
/**
* @param {Options} [opt_options] Tile source options. Use {@link import("../format/IIIFInfo.js").IIIFInfo}
* to parse Image API service information responses into constructor options.
* @api
*/
constructor(opt_options?: Options | undefined);
}
import TileImage from "./TileImage.js";
//# sourceMappingURL=IIIF.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IIIF.d.ts","sourceRoot":"","sources":["../src/source/IIIF.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;UAMnC,OAAO,YAAY,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBvC;;;;GAIG;AACH;IACE;;;;OAIG;IACH,+CAmSC;CACF"}
+338
View File
@@ -0,0 +1,338 @@
/**
* @module ol/source/IIIF
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import TileGrid from '../tilegrid/TileGrid.js';
import TileImage from './TileImage.js';
import { CustomTile } from './Zoomify.js';
import { DEFAULT_TILE_SIZE } from '../tilegrid/common.js';
import { Versions } from '../format/IIIFInfo.js';
import { assert } from '../asserts.js';
import { getTopLeft } from '../extent.js';
import { includes } from '../array.js';
import { toSize } from '../size.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Size of the cache.
* @property {null|string} [crossOrigin] The value for the crossOrigin option of the request.
* @property {import("../extent.js").Extent} [extent=[0, -height, width, 0]] The extent.
* @property {string} [format='jpg'] Requested image format.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
* @property {string} [quality] Requested IIIF image quality. Default is 'native'
* for version 1, 'default' for versions 2 and 3.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {Array<number>} [resolutions] Supported resolutions as given in IIIF 'scaleFactors'
* @property {import("../size.js").Size} size Size of the image [width, height].
* @property {Array<import("../size.js").Size>} [sizes] Supported scaled image sizes.
* Content of the IIIF info.json 'sizes' property, but as array of Size objects.
* @property {import("./Source.js").State} [state] Source state.
* @property {Array<string>} [supports=[]] Supported IIIF region and size calculation
* features.
* @property {number} [tilePixelRatio] Tile pixel ratio.
* @property {number|import("../size.js").Size} [tileSize] Tile size.
* Same tile size is used for all zoom levels. If tile size is a number,
* a square tile is assumed. If the IIIF image service supports arbitrary
* tiling (sizeByH, sizeByW, sizeByWh or sizeByPct as well as regionByPx or regionByPct
* are supported), the default tilesize is 256.
* @property {number} [transition] Transition.
* @property {string} [url] Base URL of the IIIF Image service.
* This should be the same as the IIIF Image ID.
* @property {import("../format/IIIFInfo.js").Versions} [version=Versions.VERSION2] Service's IIIF Image API version.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
function formatPercentage(percentage) {
return percentage.toLocaleString('en', { maximumFractionDigits: 10 });
}
/**
* @classdesc
* Layer source for IIIF Image API services.
* @api
*/
var IIIF = /** @class */ (function (_super) {
__extends(IIIF, _super);
/**
* @param {Options} [opt_options] Tile source options. Use {@link import("../format/IIIFInfo.js").IIIFInfo}
* to parse Image API service information responses into constructor options.
* @api
*/
function IIIF(opt_options) {
var _this = this;
/**
* @type {Partial<Options>}
*/
var options = opt_options || {};
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
var baseUrl = options.url || '';
baseUrl =
baseUrl +
(baseUrl.lastIndexOf('/') === baseUrl.length - 1 || baseUrl === ''
? ''
: '/');
var version = options.version || Versions.VERSION2;
var sizes = options.sizes || [];
var size = options.size;
assert(size != undefined &&
Array.isArray(size) &&
size.length == 2 &&
!isNaN(size[0]) &&
size[0] > 0 &&
!isNaN(size[1]) &&
size[1] > 0, 60);
var width = size[0];
var height = size[1];
var tileSize = options.tileSize;
var tilePixelRatio = options.tilePixelRatio || 1;
var format = options.format || 'jpg';
var quality = options.quality ||
(options.version == Versions.VERSION1 ? 'native' : 'default');
var resolutions = options.resolutions || [];
var supports = options.supports || [];
var extent = options.extent || [0, -height, width, 0];
var supportsListedSizes = sizes != undefined && Array.isArray(sizes) && sizes.length > 0;
var supportsListedTiles = tileSize !== undefined &&
((typeof tileSize === 'number' &&
Number.isInteger(tileSize) &&
tileSize > 0) ||
(Array.isArray(tileSize) && tileSize.length > 0));
var supportsArbitraryTiling = supports != undefined &&
Array.isArray(supports) &&
(includes(supports, 'regionByPx') || includes(supports, 'regionByPct')) &&
(includes(supports, 'sizeByWh') ||
includes(supports, 'sizeByH') ||
includes(supports, 'sizeByW') ||
includes(supports, 'sizeByPct'));
var tileWidth, tileHeight, maxZoom;
resolutions.sort(function (a, b) {
return b - a;
});
if (supportsListedTiles || supportsArbitraryTiling) {
if (tileSize != undefined) {
if (typeof tileSize === 'number' &&
Number.isInteger(tileSize) &&
tileSize > 0) {
tileWidth = tileSize;
tileHeight = tileSize;
}
else if (Array.isArray(tileSize) && tileSize.length > 0) {
if (tileSize.length == 1 ||
(tileSize[1] == undefined && Number.isInteger(tileSize[0]))) {
tileWidth = tileSize[0];
tileHeight = tileSize[0];
}
if (tileSize.length == 2) {
if (Number.isInteger(tileSize[0]) &&
Number.isInteger(tileSize[1])) {
tileWidth = tileSize[0];
tileHeight = tileSize[1];
}
else if (tileSize[0] == undefined &&
Number.isInteger(tileSize[1])) {
tileWidth = tileSize[1];
tileHeight = tileSize[1];
}
}
}
}
if (tileWidth === undefined || tileHeight === undefined) {
tileWidth = DEFAULT_TILE_SIZE;
tileHeight = DEFAULT_TILE_SIZE;
}
if (resolutions.length == 0) {
maxZoom = Math.max(Math.ceil(Math.log(width / tileWidth) / Math.LN2), Math.ceil(Math.log(height / tileHeight) / Math.LN2));
for (var i = maxZoom; i >= 0; i--) {
resolutions.push(Math.pow(2, i));
}
}
else {
var maxScaleFactor = Math.max.apply(Math, resolutions);
// TODO maxScaleFactor might not be a power to 2
maxZoom = Math.round(Math.log(maxScaleFactor) / Math.LN2);
}
}
else {
// No tile support.
tileWidth = width;
tileHeight = height;
resolutions = [];
if (supportsListedSizes) {
/*
* 'sizes' provided. Use full region in different resolutions. Every
* resolution has only one tile.
*/
sizes.sort(function (a, b) {
return a[0] - b[0];
});
maxZoom = -1;
var ignoredSizesIndex = [];
for (var i = 0; i < sizes.length; i++) {
var resolution = width / sizes[i][0];
if (resolutions.length > 0 &&
resolutions[resolutions.length - 1] == resolution) {
ignoredSizesIndex.push(i);
continue;
}
resolutions.push(resolution);
maxZoom++;
}
if (ignoredSizesIndex.length > 0) {
for (var i = 0; i < ignoredSizesIndex.length; i++) {
sizes.splice(ignoredSizesIndex[i] - i, 1);
}
}
}
else {
// No useful image information at all. Try pseudo tile with full image.
resolutions.push(1);
sizes.push([width, height]);
maxZoom = 0;
}
}
var tileGrid = new TileGrid({
tileSize: [tileWidth, tileHeight],
extent: extent,
origin: getTopLeft(extent),
resolutions: resolutions,
});
var tileUrlFunction = function (tileCoord, pixelRatio, projection) {
var regionParam, sizeParam;
var zoom = tileCoord[0];
if (zoom > maxZoom) {
return;
}
var tileX = tileCoord[1], tileY = tileCoord[2], scale = resolutions[zoom];
if (tileX === undefined ||
tileY === undefined ||
scale === undefined ||
tileX < 0 ||
Math.ceil(width / scale / tileWidth) <= tileX ||
tileY < 0 ||
Math.ceil(height / scale / tileHeight) <= tileY) {
return;
}
if (supportsArbitraryTiling || supportsListedTiles) {
var regionX = tileX * tileWidth * scale, regionY = tileY * tileHeight * scale;
var regionW = tileWidth * scale, regionH = tileHeight * scale, sizeW = tileWidth, sizeH = tileHeight;
if (regionX + regionW > width) {
regionW = width - regionX;
}
if (regionY + regionH > height) {
regionH = height - regionY;
}
if (regionX + tileWidth * scale > width) {
sizeW = Math.floor((width - regionX + scale - 1) / scale);
}
if (regionY + tileHeight * scale > height) {
sizeH = Math.floor((height - regionY + scale - 1) / scale);
}
if (regionX == 0 &&
regionW == width &&
regionY == 0 &&
regionH == height) {
// canonical full image region parameter is 'full', not 'x,y,w,h'
regionParam = 'full';
}
else if (!supportsArbitraryTiling ||
includes(supports, 'regionByPx')) {
regionParam = regionX + ',' + regionY + ',' + regionW + ',' + regionH;
}
else if (includes(supports, 'regionByPct')) {
var pctX = formatPercentage((regionX / width) * 100), pctY = formatPercentage((regionY / height) * 100), pctW = formatPercentage((regionW / width) * 100), pctH = formatPercentage((regionH / height) * 100);
regionParam = 'pct:' + pctX + ',' + pctY + ',' + pctW + ',' + pctH;
}
if (version == Versions.VERSION3 &&
(!supportsArbitraryTiling || includes(supports, 'sizeByWh'))) {
sizeParam = sizeW + ',' + sizeH;
}
else if (!supportsArbitraryTiling || includes(supports, 'sizeByW')) {
sizeParam = sizeW + ',';
}
else if (includes(supports, 'sizeByH')) {
sizeParam = ',' + sizeH;
}
else if (includes(supports, 'sizeByWh')) {
sizeParam = sizeW + ',' + sizeH;
}
else if (includes(supports, 'sizeByPct')) {
sizeParam = 'pct:' + formatPercentage(100 / scale);
}
}
else {
regionParam = 'full';
if (supportsListedSizes) {
var regionWidth = sizes[zoom][0], regionHeight = sizes[zoom][1];
if (version == Versions.VERSION3) {
if (regionWidth == width && regionHeight == height) {
sizeParam = 'max';
}
else {
sizeParam = regionWidth + ',' + regionHeight;
}
}
else {
if (regionWidth == width) {
sizeParam = 'full';
}
else {
sizeParam = regionWidth + ',';
}
}
}
else {
sizeParam = version == Versions.VERSION3 ? 'max' : 'full';
}
}
return (baseUrl + regionParam + '/' + sizeParam + '/0/' + quality + '.' + format);
};
var IiifTileClass = CustomTile.bind(null, toSize(tileSize || 256).map(function (size) {
return size * tilePixelRatio;
}));
_this = _super.call(this, {
attributions: options.attributions,
attributionsCollapsible: options.attributionsCollapsible,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
interpolate: interpolate,
projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: options.state,
tileClass: IiifTileClass,
tileGrid: tileGrid,
tilePixelRatio: options.tilePixelRatio,
tileUrlFunction: tileUrlFunction,
transition: options.transition,
}) || this;
/**
* @type {number|import("../array.js").NearestDirectionFunction}
*/
_this.zDirection = options.zDirection;
return _this;
}
return IIIF;
}(TileImage));
export default IIIF;
//# sourceMappingURL=IIIF.js.map
+1
View File
File diff suppressed because one or more lines are too long
+160
View File
@@ -0,0 +1,160 @@
/**
* Default image load function for image sources that use import("../Image.js").Image image
* instances.
* @param {import("../Image.js").default} image Image.
* @param {string} src Source.
*/
export function defaultImageLoadFunction(image: import("../Image.js").default, src: string): void;
export type ImageSourceEventType = string;
export namespace ImageSourceEventType {
const IMAGELOADSTART: string;
const IMAGELOADEND: string;
const IMAGELOADERROR: string;
}
/**
* @typedef {'imageloadend'|'imageloaderror'|'imageloadstart'} ImageSourceEventTypes
*/
/**
* @classdesc
* Events emitted by {@link module:ol/source/Image~ImageSource} instances are instances of this
* type.
*/
export class ImageSourceEvent extends Event {
/**
* @param {string} type Type.
* @param {import("../Image.js").default} image The image.
*/
constructor(type: string, image: import("../Image.js").default);
/**
* The image related to the event.
* @type {import("../Image.js").default}
* @api
*/
image: import("../Image.js").default;
}
export default ImageSource;
export type ImageSourceEventTypes = 'imageloadend' | 'imageloaderror' | 'imageloadstart';
/**
* *
*/
export type ImageSourceOnSignature<Return> = import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> & import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> & import("../Observable").OnSignature<ImageSourceEventTypes, ImageSourceEvent, Return> & import("../Observable").CombinedOnSignature<import("../Observable").EventTypes | import("../ObjectEventType").Types | ImageSourceEventTypes, Return>;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Resolutions.
*/
resolutions?: number[] | undefined;
/**
* State.
*/
state?: import("./Source.js").State | undefined;
};
import Event from "../events/Event.js";
/***
* @template Return
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
* import("../Observable").OnSignature<ImageSourceEventTypes, ImageSourceEvent, Return> &
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types
* |ImageSourceEventTypes, Return>} ImageSourceOnSignature
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
* @property {Array<number>} [resolutions] Resolutions.
* @property {import("./Source.js").State} [state] State.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for sources providing a single image.
* @abstract
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
declare class ImageSource extends Source {
/**
* @param {Options} options Single image source options.
*/
constructor(options: Options);
/***
* @type {ImageSourceOnSignature<import("../events").EventsKey>}
*/
on: ImageSourceOnSignature<import("../events").EventsKey>;
/***
* @type {ImageSourceOnSignature<import("../events").EventsKey>}
*/
once: ImageSourceOnSignature<import("../events").EventsKey>;
/***
* @type {ImageSourceOnSignature<void>}
*/
un: ImageSourceOnSignature<void>;
/**
* @private
* @type {Array<number>|null}
*/
private resolutions_;
/**
* @private
* @type {import("../reproj/Image.js").default}
*/
private reprojectedImage_;
/**
* @private
* @type {number}
*/
private reprojectedRevision_;
/**
* @protected
* @param {number} resolution Resolution.
* @return {number} Resolution.
*/
protected findNearestResolution(resolution: number): number;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageBase.js").default} Single image.
*/
getImage(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../ImageBase.js").default;
/**
* @abstract
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageBase.js").default} Single image.
* @protected
*/
protected getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../ImageBase.js").default;
/**
* Handle image change events.
* @param {import("../events/Event.js").default} event Event.
* @protected
*/
protected handleImageChange(event: import("../events/Event.js").default): void;
}
import Source from "./Source.js";
//# sourceMappingURL=Image.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/source/Image.js"],"names":[],"mappings":"AAyQA;;;;;GAKG;AACH,gDAHW,OAAO,aAAa,EAAE,OAAO,OAC7B,MAAM,QAIhB;mCAnQS,MAAM;;;;;;AAyBhB;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,kBAHW,MAAM,SACN,OAAO,aAAa,EAAE,OAAO,EAWvC;IANC;;;;OAIG;IACH,OAHU,OAAO,aAAa,EAAE,OAAO,CAGrB;CAErB;;oCAvBY,cAAc,GAAC,gBAAgB,GAAC,gBAAgB;;;;6CA2BhD,OAAO,eAAe,EAAE,WAAW,CAAC,OAAO,eAAe,EAAE,UAAU,EAAE,OAAO,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC,GACjI,OAAW,eAAe,EAAE,WAAW,CAAC,OAAO,oBAAoB,EAAE,KAAK,EAAE,OAAO,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,GACpH,OAAW,eAAe,EAAE,WAAW,CAAC,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,CAAC,GACxF,OAAW,eAAe,EAAE,mBAAmB,CAAC,OAAO,eAAe,EAAE,UAAU,GAAC,OAAO,oBAAoB,EAAE,KAAK,GAC9G,qBAAqB,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;iBASxB,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;AAfjD;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAiDjB;IAjCC;;OAEG;IACH,IAFU,uBAAuB,OAAO,WAAW,EAAE,SAAS,CAAC,CAExD;IAEP;;OAEG;IACH,MAFU,uBAAuB,OAAO,WAAW,EAAE,SAAS,CAAC,CAEtD;IAET;;OAEG;IACH,IAFU,uBAAuB,IAAI,CAAC,CAE/B;IAEP;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,6BAA6B;IAU/B;;;;OAIG;IACH,4CAHW,MAAM,GACL,MAAM,CAQjB;IAED;;;;;;OAMG;IACH,iBANW,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACtC,OAAO,iBAAiB,EAAE,OAAO,CAgD5C;IAED;;;;;;;;OAQG;IACH,mCAPW,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACtC,OAAO,iBAAiB,EAAE,OAAO,CAK5C;IAED;;;;OAIG;IACH,mCAHW,OAAO,oBAAoB,EAAE,OAAO,QAyB9C;CACF"}
+258
View File
@@ -0,0 +1,258 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/Image
*/
import Event from '../events/Event.js';
import ImageState from '../ImageState.js';
import ReprojImage from '../reproj/Image.js';
import Source from './Source.js';
import { ENABLE_RASTER_REPROJECTION } from '../reproj/common.js';
import { abstract } from '../util.js';
import { equals } from '../extent.js';
import { equivalent } from '../proj.js';
import { linearFindNearest } from '../array.js';
/**
* @enum {string}
*/
export var ImageSourceEventType = {
/**
* Triggered when an image starts loading.
* @event module:ol/source/Image.ImageSourceEvent#imageloadstart
* @api
*/
IMAGELOADSTART: 'imageloadstart',
/**
* Triggered when an image finishes loading.
* @event module:ol/source/Image.ImageSourceEvent#imageloadend
* @api
*/
IMAGELOADEND: 'imageloadend',
/**
* Triggered if image loading results in an error.
* @event module:ol/source/Image.ImageSourceEvent#imageloaderror
* @api
*/
IMAGELOADERROR: 'imageloaderror',
};
/**
* @typedef {'imageloadend'|'imageloaderror'|'imageloadstart'} ImageSourceEventTypes
*/
/**
* @classdesc
* Events emitted by {@link module:ol/source/Image~ImageSource} instances are instances of this
* type.
*/
var ImageSourceEvent = /** @class */ (function (_super) {
__extends(ImageSourceEvent, _super);
/**
* @param {string} type Type.
* @param {import("../Image.js").default} image The image.
*/
function ImageSourceEvent(type, image) {
var _this = _super.call(this, type) || this;
/**
* The image related to the event.
* @type {import("../Image.js").default}
* @api
*/
_this.image = image;
return _this;
}
return ImageSourceEvent;
}(Event));
export { ImageSourceEvent };
/***
* @template Return
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
* import("../Observable").OnSignature<ImageSourceEventTypes, ImageSourceEvent, Return> &
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types
* |ImageSourceEventTypes, Return>} ImageSourceOnSignature
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
* @property {Array<number>} [resolutions] Resolutions.
* @property {import("./Source.js").State} [state] State.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for sources providing a single image.
* @abstract
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
var ImageSource = /** @class */ (function (_super) {
__extends(ImageSource, _super);
/**
* @param {Options} options Single image source options.
*/
function ImageSource(options) {
var _this = this;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
projection: options.projection,
state: options.state,
interpolate: interpolate,
}) || this;
/***
* @type {ImageSourceOnSignature<import("../events").EventsKey>}
*/
_this.on;
/***
* @type {ImageSourceOnSignature<import("../events").EventsKey>}
*/
_this.once;
/***
* @type {ImageSourceOnSignature<void>}
*/
_this.un;
/**
* @private
* @type {Array<number>|null}
*/
_this.resolutions_ =
options.resolutions !== undefined ? options.resolutions : null;
/**
* @private
* @type {import("../reproj/Image.js").default}
*/
_this.reprojectedImage_ = null;
/**
* @private
* @type {number}
*/
_this.reprojectedRevision_ = 0;
return _this;
}
/**
* @return {Array<number>|null} Resolutions.
*/
ImageSource.prototype.getResolutions = function () {
return this.resolutions_;
};
/**
* @protected
* @param {number} resolution Resolution.
* @return {number} Resolution.
*/
ImageSource.prototype.findNearestResolution = function (resolution) {
if (this.resolutions_) {
var idx = linearFindNearest(this.resolutions_, resolution, 0);
resolution = this.resolutions_[idx];
}
return resolution;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageBase.js").default} Single image.
*/
ImageSource.prototype.getImage = function (extent, resolution, pixelRatio, projection) {
var sourceProjection = this.getProjection();
if (!ENABLE_RASTER_REPROJECTION ||
!sourceProjection ||
!projection ||
equivalent(sourceProjection, projection)) {
if (sourceProjection) {
projection = sourceProjection;
}
return this.getImageInternal(extent, resolution, pixelRatio, projection);
}
else {
if (this.reprojectedImage_) {
if (this.reprojectedRevision_ == this.getRevision() &&
equivalent(this.reprojectedImage_.getProjection(), projection) &&
this.reprojectedImage_.getResolution() == resolution &&
equals(this.reprojectedImage_.getExtent(), extent)) {
return this.reprojectedImage_;
}
this.reprojectedImage_.dispose();
this.reprojectedImage_ = null;
}
this.reprojectedImage_ = new ReprojImage(sourceProjection, projection, extent, resolution, pixelRatio, function (extent, resolution, pixelRatio) {
return this.getImageInternal(extent, resolution, pixelRatio, sourceProjection);
}.bind(this), this.getInterpolate());
this.reprojectedRevision_ = this.getRevision();
return this.reprojectedImage_;
}
};
/**
* @abstract
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageBase.js").default} Single image.
* @protected
*/
ImageSource.prototype.getImageInternal = function (extent, resolution, pixelRatio, projection) {
return abstract();
};
/**
* Handle image change events.
* @param {import("../events/Event.js").default} event Event.
* @protected
*/
ImageSource.prototype.handleImageChange = function (event) {
var image = /** @type {import("../Image.js").default} */ (event.target);
var type;
switch (image.getState()) {
case ImageState.LOADING:
this.loading = true;
type = ImageSourceEventType.IMAGELOADSTART;
break;
case ImageState.LOADED:
this.loading = false;
type = ImageSourceEventType.IMAGELOADEND;
break;
case ImageState.ERROR:
this.loading = false;
type = ImageSourceEventType.IMAGELOADERROR;
break;
default:
return;
}
if (this.hasListener(type)) {
this.dispatchEvent(new ImageSourceEvent(type, image));
}
};
return ImageSource;
}(Source));
/**
* Default image load function for image sources that use import("../Image.js").Image image
* instances.
* @param {import("../Image.js").default} image Image.
* @param {string} src Source.
*/
export function defaultImageLoadFunction(image, src) {
/** @type {HTMLImageElement|HTMLVideoElement} */ (image.getImage()).src = src;
}
export default ImageSource;
//# sourceMappingURL=Image.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../src/source/Image.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAG;IAClC;;;;OAIG;IACH,cAAc,EAAE,gBAAgB;IAEhC;;;;OAIG;IACH,YAAY,EAAE,cAAc;IAE5B;;;;OAIG;IACH,cAAc,EAAE,gBAAgB;CACjC,CAAC;AAEF;;GAEG;AAEH;;;;GAIG;AACH;IAAsC,oCAAK;IACzC;;;OAGG;IACH,0BAAY,IAAI,EAAE,KAAK;QAAvB,YACE,kBAAM,IAAI,CAAC,SAQZ;QANC;;;;WAIG;QACH,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;IACrB,CAAC;IACH,uBAAC;AAAD,CAAC,AAfD,CAAsC,KAAK,GAe1C;;AAED;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH;IAA0B,+BAAM;IAC9B;;OAEG;IACH,qBAAY,OAAO;QAAnB,iBA+CC;QA9CC,IAAI,WAAW,GACb,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;QACvE,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AC;IAED;;;;OAIG;IACH,uCAAiB,GAAjB,UAAkB,KAAK;QACrB,IAAM,KAAK,GAAG,4CAA4C,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC1E,IAAI,IAAI,CAAC;QACT,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE;YACxB,KAAK,UAAU,CAAC,OAAO;gBACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;gBACpB,IAAI,GAAG,oBAAoB,CAAC,cAAc,CAAC;gBAC3C,MAAM;YACR,KAAK,UAAU,CAAC,MAAM;gBACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;gBACrB,IAAI,GAAG,oBAAoB,CAAC,YAAY,CAAC;gBACzC,MAAM;YACR,KAAK,UAAU,CAAC,KAAK;gBACnB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;gBACrB,IAAI,GAAG,oBAAoB,CAAC,cAAc,CAAC;gBAC3C,MAAM;YACR;gBACE,OAAO;SACV;QACD,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;YAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;SACvD;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AAzKD,CAA0B,MAAM,GAyK/B;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAK,EAAE,GAAG;IACjD,gDAAgD,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAChF,CAAC;AAED,eAAe,WAAW,CAAC"}
+213
View File
@@ -0,0 +1,213 @@
export default ImageArcGISRest;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Use the `ol/Map#pixelRatio` value when requesting the image from
* the remote server.
*/
hidpi?: boolean | undefined;
/**
* Optional function to load an image given
* a URL.
*/
imageLoadFunction?: import("../Image.js").LoadFunction | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* ArcGIS Rest parameters. This field is optional. Service
* defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
* `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
* will be set dynamically. Set `LAYERS` to override the default service layer visibility. See
* https://developers.arcgis.com/rest/services-reference/export-map.htm
* for further reference.
*/
params?: {
[x: string]: any;
} | undefined;
/**
* Projection. Default is the view projection.
* The projection code must contain a numeric end portion separated by :
* or the entire code must form a valid ArcGIS SpatialReference definition.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Ratio. `1` means image requests are the size of the map viewport,
* `2` means twice the size of the map viewport, and so on.
*/
ratio?: number | undefined;
/**
* Resolutions. If specified, requests will be made for
* these resolutions only.
*/
resolutions?: number[] | undefined;
/**
* ArcGIS Rest service URL for a Map Service or Image Service. The url
* should include /MapServer or /ImageServer.
*/
url?: string | undefined;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting the image from
* the remote server.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given
* a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service
* defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
* `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
* will be set dynamically. Set `LAYERS` to override the default service layer visibility. See
* https://developers.arcgis.com/rest/services-reference/export-map.htm
* for further reference.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* The projection code must contain a numeric end portion separated by :
* or the entire code must form a valid ArcGIS SpatialReference definition.
* @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport,
* `2` means twice the size of the map viewport, and so on.
* @property {Array<number>} [resolutions] Resolutions. If specified, requests will be made for
* these resolutions only.
* @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The url
* should include /MapServer or /ImageServer.
*/
/**
* @classdesc
* Source for data from ArcGIS Rest services providing single, untiled images.
* Useful when underlying map service has labels.
*
* If underlying map service is not using labels,
* take advantage of ol image caching and use
* {@link module:ol/source/TileArcGISRest~TileArcGISRest} data source.
*
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
declare class ImageArcGISRest extends ImageSource {
/**
* @param {Options} [opt_options] Image ArcGIS Rest Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {?string}
*/
private crossOrigin_;
/**
* @private
* @type {boolean}
*/
private hidpi_;
/**
* @private
* @type {string|undefined}
*/
private url_;
/**
* @private
* @type {import("../Image.js").LoadFunction}
*/
private imageLoadFunction_;
/**
* @private
* @type {!Object}
*/
private params_;
/**
* @private
* @type {import("../Image.js").default}
*/
private image_;
/**
* @private
* @type {import("../size.js").Size}
*/
private imageSize_;
/**
* @private
* @type {number}
*/
private renderedRevision_;
/**
* @private
* @type {number}
*/
private ratio_;
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
getParams(): any;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../Image.js").default;
/**
* Return the image load function of the source.
* @return {import("../Image.js").LoadFunction} The image load function.
* @api
*/
getImageLoadFunction(): import("../Image.js").LoadFunction;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../size.js").Size} size Size.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string} Request URL.
* @private
*/
private getRequestUrl_;
/**
* Return the URL used for this ArcGIS source.
* @return {string|undefined} URL.
* @api
*/
getUrl(): string | undefined;
/**
* Set the image load function of the source.
* @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
* @api
*/
setImageLoadFunction(imageLoadFunction: import("../Image.js").LoadFunction): void;
/**
* Set the URL to use for requests.
* @param {string|undefined} url URL.
* @api
*/
setUrl(url: string | undefined): void;
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
updateParams(params: any): void;
}
import ImageSource from "./Image.js";
//# sourceMappingURL=ImageArcGISRest.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageArcGISRest.d.ts","sourceRoot":"","sources":["../src/source/ImageArcGISRest.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+Bc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;AAnBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;;;;;;;;GAWG;AACH;IACE;;OAEG;IACH,+CAyEC;IAzDC;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,2BAG8B;IAE9B;;;OAGG;IACH,gBAAmC;IAEnC;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,mBAAwB;IAExB;;;OAGG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,eAA+D;IAGjE;;;;;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,CAgFxC;IAED;;;;OAIG;IACH,wBAHY,OAAO,aAAa,EAAE,YAAY,CAK7C;IAED;;;;;;;;OAQG;IACH,uBAwBC;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,gCAIC;CACF"}
+282
View File
@@ -0,0 +1,282 @@
/**
* @module ol/source/ImageArcGISRest
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import EventType from '../events/EventType.js';
import ImageSource, { defaultImageLoadFunction } from './Image.js';
import ImageWrapper from '../Image.js';
import { appendParams } from '../uri.js';
import { assert } from '../asserts.js';
import { assign } from '../obj.js';
import { containsExtent, getHeight, getWidth } from '../extent.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting the image from
* the remote server.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given
* a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service
* defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
* `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
* will be set dynamically. Set `LAYERS` to override the default service layer visibility. See
* https://developers.arcgis.com/rest/services-reference/export-map.htm
* for further reference.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* The projection code must contain a numeric end portion separated by :
* or the entire code must form a valid ArcGIS SpatialReference definition.
* @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport,
* `2` means twice the size of the map viewport, and so on.
* @property {Array<number>} [resolutions] Resolutions. If specified, requests will be made for
* these resolutions only.
* @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The url
* should include /MapServer or /ImageServer.
*/
/**
* @classdesc
* Source for data from ArcGIS Rest services providing single, untiled images.
* Useful when underlying map service has labels.
*
* If underlying map service is not using labels,
* take advantage of ol image caching and use
* {@link module:ol/source/TileArcGISRest~TileArcGISRest} data source.
*
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
var ImageArcGISRest = /** @class */ (function (_super) {
__extends(ImageArcGISRest, _super);
/**
* @param {Options} [opt_options] Image ArcGIS Rest Options.
*/
function ImageArcGISRest(opt_options) {
var _this = this;
var options = opt_options ? opt_options : {};
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
interpolate: interpolate,
projection: options.projection,
resolutions: options.resolutions,
}) || this;
/**
* @private
* @type {?string}
*/
_this.crossOrigin_ =
options.crossOrigin !== undefined ? options.crossOrigin : null;
/**
* @private
* @type {boolean}
*/
_this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
/**
* @private
* @type {string|undefined}
*/
_this.url_ = options.url;
/**
* @private
* @type {import("../Image.js").LoadFunction}
*/
_this.imageLoadFunction_ =
options.imageLoadFunction !== undefined
? options.imageLoadFunction
: defaultImageLoadFunction;
/**
* @private
* @type {!Object}
*/
_this.params_ = options.params || {};
/**
* @private
* @type {import("../Image.js").default}
*/
_this.image_ = null;
/**
* @private
* @type {import("../size.js").Size}
*/
_this.imageSize_ = [0, 0];
/**
* @private
* @type {number}
*/
_this.renderedRevision_ = 0;
/**
* @private
* @type {number}
*/
_this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
return _this;
}
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
ImageArcGISRest.prototype.getParams = function () {
return this.params_;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
ImageArcGISRest.prototype.getImageInternal = function (extent, resolution, pixelRatio, projection) {
if (this.url_ === undefined) {
return null;
}
resolution = this.findNearestResolution(resolution);
pixelRatio = this.hidpi_ ? pixelRatio : 1;
var image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
containsExtent(image.getExtent(), extent)) {
return image;
}
var params = {
'F': 'image',
'FORMAT': 'PNG32',
'TRANSPARENT': true,
};
assign(params, this.params_);
extent = extent.slice();
var centerX = (extent[0] + extent[2]) / 2;
var centerY = (extent[1] + extent[3]) / 2;
if (this.ratio_ != 1) {
var halfWidth = (this.ratio_ * getWidth(extent)) / 2;
var halfHeight = (this.ratio_ * getHeight(extent)) / 2;
extent[0] = centerX - halfWidth;
extent[1] = centerY - halfHeight;
extent[2] = centerX + halfWidth;
extent[3] = centerY + halfHeight;
}
var imageResolution = resolution / pixelRatio;
// Compute an integer width and height.
var width = Math.ceil(getWidth(extent) / imageResolution);
var height = Math.ceil(getHeight(extent) / imageResolution);
// Modify the extent to match the integer width and height.
extent[0] = centerX - (imageResolution * width) / 2;
extent[2] = centerX + (imageResolution * width) / 2;
extent[1] = centerY - (imageResolution * height) / 2;
extent[3] = centerY + (imageResolution * height) / 2;
this.imageSize_[0] = width;
this.imageSize_[1] = height;
var url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio, projection, params);
this.image_ = new ImageWrapper(extent, resolution, pixelRatio, url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();
this.image_.addEventListener(EventType.CHANGE, this.handleImageChange.bind(this));
return this.image_;
};
/**
* Return the image load function of the source.
* @return {import("../Image.js").LoadFunction} The image load function.
* @api
*/
ImageArcGISRest.prototype.getImageLoadFunction = function () {
return this.imageLoadFunction_;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../size.js").Size} size Size.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string} Request URL.
* @private
*/
ImageArcGISRest.prototype.getRequestUrl_ = function (extent, size, pixelRatio, projection, params) {
// ArcGIS Server only wants the numeric portion of the projection ID.
// (if there is no numeric portion the entire projection code must
// form a valid ArcGIS SpatialReference definition).
var srid = projection
.getCode()
.split(/:(?=\d+$)/)
.pop();
params['SIZE'] = size[0] + ',' + size[1];
params['BBOX'] = extent.join(',');
params['BBOXSR'] = srid;
params['IMAGESR'] = srid;
params['DPI'] = Math.round(90 * pixelRatio);
var url = this.url_;
var modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
if (modifiedUrl == url) {
assert(false, 50); // `options.featureTypes` should be an Array
}
return appendParams(modifiedUrl, params);
};
/**
* Return the URL used for this ArcGIS source.
* @return {string|undefined} URL.
* @api
*/
ImageArcGISRest.prototype.getUrl = function () {
return this.url_;
};
/**
* Set the image load function of the source.
* @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
* @api
*/
ImageArcGISRest.prototype.setImageLoadFunction = function (imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
};
/**
* Set the URL to use for requests.
* @param {string|undefined} url URL.
* @api
*/
ImageArcGISRest.prototype.setUrl = function (url) {
if (url != this.url_) {
this.url_ = url;
this.image_ = null;
this.changed();
}
};
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
ImageArcGISRest.prototype.updateParams = function (params) {
assign(this.params_, params);
this.image_ = null;
this.changed();
};
return ImageArcGISRest;
}(ImageSource));
export default ImageArcGISRest;
//# sourceMappingURL=ImageArcGISRest.js.map
File diff suppressed because one or more lines are too long
+131
View File
@@ -0,0 +1,131 @@
export default ImageCanvasSource;
/**
* A function returning the canvas element (`{HTMLCanvasElement}`)
* used by the source as an image. The arguments passed to the function are:
* {@link module :ol/extent~Extent} the image extent, `{number}` the image resolution,
* `{number}` the pixel ratio of the map, {@link module :ol/size~Size} the image size,
* and {@link module :ol/proj/Projection~Projection} the image projection. The canvas returned by
* this function is cached by the source. The this keyword inside the function
* references the {@link module :ol/source/ImageCanvas~ImageCanvasSource}.
*/
export type FunctionType = (this: import("../ImageCanvas.js").default, arg1: import("../extent.js").Extent, arg2: number, arg3: number, arg4: import("../size.js").Size, arg5: import("../proj/Projection.js").default) => HTMLCanvasElement;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Canvas function.
* The function returning the canvas element used by the source
* as an image. The arguments passed to the function are: {@link import ("../extent.js").Extent} the
* image extent, `{number}` the image resolution, `{number}` the pixel ratio of the map,
* {@link import ("../size.js").Size} the image size, and {@link import ("../proj/Projection.js").default} the image
* projection. The canvas returned by this function is cached by the source. If
* the value returned by the function is later changed then
* `changed` should be called on the source for the source to
* invalidate the current cached image. See: {@link module :ol/Observable~Observable#changed}
*/
canvasFunction?: FunctionType | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
* width and height of the map viewport, and so on. Must be `1` or higher.
*/
ratio?: number | undefined;
/**
* Resolutions.
* If specified, new canvases will be created for these resolutions
*/
resolutions?: number[] | undefined;
/**
* Source state.
*/
state?: import("./Source.js").State | undefined;
};
/**
* A function returning the canvas element (`{HTMLCanvasElement}`)
* used by the source as an image. The arguments passed to the function are:
* {@link module:ol/extent~Extent} the image extent, `{number}` the image resolution,
* `{number}` the pixel ratio of the map, {@link module:ol/size~Size} the image size,
* and {@link module:ol/proj/Projection~Projection} the image projection. The canvas returned by
* this function is cached by the source. The this keyword inside the function
* references the {@link module:ol/source/ImageCanvas~ImageCanvasSource}.
*
* @typedef {function(this:import("../ImageCanvas.js").default, import("../extent.js").Extent, number,
* number, import("../size.js").Size, import("../proj/Projection.js").default): HTMLCanvasElement} FunctionType
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {FunctionType} [canvasFunction] Canvas function.
* The function returning the canvas element used by the source
* as an image. The arguments passed to the function are: {@link import("../extent.js").Extent} the
* image extent, `{number}` the image resolution, `{number}` the pixel ratio of the map,
* {@link import("../size.js").Size} the image size, and {@link import("../proj/Projection.js").default} the image
* projection. The canvas returned by this function is cached by the source. If
* the value returned by the function is later changed then
* `changed` should be called on the source for the source to
* invalidate the current cached image. See: {@link module:ol/Observable~Observable#changed}
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1.5] Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
* width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array<number>} [resolutions] Resolutions.
* If specified, new canvases will be created for these resolutions
* @property {import("./Source.js").State} [state] Source state.
*/
/**
* @classdesc
* Base class for image sources where a canvas element is the image.
* @api
*/
declare class ImageCanvasSource extends ImageSource {
/**
* @param {Options} [opt_options] ImageCanvas options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {FunctionType}
*/
private canvasFunction_;
/**
* @private
* @type {import("../ImageCanvas.js").default}
*/
private canvas_;
/**
* @private
* @type {number}
*/
private renderedRevision_;
/**
* @private
* @type {number}
*/
private ratio_;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageCanvas.js").default} Single image.
*/
getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../ImageCanvas.js").default;
}
import ImageSource from "./Image.js";
//# sourceMappingURL=ImageCanvas.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageCanvas.d.ts","sourceRoot":"","sources":["../src/source/ImageCanvas.js"],"names":[],"mappings":";;;;;;;;;;kCAsB2B,OAAO,mBAAmB,EAAE,OAAO,QAAE,OAAO,cAAc,EAAE,MAAM,QAAE,MAAM,QACpG,MAAY,QAAE,OAAO,YAAY,EAAE,IAAI,QAAE,OAAO,uBAAuB,EAAE,OAAO,KAAG,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkBvF,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;AA5BjD;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,+CAwCC;IAvBC;;;OAGG;IACH,wBAA6C;IAE7C;;;OAGG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,eAA+D;IAGjE;;;;;;OAMG;IACH,yBANW,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACtC,OAAO,mBAAmB,EAAE,OAAO,CAqC9C;CACF"}
+135
View File
@@ -0,0 +1,135 @@
/**
* @module ol/source/ImageCanvas
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import ImageCanvas from '../ImageCanvas.js';
import ImageSource from './Image.js';
import { containsExtent, getHeight, getWidth, scaleFromCenter, } from '../extent.js';
/**
* A function returning the canvas element (`{HTMLCanvasElement}`)
* used by the source as an image. The arguments passed to the function are:
* {@link module:ol/extent~Extent} the image extent, `{number}` the image resolution,
* `{number}` the pixel ratio of the map, {@link module:ol/size~Size} the image size,
* and {@link module:ol/proj/Projection~Projection} the image projection. The canvas returned by
* this function is cached by the source. The this keyword inside the function
* references the {@link module:ol/source/ImageCanvas~ImageCanvasSource}.
*
* @typedef {function(this:import("../ImageCanvas.js").default, import("../extent.js").Extent, number,
* number, import("../size.js").Size, import("../proj/Projection.js").default): HTMLCanvasElement} FunctionType
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {FunctionType} [canvasFunction] Canvas function.
* The function returning the canvas element used by the source
* as an image. The arguments passed to the function are: {@link import("../extent.js").Extent} the
* image extent, `{number}` the image resolution, `{number}` the pixel ratio of the map,
* {@link import("../size.js").Size} the image size, and {@link import("../proj/Projection.js").default} the image
* projection. The canvas returned by this function is cached by the source. If
* the value returned by the function is later changed then
* `changed` should be called on the source for the source to
* invalidate the current cached image. See: {@link module:ol/Observable~Observable#changed}
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1.5] Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
* width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array<number>} [resolutions] Resolutions.
* If specified, new canvases will be created for these resolutions
* @property {import("./Source.js").State} [state] Source state.
*/
/**
* @classdesc
* Base class for image sources where a canvas element is the image.
* @api
*/
var ImageCanvasSource = /** @class */ (function (_super) {
__extends(ImageCanvasSource, _super);
/**
* @param {Options} [opt_options] ImageCanvas options.
*/
function ImageCanvasSource(opt_options) {
var _this = this;
var options = opt_options ? opt_options : {};
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
interpolate: interpolate,
projection: options.projection,
resolutions: options.resolutions,
state: options.state,
}) || this;
/**
* @private
* @type {FunctionType}
*/
_this.canvasFunction_ = options.canvasFunction;
/**
* @private
* @type {import("../ImageCanvas.js").default}
*/
_this.canvas_ = null;
/**
* @private
* @type {number}
*/
_this.renderedRevision_ = 0;
/**
* @private
* @type {number}
*/
_this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
return _this;
}
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageCanvas.js").default} Single image.
*/
ImageCanvasSource.prototype.getImageInternal = function (extent, resolution, pixelRatio, projection) {
resolution = this.findNearestResolution(resolution);
var canvas = this.canvas_;
if (canvas &&
this.renderedRevision_ == this.getRevision() &&
canvas.getResolution() == resolution &&
canvas.getPixelRatio() == pixelRatio &&
containsExtent(canvas.getExtent(), extent)) {
return canvas;
}
extent = extent.slice();
scaleFromCenter(extent, this.ratio_);
var width = getWidth(extent) / resolution;
var height = getHeight(extent) / resolution;
var size = [width * pixelRatio, height * pixelRatio];
var canvasElement = this.canvasFunction_.call(this, extent, resolution, pixelRatio, size, projection);
if (canvasElement) {
canvas = new ImageCanvas(extent, resolution, pixelRatio, canvasElement);
}
this.canvas_ = canvas;
this.renderedRevision_ = this.getRevision();
return canvas;
};
return ImageCanvasSource;
}(ImageSource));
export default ImageCanvasSource;
//# sourceMappingURL=ImageCanvas.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageCanvas.js","sourceRoot":"","sources":["../src/source/ImageCanvas.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,WAAW,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;GAIG;AACH;IAAgC,qCAAW;IACzC;;OAEG;IACH,2BAAY,WAAW;QAAvB,iBAwCC;QAvCC,IAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,WA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f;QAED,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QACxB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,IAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;QAC5C,IAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;QAC9C,IAAM,IAAI,GAAG,CAAC,KAAK,GAAG,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;QAEvD,IAAM,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAC7C,IAAI,EACJ,MAAM,EACN,UAAU,EACV,UAAU,EACV,IAAI,EACJ,UAAU,CACX,CAAC;QACF,IAAI,aAAa,EAAE;YACjB,MAAM,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;SACzE;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAE5C,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,wBAAC;AAAD,CAAC,AAzFD,CAAgC,WAAW,GAyF1C;AAED,eAAe,iBAAiB,CAAC"}
+197
View File
@@ -0,0 +1,197 @@
export default ImageMapGuide;
export type Options = {
/**
* The mapagent url.
*/
url?: string | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* The display resolution.
*/
displayDpi?: number | undefined;
/**
* The meters-per-unit value.
*/
metersPerUnit?: number | undefined;
/**
* Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
*/
hidpi?: boolean | undefined;
/**
* If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
*/
useOverlay?: boolean | undefined;
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or higher.
*/
ratio?: number | undefined;
/**
* Resolutions.
* If specified, requests will be made for these resolutions only.
*/
resolutions?: number[] | undefined;
/**
* Optional function to load an image given a URL.
*/
imageLoadFunction?: import("../Image.js").LoadFunction | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Additional parameters.
*/
params?: any;
};
/**
* @typedef {Object} Options
* @property {string} [url] The mapagent url.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {number} [displayDpi=96] The display resolution.
* @property {number} [metersPerUnit=1] The meters-per-unit value.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {boolean} [useOverlay] If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1] Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array<number>} [resolutions] Resolutions.
* If specified, requests will be made for these resolutions only.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object} [params] Additional parameters.
*/
/**
* @classdesc
* Source for images from Mapguide servers
*
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
declare class ImageMapGuide extends ImageSource {
/**
* @param {Options} options ImageMapGuide options.
*/
constructor(options: Options);
/**
* @private
* @type {?string}
*/
private crossOrigin_;
/**
* @private
* @type {number}
*/
private displayDpi_;
/**
* @private
* @type {!Object}
*/
private params_;
/**
* @private
* @type {string|undefined}
*/
private url_;
/**
* @private
* @type {import("../Image.js").LoadFunction}
*/
private imageLoadFunction_;
/**
* @private
* @type {boolean}
*/
private hidpi_;
/**
* @private
* @type {number}
*/
private metersPerUnit_;
/**
* @private
* @type {number}
*/
private ratio_;
/**
* @private
* @type {boolean}
*/
private useOverlay_;
/**
* @private
* @type {import("../Image.js").default}
*/
private image_;
/**
* @private
* @type {number}
*/
private renderedRevision_;
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
getParams(): any;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../Image.js").default;
/**
* Return the image load function of the source.
* @return {import("../Image.js").LoadFunction} The image load function.
* @api
*/
getImageLoadFunction(): import("../Image.js").LoadFunction;
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
updateParams(params: any): void;
/**
* @param {string} baseUrl The mapagent url.
* @param {Object<string, string|number>} params Request parameters.
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../size.js").Size} size Size.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {string} The mapagent map image request URL.
*/
getUrl(baseUrl: string, params: {
[x: string]: string | number;
}, extent: import("../extent.js").Extent, size: import("../size.js").Size, projection: import("../proj/Projection.js").default): string;
/**
* Set the image load function of the MapGuide source.
* @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
* @api
*/
setImageLoadFunction(imageLoadFunction: import("../Image.js").LoadFunction): void;
}
import ImageSource from "./Image.js";
//# sourceMappingURL=ImageMapGuide.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageMapGuide.d.ts","sourceRoot":"","sources":["../src/source/ImageMapGuide.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Bc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAXjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAuFjB;IAxEC;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,oBAC4D;IAE5D;;;OAGG;IACH,gBAAmC;IAEnC;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,2BAG8B;IAE9B;;;OAGG;IACH,eAAgE;IAEhE;;;OAGG;IACH,uBACiE;IAEjE;;;OAGG;IACH,eAA6D;IAE7D;;;OAGG;IACH,oBAC+D;IAE/D;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,0BAA0B;IAG5B;;;;;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,CAoDxC;IAED;;;;OAIG;IACH,wBAHY,OAAO,aAAa,EAAE,YAAY,CAK7C;IAED;;;;OAIG;IACH,gCAGC;IAED;;;;;;;OAOG;IACH,gBAPW,MAAM;YACC,MAAM,GAAE,MAAM,GAAC,MAAM;eAC5B,OAAO,cAAc,EAAE,MAAM,QAC7B,OAAO,YAAY,EAAE,IAAI,cACzB,OAAO,uBAAuB,EAAE,OAAO,GACtC,MAAM,CAsBjB;IAED;;;;OAIG;IACH,wCAHW,OAAO,aAAa,EAAE,YAAY,QAO5C;CACF"}
+259
View File
@@ -0,0 +1,259 @@
/**
* @module ol/source/ImageMapGuide
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import EventType from '../events/EventType.js';
import ImageSource, { defaultImageLoadFunction } from './Image.js';
import ImageWrapper from '../Image.js';
import { appendParams } from '../uri.js';
import { assign } from '../obj.js';
import { containsExtent, getCenter, getHeight, getWidth, scaleFromCenter, } from '../extent.js';
/**
* @typedef {Object} Options
* @property {string} [url] The mapagent url.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {number} [displayDpi=96] The display resolution.
* @property {number} [metersPerUnit=1] The meters-per-unit value.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {boolean} [useOverlay] If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1] Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array<number>} [resolutions] Resolutions.
* If specified, requests will be made for these resolutions only.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object} [params] Additional parameters.
*/
/**
* @classdesc
* Source for images from Mapguide servers
*
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
var ImageMapGuide = /** @class */ (function (_super) {
__extends(ImageMapGuide, _super);
/**
* @param {Options} options ImageMapGuide options.
*/
function ImageMapGuide(options) {
var _this = this;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
interpolate: interpolate,
projection: options.projection,
resolutions: options.resolutions,
}) || this;
/**
* @private
* @type {?string}
*/
_this.crossOrigin_ =
options.crossOrigin !== undefined ? options.crossOrigin : null;
/**
* @private
* @type {number}
*/
_this.displayDpi_ =
options.displayDpi !== undefined ? options.displayDpi : 96;
/**
* @private
* @type {!Object}
*/
_this.params_ = options.params || {};
/**
* @private
* @type {string|undefined}
*/
_this.url_ = options.url;
/**
* @private
* @type {import("../Image.js").LoadFunction}
*/
_this.imageLoadFunction_ =
options.imageLoadFunction !== undefined
? options.imageLoadFunction
: defaultImageLoadFunction;
/**
* @private
* @type {boolean}
*/
_this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
/**
* @private
* @type {number}
*/
_this.metersPerUnit_ =
options.metersPerUnit !== undefined ? options.metersPerUnit : 1;
/**
* @private
* @type {number}
*/
_this.ratio_ = options.ratio !== undefined ? options.ratio : 1;
/**
* @private
* @type {boolean}
*/
_this.useOverlay_ =
options.useOverlay !== undefined ? options.useOverlay : false;
/**
* @private
* @type {import("../Image.js").default}
*/
_this.image_ = null;
/**
* @private
* @type {number}
*/
_this.renderedRevision_ = 0;
return _this;
}
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
ImageMapGuide.prototype.getParams = function () {
return this.params_;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
ImageMapGuide.prototype.getImageInternal = function (extent, resolution, pixelRatio, projection) {
resolution = this.findNearestResolution(resolution);
pixelRatio = this.hidpi_ ? pixelRatio : 1;
var image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
containsExtent(image.getExtent(), extent)) {
return image;
}
if (this.ratio_ != 1) {
extent = extent.slice();
scaleFromCenter(extent, this.ratio_);
}
var width = getWidth(extent) / resolution;
var height = getHeight(extent) / resolution;
var size = [width * pixelRatio, height * pixelRatio];
if (this.url_ !== undefined) {
var imageUrl = this.getUrl(this.url_, this.params_, extent, size, projection);
image = new ImageWrapper(extent, resolution, pixelRatio, imageUrl, this.crossOrigin_, this.imageLoadFunction_);
image.addEventListener(EventType.CHANGE, this.handleImageChange.bind(this));
}
else {
image = null;
}
this.image_ = image;
this.renderedRevision_ = this.getRevision();
return image;
};
/**
* Return the image load function of the source.
* @return {import("../Image.js").LoadFunction} The image load function.
* @api
*/
ImageMapGuide.prototype.getImageLoadFunction = function () {
return this.imageLoadFunction_;
};
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
ImageMapGuide.prototype.updateParams = function (params) {
assign(this.params_, params);
this.changed();
};
/**
* @param {string} baseUrl The mapagent url.
* @param {Object<string, string|number>} params Request parameters.
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../size.js").Size} size Size.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {string} The mapagent map image request URL.
*/
ImageMapGuide.prototype.getUrl = function (baseUrl, params, extent, size, projection) {
var scale = getScale(extent, size, this.metersPerUnit_, this.displayDpi_);
var center = getCenter(extent);
var baseParams = {
'OPERATION': this.useOverlay_
? 'GETDYNAMICMAPOVERLAYIMAGE'
: 'GETMAPIMAGE',
'VERSION': '2.0.0',
'LOCALE': 'en',
'CLIENTAGENT': 'ol/source/ImageMapGuide source',
'CLIP': '1',
'SETDISPLAYDPI': this.displayDpi_,
'SETDISPLAYWIDTH': Math.round(size[0]),
'SETDISPLAYHEIGHT': Math.round(size[1]),
'SETVIEWSCALE': scale,
'SETVIEWCENTERX': center[0],
'SETVIEWCENTERY': center[1],
};
assign(baseParams, params);
return appendParams(baseUrl, baseParams);
};
/**
* Set the image load function of the MapGuide source.
* @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
* @api
*/
ImageMapGuide.prototype.setImageLoadFunction = function (imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
};
return ImageMapGuide;
}(ImageSource));
/**
* @param {import("../extent.js").Extent} extent The map extents.
* @param {import("../size.js").Size} size The viewport size.
* @param {number} metersPerUnit The meters-per-unit value.
* @param {number} dpi The display resolution.
* @return {number} The computed map scale.
*/
function getScale(extent, size, metersPerUnit, dpi) {
var mcsW = getWidth(extent);
var mcsH = getHeight(extent);
var devW = size[0];
var devH = size[1];
var mpp = 0.0254 / dpi;
if (devH * mcsW > devW * mcsH) {
return (mcsW * metersPerUnit) / (devW * mpp); // width limited
}
else {
return (mcsH * metersPerUnit) / (devH * mpp); // height limited
}
}
export default ImageMapGuide;
//# sourceMappingURL=ImageMapGuide.js.map
+1
View File
File diff suppressed because one or more lines are too long
+114
View File
@@ -0,0 +1,114 @@
export default Static;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Extent of the image in map coordinates.
* This is the [left, bottom, right, top] map coordinates of your image.
*/
imageExtent?: import("../extent.js").Extent | undefined;
/**
* Optional function to load an image given a URL.
*/
imageLoadFunction?: import("../Image.js").LoadFunction | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Size of the image in pixels. Usually the image size is auto-detected, so this
* only needs to be set if auto-detection fails for some reason.
*/
imageSize?: import("../size.js").Size | undefined;
/**
* Image URL.
*/
url: string;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
* This is the [left, bottom, right, top] map coordinates of your image.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {import("../size.js").Size} [imageSize] Size of the image in pixels. Usually the image size is auto-detected, so this
* only needs to be set if auto-detection fails for some reason.
* @property {string} url Image URL.
*/
/**
* @classdesc
* A layer source for displaying a single, static image.
* @api
*/
declare class Static extends ImageSource {
/**
* @param {Options} options ImageStatic options.
*/
constructor(options: Options);
/**
* @private
* @type {string}
*/
private url_;
/**
* @private
* @type {import("../extent.js").Extent}
*/
private imageExtent_;
/**
* @private
* @type {import("../Image.js").default}
*/
private image_;
/**
* @private
* @type {import("../size.js").Size|null}
*/
private imageSize_;
/**
* Returns the image extent
* @return {import("../extent.js").Extent} image extent.
* @api
*/
getImageExtent(): import("../extent.js").Extent;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../Image.js").default;
/**
* Return the URL used for this image source.
* @return {string} URL.
* @api
*/
getUrl(): string;
}
import ImageSource from "./Image.js";
//# sourceMappingURL=ImageStatic.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageStatic.d.ts","sourceRoot":"","sources":["../src/source/ImageStatic.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0Bc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;SAGnC,MAAM;;AAfpB;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EA0DjB;IAnCC;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,qBAAuC;IAEvC;;;OAGG;IACH,eAOC;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"}
+165
View File
@@ -0,0 +1,165 @@
/**
* @module ol/source/ImageStatic
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import EventType from '../events/EventType.js';
import ImageSource, { defaultImageLoadFunction } from './Image.js';
import ImageState from '../ImageState.js';
import ImageWrapper from '../Image.js';
import { IMAGE_SMOOTHING_DISABLED } from '../renderer/canvas/common.js';
import { assign } from '../obj.js';
import { createCanvasContext2D } from '../dom.js';
import { getHeight, getWidth, intersects } from '../extent.js';
import { get as getProjection } from '../proj.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
* This is the [left, bottom, right, top] map coordinates of your image.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {import("../size.js").Size} [imageSize] Size of the image in pixels. Usually the image size is auto-detected, so this
* only needs to be set if auto-detection fails for some reason.
* @property {string} url Image URL.
*/
/**
* @classdesc
* A layer source for displaying a single, static image.
* @api
*/
var Static = /** @class */ (function (_super) {
__extends(Static, _super);
/**
* @param {Options} options ImageStatic options.
*/
function Static(options) {
var _this = this;
var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : null;
var /** @type {import("../Image.js").LoadFunction} */ imageLoadFunction = options.imageLoadFunction !== undefined
? options.imageLoadFunction
: defaultImageLoadFunction;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
interpolate: interpolate,
projection: getProjection(options.projection),
}) || this;
/**
* @private
* @type {string}
*/
_this.url_ = options.url;
/**
* @private
* @type {import("../extent.js").Extent}
*/
_this.imageExtent_ = options.imageExtent;
/**
* @private
* @type {import("../Image.js").default}
*/
_this.image_ = new ImageWrapper(_this.imageExtent_, undefined, 1, _this.url_, crossOrigin, imageLoadFunction);
/**
* @private
* @type {import("../size.js").Size|null}
*/
_this.imageSize_ = options.imageSize ? options.imageSize : null;
_this.image_.addEventListener(EventType.CHANGE, _this.handleImageChange.bind(_this));
return _this;
}
/**
* Returns the image extent
* @return {import("../extent.js").Extent} image extent.
* @api
*/
Static.prototype.getImageExtent = function () {
return this.imageExtent_;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
Static.prototype.getImageInternal = function (extent, resolution, pixelRatio, projection) {
if (intersects(extent, this.image_.getExtent())) {
return this.image_;
}
return null;
};
/**
* Return the URL used for this image source.
* @return {string} URL.
* @api
*/
Static.prototype.getUrl = function () {
return this.url_;
};
/**
* @param {import("../events/Event.js").default} evt Event.
*/
Static.prototype.handleImageChange = function (evt) {
if (this.image_.getState() == ImageState.LOADED) {
var imageExtent = this.image_.getExtent();
var image = this.image_.getImage();
var imageWidth = void 0, imageHeight = void 0;
if (this.imageSize_) {
imageWidth = this.imageSize_[0];
imageHeight = this.imageSize_[1];
}
else {
imageWidth = image.width;
imageHeight = image.height;
}
var extentWidth = getWidth(imageExtent);
var extentHeight = getHeight(imageExtent);
var xResolution = extentWidth / imageWidth;
var yResolution = extentHeight / imageHeight;
var targetWidth = imageWidth;
var targetHeight = imageHeight;
if (xResolution > yResolution) {
targetWidth = Math.round(extentWidth / yResolution);
}
else {
targetHeight = Math.round(extentHeight / xResolution);
}
if (targetWidth !== imageWidth || targetHeight !== imageHeight) {
var context = createCanvasContext2D(targetWidth, targetHeight);
if (!this.getInterpolate()) {
assign(context, IMAGE_SMOOTHING_DISABLED);
}
var canvas = context.canvas;
context.drawImage(image, 0, 0, imageWidth, imageHeight, 0, 0, canvas.width, canvas.height);
this.image_.setImage(canvas);
}
}
_super.prototype.handleImageChange.call(this, evt);
};
return Static;
}(ImageSource));
export default Static;
//# sourceMappingURL=ImageStatic.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageStatic.js","sourceRoot":"","sources":["../src/source/ImageStatic.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,WAAW,EAAE,EAAC,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACjE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,GAAG,IAAI,aAAa,EAAC,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH;IAAqB,0BAAW;IAC9B;;OAEG;IACH,gBAAY,OAAO;QAAnB,iBAwDC;QAvDC,IAAM,WAAW,GACf,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;QAEjE,IAAM,iDAAiD,CAAC,iBAAiB,GACrE,OAAO,CAAC,iBAAiB,KAAK,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,iBAAiB;YAC3B,CAAC,CAAC,wBAAwB,CAAC;QAEjC,IAAI,WAAW,GACb,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,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AAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE;oBAC1B,MAAM,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC;iBAC3C;gBACD,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC9B,OAAO,CAAC,SAAS,CACf,KAAK,EACL,CAAC,EACD,CAAC,EACD,UAAU,EACV,WAAW,EACX,CAAC,EACD,CAAC,EACD,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,MAAM,CACd,CAAC;gBACF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;aAC9B;SACF;QACD,iBAAM,iBAAiB,YAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IACH,aAAC;AAAD,CAAC,AA9ID,CAAqB,WAAW,GA8I/B;AAED,eAAe,MAAM,CAAC"}
+251
View File
@@ -0,0 +1,251 @@
export default ImageWMS;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
*/
hidpi?: boolean | undefined;
/**
* The type of
* the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
* Only needed if `hidpi` is `true`.
*/
serverType?: import("./wms.js").ServerType | undefined;
/**
* Optional function to load an image given a URL.
*/
imageLoadFunction?: import("../Image.js").LoadFunction | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* WMS request parameters.
* At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
* and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
*/
params: {
[x: string]: any;
};
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or
* higher.
*/
ratio?: number | undefined;
/**
* Resolutions.
* If specified, requests will be made for these resolutions only.
*/
resolutions?: number[] | undefined;
/**
* WMS service URL.
*/
url: string;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("./wms.js").ServerType} [serverType] The type of
* the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
* Only needed if `hidpi` is `true`.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} params WMS request parameters.
* At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
* and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or
* higher.
* @property {Array<number>} [resolutions] Resolutions.
* If specified, requests will be made for these resolutions only.
* @property {string} url WMS service URL.
*/
/**
* @classdesc
* Source for WMS servers providing single, untiled images.
*
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
declare class ImageWMS extends ImageSource {
/**
* @param {Options} [opt_options] ImageWMS options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {?string}
*/
private crossOrigin_;
/**
* @private
* @type {string|undefined}
*/
private url_;
/**
* @private
* @type {import("../Image.js").LoadFunction}
*/
private imageLoadFunction_;
/**
* @private
* @type {!Object}
*/
private params_;
/**
* @private
* @type {boolean}
*/
private v13_;
/**
* @private
* @type {import("./wms.js").ServerType}
*/
private serverType_;
/**
* @private
* @type {boolean}
*/
private hidpi_;
/**
* @private
* @type {import("../Image.js").default}
*/
private image_;
/**
* @private
* @type {import("../size.js").Size}
*/
private imageSize_;
/**
* @private
* @type {number}
*/
private renderedRevision_;
/**
* @private
* @type {number}
*/
private ratio_;
/**
* Return the GetFeatureInfo URL for the passed coordinate, resolution, and
* projection. Return `undefined` if the GetFeatureInfo URL cannot be
* constructed.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
* be provided. If `QUERY_LAYERS` is not provided then the layers specified
* in the `LAYERS` parameter will be used. `VERSION` should not be
* specified here.
* @return {string|undefined} GetFeatureInfo URL.
* @api
*/
getFeatureInfoUrl(coordinate: import("../coordinate.js").Coordinate, resolution: number, projection: import("../proj.js").ProjectionLike, params: any): string | undefined;
/**
* Return the GetLegendGraphic URL, optionally optimized for the passed
* resolution and possibly including any passed specific parameters. Returns
* `undefined` if the GetLegendGraphic URL cannot be constructed.
*
* @param {number} [resolution] Resolution. If set to undefined, `SCALE`
* will not be calculated and included in URL.
* @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the
* request is generated for this wms layer, else it will try to use the
* configured wms layer. Default `FORMAT` is `image/png`.
* `VERSION` should not be specified here.
* @return {string|undefined} GetLegendGraphic URL.
* @api
*/
getLegendUrl(resolution?: number | undefined, params?: any): string | undefined;
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
getParams(): any;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
getImageInternal(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../Image.js").default;
/**
* Return the image load function of the source.
* @return {import("../Image.js").LoadFunction} The image load function.
* @api
*/
getImageLoadFunction(): import("../Image.js").LoadFunction;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../size.js").Size} size Size.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string} Request URL.
* @private
*/
private getRequestUrl_;
/**
* Return the URL used for this WMS source.
* @return {string|undefined} URL.
* @api
*/
getUrl(): string | undefined;
/**
* Set the image load function of the source.
* @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
* @api
*/
setImageLoadFunction(imageLoadFunction: import("../Image.js").LoadFunction): void;
/**
* Set the URL to use for requests.
* @param {string|undefined} url URL.
* @api
*/
setUrl(url: string | undefined): void;
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
updateParams(params: any): void;
/**
* @private
*/
private updateV13_;
}
import ImageSource from "./Image.js";
//# sourceMappingURL=ImageWMS.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ImageWMS.d.ts","sourceRoot":"","sources":["../src/source/ImageWMS.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkDqB,MAAM;;;;;iBAIb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;SAMnC,MAAM;;AAzBpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,+CAsFC;IAtEC;;;OAGG;IACH,qBACgE;IAEhE;;;OAGG;IACH,aAAuB;IAEvB;;;OAGG;IACH,2BAG8B;IAE9B;;;OAGG;IACH,gBAAmC;IAEnC;;;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,CAyFxC;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"}
+409
View File
@@ -0,0 +1,409 @@
/**
* @module ol/source/ImageWMS
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import EventType from '../events/EventType.js';
import ImageSource, { defaultImageLoadFunction } from './Image.js';
import ImageWrapper from '../Image.js';
import { DEFAULT_VERSION } from './wms.js';
import { appendParams } from '../uri.js';
import { assert } from '../asserts.js';
import { assign } from '../obj.js';
import { calculateSourceResolution } from '../reproj.js';
import { ceil, floor, round } from '../math.js';
import { compareVersions } from '../string.js';
import { containsExtent, getCenter, getForViewAndSize, getHeight, getWidth, } from '../extent.js';
import { get as getProjection, transform } from '../proj.js';
/**
* Number of decimal digits to consider in integer values when rounding.
* @type {number}
*/
var DECIMALS = 4;
/**
* @const
* @type {import("../size.js").Size}
*/
var GETFEATUREINFO_IMAGE_SIZE = [101, 101];
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("./wms.js").ServerType} [serverType] The type of
* the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
* Only needed if `hidpi` is `true`.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} params WMS request parameters.
* At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
* and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1.5] Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or
* higher.
* @property {Array<number>} [resolutions] Resolutions.
* If specified, requests will be made for these resolutions only.
* @property {string} url WMS service URL.
*/
/**
* @classdesc
* Source for WMS servers providing single, untiled images.
*
* @fires module:ol/source/Image.ImageSourceEvent
* @api
*/
var ImageWMS = /** @class */ (function (_super) {
__extends(ImageWMS, _super);
/**
* @param {Options} [opt_options] ImageWMS options.
*/
function ImageWMS(opt_options) {
var _this = this;
var options = opt_options ? opt_options : {};
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
interpolate: interpolate,
projection: options.projection,
resolutions: options.resolutions,
}) || this;
/**
* @private
* @type {?string}
*/
_this.crossOrigin_ =
options.crossOrigin !== undefined ? options.crossOrigin : null;
/**
* @private
* @type {string|undefined}
*/
_this.url_ = options.url;
/**
* @private
* @type {import("../Image.js").LoadFunction}
*/
_this.imageLoadFunction_ =
options.imageLoadFunction !== undefined
? options.imageLoadFunction
: defaultImageLoadFunction;
/**
* @private
* @type {!Object}
*/
_this.params_ = options.params || {};
/**
* @private
* @type {boolean}
*/
_this.v13_ = true;
_this.updateV13_();
/**
* @private
* @type {import("./wms.js").ServerType}
*/
_this.serverType_ = options.serverType;
/**
* @private
* @type {boolean}
*/
_this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
/**
* @private
* @type {import("../Image.js").default}
*/
_this.image_ = null;
/**
* @private
* @type {import("../size.js").Size}
*/
_this.imageSize_ = [0, 0];
/**
* @private
* @type {number}
*/
_this.renderedRevision_ = 0;
/**
* @private
* @type {number}
*/
_this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
return _this;
}
/**
* Return the GetFeatureInfo URL for the passed coordinate, resolution, and
* projection. Return `undefined` if the GetFeatureInfo URL cannot be
* constructed.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
* be provided. If `QUERY_LAYERS` is not provided then the layers specified
* in the `LAYERS` parameter will be used. `VERSION` should not be
* specified here.
* @return {string|undefined} GetFeatureInfo URL.
* @api
*/
ImageWMS.prototype.getFeatureInfoUrl = function (coordinate, resolution, projection, params) {
if (this.url_ === undefined) {
return undefined;
}
var projectionObj = getProjection(projection);
var sourceProjectionObj = this.getProjection();
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
resolution = calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution);
coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
}
var extent = getForViewAndSize(coordinate, resolution, 0, GETFEATUREINFO_IMAGE_SIZE);
var baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_VERSION,
'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png',
'TRANSPARENT': true,
'QUERY_LAYERS': this.params_['LAYERS'],
};
assign(baseParams, this.params_, params);
var x = floor((coordinate[0] - extent[0]) / resolution, DECIMALS);
var y = floor((extent[3] - coordinate[1]) / resolution, DECIMALS);
baseParams[this.v13_ ? 'I' : 'X'] = x;
baseParams[this.v13_ ? 'J' : 'Y'] = y;
return this.getRequestUrl_(extent, GETFEATUREINFO_IMAGE_SIZE, 1, sourceProjectionObj || projectionObj, baseParams);
};
/**
* Return the GetLegendGraphic URL, optionally optimized for the passed
* resolution and possibly including any passed specific parameters. Returns
* `undefined` if the GetLegendGraphic URL cannot be constructed.
*
* @param {number} [resolution] Resolution. If set to undefined, `SCALE`
* will not be calculated and included in URL.
* @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the
* request is generated for this wms layer, else it will try to use the
* configured wms layer. Default `FORMAT` is `image/png`.
* `VERSION` should not be specified here.
* @return {string|undefined} GetLegendGraphic URL.
* @api
*/
ImageWMS.prototype.getLegendUrl = function (resolution, params) {
if (this.url_ === undefined) {
return undefined;
}
var baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_VERSION,
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
};
if (params === undefined || params['LAYER'] === undefined) {
var layers = this.params_.LAYERS;
var isSingleLayer = !Array.isArray(layers) || layers.length === 1;
if (!isSingleLayer) {
return undefined;
}
baseParams['LAYER'] = layers;
}
if (resolution !== undefined) {
var mpu = this.getProjection()
? this.getProjection().getMetersPerUnit()
: 1;
var pixelSize = 0.00028;
baseParams['SCALE'] = (resolution * mpu) / pixelSize;
}
assign(baseParams, params);
return appendParams(/** @type {string} */ (this.url_), baseParams);
};
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
ImageWMS.prototype.getParams = function () {
return this.params_;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../Image.js").default} Single image.
*/
ImageWMS.prototype.getImageInternal = function (extent, resolution, pixelRatio, projection) {
if (this.url_ === undefined) {
return null;
}
resolution = this.findNearestResolution(resolution);
if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) {
pixelRatio = 1;
}
var imageResolution = resolution / pixelRatio;
var center = getCenter(extent);
var viewWidth = ceil(getWidth(extent) / imageResolution, DECIMALS);
var viewHeight = ceil(getHeight(extent) / imageResolution, DECIMALS);
var viewExtent = getForViewAndSize(center, imageResolution, 0, [
viewWidth,
viewHeight,
]);
var requestWidth = ceil((this.ratio_ * getWidth(extent)) / imageResolution, DECIMALS);
var requestHeight = ceil((this.ratio_ * getHeight(extent)) / imageResolution, DECIMALS);
var requestExtent = getForViewAndSize(center, imageResolution, 0, [
requestWidth,
requestHeight,
]);
var image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
containsExtent(image.getExtent(), viewExtent)) {
return image;
}
var params = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true,
};
assign(params, this.params_);
this.imageSize_[0] = round(getWidth(requestExtent) / imageResolution, DECIMALS);
this.imageSize_[1] = round(getHeight(requestExtent) / imageResolution, DECIMALS);
var url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio, projection, params);
this.image_ = new ImageWrapper(requestExtent, resolution, pixelRatio, url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();
this.image_.addEventListener(EventType.CHANGE, this.handleImageChange.bind(this));
return this.image_;
};
/**
* Return the image load function of the source.
* @return {import("../Image.js").LoadFunction} The image load function.
* @api
*/
ImageWMS.prototype.getImageLoadFunction = function () {
return this.imageLoadFunction_;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../size.js").Size} size Size.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string} Request URL.
* @private
*/
ImageWMS.prototype.getRequestUrl_ = function (extent, size, pixelRatio, projection, params) {
assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()`
params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
if (!('STYLES' in this.params_)) {
params['STYLES'] = '';
}
if (pixelRatio != 1) {
switch (this.serverType_) {
case 'geoserver':
var dpi = (90 * pixelRatio + 0.5) | 0;
if ('FORMAT_OPTIONS' in params) {
params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
}
else {
params['FORMAT_OPTIONS'] = 'dpi:' + dpi;
}
break;
case 'mapserver':
params['MAP_RESOLUTION'] = 90 * pixelRatio;
break;
case 'carmentaserver':
case 'qgis':
params['DPI'] = 90 * pixelRatio;
break;
default: // Unknown `serverType` configured
assert(false, 8);
break;
}
}
params['WIDTH'] = size[0];
params['HEIGHT'] = size[1];
var axisOrientation = projection.getAxisOrientation();
var bbox;
if (this.v13_ && axisOrientation.substr(0, 2) == 'ne') {
bbox = [extent[1], extent[0], extent[3], extent[2]];
}
else {
bbox = extent;
}
params['BBOX'] = bbox.join(',');
return appendParams(/** @type {string} */ (this.url_), params);
};
/**
* Return the URL used for this WMS source.
* @return {string|undefined} URL.
* @api
*/
ImageWMS.prototype.getUrl = function () {
return this.url_;
};
/**
* Set the image load function of the source.
* @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
* @api
*/
ImageWMS.prototype.setImageLoadFunction = function (imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
};
/**
* Set the URL to use for requests.
* @param {string|undefined} url URL.
* @api
*/
ImageWMS.prototype.setUrl = function (url) {
if (url != this.url_) {
this.url_ = url;
this.image_ = null;
this.changed();
}
};
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
ImageWMS.prototype.updateParams = function (params) {
assign(this.params_, params);
this.updateV13_();
this.image_ = null;
this.changed();
};
/**
* @private
*/
ImageWMS.prototype.updateV13_ = function () {
var version = this.params_['VERSION'] || DEFAULT_VERSION;
this.v13_ = compareVersions(version, '1.3') >= 0;
};
return ImageWMS;
}(ImageSource));
export default ImageWMS;
//# sourceMappingURL=ImageWMS.js.map
+1
View File
File diff suppressed because one or more lines are too long
+123
View File
@@ -0,0 +1,123 @@
export default OGCMapTile;
export type Options = {
/**
* URL to the OGC Map Tileset endpoint.
*/
url: string;
/**
* A lookup of values to use in the tile URL template. The `{tileMatrix}`
* (zoom level), `{tileRow}`, and `{tileCol}` variables in the URL will always be provided by the source.
*/
context?: any;
/**
* The content type for the tiles (e.g. "image/png"). If not provided,
* the source will try to find a link with rel="item" that uses a supported image type.
*/
mediaType?: string | undefined;
/**
* Projection. By default, the projection
* will be derived from the `crs` of the `tileMatrixSet`. You can override this by supplying
* a projection to the constructor.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Tile cache size. The default depends on the screen size. Will be ignored if too small.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(tile, src) {
* tile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
};
/**
* @typedef {Object} Options
* @property {string} url URL to the OGC Map Tileset endpoint.
* @property {Object} [context] A lookup of values to use in the tile URL template. The `{tileMatrix}`
* (zoom level), `{tileRow}`, and `{tileCol}` variables in the URL will always be provided by the source.
* @property {string} [mediaType] The content type for the tiles (e.g. "image/png"). If not provided,
* the source will try to find a link with rel="item" that uses a supported image type.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. By default, the projection
* will be derived from the `crs` of the `tileMatrixSet`. You can override this by supplying
* a projection to the constructor.
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. The default depends on the screen size. Will be ignored if too small.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(tile, src) {
* tile.getImage().src = src;
* };
* ```
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
/**
* @classdesc
* Layer source for map tiles from an [OGC API - Tiles](https://ogcapi.ogc.org/tiles/) service that provides "map" type tiles.
* The service must conform to at least the core (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core)
* and tileset (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tileset) conformance classes.
*/
declare class OGCMapTile extends TileImage {
/**
* @param {Options} options OGC map tile options.
*/
constructor(options: Options);
/**
* @param {import("./ogcTileUtil.js").TileSetInfo} tileSetInfo Tile set info.
* @private
*/
private handleTileSetInfo_;
/**
* @private
* @param {Error} error The error.
*/
private handleError_;
}
import TileImage from "./TileImage.js";
//# sourceMappingURL=OGCMapTile.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OGCMapTile.d.ts","sourceRoot":"","sources":["../src/source/OGCMapTile.js"],"names":[],"mappings":";;;;;SAQc,MAAM;;;;;;;;;;;;;;;;iBAKN,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAPjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAgCjB;IAED;;;OAGG;IACH,2BAIC;IAED;;;OAGG;IACH,qBAGC;CACF"}
+111
View File
@@ -0,0 +1,111 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/OGCMapTile
*/
import TileImage from './TileImage.js';
import { getTileSetInfo } from './ogcTileUtil.js';
/**
* @typedef {Object} Options
* @property {string} url URL to the OGC Map Tileset endpoint.
* @property {Object} [context] A lookup of values to use in the tile URL template. The `{tileMatrix}`
* (zoom level), `{tileRow}`, and `{tileCol}` variables in the URL will always be provided by the source.
* @property {string} [mediaType] The content type for the tiles (e.g. "image/png"). If not provided,
* the source will try to find a link with rel="item" that uses a supported image type.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. By default, the projection
* will be derived from the `crs` of the `tileMatrixSet`. You can override this by supplying
* a projection to the constructor.
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. The default depends on the screen size. Will be ignored if too small.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(tile, src) {
* tile.getImage().src = src;
* };
* ```
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
/**
* @classdesc
* Layer source for map tiles from an [OGC API - Tiles](https://ogcapi.ogc.org/tiles/) service that provides "map" type tiles.
* The service must conform to at least the core (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core)
* and tileset (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tileset) conformance classes.
*/
var OGCMapTile = /** @class */ (function (_super) {
__extends(OGCMapTile, _super);
/**
* @param {Options} options OGC map tile options.
*/
function OGCMapTile(options) {
var _this = this;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
interpolate: interpolate,
projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: 'loading',
tileLoadFunction: options.tileLoadFunction,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition,
}) || this;
var sourceInfo = {
url: options.url,
projection: _this.getProjection(),
mediaType: options.mediaType,
context: options.context || null,
};
getTileSetInfo(sourceInfo)
.then(_this.handleTileSetInfo_.bind(_this))
.catch(_this.handleError_.bind(_this));
return _this;
}
/**
* @param {import("./ogcTileUtil.js").TileSetInfo} tileSetInfo Tile set info.
* @private
*/
OGCMapTile.prototype.handleTileSetInfo_ = function (tileSetInfo) {
this.tileGrid = tileSetInfo.grid;
this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate);
this.setState('ready');
};
/**
* @private
* @param {Error} error The error.
*/
OGCMapTile.prototype.handleError_ = function (error) {
console.error(error); // eslint-disable-line no-console
this.setState('error');
};
return OGCMapTile;
}(TileImage));
export default OGCMapTile;
//# sourceMapping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EF,cAAc,CAAC,UAAU,CAAC;aACvB,IAAI,CAAC,KAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;aACxC,KAAK,CAAC,KAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC,CAAC;;IACzC,CAAC;IAED;;;OAGG;IACH,uCAAkB,GAAlB,UAAmB,WAAW;QAC5B,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,iCAAY,GAAZ,UAAa,KAAK;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,iCAAiC;QACvD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACH,iBAAC;AAAD,CAAC,AAtDD,CAAyB,SAAS,GAsDjC;AAED,eAAe,UAAU,CAAC"}
+122
View File
@@ -0,0 +1,122 @@
export default OGCVectorTile;
export type Options = {
/**
* URL to the OGC Vector Tileset endpoint.
*/
url: string;
/**
* A lookup of values to use in the tile URL template. The `{tileMatrix}`
* (zoom level), `{tileRow}`, and `{tileCol}` variables in the URL will always be provided by the source.
*/
context?: any;
/**
* Feature parser for tiles.
*/
format: import("../format/Feature.js").default;
/**
* The content type for the tiles (e.g. "application/vnd.mapbox-vector-tile"). If not provided,
* the source will try to find a link with rel="item" that uses a vector type supported by the configured format.
*/
mediaType?: string | undefined;
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least twice the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* This source may have overlapping geometries. Setting this
* to `false` (e.g. for sources with polygons that represent administrative
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
* stroke operations.
*/
overlaps?: boolean | undefined;
/**
* Projection of the tile grid.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Class used to instantiate image tiles.
* Default is {@link module :ol/VectorTile~VectorTile}.
*/
tileClass?: typeof import("../VectorTile.js").default | undefined;
/**
* A duration for tile opacity
* transitions in milliseconds. A duration of 0 disables the opacity transition.
*/
transition?: number | undefined;
/**
* Whether to wrap the world horizontally.
* When set to `false`, only one world
* will be rendered. When set to `true`, tiles will be wrapped horizontally to
* render multiple worlds.
*/
wrapX?: boolean | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Options
* @property {string} url URL to the OGC Vector Tileset endpoint.
* @property {Object} [context] A lookup of values to use in the tile URL template. The `{tileMatrix}`
* (zoom level), `{tileRow}`, and `{tileCol}` variables in the URL will always be provided by the source.
* @property {import("../format/Feature.js").default} format Feature parser for tiles.
* @property {string} [mediaType] The content type for the tiles (e.g. "application/vnd.mapbox-vector-tile"). If not provided,
* the source will try to find a link with rel="item" that uses a vector type supported by the configured format.
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least twice the number of tiles in the viewport.
* @property {boolean} [overlaps=true] This source may have overlapping geometries. Setting this
* to `false` (e.g. for sources with polygons that represent administrative
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
* stroke operations.
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection of the tile grid.
* @property {typeof import("../VectorTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/VectorTile~VectorTile}.
* @property {number} [transition] A duration for tile opacity
* transitions in milliseconds. A duration of 0 disables the opacity transition.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* When set to `false`, only one world
* will be rendered. When set to `true`, tiles will be wrapped horizontally to
* render multiple worlds.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=1]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for map tiles from an [OGC API - Tiles](https://ogcapi.ogc.org/tiles/) service that provides "vector" type tiles.
* The service must conform to at least the core (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core)
* and tileset (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tileset) conformance classes.
*
* Vector tile sets may come in a variety of formats (e.g. GeoJSON, MVT). The `format` option is used to determine
* which of the advertised media types is used. If you need to force the use of a particular media type, you can
* provide the `mediaType` option.
*/
declare class OGCVectorTile extends VectorTile {
/**
* @param {Options} options OGC vector tile options.
*/
constructor(options: Options);
/**
* @param {import("./ogcTileUtil.js").TileSetInfo} tileSetInfo Tile set info.
* @private
*/
private handleTileSetInfo_;
/**
* @private
* @param {Error} error The error.
*/
private handleError_;
}
import VectorTile_1 from "./VectorTile.js";
//# sourceMappingURL=OGCVectorTile.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OGCVectorTile.d.ts","sourceRoot":"","sources":["../src/source/OGCVectorTile.js"],"names":[],"mappings":";;;;;SASc,MAAM;;;;;;;;;YAGN,OAAO,sBAAsB,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUtC,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;AAfjD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;GASG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EA4BjB;IAED;;;OAGG;IACH,2BAIC;IAED;;;OAGG;IACH,qBAGC;CACF"}
+110
View File
@@ -0,0 +1,110 @@
/**
* @module ol/source/OGCVectorTile
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import VectorTile from './VectorTile.js';
import { getTileSetInfo } from './ogcTileUtil.js';
/**
* @typedef {Object} Options
* @property {string} url URL to the OGC Vector Tileset endpoint.
* @property {Object} [context] A lookup of values to use in the tile URL template. The `{tileMatrix}`
* (zoom level), `{tileRow}`, and `{tileCol}` variables in the URL will always be provided by the source.
* @property {import("../format/Feature.js").default} format Feature parser for tiles.
* @property {string} [mediaType] The content type for the tiles (e.g. "application/vnd.mapbox-vector-tile"). If not provided,
* the source will try to find a link with rel="item" that uses a vector type supported by the configured format.
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least twice the number of tiles in the viewport.
* @property {boolean} [overlaps=true] This source may have overlapping geometries. Setting this
* to `false` (e.g. for sources with polygons that represent administrative
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
* stroke operations.
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection of the tile grid.
* @property {typeof import("../VectorTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/VectorTile~VectorTile}.
* @property {number} [transition] A duration for tile opacity
* transitions in milliseconds. A duration of 0 disables the opacity transition.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* When set to `false`, only one world
* will be rendered. When set to `true`, tiles will be wrapped horizontally to
* render multiple worlds.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=1]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for map tiles from an [OGC API - Tiles](https://ogcapi.ogc.org/tiles/) service that provides "vector" type tiles.
* The service must conform to at least the core (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core)
* and tileset (http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tileset) conformance classes.
*
* Vector tile sets may come in a variety of formats (e.g. GeoJSON, MVT). The `format` option is used to determine
* which of the advertised media types is used. If you need to force the use of a particular media type, you can
* provide the `mediaType` option.
*/
var OGCVectorTile = /** @class */ (function (_super) {
__extends(OGCVectorTile, _super);
/**
* @param {Options} options OGC vector tile options.
*/
function OGCVectorTile(options) {
var _this = _super.call(this, {
attributions: options.attributions,
attributionsCollapsible: options.attributionsCollapsible,
cacheSize: options.cacheSize,
format: options.format,
overlaps: options.overlaps,
projection: options.projection,
tileClass: options.tileClass,
transition: options.transition,
wrapX: options.wrapX,
zDirection: options.zDirection,
state: 'loading',
}) || this;
var sourceInfo = {
url: options.url,
projection: _this.getProjection(),
mediaType: options.mediaType,
supportedMediaTypes: options.format.supportedMediaTypes,
context: options.context || null,
};
getTileSetInfo(sourceInfo)
.then(_this.handleTileSetInfo_.bind(_this))
.catch(_this.handleError_.bind(_this));
return _this;
}
/**
* @param {import("./ogcTileUtil.js").TileSetInfo} tileSetInfo Tile set info.
* @private
*/
OGCVectorTile.prototype.handleTileSetInfo_ = function (tileSetInfo) {
this.tileGrid = tileSetInfo.grid;
this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate);
this.setState('ready');
};
/**
* @private
* @param {Error} error The error.
*/
OGCVectorTile.prototype.handleError_ = function (error) {
console.error(error); // eslint-disable-line no-console
this.setState('error');
};
return OGCVectorTile;
}(VectorTile));
export default OGCVectorTile;
//# sourceMappingURL=OGCVectorTile.js.map
+1
View File
@@ -0,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,GAAlB,UAAmB,WAAW;QAC5B,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,oCAAY,GAAZ,UAAa,KAAK;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,iCAAiC;QACvD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACH,oBAAC;AAAD,CAAC,AAlDD,CAA4B,UAAU,GAkDrC;AAED,eAAe,aAAa,CAAC"}
+117
View File
@@ -0,0 +1,117 @@
/**
* The attribution containing a link to the OpenStreetMap Copyright and License
* page.
* @const
* @type {string}
* @api
*/
export const ATTRIBUTION: string;
export default OSM;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Max zoom.
*/
maxZoom?: number | undefined;
/**
* Whether the layer is opaque.
*/
opaque?: boolean | undefined;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* URL template.
* Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
*/
url?: string | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin='anonymous'] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {number} [maxZoom=19] Max zoom.
* @property {boolean} [opaque=true] Whether the layer is opaque.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {string} [url='https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'] URL template.
* Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for the OpenStreetMap tile server.
* @api
*/
declare class OSM extends XYZ {
/**
* @param {Options} [opt_options] Open Street Map options.
*/
constructor(opt_options?: Options | undefined);
}
import XYZ from "./XYZ.js";
//# sourceMappingURL=OSM.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OSM.d.ts","sourceRoot":"","sources":["../src/source/OSM.js"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,0BAHU,MAAM,CAME;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,+CAuCC;CACF"}
+105
View File
@@ -0,0 +1,105 @@
/**
* @module ol/source/OSM
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import XYZ from './XYZ.js';
/**
* The attribution containing a link to the OpenStreetMap Copyright and License
* page.
* @const
* @type {string}
* @api
*/
export var ATTRIBUTION = '&#169; ' +
'<a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> ' +
'contributors.';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin='anonymous'] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {number} [maxZoom=19] Max zoom.
* @property {boolean} [opaque=true] Whether the layer is opaque.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {string} [url='https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'] URL template.
* Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for the OpenStreetMap tile server.
* @api
*/
var OSM = /** @class */ (function (_super) {
__extends(OSM, _super);
/**
* @param {Options} [opt_options] Open Street Map options.
*/
function OSM(opt_options) {
var options = opt_options || {};
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
var attributions;
if (options.attributions !== undefined) {
attributions = options.attributions;
}
else {
attributions = [ATTRIBUTION];
}
var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : 'anonymous';
var url = options.url !== undefined
? options.url
: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
return _super.call(this, {
attributions: attributions,
attributionsCollapsible: false,
cacheSize: options.cacheSize,
crossOrigin: crossOrigin,
interpolate: interpolate,
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,
opaque: options.opaque !== undefined ? options.opaque : true,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
tileLoadFunction: options.tileLoadFunction,
transition: options.transition,
url: url,
wrapX: options.wrapX,
zDirection: options.zDirection,
}) || this;
}
return OSM;
}(XYZ));
export default OSM;
//# sourceMappingURL=OSM.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OSM.js","sourceRoot":"","sources":["../src/source/OSM.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,CAAC,IAAM,WAAW,GACtB,SAAS;IACT,sFAAsF;IACtF,eAAe,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;GAIG;AACH;IAAkB,uBAAG;IACnB;;OAEG;IACH,aAAY,WAAW;QACrB,IAAM,OAAO,GAAG,WAAW,IAAI,EAAE,CAAC;QAElC,IAAI,WAAW,GACb,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;QACvE,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE;YACrC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;SACnC;QAED,IAAI,YAAY,CAAC;QACjB,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACtC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;SACrC;aAAM;YACL,YAAY,GAAG,CAAC,WAAW,CAAC,CAAC;SAC9B;QAED,IAAM,WAAW,GACf,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;QAExE,IAAM,GAAG,GACP,OAAO,CAAC,GAAG,KAAK,SAAS;YACvB,CAAC,CAAC,OAAO,CAAC,GAAG;YACb,CAAC,CAAC,sDAAsD,CAAC;eAE7D,kBAAM;YACJ,YAAY,EAAE,YAAY;YAC1B,uBAAuB,EAAE,KAAK;YAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,WAAW;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC7D,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;YAC5D,0BAA0B,EAAE,OAAO,CAAC,0BAA0B;YAC9D,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;IACH,UAAC;AAAD,CAAC,AA5CD,CAAkB,GAAG,GA4CpB;AAED,eAAe,GAAG,CAAC"}
+392
View File
@@ -0,0 +1,392 @@
/**
* @param {Uint8ClampedArray} data Image data.
* @param {number} width Number of columns.
* @param {number} height Number of rows.
* @return {ImageData} Image data.
*/
export function newImageData(data: Uint8ClampedArray, width: number, height: number): ImageData;
/**
* @typedef {function(Error, ImageData, (Object|Array<Object>)): void} JobCallback
*/
/**
* @typedef {Object} Job
* @property {Object} meta Job metadata.
* @property {Array<ImageData>} inputs Array of input data.
* @property {JobCallback} callback Called when the job is complete.
*/
/**
* @typedef {Object} ProcessorOptions
* @property {number} threads Number of workers to spawn.
* @property {Operation} operation The operation.
* @property {Object<string, Function>} [lib] Functions that will be made available to operations run in a worker.
* @property {number} queue The number of queued jobs to allow.
* @property {boolean} [imageOps=false] Pass all the image data to the operation instead of a single pixel.
*/
/**
* @classdesc
* A processor runs pixel or image operations in workers.
*/
export class Processor extends Disposable {
/**
* @param {ProcessorOptions} config Configuration.
*/
constructor(config: ProcessorOptions);
_imageOps: boolean;
_workers: Worker[];
/**
* @type {Array<Job>}
* @private
*/
private _queue;
_maxQueueLength: number;
_running: number;
/**
* @type {Object<number, any>}
* @private
*/
private _dataLookup;
/**
* @type {Job}
* @private
*/
private _job;
/**
* Run operation on input data.
* @param {Array<ImageData>} inputs Array of image data.
* @param {Object} meta A user data object. This is passed to all operations
* and must be serializable.
* @param {function(Error, ImageData, Object): void} callback Called when work
* completes. The first argument is any error. The second is the ImageData
* generated by operations. The third is the user data object.
*/
process(inputs: Array<ImageData>, meta: any, callback: (arg0: Error, arg1: ImageData, arg2: any) => void): void;
/**
* Add a job to the queue.
* @param {Job} job The job.
*/
_enqueue(job: Job): void;
/**
* Dispatch a job.
*/
_dispatch(): void;
/**
* Handle messages from the worker.
* @param {number} index The worker index.
* @param {MessageEvent} event The message event.
*/
_onWorkerMessage(index: number, event: MessageEvent): void;
/**
* Resolve a job. If there are no more worker threads, the processor callback
* will be called.
*/
_resolveJob(): void;
}
/**
* @typedef {import("./Image.js").ImageSourceEventTypes|'beforeoperations'|'afteroperations'} RasterSourceEventTypes
*/
/**
* @classdesc
* Events emitted by {@link module:ol/source/Raster~RasterSource} instances are instances of this
* type.
*/
export class RasterSourceEvent extends Event {
/**
* @param {string} type Type.
* @param {import("../PluggableMap.js").FrameState} frameState The frame state.
* @param {Object|Array<Object>} data An object made available to operations. For "afteroperations" evenets
* this will be an array of objects if more than one thread is used.
*/
constructor(type: string, frameState: import("../PluggableMap.js").FrameState, data: any | Array<any>);
/**
* The raster extent.
* @type {import("../extent.js").Extent}
* @api
*/
extent: import("../extent.js").Extent;
/**
* The pixel resolution (map units per pixel).
* @type {number}
* @api
*/
resolution: number;
/**
* An object made available to all operations. This can be used by operations
* as a storage object (e.g. for calculating statistics).
* @type {Object}
* @api
*/
data: any;
}
export default RasterSource;
export type MinionData = {
/**
* Array of buffers.
*/
buffers: Array<ArrayBuffer>;
/**
* Operation metadata.
*/
meta: any;
/**
* The operation is an image operation.
*/
imageOps: boolean;
/**
* The width of the image.
*/
width: number;
/**
* The height of the image.
*/
height: number;
};
export type FauxMessageEvent = {
/**
* Message data.
*/
data: any;
};
export type JobCallback = (arg0: Error, arg1: ImageData, arg2: (any | Array<any>)) => void;
export type Job = {
/**
* Job metadata.
*/
meta: any;
/**
* Array of input data.
*/
inputs: Array<ImageData>;
/**
* Called when the job is complete.
*/
callback: JobCallback;
};
export type ProcessorOptions = {
/**
* Number of workers to spawn.
*/
threads: number;
/**
* The operation.
*/
operation: Operation;
/**
* Functions that will be made available to operations run in a worker.
*/
lib?: {
[x: string]: Function;
} | undefined;
/**
* The number of queued jobs to allow.
*/
queue: number;
/**
* Pass all the image data to the operation instead of a single pixel.
*/
imageOps?: boolean | undefined;
};
/**
* A function that takes an array of input data, performs some operation, and
* returns an array of output data.
* For `pixel` type operations, the function will be called with an array of
* pixels, where each pixel is an array of four numbers (`[r, g, b, a]`) in the
* range of 0 - 255. It should return a single pixel array.
* For `'image'` type operations, functions will be called with an array of
* [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData)
* and should return a single
* [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
* The operations
* are called with a second "data" argument, which can be used for storage. The
* data object is accessible from raster events, where it can be initialized in
* "beforeoperations" and accessed again in "afteroperations".
*/
export type Operation = (arg0: (Array<Array<number>> | Array<ImageData>), arg1: any) => (Array<number> | ImageData);
export type RasterSourceEventTypes = import("./Image.js").ImageSourceEventTypes | 'beforeoperations' | 'afteroperations';
export type Options = {
/**
* Input
* sources or layers. For vector data, use an VectorImage layer.
*/
sources: Array<import("./Source.js").default | import("../layer/Layer.js").default>;
/**
* Raster operation.
* The operation will be called with data from input sources
* and the output will be assigned to the raster source.
*/
operation?: Operation | undefined;
/**
* Functions that will be made available to operations run in a worker.
*/
lib?: any;
/**
* By default, operations will be run in a single worker thread.
* To avoid using workers altogether, set `threads: 0`. For pixel operations, operations can
* be run in multiple worker threads. Note that there is additional overhead in
* transferring data to multiple workers, and that depending on the user's
* system, it may not be possible to parallelize the work.
*/
threads?: number | undefined;
/**
* Operation type.
* Supported values are `'pixel'` and `'image'`. By default,
* `'pixel'` operations are assumed, and operations will be called with an
* array of pixels from input sources. If set to `'image'`, operations will
* be called with an array of ImageData objects from input sources.
*/
operationType?: string | undefined;
};
/**
* *
*/
export type RasterSourceOnSignature<Return> = import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> & import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> & import("../Observable").OnSignature<import("./Image.js").ImageSourceEventTypes, import("./Image.js").ImageSourceEvent, Return> & import("../Observable").OnSignature<RasterSourceEventTypes, RasterSourceEvent, Return> & import("../Observable").CombinedOnSignature<import("../Observable").EventTypes | import("../ObjectEventType").Types | RasterSourceEventTypes, Return>;
import Disposable from "../Disposable.js";
import Event from "../events/Event.js";
/**
* @typedef {Object} Options
* @property {Array<import("./Source.js").default|import("../layer/Layer.js").default>} sources Input
* sources or layers. For vector data, use an VectorImage layer.
* @property {Operation} [operation] Raster operation.
* The operation will be called with data from input sources
* and the output will be assigned to the raster source.
* @property {Object} [lib] Functions that will be made available to operations run in a worker.
* @property {number} [threads] By default, operations will be run in a single worker thread.
* To avoid using workers altogether, set `threads: 0`. For pixel operations, operations can
* be run in multiple worker threads. Note that there is additional overhead in
* transferring data to multiple workers, and that depending on the user's
* system, it may not be possible to parallelize the work.
* @property {RasterOperationType} [operationType='pixel'] Operation type.
* Supported values are `'pixel'` and `'image'`. By default,
* `'pixel'` operations are assumed, and operations will be called with an
* array of pixels from input sources. If set to `'image'`, operations will
* be called with an array of ImageData objects from input sources.
*/
/***
* @template Return
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
* import("../Observable").OnSignature<import("./Image.js").ImageSourceEventTypes, import("./Image.js").ImageSourceEvent, Return> &
* import("../Observable").OnSignature<RasterSourceEventTypes, RasterSourceEvent, Return> &
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types
* |RasterSourceEventTypes, Return>} RasterSourceOnSignature
*/
/**
* @classdesc
* A source that transforms data from any number of input sources using an
* {@link module:ol/source/Raster~Operation} function to transform input pixel values into
* output pixel values.
*
* @fires module:ol/source/Raster.RasterSourceEvent
* @api
*/
declare class RasterSource extends ImageSource {
/**
* @param {Options} options Options.
*/
constructor(options: Options);
/***
* @type {RasterSourceOnSignature<import("../events").EventsKey>}
*/
on: RasterSourceOnSignature<import("../events").EventsKey>;
/***
* @type {RasterSourceOnSignature<import("../events").EventsKey>}
*/
once: RasterSourceOnSignature<import("../events").EventsKey>;
/***
* @type {RasterSourceOnSignature<void>}
*/
un: RasterSourceOnSignature<void>;
/**
* @private
* @type {Processor}
*/
private processor_;
/**
* @private
* @type {RasterOperationType}
*/
private operationType_;
/**
* @private
* @type {number}
*/
private threads_;
/**
* @private
* @type {Array<import("../layer/Layer.js").default>}
*/
private layers_;
/**
* @private
* @type {import("../TileQueue.js").default}
*/
private tileQueue_;
/**
* The most recently requested frame state.
* @type {import("../PluggableMap.js").FrameState}
* @private
*/
private requestedFrameState_;
/**
* The most recently rendered image canvas.
* @type {import("../ImageCanvas.js").default}
* @private
*/
private renderedImageCanvas_;
/**
* The most recently rendered revision.
* @type {number}
*/
renderedRevision_: number;
/**
* @private
* @type {import("../PluggableMap.js").FrameState}
*/
private frameState_;
/**
* Set the operation.
* @param {Operation} operation New operation.
* @param {Object} [opt_lib] Functions that will be available to operations run
* in a worker.
* @api
*/
setOperation(operation: Operation, opt_lib?: any): void;
/**
* Update the stored frame state.
* @param {import("../extent.js").Extent} extent The view extent (in map units).
* @param {number} resolution The view resolution.
* @param {import("../proj/Projection.js").default} projection The view projection.
* @return {import("../PluggableMap.js").FrameState} The updated frame state.
* @private
*/
private updateFrameState_;
/**
* Determine if all sources are ready.
* @return {boolean} All sources are ready.
* @private
*/
private allSourcesReady_;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageCanvas.js").default} Single image.
*/
getImage(extent: import("../extent.js").Extent, resolution: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../ImageCanvas.js").default;
/**
* Start processing source data.
* @private
*/
private processSources_;
/**
* Called when pixel processing is complete.
* @param {import("../PluggableMap.js").FrameState} frameState The frame state.
* @param {Error} err Any error during processing.
* @param {ImageData} output The output image data.
* @param {Object|Array<Object>} data The user data (or an array if more than one thread).
* @private
*/
private onWorkerComplete_;
}
import ImageSource from "./Image.js";
//# sourceMappingURL=Raster.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Raster.d.ts","sourceRoot":"","sources":["../src/source/Raster.js"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,mCALW,iBAAiB,SACjB,MAAM,UACN,MAAM,GACL,SAAS,CAapB;AAiJD;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AACH;IACE;;OAEG;IACH,oBAFW,gBAAgB,EAmD1B;IA9CC,mBAAkC;IAwBlC,mBAAuB;IAEvB;;;OAGG;IACH,eAAgB;IAEhB,wBAA+C;IAC/C,iBAAiB;IAEjB;;;OAGG;IACH,oBAAqB;IAErB;;;OAGG;IACH,aAAgB;IAGlB;;;;;;;;OAQG;IACH,gBAPW,MAAM,SAAS,CAAC,8BAGP,KAAK,QAAE,SAAS,gBAAW,IAAI,QAWlD;IAED;;;OAGG;IACH,cAFW,GAAG,QAOb;IAED;;OAEG;IACH,kBA+CC;IAED;;;;OAIG;IACH,wBAHW,MAAM,SACN,YAAY,QAWt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OAAW,eAAe,EAAE,WAAW,CAAC,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,CAAC,GAC1F,OAAW,eAAe,EAAE,mBAAmB,CAAC,OAAO,eAAe,EAAE,UAAU,GAAC,OAAO,oBAAoB,EAAE,KAAK,GAC9G,sBAAsB,EAAE,MAAM,CAAC;;;AA3BvC;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAsIjB;IA/HC;;OAEG;IACH,IAFU,wBAAwB,OAAO,WAAW,EAAE,SAAS,CAAC,CAEzD;IAEP;;OAEG;IACH,MAFU,wBAAwB,OAAO,WAAW,EAAE,SAAS,CAAC,CAEvD;IAET;;OAEG;IACH,IAFU,wBAAwB,IAAI,CAAC,CAEhC;IAEP;;;OAGG;IACH,mBAAsB;IAEtB;;;OAGG;IACH,uBAG+B;IAE/B;;;OAGG;IACH,iBAAmE;IAEnE;;;OAGG;IACH,gBAA4C;IAO5C;;;OAGG;IACH,mBAE2B;IAE3B;;;;OAIG;IACH,6BAAyB;IAEzB;;;;OAIG;IACH,6BAAgC;IAEhC;;;OAGG;IACH,mBAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,oBAsBC;IA4BH;;;;;;OAMG;IACH,wBALW,SAAS,uBAkBnB;IAED;;;;;;;OAOG;IACH,0BAqBC;IAED;;;;OAIG;IACH,yBAWC;IAED;;;;;;OAMG;IACH,iBANW,OAAO,cAAc,EAAE,MAAM,cAC7B,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACtC,OAAO,mBAAmB,EAAE,OAAO,CAoC9C;IAED;;;OAGG;IACH,wBAuBC;IAED;;;;;;;OAOG;IACH,0BAwCC;CAQF"}
+894
View File
@@ -0,0 +1,894 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/Raster
*/
import Disposable from '../Disposable.js';
import Event from '../events/Event.js';
import EventType from '../events/EventType.js';
import ImageCanvas from '../ImageCanvas.js';
import ImageLayer from '../layer/Image.js';
import ImageSource from './Image.js';
import Source from './Source.js';
import TileLayer from '../layer/Tile.js';
import TileQueue from '../TileQueue.js';
import TileSource from './Tile.js';
import { assign } from '../obj.js';
import { createCanvasContext2D } from '../dom.js';
import { create as createTransform } from '../transform.js';
import { equals, getCenter, getHeight, getWidth } from '../extent.js';
import { getUid } from '../util.js';
var hasImageData = true;
try {
new ImageData(10, 10);
}
catch (_) {
hasImageData = false;
}
/** @type {CanvasRenderingContext2D} */
var context;
/**
* @param {Uint8ClampedArray} data Image data.
* @param {number} width Number of columns.
* @param {number} height Number of rows.
* @return {ImageData} Image data.
*/
export function newImageData(data, width, height) {
if (hasImageData) {
return new ImageData(data, width, height);
}
if (!context) {
context = document.createElement('canvas').getContext('2d');
}
var imageData = context.createImageData(width, height);
imageData.data.set(data);
return imageData;
}
/**
* @typedef {Object} MinionData
* @property {Array<ArrayBuffer>} buffers Array of buffers.
* @property {Object} meta Operation metadata.
* @property {boolean} imageOps The operation is an image operation.
* @property {number} width The width of the image.
* @property {number} height The height of the image.
*/
/* istanbul ignore next */
/**
* Create a function for running operations. This function is serialized for
* use in a worker.
* @param {function(Array, Object):*} operation The operation.
* @return {function(MinionData):ArrayBuffer} A function that takes an object with
* buffers, meta, imageOps, width, and height properties and returns an array
* buffer.
*/
function createMinion(operation) {
var workerHasImageData = true;
try {
new ImageData(10, 10);
}
catch (_) {
workerHasImageData = false;
}
function newWorkerImageData(data, width, height) {
if (workerHasImageData) {
return new ImageData(data, width, height);
}
else {
return { data: data, width: width, height: height };
}
}
return function (data) {
// bracket notation for minification support
var buffers = data['buffers'];
var meta = data['meta'];
var imageOps = data['imageOps'];
var width = data['width'];
var height = data['height'];
var numBuffers = buffers.length;
var numBytes = buffers[0].byteLength;
if (imageOps) {
var images = new Array(numBuffers);
for (var b = 0; b < numBuffers; ++b) {
images[b] = newWorkerImageData(new Uint8ClampedArray(buffers[b]), width, height);
}
var output_1 = operation(images, meta).data;
return output_1.buffer;
}
var output = new Uint8ClampedArray(numBytes);
var arrays = new Array(numBuffers);
var pixels = new Array(numBuffers);
for (var b = 0; b < numBuffers; ++b) {
arrays[b] = new Uint8ClampedArray(buffers[b]);
pixels[b] = [0, 0, 0, 0];
}
for (var i = 0; i < numBytes; i += 4) {
for (var j = 0; j < numBuffers; ++j) {
var array = arrays[j];
pixels[j][0] = array[i];
pixels[j][1] = array[i + 1];
pixels[j][2] = array[i + 2];
pixels[j][3] = array[i + 3];
}
var pixel = operation(pixels, meta);
output[i] = pixel[0];
output[i + 1] = pixel[1];
output[i + 2] = pixel[2];
output[i + 3] = pixel[3];
}
return output.buffer;
};
}
/**
* Create a worker for running operations.
* @param {ProcessorOptions} config Processor options.
* @param {function(MessageEvent): void} onMessage Called with a message event.
* @return {Worker} The worker.
*/
function createWorker(config, onMessage) {
var lib = Object.keys(config.lib || {}).map(function (name) {
return 'var ' + name + ' = ' + config.lib[name].toString() + ';';
});
var lines = lib.concat([
'var __minion__ = (' + createMinion.toString() + ')(',
config.operation.toString(),
');',
'self.addEventListener("message", function(event) {',
' var buffer = __minion__(event.data);',
' self.postMessage({buffer: buffer, meta: event.data.meta}, [buffer]);',
'});',
]);
var worker = new Worker(typeof Blob === 'undefined'
? 'data:text/javascript;base64,' +
Buffer.from(lines.join('\n'), 'binary').toString('base64')
: URL.createObjectURL(new Blob(lines, { type: 'text/javascript' })));
worker.addEventListener('message', onMessage);
return worker;
}
/**
* @typedef {Object} FauxMessageEvent
* @property {Object} data Message data.
*/
/**
* Create a faux worker for running operations.
* @param {ProcessorOptions} config Configuration.
* @param {function(FauxMessageEvent): void} onMessage Called with a message event.
* @return {Object} The faux worker.
*/
function createFauxWorker(config, onMessage) {
var minion = createMinion(config.operation);
var terminated = false;
return {
postMessage: function (data) {
setTimeout(function () {
if (terminated) {
return;
}
onMessage({ data: { buffer: minion(data), meta: data['meta'] } });
}, 0);
},
terminate: function () {
terminated = true;
},
};
}
/**
* @typedef {function(Error, ImageData, (Object|Array<Object>)): void} JobCallback
*/
/**
* @typedef {Object} Job
* @property {Object} meta Job metadata.
* @property {Array<ImageData>} inputs Array of input data.
* @property {JobCallback} callback Called when the job is complete.
*/
/**
* @typedef {Object} ProcessorOptions
* @property {number} threads Number of workers to spawn.
* @property {Operation} operation The operation.
* @property {Object<string, Function>} [lib] Functions that will be made available to operations run in a worker.
* @property {number} queue The number of queued jobs to allow.
* @property {boolean} [imageOps=false] Pass all the image data to the operation instead of a single pixel.
*/
/**
* @classdesc
* A processor runs pixel or image operations in workers.
*/
var Processor = /** @class */ (function (_super) {
__extends(Processor, _super);
/**
* @param {ProcessorOptions} config Configuration.
*/
function Processor(config) {
var _this = _super.call(this) || this;
_this._imageOps = !!config.imageOps;
var threads;
if (config.threads === 0) {
threads = 0;
}
else if (_this._imageOps) {
threads = 1;
}
else {
threads = config.threads || 1;
}
/**
* @type {Array<Worker>}
*/
var workers = new Array(threads);
if (threads) {
for (var i = 0; i < threads; ++i) {
workers[i] = createWorker(config, _this._onWorkerMessage.bind(_this, i));
}
}
else {
workers[0] = createFauxWorker(config, _this._onWorkerMessage.bind(_this, 0));
}
_this._workers = workers;
/**
* @type {Array<Job>}
* @private
*/
_this._queue = [];
_this._maxQueueLength = config.queue || Infinity;
_this._running = 0;
/**
* @type {Object<number, any>}
* @private
*/
_this._dataLookup = {};
/**
* @type {Job}
* @private
*/
_this._job = null;
return _this;
}
/**
* Run operation on input data.
* @param {Array<ImageData>} inputs Array of image data.
* @param {Object} meta A user data object. This is passed to all operations
* and must be serializable.
* @param {function(Error, ImageData, Object): void} callback Called when work
* completes. The first argument is any error. The second is the ImageData
* generated by operations. The third is the user data object.
*/
Processor.prototype.process = function (inputs, meta, callback) {
this._enqueue({
inputs: inputs,
meta: meta,
callback: callback,
});
this._dispatch();
};
/**
* Add a job to the queue.
* @param {Job} job The job.
*/
Processor.prototype._enqueue = function (job) {
this._queue.push(job);
while (this._queue.length > this._maxQueueLength) {
this._queue.shift().callback(null, null);
}
};
/**
* Dispatch a job.
*/
Processor.prototype._dispatch = function () {
if (this._running || this._queue.length === 0) {
return;
}
var job = this._queue.shift();
this._job = job;
var width = job.inputs[0].width;
var height = job.inputs[0].height;
var buffers = job.inputs.map(function (input) {
return input.data.buffer;
});
var threads = this._workers.length;
this._running = threads;
if (threads === 1) {
this._workers[0].postMessage({
buffers: buffers,
meta: job.meta,
imageOps: this._imageOps,
width: width,
height: height,
}, buffers);
return;
}
var length = job.inputs[0].data.length;
var segmentLength = 4 * Math.ceil(length / 4 / threads);
for (var i = 0; i < threads; ++i) {
var offset = i * segmentLength;
var slices = [];
for (var j = 0, jj = buffers.length; j < jj; ++j) {
slices.push(buffers[j].slice(offset, offset + segmentLength));
}
this._workers[i].postMessage({
buffers: slices,
meta: job.meta,
imageOps: this._imageOps,
width: width,
height: height,
}, slices);
}
};
/**
* Handle messages from the worker.
* @param {number} index The worker index.
* @param {MessageEvent} event The message event.
*/
Processor.prototype._onWorkerMessage = function (index, event) {
if (this.disposed) {
return;
}
this._dataLookup[index] = event.data;
--this._running;
if (this._running === 0) {
this._resolveJob();
}
};
/**
* Resolve a job. If there are no more worker threads, the processor callback
* will be called.
*/
Processor.prototype._resolveJob = function () {
var job = this._job;
var threads = this._workers.length;
var data, meta;
if (threads === 1) {
data = new Uint8ClampedArray(this._dataLookup[0]['buffer']);
meta = this._dataLookup[0]['meta'];
}
else {
var length_1 = job.inputs[0].data.length;
data = new Uint8ClampedArray(length_1);
meta = new Array(threads);
var segmentLength = 4 * Math.ceil(length_1 / 4 / threads);
for (var i = 0; i < threads; ++i) {
var buffer = this._dataLookup[i]['buffer'];
var offset = i * segmentLength;
data.set(new Uint8ClampedArray(buffer), offset);
meta[i] = this._dataLookup[i]['meta'];
}
}
this._job = null;
this._dataLookup = {};
job.callback(null, newImageData(data, job.inputs[0].width, job.inputs[0].height), meta);
this._dispatch();
};
/**
* Terminate all workers associated with the processor.
*/
Processor.prototype.disposeInternal = function () {
for (var i = 0; i < this._workers.length; ++i) {
this._workers[i].terminate();
}
this._workers.length = 0;
};
return Processor;
}(Disposable));
export { Processor };
/**
* A function that takes an array of input data, performs some operation, and
* returns an array of output data.
* For `pixel` type operations, the function will be called with an array of
* pixels, where each pixel is an array of four numbers (`[r, g, b, a]`) in the
* range of 0 - 255. It should return a single pixel array.
* For `'image'` type operations, functions will be called with an array of
* [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData)
* and should return a single
* [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
* The operations
* are called with a second "data" argument, which can be used for storage. The
* data object is accessible from raster events, where it can be initialized in
* "beforeoperations" and accessed again in "afteroperations".
*
* @typedef {function((Array<Array<number>>|Array<ImageData>), Object):
* (Array<number>|ImageData)} Operation
*/
/**
* @enum {string}
*/
var RasterEventType = {
/**
* Triggered before operations are run. Listeners will receive an event object with
* a `data` property that can be used to make data available to operations.
* @event module:ol/source/Raster.RasterSourceEvent#beforeoperations
* @api
*/
BEFOREOPERATIONS: 'beforeoperations',
/**
* Triggered after operations are run. Listeners will receive an event object with
* a `data` property. If more than one thread is used, `data` will be an array of
* objects. If a single thread is used, `data` will be a single object.
* @event module:ol/source/Raster.RasterSourceEvent#afteroperations
* @api
*/
AFTEROPERATIONS: 'afteroperations',
};
/**
* Raster operation type. Supported values are `'pixel'` and `'image'`.
* @enum {string}
*/
var RasterOperationType = {
PIXEL: 'pixel',
IMAGE: 'image',
};
/**
* @typedef {import("./Image.js").ImageSourceEventTypes|'beforeoperations'|'afteroperations'} RasterSourceEventTypes
*/
/**
* @classdesc
* Events emitted by {@link module:ol/source/Raster~RasterSource} instances are instances of this
* type.
*/
var RasterSourceEvent = /** @class */ (function (_super) {
__extends(RasterSourceEvent, _super);
/**
* @param {string} type Type.
* @param {import("../PluggableMap.js").FrameState} frameState The frame state.
* @param {Object|Array<Object>} data An object made available to operations. For "afteroperations" evenets
* this will be an array of objects if more than one thread is used.
*/
function RasterSourceEvent(type, frameState, data) {
var _this = _super.call(this, type) || this;
/**
* The raster extent.
* @type {import("../extent.js").Extent}
* @api
*/
_this.extent = frameState.extent;
/**
* The pixel resolution (map units per pixel).
* @type {number}
* @api
*/
_this.resolution = frameState.viewState.resolution / frameState.pixelRatio;
/**
* An object made available to all operations. This can be used by operations
* as a storage object (e.g. for calculating statistics).
* @type {Object}
* @api
*/
_this.data = data;
return _this;
}
return RasterSourceEvent;
}(Event));
export { RasterSourceEvent };
/**
* @typedef {Object} Options
* @property {Array<import("./Source.js").default|import("../layer/Layer.js").default>} sources Input
* sources or layers. For vector data, use an VectorImage layer.
* @property {Operation} [operation] Raster operation.
* The operation will be called with data from input sources
* and the output will be assigned to the raster source.
* @property {Object} [lib] Functions that will be made available to operations run in a worker.
* @property {number} [threads] By default, operations will be run in a single worker thread.
* To avoid using workers altogether, set `threads: 0`. For pixel operations, operations can
* be run in multiple worker threads. Note that there is additional overhead in
* transferring data to multiple workers, and that depending on the user's
* system, it may not be possible to parallelize the work.
* @property {RasterOperationType} [operationType='pixel'] Operation type.
* Supported values are `'pixel'` and `'image'`. By default,
* `'pixel'` operations are assumed, and operations will be called with an
* array of pixels from input sources. If set to `'image'`, operations will
* be called with an array of ImageData objects from input sources.
*/
/***
* @template Return
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
* import("../Observable").OnSignature<import("./Image.js").ImageSourceEventTypes, import("./Image.js").ImageSourceEvent, Return> &
* import("../Observable").OnSignature<RasterSourceEventTypes, RasterSourceEvent, Return> &
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types
* |RasterSourceEventTypes, Return>} RasterSourceOnSignature
*/
/**
* @classdesc
* A source that transforms data from any number of input sources using an
* {@link module:ol/source/Raster~Operation} function to transform input pixel values into
* output pixel values.
*
* @fires module:ol/source/Raster.RasterSourceEvent
* @api
*/
var RasterSource = /** @class */ (function (_super) {
__extends(RasterSource, _super);
/**
* @param {Options} options Options.
*/
function RasterSource(options) {
var _this = _super.call(this, {
projection: null,
}) || this;
/***
* @type {RasterSourceOnSignature<import("../events").EventsKey>}
*/
_this.on;
/***
* @type {RasterSourceOnSignature<import("../events").EventsKey>}
*/
_this.once;
/***
* @type {RasterSourceOnSignature<void>}
*/
_this.un;
/**
* @private
* @type {Processor}
*/
_this.processor_ = null;
/**
* @private
* @type {RasterOperationType}
*/
_this.operationType_ =
options.operationType !== undefined
? options.operationType
: RasterOperationType.PIXEL;
/**
* @private
* @type {number}
*/
_this.threads_ = options.threads !== undefined ? options.threads : 1;
/**
* @private
* @type {Array<import("../layer/Layer.js").default>}
*/
_this.layers_ = createLayers(options.sources);
var changed = _this.changed.bind(_this);
for (var i = 0, ii = _this.layers_.length; i < ii; ++i) {
_this.layers_[i].addEventListener(EventType.CHANGE, changed);
}
/**
* @private
* @type {import("../TileQueue.js").default}
*/
_this.tileQueue_ = new TileQueue(function () {
return 1;
}, _this.changed.bind(_this));
/**
* The most recently requested frame state.
* @type {import("../PluggableMap.js").FrameState}
* @private
*/
_this.requestedFrameState_;
/**
* The most recently rendered image canvas.
* @type {import("../ImageCanvas.js").default}
* @private
*/
_this.renderedImageCanvas_ = null;
/**
* The most recently rendered revision.
* @type {number}
*/
_this.renderedRevision_;
/**
* @private
* @type {import("../PluggableMap.js").FrameState}
*/
_this.frameState_ = {
animate: false,
coordinateToPixelTransform: createTransform(),
declutterTree: null,
extent: null,
index: 0,
layerIndex: 0,
layerStatesArray: getLayerStatesArray(_this.layers_),
pixelRatio: 1,
pixelToCoordinateTransform: createTransform(),
postRenderFunctions: [],
size: [0, 0],
tileQueue: _this.tileQueue_,
time: Date.now(),
usedTiles: {},
viewState: /** @type {import("../View.js").State} */ ({
rotation: 0,
}),
viewHints: [],
wantedTiles: {},
mapId: getUid(_this),
renderTargets: {},
};
_this.setAttributions(function (frameState) {
var attributions = [];
for (var index = 0, iMax = options.sources.length; index < iMax; ++index) {
var sourceOrLayer = options.sources[index];
var source = sourceOrLayer instanceof Source
? sourceOrLayer
: sourceOrLayer.getSource();
var attributionGetter = source.getAttributions();
if (typeof attributionGetter === 'function') {
var sourceAttribution = attributionGetter(frameState);
attributions.push.apply(attributions, sourceAttribution);
}
}
return attributions.length !== 0 ? attributions : null;
});
if (options.operation !== undefined) {
_this.setOperation(options.operation, options.lib);
}
return _this;
}
/**
* Set the operation.
* @param {Operation} operation New operation.
* @param {Object} [opt_lib] Functions that will be available to operations run
* in a worker.
* @api
*/
RasterSource.prototype.setOperation = function (operation, opt_lib) {
if (this.processor_) {
this.processor_.dispose();
}
this.processor_ = new Processor({
operation: operation,
imageOps: this.operationType_ === RasterOperationType.IMAGE,
queue: 1,
lib: opt_lib,
threads: this.threads_,
});
this.changed();
};
/**
* Update the stored frame state.
* @param {import("../extent.js").Extent} extent The view extent (in map units).
* @param {number} resolution The view resolution.
* @param {import("../proj/Projection.js").default} projection The view projection.
* @return {import("../PluggableMap.js").FrameState} The updated frame state.
* @private
*/
RasterSource.prototype.updateFrameState_ = function (extent, resolution, projection) {
var frameState = /** @type {import("../PluggableMap.js").FrameState} */ (assign({}, this.frameState_));
frameState.viewState = /** @type {import("../View.js").State} */ (assign({}, frameState.viewState));
var center = getCenter(extent);
frameState.extent = extent.slice();
frameState.size[0] = Math.round(getWidth(extent) / resolution);
frameState.size[1] = Math.round(getHeight(extent) / resolution);
frameState.time = Date.now();
var viewState = frameState.viewState;
viewState.center = center;
viewState.projection = projection;
viewState.resolution = resolution;
return frameState;
};
/**
* Determine if all sources are ready.
* @return {boolean} All sources are ready.
* @private
*/
RasterSource.prototype.allSourcesReady_ = function () {
var ready = true;
var source;
for (var i = 0, ii = this.layers_.length; i < ii; ++i) {
source = this.layers_[i].getSource();
if (source.getState() !== 'ready') {
ready = false;
break;
}
}
return ready;
};
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../ImageCanvas.js").default} Single image.
*/
RasterSource.prototype.getImage = function (extent, resolution, pixelRatio, projection) {
if (!this.allSourcesReady_()) {
return null;
}
var frameState = this.updateFrameState_(extent, resolution, projection);
this.requestedFrameState_ = frameState;
// check if we can't reuse the existing ol/ImageCanvas
if (this.renderedImageCanvas_) {
var renderedResolution = this.renderedImageCanvas_.getResolution();
var renderedExtent = this.renderedImageCanvas_.getExtent();
if (resolution !== renderedResolution ||
!equals(extent, renderedExtent)) {
this.renderedImageCanvas_ = null;
}
}
if (!this.renderedImageCanvas_ ||
this.getRevision() !== this.renderedRevision_) {
this.processSources_();
}
frameState.tileQueue.loadMoreTiles(16, 16);
if (frameState.animate) {
requestAnimationFrame(this.changed.bind(this));
}
return this.renderedImageCanvas_;
};
/**
* Start processing source data.
* @private
*/
RasterSource.prototype.processSources_ = function () {
var frameState = this.requestedFrameState_;
var len = this.layers_.length;
var imageDatas = new Array(len);
for (var i = 0; i < len; ++i) {
frameState.layerIndex = i;
var imageData = getImageData(this.layers_[i], frameState);
if (imageData) {
imageDatas[i] = imageData;
}
else {
return;
}
}
var data = {};
this.dispatchEvent(new RasterSourceEvent(RasterEventType.BEFOREOPERATIONS, frameState, data));
this.processor_.process(imageDatas, data, this.onWorkerComplete_.bind(this, frameState));
};
/**
* Called when pixel processing is complete.
* @param {import("../PluggableMap.js").FrameState} frameState The frame state.
* @param {Error} err Any error during processing.
* @param {ImageData} output The output image data.
* @param {Object|Array<Object>} data The user data (or an array if more than one thread).
* @private
*/
RasterSource.prototype.onWorkerComplete_ = function (frameState, err, output, data) {
if (err || !output) {
return;
}
// do nothing if extent or resolution changed
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
if (resolution !== this.requestedFrameState_.viewState.resolution ||
!equals(extent, this.requestedFrameState_.extent)) {
return;
}
var context;
if (this.renderedImageCanvas_) {
context = this.renderedImageCanvas_.getImage().getContext('2d');
}
else {
var width = Math.round(getWidth(extent) / resolution);
var height = Math.round(getHeight(extent) / resolution);
context = createCanvasContext2D(width, height);
this.renderedImageCanvas_ = new ImageCanvas(extent, resolution, 1, context.canvas);
}
context.putImageData(output, 0, 0);
this.changed();
this.renderedRevision_ = this.getRevision();
this.dispatchEvent(new RasterSourceEvent(RasterEventType.AFTEROPERATIONS, frameState, data));
if (frameState.animate) {
requestAnimationFrame(this.changed.bind(this));
}
};
RasterSource.prototype.disposeInternal = function () {
if (this.processor_) {
this.processor_.dispose();
}
_super.prototype.disposeInternal.call(this);
};
return RasterSource;
}(ImageSource));
/**
* Clean up and unregister the worker.
* @function
* @api
*/
RasterSource.prototype.dispose;
/**
* A reusable canvas context.
* @type {CanvasRenderingContext2D}
* @private
*/
var sharedContext = null;
/**
* Get image data from a layer.
* @param {import("../layer/Layer.js").default} layer Layer to render.
* @param {import("../PluggableMap.js").FrameState} frameState The frame state.
* @return {ImageData} The image data.
*/
function getImageData(layer, frameState) {
var renderer = layer.getRenderer();
if (!renderer) {
throw new Error('Unsupported layer type: ' + layer);
}
if (!renderer.prepareFrame(frameState)) {
return null;
}
var width = frameState.size[0];
var height = frameState.size[1];
if (width === 0 || height === 0) {
return null;
}
var container = renderer.renderFrame(frameState, null);
var element;
if (container instanceof HTMLCanvasElement) {
element = container;
}
else {
if (container) {
element = container.firstElementChild;
}
if (!(element instanceof HTMLCanvasElement)) {
throw new Error('Unsupported rendered element: ' + element);
}
if (element.width === width && element.height === height) {
var context_1 = element.getContext('2d');
return context_1.getImageData(0, 0, width, height);
}
}
if (!sharedContext) {
sharedContext = createCanvasContext2D(width, height);
}
else {
var canvas = sharedContext.canvas;
if (canvas.width !== width || canvas.height !== height) {
sharedContext = createCanvasContext2D(width, height);
}
else {
sharedContext.clearRect(0, 0, width, height);
}
}
sharedContext.drawImage(element, 0, 0, width, height);
return sharedContext.getImageData(0, 0, width, height);
}
/**
* Get a list of layer states from a list of layers.
* @param {Array<import("../layer/Layer.js").default>} layers Layers.
* @return {Array<import("../layer/Layer.js").State>} The layer states.
*/
function getLayerStatesArray(layers) {
return layers.map(function (layer) {
return layer.getLayerState();
});
}
/**
* Create layers for all sources.
* @param {Array<import("./Source.js").default|import("../layer/Layer.js").default>} sources The sources.
* @return {Array<import("../layer/Layer.js").default>} Array of layers.
*/
function createLayers(sources) {
var len = sources.length;
var layers = new Array(len);
for (var i = 0; i < len; ++i) {
layers[i] = createLayer(sources[i]);
}
return layers;
}
/**
* Create a layer for the provided source.
* @param {import("./Source.js").default|import("../layer/Layer.js").default} layerOrSource The layer or source.
* @return {import("../layer/Layer.js").default} The layer.
*/
function createLayer(layerOrSource) {
// @type {import("../layer/Layer.js").default}
var layer;
if (layerOrSource instanceof Source) {
if (layerOrSource instanceof TileSource) {
layer = new TileLayer({ source: layerOrSource });
}
else if (layerOrSource instanceof ImageSource) {
layer = new ImageLayer({ source: layerOrSource });
}
}
else {
layer = layerOrSource;
}
return layer;
}
export default RasterSource;
//# sourceMappingURL=Raster.js.map
+1
View File
File diff suppressed because one or more lines are too long
+203
View File
@@ -0,0 +1,203 @@
export default Source;
/**
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
*/
export type State = 'undefined' | 'loading' | 'ready' | 'error';
/**
* A function that takes a {@link module :ol/PluggableMap~FrameState} and returns a string or
* an array of strings representing source attributions.
*/
export type Attribution = (arg0: import("../PluggableMap.js").FrameState) => (string | Array<string>);
/**
* A type that can be used to provide attribution information for data sources.
*
* It represents either
* * a simple string (e.g. `'© Acme Inc.'`)
* * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)
* * a function that returns a string or array of strings ({@link module :ol/source/Source~Attribution})
*/
export type AttributionLike = string | Array<string> | Attribution;
export type Options = {
/**
* Attributions.
*/
attributions?: AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* State.
*/
state?: State | undefined;
/**
* WrapX.
*/
wrapX?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
interpolate?: boolean | undefined;
};
/**
* @typedef {'undefined' | 'loading' | 'ready' | 'error'} State
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
*/
/**
* A function that takes a {@link module:ol/PluggableMap~FrameState} and returns a string or
* an array of strings representing source attributions.
*
* @typedef {function(import("../PluggableMap.js").FrameState): (string|Array<string>)} Attribution
*/
/**
* A type that can be used to provide attribution information for data sources.
*
* It represents either
* * a simple string (e.g. `'© Acme Inc.'`)
* * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)
* * a function that returns a string or array of strings ({@link module:ol/source/Source~Attribution})
*
* @typedef {string|Array<string>|Attribution} AttributionLike
*/
/**
* @typedef {Object} Options
* @property {AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {import("./Source.js").State} [state='ready'] State.
* @property {boolean} [wrapX=false] WrapX.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for {@link module:ol/layer/Layer~Layer} sources.
*
* A generic `change` event is triggered when the state of the source changes.
* @abstract
* @api
*/
declare class Source extends BaseObject {
/**
* @param {Options} options Source options.
*/
constructor(options: Options);
/**
* @protected
* @type {import("../proj/Projection.js").default|null}
*/
protected projection: import("../proj/Projection.js").default | null;
/**
* @private
* @type {?Attribution}
*/
private attributions_;
/**
* @private
* @type {boolean}
*/
private attributionsCollapsible_;
/**
* This source is currently loading data. Sources that defer loading to the
* map's tile queue never set this to `true`.
* @type {boolean}
*/
loading: boolean;
/**
* @private
* @type {import("./Source.js").State}
*/
private state_;
/**
* @private
* @type {boolean}
*/
private wrapX_;
/**
* @private
* @type {boolean}
*/
private interpolate_;
/**
* @protected
* @type {function(import("../View.js").ViewOptions):void}
*/
protected viewResolver: (arg0: import("../View.js").ViewOptions) => void;
/**
* @protected
* @type {function(Error):void}
*/
protected viewRejector: (arg0: Error) => void;
/**
* @private
* @type {Promise<import("../View.js").ViewOptions>}
*/
private viewPromise_;
/**
* Get the attribution function for the source.
* @return {?Attribution} Attribution function.
* @api
*/
getAttributions(): Attribution | null;
/**
* @return {boolean} Attributions are collapsible.
* @api
*/
getAttributionsCollapsible(): boolean;
/**
* Get the projection of the source.
* @return {import("../proj/Projection.js").default|null} Projection.
* @api
*/
getProjection(): import("../proj/Projection.js").default | null;
/**
* @abstract
* @return {Array<number>|null} Resolutions.
*/
getResolutions(): Array<number> | null;
/**
* @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
*/
getView(): Promise<import("../View.js").ViewOptions>;
/**
* Get the state of the source, see {@link import("./Source.js").State} for possible states.
* @return {import("./Source.js").State} State.
* @api
*/
getState(): import("./Source.js").State;
/**
* @return {boolean|undefined} Wrap X.
*/
getWrapX(): boolean | undefined;
/**
* @return {boolean} Use linear interpolation when resampling.
*/
getInterpolate(): boolean;
/**
* Refreshes the source. The source will be cleared, and data from the server will be reloaded.
* @api
*/
refresh(): void;
/**
* Set the attributions of the source.
* @param {AttributionLike|undefined} attributions Attributions.
* Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution},
* or `undefined`.
* @api
*/
setAttributions(attributions: AttributionLike | undefined): void;
/**
* Set the state of the source.
* @param {import("./Source.js").State} state State.
*/
setState(state: import("./Source.js").State): void;
}
import BaseObject from "../Object.js";
//# sourceMappingURL=Source.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Source.d.ts","sourceRoot":"","sources":["../src/source/Source.js"],"names":[],"mappings":";;;;oBAQa,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO;;;;;iCAQlC,OAAO,oBAAoB,EAAE,UAAU,KAAG,CAAC,MAAM,GAAC,MAAM,MAAM,CAAC,CAAC;;;;;;;;;8BAWzE,MAAM,GAAC,MAAM,MAAM,CAAC,GAAC,WAAW;;;;;;;;;;;;;iBAO/B,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;AA3BjD;;;GAGG;AAEH;;;;;GAKG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAwEjB;IAnEC;;;OAGG;IACH,sBAFU,OAAO,uBAAuB,EAAE,OAAO,GAAC,IAAI,CAEH;IAEnD;;;OAGG;IACH,sBAA4D;IAE5D;;;OAGG;IACH,iCAGU;IAEV;;;;OAIG;IACH,SAFU,OAAO,CAEG;IAEpB;;;OAGG;IACH,eAAmE;IAEnE;;;OAGG;IACH,eAAiE;IAEjE;;;OAGG;IACH,qBAAyC;IAEzC;;;OAGG;IACH,+BAFmB,OAAO,YAAY,EAAE,WAAW,KAAE,IAAI,CAEjC;IAExB;;;OAGG;IACH,+BAFmB,KAAK,KAAE,IAAI,CAEN;IAGxB;;;OAGG;IACH,qBAGE;IAGJ;;;;OAIG;IACH,mBAHa,WAAW,QAKvB;IAED;;;OAGG;IACH,8BAHY,OAAO,CAKlB;IAED;;;;OAIG;IACH,iBAHY,OAAO,uBAAuB,EAAE,OAAO,GAAC,IAAI,CAKvD;IAED;;;OAGG;IACH,kBAFY,MAAM,MAAM,CAAC,GAAC,IAAI,CAI7B;IAED;;OAEG;IACH,WAFY,QAAQ,OAAO,YAAY,EAAE,WAAW,CAAC,CAIpD;IAED;;;;OAIG;IACH,YAHY,OAAO,aAAa,EAAE,KAAK,CAKtC;IAED;;OAEG;IACH,YAFY,OAAO,GAAC,SAAS,CAI5B;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,gBAEC;IAED;;;;;;OAMG;IACH,8BALW,eAAe,GAAC,SAAS,QAQnC;IAED;;;OAGG;IACH,gBAFW,OAAO,aAAa,EAAE,KAAK,QAKrC;CACF"}
+235
View File
@@ -0,0 +1,235 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/Source
*/
import BaseObject from '../Object.js';
import { abstract } from '../util.js';
import { get as getProjection } from '../proj.js';
/**
* @typedef {'undefined' | 'loading' | 'ready' | 'error'} State
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
*/
/**
* A function that takes a {@link module:ol/PluggableMap~FrameState} and returns a string or
* an array of strings representing source attributions.
*
* @typedef {function(import("../PluggableMap.js").FrameState): (string|Array<string>)} Attribution
*/
/**
* A type that can be used to provide attribution information for data sources.
*
* It represents either
* * a simple string (e.g. `'© Acme Inc.'`)
* * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)
* * a function that returns a string or array of strings ({@link module:ol/source/Source~Attribution})
*
* @typedef {string|Array<string>|Attribution} AttributionLike
*/
/**
* @typedef {Object} Options
* @property {AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {import("./Source.js").State} [state='ready'] State.
* @property {boolean} [wrapX=false] WrapX.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for {@link module:ol/layer/Layer~Layer} sources.
*
* A generic `change` event is triggered when the state of the source changes.
* @abstract
* @api
*/
var Source = /** @class */ (function (_super) {
__extends(Source, _super);
/**
* @param {Options} options Source options.
*/
function Source(options) {
var _this = _super.call(this) || this;
/**
* @protected
* @type {import("../proj/Projection.js").default|null}
*/
_this.projection = getProjection(options.projection);
/**
* @private
* @type {?Attribution}
*/
_this.attributions_ = adaptAttributions(options.attributions);
/**
* @private
* @type {boolean}
*/
_this.attributionsCollapsible_ =
options.attributionsCollapsible !== undefined
? options.attributionsCollapsible
: true;
/**
* This source is currently loading data. Sources that defer loading to the
* map's tile queue never set this to `true`.
* @type {boolean}
*/
_this.loading = false;
/**
* @private
* @type {import("./Source.js").State}
*/
_this.state_ = options.state !== undefined ? options.state : 'ready';
/**
* @private
* @type {boolean}
*/
_this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
/**
* @private
* @type {boolean}
*/
_this.interpolate_ = !!options.interpolate;
/**
* @protected
* @type {function(import("../View.js").ViewOptions):void}
*/
_this.viewResolver = null;
/**
* @protected
* @type {function(Error):void}
*/
_this.viewRejector = null;
var self = _this;
/**
* @private
* @type {Promise<import("../View.js").ViewOptions>}
*/
_this.viewPromise_ = new Promise(function (resolve, reject) {
self.viewResolver = resolve;
self.viewRejector = reject;
});
return _this;
}
/**
* Get the attribution function for the source.
* @return {?Attribution} Attribution function.
* @api
*/
Source.prototype.getAttributions = function () {
return this.attributions_;
};
/**
* @return {boolean} Attributions are collapsible.
* @api
*/
Source.prototype.getAttributionsCollapsible = function () {
return this.attributionsCollapsible_;
};
/**
* Get the projection of the source.
* @return {import("../proj/Projection.js").default|null} Projection.
* @api
*/
Source.prototype.getProjection = function () {
return this.projection;
};
/**
* @abstract
* @return {Array<number>|null} Resolutions.
*/
Source.prototype.getResolutions = function () {
return abstract();
};
/**
* @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
*/
Source.prototype.getView = function () {
return this.viewPromise_;
};
/**
* Get the state of the source, see {@link import("./Source.js").State} for possible states.
* @return {import("./Source.js").State} State.
* @api
*/
Source.prototype.getState = function () {
return this.state_;
};
/**
* @return {boolean|undefined} Wrap X.
*/
Source.prototype.getWrapX = function () {
return this.wrapX_;
};
/**
* @return {boolean} Use linear interpolation when resampling.
*/
Source.prototype.getInterpolate = function () {
return this.interpolate_;
};
/**
* Refreshes the source. The source will be cleared, and data from the server will be reloaded.
* @api
*/
Source.prototype.refresh = function () {
this.changed();
};
/**
* Set the attributions of the source.
* @param {AttributionLike|undefined} attributions Attributions.
* Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution},
* or `undefined`.
* @api
*/
Source.prototype.setAttributions = function (attributions) {
this.attributions_ = adaptAttributions(attributions);
this.changed();
};
/**
* Set the state of the source.
* @param {import("./Source.js").State} state State.
*/
Source.prototype.setState = function (state) {
this.state_ = state;
this.changed();
};
return Source;
}(BaseObject));
/**
* Turns the attributions option into an attributions function.
* @param {AttributionLike|undefined} attributionLike The attribution option.
* @return {Attribution|null} An attribution function (or null).
*/
function adaptAttributions(attributionLike) {
if (!attributionLike) {
return null;
}
if (Array.isArray(attributionLike)) {
return function (frameState) {
return attributionLike;
};
}
if (typeof attributionLike === 'function') {
return attributionLike;
}
return function (frameState) {
return [attributionLike];
};
}
export default Source;
//# sourceMappingURL=Source.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Source.js","sourceRoot":"","sources":["../src/source/Source.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;GAEG;AACH,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,GAAG,I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;KACb;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAClC,OAAO,UAAU,UAAU;YACzB,OAAO,eAAe,CAAC;QACzB,CAAC,CAAC;KACH;IAED,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;QACzC,OAAO,eAAe,CAAC;KACxB;IAED,OAAO,UAAU,UAAU;QACzB,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,MAAM,CAAC"}
+99
View File
@@ -0,0 +1,99 @@
export default Stamen;
export type Options = {
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Layer name.
*/
layer: string;
/**
* Minimum zoom.
*/
minZoom?: number | undefined;
/**
* Maximum zoom.
*/
maxZoom?: number | undefined;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
*/
url?: string | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Options
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {string} layer Layer name.
* @property {number} [minZoom] Minimum zoom.
* @property {number} [maxZoom] Maximum zoom.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction]
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for the Stamen tile server.
* @api
*/
declare class Stamen extends XYZ {
/**
* @param {Options} options Stamen options.
*/
constructor(options: Options);
}
import XYZ from "./XYZ.js";
//# sourceMappingURL=Stamen.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Stamen.d.ts","sourceRoot":"","sources":["../src/source/Stamen.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;WA4Fc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANpB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAwCjB;CACF"}
+167
View File
@@ -0,0 +1,167 @@
/**
* @module ol/source/Stamen
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import XYZ from './XYZ.js';
import { ATTRIBUTION as OSM_ATTRIBUTION } from './OSM.js';
/**
* @const
* @type {Array<string>}
*/
var ATTRIBUTIONS = [
'Map tiles by <a href="https://stamen.com/" target="_blank">Stamen Design</a>, ' +
'under <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC BY' +
' 3.0</a>.',
OSM_ATTRIBUTION,
];
/**
* @type {Object<string, {extension: string, opaque: boolean}>}
*/
var LayerConfig = {
'terrain': {
extension: 'jpg',
opaque: true,
},
'terrain-background': {
extension: 'jpg',
opaque: true,
},
'terrain-labels': {
extension: 'png',
opaque: false,
},
'terrain-lines': {
extension: 'png',
opaque: false,
},
'toner-background': {
extension: 'png',
opaque: true,
},
'toner': {
extension: 'png',
opaque: true,
},
'toner-hybrid': {
extension: 'png',
opaque: false,
},
'toner-labels': {
extension: 'png',
opaque: false,
},
'toner-lines': {
extension: 'png',
opaque: false,
},
'toner-lite': {
extension: 'png',
opaque: true,
},
'watercolor': {
extension: 'jpg',
opaque: true,
},
};
/**
* @type {Object<string, {minZoom: number, maxZoom: number}>}
*/
var ProviderConfig = {
'terrain': {
minZoom: 0,
maxZoom: 18,
},
'toner': {
minZoom: 0,
maxZoom: 20,
},
'watercolor': {
minZoom: 0,
maxZoom: 18,
},
};
/**
* @typedef {Object} Options
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {string} layer Layer name.
* @property {number} [minZoom] Minimum zoom.
* @property {number} [maxZoom] Maximum zoom.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction]
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for the Stamen tile server.
* @api
*/
var Stamen = /** @class */ (function (_super) {
__extends(Stamen, _super);
/**
* @param {Options} options Stamen options.
*/
function Stamen(options) {
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
var i = options.layer.indexOf('-');
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
var providerConfig = ProviderConfig[provider];
var layerConfig = LayerConfig[options.layer];
var url = options.url !== undefined
? options.url
: 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' +
options.layer +
'/{z}/{x}/{y}.' +
layerConfig.extension;
return _super.call(this, {
attributions: ATTRIBUTIONS,
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
interpolate: interpolate,
maxZoom: options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom,
minZoom: options.minZoom != undefined ? options.minZoom : providerConfig.minZoom,
opaque: layerConfig.opaque,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
tileLoadFunction: options.tileLoadFunction,
transition: options.transition,
url: url,
wrapX: options.wrapX,
zDirection: options.zDirection,
}) || this;
}
return Stamen;
}(XYZ));
export default Stamen;
//# sourceMappingURL=Stamen.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Stamen.js","sourceRoot":"","sources":["../src/source/Stamen.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAC,WAAW,IAAI,eAAe,EAAC,MAAM,UAAU,CAAC;AAExD;;;GAGG;AACH,IAAM,YAAY,GAAG;IACnB,gFAAgF;QAC9E,oFAAoF;QACpF,WAAW;IACb,eAAe;CAChB,CAAC;AAEF;;GAEG;AACH,IAAM,WAAW,GAAG;IAClB,SAAS,EAAE;QACT,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;KACb;IACD,oBAAoB,EAAE;QACpB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;KACb;IACD,gBAAgB,EAAE;QAChB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;KACd;IACD,eAAe,EAAE;QACf,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;KACd;IACD,kBAAkB,EAAE;QAClB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;KACb;IACD,OAAO,EAAE;QACP,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;KACb;IACD,cAAc,EAAE;QACd,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;KACd;IACD,cAAc,EAAE;QACd,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;KACd;IACD,aAAa,EAAE;QACb,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;KACd;IACD,YAAY,EAAE;QACZ,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;KACb;IACD,YAAY,EAAE;QACZ,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;KACb;CACF,CAAC;AAEF;;GAEG;AACH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E,WAAW;YACxB,OAAO,EACL,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO;YACzE,OAAO,EACL,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO;YACzE,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,0BAA0B,EAAE,OAAO,CAAC,0BAA0B;YAC9D,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;IACH,aAAC;AAAD,CAAC,AA3CD,CAAqB,GAAG,GA2CvB;AAED,eAAe,MAAM,CAAC"}
+288
View File
@@ -0,0 +1,288 @@
/**
* @classdesc
* Events emitted by {@link module:ol/source/Tile~TileSource} instances are instances of this
* type.
*/
export class TileSourceEvent extends Event {
/**
* @param {string} type Type.
* @param {import("../Tile.js").default} tile The tile.
*/
constructor(type: string, tile: import("../Tile.js").default);
/**
* The tile related to the event.
* @type {import("../Tile.js").default}
* @api
*/
tile: import("../Tile.js").default;
}
export default TileSource;
/**
* *
*/
export type TileSourceOnSignature<Return> = import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> & import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> & import("../Observable").OnSignature<import("./TileEventType").TileSourceEventTypes, TileSourceEvent, Return> & import("../Observable").CombinedOnSignature<import("../Observable").EventTypes | import("../ObjectEventType").Types | import("./TileEventType").TileSourceEventTypes, Return>;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* CacheSize.
*/
cacheSize?: number | undefined;
/**
* Whether the layer is opaque.
*/
opaque?: boolean | undefined;
/**
* TilePixelRatio.
*/
tilePixelRatio?: number | undefined;
/**
* Projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* State.
*/
state?: import("./Source.js").State | undefined;
/**
* TileGrid.
*/
tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
/**
* WrapX.
*/
wrapX?: boolean | undefined;
/**
* Transition.
*/
transition?: number | undefined;
/**
* Key.
*/
key?: string | undefined;
/**
* ZDirection.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
/**
* Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
interpolate?: boolean | undefined;
};
import Event from "../events/Event.js";
/***
* @template Return
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
* import("../Observable").OnSignature<import("./TileEventType").TileSourceEventTypes, TileSourceEvent, Return> &
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
* import("./TileEventType").TileSourceEventTypes, Return>} TileSourceOnSignature
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] CacheSize.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {number} [tilePixelRatio] TilePixelRatio.
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
* @property {import("./Source.js").State} [state] State.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
* @property {boolean} [wrapX=false] WrapX.
* @property {number} [transition] Transition.
* @property {string} [key] Key.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0] ZDirection.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for sources providing images divided into a tile grid.
* @abstract
* @api
*/
declare class TileSource extends Source {
/**
* @param {Options} options SourceTile source options.
*/
constructor(options: Options);
/***
* @type {TileSourceOnSignature<import("../events").EventsKey>}
*/
on: TileSourceOnSignature<import("../events").EventsKey>;
/***
* @type {TileSourceOnSignature<import("../events").EventsKey>}
*/
once: TileSourceOnSignature<import("../events").EventsKey>;
/***
* @type {TileSourceOnSignature<void>}
*/
un: TileSourceOnSignature<void>;
/**
* @private
* @type {boolean}
*/
private opaque_;
/**
* @private
* @type {number}
*/
private tilePixelRatio_;
/**
* @type {import("../tilegrid/TileGrid.js").default|null}
*/
tileGrid: import("../tilegrid/TileGrid.js").default | null;
/**
* @protected
* @type {import("../TileCache.js").default}
*/
protected tileCache: import("../TileCache.js").default;
/**
* @protected
* @type {import("../size.js").Size}
*/
protected tmpSize: import("../size.js").Size;
/**
* @private
* @type {string}
*/
private key_;
/**
* @protected
* @type {import("../Tile.js").Options}
*/
protected tileOptions: import("../Tile.js").Options;
/**
* zDirection hint, read by the renderer. Indicates which resolution should be used
* by a renderer if the views resolution does not match any resolution of the tile source.
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
* will be used. If -1, the nearest higher resolution will be used.
* @type {number|import("../array.js").NearestDirectionFunction}
*/
zDirection: number | import("../array.js").NearestDirectionFunction;
/**
* @return {boolean} Can expire cache.
*/
canExpireCache(): boolean;
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {!Object<string, boolean>} usedTiles Used tiles.
*/
expireCache(projection: import("../proj/Projection.js").default, usedTiles: {
[x: string]: boolean;
}): void;
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {number} z Zoom level.
* @param {import("../TileRange.js").default} tileRange Tile range.
* @param {function(import("../Tile.js").default):(boolean|void)} callback Called with each
* loaded tile. If the callback returns `false`, the tile will not be
* considered loaded.
* @return {boolean} The tile range is fully covered with loaded tiles.
*/
forEachLoadedTile(projection: import("../proj/Projection.js").default, z: number, tileRange: import("../TileRange.js").default, callback: (arg0: import("../Tile.js").default) => (boolean | void)): boolean;
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {number} Gutter.
*/
getGutterForProjection(projection: import("../proj/Projection.js").default): number;
/**
* Return the key to be used for all tiles in the source.
* @return {string} The key for all tiles.
*/
getKey(): string;
/**
* Set the value to be used as the key for all tiles in the source.
* @param {string} key The key for tiles.
* @protected
*/
protected setKey(key: string): void;
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {boolean} Opaque.
*/
getOpaque(projection: import("../proj/Projection.js").default): boolean;
/**
* @abstract
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../Tile.js").default} Tile.
*/
getTile(z: number, x: number, y: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../Tile.js").default;
/**
* Return the tile grid of the tile source.
* @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
* @api
*/
getTileGrid(): import("../tilegrid/TileGrid.js").default | null;
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
*/
getTileGridForProjection(projection: import("../proj/Projection.js").default): import("../tilegrid/TileGrid.js").default;
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../TileCache.js").default} Tile cache.
* @protected
*/
protected getTileCacheForProjection(projection: import("../proj/Projection.js").default): import("../TileCache.js").default;
/**
* Get the tile pixel ratio for this source. Subclasses may override this
* method, which is meant to return a supported pixel ratio that matches the
* provided `pixelRatio` as close as possible.
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
getTilePixelRatio(pixelRatio: number): number;
/**
* @param {number} z Z.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../size.js").Size} Tile size.
*/
getTilePixelSize(z: number, pixelRatio: number, projection: import("../proj/Projection.js").default): import("../size.js").Size;
/**
* Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
* is outside the resolution and extent range of the tile grid, `null` will be
* returned.
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../proj/Projection.js").default} [opt_projection] Projection.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
* null if no tile URL should be created for the passed `tileCoord`.
*/
getTileCoordForTileUrlFunction(tileCoord: import("../tilecoord.js").TileCoord, opt_projection?: import("../proj/Projection.js").default | undefined): import("../tilecoord.js").TileCoord;
/**
* Remove all cached tiles from the source. The next render cycle will fetch new tiles.
* @api
*/
clear(): void;
/**
* Increases the cache size if needed
* @param {number} tileCount Minimum number of tiles needed.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
updateCacheSize(tileCount: number, projection: import("../proj/Projection.js").default): void;
/**
* Marks a tile coord as being used, without triggering a load.
* @abstract
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
useTile(z: number, x: number, y: number, projection: import("../proj/Projection.js").default): void;
}
import Source from "./Source.js";
//# sourceMappingURL=Tile.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Tile.d.ts","sourceRoot":"","sources":["../src/source/Tile.js"],"names":[],"mappings":"AAsXA;;;;GAIG;AACH;IACE;;;OAGG;IACH,kBAHW,MAAM,QACN,OAAO,YAAY,EAAE,OAAO,EAWtC;IANC;;;;OAIG;IACH,MAHU,OAAO,YAAY,EAAE,OAAO,CAGtB;CAEnB;;;;;4CAvXY,OAAO,eAAe,EAAE,WAAW,CAAC,OAAO,eAAe,EAAE,UAAU,EAAE,OAAO,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC,GACjI,OAAW,eAAe,EAAE,WAAW,CAAC,OAAO,oBAAoB,EAAE,KAAK,EAAE,OAAO,WAAW,EAAE,WAAW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 -0,0 +1,376 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/Tile
*/
import Event from '../events/Event.js';
import Source from './Source.js';
import TileCache from '../TileCache.js';
import TileState from '../TileState.js';
import { abstract } from '../util.js';
import { assert } from '../asserts.js';
import { equivalent } from '../proj.js';
import { getKeyZXY, withinExtentAndZ } from '../tilecoord.js';
import { getForProjection as getTileGridForProjection, wrapX, } from '../tilegrid.js';
import { scale as scaleSize, toSize } from '../size.js';
/***
* @template Return
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
* import("../Observable").OnSignature<import("./TileEventType").TileSourceEventTypes, TileSourceEvent, Return> &
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
* import("./TileEventType").TileSourceEventTypes, Return>} TileSourceOnSignature
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] CacheSize.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {number} [tilePixelRatio] TilePixelRatio.
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
* @property {import("./Source.js").State} [state] State.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
* @property {boolean} [wrapX=false] WrapX.
* @property {number} [transition] Transition.
* @property {string} [key] Key.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0] ZDirection.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for sources providing images divided into a tile grid.
* @abstract
* @api
*/
var TileSource = /** @class */ (function (_super) {
__extends(TileSource, _super);
/**
* @param {Options} options SourceTile source options.
*/
function TileSource(options) {
var _this = _super.call(this, {
attributions: options.attributions,
attributionsCollapsible: options.attributionsCollapsible,
projection: options.projection,
state: options.state,
wrapX: options.wrapX,
interpolate: options.interpolate,
}) || this;
/***
* @type {TileSourceOnSignature<import("../events").EventsKey>}
*/
_this.on;
/***
* @type {TileSourceOnSignature<import("../events").EventsKey>}
*/
_this.once;
/***
* @type {TileSourceOnSignature<void>}
*/
_this.un;
/**
* @private
* @type {boolean}
*/
_this.opaque_ = options.opaque !== undefined ? options.opaque : false;
/**
* @private
* @type {number}
*/
_this.tilePixelRatio_ =
options.tilePixelRatio !== undefined ? options.tilePixelRatio : 1;
/**
* @type {import("../tilegrid/TileGrid.js").default|null}
*/
_this.tileGrid = options.tileGrid !== undefined ? options.tileGrid : null;
var tileSize = [256, 256];
if (_this.tileGrid) {
toSize(_this.tileGrid.getTileSize(_this.tileGrid.getMinZoom()), tileSize);
}
/**
* @protected
* @type {import("../TileCache.js").default}
*/
_this.tileCache = new TileCache(options.cacheSize || 0);
/**
* @protected
* @type {import("../size.js").Size}
*/
_this.tmpSize = [0, 0];
/**
* @private
* @type {string}
*/
_this.key_ = options.key || '';
/**
* @protected
* @type {import("../Tile.js").Options}
*/
_this.tileOptions = {
transition: options.transition,
interpolate: options.interpolate,
};
/**
* zDirection hint, read by the renderer. Indicates which resolution should be used
* by a renderer if the views resolution does not match any resolution of the tile source.
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
* will be used. If -1, the nearest higher resolution will be used.
* @type {number|import("../array.js").NearestDirectionFunction}
*/
_this.zDirection = options.zDirection ? options.zDirection : 0;
return _this;
}
/**
* @return {boolean} Can expire cache.
*/
TileSource.prototype.canExpireCache = function () {
return this.tileCache.canExpireCache();
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {!Object<string, boolean>} usedTiles Used tiles.
*/
TileSource.prototype.expireCache = function (projection, usedTiles) {
var tileCache = this.getTileCacheForProjection(projection);
if (tileCache) {
tileCache.expireCache(usedTiles);
}
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {number} z Zoom level.
* @param {import("../TileRange.js").default} tileRange Tile range.
* @param {function(import("../Tile.js").default):(boolean|void)} callback Called with each
* loaded tile. If the callback returns `false`, the tile will not be
* considered loaded.
* @return {boolean} The tile range is fully covered with loaded tiles.
*/
TileSource.prototype.forEachLoadedTile = function (projection, z, tileRange, callback) {
var tileCache = this.getTileCacheForProjection(projection);
if (!tileCache) {
return false;
}
var covered = true;
var tile, tileCoordKey, loaded;
for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
tileCoordKey = getKeyZXY(z, x, y);
loaded = false;
if (tileCache.containsKey(tileCoordKey)) {
tile = /** @type {!import("../Tile.js").default} */ (tileCache.get(tileCoordKey));
loaded = tile.getState() === TileState.LOADED;
if (loaded) {
loaded = callback(tile) !== false;
}
}
if (!loaded) {
covered = false;
}
}
}
return covered;
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {number} Gutter.
*/
TileSource.prototype.getGutterForProjection = function (projection) {
return 0;
};
/**
* Return the key to be used for all tiles in the source.
* @return {string} The key for all tiles.
*/
TileSource.prototype.getKey = function () {
return this.key_;
};
/**
* Set the value to be used as the key for all tiles in the source.
* @param {string} key The key for tiles.
* @protected
*/
TileSource.prototype.setKey = function (key) {
if (this.key_ !== key) {
this.key_ = key;
this.changed();
}
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {boolean} Opaque.
*/
TileSource.prototype.getOpaque = function (projection) {
return this.opaque_;
};
/**
* @return {Array<number>|null} Resolutions.
*/
TileSource.prototype.getResolutions = function () {
if (!this.tileGrid) {
return null;
}
return this.tileGrid.getResolutions();
};
/**
* @abstract
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../Tile.js").default} Tile.
*/
TileSource.prototype.getTile = function (z, x, y, pixelRatio, projection) {
return abstract();
};
/**
* Return the tile grid of the tile source.
* @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
* @api
*/
TileSource.prototype.getTileGrid = function () {
return this.tileGrid;
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
*/
TileSource.prototype.getTileGridForProjection = function (projection) {
if (!this.tileGrid) {
return getTileGridForProjection(projection);
}
else {
return this.tileGrid;
}
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../TileCache.js").default} Tile cache.
* @protected
*/
TileSource.prototype.getTileCacheForProjection = function (projection) {
var sourceProjection = this.getProjection();
assert(sourceProjection === null || equivalent(sourceProjection, projection), 68 // A VectorTile source can only be rendered if it has a projection compatible with the view projection.
);
return this.tileCache;
};
/**
* Get the tile pixel ratio for this source. Subclasses may override this
* method, which is meant to return a supported pixel ratio that matches the
* provided `pixelRatio` as close as possible.
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
TileSource.prototype.getTilePixelRatio = function (pixelRatio) {
return this.tilePixelRatio_;
};
/**
* @param {number} z Z.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../size.js").Size} Tile size.
*/
TileSource.prototype.getTilePixelSize = function (z, pixelRatio, projection) {
var tileGrid = this.getTileGridForProjection(projection);
var tilePixelRatio = this.getTilePixelRatio(pixelRatio);
var tileSize = toSize(tileGrid.getTileSize(z), this.tmpSize);
if (tilePixelRatio == 1) {
return tileSize;
}
else {
return scaleSize(tileSize, tilePixelRatio, this.tmpSize);
}
};
/**
* Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
* is outside the resolution and extent range of the tile grid, `null` will be
* returned.
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../proj/Projection.js").default} [opt_projection] Projection.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
* null if no tile URL should be created for the passed `tileCoord`.
*/
TileSource.prototype.getTileCoordForTileUrlFunction = function (tileCoord, opt_projection) {
var projection = opt_projection !== undefined ? opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection);
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = wrapX(tileGrid, tileCoord, projection);
}
return withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
};
/**
* Remove all cached tiles from the source. The next render cycle will fetch new tiles.
* @api
*/
TileSource.prototype.clear = function () {
this.tileCache.clear();
};
TileSource.prototype.refresh = function () {
this.clear();
_super.prototype.refresh.call(this);
};
/**
* Increases the cache size if needed
* @param {number} tileCount Minimum number of tiles needed.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
TileSource.prototype.updateCacheSize = function (tileCount, projection) {
var tileCache = this.getTileCacheForProjection(projection);
if (tileCount > tileCache.highWaterMark) {
tileCache.highWaterMark = tileCount;
}
};
/**
* Marks a tile coord as being used, without triggering a load.
* @abstract
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
TileSource.prototype.useTile = function (z, x, y, projection) { };
return TileSource;
}(Source));
/**
* @classdesc
* Events emitted by {@link module:ol/source/Tile~TileSource} instances are instances of this
* type.
*/
var TileSourceEvent = /** @class */ (function (_super) {
__extends(TileSourceEvent, _super);
/**
* @param {string} type Type.
* @param {import("../Tile.js").default} tile The tile.
*/
function TileSourceEvent(type, tile) {
var _this = _super.call(this, type) || this;
/**
* The tile related to the event.
* @type {import("../Tile.js").default}
* @api
*/
_this.tile = tile;
return _this;
}
return TileSourceEvent;
}(Event));
export { TileSourceEvent };
export default TileSource;
//# sourceMappingURL=Tile.js.map
+1
View File
File diff suppressed because one or more lines are too long
+204
View File
@@ -0,0 +1,204 @@
export default TileArcGISRest;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* ArcGIS Rest parameters. This field is optional. Service defaults will be
* used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by
* default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`,
* and `IMAGESR` will be set dynamically. Set `LAYERS` to
* override the default service layer visibility. See
* https://developers.arcgis.com/rest/services-reference/export-map.htm
* for further reference.
*/
params?: {
[x: string]: any;
} | undefined;
/**
* Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
*/
hidpi?: boolean | undefined;
/**
* Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection
* extent, the grid will be based on that; if not, a grid based on a global
* extent with origin at 0,0 will be used.
*/
tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
/**
* Projection. Default is the view projection.
* The projection code must contain a numeric end portion separated by :
* or the entire code must form a valid ArcGIS SpatialReference definition.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Optional function to load a tile given a URL.
* The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* ArcGIS Rest service URL for a Map Service or Image Service. The
* url should include /MapServer or /ImageServer.
*/
url?: string | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Duration of the opacity transition for rendering. To disable the opacity
* transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* ArcGIS Rest service urls. Use this instead of `url` when the ArcGIS
* Service supports multiple urls for export requests.
*/
urls?: string[] | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service defaults will be
* used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by
* default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`,
* and `IMAGESR` will be set dynamically. Set `LAYERS` to
* override the default service layer visibility. See
* https://developers.arcgis.com/rest/services-reference/export-map.htm
* for further reference.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection
* extent, the grid will be based on that; if not, a grid based on a global
* extent with origin at 0,0 will be used.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* The projection code must contain a numeric end portion separated by :
* or the entire code must form a valid ArcGIS SpatialReference definition.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL.
* The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The
* url should include /MapServer or /ImageServer.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering. To disable the opacity
* transition, pass `transition: 0`.
* @property {Array<string>} [urls] ArcGIS Rest service urls. Use this instead of `url` when the ArcGIS
* Service supports multiple urls for export requests.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for tile data from ArcGIS Rest services. Map and Image
* Services are supported.
*
* For cached ArcGIS services, better performance is available using the
* {@link module:ol/source/XYZ~XYZ} data source.
* @api
*/
declare class TileArcGISRest extends TileImage {
/**
* @param {Options} [opt_options] Tile ArcGIS Rest options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {!Object}
*/
private params_;
/**
* @private
* @type {boolean}
*/
private hidpi_;
/**
* @private
* @type {import("../extent.js").Extent}
*/
private tmpExtent_;
/**
* @private
* @return {string} The key for the current params.
*/
private getKeyForParams_;
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
getParams(): any;
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../size.js").Size} tileSize Tile size.
* @param {import("../extent.js").Extent} tileExtent Tile extent.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string|undefined} Request URL.
* @private
*/
private getRequestUrl_;
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
updateParams(params: any): void;
}
import TileImage from "./TileImage.js";
//# sourceMappingURL=TileArcGISRest.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileArcGISRest.d.ts","sourceRoot":"","sources":["../src/source/TileArcGISRest.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAxBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,+CA4CC;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"}
+240
View File
@@ -0,0 +1,240 @@
/**
* @module ol/source/TileArcGISRest
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import TileImage from './TileImage.js';
import { appendParams } from '../uri.js';
import { assign } from '../obj.js';
import { createEmpty } from '../extent.js';
import { modulo } from '../math.js';
import { scale as scaleSize, toSize } from '../size.js';
import { hash as tileCoordHash } from '../tilecoord.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service defaults will be
* used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by
* default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`,
* and `IMAGESR` will be set dynamically. Set `LAYERS` to
* override the default service layer visibility. See
* https://developers.arcgis.com/rest/services-reference/export-map.htm
* for further reference.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection
* extent, the grid will be based on that; if not, a grid based on a global
* extent with origin at 0,0 will be used.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* The projection code must contain a numeric end portion separated by :
* or the entire code must form a valid ArcGIS SpatialReference definition.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL.
* The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The
* url should include /MapServer or /ImageServer.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering. To disable the opacity
* transition, pass `transition: 0`.
* @property {Array<string>} [urls] ArcGIS Rest service urls. Use this instead of `url` when the ArcGIS
* Service supports multiple urls for export requests.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for tile data from ArcGIS Rest services. Map and Image
* Services are supported.
*
* For cached ArcGIS services, better performance is available using the
* {@link module:ol/source/XYZ~XYZ} data source.
* @api
*/
var TileArcGISRest = /** @class */ (function (_super) {
__extends(TileArcGISRest, _super);
/**
* @param {Options} [opt_options] Tile ArcGIS Rest options.
*/
function TileArcGISRest(opt_options) {
var _this = this;
var options = opt_options ? opt_options : {};
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
interpolate: interpolate,
projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction,
url: options.url,
urls: options.urls,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition,
zDirection: options.zDirection,
}) || this;
/**
* @private
* @type {!Object}
*/
_this.params_ = options.params || {};
/**
* @private
* @type {boolean}
*/
_this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
/**
* @private
* @type {import("../extent.js").Extent}
*/
_this.tmpExtent_ = createEmpty();
_this.setKey(_this.getKeyForParams_());
return _this;
}
/**
* @private
* @return {string} The key for the current params.
*/
TileArcGISRest.prototype.getKeyForParams_ = function () {
var i = 0;
var res = [];
for (var key in this.params_) {
res[i++] = key + '-' + this.params_[key];
}
return res.join('/');
};
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
TileArcGISRest.prototype.getParams = function () {
return this.params_;
};
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../size.js").Size} tileSize Tile size.
* @param {import("../extent.js").Extent} tileExtent Tile extent.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string|undefined} Request URL.
* @private
*/
TileArcGISRest.prototype.getRequestUrl_ = function (tileCoord, tileSize, tileExtent, pixelRatio, projection, params) {
var urls = this.urls;
if (!urls) {
return undefined;
}
// ArcGIS Server only wants the numeric portion of the projection ID.
// (if there is no numeric portion the entire projection code must
// form a valid ArcGIS SpatialReference definition).
var srid = projection
.getCode()
.split(/:(?=\d+$)/)
.pop();
params['SIZE'] = tileSize[0] + ',' + tileSize[1];
params['BBOX'] = tileExtent.join(',');
params['BBOXSR'] = srid;
params['IMAGESR'] = srid;
params['DPI'] = Math.round(params['DPI'] ? params['DPI'] * pixelRatio : 90 * pixelRatio);
var url;
if (urls.length == 1) {
url = urls[0];
}
else {
var index = modulo(tileCoordHash(tileCoord), urls.length);
url = urls[index];
}
var modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
return appendParams(modifiedUrl, params);
};
/**
* Get the tile pixel ratio for this source.
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
TileArcGISRest.prototype.getTilePixelRatio = function (pixelRatio) {
return this.hidpi_ ? pixelRatio : 1;
};
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
TileArcGISRest.prototype.updateParams = function (params) {
assign(this.params_, params);
this.setKey(this.getKeyForParams_());
};
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord The tile coordinate
* @param {number} pixelRatio The pixel ratio
* @param {import("../proj/Projection.js").default} projection The projection
* @return {string|undefined} The tile URL
* @override
*/
TileArcGISRest.prototype.tileUrlFunction = function (tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
if (pixelRatio != 1 && !this.hidpi_) {
pixelRatio = 1;
}
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
if (pixelRatio != 1) {
tileSize = scaleSize(tileSize, pixelRatio, this.tmpSize);
}
// Apply default params and override with user specified values.
var baseParams = {
'F': 'image',
'FORMAT': 'PNG32',
'TRANSPARENT': true,
};
assign(baseParams, this.params_);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent, pixelRatio, projection, baseParams);
};
return TileArcGISRest;
}(TileImage));
export default TileArcGISRest;
//# sourceMappingURL=TileArcGISRest.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileArcGISRest.js","sourceRoot":"","sources":["../src/source/TileArcGISRest.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,KAAK,IAAI,SAAS,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,IAAI,IAAI,aAAa,EAAC,MAA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;QAED,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE;YACpD,OAAO,SAAS,CAAC;SAClB;QAED,IAAI,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACnC,UAAU,GAAG,CAAC,CAAC;SAChB;QAED,IAAM,UAAU,GAAG,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3E,IAAI,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAExE,IAAI,UAAU,IAAI,CAAC,EAAE;YACnB,QAAQ,GAAG,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAC1D;QAED,gEAAgE;QAChE,IAAM,UAAU,GAAG;YACjB,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,OAAO;YACjB,aAAa,EAAE,IAAI;SACpB,CAAC;QACF,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,IAAI,CAAC,cAAc,CACxB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,CACX,CAAC;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA9LD,CAA6B,SAAS,GA8LrC;AAED,eAAe,cAAc,CAAC"}
+53
View File
@@ -0,0 +1,53 @@
export default TileDebug;
export type Options = {
/**
* Optional projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Tile grid.
*/
tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Set to `1` when debugging `VectorTile` sources with a default configuration.
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
/**
* Template for labeling the tiles.
* Should include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
*/
template?: string | undefined;
};
/**
* @typedef {Object} Options
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Optional projection.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Set to `1` when debugging `VectorTile` sources with a default configuration.
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
* @property {string} [template='z:{z} x:{x} y:{y}'] Template for labeling the tiles.
* Should include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
*/
/**
* @classdesc
* A pseudo tile source, which does not fetch tiles from a server, but renders
* a grid outline for the tile grid/projection along with the coordinates for
* each tile. See examples/canvas-tiles for an example.
* @api
*/
declare class TileDebug extends XYZ {
/**
* @param {Options} [opt_options] Debug tile options.
*/
constructor(opt_options?: Options | undefined);
}
import XYZ from "./XYZ.js";
//# sourceMappingURL=TileDebug.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileDebug.d.ts","sourceRoot":"","sources":["../src/source/TileDebug.js"],"names":[],"mappings":";;;;;iBAUc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;AAFjD;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,+CAmCC;CACF"}
+81
View File
@@ -0,0 +1,81 @@
/**
* @module ol/source/TileDebug
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import XYZ from './XYZ.js';
import { createCanvasContext2D } from '../dom.js';
import { toSize } from '../size.js';
/**
* @typedef {Object} Options
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Optional projection.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Set to `1` when debugging `VectorTile` sources with a default configuration.
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
* @property {string} [template='z:{z} x:{x} y:{y}'] Template for labeling the tiles.
* Should include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
*/
/**
* @classdesc
* A pseudo tile source, which does not fetch tiles from a server, but renders
* a grid outline for the tile grid/projection along with the coordinates for
* each tile. See examples/canvas-tiles for an example.
* @api
*/
var TileDebug = /** @class */ (function (_super) {
__extends(TileDebug, _super);
/**
* @param {Options} [opt_options] Debug tile options.
*/
function TileDebug(opt_options) {
var _this = this;
/**
* @type {Options}
*/
var options = opt_options || {};
_this = _super.call(this, {
opaque: false,
projection: options.projection,
tileGrid: options.tileGrid,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
zDirection: options.zDirection,
url: options.template || 'z:{z} x:{x} y:{y}',
tileLoadFunction: function (tile, text) {
var z = tile.getTileCoord()[0];
var tileSize = toSize(_this.tileGrid.getTileSize(z));
var context = createCanvasContext2D(tileSize[0], tileSize[1]);
context.strokeStyle = 'grey';
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
context.fillStyle = 'grey';
context.strokeStyle = 'white';
context.textAlign = 'center';
context.textBaseline = 'middle';
context.font = '24px sans-serif';
context.lineWidth = 4;
context.strokeText(text, tileSize[0] / 2, tileSize[1] / 2, tileSize[0]);
context.fillText(text, tileSize[0] / 2, tileSize[1] / 2, tileSize[0]);
/** @type {import("../ImageTile.js").default} */ (tile).setImage(context.canvas);
},
}) || this;
return _this;
}
return TileDebug;
}(XYZ));
export default TileDebug;
//# sourceMappingURL=TileDebug.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileDebug.js","sourceRoot":"","sources":["../src/source/TileDebug.js"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAElC;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH;IAAwB,6BAAG;IACzB;;OAEG;IACH,mBAAY,WAAW;QAAvB,iBAmCC;QAlCC;;WAEG;QACH,IAAM,OAAO,GAAG,WAAW,IAAI,EAAE,CAAC;gBAElC,kBAAM;YACJ,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACzD,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,GAAG,EAAE,OAAO,CAAC,QAAQ,IAAI,mBAAmB;YAC5C,gBAAgB,EAAE,UAAC,IAAI,EAAE,IAAI;gBAC3B,IAAM,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAM,QAAQ,GAAG,MAAM,CAAC,KAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtD,IAAM,OAAO,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEhE,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;gBAC7B,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;gBAEnE,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;gBAC3B,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC;gBAC9B,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC;gBAC7B,OAAO,CAAC,YAAY,GAAG,QAAQ,CAAC;gBAChC,OAAO,CAAC,IAAI,GAAG,iBAAiB,CAAC;gBACjC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;gBACtB,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxE,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEtE,gDAAgD,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAC9D,OAAO,CAAC,MAAM,CACf,CAAC;YACJ,CAAC;SACF,CAAC;;IACJ,CAAC;IACH,gBAAC;AAAD,CAAC,AAxCD,CAAwB,GAAG,GAwC1B;AAED,eAAe,SAAS,CAAC"}
+8
View File
@@ -0,0 +1,8 @@
declare namespace _default {
const TILELOADSTART: string;
const TILELOADEND: string;
const TILELOADERROR: string;
}
export default _default;
export type TileSourceEventTypes = 'tileloadstart' | 'tileloadend' | 'tileloaderror';
//# sourceMappingURL=TileEventType.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileEventType.d.ts","sourceRoot":"","sources":["../src/source/TileEventType.js"],"names":[],"mappings":";;;;;;mCAgCa,eAAe,GAAC,aAAa,GAAC,eAAe"}
+31
View File
@@ -0,0 +1,31 @@
/**
* @module ol/source/TileEventType
*/
/**
* @enum {string}
*/
export default {
/**
* Triggered when a tile starts loading.
* @event module:ol/source/Tile.TileSourceEvent#tileloadstart
* @api
*/
TILELOADSTART: 'tileloadstart',
/**
* Triggered when a tile finishes loading, either when its data is loaded,
* or when loading was aborted because the tile is no longer needed.
* @event module:ol/source/Tile.TileSourceEvent#tileloadend
* @api
*/
TILELOADEND: 'tileloadend',
/**
* Triggered if tile loading results in an error.
* @event module:ol/source/Tile.TileSourceEvent#tileloaderror
* @api
*/
TILELOADERROR: 'tileloaderror',
};
/**
* @typedef {'tileloadstart'|'tileloadend'|'tileloaderror'} TileSourceEventTypes
*/
//# sourceMappingURL=TileEventType.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileEventType.js","sourceRoot":"","sources":["../src/source/TileEventType.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAe;IACb;;;;OAIG;IACH,aAAa,EAAE,eAAe;IAE9B;;;;;OAKG;IACH,WAAW,EAAE,aAAa;IAE1B;;;;OAIG;IACH,aAAa,EAAE,eAAe;CAC/B,CAAC;AAEF;;GAEG"}
+257
View File
@@ -0,0 +1,257 @@
export default TileImage;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Whether the layer is opaque.
*/
opaque?: boolean | undefined;
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Source state.
*/
state?: import("./Source.js").State | undefined;
/**
* Class used to instantiate image tiles.
* Default is {@link module :ol/ImageTile~ImageTile}.
*/
tileClass?: typeof ImageTile | undefined;
/**
* Tile grid.
*/
tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* The pixel ratio used by the tile service. For example, if the tile
* service advertizes 256px by 256px tiles but actually sends 512px
* by 512px images (for retina/hidpi devices) then `tilePixelRatio`
* should be set to `2`.
*/
tilePixelRatio?: number | undefined;
/**
* Optional function to get tile URL given a tile coordinate and the projection.
*/
tileUrlFunction?: import("../Tile.js").UrlFunction | undefined;
/**
* URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
* used instead of defining each one separately in the `urls` option.
*/
url?: string | undefined;
/**
* An array of URL templates.
*/
urls?: string[] | undefined;
/**
* Whether to wrap the world horizontally. The default, is to
* request out-of-bounds tiles from the server. When set to `false`, only one
* world will be rendered. When set to `true`, tiles will be requested for one
* world only, but they will be wrapped horizontally to render multiple worlds.
*/
wrapX?: boolean | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* Optional tile key for proper cache fetching
*/
key?: string | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("./Source.js").State} [state] Source state.
* @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~ImageTile}.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service. For example, if the tile
* service advertizes 256px by 256px tiles but actually sends 512px
* by 512px images (for retina/hidpi devices) then `tilePixelRatio`
* should be set to `2`.
* @property {import("../Tile.js").UrlFunction} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection.
* @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
* used instead of defining each one separately in the `urls` option.
* @property {Array<string>} [urls] An array of URL templates.
* @property {boolean} [wrapX] Whether to wrap the world horizontally. The default, is to
* request out-of-bounds tiles from the server. When set to `false`, only one
* world will be rendered. When set to `true`, tiles will be requested for one
* world only, but they will be wrapped horizontally to render multiple worlds.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {string} [key] Optional tile key for proper cache fetching
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Base class for sources providing images divided into a tile grid.
*
* @fires import("./Tile.js").TileSourceEvent
* @api
*/
declare class TileImage extends UrlTile {
/**
* @param {!Options} options Image tile options.
*/
constructor(options: Options);
/**
* @protected
* @type {?string}
*/
protected crossOrigin: string | null;
/**
* @protected
* @type {typeof ImageTile}
*/
protected tileClass: typeof ImageTile;
/**
* @protected
* @type {!Object<string, TileCache>}
*/
protected tileCacheForProjection: {
[x: string]: TileCache;
};
/**
* @protected
* @type {!Object<string, import("../tilegrid/TileGrid.js").default>}
*/
protected tileGridForProjection: {
[x: string]: import("../tilegrid/TileGrid.js").default;
};
/**
* @private
* @type {number|undefined}
*/
private reprojectionErrorThreshold_;
/**
* @private
* @type {boolean}
*/
private renderReprojectionEdges_;
/**
* @return {number} Gutter.
*/
getGutter(): number;
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {string} key The key set on the tile.
* @return {!ImageTile} Tile.
* @private
*/
private createTile_;
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!(ImageTile|ReprojTile)} Tile.
*/
getTile(z: number, x: number, y: number, pixelRatio: number, projection: import("../proj/Projection.js").default): (ImageTile | ReprojTile);
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {!import("../proj/Projection.js").default} projection Projection.
* @return {!(ImageTile|ReprojTile)} Tile.
* @protected
*/
protected getTileInternal(z: number, x: number, y: number, pixelRatio: number, projection: import("../proj/Projection.js").default): (ImageTile | ReprojTile);
/**
* Sets whether to render reprojection edges or not (usually for debugging).
* @param {boolean} render Render the edges.
* @api
*/
setRenderReprojectionEdges(render: boolean): void;
/**
* Sets the tile grid to use when reprojecting the tiles to the given
* projection instead of the default tile grid for the projection.
*
* This can be useful when the default tile grid cannot be created
* (e.g. projection has no extent defined) or
* for optimization reasons (custom tile size, resolutions, ...).
*
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
* @api
*/
setTileGridForProjection(projection: import("../proj.js").ProjectionLike, tilegrid: import("../tilegrid/TileGrid.js").default): void;
}
import ImageTile from "../ImageTile.js";
import UrlTile from "./UrlTile.js";
import TileCache from "../TileCache.js";
import ReprojTile from "../reproj/Tile.js";
//# sourceMappingURL=TileImage.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileImage.d.ts","sourceRoot":"","sources":["../src/source/TileImage.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Bc,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAZjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,qBAFY,OAAO,EAoElB;IArCC;;;OAGG;IACH,uBAFW,MAAM,QAG+C;IAEhE;;;OAGG;IACH,qBAFU,gBAAgB,CAGuC;IAEjE;;;OAGG;IACH;YAFkB,MAAM,GAAE,SAAS;MAEH;IAEhC;;;OAGG;IACH;YAFkB,MAAM,GAAE,OAAO,yBAAyB,EAAE,OAAO;MAEpC;IAE/B;;;OAGG;IACH,oCAAqE;IAErE;;;OAGG;IACH,iCAAqC;IA2DvC;;OAEG;IACH,aAFY,MAAM,CAIjB;IA0ED;;;;;;;;;OASG;IACH,oBAoBC;IAED;;;;;;;OAOG;IACH,WAPW,MAAM,KACN,MAAM,KACN,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACrC,CAAC,SAAS,GAAC,UAAU,CAAC,CA+DlC;IAED;;;;;;;;OAQG;IACH,6BARW,MAAM,KACN,MAAM,KACN,MAAM,cACN,MAAM,cACL,OAAO,uBAAuB,EAAE,OAAO,GACtC,CAAC,SAAS,GAAC,UAAU,CAAC,CA+BlC;IAED;;;;OAIG;IACH,mCAHW,OAAO,QAejB;IAED;;;;;;;;;;;OAWG;IACH,qCAJW,OAAO,YAAY,EAAE,cAAc,YACnC,OAAO,yBAAyB,EAAE,OAAO,QAanD;CACF"}
+429
View File
@@ -0,0 +1,429 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/source/TileImage
*/
import EventType from '../events/EventType.js';
import ImageTile from '../ImageTile.js';
import ReprojTile from '../reproj/Tile.js';
import TileCache from '../TileCache.js';
import TileState from '../TileState.js';
import UrlTile from './UrlTile.js';
import { ENABLE_RASTER_REPROJECTION } from '../reproj/common.js';
import { equivalent, get as getProjection } from '../proj.js';
import { getKey, getKeyZXY } from '../tilecoord.js';
import { getForProjection as getTileGridForProjection } from '../tilegrid.js';
import { getUid } from '../util.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {boolean} [opaque=false] Whether the layer is opaque.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {import("./Source.js").State} [state] Source state.
* @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~ImageTile}.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service. For example, if the tile
* service advertizes 256px by 256px tiles but actually sends 512px
* by 512px images (for retina/hidpi devices) then `tilePixelRatio`
* should be set to `2`.
* @property {import("../Tile.js").UrlFunction} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection.
* @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
* used instead of defining each one separately in the `urls` option.
* @property {Array<string>} [urls] An array of URL templates.
* @property {boolean} [wrapX] Whether to wrap the world horizontally. The default, is to
* request out-of-bounds tiles from the server. When set to `false`, only one
* world will be rendered. When set to `true`, tiles will be requested for one
* world only, but they will be wrapped horizontally to render multiple worlds.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {string} [key] Optional tile key for proper cache fetching
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Base class for sources providing images divided into a tile grid.
*
* @fires import("./Tile.js").TileSourceEvent
* @api
*/
var TileImage = /** @class */ (function (_super) {
__extends(TileImage, _super);
/**
* @param {!Options} options Image tile options.
*/
function TileImage(options) {
var _this = this;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
opaque: options.opaque,
projection: options.projection,
state: options.state,
tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction
? options.tileLoadFunction
: defaultTileLoadFunction,
tilePixelRatio: options.tilePixelRatio,
tileUrlFunction: options.tileUrlFunction,
url: options.url,
urls: options.urls,
wrapX: options.wrapX,
transition: options.transition,
interpolate: interpolate,
key: options.key,
attributionsCollapsible: options.attributionsCollapsible,
zDirection: options.zDirection,
}) || this;
/**
* @protected
* @type {?string}
*/
_this.crossOrigin =
options.crossOrigin !== undefined ? options.crossOrigin : null;
/**
* @protected
* @type {typeof ImageTile}
*/
_this.tileClass =
options.tileClass !== undefined ? options.tileClass : ImageTile;
/**
* @protected
* @type {!Object<string, TileCache>}
*/
_this.tileCacheForProjection = {};
/**
* @protected
* @type {!Object<string, import("../tilegrid/TileGrid.js").default>}
*/
_this.tileGridForProjection = {};
/**
* @private
* @type {number|undefined}
*/
_this.reprojectionErrorThreshold_ = options.reprojectionErrorThreshold;
/**
* @private
* @type {boolean}
*/
_this.renderReprojectionEdges_ = false;
return _this;
}
/**
* @return {boolean} Can expire cache.
*/
TileImage.prototype.canExpireCache = function () {
if (!ENABLE_RASTER_REPROJECTION) {
return _super.prototype.canExpireCache.call(this);
}
if (this.tileCache.canExpireCache()) {
return true;
}
else {
for (var key in this.tileCacheForProjection) {
if (this.tileCacheForProjection[key].canExpireCache()) {
return true;
}
}
}
return false;
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {!Object<string, boolean>} usedTiles Used tiles.
*/
TileImage.prototype.expireCache = function (projection, usedTiles) {
if (!ENABLE_RASTER_REPROJECTION) {
_super.prototype.expireCache.call(this, projection, usedTiles);
return;
}
var usedTileCache = this.getTileCacheForProjection(projection);
this.tileCache.expireCache(this.tileCache == usedTileCache ? usedTiles : {});
for (var id in this.tileCacheForProjection) {
var tileCache = this.tileCacheForProjection[id];
tileCache.expireCache(tileCache == usedTileCache ? usedTiles : {});
}
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {number} Gutter.
*/
TileImage.prototype.getGutterForProjection = function (projection) {
if (ENABLE_RASTER_REPROJECTION &&
this.getProjection() &&
projection &&
!equivalent(this.getProjection(), projection)) {
return 0;
}
else {
return this.getGutter();
}
};
/**
* @return {number} Gutter.
*/
TileImage.prototype.getGutter = function () {
return 0;
};
/**
* Return the key to be used for all tiles in the source.
* @return {string} The key for all tiles.
*/
TileImage.prototype.getKey = function () {
var key = _super.prototype.getKey.call(this);
if (!this.getInterpolate()) {
key += ':disable-interpolation';
}
return key;
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {boolean} Opaque.
*/
TileImage.prototype.getOpaque = function (projection) {
if (ENABLE_RASTER_REPROJECTION &&
this.getProjection() &&
projection &&
!equivalent(this.getProjection(), projection)) {
return false;
}
else {
return _super.prototype.getOpaque.call(this, projection);
}
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
*/
TileImage.prototype.getTileGridForProjection = function (projection) {
if (!ENABLE_RASTER_REPROJECTION) {
return _super.prototype.getTileGridForProjection.call(this, projection);
}
var thisProj = this.getProjection();
if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
return this.tileGrid;
}
else {
var projKey = getUid(projection);
if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] =
getTileGridForProjection(projection);
}
return this.tileGridForProjection[projKey];
}
};
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../TileCache.js").default} Tile cache.
*/
TileImage.prototype.getTileCacheForProjection = function (projection) {
if (!ENABLE_RASTER_REPROJECTION) {
return _super.prototype.getTileCacheForProjection.call(this, projection);
}
var thisProj = this.getProjection();
if (!thisProj || equivalent(thisProj, projection)) {
return this.tileCache;
}
else {
var projKey = getUid(projection);
if (!(projKey in this.tileCacheForProjection)) {
this.tileCacheForProjection[projKey] = new TileCache(this.tileCache.highWaterMark);
}
return this.tileCacheForProjection[projKey];
}
};
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {string} key The key set on the tile.
* @return {!ImageTile} Tile.
* @private
*/
TileImage.prototype.createTile_ = function (z, x, y, pixelRatio, projection, key) {
var tileCoord = [z, x, y];
var urlTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection);
var tileUrl = urlTileCoord
? this.tileUrlFunction(urlTileCoord, pixelRatio, projection)
: undefined;
var tile = new this.tileClass(tileCoord, tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY, tileUrl !== undefined ? tileUrl : '', this.crossOrigin, this.tileLoadFunction, this.tileOptions);
tile.key = key;
tile.addEventListener(EventType.CHANGE, this.handleTileChange.bind(this));
return tile;
};
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!(ImageTile|ReprojTile)} Tile.
*/
TileImage.prototype.getTile = function (z, x, y, pixelRatio, projection) {
var sourceProjection = this.getProjection();
if (!ENABLE_RASTER_REPROJECTION ||
!sourceProjection ||
!projection ||
equivalent(sourceProjection, projection)) {
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection);
}
else {
var cache = this.getTileCacheForProjection(projection);
var tileCoord = [z, x, y];
var tile = void 0;
var tileCoordKey = getKey(tileCoord);
if (cache.containsKey(tileCoordKey)) {
tile = cache.get(tileCoordKey);
}
var key = this.getKey();
if (tile && tile.key == key) {
return tile;
}
else {
var sourceTileGrid = this.getTileGridForProjection(sourceProjection);
var targetTileGrid = this.getTileGridForProjection(projection);
var wrappedTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection);
var newTile = new ReprojTile(sourceProjection, sourceTileGrid, projection, targetTileGrid, tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio), this.getGutter(), function (z, x, y, pixelRatio) {
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection);
}.bind(this), this.reprojectionErrorThreshold_, this.renderReprojectionEdges_, this.getInterpolate());
newTile.key = key;
if (tile) {
newTile.interimTile = tile;
newTile.refreshInterimChain();
cache.replace(tileCoordKey, newTile);
}
else {
cache.set(tileCoordKey, newTile);
}
return newTile;
}
}
};
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {!import("../proj/Projection.js").default} projection Projection.
* @return {!(ImageTile|ReprojTile)} Tile.
* @protected
*/
TileImage.prototype.getTileInternal = function (z, x, y, pixelRatio, projection) {
var tile = null;
var tileCoordKey = getKeyZXY(z, x, y);
var key = this.getKey();
if (!this.tileCache.containsKey(tileCoordKey)) {
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
this.tileCache.set(tileCoordKey, tile);
}
else {
tile = this.tileCache.get(tileCoordKey);
if (tile.key != key) {
// The source's params changed. If the tile has an interim tile and if we
// can use it then we use it. Otherwise we create a new tile. In both
// cases we attempt to assign an interim tile to the new tile.
var interimTile = tile;
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
//make the new tile the head of the list,
if (interimTile.getState() == TileState.IDLE) {
//the old tile hasn't begun loading yet, and is now outdated, so we can simply discard it
tile.interimTile = interimTile.interimTile;
}
else {
tile.interimTile = interimTile;
}
tile.refreshInterimChain();
this.tileCache.replace(tileCoordKey, tile);
}
}
return tile;
};
/**
* Sets whether to render reprojection edges or not (usually for debugging).
* @param {boolean} render Render the edges.
* @api
*/
TileImage.prototype.setRenderReprojectionEdges = function (render) {
if (!ENABLE_RASTER_REPROJECTION ||
this.renderReprojectionEdges_ == render) {
return;
}
this.renderReprojectionEdges_ = render;
for (var id in this.tileCacheForProjection) {
this.tileCacheForProjection[id].clear();
}
this.changed();
};
/**
* Sets the tile grid to use when reprojecting the tiles to the given
* projection instead of the default tile grid for the projection.
*
* This can be useful when the default tile grid cannot be created
* (e.g. projection has no extent defined) or
* for optimization reasons (custom tile size, resolutions, ...).
*
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
* @api
*/
TileImage.prototype.setTileGridForProjection = function (projection, tilegrid) {
if (ENABLE_RASTER_REPROJECTION) {
var proj = getProjection(projection);
if (proj) {
var projKey = getUid(proj);
if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] = tilegrid;
}
}
}
};
return TileImage;
}(UrlTile));
/**
* @param {ImageTile} imageTile Image tile.
* @param {string} src Source.
*/
function defaultTileLoadFunction(imageTile, src) {
/** @type {HTMLImageElement|HTMLVideoElement} */ (imageTile.getImage()).src =
src;
}
export default TileImage;
//# sourceMappingURL=TileImage.js.map
+1
View File
File diff suppressed because one or more lines are too long
+222
View File
@@ -0,0 +1,222 @@
export default TileJSON;
export type Config = {
/**
* The name.
*/
name?: string | undefined;
/**
* The description.
*/
description?: string | undefined;
/**
* The version.
*/
version?: string | undefined;
/**
* The attribution.
*/
attribution?: string | undefined;
/**
* The template.
*/
template?: string | undefined;
/**
* The legend.
*/
legend?: string | undefined;
/**
* The scheme.
*/
scheme?: string | undefined;
/**
* The tile URL templates.
*/
tiles: Array<string>;
/**
* Optional grids.
*/
grids?: string[] | undefined;
/**
* Minimum zoom level.
*/
minzoom?: number | undefined;
/**
* Maximum zoom level.
*/
maxzoom?: number | undefined;
/**
* Optional bounds.
*/
bounds?: number[] | undefined;
/**
* Optional center.
*/
center?: number[] | undefined;
};
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* Use JSONP with callback to load the TileJSON.
* Useful when the server does not support CORS..
*/
jsonp?: boolean | undefined;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* TileJSON configuration for this source.
* If not provided, `url` must be configured.
*/
tileJSON?: Config | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* The tile size used by the tile service.
* Note: `tileSize` and other non-standard TileJSON properties are currently ignored.
*/
tileSize?: number | import("../size.js").Size | undefined;
/**
* URL to the TileJSON file. If not provided, `tileJSON` must be configured.
*/
url?: string | undefined;
/**
* Whether to wrap the world horizontally.
*/
wrapX?: boolean | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Config
* @property {string} [name] The name.
* @property {string} [description] The description.
* @property {string} [version] The version.
* @property {string} [attribution] The attribution.
* @property {string} [template] The template.
* @property {string} [legend] The legend.
* @property {string} [scheme] The scheme.
* @property {Array<string>} tiles The tile URL templates.
* @property {Array<string>} [grids] Optional grids.
* @property {number} [minzoom] Minimum zoom level.
* @property {number} [maxzoom] Maximum zoom level.
* @property {Array<number>} [bounds] Optional bounds.
* @property {Array<number>} [center] Optional center.
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {boolean} [jsonp=false] Use JSONP with callback to load the TileJSON.
* Useful when the server does not support CORS..
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {Config} [tileJSON] TileJSON configuration for this source.
* If not provided, `url` must be configured.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number|import("../size.js").Size} [tileSize=[256, 256]] The tile size used by the tile service.
* Note: `tileSize` and other non-standard TileJSON properties are currently ignored.
* @property {string} [url] URL to the TileJSON file. If not provided, `tileJSON` must be configured.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for tile data in TileJSON format.
* @api
*/
declare class TileJSON extends TileImage {
/**
* @param {Options} options TileJSON options.
*/
constructor(options: Options);
/**
* @type {Config}
* @private
*/
private tileJSON_;
/**
* @type {number|import("../size.js").Size}
* @private
*/
private tileSize_;
/**
* @private
* @param {Event} event The load event.
*/
private onXHRLoad_;
/**
* @private
* @param {Event} event The error event.
*/
private onXHRError_;
/**
* @return {Config} The tilejson object.
* @api
*/
getTileJSON(): Config;
/**
* @protected
* @param {Config} tileJSON Tile JSON.
*/
protected handleTileJSONResponse(tileJSON: Config): void;
/**
* @protected
*/
protected handleTileJSONError(): void;
}
import TileImage from "./TileImage.js";
//# sourceMappingURL=TileJSON.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileJSON.d.ts","sourceRoot":"","sources":["../src/source/TileJSON.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA0Bc,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAT3B;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAsDjB;IA/BC;;;OAGG;IACH,kBAAqB;IAErB;;;OAGG;IACH,kBAAiC;IAuBnC;;;OAGG;IACH,mBAeC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,eAHY,MAAM,CAKjB;IAED;;;OAGG;IACH,2CAFW,MAAM,QAuChB;IAED;;OAEG;IACH,sCAEC;CACF"}
+217
View File
@@ -0,0 +1,217 @@
/**
* @module ol/source/TileJSON
*/
// FIXME check order of async callbacks
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* See https://mapbox.com/developers/api/.
*/
import TileImage from './TileImage.js';
import { applyTransform, intersects } from '../extent.js';
import { assert } from '../asserts.js';
import { createFromTemplates } from '../tileurlfunction.js';
import { createXYZ, extentFromProjection } from '../tilegrid.js';
import { get as getProjection, getTransformFromProjections } from '../proj.js';
import { jsonp as requestJSONP } from '../net.js';
/**
* @typedef {Object} Config
* @property {string} [name] The name.
* @property {string} [description] The description.
* @property {string} [version] The version.
* @property {string} [attribution] The attribution.
* @property {string} [template] The template.
* @property {string} [legend] The legend.
* @property {string} [scheme] The scheme.
* @property {Array<string>} tiles The tile URL templates.
* @property {Array<string>} [grids] Optional grids.
* @property {number} [minzoom] Minimum zoom level.
* @property {number} [maxzoom] Maximum zoom level.
* @property {Array<number>} [bounds] Optional bounds.
* @property {Array<number>} [center] Optional center.
*/
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {boolean} [jsonp=false] Use JSONP with callback to load the TileJSON.
* Useful when the server does not support CORS..
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {Config} [tileJSON] TileJSON configuration for this source.
* If not provided, `url` must be configured.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {number|import("../size.js").Size} [tileSize=[256, 256]] The tile size used by the tile service.
* Note: `tileSize` and other non-standard TileJSON properties are currently ignored.
* @property {string} [url] URL to the TileJSON file. If not provided, `tileJSON` must be configured.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for tile data in TileJSON format.
* @api
*/
var TileJSON = /** @class */ (function (_super) {
__extends(TileJSON, _super);
/**
* @param {Options} options TileJSON options.
*/
function TileJSON(options) {
var _this = this;
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
_this = _super.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
interpolate: interpolate,
projection: getProjection('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: 'loading',
tileLoadFunction: options.tileLoadFunction,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition,
zDirection: options.zDirection,
}) || this;
/**
* @type {Config}
* @private
*/
_this.tileJSON_ = null;
/**
* @type {number|import("../size.js").Size}
* @private
*/
_this.tileSize_ = options.tileSize;
if (options.url) {
if (options.jsonp) {
requestJSONP(options.url, _this.handleTileJSONResponse.bind(_this), _this.handleTileJSONError.bind(_this));
}
else {
var client = new XMLHttpRequest();
client.addEventListener('load', _this.onXHRLoad_.bind(_this));
client.addEventListener('error', _this.onXHRError_.bind(_this));
client.open('GET', options.url);
client.send();
}
}
else if (options.tileJSON) {
_this.handleTileJSONResponse(options.tileJSON);
}
else {
assert(false, 51); // Either `url` or `tileJSON` options must be provided
}
return _this;
}
/**
* @private
* @param {Event} event The load event.
*/
TileJSON.prototype.onXHRLoad_ = function (event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || (client.status >= 200 && client.status < 300)) {
var response = void 0;
try {
response = /** @type {Config} */ (JSON.parse(client.responseText));
}
catch (err) {
this.handleTileJSONError();
return;
}
this.handleTileJSONResponse(response);
}
else {
this.handleTileJSONError();
}
};
/**
* @private
* @param {Event} event The error event.
*/
TileJSON.prototype.onXHRError_ = function (event) {
this.handleTileJSONError();
};
/**
* @return {Config} The tilejson object.
* @api
*/
TileJSON.prototype.getTileJSON = function () {
return this.tileJSON_;
};
/**
* @protected
* @param {Config} tileJSON Tile JSON.
*/
TileJSON.prototype.handleTileJSONResponse = function (tileJSON) {
var epsg4326Projection = getProjection('EPSG:4326');
var sourceProjection = this.getProjection();
var extent;
if (tileJSON['bounds'] !== undefined) {
var transform = getTransformFromProjections(epsg4326Projection, sourceProjection);
extent = applyTransform(tileJSON['bounds'], transform);
}
var gridExtent = extentFromProjection(sourceProjection);
var minZoom = tileJSON['minzoom'] || 0;
var maxZoom = tileJSON['maxzoom'] || 22;
var tileGrid = createXYZ({
extent: gridExtent,
maxZoom: maxZoom,
minZoom: minZoom,
tileSize: this.tileSize_,
});
this.tileGrid = tileGrid;
this.tileUrlFunction = createFromTemplates(tileJSON['tiles'], tileGrid);
if (tileJSON['attribution'] !== undefined && !this.getAttributions()) {
var attributionExtent_1 = extent !== undefined ? extent : gridExtent;
this.setAttributions(function (frameState) {
if (intersects(attributionExtent_1, frameState.extent)) {
return [tileJSON['attribution']];
}
return null;
});
}
this.tileJSON_ = tileJSON;
this.setState('ready');
};
/**
* @protected
*/
TileJSON.prototype.handleTileJSONError = function () {
this.setState('error');
};
return TileJSON;
}(TileImage));
export default TileJSON;
//# sourceMappingURL=TileJSON.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileJSON.js","sourceRoot":"","sources":["../src/source/TileJSON.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,uCAAuC;;;;;;;;;;;;;;;;AAEvC;;GAEG;AAEH,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAC,GAAG,IAAI,aAAa,EAAE,2BAA2B,EAAC,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAC,KAAK,IAAI,YAAY,EAAC,MAAM,WAAW,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;GAIG;AACH;IAAuB,4BAAS;IAC9B;;OAEG;IACH,kBAAY,OAAO;Q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AC,CAAC,CAAC;iBAClC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;QACD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,sCAAmB,GAAnB;QACE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACH,eAAC;AAAD,CAAC,AAhJD,CAAuB,SAAS,GAgJ/B;AAED,eAAe,QAAQ,CAAC"}
+282
View File
@@ -0,0 +1,282 @@
export default TileWMS;
export type Options = {
/**
* Attributions.
*/
attributions?: import("./Source.js").AttributionLike | undefined;
/**
* Attributions are collapsible.
*/
attributionsCollapsible?: boolean | undefined;
/**
* Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
*/
cacheSize?: number | undefined;
/**
* The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
*/
crossOrigin?: string | null | undefined;
/**
* Deprecated. Use the `interpolate` option instead.
*/
imageSmoothing?: boolean | undefined;
/**
* Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
*/
interpolate?: boolean | undefined;
/**
* WMS request parameters.
* At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
* and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
*/
params: {
[x: string]: any;
};
/**
* The size in pixels of the gutter around image tiles to ignore. By setting
* this property to a non-zero value, images will be requested that are wider
* and taller than the tile size by a value of `2 x gutter`.
* Using a non-zero value allows artifacts of rendering at tile edges to be
* ignored. If you control the WMS service it is recommended to address
* "artifacts at tile edges" issues by properly configuring the WMS service. For
* example, MapServer has a `tile_map_edge_buffer` configuration parameter for
* this. See https://mapserver.org/output/tile_mode.html.
*/
gutter?: number | undefined;
/**
* Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
*/
hidpi?: boolean | undefined;
/**
* Projection. Default is the view projection.
*/
projection?: import("../proj.js").ProjectionLike;
/**
* Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
*/
reprojectionErrorThreshold?: number | undefined;
/**
* Class used to instantiate image tiles.
* Default is {@link module :ol/ImageTile~ImageTile}.
*/
tileClass?: typeof import("../ImageTile.js").default | undefined;
/**
* Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection
* extent, the grid will be based on that; if not, a grid based on a global
* extent with origin at 0,0 will be used.
*/
tileGrid?: import("../tilegrid/TileGrid.js").default | undefined;
/**
* The type of
* the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
* Only needed if `hidpi` is `true`.
*/
serverType?: import("./wms.js").ServerType | undefined;
/**
* Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
*/
tileLoadFunction?: import("../Tile.js").LoadFunction | undefined;
/**
* WMS service URL.
*/
url?: string | undefined;
/**
* WMS service urls.
* Use this instead of `url` when the WMS supports multiple urls for GetMap requests.
*/
urls?: string[] | undefined;
/**
* Whether to wrap the world horizontally.
* When set to `false`, only one world
* will be rendered. When `true`, tiles will be requested for one world only,
* but they will be wrapped horizontally to render multiple worlds.
*/
wrapX?: boolean | undefined;
/**
* Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
*/
transition?: number | undefined;
/**
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module :ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
zDirection?: number | import("../array.js").NearestDirectionFunction | undefined;
};
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} params WMS request parameters.
* At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
* and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
* @property {number} [gutter=0]
* The size in pixels of the gutter around image tiles to ignore. By setting
* this property to a non-zero value, images will be requested that are wider
* and taller than the tile size by a value of `2 x gutter`.
* Using a non-zero value allows artifacts of rendering at tile edges to be
* ignored. If you control the WMS service it is recommended to address
* "artifacts at tile edges" issues by properly configuring the WMS service. For
* example, MapServer has a `tile_map_edge_buffer` configuration parameter for
* this. See https://mapserver.org/output/tile_mode.html.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~ImageTile}.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection
* extent, the grid will be based on that; if not, a grid based on a global
* extent with origin at 0,0 will be used.
* @property {import("./wms.js").ServerType} [serverType] The type of
* the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
* Only needed if `hidpi` is `true`.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {string} [url] WMS service URL.
* @property {Array<string>} [urls] WMS service urls.
* Use this instead of `url` when the WMS supports multiple urls for GetMap requests.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* When set to `false`, only one world
* will be rendered. When `true`, tiles will be requested for one world only,
* but they will be wrapped horizontally to render multiple worlds.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for tile data from WMS servers.
* @api
*/
declare class TileWMS extends TileImage {
/**
* @param {Options} [opt_options] Tile WMS options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {number}
*/
private gutter_;
/**
* @private
* @type {!Object}
*/
private params_;
/**
* @private
* @type {boolean}
*/
private v13_;
/**
* @private
* @type {import("./wms.js").ServerType}
*/
private serverType_;
/**
* @private
* @type {boolean}
*/
private hidpi_;
/**
* @private
* @type {import("../extent.js").Extent}
*/
private tmpExtent_;
/**
* Return the GetFeatureInfo URL for the passed coordinate, resolution, and
* projection. Return `undefined` if the GetFeatureInfo URL cannot be
* constructed.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
* be provided. If `QUERY_LAYERS` is not provided then the layers specified
* in the `LAYERS` parameter will be used. `VERSION` should not be
* specified here.
* @return {string|undefined} GetFeatureInfo URL.
* @api
*/
getFeatureInfoUrl(coordinate: import("../coordinate.js").Coordinate, resolution: number, projection: import("../proj.js").ProjectionLike, params: any): string | undefined;
/**
* Return the GetLegendGraphic URL, optionally optimized for the passed
* resolution and possibly including any passed specific parameters. Returns
* `undefined` if the GetLegendGraphic URL cannot be constructed.
*
* @param {number} [resolution] Resolution. If set to undefined, `SCALE`
* will not be calculated and included in URL.
* @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the
* request is generated for this wms layer, else it will try to use the
* configured wms layer. Default `FORMAT` is `image/png`.
* `VERSION` should not be specified here.
* @return {string|undefined} GetLegendGraphic URL.
* @api
*/
getLegendUrl(resolution?: number | undefined, params?: any): string | undefined;
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
getParams(): any;
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../size.js").Size} tileSize Tile size.
* @param {import("../extent.js").Extent} tileExtent Tile extent.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string|undefined} Request URL.
* @private
*/
private getRequestUrl_;
/**
* @private
* @return {string} The key for the current params.
*/
private getKeyForParams_;
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
updateParams(params: any): void;
/**
* @private
*/
private updateV13_;
}
import TileImage from "./TileImage.js";
//# sourceMappingURL=TileWMS.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TileWMS.d.ts","sourceRoot":"","sources":["../src/source/TileWMS.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA4BqB,MAAM;;;;;;;;;;;;;;;;;;;;;iBAeb,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA1BjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,+CAsEC;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"}
+416
View File
@@ -0,0 +1,416 @@
/**
* @module ol/source/TileWMS
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import TileImage from './TileImage.js';
import { DEFAULT_VERSION } from './wms.js';
import { appendParams } from '../uri.js';
import { assert } from '../asserts.js';
import { assign } from '../obj.js';
import { buffer, createEmpty } from '../extent.js';
import { buffer as bufferSize, scale as scaleSize, toSize } from '../size.js';
import { calculateSourceResolution } from '../reproj.js';
import { compareVersions } from '../string.js';
import { get as getProjection, transform, transformExtent } from '../proj.js';
import { modulo } from '../math.js';
import { hash as tileCoordHash } from '../tilecoord.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
* @property {Object<string,*>} params WMS request parameters.
* At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
* and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically.
* @property {number} [gutter=0]
* The size in pixels of the gutter around image tiles to ignore. By setting
* this property to a non-zero value, images will be requested that are wider
* and taller than the tile size by a value of `2 x gutter`.
* Using a non-zero value allows artifacts of rendering at tile edges to be
* ignored. If you control the WMS service it is recommended to address
* "artifacts at tile edges" issues by properly configuring the WMS service. For
* example, MapServer has a `tile_map_edge_buffer` configuration parameter for
* this. See https://mapserver.org/output/tile_mode.html.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~ImageTile}.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection
* extent, the grid will be based on that; if not, a grid based on a global
* extent with origin at 0,0 will be used.
* @property {import("./wms.js").ServerType} [serverType] The type of
* the remote WMS server: `mapserver`, `geoserver`, `carmentaserver`, or `qgis`.
* Only needed if `hidpi` is `true`.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
* ```js
* function(imageTile, src) {
* imageTile.getImage().src = src;
* };
* ```
* @property {string} [url] WMS service URL.
* @property {Array<string>} [urls] WMS service urls.
* Use this instead of `url` when the WMS supports multiple urls for GetMap requests.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* When set to `false`, only one world
* will be rendered. When `true`, tiles will be requested for one world only,
* but they will be wrapped horizontally to render multiple worlds.
* @property {number} [transition] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0]
* Choose whether to use tiles with a higher or lower zoom level when between integer
* zoom levels. See {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution}.
*/
/**
* @classdesc
* Layer source for tile data from WMS servers.
* @api
*/
var TileWMS = /** @class */ (function (_super) {
__extends(TileWMS, _super);
/**
* @param {Options} [opt_options] Tile WMS options.
*/
function TileWMS(opt_options) {
var _this = this;
var options = opt_options ? opt_options : /** @type {Options} */ ({});
var interpolate = options.imageSmoothing !== undefined ? options.imageSmoothing : true;
if (options.interpolate !== undefined) {
interpolate = options.interpolate;
}
var params = options.params || {};
var transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
_this = _super.call(this, {
attributions: options.attributions,
attributionsCollapsible: options.attributionsCollapsible,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
interpolate: interpolate,
opaque: !transparent,
projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
tileClass: options.tileClass,
tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction,
url: options.url,
urls: options.urls,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition,
zDirection: options.zDirection,
}) || this;
/**
* @private
* @type {number}
*/
_this.gutter_ = options.gutter !== undefined ? options.gutter : 0;
/**
* @private
* @type {!Object}
*/
_this.params_ = params;
/**
* @private
* @type {boolean}
*/
_this.v13_ = true;
/**
* @private
* @type {import("./wms.js").ServerType}
*/
_this.serverType_ = options.serverType;
/**
* @private
* @type {boolean}
*/
_this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
/**
* @private
* @type {import("../extent.js").Extent}
*/
_this.tmpExtent_ = createEmpty();
_this.updateV13_();
_this.setKey(_this.getKeyForParams_());
return _this;
}
/**
* Return the GetFeatureInfo URL for the passed coordinate, resolution, and
* projection. Return `undefined` if the GetFeatureInfo URL cannot be
* constructed.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
* be provided. If `QUERY_LAYERS` is not provided then the layers specified
* in the `LAYERS` parameter will be used. `VERSION` should not be
* specified here.
* @return {string|undefined} GetFeatureInfo URL.
* @api
*/
TileWMS.prototype.getFeatureInfoUrl = function (coordinate, resolution, projection, params) {
var projectionObj = getProjection(projection);
var sourceProjectionObj = this.getProjection();
var tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projectionObj);
}
var z = tileGrid.getZForResolution(resolution, this.zDirection);
var tileCoord = tileGrid.getTileCoordForCoordAndZ(coordinate, z);
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
if (gutter !== 0) {
tileSize = bufferSize(tileSize, gutter, this.tmpSize);
tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
}
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
tileResolution = calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution);
tileExtent = transformExtent(tileExtent, projectionObj, sourceProjectionObj);
coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
}
var baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_VERSION,
'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png',
'TRANSPARENT': true,
'QUERY_LAYERS': this.params_['LAYERS'],
};
assign(baseParams, this.params_, params);
var x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution);
var y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution);
baseParams[this.v13_ ? 'I' : 'X'] = x;
baseParams[this.v13_ ? 'J' : 'Y'] = y;
return this.getRequestUrl_(tileCoord, tileSize, tileExtent, 1, sourceProjectionObj || projectionObj, baseParams);
};
/**
* Return the GetLegendGraphic URL, optionally optimized for the passed
* resolution and possibly including any passed specific parameters. Returns
* `undefined` if the GetLegendGraphic URL cannot be constructed.
*
* @param {number} [resolution] Resolution. If set to undefined, `SCALE`
* will not be calculated and included in URL.
* @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the
* request is generated for this wms layer, else it will try to use the
* configured wms layer. Default `FORMAT` is `image/png`.
* `VERSION` should not be specified here.
* @return {string|undefined} GetLegendGraphic URL.
* @api
*/
TileWMS.prototype.getLegendUrl = function (resolution, params) {
if (this.urls[0] === undefined) {
return undefined;
}
var baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_VERSION,
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
};
if (params === undefined || params['LAYER'] === undefined) {
var layers = this.params_.LAYERS;
var isSingleLayer = !Array.isArray(layers) || layers.length === 1;
if (!isSingleLayer) {
return undefined;
}
baseParams['LAYER'] = layers;
}
if (resolution !== undefined) {
var mpu = this.getProjection()
? this.getProjection().getMetersPerUnit()
: 1;
var pixelSize = 0.00028;
baseParams['SCALE'] = (resolution * mpu) / pixelSize;
}
assign(baseParams, params);
return appendParams(/** @type {string} */ (this.urls[0]), baseParams);
};
/**
* @return {number} Gutter.
*/
TileWMS.prototype.getGutter = function () {
return this.gutter_;
};
/**
* Get the user-provided params, i.e. those passed to the constructor through
* the "params" option, and possibly updated using the updateParams method.
* @return {Object} Params.
* @api
*/
TileWMS.prototype.getParams = function () {
return this.params_;
};
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../size.js").Size} tileSize Tile size.
* @param {import("../extent.js").Extent} tileExtent Tile extent.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {Object} params Params.
* @return {string|undefined} Request URL.
* @private
*/
TileWMS.prototype.getRequestUrl_ = function (tileCoord, tileSize, tileExtent, pixelRatio, projection, params) {
var urls = this.urls;
if (!urls) {
return undefined;
}
params['WIDTH'] = tileSize[0];
params['HEIGHT'] = tileSize[1];
params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
if (!('STYLES' in this.params_)) {
params['STYLES'] = '';
}
if (pixelRatio != 1) {
switch (this.serverType_) {
case 'geoserver':
var dpi = (90 * pixelRatio + 0.5) | 0;
if ('FORMAT_OPTIONS' in params) {
params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
}
else {
params['FORMAT_OPTIONS'] = 'dpi:' + dpi;
}
break;
case 'mapserver':
params['MAP_RESOLUTION'] = 90 * pixelRatio;
break;
case 'carmentaserver':
case 'qgis':
params['DPI'] = 90 * pixelRatio;
break;
default: // Unknown `serverType` configured
assert(false, 52);
break;
}
}
var axisOrientation = projection.getAxisOrientation();
var bbox = tileExtent;
if (this.v13_ && axisOrientation.substr(0, 2) == 'ne') {
var tmp = void 0;
tmp = tileExtent[0];
bbox[0] = tileExtent[1];
bbox[1] = tmp;
tmp = tileExtent[2];
bbox[2] = tileExtent[3];
bbox[3] = tmp;
}
params['BBOX'] = bbox.join(',');
var url;
if (urls.length == 1) {
url = urls[0];
}
else {
var index = modulo(tileCoordHash(tileCoord), urls.length);
url = urls[index];
}
return appendParams(url, params);
};
/**
* Get the tile pixel ratio for this source.
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
TileWMS.prototype.getTilePixelRatio = function (pixelRatio) {
return !this.hidpi_ || this.serverType_ === undefined ? 1 : pixelRatio;
};
/**
* @private
* @return {string} The key for the current params.
*/
TileWMS.prototype.getKeyForParams_ = function () {
var i = 0;
var res = [];
for (var key in this.params_) {
res[i++] = key + '-' + this.params_[key];
}
return res.join('/');
};
/**
* Update the user-provided params.
* @param {Object} params Params.
* @api
*/
TileWMS.prototype.updateParams = function (params) {
assign(this.params_, params);
this.updateV13_();
this.setKey(this.getKeyForParams_());
};
/**
* @private
*/
TileWMS.prototype.updateV13_ = function () {
var version = this.params_['VERSION'] || DEFAULT_VERSION;
this.v13_ = compareVersions(version, '1.3') >= 0;
};
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord The tile coordinate
* @param {number} pixelRatio The pixel ratio
* @param {import("../proj/Projection.js").default} projection The projection
* @return {string|undefined} The tile URL
* @override
*/
TileWMS.prototype.tileUrlFunction = function (tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) {
pixelRatio = 1;
}
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
if (gutter !== 0) {
tileSize = bufferSize(tileSize, gutter, this.tmpSize);
tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
}
if (pixelRatio != 1) {
tileSize = scaleSize(tileSize, pixelRatio, this.tmpSize);
}
var baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true,
};
assign(baseParams, this.params_);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent, pixelRatio, projection, baseParams);
};
return TileWMS;
}(TileImage));
export default TileWMS;
//# sourceMappingURL=TileWMS.js.map
+1
View File
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More