Use standard tile coords
This commit is contained in:
@@ -274,7 +274,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
||||
// Calculate integer positions and sizes so that tiles align
|
||||
const floatX = (origin[0] - (originTileCoord[1] - tileCoord[1]) * dx);
|
||||
const nextX = Math.round(floatX + dx);
|
||||
const floatY = (origin[1] + (originTileCoord[2] - tileCoord[2]) * dy);
|
||||
const floatY = (origin[1] - (originTileCoord[2] - tileCoord[2]) * dy);
|
||||
const nextY = Math.round(floatY + dy);
|
||||
const x = Math.round(floatX);
|
||||
const y = Math.round(floatY);
|
||||
|
||||
@@ -250,7 +250,7 @@ class BingMaps extends TileImage {
|
||||
if (!tileCoord) {
|
||||
return undefined;
|
||||
} else {
|
||||
createOrUpdate(tileCoord[0], tileCoord[1], -tileCoord[2] - 1, quadKeyTileCoord);
|
||||
createOrUpdate(tileCoord[0], tileCoord[1], tileCoord[2], quadKeyTileCoord);
|
||||
let url = imageUrl;
|
||||
if (hidpi) {
|
||||
url += '&dpi=d1&device=mobile';
|
||||
|
||||
@@ -121,7 +121,7 @@ class TileDebug extends XYZ {
|
||||
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
|
||||
let text;
|
||||
if (textTileCoord) {
|
||||
text = 'z:' + textTileCoord[0] + ' x:' + textTileCoord[1] + ' y:' + (-textTileCoord[2] - 1);
|
||||
text = 'z:' + textTileCoord[0] + ' x:' + textTileCoord[1] + ' y:' + textTileCoord[2];
|
||||
} else {
|
||||
text = 'none';
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ function createFromWMTSTemplate(template) {
|
||||
const localContext = {
|
||||
'TileMatrix': tileGrid.getMatrixId(tileCoord[0]),
|
||||
'TileCol': tileCoord[1],
|
||||
'TileRow': -tileCoord[2] - 1
|
||||
'TileRow': tileCoord[2]
|
||||
};
|
||||
assign(localContext, dimensions);
|
||||
let url = template;
|
||||
|
||||
@@ -213,7 +213,7 @@ class Zoomify extends TileImage {
|
||||
} else {
|
||||
const tileCoordZ = tileCoord[0];
|
||||
const tileCoordX = tileCoord[1];
|
||||
const tileCoordY = -tileCoord[2] - 1;
|
||||
const tileCoordY = tileCoord[2];
|
||||
const tileIndex =
|
||||
tileCoordX +
|
||||
tileCoordY * tierSizeInTiles[tileCoordZ][0];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/**
|
||||
* An array of three numbers representing the location of a tile in a tile
|
||||
* grid. The order is `z`, `x`, and `y`. `z` is the zoom level.
|
||||
* grid. The order is `z` (zoom level), `x` (column), and `y` (row).
|
||||
* @typedef {Array<number>} TileCoord
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -342,10 +342,10 @@ class TileGrid {
|
||||
*/
|
||||
getTileRangeForExtentAndZ(extent, z, opt_tileRange) {
|
||||
const tileCoord = tmpTileCoord;
|
||||
this.getTileCoordForXYAndZ_(extent[0], extent[1], z, false, tileCoord);
|
||||
this.getTileCoordForXYAndZ_(extent[0], extent[3], z, false, tileCoord);
|
||||
const minX = tileCoord[1];
|
||||
const minY = tileCoord[2];
|
||||
this.getTileCoordForXYAndZ_(extent[2], extent[3], z, true, tileCoord);
|
||||
this.getTileCoordForXYAndZ_(extent[2], extent[1], z, true, tileCoord);
|
||||
return createOrUpdateTileRange(minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ class TileGrid {
|
||||
const tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_);
|
||||
return [
|
||||
origin[0] + (tileCoord[1] + 0.5) * tileSize[0] * resolution,
|
||||
origin[1] + (tileCoord[2] + 0.5) * tileSize[1] * resolution
|
||||
origin[1] - (tileCoord[2] + 0.5) * tileSize[1] * resolution
|
||||
];
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ class TileGrid {
|
||||
const resolution = this.getResolution(tileCoord[0]);
|
||||
const tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_);
|
||||
const minX = origin[0] + tileCoord[1] * tileSize[0] * resolution;
|
||||
const minY = origin[1] + tileCoord[2] * tileSize[1] * resolution;
|
||||
const minY = origin[1] - (tileCoord[2] + 1) * tileSize[1] * resolution;
|
||||
const maxX = minX + tileSize[0] * resolution;
|
||||
const maxY = minY + tileSize[1] * resolution;
|
||||
return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
|
||||
@@ -418,9 +418,9 @@ class TileGrid {
|
||||
const tileSize = toSize(this.getTileSize(z), this.tmpSize_);
|
||||
|
||||
const adjustX = reverseIntersectionPolicy ? 0.5 : 0;
|
||||
const adjustY = reverseIntersectionPolicy ? 0 : 0.5;
|
||||
const adjustY = reverseIntersectionPolicy ? 0.5 : 0;
|
||||
const xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
|
||||
const yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY);
|
||||
const yFromOrigin = Math.floor((origin[1] - y) / resolution + adjustY);
|
||||
let tileCoordX = scale * xFromOrigin / tileSize[0];
|
||||
let tileCoordY = scale * yFromOrigin / tileSize[1];
|
||||
|
||||
@@ -456,9 +456,9 @@ class TileGrid {
|
||||
const tileSize = toSize(this.getTileSize(z), this.tmpSize_);
|
||||
|
||||
const adjustX = reverseIntersectionPolicy ? 0.5 : 0;
|
||||
const adjustY = reverseIntersectionPolicy ? 0 : 0.5;
|
||||
const adjustY = reverseIntersectionPolicy ? 0.5 : 0;
|
||||
const xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
|
||||
const yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY);
|
||||
const yFromOrigin = Math.floor((origin[1] - y) / resolution + adjustY);
|
||||
let tileCoordX = xFromOrigin / tileSize[0];
|
||||
let tileCoordY = yFromOrigin / tileSize[1];
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ import TileGrid from './TileGrid.js';
|
||||
* `TileMatrixHeight` advertised in the GetCapabilities response of the WMTS, and
|
||||
* define the grid's extent together with the `origin`.
|
||||
* An `extent` can be configured in addition, and will further limit the extent for
|
||||
* which tile requests are made by sources. Note that when the top-left corner of
|
||||
* which tile requests are made by sources. If the bottom-left corner of
|
||||
* the `extent` is used as `origin` or `origins`, then the `y` value must be
|
||||
* negative because OpenLayers tile coordinates increase upwards.
|
||||
* negative because OpenLayers tile coordinates use the top left as the origin.
|
||||
* @property {number|import("../size.js").Size} [tileSize] Tile size.
|
||||
* @property {Array<import("../size.js").Size>} [tileSizes] Tile sizes. The length of
|
||||
* this array needs to match the length of the `resolutions` array.
|
||||
@@ -174,8 +174,7 @@ export function createFromCapabilitiesMatrixSet(matrixSet, opt_extent, opt_matri
|
||||
resolutions.push(resolution);
|
||||
tileSizes.push(tileWidth == tileHeight ?
|
||||
tileWidth : [tileWidth, tileHeight]);
|
||||
// top-left origin, so height is negative
|
||||
sizes.push([elt['MatrixWidth'], -elt['MatrixHeight']]);
|
||||
sizes.push([elt['MatrixWidth'], elt['MatrixHeight']]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -29,15 +29,12 @@ export function createFromTemplate(template, tileGrid) {
|
||||
} else {
|
||||
return template.replace(zRegEx, tileCoord[0].toString())
|
||||
.replace(xRegEx, tileCoord[1].toString())
|
||||
.replace(yRegEx, function() {
|
||||
const y = -tileCoord[2] - 1;
|
||||
return y.toString();
|
||||
})
|
||||
.replace(yRegEx, tileCoord[2].toString())
|
||||
.replace(dashYRegEx, function() {
|
||||
const z = tileCoord[0];
|
||||
const range = tileGrid.getFullTileRange(z);
|
||||
assert(range, 55); // The {-y} placeholder requires a tile grid with extent
|
||||
const y = range.getHeight() + tileCoord[2];
|
||||
const y = range.getHeight() - tileCoord[2] - 1;
|
||||
return y.toString();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user