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

Adding render tests for image fallback with feature constant expressions and addImage operation #11391

Merged
merged 2 commits into from
Mar 10, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addLayer will trigger tile re-layout. Would it be possible to move layer definition to style definition? List of operations may be:

  1. wait
  2. add image
  3. set feature state

Test will verify that updated set of images is used for property evaluation in the feature-state code path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @alexshalamov!

I tried the test with the layer definition in the style definition as you describe (in place of the current "layers": []. This causes the test to pass in GL Native but fail in GL JS. I think this is from an issue unique to render tests in GL JS.

I see two ways around this:

  • resolve this issue in GL JS to get consistent render test behavior
  • add the test in GL Native only (and perhaps open an issue to address this in GL JS at a later date).

I think the latter in the simplest approach for now, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested out the changes you suggest, and they still don't seem to use the intended updateVertexVectors function in Native.

{
"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.