diff --git a/src/data/bucket/line_bucket.js b/src/data/bucket/line_bucket.js index 7e11a4fdae4..d76021b75d6 100644 --- a/src/data/bucket/line_bucket.js +++ b/src/data/bucket/line_bucket.js @@ -121,7 +121,7 @@ class LineBucket implements Bucket { const lineSortKey = this.layers[0].layout.get('line-sort-key'); const bucketFeatures = []; - for (const {feature, index, sourceLayerIndex} of features) { + for (const {feature, id, index, sourceLayerIndex} of features) { if (!this.layers[0]._featureFilter(new EvaluationParameters(this.zoom), feature)) continue; const geometry = loadGeometry(feature); @@ -130,7 +130,7 @@ class LineBucket implements Bucket { undefined; const bucketFeature: BucketFeature = { - id: feature.id, + id, properties: feature.properties, type: feature.type, sourceLayerIndex, diff --git a/test/integration/render-tests/feature-state/promote-id-circle/expected.png b/test/integration/render-tests/feature-state/promote-id-circle/expected.png new file mode 100644 index 00000000000..1587818fee0 Binary files /dev/null and b/test/integration/render-tests/feature-state/promote-id-circle/expected.png differ diff --git a/test/integration/render-tests/feature-state/promote-id/style.json b/test/integration/render-tests/feature-state/promote-id-circle/style.json similarity index 100% rename from test/integration/render-tests/feature-state/promote-id/style.json rename to test/integration/render-tests/feature-state/promote-id-circle/style.json diff --git a/test/integration/render-tests/feature-state/promote-id-fill-extrusion/expected.png b/test/integration/render-tests/feature-state/promote-id-fill-extrusion/expected.png new file mode 100644 index 00000000000..95a581a0695 Binary files /dev/null and b/test/integration/render-tests/feature-state/promote-id-fill-extrusion/expected.png differ diff --git a/test/integration/render-tests/feature-state/promote-id-fill-extrusion/style.json b/test/integration/render-tests/feature-state/promote-id-fill-extrusion/style.json new file mode 100644 index 00000000000..a4a31d62dfa --- /dev/null +++ b/test/integration/render-tests/feature-state/promote-id-fill-extrusion/style.json @@ -0,0 +1,161 @@ +{ + "version": 8, + "metadata": { + "test": { + "height": 128, + "width": 512, + "operations": [ + [ + "setFeatureState", + { + "source": "geojson", + "id": "9007199254740992" + }, + { + "color": "red" + } + ], + [ + "setFeatureState", + { + "source": "geojson", + "id": "1.2" + }, + { + "color": "blue" + } + ], + [ + "wait" + ] + ] + } + }, + "sources": { + "geojson": { + "type": "geojson", + "promoteId": "foo", + "data": { + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -0.0005, + -0.0001 + ], + [ + -0.0005, + 0.0001 + ], + [ + -0.0003, + 0.0001 + ], + [ + -0.0003, + -0.0001 + ], + [ + -0.0005, + -0.0001 + ] + ] + ] + }, + "properties": { + "foo": "9007199254740992" + } + }, { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -0.0001, + -0.0001 + ], + [ + -0.0001, + 0.0001 + ], + [ + 0.0001, + 0.0001 + ], + [ + 0.0001, + -0.0001 + ], + [ + -0.0001, + -0.0001 + ] + ] + ] + }, + "properties": { + "foo": "9007199254740993" + } + }, { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0.0003, + -0.0001 + ], + [ + 0.0003, + 0.0001 + ], + [ + 0.0005, + 0.0001 + ], + [ + 0.0005, + -0.0001 + ], + [ + 0.0003, + -0.0001 + ] + ] + ] + }, + "properties": { + "foo": "1.2" + } + }] + } + } + }, + "pitch": 60, + "zoom": 18, + "layers": [ + { + "id": "fill-extrusion", + "type": "fill-extrusion", + "source": "geojson", + "paint": { + "fill-extrusion-height": 10, + "fill-extrusion-base": 0, + "fill-extrusion-color": [ + "coalesce", + [ + "feature-state", + "color" + ], + "black" + ] + } + } + ] +} diff --git a/test/integration/render-tests/feature-state/promote-id-fill/expected.png b/test/integration/render-tests/feature-state/promote-id-fill/expected.png new file mode 100644 index 00000000000..aa7e7f3f27b Binary files /dev/null and b/test/integration/render-tests/feature-state/promote-id-fill/expected.png differ diff --git a/test/integration/render-tests/feature-state/promote-id-fill/style.json b/test/integration/render-tests/feature-state/promote-id-fill/style.json new file mode 100644 index 00000000000..31514683e4d --- /dev/null +++ b/test/integration/render-tests/feature-state/promote-id-fill/style.json @@ -0,0 +1,114 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 32, + "operations": [ + [ + "setFeatureState", + { + "source": "geojson", + "id": "9007199254740992" + }, + { + "color": "red" + } + ], + [ + "setFeatureState", + { + "source": "geojson", + "id": "1.2" + }, + { + "color": "blue" + } + ], + [ + "wait" + ] + ] + } + }, + "zoom": 2, + "sources": { + "geojson": { + "type": "geojson", + "promoteId": "foo", + "data": { + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ -5, -1 ], + [ -5, 1 ], + [ -3, 1 ], + [ -3, -1 ], + [ -5, -1 ] + ] + ] + }, + "properties": { + "foo": "9007199254740992" + } + }, { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ -1, -1 ], + [ -1, 1 ], + [ 1, 1 ], + [ 1, -1 ], + [ -0.5, -1 ] + ] + ] + }, + "properties": { + "foo": "9007199254740993" + } + }, { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ 3, -1 ], + [ 3, 1 ], + [ 5, 1 ], + [ 5, -1 ], + [ 3, -1 ] + ] + ] + }, + "properties": { + "foo": "1.2" + } + }] + } + } + }, + "layers": [ + { + "id": "fill", + "type": "fill", + "source": "geojson", + "paint": { + "fill-antialias": false, + "fill-color": [ + "coalesce", + [ + "feature-state", + "color" + ], + "black" + ] + } + } + ] +} diff --git a/test/integration/render-tests/feature-state/promote-id-line/expected.png b/test/integration/render-tests/feature-state/promote-id-line/expected.png new file mode 100644 index 00000000000..55bfc9fa640 Binary files /dev/null and b/test/integration/render-tests/feature-state/promote-id-line/expected.png differ diff --git a/test/integration/render-tests/feature-state/promote-id-line/style.json b/test/integration/render-tests/feature-state/promote-id-line/style.json new file mode 100644 index 00000000000..b2ec7836cde --- /dev/null +++ b/test/integration/render-tests/feature-state/promote-id-line/style.json @@ -0,0 +1,116 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 32, + "operations": [ + [ + "setFeatureState", + { + "source": "geojson", + "id": "9007199254740992" + }, + { + "color": "red" + } + ], + [ + "setFeatureState", + { + "source": "geojson", + "id": "1.2" + }, + { + "color": "blue" + } + ], + [ + "wait" + ] + ] + } + }, + "sources": { + "geojson": { + "type": "geojson", + "promoteId": "foo", + "data": { + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -10, + -10 + ], + [ + -10, + 10 + ] + ] + }, + "properties": { + "foo": "9007199254740992" + } + }, { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + -10 + ], + [ + 0, + 10 + ] + ] + }, + "properties": { + "foo": "9007199254740993" + } + }, { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 10, + -10 + ], + [ + 10, + 10 + ] + ] + }, + "properties": { + "foo": "1.2" + } + }] + } + } + }, + "layers": [ + { + "id": "line", + "type": "line", + "source": "geojson", + "paint": { + "line-width": 5, + "line-color": [ + "coalesce", + [ + "feature-state", + "color" + ], + "black" + ] + } + } + ] +} diff --git a/test/integration/render-tests/feature-state/promote-id-symbol/expected.png b/test/integration/render-tests/feature-state/promote-id-symbol/expected.png new file mode 100644 index 00000000000..3c3d132c91a Binary files /dev/null and b/test/integration/render-tests/feature-state/promote-id-symbol/expected.png differ diff --git a/test/integration/render-tests/feature-state/promote-id-symbol/style.json b/test/integration/render-tests/feature-state/promote-id-symbol/style.json new file mode 100644 index 00000000000..374dc13e84e --- /dev/null +++ b/test/integration/render-tests/feature-state/promote-id-symbol/style.json @@ -0,0 +1,103 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 32, + "operations": [ + [ + "setFeatureState", + { + "source": "geojson", + "id": "9007199254740992" + }, + { + "color": "red" + } + ], + [ + "setFeatureState", + { + "source": "geojson", + "id": "1.2" + }, + { + "color": "blue" + } + ], + [ + "wait" + ] + ] + } + }, + "zoom": 2, + "sprite": "local://sprites/sprite", + "sources": { + "geojson": { + "type": "geojson", + "promoteId": "foo", + "data": { + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + }, + "properties": { + "foo": "9007199254740992" + } + }, { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 3, + 0 + ] + }, + "properties": { + "foo": "9007199254740993" + } + }, { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -3, + 0 + ] + }, + "properties": { + "foo": "1.2" + } + }] + } + } + }, + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "icon-image": "dot.sdf", + "icon-allow-overlap": true + }, + "paint": { + "icon-color": [ + "coalesce", + [ + "feature-state", + "color" + ], + "black" + ] + } + } + ] +} diff --git a/test/integration/render-tests/feature-state/promote-id/expected.png b/test/integration/render-tests/feature-state/promote-id/expected.png deleted file mode 100644 index 7e58decb017..00000000000 Binary files a/test/integration/render-tests/feature-state/promote-id/expected.png and /dev/null differ