forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add expression and render tests for
within
expression (mapbox#9270)
* 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
1 parent
47478e3
commit e2f7293
Showing
13 changed files
with
641 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
52
test/integration/expression-tests/within/invalid-geojson/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
Binary file added
BIN
+377 Bytes
test/integration/render-tests/within/filter-with-inlined-geojson/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions
100
test/integration/render-tests/within/filter-with-inlined-geojson/style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
111
test/integration/render-tests/within/layout-text/style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.