From 792e15124d7503a7d212c58911dd99d776dbcdc5 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sun, 23 Aug 2020 12:37:52 +0200 Subject: [PATCH] VectorTile source projection has to match the view projection --- doc/errors/index.md | 6 +++++- src/ol/renderer/canvas/VectorTileLayer.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/errors/index.md b/doc/errors/index.md index e45f47bd3b..58c85f79ff 100644 --- a/doc/errors/index.md +++ b/doc/errors/index.md @@ -248,4 +248,8 @@ This is done by providing adequate shaders using the `hitVertexShader` and `hitF ### 67 -A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both. \ No newline at end of file +A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both. + +### 68 + +A VectorTile source can only be rendered if it has a projection compatible with the view projection. \ No newline at end of file diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js index 80d88dfc0c..ab53ca17c5 100644 --- a/src/ol/renderer/canvas/VectorTileLayer.js +++ b/src/ol/renderer/canvas/VectorTileLayer.js @@ -20,6 +20,7 @@ import { scale as scaleTransform, translate as translateTransform, } from '../../transform.js'; +import {assert} from '../../asserts.js'; import { buffer, containsCoordinate, @@ -34,6 +35,7 @@ import { createHitDetectionImageData, hitDetect, } from '../../render/canvas/hitdetect.js'; +import {equivalent} from '../../proj.js'; import { getSquaredTolerance as getSquaredRenderTolerance, renderFeature, @@ -230,7 +232,15 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer { * @return {boolean} Layer is ready to be rendered. */ prepareFrame(frameState) { - const layerRevision = this.getLayer().getRevision(); + const layer = this.getLayer(); + assert( + equivalent( + layer.getSource().getProjection(), + frameState.viewState.projection + ), + 68 // A VectorTile source can only be rendered if it has a projection compatible with the view projection. + ); + const layerRevision = layer.getRevision(); if (this.renderedLayerRevision_ != layerRevision) { this.renderedTiles.length = 0; }