From 9090d101e6b6d3f06b9a9e49d54dca4c22bcae74 Mon Sep 17 00:00:00 2001 From: Molly Lloyd Date: Fri, 13 Apr 2018 13:26:58 -0700 Subject: [PATCH] Only evaluate CrossFaded properties at integer zooms (#6430) * validate non-integer stops for crossfaded properties * add to style spec docs * remove validation errors, only evalutate CrossFaded props at integer zooms * reword spec --- src/style-spec/reference/v8.json | 10 +++++----- src/style/properties.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/style-spec/reference/v8.json b/src/style-spec/reference/v8.json index 67c88453431..54d250ede75 100644 --- a/src/style-spec/reference/v8.json +++ b/src/style-spec/reference/v8.json @@ -2860,7 +2860,7 @@ "function": "piecewise-constant", "zoom-function": true, "transition": true, - "doc": "Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).", + "doc": "Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", "sdk-support": { "basic functionality": { "js": "0.10.0", @@ -2975,7 +2975,7 @@ "function": "piecewise-constant", "zoom-function": true, "transition": true, - "doc": "Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).", + "doc": "Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", "sdk-support": { "basic functionality": { "js": "0.27.0", @@ -3245,7 +3245,7 @@ "value": "number", "function": "piecewise-constant", "zoom-function": true, - "doc": "Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale.", + "doc": "Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels.", "minimum": 0, "transition": true, "units": "line widths", @@ -3269,7 +3269,7 @@ "function": "piecewise-constant", "zoom-function": true, "transition": true, - "doc": "Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512).", + "doc": "Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", "sdk-support": { "basic functionality": { "js": "0.10.0", @@ -4313,7 +4313,7 @@ "function": "piecewise-constant", "zoom-function": true, "transition": true, - "doc": "Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).", + "doc": "Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", "sdk-support": { "basic functionality": { "js": "0.10.0", diff --git a/src/style/properties.js b/src/style/properties.js index 4145dc47872..c3f7c4c89ff 100644 --- a/src/style/properties.js +++ b/src/style/properties.js @@ -598,9 +598,9 @@ export class CrossFadedProperty implements Property> { } else { assert(!value.isDataDriven()); return this._calculate( - value.expression.evaluate({zoom: parameters.zoom - 1.0}), - value.expression.evaluate({zoom: parameters.zoom}), - value.expression.evaluate({zoom: parameters.zoom + 1.0}), + value.expression.evaluate({zoom: Math.floor(parameters.zoom - 1.0)}), + value.expression.evaluate({zoom: Math.floor(parameters.zoom)}), + value.expression.evaluate({zoom: Math.floor(parameters.zoom + 1.0)}), parameters); } }