Merge pull request #13832 from mike-000/vector-tile-grids

Base vector tile render tile grid on the source grid
This commit is contained in:
Andreas Hocevar
2022-07-18 10:07:52 +02:00
committed by GitHub
6 changed files with 42 additions and 27 deletions

View File

@@ -496,7 +496,9 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
let hitDetectionImageData = tile.hitDetectionImageData[layerUid];
if (!hitDetectionImageData && !this.animatingOrInteracting_) {
const tileSize = toSize(
tileGrid.getTileSize(tileGrid.getZForResolution(resolution))
tileGrid.getTileSize(
tileGrid.getZForResolution(resolution, source.zDirection)
)
);
const rotation = this.renderedRotation_;
const transforms = [

View File

@@ -5,19 +5,17 @@
import EventType from '../events/EventType.js';
import Tile from '../VectorTile.js';
import TileCache from '../TileCache.js';
import TileGrid from '../tilegrid/TileGrid.js';
import TileState from '../TileState.js';
import UrlTile from './UrlTile.js';
import VectorRenderTile from '../VectorRenderTile.js';
import {DEFAULT_MAX_ZOOM} from '../tilegrid/common.js';
import {
buffer as bufferExtent,
getIntersection,
intersects,
} from '../extent.js';
import {
createForProjection,
createXYZ,
extentFromProjection,
} from '../tilegrid.js';
import {createXYZ, extentFromProjection} from '../tilegrid.js';
import {fromKey, getCacheKeyForTileKey, getKeyZXY} from '../tilecoord.js';
import {isEmpty} from '../obj.js';
import {loadFeaturesXhr} from '../featureloader.js';
@@ -274,7 +272,10 @@ class VectorTile extends UrlTile {
if (sourceExtent) {
getIntersection(extent, sourceExtent, extent);
}
const sourceZ = sourceTileGrid.getZForResolution(resolution, 1);
const sourceZ = sourceTileGrid.getZForResolution(
resolution,
this.zDirection
);
sourceTileGrid.forEachTileCoord(extent, sourceZ, (sourceTileCoord) => {
const tileUrl = this.tileUrlFunction(
@@ -428,13 +429,25 @@ class VectorTile extends UrlTile {
// A tile grid that matches the tile size of the source tile grid is more
// likely to have 1:1 relationships between source tiles and rendered tiles.
const sourceTileGrid = this.tileGrid;
tileGrid = createForProjection(
projection,
undefined,
sourceTileGrid
? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom())
: undefined
);
const resolutions = sourceTileGrid.getResolutions().slice();
const origins = resolutions.map(function (resolution, z) {
return sourceTileGrid.getOrigin(z);
});
const tileSizes = resolutions.map(function (resolution, z) {
return sourceTileGrid.getTileSize(z);
});
const length = DEFAULT_MAX_ZOOM + 1;
for (let z = resolutions.length; z < length; ++z) {
resolutions.push(resolutions[z - 1] / 2);
origins.push(origins[z - 1]);
tileSizes.push(tileSizes[z - 1]);
}
tileGrid = new TileGrid({
extent: sourceTileGrid.getExtent(),
origins: origins,
resolutions: resolutions,
tileSizes: tileSizes,
});
this.tileGrids_[code] = tileGrid;
}
return tileGrid;

View File

@@ -51,7 +51,7 @@ const DECIMALS = 5;
* negative because OpenLayers tile coordinates use the top left as the origin.
* @property {number|import("../size.js").Size} [tileSize] Tile size.
* Default is `[256, 256]`.
* @property {Array<import("../size.js").Size>} [tileSizes] Tile sizes. If given, the array length
* @property {Array<number|import("../size.js").Size>} [tileSizes] Tile sizes. If given, the array length
* should match the length of the `resolutions` array, i.e. each resolution can have a different
* tile size.
*/

View File

@@ -34,7 +34,7 @@ import {get as getProjection} from '../proj.js';
* an extent is used as `origin` or `origins`, then the `y` value must be
* 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
* @property {Array<number|import("../size.js").Size>} [tileSizes] Tile sizes. The length of
* this array needs to match the length of the `resolutions` array.
*/
@@ -108,7 +108,7 @@ export function createFromCapabilitiesMatrixSet(
const matrixIds = [];
/** @type {!Array<import("../coordinate.js").Coordinate>} */
const origins = [];
/** @type {!Array<import("../size.js").Size>} */
/** @type {!Array<number|import("../size.js").Size>} */
const tileSizes = [];
/** @type {!Array<import("../size.js").Size>} */
const sizes = [];