Skip to content

Commit

Permalink
Adding render tests for image fallback with feature constant expressi…
Browse files Browse the repository at this point in the history
…ons and `addImage` operation (#11391)

* Added tests for image fallback with constant expressions

* Adding tests for 'addImage' operation and rearranging feature-state tests
  • Loading branch information
SnailBones committed Mar 10, 2022
1 parent 5650f9b commit daf0967
Show file tree
Hide file tree
Showing 12 changed files with 369 additions and 0 deletions.
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,76 @@
{
"version": 8,
"metadata": {
"test": {
"height": 64,
"width": 128,
"operations": [
["addImage", "rocket", "./image/rocket.png"],
["wait"],
[
"addLayer",
{
"id": "text",
"type": "symbol",
"source": "geojson",
"layout": {
"text-allow-overlap": true,
"icon-allow-overlap": true,
"icon-image": [
"coalesce",
["image", "rocket"],
["image", "fav-bicycle-18"]
],
"text-field": [
"case",
["to-boolean", ["coalesce", ["image", "rocket"], ""]],
"beta sprite",
"fallback sprite"
],
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top"
},
"paint": {
"text-color": [
"case",
["to-boolean", ["coalesce", ["image", "rocket"], ""]],
"blue",
"red"
],
"text-opacity": [
"case",
["to-boolean", ["coalesce", ["image", "rocket"], ""]],
0.2,
1
]
}
}
],
["wait"]
]
}
},
"center": [0, 0],
"zoom": 0,
"sprite": "local://sprites/sprite",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
}
}
]
}
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": []
}
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,78 @@
{
"version": 8,
"metadata": {
"test": {
"height": 64,
"width": 128
}
},
"center": [ 0, 0 ],
"zoom": 0,
"sprite": "local://sprites/sprite",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
}
}
]
}
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "text",
"type": "symbol",
"source": "geojson",
"layout": {
"text-allow-overlap": true,
"icon-allow-overlap": true,
"icon-image": [
"coalesce",
["image", "fav-bicycle-18"],
["image", "generic_metro"]
],
"text-field": [ "case",
["to-boolean", ["coalesce",
["image", "fav-bicycle-18"],
""
]],
"beta sprite",
"fallback sprite"
],
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-offset": [0, 0.6],
"text-anchor": "top"
},
"paint": {
"text-color": [ "case",
["to-boolean", ["coalesce",
["image", "fav-bicycle-18"],
""
]],
"blue",
"red"
],
"text-opacity": [ "case",
["to-boolean", ["coalesce",
["image", "fav-bicycle-18"],
""
]],
0.2,
1
]
}
}
]
}
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,78 @@
{
"version": 8,
"metadata": {
"test": {
"height": 64,
"width": 128
}
},
"center": [ 0, 0 ],
"zoom": 0,
"sprite": "local://sprites/emerald",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
}
}
]
}
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "text",
"type": "symbol",
"source": "geojson",
"layout": {
"text-allow-overlap": true,
"icon-allow-overlap": true,
"icon-image": [
"coalesce",
["image", "fav-bicycle-18"],
["image", "generic_metro"]
],
"text-field": [ "case",
["to-boolean", ["coalesce",
["image", "fav-bicycle-18"],
""
]],
"beta sprite",
"fallback sprite"
],
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-offset": [0, 0.6],
"text-anchor": "top"
},
"paint": {
"text-color": [ "case",
["to-boolean", ["coalesce",
["image", "fav-bicycle-18"],
""
]],
"blue",
"red"
],
"text-opacity": [ "case",
["to-boolean", ["coalesce",
["image", "fav-bicycle-18"],
""
]],
0.2,
1
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64,
"allowed": 0.0015,
"operations": [
[
"addImage",
"rocket",
"./image/rocket.png"
],
[
"wait"
],
[
"addLayer",
{
"id": "circle",
"type": "circle",
"source": "geojson",
"paint": {
"circle-radius": 5,
"circle-color": [ "case",
["to-boolean", ["coalesce",
["image", ["get", "icon"]],
""
]
],
[ "case",
["boolean", [ "feature-state", "hover"], false ],
"green",
"blue"
],
[ "case",
["boolean", [ "feature-state", "hover"], false ],
"yellow",
"red"
]
]
}
}
],
[
"setFeatureState",
{
"source": "geojson",
"id": "0"
},
{
"hover": true
}
],
[
"wait"
],
[
"setFeatureState",
{
"source": "geojson",
"id": "2"
},
{
"hover": true
}
],
[
"wait"
]
]
}
},
"zoom": 2,
"sprite": "local://sprites/sprite",
"sources": {
"geojson": {
"type": "geojson",
"data":
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 0,
"properties": { "icon": "rocket"},
"geometry": {
"type": "Point",
"coordinates": [
-2,
2
]
}
},
{
"type": "Feature",
"id": 1,
"properties": { "icon": "rocket"},
"geometry": {
"type": "Point",
"coordinates": [
2,
2
]
}
},
{
"type": "Feature",
"id": 2,
"properties": { "icon": "missing-icon"},
"geometry": {
"type": "Point",
"coordinates": [
2,
-2
]
}
},
{
"type": "Feature",
"id": 3,
"properties": { "icon": "missing-icon"},
"geometry": {
"type": "Point",
"coordinates": [
-2,
-2
]
}
}
]
}
}
},
"layers": [
]
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit daf0967

Please sign in to comment.