847 lines
26 KiB
JavaScript
847 lines
26 KiB
JavaScript
import {
|
|
TileGrid_default
|
|
} from "./chunk-WCB6SF5A.js";
|
|
import {
|
|
Tile_default
|
|
} from "./chunk-QL7JR4NF.js";
|
|
import {
|
|
hash,
|
|
hashZXY,
|
|
withinExtentAndZ
|
|
} from "./chunk-SQ4UGRSZ.js";
|
|
import {
|
|
ImageTile_default
|
|
} from "./chunk-MESSQWK4.js";
|
|
import {
|
|
Source_default
|
|
} from "./chunk-XHKILN37.js";
|
|
import {
|
|
TileState_default
|
|
} from "./chunk-5D2XPBR2.js";
|
|
import {
|
|
DEFAULT_MAX_ZOOM,
|
|
DEFAULT_TILE_SIZE
|
|
} from "./chunk-FM44FOIC.js";
|
|
import {
|
|
scale,
|
|
toSize
|
|
} from "./chunk-PPP4FLHO.js";
|
|
import {
|
|
METERS_PER_UNIT,
|
|
equivalent,
|
|
get
|
|
} from "./chunk-XZU4LSFD.js";
|
|
import {
|
|
modulo
|
|
} from "./chunk-54BTDBAD.js";
|
|
import {
|
|
containsCoordinate,
|
|
createOrUpdate,
|
|
getCorner,
|
|
getHeight,
|
|
getWidth
|
|
} from "./chunk-CKDBVGKM.js";
|
|
import {
|
|
abstract,
|
|
getUid
|
|
} from "./chunk-H47PV7W6.js";
|
|
import {
|
|
EventType_default,
|
|
Event_default
|
|
} from "./chunk-KJXIHBKT.js";
|
|
|
|
// node_modules/ol/tilegrid.js
|
|
function getForProjection(projection) {
|
|
let tileGrid = projection.getDefaultTileGrid();
|
|
if (!tileGrid) {
|
|
tileGrid = createForProjection(projection);
|
|
projection.setDefaultTileGrid(tileGrid);
|
|
}
|
|
return tileGrid;
|
|
}
|
|
function wrapX(tileGrid, tileCoord, projection) {
|
|
const z = tileCoord[0];
|
|
const center = tileGrid.getTileCoordCenter(tileCoord);
|
|
const projectionExtent = extentFromProjection(projection);
|
|
if (!containsCoordinate(projectionExtent, center)) {
|
|
const worldWidth = getWidth(projectionExtent);
|
|
const worldsAway = Math.ceil(
|
|
(projectionExtent[0] - center[0]) / worldWidth
|
|
);
|
|
center[0] += worldWidth * worldsAway;
|
|
return tileGrid.getTileCoordForCoordAndZ(center, z);
|
|
}
|
|
return tileCoord;
|
|
}
|
|
function createForExtent(extent, maxZoom, tileSize, corner) {
|
|
corner = corner !== void 0 ? corner : "top-left";
|
|
const resolutions = resolutionsFromExtent(extent, maxZoom, tileSize);
|
|
return new TileGrid_default({
|
|
extent,
|
|
origin: getCorner(extent, corner),
|
|
resolutions,
|
|
tileSize
|
|
});
|
|
}
|
|
function createXYZ(options) {
|
|
const xyzOptions = options || {};
|
|
const extent = xyzOptions.extent || get("EPSG:3857").getExtent();
|
|
const gridOptions = {
|
|
extent,
|
|
minZoom: xyzOptions.minZoom,
|
|
tileSize: xyzOptions.tileSize,
|
|
resolutions: resolutionsFromExtent(
|
|
extent,
|
|
xyzOptions.maxZoom,
|
|
xyzOptions.tileSize,
|
|
xyzOptions.maxResolution
|
|
)
|
|
};
|
|
return new TileGrid_default(gridOptions);
|
|
}
|
|
function resolutionsFromExtent(extent, maxZoom, tileSize, maxResolution) {
|
|
maxZoom = maxZoom !== void 0 ? maxZoom : DEFAULT_MAX_ZOOM;
|
|
tileSize = toSize(tileSize !== void 0 ? tileSize : DEFAULT_TILE_SIZE);
|
|
const height = getHeight(extent);
|
|
const width = getWidth(extent);
|
|
maxResolution = maxResolution > 0 ? maxResolution : Math.max(width / tileSize[0], height / tileSize[1]);
|
|
const length = maxZoom + 1;
|
|
const resolutions = new Array(length);
|
|
for (let z = 0; z < length; ++z) {
|
|
resolutions[z] = maxResolution / Math.pow(2, z);
|
|
}
|
|
return resolutions;
|
|
}
|
|
function createForProjection(projection, maxZoom, tileSize, corner) {
|
|
const extent = extentFromProjection(projection);
|
|
return createForExtent(extent, maxZoom, tileSize, corner);
|
|
}
|
|
function extentFromProjection(projection) {
|
|
projection = get(projection);
|
|
let extent = projection.getExtent();
|
|
if (!extent) {
|
|
const half = 180 * METERS_PER_UNIT.degrees / projection.getMetersPerUnit();
|
|
extent = createOrUpdate(-half, -half, half, half);
|
|
}
|
|
return extent;
|
|
}
|
|
|
|
// node_modules/ol/uri.js
|
|
function appendParams(uri, params) {
|
|
const keyParams = [];
|
|
Object.keys(params).forEach(function(k) {
|
|
if (params[k] !== null && params[k] !== void 0) {
|
|
keyParams.push(k + "=" + encodeURIComponent(params[k]));
|
|
}
|
|
});
|
|
const qs = keyParams.join("&");
|
|
uri = uri.replace(/[?&]$/, "");
|
|
uri += uri.includes("?") ? "&" : "?";
|
|
return uri + qs;
|
|
}
|
|
var zRegEx = /\{z\}/g;
|
|
var xRegEx = /\{x\}/g;
|
|
var yRegEx = /\{y\}/g;
|
|
var dashYRegEx = /\{-y\}/g;
|
|
function renderXYZTemplate(template, z, x, y, maxY) {
|
|
return template.replace(zRegEx, z.toString()).replace(xRegEx, x.toString()).replace(yRegEx, y.toString()).replace(dashYRegEx, function() {
|
|
if (maxY === void 0) {
|
|
throw new Error(
|
|
"If the URL template has a {-y} placeholder, the grid extent must be known"
|
|
);
|
|
}
|
|
return (maxY - y).toString();
|
|
});
|
|
}
|
|
function pickUrl(urls, z, x, y) {
|
|
const hash2 = hashZXY(z, x, y);
|
|
const index = modulo(hash2, urls.length);
|
|
return urls[index];
|
|
}
|
|
function expandUrl(url) {
|
|
const urls = [];
|
|
let match = /\{([a-z])-([a-z])\}/.exec(url);
|
|
if (match) {
|
|
const startCharCode = match[1].charCodeAt(0);
|
|
const stopCharCode = match[2].charCodeAt(0);
|
|
let charCode;
|
|
for (charCode = startCharCode; charCode <= stopCharCode; ++charCode) {
|
|
urls.push(url.replace(match[0], String.fromCharCode(charCode)));
|
|
}
|
|
return urls;
|
|
}
|
|
match = /\{(\d+)-(\d+)\}/.exec(url);
|
|
if (match) {
|
|
const stop = parseInt(match[2], 10);
|
|
for (let i = parseInt(match[1], 10); i <= stop; i++) {
|
|
urls.push(url.replace(match[0], i.toString()));
|
|
}
|
|
return urls;
|
|
}
|
|
urls.push(url);
|
|
return urls;
|
|
}
|
|
|
|
// node_modules/ol/tileurlfunction.js
|
|
function createFromTemplate(template, tileGrid) {
|
|
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 void 0;
|
|
}
|
|
let maxY;
|
|
const z = tileCoord[0];
|
|
if (tileGrid) {
|
|
const range = tileGrid.getFullTileRange(z);
|
|
if (range) {
|
|
maxY = range.getHeight() - 1;
|
|
}
|
|
}
|
|
return renderXYZTemplate(template, z, tileCoord[1], tileCoord[2], maxY);
|
|
})
|
|
);
|
|
}
|
|
function createFromTemplates(templates, tileGrid) {
|
|
const len = templates.length;
|
|
const tileUrlFunctions = new Array(len);
|
|
for (let i = 0; i < len; ++i) {
|
|
tileUrlFunctions[i] = createFromTemplate(templates[i], tileGrid);
|
|
}
|
|
return createFromTileUrlFunctions(tileUrlFunctions);
|
|
}
|
|
function createFromTileUrlFunctions(tileUrlFunctions) {
|
|
if (tileUrlFunctions.length === 1) {
|
|
return tileUrlFunctions[0];
|
|
}
|
|
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 void 0;
|
|
}
|
|
const h = hash(tileCoord);
|
|
const index = modulo(h, tileUrlFunctions.length);
|
|
return tileUrlFunctions[index](tileCoord, pixelRatio, projection);
|
|
})
|
|
);
|
|
}
|
|
function nullTileUrlFunction(tileCoord, pixelRatio, projection) {
|
|
return void 0;
|
|
}
|
|
|
|
// node_modules/ol/source/Tile.js
|
|
var TileSource = class extends Source_default {
|
|
/**
|
|
* @param {Options} options SourceTile source options.
|
|
*/
|
|
constructor(options) {
|
|
super({
|
|
attributions: options.attributions,
|
|
attributionsCollapsible: options.attributionsCollapsible,
|
|
projection: options.projection,
|
|
state: options.state,
|
|
wrapX: options.wrapX,
|
|
interpolate: options.interpolate
|
|
});
|
|
this.on;
|
|
this.once;
|
|
this.un;
|
|
this.tilePixelRatio_ = options.tilePixelRatio !== void 0 ? options.tilePixelRatio : 1;
|
|
this.tileGrid = options.tileGrid !== void 0 ? options.tileGrid : null;
|
|
const tileSize = [256, 256];
|
|
if (this.tileGrid) {
|
|
toSize(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), tileSize);
|
|
}
|
|
this.tmpSize = [0, 0];
|
|
this.key_ = options.key || getUid(this);
|
|
this.tileOptions = {
|
|
transition: options.transition,
|
|
interpolate: options.interpolate
|
|
};
|
|
this.zDirection = options.zDirection ? options.zDirection : 0;
|
|
}
|
|
/**
|
|
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
* @return {number} Gutter.
|
|
*/
|
|
getGutterForProjection(projection) {
|
|
return 0;
|
|
}
|
|
/**
|
|
* Return the key to be used for all tiles in the source.
|
|
* @return {string} The key for all tiles.
|
|
*/
|
|
getKey() {
|
|
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
|
|
*/
|
|
setKey(key) {
|
|
if (this.key_ !== key) {
|
|
this.key_ = key;
|
|
this.changed();
|
|
}
|
|
}
|
|
/**
|
|
* @param {import("../proj/Projection").default} [projection] Projection.
|
|
* @return {Array<number>|null} Resolutions.
|
|
* @override
|
|
*/
|
|
getResolutions(projection) {
|
|
const tileGrid = projection ? this.getTileGridForProjection(projection) : this.tileGrid;
|
|
if (!tileGrid) {
|
|
return null;
|
|
}
|
|
return 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 {TileType|null} Tile.
|
|
*/
|
|
getTile(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
|
|
*/
|
|
getTileGrid() {
|
|
return this.tileGrid;
|
|
}
|
|
/**
|
|
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
|
|
*/
|
|
getTileGridForProjection(projection) {
|
|
if (!this.tileGrid) {
|
|
return getForProjection(projection);
|
|
}
|
|
return this.tileGrid;
|
|
}
|
|
/**
|
|
* 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) {
|
|
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.
|
|
*/
|
|
getTilePixelSize(z, pixelRatio, projection) {
|
|
const tileGrid = this.getTileGridForProjection(projection);
|
|
const tilePixelRatio = this.getTilePixelRatio(pixelRatio);
|
|
const tileSize = toSize(tileGrid.getTileSize(z), this.tmpSize);
|
|
if (tilePixelRatio == 1) {
|
|
return tileSize;
|
|
}
|
|
return scale(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} [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, projection) {
|
|
const gridProjection = projection !== void 0 ? projection : this.getProjection();
|
|
const tileGrid = projection !== void 0 ? this.getTileGridForProjection(gridProjection) : this.tileGrid || this.getTileGridForProjection(gridProjection);
|
|
if (this.getWrapX() && gridProjection.isGlobal()) {
|
|
tileCoord = wrapX(tileGrid, tileCoord, gridProjection);
|
|
}
|
|
return withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
|
|
}
|
|
/**
|
|
* Remove all cached reprojected tiles from the source. The next render cycle will create new tiles.
|
|
* @api
|
|
*/
|
|
clear() {
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
refresh() {
|
|
this.clear();
|
|
super.refresh();
|
|
}
|
|
};
|
|
var TileSourceEvent = class extends Event_default {
|
|
/**
|
|
* @param {string} type Type.
|
|
* @param {import("../Tile.js").default} tile The tile.
|
|
*/
|
|
constructor(type, tile) {
|
|
super(type);
|
|
this.tile = tile;
|
|
}
|
|
};
|
|
var Tile_default2 = TileSource;
|
|
|
|
// node_modules/ol/source/TileEventType.js
|
|
var TileEventType_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. Note that this is not the
|
|
* right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load}
|
|
* for details.
|
|
* @event module:ol/source/Tile.TileSourceEvent#tileloaderror
|
|
* @api
|
|
*/
|
|
TILELOADERROR: "tileloaderror"
|
|
};
|
|
|
|
// node_modules/ol/source/UrlTile.js
|
|
var UrlTile = class _UrlTile extends Tile_default2 {
|
|
/**
|
|
* @param {Options} options Image tile options.
|
|
*/
|
|
constructor(options) {
|
|
super({
|
|
attributions: options.attributions,
|
|
cacheSize: options.cacheSize,
|
|
projection: options.projection,
|
|
state: options.state,
|
|
tileGrid: options.tileGrid,
|
|
tilePixelRatio: options.tilePixelRatio,
|
|
wrapX: options.wrapX,
|
|
transition: options.transition,
|
|
interpolate: options.interpolate,
|
|
key: options.key,
|
|
attributionsCollapsible: options.attributionsCollapsible,
|
|
zDirection: options.zDirection
|
|
});
|
|
this.generateTileUrlFunction_ = this.tileUrlFunction === _UrlTile.prototype.tileUrlFunction;
|
|
this.tileLoadFunction = options.tileLoadFunction;
|
|
if (options.tileUrlFunction) {
|
|
this.tileUrlFunction = options.tileUrlFunction;
|
|
}
|
|
this.urls = null;
|
|
if (options.urls) {
|
|
this.setUrls(options.urls);
|
|
} else if (options.url) {
|
|
this.setUrl(options.url);
|
|
}
|
|
this.tileLoadingKeys_ = {};
|
|
}
|
|
/**
|
|
* Deprecated. Use an ImageTile source instead.
|
|
* Return the tile load function of the source.
|
|
* @return {import("../Tile.js").LoadFunction} TileLoadFunction
|
|
* @api
|
|
*/
|
|
getTileLoadFunction() {
|
|
return this.tileLoadFunction;
|
|
}
|
|
/**
|
|
* Deprecated. Use an ImageTile source instead.
|
|
* Return the tile URL function of the source.
|
|
* @return {import("../Tile.js").UrlFunction} TileUrlFunction
|
|
* @api
|
|
*/
|
|
getTileUrlFunction() {
|
|
return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction;
|
|
}
|
|
/**
|
|
* Deprecated. Use an ImageTile source instead.
|
|
* Return the URLs used for this source.
|
|
* When a tileUrlFunction is used instead of url or urls,
|
|
* null will be returned.
|
|
* @return {!Array<string>|null} URLs.
|
|
* @api
|
|
*/
|
|
getUrls() {
|
|
return this.urls;
|
|
}
|
|
/**
|
|
* Handle tile change events.
|
|
* @param {import("../events/Event.js").default} event Event.
|
|
* @protected
|
|
*/
|
|
handleTileChange(event) {
|
|
const tile = (
|
|
/** @type {import("../Tile.js").default} */
|
|
event.target
|
|
);
|
|
const uid = getUid(tile);
|
|
const tileState = tile.getState();
|
|
let type;
|
|
if (tileState == TileState_default.LOADING) {
|
|
this.tileLoadingKeys_[uid] = true;
|
|
type = TileEventType_default.TILELOADSTART;
|
|
} else if (uid in this.tileLoadingKeys_) {
|
|
delete this.tileLoadingKeys_[uid];
|
|
type = tileState == TileState_default.ERROR ? TileEventType_default.TILELOADERROR : tileState == TileState_default.LOADED ? TileEventType_default.TILELOADEND : void 0;
|
|
}
|
|
if (type != void 0) {
|
|
this.dispatchEvent(new TileSourceEvent(type, tile));
|
|
}
|
|
}
|
|
/**
|
|
* Deprecated. Use an ImageTile source instead.
|
|
* Set the tile load function of the source.
|
|
* @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
|
|
* @api
|
|
*/
|
|
setTileLoadFunction(tileLoadFunction) {
|
|
this.tileLoadFunction = tileLoadFunction;
|
|
this.changed();
|
|
}
|
|
/**
|
|
* Deprecated. Use an ImageTile source instead.
|
|
* Set the tile URL function of the source.
|
|
* @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
|
|
* @param {string} [key] Optional new tile key for the source.
|
|
* @api
|
|
*/
|
|
setTileUrlFunction(tileUrlFunction, key) {
|
|
this.tileUrlFunction = tileUrlFunction;
|
|
if (typeof key !== "undefined") {
|
|
this.setKey(key);
|
|
} else {
|
|
this.changed();
|
|
}
|
|
}
|
|
/**
|
|
* Set the URL to use for requests.
|
|
* @param {string} url URL.
|
|
* @api
|
|
*/
|
|
setUrl(url) {
|
|
const urls = expandUrl(url);
|
|
this.urls = urls;
|
|
this.setUrls(urls);
|
|
}
|
|
/**
|
|
* Deprecated. Use an ImageTile source instead.
|
|
* Set the URLs to use for requests.
|
|
* @param {Array<string>} urls URLs.
|
|
* @api
|
|
*/
|
|
setUrls(urls) {
|
|
this.urls = urls;
|
|
const key = urls.join("\n");
|
|
if (this.generateTileUrlFunction_) {
|
|
this.setTileUrlFunction(createFromTemplates(urls, this.tileGrid), key);
|
|
} else {
|
|
this.setKey(key);
|
|
}
|
|
}
|
|
/**
|
|
* @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.
|
|
*/
|
|
tileUrlFunction(tileCoord, pixelRatio, projection) {
|
|
return void 0;
|
|
}
|
|
};
|
|
var UrlTile_default = UrlTile;
|
|
|
|
// node_modules/ol/source/TileImage.js
|
|
var TileImage = class extends UrlTile_default {
|
|
/**
|
|
* @param {!Options} options Image tile options.
|
|
*/
|
|
constructor(options) {
|
|
super({
|
|
attributions: options.attributions,
|
|
cacheSize: options.cacheSize,
|
|
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: options.interpolate !== void 0 ? options.interpolate : true,
|
|
key: options.key,
|
|
attributionsCollapsible: options.attributionsCollapsible,
|
|
zDirection: options.zDirection
|
|
});
|
|
this.crossOrigin = options.crossOrigin !== void 0 ? options.crossOrigin : null;
|
|
this.tileClass = options.tileClass !== void 0 ? options.tileClass : ImageTile_default;
|
|
this.tileGridForProjection = {};
|
|
this.reprojectionErrorThreshold_ = options.reprojectionErrorThreshold;
|
|
this.renderReprojectionEdges_ = false;
|
|
}
|
|
/**
|
|
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
* @return {number} Gutter.
|
|
* @override
|
|
*/
|
|
getGutterForProjection(projection) {
|
|
if (this.getProjection() && projection && !equivalent(this.getProjection(), projection)) {
|
|
return 0;
|
|
}
|
|
return this.getGutter();
|
|
}
|
|
/**
|
|
* @return {number} Gutter.
|
|
*/
|
|
getGutter() {
|
|
return 0;
|
|
}
|
|
/**
|
|
* Return the key to be used for all tiles in the source.
|
|
* @return {string} The key for all tiles.
|
|
* @override
|
|
*/
|
|
getKey() {
|
|
let key = super.getKey();
|
|
if (!this.getInterpolate()) {
|
|
key += ":disable-interpolation";
|
|
}
|
|
return key;
|
|
}
|
|
/**
|
|
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
|
|
* @override
|
|
*/
|
|
getTileGridForProjection(projection) {
|
|
const thisProj = this.getProjection();
|
|
if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
|
|
return this.tileGrid;
|
|
}
|
|
const projKey = getUid(projection);
|
|
if (!(projKey in this.tileGridForProjection)) {
|
|
this.tileGridForProjection[projKey] = getForProjection(projection);
|
|
}
|
|
return this.tileGridForProjection[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
|
|
*/
|
|
createTile_(z, x, y, pixelRatio, projection, key) {
|
|
const tileCoord = [z, x, y];
|
|
const urlTileCoord = this.getTileCoordForTileUrlFunction(
|
|
tileCoord,
|
|
projection
|
|
);
|
|
const tileUrl = urlTileCoord ? this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : void 0;
|
|
const tile = new this.tileClass(
|
|
tileCoord,
|
|
tileUrl !== void 0 ? TileState_default.IDLE : TileState_default.EMPTY,
|
|
tileUrl !== void 0 ? tileUrl : "",
|
|
this.crossOrigin,
|
|
this.tileLoadFunction,
|
|
this.tileOptions
|
|
);
|
|
tile.key = key;
|
|
tile.addEventListener(EventType_default.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.
|
|
* @override
|
|
*/
|
|
getTile(z, x, y, pixelRatio, projection) {
|
|
const sourceProjection = this.getProjection();
|
|
if (!sourceProjection || !projection || equivalent(sourceProjection, projection)) {
|
|
return this.getTileInternal(
|
|
z,
|
|
x,
|
|
y,
|
|
pixelRatio,
|
|
sourceProjection || projection
|
|
);
|
|
}
|
|
const tileCoord = [z, x, y];
|
|
const key = this.getKey();
|
|
const sourceTileGrid = this.getTileGridForProjection(sourceProjection);
|
|
const targetTileGrid = this.getTileGridForProjection(projection);
|
|
const wrappedTileCoord = this.getTileCoordForTileUrlFunction(
|
|
tileCoord,
|
|
projection
|
|
);
|
|
const tile = new Tile_default(
|
|
sourceProjection,
|
|
sourceTileGrid,
|
|
projection,
|
|
targetTileGrid,
|
|
tileCoord,
|
|
wrappedTileCoord,
|
|
this.getTilePixelRatio(pixelRatio),
|
|
this.getGutter(),
|
|
(z2, x2, y2, pixelRatio2) => this.getTileInternal(z2, x2, y2, pixelRatio2, sourceProjection),
|
|
this.reprojectionErrorThreshold_,
|
|
this.renderReprojectionEdges_,
|
|
this.tileOptions
|
|
);
|
|
tile.key = key;
|
|
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} Tile.
|
|
* @protected
|
|
*/
|
|
getTileInternal(z, x, y, pixelRatio, projection) {
|
|
const key = this.getKey();
|
|
return this.createTile_(z, x, y, pixelRatio, projection, key);
|
|
}
|
|
/**
|
|
* Sets whether to render reprojection edges or not (usually for debugging).
|
|
* @param {boolean} render Render the edges.
|
|
* @api
|
|
*/
|
|
setRenderReprojectionEdges(render) {
|
|
if (this.renderReprojectionEdges_ == render) {
|
|
return;
|
|
}
|
|
this.renderReprojectionEdges_ = render;
|
|
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
|
|
*/
|
|
setTileGridForProjection(projection, tilegrid) {
|
|
const proj = get(projection);
|
|
if (proj) {
|
|
const projKey = getUid(proj);
|
|
if (!(projKey in this.tileGridForProjection)) {
|
|
this.tileGridForProjection[projKey] = tilegrid;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
function defaultTileLoadFunction(imageTile, src) {
|
|
imageTile.getImage().src = src;
|
|
}
|
|
var TileImage_default = TileImage;
|
|
|
|
// node_modules/ol/source/XYZ.js
|
|
var XYZ = class extends TileImage_default {
|
|
/**
|
|
* @param {Options} [options] XYZ options.
|
|
*/
|
|
constructor(options) {
|
|
options = options || {};
|
|
const projection = options.projection !== void 0 ? options.projection : "EPSG:3857";
|
|
const tileGrid = options.tileGrid !== void 0 ? options.tileGrid : createXYZ({
|
|
extent: extentFromProjection(projection),
|
|
maxResolution: options.maxResolution,
|
|
maxZoom: options.maxZoom,
|
|
minZoom: options.minZoom,
|
|
tileSize: options.tileSize
|
|
});
|
|
super({
|
|
attributions: options.attributions,
|
|
cacheSize: options.cacheSize,
|
|
crossOrigin: options.crossOrigin,
|
|
interpolate: options.interpolate,
|
|
projection,
|
|
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
|
tileGrid,
|
|
tileLoadFunction: options.tileLoadFunction,
|
|
tilePixelRatio: options.tilePixelRatio,
|
|
tileUrlFunction: options.tileUrlFunction,
|
|
url: options.url,
|
|
urls: options.urls,
|
|
wrapX: options.wrapX !== void 0 ? options.wrapX : true,
|
|
transition: options.transition,
|
|
attributionsCollapsible: options.attributionsCollapsible,
|
|
zDirection: options.zDirection
|
|
});
|
|
this.gutter_ = options.gutter !== void 0 ? options.gutter : 0;
|
|
}
|
|
/**
|
|
* @return {number} Gutter.
|
|
* @override
|
|
*/
|
|
getGutter() {
|
|
return this.gutter_;
|
|
}
|
|
};
|
|
var XYZ_default = XYZ;
|
|
|
|
export {
|
|
getForProjection,
|
|
createXYZ,
|
|
extentFromProjection,
|
|
appendParams,
|
|
renderXYZTemplate,
|
|
pickUrl,
|
|
expandUrl,
|
|
createFromTemplates,
|
|
createFromTileUrlFunctions,
|
|
nullTileUrlFunction,
|
|
TileSourceEvent,
|
|
Tile_default2 as Tile_default,
|
|
TileEventType_default,
|
|
UrlTile_default,
|
|
TileImage_default,
|
|
XYZ_default
|
|
};
|
|
//# sourceMappingURL=chunk-GAUW6BWT.js.map
|