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 00000000000..3aaf75a74bf Binary files /dev/null and b/test/integration/render-tests/within/paint-line/expected.png differ 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