From 4c7337627d94d8265e8cebac536981c321089b62 Mon Sep 17 00:00:00 2001 From: ryanhamley Date: Mon, 7 Oct 2019 15:01:42 -0700 Subject: [PATCH 1/2] Fix buggy image coercion so image names resolve correctly --- src/style-spec/expression/definitions/coercion.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/style-spec/expression/definitions/coercion.js b/src/style-spec/expression/definitions/coercion.js index e50c1eb6ddd..9001e60f9ae 100644 --- a/src/style-spec/expression/definitions/coercion.js +++ b/src/style-spec/expression/definitions/coercion.js @@ -102,8 +102,8 @@ class Coercion implements Expression { // created by properties that expect the 'formatted' type. return Formatted.fromString(valueToString(this.args[0].evaluate(ctx))); } else if (this.type.kind === 'image') { - const name = valueToString(this.args[0].evaluate(ctx)); - return ResolvedImage.fromString({name, available: false}); + const name = this.args[0].evaluate(ctx); + return typeof name === 'string' ? ResolvedImage.fromString({name, available: false}) : name; } else { return valueToString(this.args[0].evaluate(ctx)); } From 1cd8c400dcea5c69fd9b156aa9208b2f9a99a728 Mon Sep 17 00:00:00 2001 From: ryanhamley Date: Tue, 8 Oct 2019 17:07:35 -0700 Subject: [PATCH 2/2] Add render test for expression --- .../icon-image/image-expression/expected.png | Bin 0 -> 294 bytes .../icon-image/image-expression/style.json | 32 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/integration/render-tests/icon-image/image-expression/expected.png create mode 100644 test/integration/render-tests/icon-image/image-expression/style.json diff --git a/test/integration/render-tests/icon-image/image-expression/expected.png b/test/integration/render-tests/icon-image/image-expression/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..0cd32ecc4546e24ac74968db277a7ed43aabc856 GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Or9=|Ar*{or0OmKdG|rQw+AzuFCUdr`_R*MyP?NZ`**|C_6n VqU)2ECIh|7;OXk;vd$@?2>=p&caH!7 literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/icon-image/image-expression/style.json b/test/integration/render-tests/icon-image/image-expression/style.json new file mode 100644 index 00000000000..7f0390b0e92 --- /dev/null +++ b/test/integration/render-tests/icon-image/image-expression/style.json @@ -0,0 +1,32 @@ +{ + "version": 8, + "metadata": { + "test": { + "height": 64, + "width": 64 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "text", + "type": "symbol", + "source": "geojson", + "layout": { + "icon-image": ["coalesce", ["image", "dot.sdf"], ["image", "foo"]] + } + } + ] +}