From fdc4d894278e187f08a93a8a163cf8f0ca58f899 Mon Sep 17 00:00:00 2001 From: zmiao Date: Wed, 19 Feb 2020 10:52:54 +0200 Subject: [PATCH] Add render tests for line within polygon. Update expression tests for within expression --- test/ignores.json | 19 +- .../within/invalid-geojson/test.json | 2 +- .../within/line-within-polygon/test.json | 44 ++++ .../within/non-supported/test.json | 32 +++ .../{basic => point-within-polygon}/test.json | 14 +- .../within/paint-line/expected.png | Bin 0 -> 3821 bytes .../render-tests/within/paint-line/style.json | 199 ++++++++++++++++++ 7 files changed, 288 insertions(+), 22 deletions(-) create mode 100644 test/integration/expression-tests/within/line-within-polygon/test.json create mode 100644 test/integration/expression-tests/within/non-supported/test.json rename test/integration/expression-tests/within/{basic => point-within-polygon}/test.json (76%) create mode 100644 test/integration/render-tests/within/paint-line/expected.png create mode 100644 test/integration/render-tests/within/paint-line/style.json diff --git a/test/ignores.json b/test/ignores.json index 854bb320213..f2cb9fe813e 100644 --- a/test/ignores.json +++ b/test/ignores.json @@ -19,11 +19,14 @@ "render-tests/fill-pattern/update-feature-state": "https://github.com/mapbox/mapbox-gl-js/issues/7207", "render-tests/text-size/zero": "https://github.com/mapbox/mapbox-gl-js/issues/9161", "render-tests/text-variable-anchor/left-top-right-buttom-offset-tile-map-mode": "skip - mapbox-gl-js does not need to render tiles", - "render-tests/within/filter-with-inlined-geojson" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js", - "render-tests/within/layout-text" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js", - "render-tests/within/paint-circle" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js", - "render-tests/within/paint-icon" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js", - "render-tests/within/paint-text" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js", - "expression-tests/within/basic" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js", - "expression-tests/within/invalid-geojson" : "skip - TODO: Within Expression needs to be implemented in mapbox-gl-js" -} + "render-tests/within/filter-with-inlined-geojson": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "render-tests/within/paint-circle": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "render-tests/within/paint-icon": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "render-tests/within/paint-text": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "render-tests/within/layout-text": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16194", + "render-tests/within/paint-line": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16220", + "expression-tests/within/point-within-polygon": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "expression-tests/within/invalid-geojson": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "expression-tests/within/non-supported": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16157", + "expression-tests/within/line-within-polygon": "skip - port https://github.com/mapbox/mapbox-gl-native/pull/16220" +} \ No newline at end of file diff --git a/test/integration/expression-tests/within/invalid-geojson/test.json b/test/integration/expression-tests/within/invalid-geojson/test.json index 541e8a92e35..5a6ccfa38fb 100644 --- a/test/integration/expression-tests/within/invalid-geojson/test.json +++ b/test/integration/expression-tests/within/invalid-geojson/test.json @@ -44,7 +44,7 @@ "compiled": { "errors": [{ "key": "", - "error": "'Within' expression requires valid geojson source that contains polygon geometry type." + "error": "'within' expression requires valid geojson source that contains polygon geometry type." }], "result": "error" } diff --git a/test/integration/expression-tests/within/line-within-polygon/test.json b/test/integration/expression-tests/within/line-within-polygon/test.json new file mode 100644 index 00000000000..b42c19c999b --- /dev/null +++ b/test/integration/expression-tests/within/line-within-polygon/test.json @@ -0,0 +1,44 @@ +{ + "expression": ["within", { + "type": "Polygon", + "coordinates": [[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]] + }], + "inputs": [[{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "LineString", + "coordinates": [[3, 3], [4, 1]] + } + }], [{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "LineString", + "coordinates": [[3, 3], [6, 6]] + } + }]], + "expected": { + "compiled": { + "type": "boolean", + "isFeatureConstant": false, + "isZoomConstant": true, + "result": "success" + }, + "outputs": [true, false], + "serialized": ["within", { + "coordinates": [[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]], + "type": "Polygon" + }] + } +} diff --git a/test/integration/expression-tests/within/non-supported/test.json b/test/integration/expression-tests/within/non-supported/test.json new file mode 100644 index 00000000000..16659a5fc16 --- /dev/null +++ b/test/integration/expression-tests/within/non-supported/test.json @@ -0,0 +1,32 @@ +{ + "expression": ["within", { + "type": "Polygon", + "coordinates": [[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]] + }], + "inputs": [[{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "Polygon", + "coordinates": [[[3, 3], [6, 6], [3, 3]]] + } + }]], + "expected": { + "compiled": { + "type": "boolean", + "isFeatureConstant": false, + "isZoomConstant": true, + "result": "success" + }, + "outputs": [false], + "serialized": ["within", { + "coordinates": [[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]], + "type": "Polygon" + }] + } +} diff --git a/test/integration/expression-tests/within/basic/test.json b/test/integration/expression-tests/within/point-within-polygon/test.json similarity index 76% rename from test/integration/expression-tests/within/basic/test.json rename to test/integration/expression-tests/within/point-within-polygon/test.json index 804d6c73cbf..8da9fbdceec 100644 --- a/test/integration/expression-tests/within/basic/test.json +++ b/test/integration/expression-tests/within/point-within-polygon/test.json @@ -27,18 +27,6 @@ "type": "Point", "coordinates": [2, 2] } - }], [{ - "zoom": 3, - "canonicalID": { - "z": 3, - "x": 3, - "y": 3 - } - }, { - "geometry": { - "type": "LineString", - "coordinates": [[3, 3], [4, 1]] - } }]], "expected": { "compiled": { @@ -47,7 +35,7 @@ "isZoomConstant": true, "result": "success" }, - "outputs": [false, true, false], + "outputs": [false, true], "serialized": ["within", { "coordinates": [[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]], "type": "Polygon" diff --git a/test/integration/render-tests/within/paint-line/expected.png b/test/integration/render-tests/within/paint-line/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..3aaf75a74bfde3409e3c2016efbc182935238b42 GIT binary patch literal 3821 zcma)9_d6S08>U8yqG}aYyMhpu7WoaedD^(4cf+VlWU02vt>y{^t9V^WO#yJ)CMdq%W} z5E&T*PWO?zX$Wc$O@}ns;uyI44#Bc<=D9+!tk2zIT%QzBpSUcV9OmVVvmAQaiOL)$ zjX*+TWhIkag_0~-SeS$)lO&RF^NMCxzey?Q-)-HA>5RI(QjTbpIFCeqL-jC>oWCeu zGRfGF7%vF@gbIGX7)*V?K>uF$kfZef8>X!09jLgnZV`$Dc#AS65o0>S2Xb%aw)ESz z+BJg&+cNhZ84sA>Dr{-}7QT+?8APn!_In^AB%Hm3kQtm?JzkATEs-%<<7(tqSxVx< ztbrHU#JGNiJ315S8<>s-Rb$cy4O90teqhT=_DJyhIEmi+BuvPimWY;PiE@}m5wn}-) z0^joSW47w>ofi$xET+-d?g<@5AZX75wwXC|WQD)5h`2!$88(k+pCM;EUaa8Ub6~A@7aA4U8IJT!*n9ld#!zd0c<_l;AkJl(u zP=N3vOQId`?;Zvph*4IW49dBbb?4?H&#s_9Vuq#E)?_+Y*`xET$Yq?#y~n8*LwQb0 zIjik%Oi5nn%)3_dh5S7aInNlyVmJlzT=eIeUT57Wa+7{?$<%B2d?XH6>t(S!DYpso zve@4{O?<8_7lGf_y}8lg1`RkQKYsX1d(3^FMAW5xFcxLz0B~h)xN_eC9avW_a2u^4-n`&11Y+VXbh9ZNxonkIY%d+Kg*k-t6&!cUNCvR z6O#U3W~ed49|e;kYEU&-jZeJt4HlRF-c%m$1NZ;T=IJ#Mag=U6BqSBvTY`M-uM)%v7Nyhim&a+OQ0g{s02t8hYxO_pe0I^1OSbVKbi_PjT z;}=l*LH6U4P+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Wl(_aKXMuyQH$#2(>1}80=e|#Sne#G`;tl850{o;OFPY0U+Z?>^!&E@F!wLIYK z2C#uGx5}LFz^-xnHE=;)8TT8c&US$K3>d7As}8t5pNTVdN86!36Iz%@K#@mrIaE0* z@|qxF!zL$<6ajs$dFj>B>c*8r>&AJ9&rs_qWpgp(`FJjdX5I3!EP&!`b1ooANn!T*Udndrxok?$3`SI+?co%!~A zs;#qL$$iHpkr*8N(qQJv#eCi#eY07ufM$+X-H&2Iajq0bLDRYpG-%IGF6L{huY)`ndi>>GfGEPp(l$Bw2$USybN@2b89ywbXgjz^>v$NR&^>p?)vE zAmy0C`uPkWqaHw$ZT=bO+`(w`;3ESafddbcF_fa5U$J{5DO2o_kJSI32?5{|a_hSZ<|3T>N2D>9Ojir~s6oRa=06^_OW6Pb literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/within/paint-line/style.json b/test/integration/render-tests/within/paint-line/style.json new file mode 100644 index 00000000000..405b892218c --- /dev/null +++ b/test/integration/render-tests/within/paint-line/style.json @@ -0,0 +1,199 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 125, + "height": 125 + } + }, + "zoom": 2, + "center": [ + -24, + -32 + ], + "sources": { + "line": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -30.805664062500004, + -31.84023266790935 + ], + [ + -20.56640625, + -32.026706293336126 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -30.629882812499996, + -28.420391085674304 + ], + [ + -18.544921875, + -28.92163128242129 + ], + [ + -18.369140624999996, + -36.49197347059368 + ], + [ + -27.24609375, + -36.77409249464194 + ] + ] + } + } + ] + } + }, + "polygon": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -31.9921875, + -27.137368359795584 + ], + [ + -32.255859375, + -35.49645605658415 + ], + [ + -22.9833984375, + -35.7465122599185 + ], + [ + -22.5, + -30.67571540416773 + ], + [ + -29.003906249999996, + -30.29701788337204 + ], + [ + -28.9599609375, + -37.64903402157864 + ], + [ + -16.1279296875, + -37.89219554724435 + ], + [ + -16.5673828125, + -26.82407078047018 + ], + [ + -31.9921875, + -27.137368359795584 + ] + ] + ] + } + } + ] + } + } + }, + "layers": [ + { + "id": "border", + "type": "fill", + "source": "polygon", + "paint": { + "fill-color": "black", + "fill-opacity": 0.5 + } + }, + { + "id": "draw", + "type": "line", + "source": "line", + "paint": { + "line-color": [ + "case", + [ + "within", + { + "type": "Polygon", + "coordinates": [ + [ + [ + -31.9921875, + -27.137368359795584 + ], + [ + -32.255859375, + -35.49645605658415 + ], + [ + -22.9833984375, + -35.7465122599185 + ], + [ + -22.5, + -30.67571540416773 + ], + [ + -29.003906249999996, + -30.29701788337204 + ], + [ + -28.9599609375, + -37.64903402157864 + ], + [ + -16.1279296875, + -37.89219554724435 + ], + [ + -16.5673828125, + -26.82407078047018 + ], + [ + -31.9921875, + -27.137368359795584 + ] + ] + ] + } + ], + "red", + "blue" + ] + } + }, + { + "id": "circle", + "type": "circle", + "source": "line", + "paint": { + "circle-color": "yellow", + "circle-radius": 2 + } + } + ] +} \ No newline at end of file