From 44dc60948e355355b6d882afc67d9a4c142d3467 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 4 Jun 2020 00:14:23 +0300 Subject: [PATCH] do not warn about exceeding extent when off by 1px (#9753) --- src/data/load_geometry.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/data/load_geometry.js b/src/data/load_geometry.js index 5a094fa1f81..c8885c57bda 100644 --- a/src/data/load_geometry.js +++ b/src/data/load_geometry.js @@ -10,14 +10,9 @@ import type Point from '@mapbox/point-geometry'; // While visible coordinates are within [0, EXTENT], tiles may theoretically // contain cordinates within [-Infinity, Infinity]. Our range is limited by the // number of bits used to represent the coordinate. -function createBounds(bits) { - return { - min: -1 * Math.pow(2, bits - 1), - max: Math.pow(2, bits - 1) - 1 - }; -} - -const bounds = createBounds(15); +const BITS = 15; +const MAX = Math.pow(2, BITS - 1) - 1; +const MIN = -MAX - 1; /** * Loads a geometry from a VectorTileFeature and scales it to the common extent @@ -34,13 +29,16 @@ export default function loadGeometry(feature: VectorTileFeature): Array bounds.max || point.y < bounds.min || point.y > bounds.max) { + if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) { + // warn when exceeding allowed extent except for the 1-px-off case + // https://github.com/mapbox/mapbox-gl-js/issues/8992 warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size'); - point.x = clamp(point.x, bounds.min, bounds.max); - point.y = clamp(point.y, bounds.min, bounds.max); } } }