Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expression and render tests for within expression #9270

Merged
merged 3 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]]]
zmiao marked this conversation as resolved.
Show resolved Hide resolved
}],
"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