Use standard tile coords

This commit is contained in:
Tim Schaub
2018-11-20 15:28:24 -07:00
parent 37c987de0a
commit e9a30c5cb7
29 changed files with 241 additions and 229 deletions
+8 -8
View File
@@ -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];
+3 -4
View File
@@ -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']]);
}
});