Skip to content

Commit

Permalink
Fix promoteId for line layers (#9210)
Browse files Browse the repository at this point in the history
* fix promoteId for line layers

* fix promoteId spec definitions (#9212)

* Add render tests for feature state
feature-state/promote-id-line will fail until #9210 is merged

Co-authored-by: Karim Naaji <karim.naaji@gmail.com>
  • Loading branch information
2 people authored and ahk committed Jan 22, 2020
1 parent a13efc0 commit 28603d1
Show file tree
Hide file tree
Showing 12 changed files with 496 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -130,7 +130,7 @@ class LineBucket implements Bucket {
undefined;

const bucketFeature: BucketFeature = {
id: feature.id,
id,
properties: feature.properties,
type: feature.type,
sourceLayerIndex,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions test/integration/render-tests/feature-state/promote-id-fill/style.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 28603d1

Please sign in to comment.