[core] map image type to string until we have a dedicated implementation

This commit is contained in:
Konstantin Käfer
2019-10-14 15:15:54 +02:00
parent 8206ce0e02
commit 9cac122c5c
5 changed files with 44 additions and 37 deletions

View File

@@ -104,7 +104,8 @@ optional<Value> toValue(const JSValue& jsvalue) {
style::expression::type::Type stringToType(const std::string& type) {
using namespace style::expression;
if (type == "string"s || type == "number-format"s) {
if (type == "string"s || type == "number-format"s ||
type == "image"s) { // TODO: replace once we implement image expressions
return type::String;
} else if (type == "number"s) {
return type::Number;

View File

@@ -16,6 +16,10 @@
"expression-tests/legacy/interval/composite": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
"expression-tests/legacy/interval/composite-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
"expression-tests/legacy/interval/tokens-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
"expression-tests/image/basic": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"expression-tests/image/compound": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"expression-tests/image/coalesce": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"expression-tests/image/implicit-assert": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"query-tests/geometry/multilinestring": "needs investigation",
"query-tests/geometry/multipolygon": "needs investigation",
"query-tests/geometry/polygon": "needs investigation",

View File

@@ -16,12 +16,12 @@ Assertion::Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>>
}
ParseResult Assertion::parse(const Convertible& value, ParsingContext& ctx) {
static std::unordered_map<std::string, type::Type> types {
static std::unordered_map<std::string, type::Type> types{
{"string", type::String},
{"image", type::String}, // TODO: replace once we implement image expressions
{"number", type::Number},
{"boolean", type::Boolean},
{"object", type::Object}
};
{"object", type::Object}};
std::size_t length = arrayLength(value);

View File

@@ -100,38 +100,40 @@ ParseResult ParsingContext::parse(const Convertible& value, std::size_t index_,
}
using ParseFunction = ParseResult (*)(const conversion::Convertible&, ParsingContext&);
MAPBOX_ETERNAL_CONSTEXPR const auto expressionRegistry = mapbox::eternal::hash_map<mapbox::eternal::string, ParseFunction>({
{"==", parseComparison},
{"!=", parseComparison},
{">", parseComparison},
{"<", parseComparison},
{">=", parseComparison},
{"<=", parseComparison},
{"all", All::parse},
{"any", Any::parse},
{"array", Assertion::parse},
{"at", At::parse},
{"boolean", Assertion::parse},
{"case", Case::parse},
{"coalesce", Coalesce::parse},
{"collator", CollatorExpression::parse},
{"format", FormatExpression::parse},
{"interpolate", parseInterpolate},
{"length", Length::parse},
{"let", Let::parse},
{"literal", Literal::parse},
{"match", parseMatch},
{"number", Assertion::parse},
{"number-format", NumberFormat::parse},
{"object", Assertion::parse},
{"step", Step::parse},
{"string", Assertion::parse},
{"to-boolean", Coercion::parse},
{"to-color", Coercion::parse},
{"to-number", Coercion::parse},
{"to-string", Coercion::parse},
{"var", Var::parse},
});
MAPBOX_ETERNAL_CONSTEXPR const auto expressionRegistry =
mapbox::eternal::hash_map<mapbox::eternal::string, ParseFunction>({
{"==", parseComparison},
{"!=", parseComparison},
{">", parseComparison},
{"<", parseComparison},
{">=", parseComparison},
{"<=", parseComparison},
{"all", All::parse},
{"any", Any::parse},
{"array", Assertion::parse},
{"at", At::parse},
{"boolean", Assertion::parse},
{"case", Case::parse},
{"coalesce", Coalesce::parse},
{"collator", CollatorExpression::parse},
{"format", FormatExpression::parse},
{"image", Assertion::parse}, // TODO: replace once we implement image expressions
{"interpolate", parseInterpolate},
{"length", Length::parse},
{"let", Let::parse},
{"literal", Literal::parse},
{"match", parseMatch},
{"number", Assertion::parse},
{"number-format", NumberFormat::parse},
{"object", Assertion::parse},
{"step", Step::parse},
{"string", Assertion::parse},
{"to-boolean", Coercion::parse},
{"to-color", Coercion::parse},
{"to-number", Coercion::parse},
{"to-string", Coercion::parse},
{"var", Var::parse},
});
bool isExpression(const std::string& name) {
return expressionRegistry.contains(name.c_str());

View File

@@ -32,7 +32,7 @@ AnchorAlignment AnchorAlignment::getAnchorAlignment(style::SymbolAnchorType anch
result.horizontalAlign = 0.0f;
break;
default:
break;
break;
}
switch (anchor) {