From 55d8eb288c42064666fa60c9a37c5f280da37b5a Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 22 Jan 2020 23:15:11 +0200 Subject: [PATCH] Fix promoteId for line layers (#9210) * 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 --- src/data/bucket/line_bucket.js | 4 +- .../promote-id-circle/expected.png | Bin 0 -> 350 bytes .../style.json | 0 .../promote-id-fill-extrusion/expected.png | Bin 0 -> 2196 bytes .../promote-id-fill-extrusion/style.json | 161 ++++++++++++++++++ .../promote-id-fill/expected.png | Bin 0 -> 126 bytes .../feature-state/promote-id-fill/style.json | 114 +++++++++++++ .../promote-id-line/expected.png | Bin 0 -> 166 bytes .../feature-state/promote-id-line/style.json | 116 +++++++++++++ .../promote-id-symbol/expected.png | Bin 0 -> 564 bytes .../promote-id-symbol/style.json | 103 +++++++++++ .../feature-state/promote-id/expected.png | Bin 349 -> 0 bytes 12 files changed, 496 insertions(+), 2 deletions(-) create mode 100644 test/integration/render-tests/feature-state/promote-id-circle/expected.png rename test/integration/render-tests/feature-state/{promote-id => promote-id-circle}/style.json (100%) create mode 100644 test/integration/render-tests/feature-state/promote-id-fill-extrusion/expected.png create mode 100644 test/integration/render-tests/feature-state/promote-id-fill-extrusion/style.json create mode 100644 test/integration/render-tests/feature-state/promote-id-fill/expected.png create mode 100644 test/integration/render-tests/feature-state/promote-id-fill/style.json create mode 100644 test/integration/render-tests/feature-state/promote-id-line/expected.png create mode 100644 test/integration/render-tests/feature-state/promote-id-line/style.json create mode 100644 test/integration/render-tests/feature-state/promote-id-symbol/expected.png create mode 100644 test/integration/render-tests/feature-state/promote-id-symbol/style.json delete mode 100644 test/integration/render-tests/feature-state/promote-id/expected.png 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 0000000000000000000000000000000000000000..1587818fee0a1c76612df5f3599bf1d2b6a3cc3a GIT binary patch literal 350 zcmV-k0iphhP)5NqVQybT`lCRm!UnZ{ zEf$GSW&UDm-xj~|u25x~XUugi$#=?ZQ0uC(QRWUyU2{B}pi(TK;aI;5@}U8l8EXCN z%*?PuTnzyqFy5JCtcgb+&n2lY)s5_y^5bN~PV07*qoM6N<$f+bO$OaK4? literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..95a581a0695c85aec02e07a77801c5e31f62bd98 GIT binary patch literal 2196 zcmb_d|2LcW9)E%=QdF6mx^s8hLxVQ4M3uI>ehaervQR8#71ItmI*X7_N7FW`p;k&Y zLakI{_nNeKrEOT1^wc;tN0x51W2AJL)3Dv#TbF6?>uG!cft~Az9Le)~UhmhJ_vd+v zq9a4??cD7Mg0K${+sh*e3;at+ZLIN`AFrnpgw28Qy}M$MQl4~g%bf^Yb6USMOU5cY zP#@uLZlxbhjQ`|N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$7{z1szEeX&Ay+OO5TZwuvKyndFN@|`87M?A~M`Ts)@U|oZSA7>yO{E z%Fzg;`lGqI_Bf>Dh(;K%O9G8=Vl(6K>BMkm%To60M`aJN-;`mGr>AVMO>{CN8uhZz zO_$foFR+A(}6O)9pIYOyp!aJB8*tP0i^W>EWg-vL^qC? z&$F_ZcL>c^5L|~>ixu(wQ31n9!(i_;*?!cv91mec$an!`xk{cRG?Srt8IYcojsu}M mvov7!C*RQjm)p7yKC}ENb!w6DSapyj4Br>ISF=0$|a;-^}RkSG<;NlU!=UrVw|B&&X% Q2sDtv)78&qol`;+0JLH!{Qv*} literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..55bfc9fa6404f125d3aa395c8d1ab6f6bd77ffe8 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQn{Wkjv*C{Zx3$dZFXQ_G5GJx zHo4V@ZT7@jZAu~vvfILUK5UvRI(c#B2FvdUAHC>4y0Z4rtBm9`|3scXvMe+2C<@d& t<+@Wt{OO{YDc!g@cakeQD)z4W%OLWI)8f%IhbExK44$rjF6*2UngEQhK(zn> literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..3c3d132c91ad29dcde29f00080eedcb3de1197a4 GIT binary patch literal 564 zcmV-40?Yl0P)ZUnT z#{kx05)Iszs3A#Qi3`}OT0eHuoThxQLS$LwOklTaeHfqOamgFi3jBo$)fyPbOT3hz zkmdk(sW*b(b+$LKPrX%vBRU($LG=c3RH8zfEeN{XL@ZSM6%E~OjP$9t8OwFI0Rs{g zesYC0PY`wYiqKZ=DHe72I?z(>Ilk)d4dx^$q`66apx#GZ)!BXAQtwmbiq0P6hI(_j zEKx&}vPJVh?8306W-&#$rh}4plULY*F-v{L$%2bIi})8?vDQ)xIEB9@YDiYTqdAS` z7(@e~a2Ll37j;qcVTyZ!J`AD{vyth*37js8>iv&9C@_R&_>4y=@h9361wSN?5l0AL z@Q$#kN0CvC;v3!uT6#BvQMB+D^Rg_SwsVZUn&SuWT!MR&4NM*7S?`*f^Q3}FwD#wTkknS z2qAaobUmKN|hOLZS8MZX;TA|7hS1Fcmj7p7RYvb02HOAd2R4JAo@uJ^7 z>CJ$|4y}G|VrSSJ?)7`Yqe7KwPO#P0kS>*3pw-o4q0A*3U0a-(Ao-SjigSG6mh@_( v%nU1E)`^|zj&OwoJm5(PA%qY@2%*G({Y^m