Skip to content

Commit

Permalink
Add expression and render tests for within expression (mapbox#9270)
Browse files Browse the repository at this point in the history
* Add expression and render tests for within expression

* Add error case for within expression test. Narrow render tests camera size

* Change polygon fill color
  • Loading branch information
zmiao authored and mike-unearth committed Mar 18, 2020
1 parent 47478e3 commit e2f7293
Show file tree
Hide file tree
Showing 13 changed files with 641 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/ignores.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
56 changes: 56 additions & 0 deletions test/integration/expression-tests/within/basic/test.json
Original file line number Diff line number Diff line change
@@ -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"
}]
}
}
52 changes: 52 additions & 0 deletions test/integration/expression-tests/within/invalid-geojson/test.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
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,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"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 111 additions & 0 deletions test/integration/render-tests/within/layout-text/style.json
Original file line number Diff line number Diff line change
@@ -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"
}

}
]
}

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 e2f7293

Please sign in to comment.