From 667cadc40344cdc638ff45ef1862ef73eb814ec3 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 18 Feb 2019 12:00:42 +0100 Subject: [PATCH] Remove extent default so we catch errors when extent is not set --- src/ol/VectorTile.js | 11 ++--------- src/ol/source/VectorTile.js | 3 +-- test/spec/ol/renderer/canvas/vectortilelayer.test.js | 1 + 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ol/VectorTile.js b/src/ol/VectorTile.js index 1f11491345..5ec352a03c 100644 --- a/src/ol/VectorTile.js +++ b/src/ol/VectorTile.js @@ -4,13 +4,6 @@ import Tile from './Tile.js'; import TileState from './TileState.js'; -/** - * @const - * @type {import("./extent.js").Extent} - */ -const DEFAULT_EXTENT = [0, 0, 4096, 4096]; - - class VectorTile extends Tile { /** @@ -89,7 +82,7 @@ class VectorTile extends Tile { * @api */ getExtent() { - return this.extent_ || DEFAULT_EXTENT; + return this.extent_; } /** @@ -166,7 +159,7 @@ class VectorTile extends Tile { * calculated by multiplying the tile size with the tile pixel ratio. For * sources using {@link module:ol/format/MVT~MVT} as feature format, the * {@link module:ol/format/MVT~MVT#getLastExtent} method will return the correct - * extent. The default is `[0, 0, 4096, 4096]`. + * extent. * @param {import("./extent.js").Extent} extent The extent. * @api */ diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 54269795be..a98900d3ad 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -42,12 +42,11 @@ import {equals} from '../array.js'; * var data = // ... fetch data * var format = tile.getFormat(); * tile.setProjection(format.readProjection(data)); + * tile.setExtent(format.getLastExtent()); // line only required for ol/format/MVT * tile.setFeatures(format.readFeatures(data, { * // featureProjection is not required for ol/format/MVT * featureProjection: map.getView().getProjection() * })); - * // the line below is only required for ol/format/MVT - * tile.setExtent(format.getLastExtent()); * } * }); * ``` diff --git a/test/spec/ol/renderer/canvas/vectortilelayer.test.js b/test/spec/ol/renderer/canvas/vectortilelayer.test.js index b2b402e73e..fb4f5c6d92 100644 --- a/test/spec/ol/renderer/canvas/vectortilelayer.test.js +++ b/test/spec/ol/renderer/canvas/vectortilelayer.test.js @@ -203,6 +203,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { let tile; tileCallback = function(t) { t.setProjection(proj); + t.setExtent([0, 0, 4096, 4096]); tile = t; }; map.renderSync();