diff --git a/test/ignores.json b/test/ignores.json index 6358e1aa291..854bb320213 100644 --- a/test/ignores.json +++ b/test/ignores.json @@ -18,5 +18,12 @@ "render-tests/text-variable-anchor/all-anchors-tile-map-mode": "skip - mapbox-gl-js does not need to render tiles", "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/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" } diff --git a/test/integration/expression-tests/within/basic/test.json b/test/integration/expression-tests/within/basic/test.json new file mode 100644 index 00000000000..a710b5c1c32 --- /dev/null +++ b/test/integration/expression-tests/within/basic/test.json @@ -0,0 +1,56 @@ +{ + "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": "Point", + "coordinates": [6, 6] + } + }], [{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "Point", + "coordinates": [2, 2] + } + }], [{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "LineString", + "coordinates": [[3, 3], [4, 1]] + } + }]], + "expected": { + "compiled": { + "type": "boolean", + "isFeatureConstant": false, + "isZoomConstant": true, + "result": "success" + }, + "outputs": [false, 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/invalid-geojson/test.json b/test/integration/expression-tests/within/invalid-geojson/test.json new file mode 100644 index 00000000000..541e8a92e35 --- /dev/null +++ b/test/integration/expression-tests/within/invalid-geojson/test.json @@ -0,0 +1,52 @@ +{ + "expression": ["within", { + "type": "LineString", + "coordinates": [[0, 0], [0, 5], [5, 5], [5, 0]] + }], + "inputs": [[{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "Point", + "coordinates": [6, 6] + } + }], [{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "Point", + "coordinates": [2, 2] + } + }], [{ + "zoom": 3, + "canonicalID": { + "z": 3, + "x": 3, + "y": 3 + } + }, { + "geometry": { + "type": "LineString", + "coordinates": [[3, 3], [4, 1]] + } + }]], + "expected": { + "compiled": { + "errors": [{ + "key": "", + "error": "'Within' expression requires valid geojson source that contains polygon geometry type." + }], + "result": "error" + } + } +} diff --git a/test/integration/render-tests/within/filter-with-inlined-geojson/expected.png b/test/integration/render-tests/within/filter-with-inlined-geojson/expected.png new file mode 100644 index 00000000000..61b6f1796b7 Binary files /dev/null and b/test/integration/render-tests/within/filter-with-inlined-geojson/expected.png differ diff --git a/test/integration/render-tests/within/filter-with-inlined-geojson/style.json b/test/integration/render-tests/within/filter-with-inlined-geojson/style.json new file mode 100644 index 00000000000..19b184eec78 --- /dev/null +++ b/test/integration/render-tests/within/filter-with-inlined-geojson/style.json @@ -0,0 +1,100 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64 + } + }, + "zoom": 3, + "center": [3, 3], + "sources": { + "points": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 1.9775390625, + 2.3284603685731593 + ] + } + }, + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 1.7138671875, + -1.7136116598836224 + ] + } + } + ] + } + }, + "polygon": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [[0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0]] + ] + } + } + ] + } + } + }, + "layers": [ + { + "id": "border", + "type": "fill", + "source": "polygon", + "paint": { + "fill-color": "black", + "fill-opacity": 0.5 + } + }, + { + "id": "circle", + "type": "circle", + "source": "points", + "filter": ["within", { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + ], + "paint": { + "circle-radius": 5, + "circle-color": "red" + } + } + ] +} diff --git a/test/integration/render-tests/within/layout-text/expected.png b/test/integration/render-tests/within/layout-text/expected.png new file mode 100644 index 00000000000..1fdeb343485 Binary files /dev/null and b/test/integration/render-tests/within/layout-text/expected.png differ diff --git a/test/integration/render-tests/within/layout-text/style.json b/test/integration/render-tests/within/layout-text/style.json new file mode 100644 index 00000000000..f12044e5fdc --- /dev/null +++ b/test/integration/render-tests/within/layout-text/style.json @@ -0,0 +1,111 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64 + } + }, + "zoom": 2, + "center": [3.5, 3.5], + "sources": { + "points": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 1.9775390625, + 2.3284603685731593 + ] + } + }, + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 2.021484375, + 7.798078531355303 + ] + } + } + ] + } + }, + "polygon": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + } + ] + } + } + }, + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "border", + "type": "fill", + "source": "polygon", + "paint": { + "fill-color": "black", + "fill-opacity": 0.5 + } + }, + { + "id": "symbol", + "type": "symbol", + "source": "points", + "layout": { + "icon-image": "", + "text-field": ["case", ["within", { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + }], "In", "Out"], + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ], + "text-size": 10 + }, + "paint" : { + "text-color": "red" + } + + } + ] + } + \ No newline at end of file diff --git a/test/integration/render-tests/within/paint-circle/expected.png b/test/integration/render-tests/within/paint-circle/expected.png new file mode 100644 index 00000000000..2be9f737ca4 Binary files /dev/null and b/test/integration/render-tests/within/paint-circle/expected.png differ diff --git a/test/integration/render-tests/within/paint-circle/style.json b/test/integration/render-tests/within/paint-circle/style.json new file mode 100644 index 00000000000..e393ce0032f --- /dev/null +++ b/test/integration/render-tests/within/paint-circle/style.json @@ -0,0 +1,101 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64 + } + }, + "zoom": 2, + "center": [3.5, 3.5], + "sources": { + "points": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 1.9775390625, + 2.3284603685731593 + ] + } + }, + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 2.021484375, + 7.798078531355303 + ] + } + } + ] + } + }, + "polygon": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + } + ] + } + } + }, + "layers": [ + { + "id": "boarder", + "type": "fill", + "source": "polygon", + "paint": { + "fill-color": "black", + "fill-opacity": 0.5 + } + }, + { + "id": "circle", + "type": "circle", + "source": "points", + "paint": { + "circle-radius": 5, + "circle-color": ["case", ["within", { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + ], "red", "blue"] + } + } + ] +} diff --git a/test/integration/render-tests/within/paint-icon/expected.png b/test/integration/render-tests/within/paint-icon/expected.png new file mode 100644 index 00000000000..f24c546a9a8 Binary files /dev/null and b/test/integration/render-tests/within/paint-icon/expected.png differ diff --git a/test/integration/render-tests/within/paint-icon/style.json b/test/integration/render-tests/within/paint-icon/style.json new file mode 100644 index 00000000000..ca58a1f59cf --- /dev/null +++ b/test/integration/render-tests/within/paint-icon/style.json @@ -0,0 +1,104 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64 + } + }, + "zoom": 2, + "center": [3.5, 3.5], + "sources": { + "points": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 1.9775390625, + 2.3284603685731593 + ] + } + }, + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 2.021484375, + 7.798078531355303 + ] + } + } + ] + } + }, + "polygon": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + } + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "boarder", + "type": "fill", + "source": "polygon", + "paint": { + "fill-color": "black", + "fill-opacity": 0.5 + } + }, + { + "id": "symbol", + "type": "symbol", + "source": "points", + "layout": { + "icon-image": "dot.sdf" + }, + "paint" : { + "icon-color": ["case", ["within", { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + ], "red", "blue"] + } + } + ] +} diff --git a/test/integration/render-tests/within/paint-text/expected.png b/test/integration/render-tests/within/paint-text/expected.png new file mode 100644 index 00000000000..c44aed8ae61 Binary files /dev/null and b/test/integration/render-tests/within/paint-text/expected.png differ diff --git a/test/integration/render-tests/within/paint-text/style.json b/test/integration/render-tests/within/paint-text/style.json new file mode 100644 index 00000000000..8749edb1721 --- /dev/null +++ b/test/integration/render-tests/within/paint-text/style.json @@ -0,0 +1,109 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64 + } + }, + "zoom": 2, + "center": [3.5, 3.5], + "sources": { + "points": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 1.9775390625, + 2.3284603685731593 + ] + } + }, + { + "type": "Feature", + "properties": { + }, + "geometry": { + "type": "Point", + "coordinates": [ + 2.021484375, + 7.798078531355303 + ] + } + } + ] + } + }, + "border": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + } + ] + } + } + }, + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "border", + "type": "fill", + "source": "border", + "paint": { + "fill-color": "black", + "fill-opacity": 0.5 + } + }, + { + "id": "symbol", + "type": "symbol", + "source": "points", + "layout": { + "text-field": "Text", + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ], + "text-size": 10 + }, + "paint": { + "text-color": ["case", ["within", { + "type": "Polygon", + "coordinates": [ + [ + [0, 0], + [0, 5], + [5, 5], + [5, 0], + [0, 0] + ] + ] + } + ], "red", "blue"] + } + } + ] +}