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

Image expression needs to be fully compatible with styleimagemissing event #8774

Closed
ryanhamley opened this issue Sep 19, 2019 · 0 comments · Fixed by #8775
Closed

Image expression needs to be fully compatible with styleimagemissing event #8774

ryanhamley opened this issue Sep 19, 2019 · 0 comments · Fixed by #8775
Assignees

Comments

@ryanhamley
Copy link
Contributor

ryanhamley commented Sep 19, 2019

Motivation

The image operator introduced in #8684 can sometimes short-circuit the styleimagemissing operator, even if no image is found. This happens because the operator returns null when an image is not found in the style.

Design

We should recognize when an image operator evaluates to null and determine which image was requested, then return that image's name, instead of null. This needs to happen after evaluation so that the image operator works with coalesce statements. In such a statement, there will likely be several images requested. A simple heuristic can be used to determine which image we should fire styleimagemissing for; we should be able to treat an expression with several images in it as analogous to a font-stack in which we assume that the most desired option is the first one listed, so we should determine what the first image requested was and use that to fire styleimagemissing.

Concepts

#8684 #7987 and the coalesce operator are the key concepts

Implementation

I have a pretty good jump on implementation. I think the best place to implement this is within the getValueAndResolveTokens method:

getValueAndResolveTokens(name: *, feature: Feature, availableImages: Array<string>) {
const value = this.layout.get(name).evaluate(feature, {}, availableImages);
const unevaluated = this._unevaluatedLayout._values[name];
if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value)) {
return resolveTokens(feature.properties, value);
}
return value;
}

cc @asheemmamoowala @alexshalamov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant