diff options
143 files changed, 2535 insertions, 1930 deletions
diff --git a/.tx/config b/.tx/config index 1de8f78303..272fe45b16 100644 --- a/.tx/config +++ b/.tx/config @@ -46,6 +46,7 @@ type = STRINGS [mapbox-gl-native.stringsxml-android] file_filter = platform/android/MapboxGLAndroidSDK/src/main/res/values-<lang>/strings.xml +lang_map = pt_PT: pt-rPT source_file = platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml source_lang = en type = ANDROID diff --git a/benchmark/parse/filter.benchmark.cpp b/benchmark/parse/filter.benchmark.cpp index e4cf635256..4e39237138 100644 --- a/benchmark/parse/filter.benchmark.cpp +++ b/benchmark/parse/filter.benchmark.cpp @@ -1,7 +1,6 @@ #include <benchmark/benchmark.h> #include <mbgl/style/filter.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/filter.hpp> diff --git a/circle.yml b/circle.yml index d2232e9106..ca9ceb6636 100644 --- a/circle.yml +++ b/circle.yml @@ -358,7 +358,7 @@ jobs: gcloud firebase test android run --type instrumentation \ --app platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/debug/MapboxGLAndroidSDKTestApp-debug.apk \ --test platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/androidTest/debug/MapboxGLAndroidSDKTestApp-debug-androidTest.apk \ - --device-ids sailfish --os-version-ids 26 --locales en --orientations portrait --timeout 20m + --device-ids sailfish --os-version-ids 26 --locales en --orientations portrait --timeout 20m - store_artifacts: path: platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/debug destination: . diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 0474de4680..7e48b336b4 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -360,7 +360,6 @@ set(MBGL_CORE_FILES include/mbgl/style/conversion.hpp include/mbgl/style/data_driven_property_value.hpp include/mbgl/style/filter.hpp - include/mbgl/style/filter_evaluator.hpp include/mbgl/style/heatmap_color_property_value.hpp include/mbgl/style/image.hpp include/mbgl/style/layer.hpp @@ -377,7 +376,6 @@ set(MBGL_CORE_FILES src/mbgl/style/custom_tile_loader.cpp src/mbgl/style/custom_tile_loader.hpp src/mbgl/style/filter.cpp - src/mbgl/style/filter_evaluator.cpp src/mbgl/style/image.cpp src/mbgl/style/image_impl.cpp src/mbgl/style/image_impl.hpp diff --git a/include/mbgl/style/expression/compound_expression.hpp b/include/mbgl/style/expression/compound_expression.hpp index 6baaae862f..431afb4d13 100644 --- a/include/mbgl/style/expression/compound_expression.hpp +++ b/include/mbgl/style/expression/compound_expression.hpp @@ -36,7 +36,7 @@ template <typename T> struct Varargs : std::vector<T> { using std::vector<T>::vector; }; namespace detail { -// Base class for the Signature<Fn> structs that are used to determine the +// Base class for the Signature<Fn> structs that are used to determine // each CompoundExpression definition's type::Type data from the type of its // "evaluate" function. struct SignatureBase { @@ -137,10 +137,21 @@ ParseResult parseCompoundExpression(const std::string name, const mbgl::style::c ParseResult createCompoundExpression(const CompoundExpressionRegistry::Definition& definition, std::vector<std::unique_ptr<Expression>> args, ParsingContext& ctx); - + ParseResult createCompoundExpression(const std::string& name, std::vector<std::unique_ptr<Expression>> args, ParsingContext& ctx); +// Convenience method for use expressions that have 0, 1, or 2 args. +ParseResult createCompoundExpression(const std::string& name, ParsingContext& ctx); + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + ParsingContext& ctx); + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + std::unique_ptr<Expression> arg2, + ParsingContext& ctx); } // namespace expression } // namespace style diff --git a/include/mbgl/style/expression/literal.hpp b/include/mbgl/style/expression/literal.hpp index a00c468efc..d3b3a20cce 100644 --- a/include/mbgl/style/expression/literal.hpp +++ b/include/mbgl/style/expression/literal.hpp @@ -51,6 +51,9 @@ private: Value value; }; +std::unique_ptr<Literal> createLiteral(const char* value); +std::unique_ptr<Literal> createLiteral(Value value); + } // namespace expression } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp index ccf8dce188..ce4015bb69 100644 --- a/include/mbgl/style/filter.hpp +++ b/include/mbgl/style/filter.hpp @@ -11,271 +11,31 @@ namespace mbgl { namespace style { - -class Filter; - -class NullFilter { -public: - friend bool operator==(const NullFilter&, const NullFilter&) { - return true; - } -}; - -class EqualsFilter { -public: - std::string key; - Value value; - - friend bool operator==(const EqualsFilter& lhs, const EqualsFilter& rhs) { - return std::tie(lhs.key, lhs.value) == std::tie(rhs.key, rhs.value); - } -}; - -class NotEqualsFilter { -public: - std::string key; - Value value; - - friend bool operator==(const NotEqualsFilter& lhs, const NotEqualsFilter& rhs) { - return std::tie(lhs.key, lhs.value) == std::tie(rhs.key, rhs.value); - } -}; - -class LessThanFilter { -public: - std::string key; - Value value; - - friend bool operator==(const LessThanFilter& lhs, const LessThanFilter& rhs) { - return std::tie(lhs.key, lhs.value) == std::tie(rhs.key, rhs.value); - } -}; - -class LessThanEqualsFilter { -public: - std::string key; - Value value; - - friend bool operator==(const LessThanEqualsFilter& lhs, const LessThanEqualsFilter& rhs) { - return std::tie(lhs.key, lhs.value) == std::tie(rhs.key, rhs.value); - } -}; - -class GreaterThanFilter { -public: - std::string key; - Value value; - - friend bool operator==(const GreaterThanFilter& lhs, const GreaterThanFilter& rhs) { - return std::tie(lhs.key, lhs.value) == std::tie(rhs.key, rhs.value); - } -}; - -class GreaterThanEqualsFilter { -public: - std::string key; - Value value; - - friend bool operator==(const GreaterThanEqualsFilter& lhs, const GreaterThanEqualsFilter& rhs) { - return std::tie(lhs.key, lhs.value) == std::tie(rhs.key, rhs.value); - } -}; - -class InFilter { -public: - std::string key; - std::vector<Value> values; - - friend bool operator==(const InFilter& lhs, const InFilter& rhs) { - return std::tie(lhs.key, lhs.values) == std::tie(rhs.key, rhs.values); - } -}; - -class NotInFilter { -public: - std::string key; - std::vector<Value> values; - - friend bool operator==(const NotInFilter& lhs, const NotInFilter& rhs) { - return std::tie(lhs.key, lhs.values) == std::tie(rhs.key, rhs.values); - } -}; - -class AnyFilter { -public: - std::vector<Filter> filters; - - friend bool operator==(const AnyFilter& lhs, const AnyFilter& rhs) { - return lhs.filters == rhs.filters; - } -}; - -class AllFilter { -public: - std::vector<Filter> filters; - - friend bool operator==(const AllFilter& lhs, const AllFilter& rhs) { - return lhs.filters == rhs.filters; - } -}; - -class NoneFilter { -public: - std::vector<Filter> filters; - - friend bool operator==(const NoneFilter& lhs, const NoneFilter& rhs) { - return lhs.filters == rhs.filters; - } -}; - -class HasFilter { -public: - std::string key; - - friend bool operator==(const HasFilter& lhs, const HasFilter& rhs) { - return lhs.key == rhs.key; - } -}; - -class NotHasFilter { -public: - std::string key; - - friend bool operator==(const NotHasFilter& lhs, const NotHasFilter& rhs) { - return lhs.key == rhs.key; - } -}; - - -class TypeEqualsFilter { -public: - FeatureType value; - - friend bool operator==(const TypeEqualsFilter& lhs, const TypeEqualsFilter& rhs) { - return lhs.value == rhs.value; - } -}; - -class TypeNotEqualsFilter { -public: - FeatureType value; - - friend bool operator==(const TypeNotEqualsFilter& lhs, const TypeNotEqualsFilter& rhs) { - return lhs.value == rhs.value; - } -}; - -class TypeInFilter { -public: - std::vector<FeatureType> values; - - friend bool operator==(const TypeInFilter& lhs, const TypeInFilter& rhs) { - return lhs.values == rhs.values; - } -}; - -class TypeNotInFilter { -public: - std::vector<FeatureType> values; - - friend bool operator==(const TypeNotInFilter& lhs, const TypeNotInFilter& rhs) { - return lhs.values == rhs.values; - } -}; - - -class IdentifierEqualsFilter { -public: - FeatureIdentifier value; - - friend bool operator==(const IdentifierEqualsFilter& lhs, const IdentifierEqualsFilter& rhs) { - return lhs.value == rhs.value; - } -}; - -class IdentifierNotEqualsFilter { -public: - FeatureIdentifier value; - - friend bool operator==(const IdentifierNotEqualsFilter& lhs, const IdentifierNotEqualsFilter& rhs) { - return lhs.value == rhs.value; - } -}; - -class IdentifierInFilter { -public: - std::vector<FeatureIdentifier> values; - - friend bool operator==(const IdentifierInFilter& lhs, const IdentifierInFilter& rhs) { - return lhs.values == rhs.values; - } -}; - -class IdentifierNotInFilter { -public: - std::vector<FeatureIdentifier> values; - - friend bool operator==(const IdentifierNotInFilter& lhs, const IdentifierNotInFilter& rhs) { - return lhs.values == rhs.values; - } -}; - -class HasIdentifierFilter { + +class Filter { public: - friend bool operator==(const HasIdentifierFilter&, const HasIdentifierFilter&) { - return true; + optional<std::shared_ptr<const expression::Expression>> expression; + + Filter() : expression() {} + + Filter(expression::ParseResult _expression) : expression(std::move(*_expression)) { + assert(!expression || *expression != nullptr); } -}; + + bool operator()(const expression::EvaluationContext& context) const; -class NotHasIdentifierFilter { -public: - friend bool operator==(const NotHasIdentifierFilter&, const NotHasIdentifierFilter&) { - return true; + friend bool operator==(const Filter& lhs, const Filter& rhs) { + if (!lhs.expression || !rhs.expression) { + return lhs.expression == rhs.expression; + } else { + return *(lhs.expression) == *(rhs.expression); + } } -}; -class ExpressionFilter { -public: - std::shared_ptr<const expression::Expression> expression; - - friend bool operator==(const ExpressionFilter& lhs, const ExpressionFilter& rhs) { - return *(lhs.expression) == *(rhs.expression); + friend bool operator!=(const Filter& lhs, const Filter& rhs) { + return !(lhs == rhs); } }; - -using FilterBase = variant< - class NullFilter, - class EqualsFilter, - class NotEqualsFilter, - class LessThanFilter, - class LessThanEqualsFilter, - class GreaterThanFilter, - class GreaterThanEqualsFilter, - class InFilter, - class NotInFilter, - class AnyFilter, - class AllFilter, - class NoneFilter, - class HasFilter, - class NotHasFilter, - class TypeEqualsFilter, - class TypeNotEqualsFilter, - class TypeInFilter, - class TypeNotInFilter, - class IdentifierEqualsFilter, - class IdentifierNotEqualsFilter, - class IdentifierInFilter, - class IdentifierNotInFilter, - class HasIdentifierFilter, - class NotHasIdentifierFilter, - class ExpressionFilter>; - -class Filter : public FilterBase { -public: - using FilterBase::FilterBase; - bool operator()(const expression::EvaluationContext& context) const; -}; - } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/filter_evaluator.hpp b/include/mbgl/style/filter_evaluator.hpp deleted file mode 100644 index a4a4098b3f..0000000000 --- a/include/mbgl/style/filter_evaluator.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include <mbgl/style/filter.hpp> -#include <mbgl/util/geometry.hpp> - -#include <type_traits> - -namespace mbgl { -namespace style { - -/* - A visitor that evaluates a `Filter` for a given feature. - - Use via `Filter::operator()`. For example: - - if (filter(feature)) { - // matches the filter - } else { - // does not match - } -*/ -class FilterEvaluator { -public: - const expression::EvaluationContext context; - - bool operator()(const NullFilter&) const; - bool operator()(const EqualsFilter& filter) const; - bool operator()(const NotEqualsFilter& filter) const; - bool operator()(const LessThanFilter& filter) const; - bool operator()(const LessThanEqualsFilter& filter) const; - bool operator()(const GreaterThanFilter& filter) const; - bool operator()(const GreaterThanEqualsFilter& filter) const; - bool operator()(const InFilter& filter) const; - bool operator()(const NotInFilter& filter) const; - bool operator()(const AnyFilter& filter) const; - bool operator()(const AllFilter& filter) const; - bool operator()(const NoneFilter& filter) const; - bool operator()(const HasFilter& filter) const; - bool operator()(const NotHasFilter& filter) const; - bool operator()(const TypeEqualsFilter& filter) const; - bool operator()(const TypeNotEqualsFilter& filter) const; - bool operator()(const TypeInFilter& filter) const; - bool operator()(const TypeNotInFilter& filter) const; - bool operator()(const IdentifierEqualsFilter& filter) const; - bool operator()(const IdentifierNotEqualsFilter& filter) const; - bool operator()(const IdentifierInFilter& filter) const; - bool operator()(const IdentifierNotInFilter& filter) const; - bool operator()(const HasIdentifierFilter&) const; - bool operator()(const NotHasIdentifierFilter&) const; - bool operator()(const ExpressionFilter&) const; - -}; - -} // namespace style -} // namespace mbgl diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index c35cde88e0..a25656012b 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,12 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 6.1.2 + - `"to-string"` expression operator converts `null` to empty string rather than to `"null"` [#11904](https://github.com/mapbox/mapbox-gl-native/pull/11904) + +## 6.1.1 - May 7, 2018 + - Update telemetry to 3.1.0 [#11855](https://github.com/mapbox/mapbox-gl-native/pull/11855) + ## 6.1.0 - May 4, 2018 - Unwrap LatLngBounds during JNI conversion [#11807](https://github.com/mapbox/mapbox-gl-native/pull/11807) - Check if renderer is not destroyed before delivering snapshot [#11800](https://github.com/mapbox/mapbox-gl-native/pull/11800) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index 84aeabef1a..a49ef47674 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=7.0.0-SNAPSHOT +VERSION_NAME=6.2.0-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values-ko/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values-ko/strings.xml new file mode 100644 index 0000000000..a292e52517 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values-ko/strings.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="mapbox_compassContentDescription">지도 나침반. 지도회전를 북쪽으로 재설정합니다.</string> + <string name="mapbox_attributionsIconContentDescription">속성 정보. 속성 대화를 표시합니다.</string> + <string name="mapbox_myLocationViewContentDescription">로케이션 뷰. 지도에서 현재 위치를 보여줍니다.</string> + <string name="mapbox_mapActionDescription">맵박스로 생성된 지도 표시. 두 손가락으로 드래그하여 화면을 위 아래로 움직이세요. 두 손가락을 이용해 화면을 확대 축소 하세요.</string> + <string name="mapbox_attributionsDialogTitle">안드로이드를 위한 맵박스 맵 SDK</string> + <string name="mapbox_attributionTelemetryTitle">더 나은 맵박스 지도 만들기</string> + <string name="mapbox_attributionTelemetryMessage">당신은 익명의 사용 데이터를 제공함으로써, 오픈스트리트맵과 맵박스 향상에 기여하고 있습니다.</string> + <string name="mapbox_attributionTelemetryPositive">동의</string> + <string name="mapbox_attributionTelemetryNegative">비동의</string> + <string name="mapbox_attributionTelemetryNeutral">추가정보</string> + <string name="mapbox_attributionErrorNoBrowser">웹 브라우저가 설치 되어 있지 않아, 웹 페이지를 열 수 없습니다.</string> + <string name="mapbox_offline_error_region_definition_invalid">제공된 오프라인지역정의가 월드바운즈에 적합하지 않습니다: %s</string> + <string name="mapbox_telemetrySettings">원격 측정 설정</string> + </resources> diff --git a/platform/android/build.gradle b/platform/android/build.gradle index 6cd9505447..16238f41c1 100644 --- a/platform/android/build.gradle +++ b/platform/android/build.gradle @@ -14,7 +14,8 @@ allprojects { mavenCentral() jcenter() google() - maven { url "http://oss.sonatype.org/content/repositories/snapshots/" } + // Snapshot repository + //maven { url "http://oss.sonatype.org/content/repositories/snapshots/" } } } diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp index 6fe6e3cb29..c7a6bcd3a3 100644 --- a/platform/android/src/style/layers/layer.cpp +++ b/platform/android/src/style/layers/layer.cpp @@ -157,14 +157,12 @@ namespace android { using namespace mbgl::style::conversion; Filter filter = layer.accept(GetFilterEvaluator()); - - jni::Object<gson::JsonElement> converted; - if (filter.is<ExpressionFilter>()) { - ExpressionFilter filterExpression = filter.get<ExpressionFilter>(); - mbgl::Value expressionValue = filterExpression.expression.get()->serialize(); - converted = gson::JsonElement::New(env, expressionValue); + if (filter.expression) { + mbgl::Value expressionValue = (*filter.expression)->serialize(); + return gson::JsonElement::New(env, expressionValue); + } else { + return jni::Object<gson::JsonElement>(); } - return converted; } struct SetSourceLayerEvaluator { diff --git a/platform/macos/app/LimeGreenStyleLayer.h b/platform/darwin/app/LimeGreenStyleLayer.h index 35480963a4..35480963a4 100644 --- a/platform/macos/app/LimeGreenStyleLayer.h +++ b/platform/darwin/app/LimeGreenStyleLayer.h diff --git a/platform/macos/app/LimeGreenStyleLayer.m b/platform/darwin/app/LimeGreenStyleLayer.m index 40c336cd98..98e96381b6 100644 --- a/platform/macos/app/LimeGreenStyleLayer.m +++ b/platform/darwin/app/LimeGreenStyleLayer.m @@ -1,7 +1,5 @@ #import "LimeGreenStyleLayer.h" - -#include <OpenGL/gl.h> -#include <OpenGL/glext.h> +@import GLKit; @implementation LimeGreenStyleLayer { GLuint _program; @@ -12,8 +10,8 @@ } - (void)didMoveToMapView:(MGLMapView *)mapView { - static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }"; - static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 1, 0, 1); }"; + static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 1, 1); }"; + static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 0.5, 0, 0.5); }"; _program = glCreateProgram(); _vertexShader = glCreateShader(GL_VERTEX_SHADER); @@ -28,10 +26,10 @@ glLinkProgram(_program); _aPos = glGetAttribLocation(_program, "a_pos"); - GLfloat background[] = { -1,-1, 1,-1, -1,1, 1,1 }; + GLfloat triangle[] = { 0, 0.5, 0.5, -0.5, -0.5, -0.5 }; glGenBuffers(1, &_buffer); glBindBuffer(GL_ARRAY_BUFFER, _buffer); - glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), background, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(GLfloat), triangle, GL_STATIC_DRAW); } - (void)drawInMapView:(MGLMapView *)mapView withContext:(MGLStyleLayerDrawingContext)context { @@ -41,7 +39,7 @@ glVertexAttribPointer(_aPos, 2, GL_FLOAT, GL_FALSE, 0, NULL); glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); } - (void)willMoveFromMapView:(MGLMapView *)mapView { diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs index 2ae6602224..60177e57c2 100644 --- a/platform/darwin/docs/guides/For Style Authors.md.ejs +++ b/platform/darwin/docs/guides/For Style Authors.md.ejs @@ -272,7 +272,7 @@ Each property representing a layout or paint attribute is set to an but you create the former using a very different syntax. `NSExpression`’s format string syntax is reminiscent of a spreadsheet formula or an expression in a database query. See the -“[Predicates and Expressions](Predicates and Expressions.md)” guide for an +“[Predicates and Expressions](predicates-and-expressions.html)” guide for an overview of the expression support in this SDK. This SDK no longer supports style functions; use expressions instead. @@ -335,7 +335,7 @@ In style specification | Method, function, or predicate type | Format string syn `number` | | `string` | | `to-boolean` | `boolValue` | -`to-color` | | +`to-color` | | `CAST(var, '<%- cocoaPrefix %>Color')` `to-number` | `mgl_numberWithFallbackValues:` | `CAST(zipCode, 'NSNumber')` `to-string` | `stringValue` | `CAST(ele, 'NSString')` `typeof` | | @@ -372,7 +372,7 @@ In style specification | Method, function, or predicate type | Format string syn `rgb` | `+[UIColor colorWithRed:green:blue:alpha:]` | `rgba` | `+[UIColor colorWithRed:green:blue:alpha:]` | <% } -%> -`to-rgba` | | +`to-rgba` | | `CAST(noindex(var), 'NSArray')` `-` | `from:subtract:` | `2 - 1` `*` | `multiply:by:` | `1 * 2` `/` | `divide:by:` | `1 / 2` @@ -427,5 +427,5 @@ In style JSON | In the format string `["any", f0, …, fn]` | `p0 OR … OR pn` `["none", f0, …, fn]` | `NOT (p0 OR … OR pn)` -See the “[Predicates and Expressions](Predicates and Expressions.md)” guide for +See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for a full description of the supported operators and operand types. diff --git a/platform/darwin/docs/guides/Predicates and Expressions.md b/platform/darwin/docs/guides/Predicates and Expressions.md index c3b3d39a52..18eccda569 100644 --- a/platform/darwin/docs/guides/Predicates and Expressions.md +++ b/platform/darwin/docs/guides/Predicates and Expressions.md @@ -70,6 +70,8 @@ path or variable into a matching type: * To cast a value to a number, use `CAST(key, 'NSNumber')`. * To cast a value to a string, use `CAST(key, 'NSString')`. +* To cast a value to a color, use `CAST(key, 'UIColor')` on iOS and `CAST(key, 'NSColor')` on macOS. +* To cast an `NSColor` or `UIColor` object to an array, use `CAST(noindex(color), 'NSArray')`. For details about the predicate format string syntax, consult the “Predicate Format String Syntax” chapter of the diff --git a/platform/darwin/resources/ko.lproj/Foundation.strings b/platform/darwin/resources/ko.lproj/Foundation.strings new file mode 100644 index 0000000000..68e6cf86fc --- /dev/null +++ b/platform/darwin/resources/ko.lproj/Foundation.strings @@ -0,0 +1,297 @@ +/* Clock position format, long: {hours} o’clock */ +"CLOCK_FMT_LONG" = "%@ 시"; + +/* Clock position format, medium: {hours} o’clock */ +"CLOCK_FMT_MEDIUM" = "%@ 시"; + +/* Clock position format, short: {hours}:00 */ +"CLOCK_FMT_SHORT" = "%@:00"; + +/* East, long */ +"COMPASS_E_LONG" = "동쪽"; + +/* East, short */ +"COMPASS_E_SHORT" = "동"; + +/* East by north, long */ +"COMPASS_EbN_LONG" = "동미북쪽"; + +/* East by north, short */ +"COMPASS_EbN_SHORT" = "동미북"; + +/* East by south, long */ +"COMPASS_EbS_LONG" = "동미남쪽"; + +/* East by south, short */ +"COMPASS_EbS_SHORT" = "동미남"; + +/* East-northeast, long */ +"COMPASS_ENE_LONG" = "동북동쪽"; + +/* East-northeast, short */ +"COMPASS_ENE_SHORT" = "동북동"; + +/* East-southeast, long */ +"COMPASS_ESE_LONG" = "동남동쪽"; + +/* East-southeast, short */ +"COMPASS_ESE_SHORT" = "동남동"; + +/* North, long */ +"COMPASS_N_LONG" = "북쪽"; + +/* North, short */ +"COMPASS_N_SHORT" = "북"; + +/* North by east, long */ +"COMPASS_NbE_LONG" = "북미동쪽"; + +/* North by east, short */ +"COMPASS_NbE_SHORT" = "북미동"; + +/* North by west, long */ +"COMPASS_NbW_LONG" = "북미서쪽"; + +/* North by west, short */ +"COMPASS_NbW_SHORT" = "북미서"; + +/* Northeast, long */ +"COMPASS_NE_LONG" = "북동쪽"; + +/* Northeast, short */ +"COMPASS_NE_SHORT" = "북동"; + +/* Northeast by east, long */ +"COMPASS_NEbE_LONG" = "북동미동쪽"; + +/* Northeast by east, short */ +"COMPASS_NEbE_SHORT" = "북동미동"; + +/* Northeast by north, long */ +"COMPASS_NEbN_LONG" = "북동미북쪽"; + +/* Northeast by north, short */ +"COMPASS_NEbN_SHORT" = "북동미북"; + +/* North-northeast, long */ +"COMPASS_NNE_LONG" = "북북동쪽"; + +/* North-northeast, short */ +"COMPASS_NNE_SHORT" = "북북동"; + +/* North-northwest, long */ +"COMPASS_NNW_LONG" = "북북서쪽"; + +/* North-northwest, short */ +"COMPASS_NNW_SHORT" = "북북서"; + +/* Northwest, long */ +"COMPASS_NW_LONG" = "북서쪽"; + +/* Northwest, short */ +"COMPASS_NW_SHORT" = "북서"; + +/* Northwest by north, long */ +"COMPASS_NWbN_LONG" = "북서미북쪽"; + +/* Northwest by north, short */ +"COMPASS_NWbN_SHORT" = "북서미북"; + +/* Northwest by west, long */ +"COMPASS_NWbW_LONG" = "북서미서쪽"; + +/* Northwest by west, short */ +"COMPASS_NWbW_SHORT" = "북서미서"; + +/* South, long */ +"COMPASS_S_LONG" = "남쪽"; + +/* South, short */ +"COMPASS_S_SHORT" = "남"; + +/* South by east, long */ +"COMPASS_SbE_LONG" = "남미동쪽"; + +/* South by east, short */ +"COMPASS_SbE_SHORT" = "남미동"; + +/* South by west, long */ +"COMPASS_SbW_LONG" = "남미서"; + +/* South by west, short */ +"COMPASS_SbW_SHORT" = "남미서"; + +/* Southeast, long */ +"COMPASS_SE_LONG" = "남동쪽"; + +/* Southeast, short */ +"COMPASS_SE_SHORT" = "남동"; + +/* Southeast by east, long */ +"COMPASS_SEbE_LONG" = "남동미동쪽"; + +/* Southeast by east, short */ +"COMPASS_SEbE_SHORT" = "남동미동"; + +/* Southeast by south, long */ +"COMPASS_SEbS_LONG" = "남동미남쪽"; + +/* Southeast by south, short */ +"COMPASS_SEbS_SHORT" = "남동미남"; + +/* South-southeast, long */ +"COMPASS_SSE_LONG" = "남남동쪽"; + +/* South-southeast, short */ +"COMPASS_SSE_SHORT" = "남남동"; + +/* South-southwest, long */ +"COMPASS_SSW_LONG" = "남남서쪽"; + +/* South-southwest, short */ +"COMPASS_SSW_SHORT" = "남남서"; + +/* Southwest, long */ +"COMPASS_SW_LONG" = "남서쪽"; + +/* Southwest, short */ +"COMPASS_SW_SHORT" = "남서"; + +/* Southwest by south, long */ +"COMPASS_SWbS_LONG" = "남서미남쪽"; + +/* Southwest by south, short */ +"COMPASS_SWbS_SHORT" = "남서미남"; + +/* Southwest by west, long */ +"COMPASS_SWbW_LONG" = "남서미서쪽"; + +/* Southwest by west, short */ +"COMPASS_SWbW_SHORT" = "남서미서"; + +/* West, long */ +"COMPASS_W_LONG" = "서쪽"; + +/* West, short */ +"COMPASS_W_SHORT" = "서"; + +/* West by north, long */ +"COMPASS_WbN_LONG" = "서미북쪽"; + +/* West by north, short */ +"COMPASS_WbN_SHORT" = "서미북"; + +/* West by south, long */ +"COMPASS_WbS_LONG" = "서미남쪽"; + +/* West by south, short */ +"COMPASS_WbS_SHORT" = "서미남"; + +/* West-northwest, long */ +"COMPASS_WNW_LONG" = "서북서쪽"; + +/* West-northwest, short */ +"COMPASS_WNW_SHORT" = "서북서"; + +/* West-southwest, long */ +"COMPASS_WSW_LONG" = "서남서쪽"; + +/* West-southwest, short */ +"COMPASS_WSW_SHORT" = "서남서"; + +/* Degrees format, long */ +"COORD_DEG_LONG" = "%d 도"; + +/* Degrees format, medium: {degrees} */ +"COORD_DEG_MEDIUM" = "%d°"; + +/* Degrees format, short: {degrees} */ +"COORD_DEG_SHORT" = "%d°"; + +/* Coordinate format, long: {degrees}{minutes} */ +"COORD_DM_LONG" = "%1$@ 와 %2$@"; + +/* Coordinate format, medium: {degrees}{minutes} */ +"COORD_DM_MEDIUM" = "%1$@%2$@"; + +/* Coordinate format, short: {degrees}{minutes} */ +"COORD_DM_SHORT" = "%1$@%2$@"; + +/* Coordinate format, long: {degrees}{minutes}{seconds} */ +"COORD_DMS_LONG" = "%1$@, %2$@, 와 %3$@"; + +/* Coordinate format, medium: {degrees}{minutes}{seconds} */ +"COORD_DMS_MEDIUM" = "%1$@%2$@%3$@"; + +/* Coordinate format, short: {degrees}{minutes}{seconds} */ +"COORD_DMS_SHORT" = "%1$@%2$@%3$@"; + +/* East longitude format, long: {longitude} */ +"COORD_E_LONG" = "%@ 동쪽"; + +/* East longitude format, medium: {longitude} */ +"COORD_E_MEDIUM" = "%@ 동쪽"; + +/* East longitude format, short: {longitude} */ +"COORD_E_SHORT" = "%@동"; + +/* Coordinate pair format, long: {latitude}, {longitude} */ +"COORD_FMT_LONG" = "%1$@ by %2$@"; + +/* Coordinate pair format, medium: {latitude}, {longitude} */ +"COORD_FMT_MEDIUM" = "%1$@, %2$@"; + +/* Coordinate pair format, short: {latitude}, {longitude} */ +"COORD_FMT_SHORT" = "%1$@, %2$@"; + +/* Minutes format, long */ +"COORD_MIN_LONG" = "%d 분"; + +/* Minutes format, medium: {minutes} */ +"COORD_MIN_MEDIUM" = "%d′"; + +/* Minutes format, short: {minutes} */ +"COORD_MIN_SHORT" = "%d′"; + +/* North latitude format, long: {latitude} */ +"COORD_N_LONG" = "%@ 북쪽"; + +/* North latitude format, medium: {latitude} */ +"COORD_N_MEDIUM" = "%@ 북쪽"; + +/* North latitude format, short: {latitude} */ +"COORD_N_SHORT" = "%@북"; + +/* South latitude format, long: {latitude} */ +"COORD_S_LONG" = "%@ 남쪽"; + +/* South latitude format, medium: {latitude} */ +"COORD_S_MEDIUM" = "%@ 남쪽"; + +/* South latitude format, short: {latitude} */ +"COORD_S_SHORT" = "%@남"; + +/* Seconds format, long */ +"COORD_SEC_LONG" = "%d 초"; + +/* Seconds format, medium: {seconds} */ +"COORD_SEC_MEDIUM" = "%d″"; + +/* Seconds format, short: {seconds} */ +"COORD_SEC_SHORT" = "%d″"; + +/* West longitude format, long: {longitude} */ +"COORD_W_LONG" = "%@ 서쪽"; + +/* West longitude format, medium: {longitude} */ +"COORD_W_MEDIUM" = "%@ 서쪽"; + +/* West longitude format, short: {longitude} */ +"COORD_W_SHORT" = "%@서"; + +/* OpenStreetMap full name attribution */ +"OSM_FULL_NAME" = "오픈스트리트맵"; + +/* OpenStreetMap short name attribution */ +"OSM_SHORT_NAME" = "오픈스트리트맵"; + diff --git a/platform/darwin/resources/ko.lproj/Foundation.stringsdict b/platform/darwin/resources/ko.lproj/Foundation.stringsdict new file mode 100644 index 0000000000..56d26aa949 --- /dev/null +++ b/platform/darwin/resources/ko.lproj/Foundation.stringsdict @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>COORD_DEG_LONG</key> + <dict> + <key>NSStringLocalizedFormatKey</key> + <string>%#@degrees@</string> + <key>degrees</key> + <dict> + <key>NSStringFormatSpecTypeKey</key> + <string>NSStringPluralRuleType</string> + <key>NSStringFormatValueTypeKey</key> + <string>d</string> + <key>other</key> + <string>%d 도</string> + </dict> + </dict> + <key>COORD_MIN_LONG</key> + <dict> + <key>NSStringLocalizedFormatKey</key> + <string>%#@minutes@</string> + <key>minutes</key> + <dict> + <key>NSStringFormatSpecTypeKey</key> + <string>NSStringPluralRuleType</string> + <key>NSStringFormatValueTypeKey</key> + <string>d</string> + <key>other</key> + <string>%d 분</string> + </dict> + </dict> + <key>COORD_SEC_LONG</key> + <dict> + <key>NSStringLocalizedFormatKey</key> + <string>%#@seconds@</string> + <key>seconds</key> + <dict> + <key>NSStringFormatSpecTypeKey</key> + <string>NSStringPluralRuleType</string> + <key>NSStringFormatValueTypeKey</key> + <string>d</string> + <key>other</key> + <string>%d 초</string> + </dict> + </dict> +</dict> +</plist> diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 47106eeac4..9089e57ad5 100755 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -408,7 +408,7 @@ global.describeValue = function (value, property, layerType) { case 'boolean': return value ? '`YES`' : '`NO`'; case 'number': - return 'the float ' + formatNumber(value); + return 'the float ' + '`' + formatNumber(value) + '`'; case 'string': if (value === '') { return 'the empty string'; diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/darwin/src/MGLBackgroundStyleLayer.h index d5c3ed5403..31755c8bad 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.h +++ b/platform/darwin/src/MGLBackgroundStyleLayer.h @@ -96,7 +96,7 @@ which it is added. The opacity at which the background will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 993645d3a8..acea3441fa 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index 06b4de32f0..69b6e41c9c 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -117,7 +117,7 @@ MGL_EXPORT full opacity. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -186,7 +186,7 @@ MGL_EXPORT The opacity at which the circle will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -235,7 +235,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 5. Set this property to `nil` to reset it to the default value. + `5`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -334,7 +334,7 @@ MGL_EXPORT The opacity of the circle's stroke. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -361,7 +361,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 0be3920987..b03ab8a7a6 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -75,7 +75,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.h b/platform/darwin/src/MGLFillExtrusionStyleLayer.h index 7c3a0773e4..bca2a99f1e 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.h +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.h @@ -78,7 +78,7 @@ MGL_EXPORT This property is measured in meters. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `fillExtrusionHeight` is non-`nil`. Otherwise, it is ignored. @@ -164,7 +164,7 @@ MGL_EXPORT This property is measured in meters. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -189,7 +189,7 @@ MGL_EXPORT per-layer, not per-feature, basis, and data-driven styling is not available. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm index 688ce4c1ac..4f3bfee18e 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -65,7 +65,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index 90740223eb..af82482c62 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -151,7 +151,7 @@ MGL_EXPORT value will also affect the 1pt stroke around the fill, if the stroke is used. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index c975e28d6b..12e3643ce6 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -65,7 +65,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index 0bff9b09f5..d0d9446a5f 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -71,6 +71,17 @@ NS_INLINE MGLCoordinateQuad MGLCoordinateQuadFromLatLngArray(std::array<mbgl::La MGLLocationCoordinate2DFromLatLng(quad[1]) }; } +/** + YES if the coordinate is valid or NO if it is not. + Considers extended coordinates. + */ +NS_INLINE BOOL MGLLocationCoordinate2DIsValid(CLLocationCoordinate2D coordinate) { + return (coordinate.latitude <= 90.0 && + coordinate.latitude >= -90.0 && + coordinate.longitude <= 360.0 && + coordinate.longitude >= -360.0); +} + #if TARGET_OS_IPHONE NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(UIEdgeInsets insets) { return { insets.top, insets.left, insets.bottom, insets.right }; diff --git a/platform/darwin/src/MGLHeatmapStyleLayer.h b/platform/darwin/src/MGLHeatmapStyleLayer.h index ad7ba5de01..167c5bafbe 100644 --- a/platform/darwin/src/MGLHeatmapStyleLayer.h +++ b/platform/darwin/src/MGLHeatmapStyleLayer.h @@ -116,7 +116,7 @@ MGL_EXPORT Primarily used for adjusting the heatmap based on zoom level. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -142,7 +142,7 @@ MGL_EXPORT The global opacity at which the heatmap layer will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -171,7 +171,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 30. Set this property to `nil` to reset it to the default value. + `30`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -197,7 +197,7 @@ MGL_EXPORT Especially useful when combined with clustering. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLHeatmapStyleLayer.mm b/platform/darwin/src/MGLHeatmapStyleLayer.mm index a394dbda3b..925b3ac750 100644 --- a/platform/darwin/src/MGLHeatmapStyleLayer.mm +++ b/platform/darwin/src/MGLHeatmapStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -56,7 +56,7 @@ { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLHillshadeStyleLayer.h b/platform/darwin/src/MGLHillshadeStyleLayer.h index 224680160a..45b0e66751 100644 --- a/platform/darwin/src/MGLHillshadeStyleLayer.h +++ b/platform/darwin/src/MGLHillshadeStyleLayer.h @@ -130,7 +130,7 @@ MGL_EXPORT Intensity of the hillshade The default value of this property is an expression that evaluates to the float - 0.5. Set this property to `nil` to reset it to the default value. + `0.5`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -232,7 +232,7 @@ MGL_EXPORT `hillshadeIlluminationAnchor` is set to `MGLHillshadeIlluminationAnchorMap`. The default value of this property is an expression that evaluates to the float - 335. Set this property to `nil` to reset it to the default value. + `335`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLHillshadeStyleLayer.mm b/platform/darwin/src/MGLHillshadeStyleLayer.mm index 2383c1ce26..70fab24e33 100644 --- a/platform/darwin/src/MGLHillshadeStyleLayer.mm +++ b/platform/darwin/src/MGLHillshadeStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h index cf4aa50112..13c925d9bd 100644 --- a/platform/darwin/src/MGLLight.h +++ b/platform/darwin/src/MGLLight.h @@ -188,7 +188,7 @@ MGL_EXPORT more extreme contrast. The default value of this property is an expression that evaluates to the float - 0.5. + `0.5`. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index 32c8ece6c5..1080244bdb 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -180,7 +180,7 @@ MGL_EXPORT Used to automatically convert miter joins to bevel joins for sharp angles. The default value of this property is an expression that evaluates to the float - 2. Set this property to `nil` to reset it to the default value. + `2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `lineJoin` is set to an expression that evaluates to `miter`. Otherwise, it is ignored. @@ -202,7 +202,7 @@ MGL_EXPORT Used to automatically convert round joins to miter joins for shallow angles. The default value of this property is an expression that evaluates to the float - 1.05. Set this property to `nil` to reset it to the default value. + `1.05`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `lineJoin` is set to an expression that evaluates to `round`. Otherwise, it is ignored. @@ -228,7 +228,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -346,7 +346,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -375,7 +375,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -399,7 +399,7 @@ MGL_EXPORT The opacity at which the line will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -545,7 +545,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 619cc70afe..84412073cd 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -77,7 +77,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm index 19fa0223a4..923c8fb2a1 100644 --- a/platform/darwin/src/MGLMapSnapshotter.mm +++ b/platform/darwin/src/MGLMapSnapshotter.mm @@ -122,8 +122,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; _snapshotCallback = std::make_unique<mbgl::Actor<mbgl::MapSnapshotter::Callback>>(*mbgl::Scheduler::GetCurrent(), [=](std::exception_ptr mbglError, mbgl::PremultipliedImage image, mbgl::MapSnapshotter::Attributions attributions, mbgl::MapSnapshotter::PointForFn pointForFn) { __typeof__(self) strongSelf = weakSelf; strongSelf.loading = false; - - + if (mbglError) { NSString *description = @(mbgl::util::toString(mbglError).c_str()); NSDictionary *userInfo = @{NSLocalizedDescriptionKey: description}; @@ -145,9 +144,13 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; } _snapshotCallback = NULL; }); - dispatch_async(queue, ^{ - _mbglMapSnapshotter->snapshot(_snapshotCallback->self()); + dispatch_async(queue, ^{ + __typeof__(self) strongSelf = weakSelf; + if (!strongSelf) { + return; + } + strongSelf->_mbglMapSnapshotter->snapshot(strongSelf->_snapshotCallback->self()); }); } diff --git a/platform/darwin/src/MGLMultiPoint.mm b/platform/darwin/src/MGLMultiPoint.mm index 5a7262b0a4..d4518e3d8f 100644 --- a/platform/darwin/src/MGLMultiPoint.mm +++ b/platform/darwin/src/MGLMultiPoint.mm @@ -163,7 +163,7 @@ if (!_bounds) { mbgl::LatLngBounds bounds = mbgl::LatLngBounds::empty(); for (auto coordinate : _coordinates) { - if (!CLLocationCoordinate2DIsValid(coordinate)) { + if (!MGLLocationCoordinate2DIsValid(coordinate)) { bounds = mbgl::LatLngBounds::empty(); break; } diff --git a/platform/darwin/src/MGLOverlay.h b/platform/darwin/src/MGLOverlay.h index 462a0c1031..7706b741e2 100644 --- a/platform/darwin/src/MGLOverlay.h +++ b/platform/darwin/src/MGLOverlay.h @@ -30,6 +30,11 @@ NS_ASSUME_NONNULL_BEGIN This property contains the smallest rectangle that completely encompasses the overlay. Implementers of this protocol must set this area when implementing their overlay class, and after setting it, you must not change it. + + If this overlay spans the antimeridian, its bounds may extend west of −180 degrees + longitude or east of 180 degrees longitude. For example, an overlay covering the + Pacific Ocean from Tokyo to San Francisco might have a bounds extending + from (35.68476, −220.24257) to (37.78428, −122.41310). */ @property (nonatomic, readonly) MGLCoordinateBounds overlayBounds; diff --git a/platform/darwin/src/MGLPointCollection.mm b/platform/darwin/src/MGLPointCollection.mm index 8f20d91a42..efb9497a1f 100644 --- a/platform/darwin/src/MGLPointCollection.mm +++ b/platform/darwin/src/MGLPointCollection.mm @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN if (!_bounds) { mbgl::LatLngBounds bounds = mbgl::LatLngBounds::empty(); for (auto coordinate : _coordinates) { - if (!CLLocationCoordinate2DIsValid(coordinate)) { + if (!MGLLocationCoordinate2DIsValid(coordinate)) { bounds = mbgl::LatLngBounds::empty(); break; } diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index bca9649e5d..ff055d24f6 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.h +++ b/platform/darwin/src/MGLRasterStyleLayer.h @@ -64,7 +64,7 @@ MGL_EXPORT brightness. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. This attribute corresponds to the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-brightness-max"><code>raster-brightness-max</code></a> @@ -97,7 +97,7 @@ MGL_EXPORT brightness. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This attribute corresponds to the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-brightness-min"><code>raster-brightness-min</code></a> @@ -129,7 +129,7 @@ MGL_EXPORT Increase or reduce the contrast of the image. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -157,7 +157,7 @@ MGL_EXPORT This property is measured in milliseconds. The default value of this property is an expression that evaluates to the float - 300. Set this property to `nil` to reset it to the default value. + `300`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -178,7 +178,7 @@ MGL_EXPORT This property is measured in degrees. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This attribute corresponds to the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-hue-rotate"><code>raster-hue-rotate</code></a> @@ -210,7 +210,7 @@ MGL_EXPORT The opacity at which the image will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: @@ -236,7 +236,7 @@ MGL_EXPORT Increase or reduce the saturation of the image. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index 94a58409de..0e31512491 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index 31e5867703..1425269012 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -6,7 +6,7 @@ #import "MGLFeature_Private.h" #import "MGLShape_Private.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSURL+MGLAdditions.h" #include <mbgl/map/map.hpp> diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 5405598124..f3e75b492c 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -8,7 +8,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -103,7 +103,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index e27f039b75..2c899fe76f 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -564,7 +564,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 2. Set this property to `nil` to reset it to the default value. + `2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. @@ -615,7 +615,7 @@ MGL_EXPORT This property is measured in degrees. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. @@ -678,7 +678,7 @@ MGL_EXPORT This property is measured in factor of the original icon sizes. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. @@ -858,7 +858,7 @@ MGL_EXPORT This property is measured in degrees. The default value of this property is an expression that evaluates to the float - 45. Set this property to `nil` to reset it to the default value. + `45`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`, and `symbolPlacement` is set to an expression that evaluates to `line`. Otherwise, @@ -890,7 +890,7 @@ MGL_EXPORT This property is measured in ems. The default value of this property is an expression that evaluates to the float - 10. Set this property to `nil` to reset it to the default value. + `10`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -973,7 +973,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 250. Set this property to `nil` to reset it to the default value. + `250`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `symbolPlacement` is set to an expression that evaluates to `line`. Otherwise, it is ignored. @@ -1129,7 +1129,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 16. Set this property to `nil` to reset it to the default value. + `16`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1219,7 +1219,7 @@ MGL_EXPORT This property is measured in ems. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1241,7 +1241,7 @@ MGL_EXPORT This property is measured in ems. The default value of this property is an expression that evaluates to the float - 1.2. Set this property to `nil` to reset it to the default value. + `1.2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1338,7 +1338,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 2. Set this property to `nil` to reset it to the default value. + `2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1389,7 +1389,7 @@ MGL_EXPORT This property is measured in degrees. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1529,7 +1529,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. @@ -1611,7 +1611,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. @@ -1638,7 +1638,7 @@ MGL_EXPORT The opacity at which the icon will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. @@ -1819,7 +1819,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1900,7 +1900,7 @@ MGL_EXPORT This property is measured in points. The default value of this property is an expression that evaluates to the float - 0. Set this property to `nil` to reset it to the default value. + `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. @@ -1927,7 +1927,7 @@ MGL_EXPORT The opacity at which the text will be drawn. The default value of this property is an expression that evaluates to the float - 1. Set this property to `nil` to reset it to the default value. + `1`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `text` is non-`nil`. Otherwise, it is ignored. diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 0d9fac4808..7ec7816c3b 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -2,7 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSDate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -142,7 +142,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } - (NSPredicate *)predicate diff --git a/platform/darwin/src/MGLVectorTileSource.mm b/platform/darwin/src/MGLVectorTileSource.mm index c6715d1759..e55ed13060 100644 --- a/platform/darwin/src/MGLVectorTileSource.mm +++ b/platform/darwin/src/MGLVectorTileSource.mm @@ -6,7 +6,7 @@ #import "MGLStyle_Private.h" #import "MGLMapView_Private.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSURL+MGLAdditions.h" #include <mbgl/map/map.hpp> @@ -112,7 +112,8 @@ static NSArray * const MGLMapboxStreetsAlternativeLanguages = @[ return [[NSLocale localeWithLocaleIdentifier:language].languageCode isEqualToString:@"en"]; }]].count; - NSArray<NSString *> *preferredLanguages = [NSBundle preferredLocalizationsFromArray:MGLMapboxStreetsAlternativeLanguages + NSArray<NSString *> *availableLanguages = acceptsEnglish ? MGLMapboxStreetsLanguages : MGLMapboxStreetsAlternativeLanguages; + NSArray<NSString *> *preferredLanguages = [NSBundle preferredLocalizationsFromArray:availableLanguages forPreferences:preferencesArray]; NSString *mostSpecificLanguage; for (NSString *language in preferredLanguages) { @@ -120,10 +121,7 @@ static NSArray * const MGLMapboxStreetsAlternativeLanguages = @[ mostSpecificLanguage = language; } } - if ([mostSpecificLanguage isEqualToString:@"mul"]) { - return acceptsEnglish ? @"en" : nil; - } - return mostSpecificLanguage; + return [mostSpecificLanguage isEqualToString:@"mul"] ? nil : mostSpecificLanguage; } - (BOOL)isMapboxStreets { @@ -135,19 +133,4 @@ static NSArray * const MGLMapboxStreetsAlternativeLanguages = @[ return [identifiers containsObject:@"mapbox.mapbox-streets-v7"] || [identifiers containsObject:@"mapbox.mapbox-streets-v6"]; } -- (NSDictionary<NSString *, NSString *> *)localizedKeysByKeyForPreferredLanguage:(nullable NSString *)preferredLanguage { - if (!self.mapboxStreets) { - return @{}; - } - - // Replace {name} and {name_*} with the matching localized name tag. - NSString *localizedKey = preferredLanguage ? [NSString stringWithFormat:@"name_%@", preferredLanguage] : @"name"; - NSMutableDictionary *localizedKeysByKey = [NSMutableDictionary dictionaryWithObject:localizedKey forKey:@"name"]; - for (NSString *languageCode in [MGLVectorTileSource mapboxStreetsLanguages]) { - NSString *key = [NSString stringWithFormat:@"name_%@", languageCode]; - localizedKeysByKey[key] = localizedKey; - } - return localizedKeysByKey; -} - @end diff --git a/platform/darwin/src/MGLVectorTileSource_Private.h b/platform/darwin/src/MGLVectorTileSource_Private.h index 8042e2cfee..8d287ae4c4 100644 --- a/platform/darwin/src/MGLVectorTileSource_Private.h +++ b/platform/darwin/src/MGLVectorTileSource_Private.h @@ -11,8 +11,6 @@ NS_ASSUME_NONNULL_BEGIN + (nullable NSString *)preferredMapboxStreetsLanguage; + (nullable NSString *)preferredMapboxStreetsLanguageForPreferences:(NSArray<NSString *> *)preferencesArray; -- (NSDictionary<NSString *, NSString *> *)localizedKeysByKeyForPreferredLanguage:(nullable NSString *)preferredLanguage; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm b/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm index 5a98b763ea..a8ae19b172 100644 --- a/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm +++ b/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm @@ -2,7 +2,7 @@ #import "MGLStyleValue_Private.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSExpression+MGLPrivateAdditions.h" #include <mbgl/style/conversion/property_value.hpp> diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index a42a2d276e..be93b13f3c 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -798,6 +798,22 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { } else if ([op isEqualToString:@"to-string"] || [op isEqualToString:@"string"]) { NSExpression *operand = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject]; return [NSExpression expressionWithFormat:@"CAST(%@, 'NSString')", operand]; + } else if ([op isEqualToString:@"to-color"]) { + NSExpression *operand = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject]; + + if (argumentObjects.count == 1) { +#if TARGET_OS_IPHONE + return [NSExpression expressionWithFormat:@"CAST(%@, 'UIColor')", operand]; +#else + return [NSExpression expressionWithFormat:@"CAST(%@, 'NSColor')", operand]; +#endif + } + NSArray *subexpressions = MGLSubexpressionsWithJSONObjects(array); + return [NSExpression expressionForFunction:@"MGL_FUNCTION" arguments:subexpressions]; + + } else if ([op isEqualToString:@"to-rgba"]) { + NSExpression *operand = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject]; + return [NSExpression expressionWithFormat:@"CAST(noindex(%@), 'NSArray')", operand]; } else if ([op isEqualToString:@"get"]) { if (argumentObjects.count == 2) { NSExpression *operand = [NSExpression expressionWithMGLJSONObject:argumentObjects.lastObject]; @@ -909,7 +925,7 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { for (NSUInteger index = 0; index < argumentObjects.count; index++) { if (index % 2 == 0 && index != argumentObjects.count - 1) { - NSPredicate *predicate = [NSPredicate mgl_predicateWithJSONObject:argumentObjects[index]]; + NSPredicate *predicate = [NSPredicate predicateWithMGLJSONObject:argumentObjects[index]]; NSExpression *argument = [NSExpression expressionForConstantValue:predicate]; [arguments addObject:argument]; } else { @@ -1091,7 +1107,22 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { NSArray *arguments = self.arguments.mgl_jsonExpressionObject; return [@[@"concat", self.operand.mgl_jsonExpressionObject] arrayByAddingObjectsFromArray:arguments]; } else if ([function isEqualToString:@"objectFrom:withIndex:"]) { - return @[@"at", self.arguments[1].mgl_jsonExpressionObject, self.arguments[0].mgl_jsonExpressionObject]; + id index = self.arguments[1].mgl_jsonExpressionObject; + + if ([self.arguments[1] expressionType] == NSConstantValueExpressionType + && [[self.arguments[1] constantValue] isKindOfClass:[NSString class]]) { + id value = self.arguments[1].constantValue; + + if ([value isEqualToString:@"FIRST"]) { + index = [NSExpression expressionForConstantValue:@0].mgl_jsonExpressionObject; + } else if ([value isEqualToString:@"LAST"]) { + index = [NSExpression expressionWithFormat:@"count(%@) - 1", self.arguments[0]].mgl_jsonExpressionObject; + } else if ([value isEqualToString:@"SIZE"]) { + return [NSExpression expressionWithFormat:@"count(%@)", self.arguments[0]].mgl_jsonExpressionObject; + } + } + + return @[@"at", index, self.arguments[0].mgl_jsonExpressionObject]; } else if ([function isEqualToString:@"boolValue"]) { return @[@"to-boolean", self.operand.mgl_jsonExpressionObject]; } else if ([function isEqualToString:@"mgl_number"] || @@ -1144,6 +1175,26 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { } else if ([type isEqualToString:@"NSNumber"]) { return @[@"to-number", object]; } +#if TARGET_OS_IPHONE + else if ([type isEqualToString:@"UIColor"] || [type isEqualToString:@"MGLColor"]) { + return @[@"to-color", object]; + } +#else + else if ([type isEqualToString:@"NSColor"] || [type isEqualToString:@"MGLColor"]) { + return @[@"to-color", object]; + } +#endif + else if ([type isEqualToString:@"NSArray"]) { + NSExpression *operand = self.arguments.firstObject; + if ([operand expressionType] == NSFunctionExpressionType ) { + operand = self.arguments.firstObject.arguments.firstObject; + } + if (([operand expressionType] != NSConstantValueExpressionType) || + ([operand expressionType] == NSConstantValueExpressionType && + [[operand constantValue] isKindOfClass:[MGLColor class]])) { + return @[@"to-rgba", object]; + } + } [NSException raise:NSInvalidArgumentException format:@"Casting expression to %@ not yet implemented.", type]; } else if ([function isEqualToString:@"MGL_FUNCTION"]) { @@ -1212,7 +1263,7 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { case NSAnyKeyExpressionType: case NSBlockExpressionType: [NSException raise:NSInvalidArgumentException - format:@"Expression type %lu not yet implemented.", self.expressionType]; + format:@"Expression type %lu not yet implemented.", (unsigned long)self.expressionType]; } // NSKeyPathSpecifierExpression @@ -1234,11 +1285,11 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { if (self.arguments.count < expectedArgumentCount) { [NSException raise:NSInvalidArgumentException format: @"Too few arguments to ‘%@’ function; expected %lu arguments.", - self.function, expectedArgumentCount]; + self.function, (unsigned long)expectedArgumentCount]; } else if (self.arguments.count > expectedArgumentCount) { [NSException raise:NSInvalidArgumentException format: @"%lu unexpected arguments to ‘%@’ function; expected %lu arguments.", - self.arguments.count - expectedArgumentCount, self.function, expectedArgumentCount]; + self.arguments.count - (unsigned long)expectedArgumentCount, self.function, (unsigned long)expectedArgumentCount]; } BOOL isAftermarketFunction = [self.function isEqualToString:@"mgl_interpolate:withCurveType:parameters:stops:"]; @@ -1252,9 +1303,15 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { NSArray *controlPoints = [self.arguments[curveTypeIndex + 1].collection mgl_jsonExpressionObject]; [interpolationArray addObjectsFromArray:controlPoints]; } + + NSDictionary<NSNumber *, NSExpression *> *stops = self.arguments[curveTypeIndex + 2].constantValue; + + if (stops.count == 0) { + [NSException raise:NSInvalidArgumentException format:@"‘stops‘ dictionary argument to ‘%@’ function must not be empty.", self.function]; + } + NSMutableArray *expressionObject = [NSMutableArray arrayWithObjects:@"interpolate", interpolationArray, nil]; [expressionObject addObject:(isAftermarketFunction ? self.arguments.firstObject : self.operand).mgl_jsonExpressionObject]; - NSDictionary<NSNumber *, NSExpression *> *stops = self.arguments[curveTypeIndex + 2].constantValue; for (NSNumber *key in [stops.allKeys sortedArrayUsingSelector:@selector(compare:)]) { [expressionObject addObject:key]; [expressionObject addObject:[stops[key] mgl_jsonExpressionObject]]; @@ -1266,8 +1323,14 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { BOOL isAftermarketFunction = [self.function isEqualToString:@"mgl_step:from:stops:"]; NSUInteger minimumIndex = isAftermarketFunction ? 1 : 0; id minimum = self.arguments[minimumIndex].mgl_jsonExpressionObject; - NSMutableArray *expressionObject = [NSMutableArray arrayWithObjects:@"step", (isAftermarketFunction ? self.arguments.firstObject : self.operand).mgl_jsonExpressionObject, minimum, nil]; NSDictionary<NSNumber *, NSExpression *> *stops = self.arguments[minimumIndex + 1].constantValue; + + if (stops.count == 0) { + [NSException raise:NSInvalidArgumentException format:@"‘stops‘ dictionary argument to ‘%@’ function must not be empty.", self.function]; + } + + NSMutableArray *expressionObject = [NSMutableArray arrayWithObjects:@"step", (isAftermarketFunction ? self.arguments.firstObject : self.operand).mgl_jsonExpressionObject, minimum, nil]; + for (NSNumber *key in [stops.allKeys sortedArrayUsingSelector:@selector(compare:)]) { [expressionObject addObject:key]; [expressionObject addObject:[stops[key] mgl_jsonExpressionObject]]; diff --git a/platform/darwin/src/NSPredicate+MGLAdditions.h b/platform/darwin/src/NSPredicate+MGLAdditions.h index a73b1a61ba..6c4b878d37 100644 --- a/platform/darwin/src/NSPredicate+MGLAdditions.h +++ b/platform/darwin/src/NSPredicate+MGLAdditions.h @@ -1,23 +1,44 @@ #import <Foundation/Foundation.h> -#import "NSExpression+MGLPrivateAdditions.h" +NS_ASSUME_NONNULL_BEGIN @interface NSPredicate (MGLAdditions) -- (mbgl::style::Filter)mgl_filter; - -+ (instancetype)mgl_predicateWithFilter:(mbgl::style::Filter)filter; - -@end - -@interface NSPredicate (MGLExpressionAdditions) - -+ (instancetype)mgl_predicateWithJSONObject:(id)object; - +#pragma mark Converting JSON Expressions + +/** + Returns a predicate equivalent to the given Foundation object deserialized + from JSON data. + + The Foundation object is interpreted according to the + [Mapbox Style Specification](https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions). + See the + “[Predicates and Expressions](../predicates-and-expressions.html)” + guide for a correspondence of operators and types between the style + specification and the `NSPredicate` representation used by this SDK. + + @param object A Foundation object deserialized from JSON data, for example + using `NSJSONSerialization`. + @return An initialized predicate equivalent to `object`, suitable for use + with the `MGLVectorStyleLayer.predicate` property. + */ ++ (instancetype)predicateWithMGLJSONObject:(id)object NS_SWIFT_NAME(init(mglJSONObject:)); + +/** + An equivalent Foundation object that can be serialized as JSON. + + The Foundation object conforms to the + [Mapbox Style Specification](https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions). + See the + “[Predicates and Expressions](../predicates-and-expressions.html)” + guide for a correspondence of operators and types between the style + specification and the `NSPredicate` representation used by this SDK. + + You can use `NSJSONSerialization` to serialize the Foundation object as data to + write to a file. + */ @property (nonatomic, readonly) id mgl_jsonExpressionObject; -- (id)mgl_if:(id)firstValue, ...; - -- (id)mgl_match:(NSExpression *)firstCase, ...; - @end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSPredicate+MGLAdditions.mm b/platform/darwin/src/NSPredicate+MGLAdditions.mm index bbd324bb63..4b9a4177cb 100644 --- a/platform/darwin/src/NSPredicate+MGLAdditions.mm +++ b/platform/darwin/src/NSPredicate+MGLAdditions.mm @@ -1,210 +1,11 @@ -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "MGLValueEvaluator.h" #import "MGLStyleValue_Private.h" #include <mbgl/style/conversion/filter.hpp> -class FilterEvaluator { -public: - - NSArray *getPredicates(std::vector<mbgl::style::Filter> filters) { - NSMutableArray *predicates = [NSMutableArray arrayWithCapacity:filters.size()]; - for (auto filter : filters) { - [predicates addObject:mbgl::style::Filter::visit(filter, FilterEvaluator())]; - } - return predicates; - } - - template <typename MBGLType> - NSExpression *getValues(std::vector<MBGLType> values) { - NSMutableArray *array = [NSMutableArray arrayWithCapacity:values.size()]; - for (auto value : values) { - id constantValue = MBGLType::visit(value, ValueEvaluator()); - [array addObject:[NSExpression expressionForConstantValue:constantValue]]; - } - return [NSExpression expressionForAggregate:array]; - } - - NSString *getFeatureTypeString(mbgl::FeatureType type) { - switch (type) { - case mbgl::FeatureType::Point: - return @"Point"; - - case mbgl::FeatureType::LineString: - return @"LineString"; - - case mbgl::FeatureType::Polygon: - return @"Polygon"; - - default: - NSCAssert(NO, @"Unrecognized feature type %hhu", type); - return nil; - } - } - - NSExpression *getFeatureTypeStrings(std::vector<mbgl::FeatureType> values) { - NSMutableArray *array = [NSMutableArray arrayWithCapacity:values.size()]; - for (auto value : values) { - id typeString = getFeatureTypeString(value); - [array addObject:[NSExpression expressionForConstantValue:typeString]]; - } - return [NSExpression expressionForAggregate:array]; - } - - NSPredicate *operator()(mbgl::style::NullFilter filter) { - return nil; - } - - NSPredicate *operator()(mbgl::style::EqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K == %@", @(filter.key.c_str()), mbgl::Value::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::NotEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K != %@", @(filter.key.c_str()), mbgl::Value::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::GreaterThanFilter filter) { - return [NSPredicate predicateWithFormat:@"%K > %@", @(filter.key.c_str()), mbgl::Value::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::GreaterThanEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K >= %@", @(filter.key.c_str()), mbgl::Value::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::LessThanFilter filter) { - return [NSPredicate predicateWithFormat:@"%K < %@", @(filter.key.c_str()), mbgl::Value::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::LessThanEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K <= %@", @(filter.key.c_str()), mbgl::Value::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::InFilter filter) { - return [NSPredicate predicateWithFormat:@"%K IN %@", @(filter.key.c_str()), getValues(filter.values)]; - } - - NSPredicate *operator()(mbgl::style::NotInFilter filter) { - return [NSPredicate predicateWithFormat:@"NOT %K IN %@", @(filter.key.c_str()), getValues(filter.values)]; - } - - NSPredicate *operator()(mbgl::style::TypeEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K == %@", @"$type", getFeatureTypeString(filter.value)]; - } - - NSPredicate *operator()(mbgl::style::TypeNotEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K != %@", @"$type", getFeatureTypeString(filter.value)]; - } - - NSPredicate *operator()(mbgl::style::TypeInFilter filter) { - return [NSPredicate predicateWithFormat:@"%K IN %@", @"$type", getFeatureTypeStrings(filter.values)]; - } - - NSPredicate *operator()(mbgl::style::TypeNotInFilter filter) { - return [NSPredicate predicateWithFormat:@"NOT %K IN %@", @"$type", getFeatureTypeStrings(filter.values)]; - } - - NSPredicate *operator()(mbgl::style::IdentifierEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K == %@", @"$id", mbgl::FeatureIdentifier::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::IdentifierNotEqualsFilter filter) { - return [NSPredicate predicateWithFormat:@"%K != %@", @"$id", mbgl::FeatureIdentifier::visit(filter.value, ValueEvaluator())]; - } - - NSPredicate *operator()(mbgl::style::IdentifierInFilter filter) { - return [NSPredicate predicateWithFormat:@"%K IN %@", @"$id", getValues(filter.values)]; - } - - NSPredicate *operator()(mbgl::style::IdentifierNotInFilter filter) { - return [NSPredicate predicateWithFormat:@"NOT %K IN %@", @"$id", getValues(filter.values)]; - } - - NSPredicate *operator()(mbgl::style::AnyFilter filter) { - NSArray *subpredicates = getPredicates(filter.filters); - if (subpredicates.count) { - return [NSCompoundPredicate orPredicateWithSubpredicates:subpredicates]; - } - return [NSPredicate predicateWithValue:NO]; - } - - NSPredicate *operator()(mbgl::style::AllFilter filter) { - // Convert [all, [>=, key, lower], [<=, key, upper]] to key BETWEEN {lower, upper} - if (filter.filters.size() == 2) { - auto leftFilter = filter.filters[0]; - auto rightFilter = filter.filters[1]; - - std::string lowerKey; - std::string upperKey; - mbgl::Value lowerBound; - mbgl::Value upperBound; - if (leftFilter.is<mbgl::style::GreaterThanEqualsFilter>()) { - lowerKey = leftFilter.get<mbgl::style::GreaterThanEqualsFilter>().key; - lowerBound = leftFilter.get<mbgl::style::GreaterThanEqualsFilter>().value; - } else if (rightFilter.is<mbgl::style::GreaterThanEqualsFilter>()) { - lowerKey = rightFilter.get<mbgl::style::GreaterThanEqualsFilter>().key; - lowerBound = rightFilter.get<mbgl::style::GreaterThanEqualsFilter>().value; - } - - if (leftFilter.is<mbgl::style::LessThanEqualsFilter>()) { - upperKey = leftFilter.get<mbgl::style::LessThanEqualsFilter>().key; - upperBound = leftFilter.get<mbgl::style::LessThanEqualsFilter>().value; - } else if (rightFilter.is<mbgl::style::LessThanEqualsFilter>()) { - upperKey = rightFilter.get<mbgl::style::LessThanEqualsFilter>().key; - upperBound = rightFilter.get<mbgl::style::LessThanEqualsFilter>().value; - } - - if (!lowerBound.is<mbgl::NullValue>() && !upperBound.is<mbgl::NullValue>() - && lowerKey == upperKey) { - return [NSPredicate predicateWithFormat:@"%K BETWEEN {%@, %@}", - @(lowerKey.c_str()), - mbgl::Value::visit(lowerBound, ValueEvaluator()), - mbgl::Value::visit(upperBound, ValueEvaluator())]; - } - } - - NSArray *subpredicates = getPredicates(filter.filters); - if (subpredicates.count) { - return [NSCompoundPredicate andPredicateWithSubpredicates:subpredicates]; - } - return [NSPredicate predicateWithValue:YES]; - } - - NSPredicate *operator()(mbgl::style::NoneFilter filter) { - NSArray *subpredicates = getPredicates(filter.filters); - if (subpredicates.count > 1) { - NSCompoundPredicate *predicate = [NSCompoundPredicate orPredicateWithSubpredicates:subpredicates]; - return [NSCompoundPredicate notPredicateWithSubpredicate:predicate]; - } else if (subpredicates.count) { - return [NSCompoundPredicate notPredicateWithSubpredicate:subpredicates.firstObject]; - } else { - return [NSPredicate predicateWithValue:YES]; - } - } - - NSPredicate *operator()(mbgl::style::HasFilter filter) { - return [NSPredicate predicateWithFormat:@"%K != nil", @(filter.key.c_str())]; - } - - NSPredicate *operator()(mbgl::style::NotHasFilter filter) { - return [NSPredicate predicateWithFormat:@"%K == nil", @(filter.key.c_str())]; - } - - NSPredicate *operator()(mbgl::style::HasIdentifierFilter filter) { - return [NSPredicate predicateWithFormat:@"%K != nil", @"$id"]; - } - - NSPredicate *operator()(mbgl::style::NotHasIdentifierFilter filter) { - return [NSPredicate predicateWithFormat:@"%K == nil", @"$id"]; - } - - NSPredicate *operator()(mbgl::style::ExpressionFilter filter) { - id jsonObject = MGLJSONObjectFromMBGLExpression(*filter.expression); - return [NSPredicate mgl_predicateWithJSONObject:jsonObject]; - } -}; - -@implementation NSPredicate (MGLAdditions) +@implementation NSPredicate (MGLPrivateAdditions) - (mbgl::style::Filter)mgl_filter { @@ -224,24 +25,28 @@ public: + (instancetype)mgl_predicateWithFilter:(mbgl::style::Filter)filter { - FilterEvaluator evaluator; - return mbgl::style::Filter::visit(filter, evaluator); + if (filter.expression) { + id jsonObject = MGLJSONObjectFromMBGLExpression(**filter.expression); + return [NSPredicate predicateWithMGLJSONObject:jsonObject]; + } else { + return nil; + } } @end -@implementation NSPredicate (MGLExpressionAdditions) +@implementation NSPredicate (MGLAdditions) NSArray *MGLSubpredicatesWithJSONObjects(NSArray *objects) { NSMutableArray *subpredicates = [NSMutableArray arrayWithCapacity:objects.count]; for (id object in objects) { - NSPredicate *predicate = [NSPredicate mgl_predicateWithJSONObject:object]; + NSPredicate *predicate = [NSPredicate predicateWithMGLJSONObject:object]; [subpredicates addObject:predicate]; } return subpredicates; } -+ (instancetype)mgl_predicateWithJSONObject:(id)object { ++ (instancetype)predicateWithMGLJSONObject:(id)object { if ([object isEqual:@YES]) { return [NSPredicate predicateWithValue:YES]; } @@ -360,6 +165,10 @@ NSArray *MGLSubpredicatesWithJSONObjects(NSArray *objects) { return nil; } +@end + +@implementation NSPredicate (MGLExpressionAdditions) + - (id)mgl_if:(id)firstValue, ... { if ([self evaluateWithObject:nil]) { diff --git a/platform/darwin/src/NSPredicate+MGLPrivateAdditions.h b/platform/darwin/src/NSPredicate+MGLPrivateAdditions.h new file mode 100644 index 0000000000..1828009678 --- /dev/null +++ b/platform/darwin/src/NSPredicate+MGLPrivateAdditions.h @@ -0,0 +1,25 @@ +#import <Foundation/Foundation.h> + +#import "NSPredicate+MGLAdditions.h" + +#include <mbgl/style/filter.hpp> + +NS_ASSUME_NONNULL_BEGIN + +@interface NSPredicate (MGLPrivateAdditions) + +- (mbgl::style::Filter)mgl_filter; + ++ (instancetype)mgl_predicateWithFilter:(mbgl::style::Filter)filter; + +@end + +@interface NSPredicate (MGLExpressionAdditions) + +- (id)mgl_if:(id)firstValue, ...; + +- (id)mgl_match:(NSExpression *)firstCase, ...; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index 6d710fdcfe..e514ec22a7 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -668,6 +668,38 @@ using namespace std::string_literals; XCTAssertEqualObjects([compatibilityExpression expressionValueWithObject:@{@"number": @1.5} context:nil], @"1.5"); XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); } + { +#if TARGET_OS_IPHONE + NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'UIColor')"]; +#else + NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'NSColor')"]; +#endif + + NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); + } + { + NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('to-color', x, y, z)"]; + NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"], @[@"get", @"y"], @[@"get", @"z"]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + } + { + NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex(x), 'NSArray')"]; + NSArray *jsonExpression = @[@"to-rgba", @[@"get", @"x"]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); + } + { + NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex(%@), 'NSArray')", MGLConstantExpression(MGLColor.blueColor)]; + NSArray *jsonExpression = @[@"to-rgba", @[@"rgb", @0, @0, @255]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); + } + { + NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex('x'), 'NSArray')"]; + XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException); + } } - (void)testInterpolationExpressionObject { @@ -710,6 +742,16 @@ using namespace std::string_literals; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); } + { + NSDictionary *stops = @{}; + NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(x, 'cubic-bezier', { 0.42, 0, 0.58, 1 }, %@)", stops]; + XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException); + } + { + NSDictionary *stops = @{}; + NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, 11, %@)", stops]; + XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException); + } } - (void)testMatchExpressionObject { @@ -826,6 +868,33 @@ using namespace std::string_literals; MGLConstantExpression(@8), MGLConstantExpression(@7)]]; NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:" + arguments:@[array, MGLConstantExpression(@"FIRST")]]; + NSArray *jsonExpression = @[@"at", @0, @[ @"literal", @[@9, @8, @7]]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + } + { + NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9), + MGLConstantExpression(@8), + MGLConstantExpression(@7)]]; + NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:" + arguments:@[array, MGLConstantExpression(@"LAST")]]; + NSArray *jsonExpression = @[@"at", @[@"-", @[@"length", @[ @"literal", @[@9, @8, @7]]], @1], @[ @"literal", @[@9, @8, @7]]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + } + { + NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9), + MGLConstantExpression(@8), + MGLConstantExpression(@7)]]; + NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:" + arguments:@[array, MGLConstantExpression(@"SIZE")]]; + NSArray *jsonExpression = @[@"length", @[ @"literal", @[@9, @8, @7]]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + } + { + NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9), + MGLConstantExpression(@8), + MGLConstantExpression(@7)]]; + NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:" arguments:@[array, MGLConstantExpression(@1)]]; NSArray *jsonExpression = @[@"at", @1, @[ @"literal", @[@9, @8, @7]]]; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm index a0ddecf77e..1489fefea9 100644 --- a/platform/darwin/test/MGLGeometryTests.mm +++ b/platform/darwin/test/MGLGeometryTests.mm @@ -172,4 +172,40 @@ XCTAssertEqual(point.y, roundTrippedPoint.y); XCTAssertEqual(point.zoomLevel, roundTrippedPoint.zoomLevel); } + +- (void)testMGLLocationCoordinate2DIsValid { + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(37.936, -71.516); + XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(46.816368, 5.844469); + XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(-21.512680, 23.334703); + XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(-44.947936, -73.081313); + XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(19.333630, 203.555405); + XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(23.254696, -240.795323); + XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(91, 361); + XCTAssertFalse(MGLLocationCoordinate2DIsValid(coordinate)); + } + { + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(-91, -361); + XCTAssertFalse(MGLLocationCoordinate2DIsValid(coordinate)); + } +} + @end diff --git a/platform/darwin/test/MGLPredicateTests.mm b/platform/darwin/test/MGLPredicateTests.mm index ab4a7e2d88..4e7b3e7e4b 100644 --- a/platform/darwin/test/MGLPredicateTests.mm +++ b/platform/darwin/test/MGLPredicateTests.mm @@ -1,229 +1,15 @@ #import <XCTest/XCTest.h> #import <Mapbox/Mapbox.h> -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "MGLValueEvaluator.h" -namespace mbgl { - namespace style { - bool operator!=(const Filter &a, const Filter &b) { - return !(a == b); - } - } -} - -#define MGLAssertEqualFilters(actual, expected, ...) \ - XCTAssertTrue(actual.is<__typeof__(expected)>()); \ - if (actual.is<__typeof__(expected)>()) { \ - XCTAssertEqual(actual.get<__typeof__(expected)>(), expected, __VA_ARGS__); \ - } - @interface MGLPredicateTests : XCTestCase @end @implementation MGLPredicateTests -- (void)testPredication { - XCTAssertNil([NSPredicate mgl_predicateWithFilter:mbgl::style::NullFilter()]); - - { - mbgl::style::EqualsFilter filter = { .key = "a", .value = std::string("b") }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a = 'b'"]); - } - - { - mbgl::style::TypeEqualsFilter filter = { .value = mbgl::FeatureType::Point }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K = 'Point'", @"$type"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::TypeEqualsFilter filter = { .value = mbgl::FeatureType::LineString }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K = 'LineString'", @"$type"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::TypeEqualsFilter filter = { .value = mbgl::FeatureType::Polygon }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K = 'Polygon'", @"$type"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::IdentifierEqualsFilter filter = { .value = UINT64_C(67086180) }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K = 67086180", @"$id"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::NotHasIdentifierFilter filter; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K = nil", @"$id"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::TypeEqualsFilter filter = { .value = mbgl::FeatureType::Unknown }; - XCTAssertThrowsSpecificNamed([NSPredicate mgl_predicateWithFilter:filter], NSException, NSInternalInconsistencyException); - } - - { - mbgl::style::NotHasFilter filter = { .key = "a" }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a = nil"]); - } - - { - mbgl::style::NotEqualsFilter filter = { .key = "a", .value = std::string("b") }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a != 'b'"]); - } - - { - mbgl::style::TypeNotEqualsFilter filter = { .value = mbgl::FeatureType::Point }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K != 'Point'", @"$type"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::IdentifierNotEqualsFilter filter = { .value = UINT64_C(67086180) }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K != 67086180", @"$id"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::HasIdentifierFilter filter; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K != nil", @"$id"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::HasFilter filter = { .key = "a" }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a != nil"]); - } - - { - mbgl::style::LessThanFilter filter = { .key = "a", .value = std::string("b") }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a < 'b'"]); - } - - { - mbgl::style::LessThanEqualsFilter filter = { .key = "a", .value = std::string("b") }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a <= 'b'"]); - } - - { - mbgl::style::GreaterThanFilter filter = { .key = "a", .value = std::string("b") }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a > 'b'"]); - } - - { - mbgl::style::GreaterThanEqualsFilter filter = { .key = "a", .value = std::string("b") }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a >= 'b'"]); - } - - { - mbgl::style::AllFilter filter = { - .filters = { - mbgl::style::GreaterThanEqualsFilter { .key = "a", .value = std::string("b") }, - mbgl::style::LessThanEqualsFilter { .key = "a", .value = std::string("z") }, - }, - }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a BETWEEN {'b', 'z'}"]); - } - - { - mbgl::style::AllFilter filter = { - .filters = { - mbgl::style::LessThanEqualsFilter { .key = "a", .value = std::string("z") }, - mbgl::style::GreaterThanEqualsFilter { .key = "a", .value = std::string("b") }, - }, - }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a BETWEEN {'b', 'z'}"]); - } - - { - mbgl::style::InFilter filter = { .key = "a", .values = { std::string("b"), std::string("c") } }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter].predicateFormat, [NSPredicate predicateWithFormat:@"a IN {'b', 'c'}"].predicateFormat); - } - - { - mbgl::style::TypeInFilter filter = { .values = { mbgl::FeatureType::LineString, mbgl::FeatureType::Polygon } }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K IN {'LineString', 'Polygon'}", @"$type"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter].predicateFormat, expected.predicateFormat); - } - - { - mbgl::style::IdentifierInFilter filter = { .values = { UINT64_C(67086180), UINT64_C(3709678893), UINT64_C(3352016856), UINT64_C(4189833989) } }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"%K IN {67086180, 3709678893, 3352016856, 4189833989}", @"$id"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::NotInFilter filter = { .key = "a", .values = { std::string("b"), std::string("c") } }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter].predicateFormat, [NSPredicate predicateWithFormat:@"NOT a IN {'b', 'c'}"].predicateFormat); - } - - { - mbgl::style::TypeNotInFilter filter = { .values = { mbgl::FeatureType::LineString, mbgl::FeatureType::Polygon } }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"NOT %K IN {'LineString', 'Polygon'}", @"$type"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter].predicateFormat, expected.predicateFormat); - } - - { - mbgl::style::IdentifierNotInFilter filter = { .values = { UINT64_C(67086180), UINT64_C(3709678893), UINT64_C(3352016856), UINT64_C(4189833989) } }; - NSPredicate *expected = [NSPredicate predicateWithFormat:@"NOT %K IN {67086180, 3709678893, 3352016856, 4189833989}", @"$id"]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], expected); - } - - { - mbgl::style::AllFilter filter; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithValue:YES]); - } - - { - mbgl::style::AllFilter filter = { - .filters = { - mbgl::style::EqualsFilter { .key = "a", .value = std::string("b") }, - mbgl::style::EqualsFilter { .key = "c", .value = std::string("d") }, - }, - }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a == 'b' AND c == 'd'"]); - } - - { - mbgl::style::AnyFilter filter; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithValue:NO]); - } - - { - mbgl::style::AnyFilter filter = { - .filters = { - mbgl::style::EqualsFilter { .key = "a", .value = std::string("b") }, - mbgl::style::EqualsFilter { .key = "c", .value = std::string("d") }, - }, - }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"a == 'b' OR c == 'd'"]); - } - - { - mbgl::style::NoneFilter filter; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithValue:YES]); - } - - { - mbgl::style::NoneFilter filter = { - .filters = { - mbgl::style::EqualsFilter { .key = "a", .value = std::string("b") }, - mbgl::style::EqualsFilter { .key = "c", .value = std::string("d") }, - }, - }; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithFilter:filter], [NSPredicate predicateWithFormat:@"NOT(a == 'b' OR c == 'd')"]); - } -} - - (void)testUnsupportedFilterPredicates { - XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"1 == 2"].mgl_filter, NSException, NSInvalidArgumentException); - XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"1 == 1"].mgl_filter, NSException, NSInvalidArgumentException); - XCTAssertThrowsSpecificNamed([NSPredicate predicateWithValue:YES].mgl_filter, NSException, NSInvalidArgumentException); - XCTAssertThrowsSpecificNamed([NSPredicate predicateWithValue:NO].mgl_filter, NSException, NSInvalidArgumentException); XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a BEGINSWITH 'L'"].mgl_filter, NSException, NSInvalidArgumentException); XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a ENDSWITH 'itude'"].mgl_filter, NSException, NSInvalidArgumentException); XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a LIKE 'glob?trotter'"].mgl_filter, NSException, NSInvalidArgumentException); @@ -242,48 +28,48 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"x == YES"]; NSArray *jsonExpression = @[@"==", @[@"get", @"x"], @YES]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') < 5"]; NSArray *jsonExpression = @[@"<", @[@"to-number", @[@"get", @"x"]], @5]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') > 5"]; NSArray *jsonExpression = @[@">", @[@"to-number", @[@"get", @"x"]], @5]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') <= 5"]; NSArray *jsonExpression = @[@"<=", @[@"to-number", @[@"get", @"x"]], @5]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') >= 5"]; NSArray *jsonExpression = @[@">=", @[@"to-number", @[@"get", @"x"]], @5]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSString') > 'value'"]; NSArray *jsonExpression = @[@">", @[@"to-string", @[@"get", @"x"]], @"value"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { @@ -360,48 +146,48 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') < 'b'"]; NSArray *jsonExpression = @[@"<", @[@"to-string", @[@"get", @"a"]], @"b"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') <= 'b'"]; NSArray *jsonExpression = @[@"<=", @[@"to-string", @[@"get", @"a"]], @"b"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') > 'b'"]; NSArray *jsonExpression = @[@">", @[@"to-string", @[@"get", @"a"]], @"b"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') >= 'b'"]; NSArray *jsonExpression = @[@">=", @[@"to-string", @[@"get", @"a"]], @"b"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') BETWEEN {'b', 'z'}"]; NSArray *jsonExpression =@[@"all", @[@"<=", @"b", @[@"to-string", @[@"get", @"a"]]], @[@"<=", @[@"to-string", @[@"get", @"a"]], @"z"]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits]; NSArray *jsonExpression = @[@"all", @[@">=", @[@"to-number", @[@"get", @"x"]], @10], @[@"<=", @[@"to-number", @[@"get", @"x"]], @100]]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { @@ -409,24 +195,24 @@ namespace mbgl { NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:expected], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:expected] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:expected], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:expected] mustRoundTrip:NO]; } { NSArray *expected = @[@"all", @[@"<=", @10, @[@"to-number", @[@"get", @"x"]]], @[@">=", @100, @[@"to-number", @[@"get", @"x"]]]]; NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:expected], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:expected] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:expected], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:expected] mustRoundTrip:NO]; } { NSArray *expected = @[@"all", @[@">=", @[@"to-number", @[@"get", @"x"]], @10], @[@">=", @100, @[@"to-number", @[@"get", @"x"]]]]; NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits]; - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:expected], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:expected] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:expected], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:expected] mustRoundTrip:NO]; } { @@ -434,7 +220,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier IN { 6, 5, 4, 3}"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(CAST($featureIdentifier, 'NSNumber'), 3, YES, 4, YES, 5, YES, 6, YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -443,7 +229,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT x IN { 6, 5, 4, 3}"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"NOT MGL_MATCH(CAST(x, 'NSNumber'), 3, YES, 4, YES, 5, YES, 6, YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -452,7 +238,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a IN { 'b', 'c' }"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(CAST(a, 'NSString'), 'b', YES, 'c', YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -461,7 +247,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ IN %@", [NSExpression expressionForVariable:@"geometryType"], @[@"LineString", @"Polygon"]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH($geometryType, 'LineString', YES, 'Polygon', YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -470,7 +256,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"{ 6, 5, 4, 3} CONTAINS x"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(CAST(x, 'NSNumber'), 3, YES, 4, YES, 5, YES, 6, YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -479,7 +265,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ CONTAINS %@", @[@"LineString", @"Polygon"], [NSExpression expressionForVariable:@"geometryType"]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH($geometryType, 'LineString', YES, 'Polygon', YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -488,7 +274,7 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"{ 6, 5, 4, 3} CONTAINS $featureIdentifier"]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected); NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(CAST($featureIdentifier, 'NSNumber'), 3, YES, 4, YES, 5, YES, 6, YES, NO) == YES"]; - auto forwardFilter = [NSPredicate mgl_predicateWithJSONObject:expected].mgl_filter; + auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter; NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter]; XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter); } @@ -499,32 +285,32 @@ namespace mbgl { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a == 'b' AND c == 'd'"]; NSArray *jsonExpression = @[@"all", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a == 'b' OR c == 'd'"]; NSArray *jsonExpression = @[@"any", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT(a == 'b' AND c == 'd')"]; NSArray *jsonExpression = @[@"!", @[@"all", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT(a == 'b' OR c == 'd')"]; NSArray *jsonExpression = @[@"!", @[@"any", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]]]; XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSPredicate mgl_predicateWithJSONObject:jsonExpression], predicate); - [self testSymmetryWithPredicate:[NSPredicate mgl_predicateWithJSONObject:jsonExpression] + XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate); + [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression] mustRoundTrip:NO]; } { diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm index 6048f39ea3..32243c1bec 100644 --- a/platform/darwin/test/MGLStyleTests.mm +++ b/platform/darwin/test/MGLStyleTests.mm @@ -448,6 +448,10 @@ XCTAssertNil([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences]); } { + NSArray *preferences = @[@"en", @"fr", @"el"]; + XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"en"); + } + { NSArray *preferences = @[@"tlh"]; XCTAssertNil([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences]); } diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 3988419265..362269b8e4 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -7,6 +7,8 @@ #include <mbgl/style/image.hpp> #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/fill_extrusion_layer.hpp> +#include <mbgl/style/expression/compound_expression.hpp> +#include <mbgl/style/expression/literal.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/util/platform.hpp> #include <mbgl/util/string.hpp> @@ -619,6 +621,9 @@ void GLFWView::onDidFinishLoadingStyle() { } void GLFWView::toggle3DExtrusions(bool visible) { + using namespace mbgl::style; + using namespace mbgl::style::expression; + show3DExtrusions = visible; // Satellite-only style does not contain building extrusions data. @@ -634,7 +639,9 @@ void GLFWView::toggle3DExtrusions(bool visible) { auto extrusionLayer = std::make_unique<mbgl::style::FillExtrusionLayer>("3d-buildings", "composite"); extrusionLayer->setSourceLayer("building"); extrusionLayer->setMinZoom(15.0f); - extrusionLayer->setFilter(mbgl::style::EqualsFilter { "extrude", { std::string("true") } }); + + ParsingContext parsingContext; + extrusionLayer->setFilter(Filter(createCompoundExpression("filter-==", createLiteral("extrude"), createLiteral("true"), parsingContext))); auto colorFn = mbgl::style::SourceFunction<mbgl::Color> { "height", mbgl::style::ExponentialStops<mbgl::Color> { diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e87c8d6ad1..f70330300b 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -8,9 +8,33 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * The minimum deployment target for this SDK is now iOS 9.0. ([#11776](https://github.com/mapbox/mapbox-gl-native/pull/11776)) +## 4.0.1 - May 14, 2018 + +### Packaging + +* Re-added support for 32-bit simulators (i386) to work around an issue in CocoaPods. ([#11891](https://github.com/mapbox/mapbox-gl-native/pull/11891)) +* Added a Korean localization. ([#11792](https://github.com/mapbox/mapbox-gl-native/pull/11792)) + ### Style layers -* Deprecated `+[NSExpression featurePropertiesVariableExpression]` use `+[NSExpression featureAttributesVariableExpression]` instead. ([#11748](https://github.com/mapbox/mapbox-gl-native/pull/11748)) +* Deprecated `+[NSExpression featurePropertiesVariableExpression]`; use `+[NSExpression featureAttributesVariableExpression]` instead. ([#11748](https://github.com/mapbox/mapbox-gl-native/pull/11748)) +* Added an `-[NSPredicate(MGLAdditions) predicateWithMGLJSONObject:]` method and `NSPredicate.mgl_jsonExpressionObject` property. ([#11810](https://github.com/mapbox/mapbox-gl-native/pull/11810)) +* Added `FIRST`, `LAST`, and `SIZE` symbolic array subscripting support to expressions. ([#11770](https://github.com/mapbox/mapbox-gl-native/pull/11770)) +* Inside an expression, casting `nil` to a string turns it into the empty string instead of the string `"null"`. ([#11904](https://github.com/mapbox/mapbox-gl-native/pull/11904)) +* Fixed an issue where certain colors were being misrepresented in `NSExpression` obtained from `MGLStyleLayer` getters. ([#11725](https://github.com/mapbox/mapbox-gl-native/pull/11725)) + +### Annotations + +* Fixed an issue where selecting an onscreen annotation could move the map unintentionally. ([#11731](https://github.com/mapbox/mapbox-gl-native/pull/11731)) +* Fixed an issue where annotation views could become distorted if `rotatesToMatchCamera` was enabled. ([#11817](https://github.com/mapbox/mapbox-gl-native/pull/11817)) +* Fixed `MGLAnnotationView.rotatesToMatchCamera` overriding other transforms that might be applied to annotation views that had this property enabled. ([#11842](https://github.com/mapbox/mapbox-gl-native/pull/11842)) +* Fixed an issue where an `MGLOverlay` object straddling the antimeridian had an empty `MGLOverlay.overlayBounds` value. ([#11783](https://github.com/mapbox/mapbox-gl-native/pull/11783)) + +### Other changes + +* If English is the first language listed in the user’s Preferred Languages setting, `-[MGLStyle localizeLabelsIntoLocale:]` no longer prioritizes other languages over English. ([#11907](https://github.com/mapbox/mapbox-gl-native/pull/11907)) +* Fixed an issue where `-[MGLMapView metersPerPixelAtLatitude:]` was removed, but not marked as unavailable. ([#11765](https://github.com/mapbox/mapbox-gl-native/pull/11765)) +* Reduced per-frame render CPU time. ([#11811](https://github.com/mapbox/mapbox-gl-native/issues/11811)) ## 3.7.8 - May 7, 2018 diff --git a/platform/ios/INSTALL.md b/platform/ios/INSTALL.md index 3c79e4dcf8..bfa7bf7ceb 100644 --- a/platform/ios/INSTALL.md +++ b/platform/ios/INSTALL.md @@ -11,7 +11,7 @@ The Mapbox Maps SDK for iOS is intended to run on iOS 9.0 and above on the follo * iPod touch 5th generation and above -Note that 32-bit simulators (such as the iPhone 5 or iPad 2) are not supported. +Note that debugging in 32-bit simulators (such as the iPhone 5 or iPad 2) is only partially supported. The Mapbox Maps SDK for iOS requires: diff --git a/platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m b/platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m new file mode 100644 index 0000000000..015a58d2d2 --- /dev/null +++ b/platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m @@ -0,0 +1,61 @@ +#import "MGLMapViewIntegrationTest.h" + +@interface MGLStyleLayerIntegrationTests : MGLMapViewIntegrationTest +@end + +@implementation MGLStyleLayerIntegrationTests + +- (MGLCircleStyleLayer*)setupCircleStyleLayer { + // Adapted from https://www.mapbox.com/ios-sdk/examples/dds-circle-layer/ + + // "mapbox://examples.2uf7qges" is a map ID referencing a tileset. For more + // more information, see mapbox.com/help/define-map-id/ + MGLSource *source = [[MGLVectorTileSource alloc] initWithIdentifier:@"trees" configurationURL:[NSURL URLWithString:@"mapbox://examples.2uf7qges"]]; + [self.mapView.style addSource:source]; + + MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier: @"tree-style" source:source]; + + // The source name from the source's TileJSON metadata: mapbox.com/api-documentation/#retrieve-tilejson-metadata + layer.sourceLayerIdentifier = @"yoshino-trees-a0puw5"; + + return layer; +} + +- (void)testForInterpolatingExpressionRenderCrashWithEmptyStops { + // Tests: https://github.com/mapbox/mapbox-gl-native/issues/9539 + // Adapted from https://www.mapbox.com/ios-sdk/examples/dds-circle-layer/ + self.mapView.centerCoordinate = CLLocationCoordinate2DMake(38.897,-77.039); + self.mapView.zoomLevel = 10.5; + + MGLCircleStyleLayer *layer = [self setupCircleStyleLayer]; + + NSExpression *interpExpression = [NSExpression mgl_expressionForInterpolatingExpression:NSExpression.zoomLevelVariableExpression + withCurveType:MGLExpressionInterpolationModeLinear + parameters:nil + stops:[NSExpression expressionForConstantValue:@{}]]; + + XCTAssertThrowsSpecificNamed((layer.circleColor = interpExpression), NSException, NSInvalidArgumentException); + + [self.mapView.style addLayer:layer]; + [self waitForMapViewToBeRenderedWithTimeout:1.0]; +} + +- (void)testForSteppingExpressionRenderCrashWithEmptyStops { + // Tests: https://github.com/mapbox/mapbox-gl-native/issues/9539 + // Adapted from https://www.mapbox.com/ios-sdk/examples/dds-circle-layer/ + self.mapView.centerCoordinate = CLLocationCoordinate2DMake(38.897,-77.039); + self.mapView.zoomLevel = 10.5; + + MGLCircleStyleLayer *layer = [self setupCircleStyleLayer]; + + NSExpression *steppingExpression = [NSExpression mgl_expressionForSteppingExpression:NSExpression.zoomLevelVariableExpression + fromExpression:[NSExpression expressionForConstantValue:[UIColor greenColor]] + stops:[NSExpression expressionForConstantValue:@{}]]; + + XCTAssertThrowsSpecificNamed((layer.circleColor = steppingExpression), NSException, NSInvalidArgumentException); + + [self.mapView.style addLayer:layer]; + [self waitForMapViewToBeRenderedWithTimeout:1.0]; +} + +@end diff --git a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec index e07178311b..77ff15ab42 100644 --- a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec +++ b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '4.0.0' + version = '4.0.1' m.name = 'Mapbox-iOS-SDK-nightly-dynamic' m.version = "#{version}-nightly" diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index fbf65f0b24..7db87e1f08 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '4.0.0' + version = '4.0.1' m.name = 'Mapbox-iOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index 5a8e913dd9..67e1665853 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '4.0.0' + version = '4.0.1' m.name = 'Mapbox-iOS-SDK' m.version = version diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 80163c7d40..0cb6c73d31 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -5,6 +5,7 @@ #import "MBXOfflinePacksTableViewController.h" #import "MBXAnnotationView.h" #import "MBXUserLocationAnnotationView.h" +#import "LimeGreenStyleLayer.h" #import "MBXEmbeddedMapViewController.h" #import <Mapbox/Mapbox.h> @@ -82,6 +83,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) { MBXSettingsRuntimeStylingRasterTileSource, MBXSettingsRuntimeStylingImageSource, MBXSettingsRuntimeStylingRouteLine, + MBXSettingsRuntimeStylingAddLimeGreenTriangleLayer, MBXSettingsRuntimeStylingDDSPolygon, MBXSettingsRuntimeStylingCustomLatLonGrid, }; @@ -366,6 +368,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @"Style Raster Tile Source", @"Style Image Source", @"Add Route Line", + @"Add Lime Green Triangle Layer", @"Dynamically Style Polygon", @"Add Custom Lat/Lon Grid", ]]; @@ -554,6 +557,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsRuntimeStylingRouteLine: [self styleRouteLine]; break; + case MBXSettingsRuntimeStylingAddLimeGreenTriangleLayer: + [self styleAddLimeGreenTriangleLayer]; + break; case MBXSettingsRuntimeStylingDDSPolygon: [self stylePolygonWithDDS]; break; @@ -1438,6 +1444,12 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [self.mapView.style addLayer:routeLayer]; } +- (void)styleAddLimeGreenTriangleLayer +{ + LimeGreenStyleLayer *layer = [[LimeGreenStyleLayer alloc] initWithIdentifier:@"mbx-custom"]; + [self.mapView.style addLayer:layer]; +} + - (void)stylePolygonWithDDS { CLLocationCoordinate2D leftCoords[] = { {37.73081027834234, -122.49412536621094}, diff --git a/platform/ios/app/ko.lproj/Localizable.strings b/platform/ios/app/ko.lproj/Localizable.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/platform/ios/app/ko.lproj/Localizable.strings diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index b3beea8540..d4fb17eb6a 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -280,7 +280,7 @@ Each property representing a layout or paint attribute is set to an but you create the former using a very different syntax. `NSExpression`’s format string syntax is reminiscent of a spreadsheet formula or an expression in a database query. See the -“[Predicates and Expressions](Predicates and Expressions.md)” guide for an +“[Predicates and Expressions](predicates-and-expressions.html)” guide for an overview of the expression support in this SDK. This SDK no longer supports style functions; use expressions instead. @@ -325,7 +325,7 @@ In style specification | Method, function, or predicate type | Format string syn `number` | | `string` | | `to-boolean` | `boolValue` | -`to-color` | | +`to-color` | | `CAST(var, 'UIColor')` `to-number` | `mgl_numberWithFallbackValues:` | `CAST(zipCode, 'NSNumber')` `to-string` | `stringValue` | `CAST(ele, 'NSString')` `typeof` | | @@ -357,7 +357,7 @@ In style specification | Method, function, or predicate type | Format string syn `upcase` | `uppercase:` | `uppercase('Elysian Fields')` `rgb` | `+[UIColor colorWithRed:green:blue:alpha:]` | `rgba` | `+[UIColor colorWithRed:green:blue:alpha:]` | -`to-rgba` | | +`to-rgba` | | `CAST(noindex(var), 'NSArray')` `-` | `from:subtract:` | `2 - 1` `*` | `multiply:by:` | `1 * 2` `/` | `divide:by:` | `1 / 2` @@ -412,5 +412,5 @@ In style JSON | In the format string `["any", f0, …, fn]` | `p0 OR … OR pn` `["none", f0, …, fn]` | `NOT (p0 OR … OR pn)` -See the “[Predicates and Expressions](Predicates and Expressions.md)” guide for +See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for a full description of the supported operators and operand types. diff --git a/platform/ios/framework/Settings.bundle/ko.lproj/Root.strings b/platform/ios/framework/Settings.bundle/ko.lproj/Root.strings new file mode 100644 index 0000000000..1fc9f9ce51 --- /dev/null +++ b/platform/ios/framework/Settings.bundle/ko.lproj/Root.strings @@ -0,0 +1,3 @@ +"TELEMETRY_GROUP_TITLE" = "개인 정보 설정"; +"TELEMETRY_SWITCH_TITLE" = "맵박스 텔레메트리"; +"TELEMETRY_GROUP_FOOTER" = "이 설정은 어플리케이션이 익명화된 장소와 사용데이터를 맵박스와 공유하는것을 허용합니다."; diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index cb5a5587a2..78cfff965c 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -36,6 +36,8 @@ 1F7454971ECD450D00021D39 /* MGLLight_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F7454941ECD450D00021D39 /* MGLLight_Private.h */; }; 1F7454A91ED08AB400021D39 /* MGLLightTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F7454A61ED08AB400021D39 /* MGLLightTest.mm */; }; 1F95931D1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */; }; + 1FC4817D2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FC4817B2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h */; }; + 1FC4817F2098CD80000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FC4817B2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h */; }; 30E578171DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */; }; 30E578181DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */; }; 30E578191DAA855E0050F07E /* UIImage+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 30E578121DAA7D690050F07E /* UIImage+MGLAdditions.mm */; }; @@ -53,7 +55,6 @@ 3510FFEC1D6D9C7A00F413B2 /* NSComparisonPredicate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3510FFE91D6D9C7A00F413B2 /* NSComparisonPredicate+MGLAdditions.mm */; }; 3510FFED1D6D9C7A00F413B2 /* NSComparisonPredicate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3510FFE91D6D9C7A00F413B2 /* NSComparisonPredicate+MGLAdditions.mm */; }; 3510FFF01D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3510FFEE1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 3510FFF11D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3510FFEE1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3510FFF21D6D9D8C00F413B2 /* NSExpression+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3510FFEF1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.mm */; }; 3510FFF31D6D9D8C00F413B2 /* NSExpression+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3510FFEF1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.mm */; }; 3510FFF91D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3510FFF71D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.h */; }; @@ -131,8 +132,8 @@ 357FE2E01E02D2B20068B753 /* NSCoder+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 357FE2DC1E02D2B20068B753 /* NSCoder+MGLAdditions.mm */; }; 3598544D1E1D38AA00B29F84 /* MGLDistanceFormatterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3598544C1E1D38AA00B29F84 /* MGLDistanceFormatterTests.m */; }; 359F57461D2FDDA6005217F1 /* MGLUserLocationAnnotationView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 359F57451D2FDBD5005217F1 /* MGLUserLocationAnnotationView_Private.h */; }; - 35B82BF81D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35B82BF61D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h */; }; - 35B82BF91D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35B82BF61D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h */; }; + 35B82BF81D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35B82BF61D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 35B82BF91D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35B82BF61D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 35B82BFA1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35B82BF71D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm */; }; 35B82BFB1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35B82BF71D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm */; }; 35B8E08C1D6C8B5100E768D2 /* MGLPredicateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35B8E08B1D6C8B5100E768D2 /* MGLPredicateTests.mm */; }; @@ -159,6 +160,9 @@ 35E79F201D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; }; 35E79F211D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; }; 36F1153D1D46080700878E1A /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 36F1153B1D46080700878E1A /* libmbgl-core.a */; }; + 3E6465D62065767A00685536 /* LimeGreenStyleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E6465D42065767A00685536 /* LimeGreenStyleLayer.m */; }; + 3E8770612074297100B7E842 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; }; + 3E8E82F120744B4100E7BE97 /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E8E82F020744B4100E7BE97 /* libmbgl-core.a */; }; 3EA93369F61CF70AFA50465D /* MGLRendererConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3EA931BC4F087E166D538F21 /* MGLRendererConfiguration.mm */; }; 3EA934623AD0000B7D99C3FB /* MGLRendererConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA9337830C7738BF7F5493C /* MGLRendererConfiguration.h */; }; 3EA9363147E77DD29FA06063 /* MGLRendererConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA9337830C7738BF7F5493C /* MGLRendererConfiguration.h */; }; @@ -267,9 +271,6 @@ 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; }; - 5549A0381EF1D86B00073113 /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5549A0371EF1D86B00073113 /* libmbgl-core.a */; }; - 5549A0391EF2877100073113 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; }; - 5549A03A1EF2877500073113 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; }; 556660CA1E1BF3A900E2C41B /* MGLFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 556660C91E1BF3A900E2C41B /* MGLFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 556660D81E1D085500E2C41B /* MGLVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 556660D71E1D085500E2C41B /* MGLVersionNumber.m */; }; 556660DB1E1D8E8D00E2C41B /* MGLFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 556660C91E1BF3A900E2C41B /* MGLFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -307,6 +308,7 @@ 9620BB391E69FE1700705A1D /* MGLSDKUpdateChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 9620BB361E69FE1700705A1D /* MGLSDKUpdateChecker.h */; }; 9620BB3A1E69FE1700705A1D /* MGLSDKUpdateChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */; }; 9620BB3B1E69FE1700705A1D /* MGLSDKUpdateChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */; }; + 9621F2502091020E005B3800 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3510FFEE1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9654C1261FFC1AB900DB6A19 /* MGLPolyline_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C1251FFC1AB900DB6A19 /* MGLPolyline_Private.h */; }; 9654C1291FFC1CCD00DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C1271FFC1CC000DB6A19 /* MGLPolygon_Private.h */; }; 9658C155204761FC00D8A674 /* MGLMapViewScaleBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9658C154204761FC00D8A674 /* MGLMapViewScaleBarTests.m */; }; @@ -362,6 +364,7 @@ AC518E03201BB56000EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; }; AC518E04201BB56100EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; }; CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; }; + CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; }; CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; }; @@ -510,8 +513,6 @@ DA8963381CC549A100684375 /* sprites in Resources */ = {isa = PBXBuildFile; fileRef = DA8963341CC549A100684375 /* sprites */; }; DA8963391CC549A100684375 /* styles in Resources */ = {isa = PBXBuildFile; fileRef = DA8963351CC549A100684375 /* styles */; }; DA89633A1CC549A100684375 /* tiles in Resources */ = {isa = PBXBuildFile; fileRef = DA8963361CC549A100684375 /* tiles */; }; - DA9EA82B201C0C0C00F9874D /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DA9EA82A201C0C0B00F9874D /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - DA9EA82C201C0C0C00F9874D /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DA9EA82A201C0C0B00F9874D /* NSExpression+MGLAdditions.h */; }; DAA32CC31E4C6B65006F8D24 /* MGLDistanceFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3557F7AF1E1D27D300CCA5E6 /* MGLDistanceFormatter.m */; }; DAA4E4081CBB6C9500178DFB /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; }; DAA4E4091CBB6C9500178DFB /* Mapbox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -754,6 +755,7 @@ 1F7454941ECD450D00021D39 /* MGLLight_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLLight_Private.h; sourceTree = "<group>"; }; 1F7454A61ED08AB400021D39 /* MGLLightTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLLightTest.mm; path = ../../darwin/test/MGLLightTest.mm; sourceTree = "<group>"; }; 1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLNSDateAdditionsTests.mm; path = ../../darwin/test/MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; }; + 1FC4817B2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSPredicate+MGLPrivateAdditions.h"; sourceTree = "<group>"; }; 20DABE861DF78148007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Foundation.strings"; sourceTree = "<group>"; }; 20DABE881DF78148007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; }; 20DABE8A1DF78149007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Root.strings"; sourceTree = "<group>"; }; @@ -830,6 +832,9 @@ 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleLayer_Private.h; sourceTree = "<group>"; }; 36F1153B1D46080700878E1A /* libmbgl-core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-core.a"; path = "build/Debug-iphoneos/libmbgl-core.a"; sourceTree = "<group>"; }; 36F1153C1D46080700878E1A /* libmbgl-platform-ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-platform-ios.a"; path = "build/Debug-iphoneos/libmbgl-platform-ios.a"; sourceTree = "<group>"; }; + 3E6465D42065767A00685536 /* LimeGreenStyleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LimeGreenStyleLayer.m; path = ../../darwin/app/LimeGreenStyleLayer.m; sourceTree = "<group>"; }; + 3E6465D52065767A00685536 /* LimeGreenStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LimeGreenStyleLayer.h; path = ../../darwin/app/LimeGreenStyleLayer.h; sourceTree = "<group>"; }; + 3E8E82F020744B4100E7BE97 /* libmbgl-core.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-core.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3EA931BC4F087E166D538F21 /* MGLRendererConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLRendererConfiguration.mm; sourceTree = "<group>"; }; 3EA9337830C7738BF7F5493C /* MGLRendererConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLRendererConfiguration.h; sourceTree = "<group>"; }; 400532FF1DB0862B0069F638 /* NSArray+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MGLAdditions.h"; sourceTree = "<group>"; }; @@ -993,6 +998,7 @@ AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLTelemetryConfig.m; sourceTree = "<group>"; }; CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewIntegrationTest.m; sourceTree = "<group>"; }; CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = "<group>"; }; + CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = "<group>"; }; CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = "<group>"; }; DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; }; DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; }; @@ -1186,7 +1192,6 @@ DA9C012C1E4C7ADB00C4742A /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = "pt-BR"; path = "pt-BR.lproj/Foundation.stringsdict"; sourceTree = "<group>"; }; DA9C012D1E4C7B1F00C4742A /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; }; DA9C012E1E4C7B6100C4742A /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Root.strings"; sourceTree = "<group>"; }; - DA9EA82A201C0C0B00F9874D /* NSExpression+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSExpression+MGLAdditions.h"; sourceTree = "<group>"; }; DAA32CA11E4C44DB006F8D24 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = de; path = de.lproj/Foundation.stringsdict; sourceTree = "<group>"; }; DAA32CA21E4C44DD006F8D24 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = de; path = de.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; DAA32CA31E4C44F1006F8D24 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Foundation.strings; sourceTree = "<group>"; }; @@ -1257,6 +1262,12 @@ DAFBD0D21E3FA7A1000CD6BF /* zh-Hant */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Foundation.strings"; sourceTree = "<group>"; }; DAFBD0D31E3FA7A1000CD6BF /* zh-Hant */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; }; DAFBD0D41E3FA7A2000CD6BF /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Root.strings"; sourceTree = "<group>"; }; + DAFEB3742093AE3700A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; }; + DAFEB3752093AE4800A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Foundation.strings; sourceTree = "<group>"; }; + DAFEB3762093AE6800A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ko; path = ko.lproj/Foundation.stringsdict; sourceTree = "<group>"; }; + DAFEB3772093AE7900A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; }; + DAFEB3782093AE9200A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ko; path = ko.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; + DAFEB3792093AEA100A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Root.strings; sourceTree = "<group>"; }; DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfiguration.m; sourceTree = "<group>"; }; DD0902A41DB18F1B00C5BDCE /* MGLNetworkConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLNetworkConfiguration.h; sourceTree = "<group>"; }; DD4823721D94AE6C00EB71B7 /* fill_filter_style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = fill_filter_style.json; sourceTree = "<group>"; }; @@ -1292,7 +1303,6 @@ buildActionMask = 2147483647; files = ( DA8847D91CBAF91600AB86E3 /* Mapbox.framework in Frameworks */, - 5549A0391EF2877100073113 /* OpenGLES.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1300,7 +1310,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5549A0381EF1D86B00073113 /* libmbgl-core.a in Frameworks */, + 3E8E82F120744B4100E7BE97 /* libmbgl-core.a in Frameworks */, DA2E88561CC036F400F24E7B /* Mapbox.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1331,7 +1341,7 @@ buildActionMask = 2147483647; files = ( DAA4E4081CBB6C9500178DFB /* Mapbox.framework in Frameworks */, - 5549A03A1EF2877500073113 /* OpenGLES.framework in Frameworks */, + 3E8770612074297100B7E842 /* OpenGLES.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1345,6 +1355,7 @@ 16376B0B1FFD9DAF0000563E /* Info.plist */, CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */, CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */, + CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */, ); path = "Integration Tests"; sourceTree = "<group>"; @@ -1724,6 +1735,8 @@ DA1DC94C1CB6C1C2006E619F /* Demo App */ = { isa = PBXGroup; children = ( + 3E6465D52065767A00685536 /* LimeGreenStyleLayer.h */, + 3E6465D42065767A00685536 /* LimeGreenStyleLayer.m */, DA1DC9501CB6C1C2006E619F /* MBXAppDelegate.h */, DA1DC9981CB6E054006E619F /* MBXAppDelegate.m */, 40FDA7691CCAAA6800442548 /* MBXAnnotationView.h */, @@ -1763,6 +1776,7 @@ DA1DC9921CB6DF24006E619F /* Frameworks */ = { isa = PBXGroup; children = ( + 3E8E82F020744B4100E7BE97 /* libmbgl-core.a */, 55D120AD1F791018004B6D81 /* libmbgl-loop-darwin.a */, 55D120AB1F791015004B6D81 /* libmbgl-filesource.a */, 55D120A91F79100C004B6D81 /* libmbgl-filesource.a */, @@ -2096,11 +2110,11 @@ 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */, DA8848141CBAFA6200AB86E3 /* NSException+MGLAdditions.h */, 3510FFEE1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h */, - DA9EA82A201C0C0B00F9874D /* NSExpression+MGLAdditions.h */, DAC25FCB200FD83E009BE98E /* NSExpression+MGLPrivateAdditions.h */, 3510FFEF1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.mm */, 35B82BF61D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h */, 35B82BF71D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm */, + 1FC4817B2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h */, DA8848151CBAFA6200AB86E3 /* NSProcessInfo+MGLAdditions.h */, DA8848161CBAFA6200AB86E3 /* NSProcessInfo+MGLAdditions.m */, DA8848171CBAFA6200AB86E3 /* NSString+MGLAdditions.h */, @@ -2189,6 +2203,7 @@ DA88483B1CBAFB8500AB86E3 /* MGLCalloutView.h in Headers */, 35E0CFE61D3E501500188327 /* MGLStyle_Private.h in Headers */, 3510FFF01D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, + 1FC4817D2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */, 353AFA141D65AB17005A69F4 /* NSDate+MGLAdditions.h in Headers */, DA8848531CBAFB9800AB86E3 /* MGLCompactCalloutView.h in Headers */, DA8847FB1CBAFA5100AB86E3 /* MGLShape.h in Headers */, @@ -2286,7 +2301,6 @@ DA8848841CBB033F00AB86E3 /* FABAttributes.h in Headers */, DA8847FD1CBAFA5100AB86E3 /* MGLTilePyramidOfflineRegion.h in Headers */, DA88482F1CBAFA6200AB86E3 /* NSProcessInfo+MGLAdditions.h in Headers */, - DA9EA82B201C0C0C00F9874D /* NSExpression+MGLAdditions.h in Headers */, DA8848601CBAFC2E00AB86E3 /* Mapbox.h in Headers */, DAF0D8101DFE0EA000B28378 /* MGLRasterTileSource_Private.h in Headers */, 350098BB1D480108004B2AF0 /* MGLVectorTileSource.h in Headers */, @@ -2316,7 +2330,6 @@ DABFB8641CBE99E500D62B32 /* MGLOfflineStorage.h in Headers */, 96E516E32000552A00A02306 /* MGLAccountManager_Private.h in Headers */, 96E5170420005A6B00A02306 /* SMCalloutView.h in Headers */, - DA9EA82C201C0C0C00F9874D /* NSExpression+MGLAdditions.h in Headers */, 96036A02200565C700510F3D /* NSOrthography+MGLAdditions.h in Headers */, DAD165791CF4CDFF001FF4B9 /* MGLShapeCollection.h in Headers */, 4049C29E1DB6CD6C00B3F799 /* MGLPointCollection.h in Headers */, @@ -2326,7 +2339,6 @@ 96E516F6200059EC00A02306 /* MGLRendererFrontend.h in Headers */, 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */, DABFB8611CBE99E500D62B32 /* MGLMultiPoint.h in Headers */, - 3510FFF11D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, 35D3A1E71E9BE7EC002B38EE /* MGLScaleBar.h in Headers */, 96E516EF2000594F00A02306 /* NSArray+MGLAdditions.h in Headers */, 96E516F12000596800A02306 /* NSString+MGLAdditions.h in Headers */, @@ -2371,6 +2383,7 @@ 96E516F920005A3500A02306 /* MGLFaux3DUserLocationAnnotationView.h in Headers */, 96E516F22000596D00A02306 /* NSException+MGLAdditions.h in Headers */, 96E516EC2000560B00A02306 /* MGLUserLocationAnnotationView_Private.h in Headers */, + 1FC4817F2098CD80000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */, DABFB8671CBE99E500D62B32 /* MGLPolygon.h in Headers */, 404C26E81D89C55D000AA13D /* MGLTileSource_Private.h in Headers */, 1F7454931ECBB43F00021D39 /* MGLLight.h in Headers */, @@ -2431,6 +2444,7 @@ 96E516E12000551100A02306 /* MGLMultiPoint_Private.h in Headers */, 3EA934623AD0000B7D99C3FB /* MGLRendererConfiguration.h in Headers */, DACA86272019218600E9693A /* MGLRasterDEMSource.h in Headers */, + 9621F2502091020E005B3800 /* NSExpression+MGLAdditions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2606,7 +2620,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = MBX; - LastUpgradeCheck = 0910; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = Mapbox; TargetAttributes = { 16376B061FFD9DAF0000563E = { @@ -2673,6 +2687,7 @@ he, da, "pt-PT", + ko, ); mainGroup = DA1DC9411CB6C1C2006E619F; productRefGroup = DA1DC94B1CB6C1C2006E619F /* Products */; @@ -2793,6 +2808,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */, 16376B0A1FFD9DAF0000563E /* MBGLIntegrationTests.m in Sources */, CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */, ); @@ -2819,6 +2835,7 @@ 927FBCFC1F4DAA8300F8BF1F /* MBXSnapshotsViewController.m in Sources */, DA1DC99B1CB6E064006E619F /* MBXViewController.m in Sources */, 40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */, + 3E6465D62065767A00685536 /* LimeGreenStyleLayer.m in Sources */, 632281DF1E6F855900D75A5D /* MBXEmbeddedMapViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3216,6 +3233,7 @@ DACBC60B20118ABE00C4D7E2 /* he */, DAD88E07202ACFE800AAA536 /* da */, DA93409B208562EB0059919A /* pt-PT */, + DAFEB3742093AE3700A86A83 /* ko */, ); name = Localizable.strings; sourceTree = "<group>"; @@ -3244,6 +3262,7 @@ DACBC60E20118AFE00C4D7E2 /* he */, DAD88E0C202AD06500AAA536 /* da */, DA93409F208563440059919A /* pt-PT */, + DAFEB3792093AEA100A86A83 /* ko */, ); name = Root.strings; sourceTree = "<group>"; @@ -3270,6 +3289,7 @@ DACBC60D20118ADE00C4D7E2 /* he */, DAD88E0A202AD03C00AAA536 /* da */, DA93409D208563220059919A /* pt-PT */, + DAFEB3772093AE7900A86A83 /* ko */, ); name = Localizable.strings; sourceTree = "<group>"; @@ -3293,6 +3313,7 @@ DA3389661FA3EE28001EA329 /* bg */, DACBC60C20118AD000C4D7E2 /* he */, DAD88E08202AD01300AAA536 /* da */, + DAFEB3752093AE4800A86A83 /* ko */, ); name = Foundation.strings; sourceTree = "<group>"; @@ -3317,6 +3338,7 @@ DA80E9611FE84AEF0065FC9B /* ar */, DAD88E09202AD01F00AAA536 /* da */, DA93409C2085630C0059919A /* pt-PT */, + DAFEB3762093AE6800A86A83 /* ko */, ); name = Foundation.stringsdict; sourceTree = "<group>"; @@ -3347,6 +3369,7 @@ DA3389691FA3EE50001EA329 /* bg */, DAD88E0B202AD04D00AAA536 /* da */, DA93409E208563360059919A /* pt-PT */, + DAFEB3782093AE9200A86A83 /* ko */, ); name = Localizable.stringsdict; sourceTree = "<group>"; @@ -3466,6 +3489,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -3473,6 +3497,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -3525,6 +3550,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -3532,6 +3558,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme index 4679378126..01b565d5d9 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -54,7 +54,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -66,6 +65,14 @@ BlueprintName = "test" ReferencedContainer = "container:ios.xcodeproj"> </BuildableReference> + <SkippedTests> + <Test + Identifier = "MGLAnnotationViewTests/testAnnotationViewInitWithFrame"> + </Test> + <Test + Identifier = "MGLAnnotationViewTests/testSelectingADisabledAnnotationView"> + </Test> + </SkippedTests> </TestableReference> </Testables> <MacroExpansion> @@ -84,7 +91,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme index 283c58ef7f..1638592557 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0920" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -26,7 +26,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -56,7 +55,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme index d1a152bce7..68e1c54ead 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -26,7 +26,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> </Testables> @@ -46,7 +45,6 @@ buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic+static.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic+static.xcscheme index e5f17124f2..325b58d690 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic+static.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic+static.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -54,7 +54,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -84,7 +83,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme index 3816aa5c91..6c7bff4527 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -40,7 +40,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -70,7 +69,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme index 7d5f2cd6d2..1f8969faf7 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -26,7 +26,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> </Testables> @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/static.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/static.xcscheme index fc385d3763..f88ec1a04c 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/static.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/static.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -26,7 +26,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> </Testables> @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/ios/jazzy.yml b/platform/ios/jazzy.yml index 34dcc1f50b..d3aae51b77 100644 --- a/platform/ios/jazzy.yml +++ b/platform/ios/jazzy.yml @@ -19,10 +19,10 @@ custom_categories: children: - Adding Markers to a Map - Runtime Styling - - Migrating to Expressions - Working with Mapbox Studio - Working with GeoJSON Data - Predicates and Expressions + - Migrating to Expressions - For Style Authors - Tile URL Templates - Info.plist Keys diff --git a/platform/ios/resources/ko.lproj/Localizable.strings b/platform/ios/resources/ko.lproj/Localizable.strings new file mode 100644 index 0000000000..40136803d1 --- /dev/null +++ b/platform/ios/resources/ko.lproj/Localizable.strings @@ -0,0 +1,117 @@ +/* Accessibility hint */ +"ANNOTATION_A11Y_HINT" = "추가 정보 보기"; + +/* No comment provided by engineer. */ +"API_CLIENT_400_DESC" = "세션 데이타 작업 실패. 초기 요청: %@"; + +/* No comment provided by engineer. */ +"API_CLIENT_400_REASON" = "상태 코드 %ld"; + +/* No comment provided by engineer. */ +"CANCEL" = "취소"; + +/* Accessibility hint for closing the selected annotation’s callout view and returning to the map */ +"CLOSE_CALLOUT_A11Y_HINT" = "지도로 복귀"; + +/* Accessibility hint */ +"COMPASS_A11Y_HINT" = "정북쪽으로 지도 회전"; + +/* Accessibility label */ +"COMPASS_A11Y_LABEL" = "나침반"; + +/* Compass abbreviation for north */ +"COMPASS_NORTH" = "북"; + +/* Instructions in Interface Builder designable; {key}, {plist file name} */ +"DESIGNABLE" = "맵박스에의한 지도를 출력하기 위해, %1$@ 를 %2$@에 당신의 접근 토큰으로 으로 설정하십시오. \n\n자세한 정보를 찾으시는 경우, 확인:"; + +/* Setup documentation URL display string; keep as short as possible */ +"FIRST_STEPS_URL" = "mapbox.com/help/first-steps-ios-sdk"; + +/* Accessibility hint */ +"INFO_A11Y_HINT" = "크레딧, 피드백 폼, 기타 보기"; + +/* Accessibility label */ +"INFO_A11Y_LABEL" = "이 맵에 관하여"; + +/* List separator */ +"LIST_SEPARATOR" = ", "; + +/* User-friendly error description */ +"LOAD_MAP_FAILED_DESC" = "알수 없는 에러로 인해 맵 로드에 실패하였습니다."; + +/* User-friendly error description */ +"LOAD_STYLE_FAILED_DESC" = "형식이 로드되지 않아, 맵 로드에 실패하였습니다."; + +/* Accessibility label */ +"LOGO_A11Y_LABEL" = "맵박스"; + +/* Accessibility label */ +"MAP_A11Y_LABEL" = "지도"; + +/* Map accessibility value; {number of visible annotations} */ +"MAP_A11Y_VALUE_ANNOTATIONS" = "%ld 주석 볼 수 있는."; + +/* Map accessibility value; {list of visible places} */ +"MAP_A11Y_VALUE_PLACES" = "가시거리 범위: %@."; + +/* Map accessibility value; {number of visible roads} */ +"MAP_A11Y_VALUE_ROADS" = "%ld 도로 볼 수 있는."; + +/* Map accessibility value; {zoom level} */ +"MAP_A11Y_VALUE_ZOOM" = "확대 %dx."; + +/* User-friendly error description */ +"PARSE_STYLE_FAILED_DESC" = "형식에 오류가 발생하여 맵 로드에 실패하였습니다."; + +/* String format for accessibility value for road feature; {starting compass direction}, {ending compass direction} */ +"ROAD_DIRECTION_A11Y_FMT" = "%1$@ to %2$@"; + +/* Accessibility value indicating that a road is a divided road (dual carriageway) */ +"ROAD_DIVIDED_A11Y_VALUE" = "분리 도로"; + +/* Accessibility value indicating that a road is a one-way road */ +"ROAD_ONEWAY_A11Y_VALUE" = "일방 통행"; + +/* String format for accessibility value for road feature; {route number} */ +"ROAD_REF_A11Y_FMT" = "경로 %@"; + +/* Action sheet title */ +"SDK_NAME" = "iOS를 위한 맵박스 지도 SDK"; + +/* Developer-only SDK update notification; {latest version, in format x.x.x} */ +"SDK_UPDATE_AVAILABLE" = "iOS버전 맵박스 지도 %@가 사용 가능합니다:"; + +/* User-friendly error description */ +"STYLE_NOT_FOUND_DESC" = "형식을 찾을 수 없거나 호환이 되지 않아, 맵 로드에 실패하였습니다."; + +/* Telemetry prompt message */ +"TELEMETRY_DISABLED_MSG" = "당신은 익명의 사용 데이타를 제공함으로써, 오픈스트리트맵과 맵박스의 향상에 기여하고 있습니다."; + +/* Telemetry prompt button */ +"TELEMETRY_DISABLED_OFF" = "참여하지 마십시오"; + +/* Telemetry prompt button */ +"TELEMETRY_DISABLED_ON" = "참여"; + +/* Telemetry prompt message */ +"TELEMETRY_ENABLED_MSG" = "당신은 익명의 사용 데이타를 제공함으로써, 오픈스트리트맵과 맵박스의 향상에 기여하고 있습니다."; + +/* Telemetry prompt button */ +"TELEMETRY_ENABLED_OFF" = "참여 중지"; + +/* Telemetry prompt button */ +"TELEMETRY_ENABLED_ON" = "참여 계속"; + +/* Telemetry prompt button */ +"TELEMETRY_MORE" = "좀 더 말해보세요"; + +/* Action in attribution sheet */ +"TELEMETRY_NAME" = "맵박스 텔레메트리"; + +/* Telemetry prompt title */ +"TELEMETRY_TITLE" = "더 나은 맵박스 지도 만들기"; + +/* Default user location annotation title */ +"USER_DOT_TITLE" = "당신의 위치"; + diff --git a/platform/ios/resources/ko.lproj/Localizable.stringsdict b/platform/ios/resources/ko.lproj/Localizable.stringsdict new file mode 100644 index 0000000000..fdde2639c6 --- /dev/null +++ b/platform/ios/resources/ko.lproj/Localizable.stringsdict @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>MAP_A11Y_VALUE_ANNOTATIONS</key> + <dict> + <key>NSStringLocalizedFormatKey</key> + <string>%#@count@</string> + <key>count</key> + <dict> + <key>NSStringFormatSpecTypeKey</key> + <string>NSStringPluralRuleType</string> + <key>NSStringFormatValueTypeKey</key> + <string>ld</string> + <key>other</key> + <string>%d 주석 보이기</string> + </dict> + </dict> + <key>MAP_A11Y_VALUE_ROADS</key> + <dict> + <key>NSStringLocalizedFormatKey</key> + <string>%#@count@</string> + <key>count</key> + <dict> + <key>NSStringFormatSpecTypeKey</key> + <string>NSStringPluralRuleType</string> + <key>NSStringFormatValueTypeKey</key> + <string>ld</string> + <key>other</key> + <string>%d 도로 보이기</string> + </dict> + </dict> + <key>MAP_A11Y_VALUE_ZOOM</key> + <dict> + <key>NSStringLocalizedFormatKey</key> + <string>%#@level@</string> + <key>level</key> + <dict> + <key>NSStringFormatSpecTypeKey</key> + <string>NSStringPluralRuleType</string> + <key>NSStringFormatValueTypeKey</key> + <string>d</string> + <key>other</key> + <string>확대 %dx</string> + </dict> + </dict> +</dict> +</plist> diff --git a/platform/ios/scripts/package.sh b/platform/ios/scripts/package.sh index 6df1b687b4..438fce240f 100755 --- a/platform/ios/scripts/package.sh +++ b/platform/ios/scripts/package.sh @@ -70,7 +70,7 @@ xcodebuild \ CURRENT_SHORT_VERSION=${SHORT_VERSION} \ CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \ CURRENT_COMMIT_HASH=${HASH} \ - ARCHS="x86_64" \ + ONLY_ACTIVE_ARCH=NO \ -derivedDataPath ${DERIVED_DATA} \ -workspace ./platform/ios/ios.xcworkspace \ -scheme ${SCHEME} \ @@ -194,6 +194,10 @@ if [[ ${BUILD_DYNAMIC} == true && ${BUILDTYPE} == Release ]]; then validate_dsym \ "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" \ "${OUTPUT}/dynamic/${NAME}.framework/${NAME}" + + step "Removing i386 slice from dSYM" + lipo -remove i386 "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" -o "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" + lipo -info "${OUTPUT}/dynamic/${NAME}.framework.dSYM/Contents/Resources/DWARF/${NAME}" fi function create_podspec { diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm index 1c53ba507a..46b0f56a79 100644 --- a/platform/ios/src/MGLAnnotationView.mm +++ b/platform/ios/src/MGLAnnotationView.mm @@ -11,8 +11,9 @@ @property (nonatomic, readwrite, nullable) NSString *reuseIdentifier; @property (nonatomic, readwrite) CATransform3D lastAppliedScaleTransform; -@property (nonatomic, readwrite) CATransform3D lastAppliedRotateTransform; @property (nonatomic, readwrite) CGFloat lastPitch; +@property (nonatomic, readwrite) CATransform3D lastAppliedRotationTransform; +@property (nonatomic, readwrite) CGFloat lastDirection; @property (nonatomic, weak) UIPanGestureRecognizer *panGestureRecognizer; @property (nonatomic, weak) UILongPressGestureRecognizer *longPressRecognizer; @property (nonatomic, weak) MGLMapView *mapView; @@ -43,9 +44,9 @@ - (void)commonInitWithAnnotation:(nullable id<MGLAnnotation>)annotation reuseIdentifier:(nullable NSString *)reuseIdentifier { _lastAppliedScaleTransform = CATransform3DIdentity; + _lastAppliedRotationTransform = CATransform3DIdentity; _annotation = annotation; _reuseIdentifier = [reuseIdentifier copy]; - _scalesWithViewingDistance = NO; _enabled = YES; } @@ -159,7 +160,7 @@ // We keep track of each viewing distance scale transform that we apply. Each iteration, // we can account for it so that we don't get cumulative scaling every time we move. - // We also avoid clobbering any existing transform passed in by the client, too. + // We also avoid clobbering any existing transform passed in by the client or this SDK. CATransform3D undoOfLastScaleTransform = CATransform3DInvert(_lastAppliedScaleTransform); CATransform3D newScaleTransform = CATransform3DMakeScale(pitchAdjustedScale, pitchAdjustedScale, 1); CATransform3D effectiveTransform = CATransform3DConcat(undoOfLastScaleTransform, newScaleTransform); @@ -181,11 +182,20 @@ { if (self.rotatesToMatchCamera == NO) return; - CGFloat directionRad = self.mapView.direction * M_PI / 180.0; - CATransform3D newRotateTransform = CATransform3DMakeRotation(-directionRad, 0, 0, 1); - self.layer.transform = CATransform3DConcat(CATransform3DIdentity, newRotateTransform); - - _lastAppliedRotateTransform = newRotateTransform; + CGFloat direction = -MGLRadiansFromDegrees(self.mapView.direction); + + // Return early if the map view has the same rotation as the already-applied transform. + if (direction == _lastDirection) return; + _lastDirection = direction; + + // We keep track of each rotation transform that we apply. Each iteration, + // we can account for it so that we don't get cumulative rotation every time we move. + // We also avoid clobbering any existing transform passed in by the client or this SDK. + CATransform3D undoOfLastRotationTransform = CATransform3DInvert(_lastAppliedRotationTransform); + CATransform3D newRotationTransform = CATransform3DMakeRotation(direction, 0, 0, 1); + CATransform3D effectiveTransform = CATransform3DConcat(undoOfLastRotationTransform, newRotationTransform); + self.layer.transform = CATransform3DConcat(self.layer.transform, effectiveTransform); + _lastAppliedRotationTransform = newRotationTransform; } #pragma mark - Draggable diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index bde8e6a71d..fd0ca19b26 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -1065,7 +1065,7 @@ MGL_EXPORT IB_DESIGNABLE */ - (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude; -- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude __attribute__((deprecated("Use -metersPerPointAtLatitude:."))); +- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude __attribute__((unavailable("Use -metersPerPointAtLatitude:."))); #pragma mark Annotating the Map diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 978547b9c6..26b23abb4e 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -49,7 +49,7 @@ #import "NSBundle+MGLAdditions.h" #import "NSDate+MGLAdditions.h" #import "NSException+MGLAdditions.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import "NSProcessInfo+MGLAdditions.h" #import "NSString+MGLAdditions.h" #import "NSURL+MGLAdditions.h" @@ -4280,6 +4280,15 @@ public: moveOnscreen = [self isBringingAnnotationOnscreenSupportedForAnnotation:annotation animated:animateSelection]; } + // If we have an invalid positioning rect, we need to provide a suitable default. + // This (currently) happens if you select an annotation that has NOT yet been + // added. See https://github.com/mapbox/mapbox-gl-native/issues/11476 + if (CGRectIsNull(calloutPositioningRect)) { + CLLocationCoordinate2D origin = annotation.coordinate; + CGPoint originPoint = [self convertCoordinate:origin toPointToView:self]; + calloutPositioningRect = { .origin = originPoint, .size = CGSizeZero }; + } + CGRect expandedPositioningRect = UIEdgeInsetsInsetRect(calloutPositioningRect, MGLMapViewOffscreenAnnotationPadding); // Used for callout positioning, and moving offscreen annotations onscreen. @@ -4432,7 +4441,11 @@ public: { MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation]; CGRect positioningRect = [self positioningRectForCalloutForAnnotationWithTag:annotationTag]; - + + if (CGRectIsNull(positioningRect)) { + return positioningRect; + } + // For annotations which `coordinate` falls offscreen it will use the current tap point as anchor instead. if ( ! CGRectIntersectsRect(positioningRect, self.bounds) && annotation != self.userLocation) { @@ -4452,15 +4465,15 @@ public: id <MGLAnnotation> annotation = [self annotationWithTag:annotationTag]; if ( ! annotation) { - return CGRectZero; + return CGRectNull; } if ([annotation isKindOfClass:[MGLMultiPoint class]]) { CLLocationCoordinate2D origin = annotation.coordinate; CGPoint originPoint = [self convertCoordinate:origin toPointToView:self]; return CGRectMake(originPoint.x, originPoint.y, MGLAnnotationImagePaddingForHitTest, MGLAnnotationImagePaddingForHitTest); - } + UIImage *image = [self imageOfAnnotationWithTag:annotationTag].image; if ( ! image) { @@ -4547,6 +4560,8 @@ public: return; } + __weak __typeof__(self) weakSelf = self; + // The user location callout view initially points to the user location // annotation’s implicit (visual) frame, which is offset from the // annotation’s explicit frame. Now the callout view needs to rendezvous @@ -4560,10 +4575,16 @@ public: UIViewAnimationOptionBeginFromCurrentState) animations:^ { + __typeof__(self) strongSelf = weakSelf; + if ( ! strongSelf) + { + return; + } + calloutView.frame = CGRectOffset(calloutView.frame, - _initialImplicitCalloutViewOffset.x, - _initialImplicitCalloutViewOffset.y); - _initialImplicitCalloutViewOffset = CGPointZero; + strongSelf->_initialImplicitCalloutViewOffset.x, + strongSelf->_initialImplicitCalloutViewOffset.y); + strongSelf->_initialImplicitCalloutViewOffset = CGPointZero; } completion:NULL]; } @@ -5694,10 +5715,12 @@ public: if (annotationView.layer.animationKeys.count > 0) { continue; } + // Move the annotation view far out of view to the left - CGRect adjustedFrame = annotationView.frame; - adjustedFrame.origin.x = -CGRectGetWidth(self.frame) * 10.0; - annotationView.frame = adjustedFrame; + CGPoint adjustedCenter = annotationView.center; + adjustedCenter.x = -CGRectGetWidth(self.frame) * 10.0; + annotationView.center = adjustedCenter; + [self enqueueAnnotationViewForAnnotationContext:annotationContext]; } } @@ -5733,6 +5756,8 @@ public: rect = annotationView.frame; } + NSAssert(!CGRectIsNull(rect), @"Positioning rect should not be CGRectNull by this point"); + CGPoint point = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect)); if ( ! CGPointEqualToPoint(calloutView.center, point)) { diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index 20417dbbd4..7beb8b766b 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -66,3 +66,4 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLAttributionInfo.h" #import "MGLMapSnapshotter.h" #import "NSExpression+MGLAdditions.h" +#import "NSPredicate+MGLAdditions.h" diff --git a/platform/ios/src/UIColor+MGLAdditions.mm b/platform/ios/src/UIColor+MGLAdditions.mm index 9ca39acda4..7c1fbddc20 100644 --- a/platform/ios/src/UIColor+MGLAdditions.mm +++ b/platform/ios/src/UIColor+MGLAdditions.mm @@ -66,7 +66,7 @@ return [UIColor colorWithRed:[components[0].constantValue doubleValue] / 255.0 green:[components[1].constantValue doubleValue] / 255.0 blue:[components[2].constantValue doubleValue] / 255.0 - alpha:components.count == 3 ? [components[3].constantValue doubleValue] : 1.0]; + alpha:components.count == 3 ? 1.0 : [components[3].constantValue doubleValue]]; } @end diff --git a/platform/ios/test/MGLAnnotationViewTests.m b/platform/ios/test/MGLAnnotationViewTests.m index 2f5963e66e..a2cc4227ed 100644 --- a/platform/ios/test/MGLAnnotationViewTests.m +++ b/platform/ios/test/MGLAnnotationViewTests.m @@ -3,6 +3,13 @@ static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReuseIdentifer"; + +@interface MGLMapView (Tests) +@property (nonatomic) MGLCameraChangeReason cameraChangeReasonBitmask; +@end + + + @interface MGLCustomAnnotationView : MGLAnnotationView @end @@ -58,6 +65,7 @@ static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReu @property (nonatomic) MGLMapView *mapView; @property (nonatomic, weak) MGLAnnotationView *annotationView; @property (nonatomic) NSInteger annotationSelectedCount; +@property (nonatomic) void (^prepareAnnotationView)(MGLAnnotationView*); @end @implementation MGLAnnotationViewTests @@ -152,6 +160,83 @@ static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReu XCTAssertEqual(selectionCount, self.annotationSelectedCount, @"-mapView:didSelectAnnotation: should be called for each selection"); } +- (void)testSelectingOnscreenAnnotationThatHasNotBeenAdded { + // See https://github.com/mapbox/mapbox-gl-native/issues/11476 + + // This bug occurs under the following conditions: + // + // - There are content insets (e.g. navigation bar) for the compare against + // CGRectZero (now CGRectNull) + // - annotationView.enabled == NO - Currently this can happen if you use + // `-initWithFrame:` rather than one of the provided initializers + // + + self.prepareAnnotationView = ^(MGLAnnotationView *view) { + view.enabled = NO; + }; + + self.mapView.contentInset = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0); + + MGLCameraChangeReason reasonBefore = self.mapView.cameraChangeReasonBitmask; + XCTAssert(reasonBefore == MGLCameraChangeReasonNone, @"Camera should not have moved at start of test"); + + // Create annotation + MGLPointFeature *point = [[MGLPointFeature alloc] init]; + point.title = NSStringFromSelector(_cmd); + point.coordinate = CLLocationCoordinate2DMake(0.0, 0.0); + + MGLCoordinateBounds coordinateBounds = [self.mapView convertRect:self.mapView.bounds toCoordinateBoundsFromView:self.mapView]; + XCTAssert(MGLCoordinateInCoordinateBounds(point.coordinate, coordinateBounds), @"The test point should be within the visible map view"); + + // Select on screen annotation (DO NOT ADD FIRST). + [self.mapView selectAnnotation:point animated:YES]; + + // Expect - the camera NOT to move. + MGLCameraChangeReason reasonAfter = self.mapView.cameraChangeReasonBitmask; + XCTAssert(reasonAfter == MGLCameraChangeReasonNone, @"Camera should not have moved"); +} + +- (void)checkDefaultPropertiesForAnnotationView:(MGLAnnotationView*)view { + XCTAssertNil(view.annotation); + XCTAssertNil(view.reuseIdentifier); + XCTAssertEqual(view.centerOffset.dx, 0.0); + XCTAssertEqual(view.centerOffset.dy, 0.0); + XCTAssertFalse(view.scalesWithViewingDistance); + XCTAssertFalse(view.rotatesToMatchCamera); + XCTAssertFalse(view.isSelected); + XCTAssert(view.isEnabled); + XCTAssertFalse(view.isDraggable); + XCTAssertEqual(view.dragState, MGLAnnotationViewDragStateNone); +} + +- (void)testAnnotationViewInitWithFrame { + CGRect frame = CGRectMake(10.0, 10.0, 100.0, 100.0); + MGLAnnotationView *view = [[MGLAnnotationView alloc] initWithFrame:frame]; + [self checkDefaultPropertiesForAnnotationView:view]; +} + +- (void)testAnnotationViewInitWithReuseIdentifier { + MGLAnnotationView *view = [[MGLAnnotationView alloc] initWithReuseIdentifier:nil]; + [self checkDefaultPropertiesForAnnotationView:view]; +} + +- (void)testSelectingADisabledAnnotationView { + self.prepareAnnotationView = ^(MGLAnnotationView *view) { + view.enabled = NO; + }; + + // Create annotation + MGLPointFeature *point = [[MGLPointFeature alloc] init]; + point.title = NSStringFromSelector(_cmd); + point.coordinate = CLLocationCoordinate2DMake(0.0, 0.0); + + XCTAssert(self.mapView.selectedAnnotations.count == 0, @"There should be 0 selected annotations"); + + [self.mapView selectAnnotation:point animated:NO]; + + XCTAssert(self.mapView.selectedAnnotations.count == 0, @"There should be 0 selected annotations"); +} + #pragma mark - MGLMapViewDelegate - - (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation @@ -163,6 +248,10 @@ static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReu annotationView = [[MGLAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:MGLTestAnnotationReuseIdentifer]; } + if (self.prepareAnnotationView) { + self.prepareAnnotationView(annotationView); + } + _annotationView = annotationView; return annotationView; diff --git a/platform/ios/uitest/ios-tests.xcodeproj/project.pbxproj b/platform/ios/uitest/ios-tests.xcodeproj/project.pbxproj index c9744d41bf..108139e6e3 100644 --- a/platform/ios/uitest/ios-tests.xcodeproj/project.pbxproj +++ b/platform/ios/uitest/ios-tests.xcodeproj/project.pbxproj @@ -47,6 +47,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 3EAB52CE206ACE7E008BFE2D /* libmbgl-loop-darwin.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-loop-darwin.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 3EAB52CF206ACE7E008BFE2D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 96567A221B0E84CD00D78776 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = SOURCE_ROOT; }; 96567A301B0E8BB900D78776 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = SOURCE_ROOT; }; DA180EF11DD1A4DF000A211D /* OHHTTPStubs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OHHTTPStubs.framework; path = "OHHTTPStubs/OHHTTPStubs/build/Debug-iphoneos/OHHTTPStubs.framework"; sourceTree = "<group>"; }; @@ -122,6 +124,8 @@ DD043325196DB9BC00E6F39D /* Frameworks */ = { isa = PBXGroup; children = ( + 3EAB52CF206ACE7E008BFE2D /* OpenGLES.framework */, + 3EAB52CE206ACE7E008BFE2D /* libmbgl-loop-darwin.a */, DA180EF11DD1A4DF000A211D /* OHHTTPStubs.framework */, DA9C551B1CD9DFA7000A15C6 /* libKIF.a */, DA482C7F1C12582600772FE3 /* Mapbox.framework */, diff --git a/platform/ios/uitest/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme b/platform/ios/uitest/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme index b1a1db6ba1..2c8de87a0f 100644 --- a/platform/ios/uitest/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme +++ b/platform/ios/uitest/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0910" + LastUpgradeVersion = "0930" version = "1.7"> <BuildAction parallelizeBuildables = "YES" @@ -40,7 +40,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -91,7 +90,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 00d242211c..ab71e62ec6 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -10,7 +10,22 @@ ### Style layers -* Deprecated `+[NSExpression featurePropertiesVariableExpression]` use `+[NSExpression featureAttributesVariableExpression]` instead. ([#11748](https://github.com/mapbox/mapbox-gl-native/pull/11748)) +* Deprecated `+[NSExpression featurePropertiesVariableExpression]`; use `+[NSExpression featureAttributesVariableExpression]` instead. ([#11748](https://github.com/mapbox/mapbox-gl-native/pull/11748)) +* Added an `-[NSPredicate(MGLAdditions) predicateWithMGLJSONObject:]` method and `NSPredicate.mgl_jsonExpressionObject` property. ([#11810](https://github.com/mapbox/mapbox-gl-native/pull/11810)) +* Added `FIRST`, `LAST`, and `SIZE` symbolic array subscripting support to expressions. ([#11770](https://github.com/mapbox/mapbox-gl-native/pull/11770)) +* Inside an expression, casting `nil` to a string turns it into the empty string instead of the string `"null"`. ([#11904](https://github.com/mapbox/mapbox-gl-native/pull/11904)) +* Fixed an issue where certain colors were being misrepresented in `NSExpression` obtained from `MGLStyleLayer` getters. ([#11725](https://github.com/mapbox/mapbox-gl-native/pull/11725)) + +### Annotations + +* Fixed an issue where selecting an onscreen annotation could move the map unintentionally. ([#11731](https://github.com/mapbox/mapbox-gl-native/pull/11731)) +* Fixed an issue where an `MGLOverlay` object straddling the antimeridian had an empty `MGLOverlay.overlayBounds` value. ([#11783](https://github.com/mapbox/mapbox-gl-native/pull/11783)) + +### Other changes + +* Reduced per-frame render CPU time. ([#11811](https://github.com/mapbox/mapbox-gl-native/issues/11811)) +* Fixed a crash when removing an `MGLOfflinePack`. ([#6092](https://github.com/mapbox/mapbox-gl-native/issues/6092)) +* If English is the first language listed in the user’s Preferred Languages setting, `-[MGLStyle localizeLabelsIntoLocale:]` no longer prioritizes other languages over English. ([#11907](https://github.com/mapbox/mapbox-gl-native/pull/11907)) ## 0.7.0 - April 19, 2018 diff --git a/platform/macos/Mapbox-macOS-SDK-symbols.podspec b/platform/macos/Mapbox-macOS-SDK-symbols.podspec index 2df93c6f42..ef2772336d 100644 --- a/platform/macos/Mapbox-macOS-SDK-symbols.podspec +++ b/platform/macos/Mapbox-macOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '0.7.0' + version = '0.7.1' m.name = 'Mapbox-macOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/macos/Mapbox-macOS-SDK.podspec b/platform/macos/Mapbox-macOS-SDK.podspec index 14b7426097..16b63cb34d 100644 --- a/platform/macos/Mapbox-macOS-SDK.podspec +++ b/platform/macos/Mapbox-macOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '0.7.0' + version = '0.7.1' m.name = 'Mapbox-macOS-SDK' m.version = version diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 7be500ae6a..4ee6050565 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -93,9 +93,8 @@ NSArray<id <MGLAnnotation>> *MBXFlattenedShapes(NSArray<id <MGLAnnotation>> *sha BOOL _isTouringWorld; BOOL _isShowingPolygonAndPolylineAnnotations; BOOL _isShowingAnimatedAnnotation; - - // Snapshotter - MGLMapSnapshotter* snapshotter; + + MGLMapSnapshotter *_snapshotter; } #pragma mark Lifecycle @@ -185,17 +184,23 @@ NSArray<id <MGLAnnotation>> *MBXFlattenedShapes(NSArray<id <MGLAnnotation>> *sha options.zoomLevel = self.mapView.zoomLevel; // Create and start the snapshotter - snapshotter = [[MGLMapSnapshotter alloc] initWithOptions:options]; - [snapshotter startWithCompletionHandler:^(MGLMapSnapshot *snapshot, NSError *error) { + __weak __typeof__(self) weakSelf = self; + _snapshotter = [[MGLMapSnapshotter alloc] initWithOptions:options]; + [_snapshotter startWithCompletionHandler:^(MGLMapSnapshot *snapshot, NSError *error) { + __typeof__(self) strongSelf = weakSelf; + if (!strongSelf) { + return; + } + if (error) { NSLog(@"Could not load snapshot: %@", error.localizedDescription); } else { // Set the default name for the file and show the panel. NSSavePanel *panel = [NSSavePanel savePanel]; - panel.nameFieldStringValue = [self.mapView.styleURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:@"png"]; + panel.nameFieldStringValue = [strongSelf.mapView.styleURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:@"png"]; panel.allowedFileTypes = [@[(NSString *)kUTTypePNG] arrayByAddingObjectsFromArray:[NSBitmapImageRep imageUnfilteredTypes]]; - [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { + [panel beginSheetModalForWindow:strongSelf.window completionHandler:^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) { // Write the contents in the new format. NSURL *fileURL = panel.URL; @@ -232,7 +237,8 @@ NSArray<id <MGLAnnotation>> *MBXFlattenedShapes(NSArray<id <MGLAnnotation>> *sha }]; } - snapshotter = nil; + + strongSelf->_snapshotter = nil; }]; } @@ -1179,7 +1185,7 @@ NSArray<id <MGLAnnotation>> *MBXFlattenedShapes(NSArray<id <MGLAnnotation>> *sha return YES; } if (menuItem.action == @selector(takeSnapshot:)) { - return !(snapshotter && [snapshotter isLoading]); + return !(_snapshotter && [_snapshotter isLoading]); } return NO; } diff --git a/platform/macos/app/ko.lproj/Localizable.strings b/platform/macos/app/ko.lproj/Localizable.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/platform/macos/app/ko.lproj/Localizable.strings diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md index 22182c7810..08385a66d9 100644 --- a/platform/macos/docs/guides/For Style Authors.md +++ b/platform/macos/docs/guides/For Style Authors.md @@ -267,7 +267,7 @@ Each property representing a layout or paint attribute is set to an but you create the former using a very different syntax. `NSExpression`’s format string syntax is reminiscent of a spreadsheet formula or an expression in a database query. See the -“[Predicates and Expressions](Predicates and Expressions.md)” guide for an +“[Predicates and Expressions](predicates-and-expressions.html)” guide for an overview of the expression support in this SDK. This SDK no longer supports style functions; use expressions instead. @@ -318,7 +318,7 @@ In style specification | Method, function, or predicate type | Format string syn `number` | | `string` | | `to-boolean` | `boolValue` | -`to-color` | | +`to-color` | | `CAST(var, 'NSColor')` `to-number` | `mgl_numberWithFallbackValues:` | `CAST(zipCode, 'NSNumber')` `to-string` | `stringValue` | `CAST(ele, 'NSString')` `typeof` | | @@ -350,7 +350,7 @@ In style specification | Method, function, or predicate type | Format string syn `upcase` | `uppercase:` | `uppercase('Elysian Fields')` `rgb` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` | `rgba` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` | -`to-rgba` | | +`to-rgba` | | `CAST(noindex(var), 'NSArray')` `-` | `from:subtract:` | `2 - 1` `*` | `multiply:by:` | `1 * 2` `/` | `divide:by:` | `1 / 2` @@ -405,5 +405,5 @@ In style JSON | In the format string `["any", f0, …, fn]` | `p0 OR … OR pn` `["none", f0, …, fn]` | `NOT (p0 OR … OR pn)` -See the “[Predicates and Expressions](Predicates and Expressions.md)” guide for +See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for a full description of the supported operators and operand types. diff --git a/platform/macos/jazzy.yml b/platform/macos/jazzy.yml index e1053324fb..915c1f46a9 100644 --- a/platform/macos/jazzy.yml +++ b/platform/macos/jazzy.yml @@ -20,7 +20,7 @@ custom_categories: - Working with GeoJSON Data - Predicates and Expressions - For Style Authors - - Style Layers Using Expressions + - Migrating to Expressions - Tile URL Templates - Info.plist Keys - name: Maps diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 002590d8ff..4cb436fdbf 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 1F7454AB1ED1DDBD00021D39 /* MGLLightTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F7454AA1ED1DDBD00021D39 /* MGLLightTest.mm */; }; 1F95931B1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */; }; 1F9EF4061FBA1B0E0063FBB0 /* mapbox_helmet.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1F9EF4051FBA1B0D0063FBB0 /* mapbox_helmet.pdf */; }; + 1FC481852098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */; }; 30E5781B1DAA857E0050F07E /* NSImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578141DAA7D920050F07E /* NSImage+MGLAdditions.h */; }; 3508EC641D749D39009B0EE4 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3508EC651D749D39009B0EE4 /* NSExpression+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */; }; @@ -37,7 +38,7 @@ 3527428D1D4C24AB00A1ECE6 /* MGLCircleStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3527428B1D4C24AB00A1ECE6 /* MGLCircleStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3527428E1D4C24AB00A1ECE6 /* MGLCircleStyleLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3527428C1D4C24AB00A1ECE6 /* MGLCircleStyleLayer.mm */; }; 352742A11D4C25BD00A1ECE6 /* MGLStyleValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3527429E1D4C25BD00A1ECE6 /* MGLStyleValue.mm */; }; - 3529039B1D6C63B80002C7DF /* NSPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 352903991D6C63B80002C7DF /* NSPredicate+MGLAdditions.h */; }; + 3529039B1D6C63B80002C7DF /* NSPredicate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 352903991D6C63B80002C7DF /* NSPredicate+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3529039C1D6C63B80002C7DF /* NSPredicate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3529039A1D6C63B80002C7DF /* NSPredicate+MGLAdditions.mm */; }; 3537CA741D3F93A600380318 /* MGLStyle_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 3537CA731D3F93A600380318 /* MGLStyle_Private.h */; }; 3538AA231D542685008EC33D /* MGLStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3538AA211D542685008EC33D /* MGLStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -62,6 +63,7 @@ 35C6DF871E214C1800ACA483 /* MGLDistanceFormatterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35C6DF861E214C1800ACA483 /* MGLDistanceFormatterTests.m */; }; 35D65C5A1D65AD5500722C23 /* NSDate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D65C581D65AD5500722C23 /* NSDate+MGLAdditions.h */; }; 35D65C5B1D65AD5500722C23 /* NSDate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35D65C591D65AD5500722C23 /* NSDate+MGLAdditions.mm */; }; + 3E6465D9206576A900685536 /* LimeGreenStyleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E6465D7206576A800685536 /* LimeGreenStyleLayer.m */; }; 3EA9317388DC9A0BF46B7674 /* MGLRendererConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA9369A4C46957566058822 /* MGLRendererConfiguration.h */; }; 3EA93BA38DBB4B814B6C1FCC /* MGLRendererConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3EA93B1B0864609938506E12 /* MGLRendererConfiguration.mm */; }; 4031ACFC1E9EB3C100A3EA26 /* MGLMapViewDelegateIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4031ACFB1E9EB3C100A3EA26 /* MGLMapViewDelegateIntegrationTests.swift */; }; @@ -95,6 +97,7 @@ 9654C12B1FFC38E000DB6A19 /* MGLPolyline_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12A1FFC38E000DB6A19 /* MGLPolyline_Private.h */; }; 9654C12D1FFC394700DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12C1FFC394700DB6A19 /* MGLPolygon_Private.h */; }; 96E027311E57C9A7004B8E66 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96E027331E57C9A7004B8E66 /* Localizable.strings */; }; + CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */; }; DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8B1D5EEAC3009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */; }; DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */; }; @@ -162,7 +165,6 @@ DAA998FB1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = DAA998F91E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; }; DAA998FC1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = DAA998FA1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.mm */; }; DAA999011E9F5EC5002E6EA6 /* MGLFillExtrusionStyleLayerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DAA999001E9F5EC5002E6EA6 /* MGLFillExtrusionStyleLayerTests.mm */; }; - DAB2CCE51DF632ED001B2FE1 /* LimeGreenStyleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB2CCE41DF632ED001B2FE1 /* LimeGreenStyleLayer.m */; }; DAC25FCA200FD5E2009BE98E /* NSExpression+MGLPrivateAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DAC25FC9200FD5E2009BE98E /* NSExpression+MGLPrivateAdditions.h */; }; DAC2ABC51CC6D343006D18C4 /* MGLAnnotationImage_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAC2ABC41CC6D343006D18C4 /* MGLAnnotationImage_Private.h */; }; DACA8622201920BE00E9693A /* MGLRasterDEMSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DACA8620201920BE00E9693A /* MGLRasterDEMSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -308,6 +310,7 @@ 1F7454AA1ED1DDBD00021D39 /* MGLLightTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLightTest.mm; sourceTree = "<group>"; }; 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLNSDateAdditionsTests.mm; path = ../../darwin/test/MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; }; 1F9EF4051FBA1B0D0063FBB0 /* mapbox_helmet.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = mapbox_helmet.pdf; sourceTree = "<group>"; }; + 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSPredicate+MGLPrivateAdditions.h"; sourceTree = "<group>"; }; 30E578141DAA7D920050F07E /* NSImage+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSImage+MGLAdditions.h"; path = "src/NSImage+MGLAdditions.h"; sourceTree = SOURCE_ROOT; }; 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSExpression+MGLAdditions.h"; sourceTree = "<group>"; }; 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSExpression+MGLAdditions.mm"; sourceTree = "<group>"; }; @@ -347,6 +350,8 @@ 35C6DF861E214C1800ACA483 /* MGLDistanceFormatterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLDistanceFormatterTests.m; path = ../../darwin/test/MGLDistanceFormatterTests.m; sourceTree = "<group>"; }; 35D65C581D65AD5500722C23 /* NSDate+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+MGLAdditions.h"; sourceTree = "<group>"; }; 35D65C591D65AD5500722C23 /* NSDate+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDate+MGLAdditions.mm"; sourceTree = "<group>"; }; + 3E6465D7206576A800685536 /* LimeGreenStyleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LimeGreenStyleLayer.m; path = ../../darwin/app/LimeGreenStyleLayer.m; sourceTree = "<group>"; }; + 3E6465D8206576A900685536 /* LimeGreenStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LimeGreenStyleLayer.h; path = ../../darwin/app/LimeGreenStyleLayer.h; sourceTree = "<group>"; }; 3EA9369A4C46957566058822 /* MGLRendererConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLRendererConfiguration.h; sourceTree = "<group>"; }; 3EA93B1B0864609938506E12 /* MGLRendererConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLRendererConfiguration.mm; sourceTree = "<group>"; }; 4031ACFB1E9EB3C100A3EA26 /* MGLMapViewDelegateIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MGLMapViewDelegateIntegrationTests.swift; sourceTree = "<group>"; }; @@ -394,6 +399,7 @@ 96E027391E57C9B9004B8E66 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; }; 96E0273A1E57C9BB004B8E66 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; }; 96E0273B1E57C9BC004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; }; + CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationTests.m; path = test/MGLAnnotationTests.m; sourceTree = SOURCE_ROOT; }; DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; }; DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; }; DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; }; @@ -518,8 +524,6 @@ DAA998F91E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFillExtrusionStyleLayer.h; sourceTree = "<group>"; }; DAA998FA1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFillExtrusionStyleLayer.mm; sourceTree = "<group>"; }; DAA999001E9F5EC5002E6EA6 /* MGLFillExtrusionStyleLayerTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFillExtrusionStyleLayerTests.mm; sourceTree = "<group>"; }; - DAB2CCE31DF632ED001B2FE1 /* LimeGreenStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LimeGreenStyleLayer.h; sourceTree = "<group>"; }; - DAB2CCE41DF632ED001B2FE1 /* LimeGreenStyleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LimeGreenStyleLayer.m; sourceTree = "<group>"; }; DAC25FC9200FD5E2009BE98E /* NSExpression+MGLPrivateAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSExpression+MGLPrivateAdditions.h"; sourceTree = "<group>"; }; DAC2ABC41CC6D343006D18C4 /* MGLAnnotationImage_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationImage_Private.h; sourceTree = "<group>"; }; DACA8620201920BE00E9693A /* MGLRasterDEMSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLRasterDEMSource.h; sourceTree = "<group>"; }; @@ -635,6 +639,9 @@ DAF2571D201902A500367EF5 /* MGLHillshadeStyleLayerTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLHillshadeStyleLayerTests.mm; sourceTree = "<group>"; }; DAFBD0D51E3FA969000CD6BF /* zh-Hant */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; }; DAFBD0D61E3FA983000CD6BF /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Foundation.strings"; sourceTree = "<group>"; }; + DAFEB3702093ACBF00A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; }; + DAFEB3722093ACDA00A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Foundation.strings; sourceTree = "<group>"; }; + DAFEB3732093ACE400A86A83 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ko; path = ko.lproj/Foundation.stringsdict; sourceTree = "<group>"; }; DD0902AF1DB1AC6400C5BDCE /* MGLNetworkConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfiguration.m; sourceTree = "<group>"; }; DD0902B01DB1AC6400C5BDCE /* MGLNetworkConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLNetworkConfiguration.h; sourceTree = "<group>"; }; DD58A4C71D822C6200E1F038 /* MGLExpressionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLExpressionTests.mm; path = ../../darwin/test/MGLExpressionTests.mm; sourceTree = "<group>"; }; @@ -816,8 +823,8 @@ DA839E961CC2E3400062CAFB /* AppDelegate.m */, DAE6C2E31CC3050F00DB3429 /* DroppedPinAnnotation.h */, DAE6C2E41CC3050F00DB3429 /* DroppedPinAnnotation.m */, - DAB2CCE31DF632ED001B2FE1 /* LimeGreenStyleLayer.h */, - DAB2CCE41DF632ED001B2FE1 /* LimeGreenStyleLayer.m */, + 3E6465D8206576A900685536 /* LimeGreenStyleLayer.h */, + 3E6465D7206576A800685536 /* LimeGreenStyleLayer.m */, DAE6C2E51CC3050F00DB3429 /* LocationCoordinate2DTransformer.h */, DAE6C2E61CC3050F00DB3429 /* LocationCoordinate2DTransformer.m */, DA839E9B1CC2E3400062CAFB /* MapDocument.h */, @@ -1029,6 +1036,7 @@ 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */, 352903991D6C63B80002C7DF /* NSPredicate+MGLAdditions.h */, 3529039A1D6C63B80002C7DF /* NSPredicate+MGLAdditions.mm */, + 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */, DAE6C3801CC31E2A00DB3429 /* NSProcessInfo+MGLAdditions.h */, DAE6C3811CC31E2A00DB3429 /* NSProcessInfo+MGLAdditions.m */, DAE6C3821CC31E2A00DB3429 /* NSString+MGLAdditions.h */, @@ -1076,6 +1084,7 @@ 4031AD001E9FD61000A3EA26 /* Test Helpers */, 4031ACFA1E9EB39A00A3EA26 /* Swift Integration */, DA8F257D1D51C5F40010E6B5 /* Styling */, + CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */, DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.m */, DAEDC4361D606291000224FF /* MGLAttributionButtonTests.m */, DA35A2C11CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m */, @@ -1212,6 +1221,7 @@ DAE6C3631CC31E0400DB3429 /* MGLPointAnnotation.h in Headers */, DAC2ABC51CC6D343006D18C4 /* MGLAnnotationImage_Private.h in Headers */, DAE6C35F1CC31E0400DB3429 /* MGLOfflinePack.h in Headers */, + 1FC481852098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */, DAE6C39C1CC31E2A00DB3429 /* NSString+MGLAdditions.h in Headers */, 3529039B1D6C63B80002C7DF /* NSPredicate+MGLAdditions.h in Headers */, DA8F25971D51CAC70010E6B5 /* MGLVectorTileSource.h in Headers */, @@ -1370,7 +1380,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = MBX; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = Mapbox; TargetAttributes = { DA839E911CC2E3400062CAFB = { @@ -1418,6 +1428,7 @@ he, da, "pt-PT", + ko, ); mainGroup = DA839E891CC2E3400062CAFB; productRefGroup = DA839E931CC2E3400062CAFB /* Products */; @@ -1483,11 +1494,11 @@ DA839E9D1CC2E3400062CAFB /* MapDocument.m in Sources */, DAE6C2ED1CC3050F00DB3429 /* DroppedPinAnnotation.m in Sources */, DAE6C2EE1CC3050F00DB3429 /* LocationCoordinate2DTransformer.m in Sources */, - DAB2CCE51DF632ED001B2FE1 /* LimeGreenStyleLayer.m in Sources */, DAE6C2F11CC3050F00DB3429 /* TimeIntervalTransformer.m in Sources */, DACB0C391E18DFFD005DDBEA /* MGLStyle+MBXAdditions.m in Sources */, DA839E9A1CC2E3400062CAFB /* main.m in Sources */, DA839E971CC2E3400062CAFB /* AppDelegate.m in Sources */, + 3E6465D9206576A900685536 /* LimeGreenStyleLayer.m in Sources */, DAE6C2F01CC3050F00DB3429 /* OfflinePackNameValueTransformer.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1601,6 +1612,7 @@ DAE6C3D31CC34C9900DB3429 /* MGLOfflinePackTests.m in Sources */, DA87A9A51DCACC5000810D09 /* MGLLineStyleLayerTests.mm in Sources */, DA87A9A31DCACC5000810D09 /* MGLRasterStyleLayerTests.mm in Sources */, + CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */, DA87A9991DC9D88400810D09 /* MGLTileSetTests.mm in Sources */, DA35A2A81CC9F41600E826B2 /* MGLCoordinateFormatterTests.m in Sources */, DAE7DEC41E24549F007505A6 /* MGLNSStringAdditionsTests.m in Sources */, @@ -1657,6 +1669,7 @@ DACBC6082011885800C4D7E2 /* he */, DAD88E03202ACF5900AAA536 /* da */, DA934097208562590059919A /* pt-PT */, + DAFEB3702093ACBF00A86A83 /* ko */, ); name = Localizable.strings; sourceTree = "<group>"; @@ -1735,6 +1748,7 @@ DA3389621FA3EDEF001EA329 /* bg */, DACBC6092011888C00C4D7E2 /* he */, DAD88E04202ACF7C00AAA536 /* da */, + DAFEB3722093ACDA00A86A83 /* ko */, ); name = Foundation.strings; sourceTree = "<group>"; @@ -1759,6 +1773,7 @@ DA80E95F1FE84A540065FC9B /* ar */, DAD88E05202ACF8200AAA536 /* da */, DA934098208562870059919A /* pt-PT */, + DAFEB3732093ACE400A86A83 /* ko */, ); name = Foundation.stringsdict; sourceTree = "<group>"; @@ -1780,6 +1795,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -1787,6 +1803,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -1837,6 +1854,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -1844,6 +1862,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/CI.xcscheme b/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/CI.xcscheme index 335441cc23..5f1cf773ae 100644 --- a/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/CI.xcscheme +++ b/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/CI.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0920" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -56,7 +56,7 @@ buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" - BlueprintIdentifier = "E933DEF922EF4BC1AD735333" + BlueprintIdentifier = "9EEBD19ABEE247CF8D3CF4C5" BuildableName = "mbgl-test" BlueprintName = "mbgl-test" ReferencedContainer = "container:../../build/macos/mbgl.xcodeproj"> @@ -70,7 +70,7 @@ buildForAnalyzing = "NO"> <BuildableReference BuildableIdentifier = "primary" - BlueprintIdentifier = "1D3EE78DAFFA4A42AFD7160D" + BlueprintIdentifier = "B328AB16ECE141AAAE2A72C8" BuildableName = "mbgl-benchmark" BlueprintName = "mbgl-benchmark" ReferencedContainer = "container:../../build/macos/mbgl.xcodeproj"> @@ -82,7 +82,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -112,7 +111,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme b/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme index 4dadaee743..fc623b22fa 100644 --- a/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme +++ b/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/dynamic.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0920" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" @@ -40,7 +40,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference @@ -70,7 +69,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/macosapp.xcscheme b/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/macosapp.xcscheme index aab7486fbe..ce62359388 100644 --- a/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/macosapp.xcscheme +++ b/platform/macos/macos.xcodeproj/xcshareddata/xcschemes/macosapp.xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0920" + LastUpgradeVersion = "0930" version = "1.3"> <BuildAction parallelizeBuildables = "YES" diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 42fd24653e..bc9ac1e641 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -58,7 +58,7 @@ #import "NSURL+MGLAdditions.h" #import "NSColor+MGLAdditions.h" #import "NSImage+MGLAdditions.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import <QuartzCore/QuartzCore.h> #import <OpenGL/gl.h> @@ -2249,8 +2249,16 @@ public: // The annotation's anchor will bounce to the current click. NSRect positioningRect = [self positioningRectForCalloutForAnnotationWithTag:annotationTag]; + // Check for invalid (zero) positioning rect + if (NSEqualRects(positioningRect, NSZeroRect)) { + CLLocationCoordinate2D origin = annotation.coordinate; + positioningRect.origin = [self convertCoordinate:origin toPointToView:self]; + } + if (!moveOnscreen && NSIsEmptyRect(NSIntersectionRect(positioningRect, self.bounds))) { - positioningRect = CGRectMake(gesturePoint.x, gesturePoint.y, positioningRect.size.width, positioningRect.size.height); + if (!NSEqualPoints(gesturePoint, NSZeroPoint)) { + positioningRect = CGRectMake(gesturePoint.x, gesturePoint.y, positioningRect.size.width, positioningRect.size.height); + } } self.selectedAnnotation = annotation; @@ -2464,6 +2472,8 @@ public: if (callout) { NSRect rect = [self positioningRectForCalloutForAnnotationWithTag:_selectedAnnotationTag]; + NSAssert(!NSEqualRects(rect, NSZeroRect), @"Positioning rect should be non-zero"); + if (!NSIsEmptyRect(NSIntersectionRect(rect, self.bounds))) { // It's possible that the current callout hasn't been presented (since the original diff --git a/platform/macos/src/Mapbox.h b/platform/macos/src/Mapbox.h index fcf41203cf..198998a874 100644 --- a/platform/macos/src/Mapbox.h +++ b/platform/macos/src/Mapbox.h @@ -62,3 +62,4 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLAttributionInfo.h" #import "MGLMapSnapshotter.h" #import "NSExpression+MGLAdditions.h" +#import "NSPredicate+MGLAdditions.h" diff --git a/platform/macos/src/NSColor+MGLAdditions.mm b/platform/macos/src/NSColor+MGLAdditions.mm index 8c9086ccf7..c73c1a41b7 100644 --- a/platform/macos/src/NSColor+MGLAdditions.mm +++ b/platform/macos/src/NSColor+MGLAdditions.mm @@ -79,8 +79,14 @@ components.push_back(component.doubleValue / 255.0); } - // Alpha - components.back() *= 255.0; + + if (components.size() < 4) { + components.push_back(1.0); + } else { + // Alpha + components.back() *= 255.0; + } + // macOS 10.12 Sierra and below uses calibrated RGB by default. if ([NSColor redColor].colorSpaceName == NSCalibratedRGBColorSpace) { diff --git a/platform/macos/test/MGLAnnotationTests.m b/platform/macos/test/MGLAnnotationTests.m new file mode 100644 index 0000000000..36a7aef9f0 --- /dev/null +++ b/platform/macos/test/MGLAnnotationTests.m @@ -0,0 +1,52 @@ +#import <Mapbox/Mapbox.h> +#import <XCTest/XCTest.h> + +@interface MGLAnnotationTests : XCTestCase <MGLMapViewDelegate> +@property (nonatomic) MGLMapView *mapView; +@property (nonatomic) BOOL centerCoordinateDidChange; +@end + +@implementation MGLAnnotationTests + +- (void)setUp +{ + [super setUp]; + _mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)]; + _mapView.delegate = self; +} + +- (void)testSelectingOnscreenAnnotationThatHasNotBeenAdded { + // See https://github.com/mapbox/mapbox-gl-native/issues/11476 + + // This bug occurs under the following conditions: + // + // - There are content insets (e.g. navigation bar) for the compare against + // NSZeroRect + + self.mapView.contentInsets = NSEdgeInsetsMake(10.0, 10.0, 10.0, 10.0); + + // Create annotation + MGLPointFeature *point = [[MGLPointFeature alloc] init]; + point.title = NSStringFromSelector(_cmd); + point.coordinate = CLLocationCoordinate2DMake(0.0, 0.0); + + MGLCoordinateBounds coordinateBounds = [self.mapView convertRect:self.mapView.bounds toCoordinateBoundsFromView:self.mapView]; + XCTAssert(MGLCoordinateInCoordinateBounds(point.coordinate, coordinateBounds), @"The test point should be within the visible map view"); + + [self.mapView addObserver:self forKeyPath:@"centerCoordinate" options:NSKeyValueObservingOptionNew context:_cmd]; + XCTAssertFalse(self.centerCoordinateDidChange, @"Center coordinate should not have changed at this point"); + + // Select on screen annotation (DO NOT ADD FIRST). + [self.mapView selectAnnotation:point]; + + XCTAssertFalse(self.centerCoordinateDidChange, @"Center coordinate should not have changed after selecting a visible annotation"); +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context { + if ((context == @selector(testSelectingOnscreenAnnotationThatHasNotBeenAdded)) && + (object == self.mapView)) { + self.centerCoordinateDidChange = YES; + } +} + +@end diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index fdd9558d0b..cc69a60ca0 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -7,7 +7,6 @@ #include <mbgl/util/math.hpp> #include <mbgl/math/minmax.hpp> #include <mbgl/style/filter.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/tile/tile_id.hpp> #include <mapbox/geometry/envelope.hpp> diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp index bb5b2ddc34..b2d05fe665 100644 --- a/src/mbgl/gl/attribute.cpp +++ b/src/mbgl/gl/attribute.cpp @@ -1,14 +1,20 @@ #include <mbgl/gl/attribute.hpp> +#include <mbgl/gl/context.hpp> #include <mbgl/gl/gl.hpp> namespace mbgl { namespace gl { -void bindAttributeLocation(ProgramID id, AttributeLocation location, const char* name) { - if (location >= MAX_ATTRIBUTES) { - throw gl::Error("too many vertex attributes"); +void bindAttributeLocation(Context& context, ProgramID id, AttributeLocation location, const char* name) { + // We're using sequentially numberered attribute locations starting with 0. Therefore we can use + // the location as a proxy for the number of attributes. + if (location >= context.maximumVertexBindingCount) { + // Don't bind the location on this hardware since it exceeds the limit (otherwise we'd get + // an OpenGL error). This means we'll see rendering errors, and possibly slow rendering due + // to unbound attributes. + } else { + MBGL_CHECK_ERROR(glBindAttribLocation(id, location, name)); } - MBGL_CHECK_ERROR(glBindAttribLocation(id, location, name)); } std::set<std::string> getActiveAttributes(ProgramID id) { diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp index fa6c2ddeab..3763f0a583 100644 --- a/src/mbgl/gl/attribute.hpp +++ b/src/mbgl/gl/attribute.hpp @@ -17,8 +17,6 @@ namespace mbgl { namespace gl { -static constexpr std::size_t MAX_ATTRIBUTES = 8; - template <class> struct DataTypeOf; template <> struct DataTypeOf< int8_t> : std::integral_constant<DataType, DataType::Byte> {}; template <> struct DataTypeOf<uint8_t> : std::integral_constant<DataType, DataType::UnsignedByte> {}; @@ -45,7 +43,7 @@ public: } }; -using AttributeBindingArray = std::array<optional<AttributeBinding>, MAX_ATTRIBUTES>; +using AttributeBindingArray = std::vector<optional<AttributeBinding>>; /* gl::Attribute<T,N> manages the binding of a vertex buffer to a GL program attribute. @@ -214,7 +212,8 @@ const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = { } // namespace detail -void bindAttributeLocation(ProgramID, AttributeLocation, const char * name); +class Context; +void bindAttributeLocation(Context&, ProgramID, AttributeLocation, const char * name); std::set<std::string> getActiveAttributes(ProgramID); template <class... As> @@ -231,13 +230,13 @@ public: using Vertex = detail::Vertex<typename As::Type...>; - static Locations bindLocations(const ProgramID& id) { + static Locations bindLocations(Context& context, const ProgramID& id) { std::set<std::string> activeAttributes = getActiveAttributes(id); AttributeLocation location = 0; auto maybeBindLocation = [&](const char* name) -> optional<AttributeLocation> { if (activeAttributes.count(name)) { - bindAttributeLocation(id, location, name); + bindAttributeLocation(context, id, location, name); return location++; } else { return {}; @@ -277,6 +276,7 @@ public: static AttributeBindingArray toBindingArray(const Locations& locations, const Bindings& bindings) { AttributeBindingArray result; + result.resize(sizeof...(As)); auto maybeAddBinding = [&] (const optional<AttributeLocation>& location, const optional<AttributeBinding>& binding) { @@ -289,6 +289,12 @@ public: return result; } + + static uint32_t activeBindingCount(const Bindings& bindings) { + uint32_t result = 0; + util::ignore({ ((result += bool(bindings.template get<As>())), 0)... }); + return result; + } }; namespace detail { diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index ba44adb42b..c6352d3e84 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -94,7 +94,13 @@ static_assert(underlying_type(BufferUsage::DynamicDraw) == GL_DYNAMIC_DRAW, "Ope static_assert(std::is_same<BinaryProgramFormat, GLenum>::value, "OpenGL type mismatch"); -Context::Context() = default; +Context::Context() + : maximumVertexBindingCount([] { + GLint value; + MBGL_CHECK_ERROR(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value)); + return value; + }()) { +} Context::~Context() { if (cleanupOnDestruction) { @@ -351,7 +357,7 @@ VertexArray Context::createVertexArray() { VertexArrayID id = 0; MBGL_CHECK_ERROR(vertexArray->genVertexArrays(1, &id)); UniqueVertexArray vao(std::move(id), { this }); - return { UniqueVertexArrayState(new VertexArrayState(std::move(vao), *this), VertexArrayStateDeleter { true })}; + return { UniqueVertexArrayState(new VertexArrayState(std::move(vao)), VertexArrayStateDeleter { true })}; } else { // On GL implementations which do not support vertex arrays, attribute bindings are global state. // So return a VertexArray which shares our global state tracking and whose deleter is a no-op. diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 67624288e2..d95311115e 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -226,7 +226,7 @@ public: State<value::BindVertexBuffer> vertexBuffer; State<value::BindVertexArray, const Context&> bindVertexArray { *this }; - VertexArrayState globalVertexArrayState { UniqueVertexArray(0, { this }), *this }; + VertexArrayState globalVertexArrayState { UniqueVertexArray(0, { this }) }; State<value::PixelStorePack> pixelStorePack; State<value::PixelStoreUnpack> pixelStoreUnpack; @@ -239,6 +239,8 @@ public: #endif // MBGL_USE_GLES2 bool supportsHalfFloatTextures = false; + const uint32_t maximumVertexBindingCount; + static constexpr const uint32_t minimumRequiredVertexBindingCount = 8; private: State<value::StencilFunc> stencilFunc; diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index af02ad3d54..f33501cd11 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -35,7 +35,7 @@ public: context.createProgram(context.createShader(ShaderType::Vertex, vertexSource), context.createShader(ShaderType::Fragment, fragmentSource))), uniformsState((context.linkProgram(program), Uniforms::bindLocations(program))), - attributeLocations(Attributes::bindLocations(program)) { + attributeLocations(Attributes::bindLocations(context, program)) { // Re-link program after manually binding only active attributes in Attributes::bindLocations context.linkProgram(program); diff --git a/src/mbgl/gl/vertex_array.cpp b/src/mbgl/gl/vertex_array.cpp index 68a500ac45..d552a8292e 100644 --- a/src/mbgl/gl/vertex_array.cpp +++ b/src/mbgl/gl/vertex_array.cpp @@ -9,7 +9,11 @@ void VertexArray::bind(Context& context, BufferID indexBuffer, const AttributeBi context.bindVertexArray = state->vertexArray; state->indexBuffer = indexBuffer; - for (AttributeLocation location = 0; location < MAX_ATTRIBUTES; ++location) { + state->bindings.reserve(bindings.size()); + for (AttributeLocation location = 0; location < bindings.size(); ++location) { + if (state->bindings.size() <= location) { + state->bindings.emplace_back(context, AttributeLocation(location)); + } state->bindings[location] = bindings[location]; } } diff --git a/src/mbgl/gl/vertex_array.hpp b/src/mbgl/gl/vertex_array.hpp index 46c67017bb..604754f672 100644 --- a/src/mbgl/gl/vertex_array.hpp +++ b/src/mbgl/gl/vertex_array.hpp @@ -15,9 +15,8 @@ class Context; class VertexArrayState { public: - VertexArrayState(UniqueVertexArray vertexArray_, Context& context) - : vertexArray(std::move(vertexArray_)), - bindings(makeBindings(context, std::make_index_sequence<MAX_ATTRIBUTES>())) { + VertexArrayState(UniqueVertexArray vertexArray_) + : vertexArray(std::move(vertexArray_)) { } void setDirty() { @@ -31,13 +30,7 @@ public: State<value::BindElementBuffer> indexBuffer; using AttributeState = State<value::VertexAttribute, Context&, AttributeLocation>; - std::array<AttributeState, MAX_ATTRIBUTES> bindings; - -private: - template <std::size_t... I> - std::array<AttributeState, MAX_ATTRIBUTES> makeBindings(Context& context, std::index_sequence<I...>) { - return {{ AttributeState { context, I }... }}; - } + std::vector<AttributeState> bindings; }; class VertexArrayStateDeleter { diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index b2f6fd450f..4249ffc24e 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -2,7 +2,6 @@ #include <mbgl/layout/merge_lines.hpp> #include <mbgl/layout/clip_lines.hpp> #include <mbgl/renderer/buckets/symbol_bucket.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/renderer/bucket_parameters.hpp> #include <mbgl/renderer/layers/render_symbol_layer.hpp> #include <mbgl/renderer/image_atlas.hpp> diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp index bcdb270b9c..4d5de05337 100644 --- a/src/mbgl/programs/program.hpp +++ b/src/mbgl/programs/program.hpp @@ -46,26 +46,38 @@ public: Shaders::fragmentSource)) { } + static typename AllUniforms::Values computeAllUniformValues( + const UniformValues& uniformValues, + const PaintPropertyBinders& paintPropertyBinders, + const typename PaintProperties::PossiblyEvaluated& currentProperties, + float currentZoom) { + return uniformValues + .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); + } + + static typename Attributes::Bindings computeAllAttributeBindings( + const gl::VertexBuffer<LayoutVertex>& layoutVertexBuffer, + const PaintPropertyBinders& paintPropertyBinders, + const typename PaintProperties::PossiblyEvaluated& currentProperties) { + return LayoutAttributes::bindings(layoutVertexBuffer) + .concat(paintPropertyBinders.attributeBindings(currentProperties)); + } + + static uint32_t activeBindingCount(const typename Attributes::Bindings& allAttributeBindings) { + return Attributes::activeBindingCount(allAttributeBindings); + } + template <class DrawMode> void draw(gl::Context& context, DrawMode drawMode, gl::DepthMode depthMode, gl::StencilMode stencilMode, gl::ColorMode colorMode, - const UniformValues& uniformValues, - const gl::VertexBuffer<LayoutVertex>& layoutVertexBuffer, const gl::IndexBuffer<DrawMode>& indexBuffer, const SegmentVector<Attributes>& segments, - const PaintPropertyBinders& paintPropertyBinders, - const typename PaintProperties::PossiblyEvaluated& currentProperties, - float currentZoom, + const typename AllUniforms::Values& allUniformValues, + const typename Attributes::Bindings& allAttributeBindings, const std::string& layerID) { - typename AllUniforms::Values allUniformValues = uniformValues - .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - - typename Attributes::Bindings allAttributeBindings = LayoutAttributes::bindings(layoutVertexBuffer) - .concat(paintPropertyBinders.attributeBindings(currentProperties)); - for (auto& segment : segments) { auto vertexArrayIt = segment.vertexArrays.find(layerID); diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index 9b5037ed9f..51f9a48f7f 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -278,35 +278,45 @@ public: Shaders::fragmentSource)) { } + static typename AllUniforms::Values computeAllUniformValues( + const UniformValues& uniformValues, + const SymbolSizeBinder& symbolSizeBinder, + const PaintPropertyBinders& paintPropertyBinders, + const typename PaintProperties::PossiblyEvaluated& currentProperties, + float currentZoom) { + return uniformValues.concat(symbolSizeBinder.uniformValues(currentZoom)) + .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); + } + + static typename Attributes::Bindings computeAllAttributeBindings( + const gl::VertexBuffer<LayoutVertex>& layoutVertexBuffer, + const gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>& dynamicLayoutVertexBuffer, + const gl::VertexBuffer<SymbolOpacityAttributes::Vertex>& opacityVertexBuffer, + const PaintPropertyBinders& paintPropertyBinders, + const typename PaintProperties::PossiblyEvaluated& currentProperties) { + assert(layoutVertexBuffer.vertexCount == dynamicLayoutVertexBuffer.vertexCount && + layoutVertexBuffer.vertexCount == opacityVertexBuffer.vertexCount); + return LayoutAttributes::bindings(layoutVertexBuffer) + .concat(SymbolDynamicLayoutAttributes::bindings(dynamicLayoutVertexBuffer)) + .concat(SymbolOpacityAttributes::bindings(opacityVertexBuffer)) + .concat(paintPropertyBinders.attributeBindings(currentProperties)); + } + + static uint32_t activeBindingCount(const typename Attributes::Bindings& allAttributeBindings) { + return Attributes::activeBindingCount(allAttributeBindings); + } + template <class DrawMode> void draw(gl::Context& context, DrawMode drawMode, gl::DepthMode depthMode, gl::StencilMode stencilMode, gl::ColorMode colorMode, - const UniformValues& uniformValues, - const gl::VertexBuffer<LayoutVertex>& layoutVertexBuffer, - const gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>& dynamicLayoutVertexBuffer, - const gl::VertexBuffer<SymbolOpacityAttributes::Vertex>& opacityVertexBuffer, - const SymbolSizeBinder& symbolSizeBinder, const gl::IndexBuffer<DrawMode>& indexBuffer, const SegmentVector<Attributes>& segments, - const PaintPropertyBinders& paintPropertyBinders, - const typename PaintProperties::PossiblyEvaluated& currentProperties, - float currentZoom, + const typename AllUniforms::Values& allUniformValues, + const typename Attributes::Bindings& allAttributeBindings, const std::string& layerID) { - typename AllUniforms::Values allUniformValues = uniformValues - .concat(symbolSizeBinder.uniformValues(currentZoom)) - .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - - typename Attributes::Bindings allAttributeBindings = LayoutAttributes::bindings(layoutVertexBuffer) - .concat(SymbolDynamicLayoutAttributes::bindings(dynamicLayoutVertexBuffer)) - .concat(SymbolOpacityAttributes::bindings(opacityVertexBuffer)) - .concat(paintPropertyBinders.attributeBindings(currentProperties)); - - assert(layoutVertexBuffer.vertexCount == dynamicLayoutVertexBuffer.vertexCount && - layoutVertexBuffer.vertexCount == opacityVertexBuffer.vertexCount); - for (auto& segment : segments) { auto vertexArrayIt = segment.vertexArrays.find(layerID); diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp index 44c3fffb6c..2dc5fe7339 100644 --- a/src/mbgl/renderer/layers/render_background_layer.cpp +++ b/src/mbgl/renderer/layers/render_background_layer.cpp @@ -50,6 +50,35 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { const Properties<>::PossiblyEvaluated properties; const BackgroundProgram::PaintPropertyBinders paintAttributeData(properties, 0); + auto draw = [&](auto& program, auto&& uniformValues) { + const auto allUniformValues = program.computeAllUniformValues( + std::move(uniformValues), + paintAttributeData, + properties, + parameters.state.getZoom() + ); + const auto allAttributeBindings = program.computeAllAttributeBindings( + parameters.staticData.tileVertexBuffer, + paintAttributeData, + properties + ); + + checkRenderability(parameters, program.activeBindingCount(allAttributeBindings)); + + program.draw( + parameters.context, + gl::Triangles(), + parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), + parameters.staticData.quadTriangleIndexBuffer, + parameters.staticData.tileTriangleSegments, + allUniformValues, + allAttributeBindings, + getID() + ); + }; + if (!evaluated.get<BackgroundPattern>().to.empty()) { optional<ImagePosition> imagePosA = parameters.imageManager.getPattern(evaluated.get<BackgroundPattern>().from); optional<ImagePosition> imagePosB = parameters.imageManager.getPattern(evaluated.get<BackgroundPattern>().to); @@ -60,12 +89,8 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { parameters.imageManager.bind(parameters.context, 0); for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) { - parameters.programs.backgroundPattern.draw( - parameters.context, - gl::Triangles(), - parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), - gl::StencilMode::disabled(), - parameters.colorModeForRenderPass(), + draw( + parameters.programs.backgroundPattern, BackgroundPatternUniforms::values( parameters.matrixForTile(tileID), evaluated.get<BackgroundOpacity>(), @@ -75,36 +100,18 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { evaluated.get<BackgroundPattern>(), tileID, parameters.state - ), - parameters.staticData.tileVertexBuffer, - parameters.staticData.quadTriangleIndexBuffer, - parameters.staticData.tileTriangleSegments, - paintAttributeData, - properties, - parameters.state.getZoom(), - getID() + ) ); } } else { for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) { - parameters.programs.background.draw( - parameters.context, - gl::Triangles(), - parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), - gl::StencilMode::disabled(), - parameters.colorModeForRenderPass(), + draw( + parameters.programs.background, BackgroundProgram::UniformValues { uniforms::u_matrix::Value{ parameters.matrixForTile(tileID) }, uniforms::u_color::Value{ evaluated.get<BackgroundColor>() }, uniforms::u_opacity::Value{ evaluated.get<BackgroundOpacity>() }, - }, - parameters.staticData.tileVertexBuffer, - parameters.staticData.quadTriangleIndexBuffer, - parameters.staticData.tileTriangleSegments, - paintAttributeData, - properties, - parameters.state.getZoom(), - getID() + } ); } } diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index 56fccfe071..b433a9d3fa 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -59,14 +59,11 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) { assert(dynamic_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl))); CircleBucket& bucket = *reinterpret_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl)); - parameters.programs.circle.get(evaluated).draw( - parameters.context, - gl::Triangles(), - parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), - parameters.mapMode != MapMode::Continuous - ? parameters.stencilModeForClipping(tile.clip) - : gl::StencilMode::disabled(), - parameters.colorModeForRenderPass(), + const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); + + auto& programInstance = parameters.programs.circle.get(evaluated); + + const auto allUniformValues = programInstance.computeAllUniformValues( CircleProgram::UniformValues { uniforms::u_matrix::Value{ tile.translatedMatrix(evaluated.get<CircleTranslate>(), @@ -82,12 +79,30 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) { uniforms::u_camera_to_center_distance::Value{ parameters.state.getCameraToCenterDistance() }, uniforms::u_pitch_with_map::Value{ pitchWithMap } }, + paintPropertyBinders, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( *bucket.vertexBuffer, + paintPropertyBinders, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), + parameters.mapMode != MapMode::Continuous + ? parameters.stencilModeForClipping(tile.clip) + : gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), *bucket.indexBuffer, bucket.segments, - bucket.paintPropertyBinders.at(getID()), - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); } diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 871464223c..d5282c9b0d 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -68,24 +68,53 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* parameters.context.setStencilMode(gl::StencilMode::disabled()); parameters.context.clear(Color{ 0.0f, 0.0f, 0.0f, 0.0f }, depthClearValue, {}); + auto draw = [&](auto& programInstance, const auto& tileBucket, auto&& uniformValues) { + const auto& paintPropertyBinders = tileBucket.paintPropertyBinders.at(getID()); + + const auto allUniformValues = programInstance.computeAllUniformValues( + std::move(uniformValues), + paintPropertyBinders, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( + *tileBucket.vertexBuffer, + paintPropertyBinders, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + parameters.depthModeFor3D(gl::DepthMode::ReadWrite), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), + *tileBucket.indexBuffer, + tileBucket.triangleSegments, + allUniformValues, + allAttributeBindings, + getID()); + }; + if (evaluated.get<FillExtrusionPattern>().from.empty()) { for (const RenderTile& tile : renderTiles) { assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl))); FillExtrusionBucket& bucket = *reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)); - parameters.programs.fillExtrusion.get(evaluated).draw( - parameters.context, gl::Triangles(), - parameters.depthModeFor3D(gl::DepthMode::ReadWrite), - gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), + draw( + parameters.programs.fillExtrusion.get(evaluated), + bucket, FillExtrusionUniforms::values( tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), evaluated.get<FillExtrusionTranslateAnchor>(), parameters.state), - parameters.state, parameters.evaluatedLight), - *bucket.vertexBuffer, *bucket.indexBuffer, bucket.triangleSegments, - bucket.paintPropertyBinders.at(getID()), evaluated, parameters.state.getZoom(), - getID()); + parameters.state, + parameters.evaluatedLight + ) + ); } } else { optional<ImagePosition> imagePosA = @@ -104,10 +133,9 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* FillExtrusionBucket& bucket = *reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)); - parameters.programs.fillExtrusionPattern.get(evaluated).draw( - parameters.context, gl::Triangles(), - parameters.depthModeFor3D(gl::DepthMode::ReadWrite), - gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), + draw( + parameters.programs.fillExtrusionPattern.get(evaluated), + bucket, FillExtrusionPatternUniforms::values( tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), evaluated.get<FillExtrusionTranslateAnchor>(), @@ -115,10 +143,9 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* parameters.imageManager.getPixelSize(), *imagePosA, *imagePosB, evaluated.get<FillExtrusionPattern>(), tile.id, parameters.state, -std::pow(2, tile.id.canonical.z) / util::tileSize / 8.0f, - parameters.evaluatedLight), - *bucket.vertexBuffer, *bucket.indexBuffer, bucket.triangleSegments, - bucket.paintPropertyBinders.at(getID()), evaluated, parameters.state.getZoom(), - getID()); + parameters.evaluatedLight + ) + ); } } @@ -131,19 +158,39 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1); const Properties<>::PossiblyEvaluated properties; + const ExtrusionTextureProgram::PaintPropertyBinders paintAttributeData{ properties, 0 }; + + auto& programInstance = parameters.programs.extrusionTexture; - parameters.programs.extrusionTexture.draw( - parameters.context, gl::Triangles(), gl::DepthMode::disabled(), - gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), + const auto allUniformValues = programInstance.computeAllUniformValues( ExtrusionTextureProgram::UniformValues{ uniforms::u_matrix::Value{ viewportMat }, uniforms::u_world::Value{ size }, uniforms::u_image::Value{ 0 }, - uniforms::u_opacity::Value{ evaluated.get<FillExtrusionOpacity>() } }, + uniforms::u_opacity::Value{ evaluated.get<FillExtrusionOpacity>() } + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( parameters.staticData.extrusionTextureVertexBuffer, + paintAttributeData, + properties + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + gl::DepthMode::disabled(), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.extrusionTextureSegments, - ExtrusionTextureProgram::PaintPropertyBinders{ properties, 0 }, properties, - parameters.state.getZoom(), getID()); + allUniformValues, + allAttributeBindings, + getID()); } } diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index efd3f4215c..c59ca6f906 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -69,12 +69,11 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { const auto& depthMode, const auto& indexBuffer, const auto& segments) { - program.get(evaluated).draw( - parameters.context, - drawMode, - depthMode, - parameters.stencilModeForClipping(tile.clip), - parameters.colorModeForRenderPass(), + auto& programInstance = program.get(evaluated); + + const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); + + const auto allUniformValues = programInstance.computeAllUniformValues( FillProgram::UniformValues { uniforms::u_matrix::Value{ tile.translatedMatrix(evaluated.get<FillTranslate>(), @@ -83,12 +82,28 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { }, uniforms::u_world::Value{ parameters.context.viewport.getCurrentValue().size }, }, + paintPropertyBinders, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( *bucket.vertexBuffer, + paintPropertyBinders, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + drawMode, + depthMode, + parameters.stencilModeForClipping(tile.clip), + parameters.colorModeForRenderPass(), indexBuffer, segments, - bucket.paintPropertyBinders.at(getID()), - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); }; @@ -139,12 +154,11 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { const auto& depthMode, const auto& indexBuffer, const auto& segments) { - program.get(evaluated).draw( - parameters.context, - drawMode, - depthMode, - parameters.stencilModeForClipping(tile.clip), - parameters.colorModeForRenderPass(), + auto& programInstance = program.get(evaluated); + + const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); + + const auto allUniformValues = programInstance.computeAllUniformValues( FillPatternUniforms::values( tile.translatedMatrix(evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(), @@ -157,12 +171,28 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { tile.id, parameters.state ), + paintPropertyBinders, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( *bucket.vertexBuffer, + paintPropertyBinders, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + drawMode, + depthMode, + parameters.stencilModeForClipping(tile.clip), + parameters.colorModeForRenderPass(), indexBuffer, segments, - bucket.paintPropertyBinders.at(getID()), - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); }; diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index 72c60446aa..dec9edb318 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -92,23 +92,38 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) { ? parameters.stencilModeForClipping(tile.clip) : gl::StencilMode::disabled(); - parameters.programs.heatmap.get(evaluated).draw( + const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); + + auto& programInstance = parameters.programs.heatmap.get(evaluated); + + const auto allUniformValues = programInstance.computeAllUniformValues( + HeatmapProgram::UniformValues { + uniforms::u_intensity::Value{ evaluated.get<style::HeatmapIntensity>() }, + uniforms::u_matrix::Value{ tile.matrix }, + uniforms::heatmap::u_extrude_scale::Value{ extrudeScale } + }, + paintPropertyBinders, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( + *bucket.vertexBuffer, + paintPropertyBinders, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( parameters.context, gl::Triangles(), parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), stencilMode, gl::ColorMode::additive(), - HeatmapProgram::UniformValues { - uniforms::u_intensity::Value{evaluated.get<style::HeatmapIntensity>()}, - uniforms::u_matrix::Value{tile.matrix}, - uniforms::heatmap::u_extrude_scale::Value{extrudeScale} - }, - *bucket.vertexBuffer, *bucket.indexBuffer, bucket.segments, - bucket.paintPropertyBinders.at(getID()), - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); } @@ -123,20 +138,41 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) { matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1); const Properties<>::PossiblyEvaluated properties; + const HeatmapTextureProgram::PaintPropertyBinders paintAttributeData{ properties, 0 }; + + auto& programInstance = parameters.programs.heatmapTexture; - parameters.programs.heatmapTexture.draw( - parameters.context, gl::Triangles(), gl::DepthMode::disabled(), - gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), + const auto allUniformValues = programInstance.computeAllUniformValues( HeatmapTextureProgram::UniformValues{ uniforms::u_matrix::Value{ viewportMat }, uniforms::u_world::Value{ size }, uniforms::u_image::Value{ 0 }, uniforms::u_color_ramp::Value{ 1 }, - uniforms::u_opacity::Value{ evaluated.get<HeatmapOpacity>() } }, + uniforms::u_opacity::Value{ evaluated.get<HeatmapOpacity>() } + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( parameters.staticData.extrusionTextureVertexBuffer, + paintAttributeData, + properties + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + gl::DepthMode::disabled(), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.extrusionTextureSegments, - HeatmapTextureProgram::PaintPropertyBinders{ properties, 0 }, properties, - parameters.state.getZoom(), getID()); + allUniformValues, + allAttributeBindings, + getID() + ); } } diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index bcfd4ffe99..411305edf4 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -69,12 +69,11 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src const auto& indexBuffer, const auto& segments, const UnwrappedTileID& id) { - parameters.programs.hillshade.draw( - parameters.context, - gl::Triangles(), - parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), - gl::StencilMode::disabled(), - parameters.colorModeForRenderPass(), + auto& programInstance = parameters.programs.hillshade; + + const HillshadeProgram::PaintPropertyBinders paintAttributeData{ evaluated, 0 }; + + const auto allUniformValues = programInstance.computeAllUniformValues( HillshadeProgram::UniformValues { uniforms::u_matrix::Value{ matrix }, uniforms::u_image::Value{ 0 }, @@ -84,12 +83,28 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src uniforms::u_light::Value{ getLight(parameters) }, uniforms::u_latrange::Value{ getLatRange(id) }, }, + paintAttributeData, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( vertexBuffer, + paintAttributeData, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), indexBuffer, segments, - HillshadeProgram::PaintPropertyBinders { evaluated, 0 }, - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); }; @@ -112,13 +127,11 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src parameters.context.bindTexture(*bucket.dem, 0, gl::TextureFilter::Nearest, gl::TextureMipMap::No, gl::TextureWrap::Clamp, gl::TextureWrap::Clamp); const Properties<>::PossiblyEvaluated properties; + const HillshadePrepareProgram::PaintPropertyBinders paintAttributeData{ properties, 0 }; - parameters.programs.hillshadePrepare.draw( - parameters.context, - gl::Triangles(), - parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), - gl::StencilMode::disabled(), - parameters.colorModeForRenderPass(), + auto& programInstance = parameters.programs.hillshadePrepare; + + const auto allUniformValues = programInstance.computeAllUniformValues( HillshadePrepareProgram::UniformValues { uniforms::u_matrix::Value { mat }, uniforms::u_dimension::Value { {{uint16_t(tilesize * 2), uint16_t(tilesize * 2) }} }, @@ -126,12 +139,28 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src uniforms::u_maxzoom::Value{ float(maxzoom) }, uniforms::u_image::Value{ 0 } }, + paintAttributeData, + properties, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( parameters.staticData.rasterVertexBuffer, + paintAttributeData, + properties + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.rasterSegments, - HillshadePrepareProgram::PaintPropertyBinders { properties, 0 }, - properties, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); bucket.texture = std::move(view.getTexture()); diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 02f61af0fa..361ad0c76b 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -62,19 +62,34 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) { LineBucket& bucket = *reinterpret_cast<LineBucket*>(tile.tile.getBucket(*baseImpl)); auto draw = [&] (auto& program, auto&& uniformValues) { - program.get(evaluated).draw( + auto& programInstance = program.get(evaluated); + + const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); + + const auto allUniformValues = programInstance.computeAllUniformValues( + std::move(uniformValues), + paintPropertyBinders, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( + *bucket.vertexBuffer, + paintPropertyBinders, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( parameters.context, gl::Triangles(), parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), parameters.stencilModeForClipping(tile.clip), parameters.colorModeForRenderPass(), - std::move(uniformValues), - *bucket.vertexBuffer, *bucket.indexBuffer, bucket.segments, - bucket.paintPropertyBinders.at(getID()), - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); }; diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index b41b2ac560..f202ed4ebb 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -73,16 +73,15 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source if (parameters.pass != RenderPass::Translucent) return; + RasterProgram::PaintPropertyBinders paintAttributeData{ evaluated, 0 }; + auto draw = [&] (const mat4& matrix, const auto& vertexBuffer, const auto& indexBuffer, const auto& segments) { - parameters.programs.raster.draw( - parameters.context, - gl::Triangles(), - parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), - gl::StencilMode::disabled(), - parameters.colorModeForRenderPass(), + auto& programInstance = parameters.programs.raster; + + const auto allUniformValues = programInstance.computeAllUniformValues( RasterProgram::UniformValues { uniforms::u_matrix::Value{ matrix }, uniforms::u_image0::Value{ 0 }, @@ -98,12 +97,28 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source uniforms::u_scale_parent::Value{ 1.0f }, uniforms::u_tl_parent::Value{ std::array<float, 2> {{ 0.0f, 0.0f }} }, }, + paintAttributeData, + evaluated, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( vertexBuffer, + paintAttributeData, + evaluated + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( + parameters.context, + gl::Triangles(), + parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), + gl::StencilMode::disabled(), + parameters.colorModeForRenderPass(), indexBuffer, segments, - RasterProgram::PaintPropertyBinders { evaluated, 0 }, - evaluated, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); }; diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 9e493003c0..e48c0e2f92 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -88,7 +88,26 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { const auto& binders, const auto& paintProperties) { - program.get(paintProperties).draw( + auto& programInstance = program.get(paintProperties); + + const auto allUniformValues = programInstance.computeAllUniformValues( + std::move(uniformValues), + *symbolSizeBinder, + binders, + paintProperties, + parameters.state.getZoom() + ); + const auto allAttributeBindings = programInstance.computeAllAttributeBindings( + *buffers.vertexBuffer, + *buffers.dynamicVertexBuffer, + *buffers.opacityVertexBuffer, + binders, + paintProperties + ); + + checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings)); + + programInstance.draw( parameters.context, gl::Triangles(), values_.pitchAlignment == AlignmentType::Map @@ -96,16 +115,10 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { : gl::DepthMode::disabled(), gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), - std::move(uniformValues), - *buffers.vertexBuffer, - *buffers.dynamicVertexBuffer, - *buffers.opacityVertexBuffer, - *symbolSizeBinder, *buffers.indexBuffer, buffers.segments, - binders, - paintProperties, - parameters.state.getZoom(), + allUniformValues, + allAttributeBindings, getID() ); }; diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index bcdc175f14..a667d5837e 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -9,8 +9,10 @@ #include <mbgl/renderer/layers/render_raster_layer.hpp> #include <mbgl/renderer/layers/render_symbol_layer.hpp> #include <mbgl/renderer/layers/render_heatmap_layer.hpp> +#include <mbgl/renderer/paint_parameters.hpp> #include <mbgl/style/types.hpp> #include <mbgl/renderer/render_tile.hpp> +#include <mbgl/util/logging.hpp> namespace mbgl { @@ -73,5 +75,32 @@ void RenderLayer::setRenderTiles(std::vector<std::reference_wrapper<RenderTile>> renderTiles = std::move(tiles); } +void RenderLayer::checkRenderability(const PaintParameters& parameters, + const uint32_t activeBindingCount) { + // Only warn once for every layer. + if (hasRenderFailures) { + return; + } + + if (activeBindingCount > parameters.context.maximumVertexBindingCount) { + Log::Error(Event::OpenGL, + "The layer '%s' uses more data-driven properties than the current device " + "supports, and will have rendering errors. To ensure compatibility with this " + "device, use %d fewer data driven properties in this layer.", + getID().c_str(), + activeBindingCount - parameters.context.minimumRequiredVertexBindingCount); + hasRenderFailures = true; + } else if (activeBindingCount > parameters.context.minimumRequiredVertexBindingCount) { + Log::Error(Event::OpenGL, + "The layer '%s' uses more data-driven properties than some devices may support. " + "Though it will render correctly on this device, it may have rendering errors " + "on other devices. To ensure compatibility with all devices, use %d fewer " + "data-driven properties in this layer.", + getID().c_str(), + activeBindingCount - parameters.context.minimumRequiredVertexBindingCount); + hasRenderFailures = true; + } +} + } //namespace mbgl diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index 04a1608564..3e2f1d7525 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -85,6 +85,11 @@ public: friend std::string layoutKey(const RenderLayer&); protected: + // Checks whether the current hardware can render this layer. If it can't, we'll show a warning + // in the console to inform the developer. + void checkRenderability(const PaintParameters&, uint32_t activeBindingCount); + +protected: // renderTiles are exposed directly to CrossTileSymbolIndex and Placement so they // can update opacities in the symbol buckets immediately before rendering friend class CrossTileSymbolIndex; @@ -95,6 +100,12 @@ protected: // Stores what render passes this layer is currently enabled for. This depends on the // evaluated StyleProperties object and is updated accordingly. RenderPass passes = RenderPass::None; + +private: + // Some layers may not render correctly on some hardware when the vertex attribute limit of + // that GPU is exceeded. More attributes are used when adding many data driven paint properties + // to a layer. + bool hasRenderFailures = false; }; } // namespace mbgl diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp index 35b34833e4..64790938ef 100644 --- a/src/mbgl/renderer/render_tile.cpp +++ b/src/mbgl/renderer/render_tile.cpp @@ -74,6 +74,8 @@ void RenderTile::finishRender(PaintParameters& parameters) { static const style::Properties<>::PossiblyEvaluated properties {}; static const DebugProgram::PaintPropertyBinders paintAttributeData(properties, 0); + auto& program = parameters.programs.debug; + if (parameters.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) { if (!tile.debugBucket || tile.debugBucket->renderable != tile.isRenderable() || tile.debugBucket->complete != tile.isComplete() || @@ -85,41 +87,51 @@ void RenderTile::finishRender(PaintParameters& parameters) { tile.expires, parameters.debugOptions, parameters.context); } - parameters.programs.debug.draw( + const auto allAttributeBindings = program.computeAllAttributeBindings( + *tile.debugBucket->vertexBuffer, + paintAttributeData, + properties + ); + + program.draw( parameters.context, gl::Lines { 4.0f * parameters.pixelRatio }, gl::DepthMode::disabled(), parameters.stencilModeForClipping(clip), gl::ColorMode::unblended(), - DebugProgram::UniformValues { - uniforms::u_matrix::Value{ matrix }, - uniforms::u_color::Value{ Color::white() } - }, - *tile.debugBucket->vertexBuffer, *tile.debugBucket->indexBuffer, tile.debugBucket->segments, - paintAttributeData, - properties, - parameters.state.getZoom(), + program.computeAllUniformValues( + DebugProgram::UniformValues { + uniforms::u_matrix::Value{ matrix }, + uniforms::u_color::Value{ Color::white() } + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ), + allAttributeBindings, "debug" ); - parameters.programs.debug.draw( + program.draw( parameters.context, gl::Lines { 2.0f * parameters.pixelRatio }, gl::DepthMode::disabled(), parameters.stencilModeForClipping(clip), gl::ColorMode::unblended(), - DebugProgram::UniformValues { - uniforms::u_matrix::Value{ matrix }, - uniforms::u_color::Value{ Color::black() } - }, - *tile.debugBucket->vertexBuffer, *tile.debugBucket->indexBuffer, tile.debugBucket->segments, - paintAttributeData, - properties, - parameters.state.getZoom(), + program.computeAllUniformValues( + DebugProgram::UniformValues { + uniforms::u_matrix::Value{ matrix }, + uniforms::u_color::Value{ Color::black() } + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ), + allAttributeBindings, "debug" ); } @@ -131,16 +143,22 @@ void RenderTile::finishRender(PaintParameters& parameters) { gl::DepthMode::disabled(), parameters.stencilModeForClipping(clip), gl::ColorMode::unblended(), - DebugProgram::UniformValues { - uniforms::u_matrix::Value{ matrix }, - uniforms::u_color::Value{ Color::red() } - }, - parameters.staticData.tileVertexBuffer, parameters.staticData.tileBorderIndexBuffer, parameters.staticData.tileBorderSegments, - paintAttributeData, - properties, - parameters.state.getZoom(), + program.computeAllUniformValues( + DebugProgram::UniformValues { + uniforms::u_matrix::Value{ matrix }, + uniforms::u_color::Value{ Color::red() } + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ), + program.computeAllAttributeBindings( + parameters.staticData.tileVertexBuffer, + paintAttributeData, + properties + ), "debug" ); } diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index ded07a0909..4380ef24a1 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -486,7 +486,9 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { static const ClippingMaskProgram::PaintPropertyBinders paintAttributeData(properties, 0); for (const auto& clipID : parameters.clipIDGenerator.getClipIDs()) { - parameters.staticData.programs.clippingMask.draw( + auto& program = parameters.staticData.programs.clippingMask; + + program.draw( parameters.context, gl::Triangles(), gl::DepthMode::disabled(), @@ -499,15 +501,21 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { gl::StencilMode::Replace }, gl::ColorMode::disabled(), - ClippingMaskProgram::UniformValues { - uniforms::u_matrix::Value{ parameters.matrixForTile(clipID.first) }, - }, - parameters.staticData.tileVertexBuffer, parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.tileTriangleSegments, - paintAttributeData, - properties, - parameters.state.getZoom(), + program.computeAllUniformValues( + ClippingMaskProgram::UniformValues { + uniforms::u_matrix::Value{ parameters.matrixForTile(clipID.first) }, + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ), + program.computeAllAttributeBindings( + parameters.staticData.tileVertexBuffer, + paintAttributeData, + properties + ), "clipping" ); } diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp index 5c497e8144..dce5e40185 100644 --- a/src/mbgl/renderer/sources/render_image_source.cpp +++ b/src/mbgl/renderer/sources/render_image_source.cpp @@ -58,24 +58,32 @@ void RenderImageSource::finishRender(PaintParameters& parameters) { static const style::Properties<>::PossiblyEvaluated properties {}; static const DebugProgram::PaintPropertyBinders paintAttributeData(properties, 0); + auto& programInstance = parameters.programs.debug; + for (auto matrix : matrices) { - parameters.programs.debug.draw( + programInstance.draw( parameters.context, gl::LineStrip { 4.0f * parameters.pixelRatio }, gl::DepthMode::disabled(), gl::StencilMode::disabled(), gl::ColorMode::unblended(), - DebugProgram::UniformValues { - uniforms::u_matrix::Value{ matrix }, - uniforms::u_color::Value{ Color::red() } - }, - parameters.staticData.tileVertexBuffer, parameters.staticData.tileBorderIndexBuffer, parameters.staticData.tileBorderSegments, - paintAttributeData, - properties, - parameters.state.getZoom(), - "debug" + programInstance.computeAllUniformValues( + DebugProgram::UniformValues { + uniforms::u_matrix::Value{ matrix }, + uniforms::u_color::Value{ Color::red() } + }, + paintAttributeData, + properties, + parameters.state.getZoom() + ), + programInstance.computeAllAttributeBindings( + parameters.staticData.tileVertexBuffer, + paintAttributeData, + properties + ), + "image" ); } } diff --git a/src/mbgl/style/conversion/filter.cpp b/src/mbgl/style/conversion/filter.cpp index 3c941945fd..386d85e921 100644 --- a/src/mbgl/style/conversion/filter.cpp +++ b/src/mbgl/style/conversion/filter.cpp @@ -1,17 +1,39 @@ #include <mbgl/style/conversion/filter.hpp> +#include <mbgl/style/expression/literal.hpp> #include <mbgl/util/geometry.hpp> #include <mbgl/style/expression/expression.hpp> #include <mbgl/style/expression/type.hpp> -#include <mbgl/style/expression/parsing_context.hpp> +#include <mbgl/style/expression/compound_expression.hpp> +#include <mbgl/style/expression/boolean_operator.hpp> namespace mbgl { namespace style { namespace conversion { -using GeometryValue = mapbox::geometry::value; +using namespace mbgl::style::expression; + +static bool isExpression(const Convertible& filter); +std::unique_ptr<Expression> convertLegacyFilter(const Convertible& values, Error& error); + +optional<Filter> Converter<Filter>::operator()(const Convertible& value, Error& error) const { + if (isExpression(value)) { + ParsingContext parsingContext(type::Boolean); + ParseResult parseResult = parsingContext.parseExpression(value); + if (!parseResult) { + error = { parsingContext.getCombinedErrors() }; + return {}; + } else { + return { Filter(std::move(parseResult)) }; + } + } else { + std::unique_ptr<Expression> expression = convertLegacyFilter(value, error); + if (!expression) return {}; + return Filter(optional<std::unique_ptr<Expression>>(std::move(expression))); + } +} // This is a port from https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/feature_filter/index.js -static bool isExpressionFilter(const Convertible& filter) { +bool isExpression(const Convertible& filter) { if (!isArray(filter) || arrayLength(filter) == 0) { return false; } @@ -20,7 +42,7 @@ static bool isExpressionFilter(const Convertible& filter) { if (!op) { return false; - + } else if (*op == "has") { if (arrayLength(filter) < 2) return false; optional<std::string> operand = toString(arrayMember(filter, 1)); @@ -35,7 +57,7 @@ static bool isExpressionFilter(const Convertible& filter) { } else if (*op == "any" || *op == "all") { for (std::size_t i = 1; i < arrayLength(filter); i++) { Convertible f = arrayMember(filter, i); - if (!isExpressionFilter(f) && !toBool(f)) { + if (!isExpression(f) && !toBool(f)) { return false; } } @@ -46,257 +68,136 @@ static bool isExpressionFilter(const Convertible& filter) { } } -static optional<GeometryValue> normalizeValue(const optional<GeometryValue>& value, Error& error) { - if (!value) { - error = { "filter expression value must be a boolean, number, or string" }; - return {}; - } else { - return *value; - } -} +std::unique_ptr<Expression> createExpression(std::string op, std::vector<std::unique_ptr<Expression>> args, Error& error) { + if (op == "any") { + return std::make_unique<Any>(std::move(args)); + + } else if (op == "all") { + return std::make_unique<All>(std::move(args)); -static optional<FeatureType> toFeatureType(const Convertible& value, Error& error) { - optional<std::string> type = toString(value); - if (!type) { - error = { "value for $type filter must be a string" }; - return {}; - } else if (*type == "Point") { - return FeatureType::Point; - } else if (*type == "LineString") { - return FeatureType::LineString; - } else if (*type == "Polygon") { - return FeatureType::Polygon; } else { - error = { "value for $type filter must be Point, LineString, or Polygon" }; - return {}; + ParsingContext parsingContext(type::Boolean); + ParseResult parseResult = createCompoundExpression(op, std::move(args), parsingContext); + if (!parseResult) { + error = { parsingContext.getCombinedErrors() }; + return {}; + } else { + return std::move(*parseResult); + } } } -static optional<FeatureIdentifier> toFeatureIdentifier(const Convertible& value, Error& error) { - optional<GeometryValue> identifier = toValue(value); - if (!identifier) { - error = { "filter expression value must be a boolean, number, or string" }; - return {}; - } else { - return (*identifier).match( - [] (uint64_t t) -> optional<FeatureIdentifier> { return { t }; }, - [] ( int64_t t) -> optional<FeatureIdentifier> { return { t }; }, - [] ( double t) -> optional<FeatureIdentifier> { return { t }; }, - [] (const std::string& t) -> optional<FeatureIdentifier> { return { t }; }, - [&] (const auto&) -> optional<FeatureIdentifier> { - error = { "filter expression value must be a boolean, number, or string" }; - return {}; - }); - } +std::unique_ptr<Expression> createExpression(std::string op, std::unique_ptr<Expression> expression, Error& error) { + std::vector<std::unique_ptr<Expression>> args; + args.push_back(std::move(expression)); + return createExpression(op, std::move(args), error); } -template <class FilterType, class IdentifierFilterType> -optional<Filter> convertUnaryFilter(const Convertible& value, Error& error) { - if (arrayLength(value) < 2) { - error = { "filter expression must have 2 elements" }; - return {}; - } - - optional<std::string> key = toString(arrayMember(value, 1)); - if (!key) { - error = { "filter expression key must be a string" }; - return {}; - } - - if (*key == "$id") { - return { IdentifierFilterType {} }; +std::unique_ptr<Expression> convertLiteral(const Convertible& convertible, Error& error) { + ParsingContext parsingContext; + ParseResult parseResult = Literal::parse(convertible, parsingContext); + if (parseResult) { + return std::move(*parseResult); } else { - return { FilterType { *key } }; + error = { parsingContext.getCombinedErrors() }; + return {}; } } -template <class FilterType, class TypeFilterType, class IdentifierFilterType> -optional<Filter> convertEqualityFilter(const Convertible& value, Error& error) { - if (arrayLength(value) < 3) { - error = { "filter expression must have 3 elements" }; - return {}; +std::vector<std::unique_ptr<Expression>> convertLiteralArray(const Convertible &input, Error& error, std::size_t startIndex = 0) { + std::vector<std::unique_ptr<Expression>> output; + for (std::size_t i = startIndex; i < arrayLength(input); i++) { + output.push_back(convertLiteral(arrayMember(input, i), error)); } + return output; +} - optional<std::string> key = toString(arrayMember(value, 1)); - if (!key) { - error = { "filter expression key must be a string" }; +std::unique_ptr<Expression> convertLegacyComparisonFilter(const Convertible& values, Error& error, optional<std::string> opOverride = {}) { + optional<std::string> op = opOverride ? opOverride : toString(arrayMember(values, 0)); + optional<std::string> property = toString(arrayMember(values, 1)); + + if (!property) { + error = { "filter property must be a string" }; return {}; - } - - if (*key == "$type") { - optional<FeatureType> filterValue = toFeatureType(arrayMember(value, 2), error); - if (!filterValue) { - return {}; - } - - return { TypeFilterType { *filterValue } }; - - } else if (*key == "$id") { - optional<FeatureIdentifier> filterValue = toFeatureIdentifier(arrayMember(value, 2), error); - if (!filterValue) { - return {}; - } - - return { IdentifierFilterType { *filterValue } }; - + } else if (*property == "$type") { + return createExpression("filter-type-" + *op, convertLiteralArray(values, error, 2), error); + } else if (*property == "$id") { + return createExpression("filter-id-" + *op, convertLiteralArray(values, error, 2), error); } else { - optional<GeometryValue> filterValue = normalizeValue(toValue(arrayMember(value, 2)), error); - if (!filterValue) { - return {}; - } - - return { FilterType { *key, *filterValue } }; + return createExpression("filter-" + *op, convertLiteralArray(values, error, 1), error); } } - -template <class FilterType> -optional<Filter> convertBinaryFilter(const Convertible& value, Error& error) { - if (arrayLength(value) < 3) { - error = { "filter expression must have 3 elements" }; - return {}; - } - - optional<std::string> key = toString(arrayMember(value, 1)); - if (!key) { - error = { "filter expression key must be a string" }; - return {}; - } - - optional<GeometryValue> filterValue = normalizeValue(toValue(arrayMember(value, 2)), error); - if (!filterValue) { + +std::unique_ptr<Expression> convertLegacyHasFilter(const Convertible& values, Error& error) { + optional<std::string> property = toString(arrayMember(values, 1)); + + if (!property) { + error = { "filter property must be a string" }; return {}; + } else if (*property == "$type") { + return std::make_unique<Literal>(true); + } else if (*property == "$id") { + return createExpression("filter-has-id", std::vector<std::unique_ptr<Expression>>(), error); + } else { + return createExpression("filter-has", std::make_unique<Literal>(*property), error); } - - return { FilterType { *key, *filterValue } }; } -template <class FilterType, class TypeFilterType, class IdentifierFilterType> -optional<Filter> convertSetFilter(const Convertible& value, Error& error) { - if (arrayLength(value) < 2) { - error = { "filter expression must at least 2 elements" }; - return {}; - } - - optional<std::string> key = toString(arrayMember(value, 1)); - if (!key) { - error = { "filter expression key must be a string" }; - return {}; - } - - if (*key == "$type") { - std::vector<FeatureType> values; - for (std::size_t i = 2; i < arrayLength(value); ++i) { - optional<FeatureType> filterValue = toFeatureType(arrayMember(value, i), error); - if (!filterValue) { - return {}; - } - values.push_back(*filterValue); - } - - return { TypeFilterType { std::move(values) } }; - - } else if (*key == "$id") { - std::vector<FeatureIdentifier> values; - for (std::size_t i = 2; i < arrayLength(value); ++i) { - optional<FeatureIdentifier> filterValue = toFeatureIdentifier(arrayMember(value, i), error); - if (!filterValue) { - return {}; - } - values.push_back(*filterValue); - } - - return { IdentifierFilterType { std::move(values) } }; - +std::unique_ptr<Expression> convertLegacyInFilter(const Convertible& values, Error& error) { + optional<std::string> property = toString(arrayMember(values, 1)); + + if (!property) { + error = { "filter property must be a string" }; + return {}; + } else if (arrayLength(values) == 0) { + return std::make_unique<Literal>(false); + } else if (*property == "$type") { + return createExpression("filter-type-in", convertLiteralArray(values, error, 2), error); + } else if (*property == "$id") { + return createExpression("filter-id-in", convertLiteralArray(values, error, 2), error); } else { - std::vector<GeometryValue> values; - for (std::size_t i = 2; i < arrayLength(value); ++i) { - optional<GeometryValue> filterValue = normalizeValue(toValue(arrayMember(value, i)), error); - if (!filterValue) { - return {}; - } - values.push_back(*filterValue); - } - - return { FilterType { *key, std::move(values) } }; + return createExpression("filter-in", convertLiteralArray(values, error, 1), error); } } -template <class FilterType> -optional<Filter> convertCompoundFilter(const Convertible& value, Error& error) { - std::vector<Filter> filters; - for (std::size_t i = 1; i < arrayLength(value); ++i) { - optional<Filter> element = convert<Filter>(arrayMember(value, i), error); - if (!element) { - return {}; - } - filters.push_back(*element); +std::vector<std::unique_ptr<Expression>> convertLegacyFilterArray(const Convertible &input, Error& error, std::size_t startIndex = 0) { + std::vector<std::unique_ptr<Expression>> output; + for (std::size_t i = startIndex; i < arrayLength(input); i++) { + output.push_back(convertLegacyFilter(arrayMember(input, i), error)); } - - return { FilterType { std::move(filters) } }; + return output; } -optional<Filter> convertExpressionFilter(const Convertible& value, Error& error) { - expression::ParsingContext ctx(expression::type::Boolean); - expression::ParseResult expression = ctx.parseExpression(value); - if (!expression) { - error = { ctx.getCombinedErrors() }; - return {}; - } - - return { ExpressionFilter { std::move(*expression) } }; -} - -optional<Filter> Converter<Filter>::operator()(const Convertible& value, Error& error) const { - if (isExpressionFilter(value)) { - return convertExpressionFilter(value, error); +std::unique_ptr<Expression> convertLegacyFilter(const Convertible& values, Error& error) { + if (isUndefined(values)) { + return std::make_unique<Literal>(true); } - if (!isArray(value)) { - error = { "filter expression must be an array" }; - return {}; - } - - if (arrayLength(value) < 1) { - error = { "filter expression must have at least 1 element" }; - return {}; - } + optional<std::string> op = toString(arrayMember(values, 0)); - optional<std::string> op = toString(arrayMember(value, 0)); if (!op) { error = { "filter operator must be a string" }; return {}; + } else if (arrayLength(values) <= 1) { + return std::make_unique<Literal>(*op != "any"); + } else { + return ( + *op == "==" || + *op == "<" || + *op == ">" || + *op == "<=" || + *op == ">=" ? convertLegacyComparisonFilter(values, error) : + *op == "!=" ? createExpression("!", convertLegacyComparisonFilter(values, error, {"=="}), error) : + *op == "any" ? createExpression("any", convertLegacyFilterArray(values, error, 1), error) : + *op == "all" ? createExpression("all", convertLegacyFilterArray(values, error, 1), error) : + *op == "none" ? createExpression("!", createExpression("any", convertLegacyFilterArray(values, error, 1), error), error) : + *op == "in" ? convertLegacyInFilter(values, error) : + *op == "!in" ? createExpression("!", convertLegacyInFilter(values, error), error) : + *op == "has" ? convertLegacyHasFilter(values, error) : + *op == "!has" ? createExpression("!", convertLegacyHasFilter(values, error), error) : + std::make_unique<Literal>(true) + ); } - - if (*op == "==") { - return convertEqualityFilter<EqualsFilter, TypeEqualsFilter, IdentifierEqualsFilter>(value, error); - } else if (*op == "!=") { - return convertEqualityFilter<NotEqualsFilter, TypeNotEqualsFilter, IdentifierNotEqualsFilter>(value, error); - } else if (*op == ">") { - return convertBinaryFilter<GreaterThanFilter>(value, error); - } else if (*op == ">=") { - return convertBinaryFilter<GreaterThanEqualsFilter>(value, error); - } else if (*op == "<") { - return convertBinaryFilter<LessThanFilter>(value, error); - } else if (*op == "<=") { - return convertBinaryFilter<LessThanEqualsFilter>(value, error); - } else if (*op == "in") { - return convertSetFilter<InFilter, TypeInFilter, IdentifierInFilter>(value, error); - } else if (*op == "!in") { - return convertSetFilter<NotInFilter, TypeNotInFilter, IdentifierNotInFilter>(value, error); - } else if (*op == "all") { - return convertCompoundFilter<AllFilter>(value, error); - } else if (*op == "any") { - return convertCompoundFilter<AnyFilter>(value, error); - } else if (*op == "none") { - return convertCompoundFilter<NoneFilter>(value, error); - } else if (*op == "has") { - return convertUnaryFilter<HasFilter, HasIdentifierFilter>(value, error); - } else if (*op == "!has") { - return convertUnaryFilter<NotHasFilter, NotHasIdentifierFilter>(value, error); - } - - error = { R"(filter operator must be one of "==", "!=", ">", ">=", "<", "<=", "in", "!in", "all", "any", "none", "has", or "!has")" }; - return {}; } } // namespace conversion diff --git a/src/mbgl/style/conversion/stringify.hpp b/src/mbgl/style/conversion/stringify.hpp index 7b7727d7c4..74171763a0 100644 --- a/src/mbgl/style/conversion/stringify.hpp +++ b/src/mbgl/style/conversion/stringify.hpp @@ -126,162 +126,9 @@ void stringify(Writer& writer, const FeatureIdentifier& id) { } template <class Writer> -class StringifyFilter { -public: - Writer& writer; - - void operator()(const NullFilter&) { - writer.Null(); - } - - void operator()(const EqualsFilter& f) { - stringifyBinaryFilter(f, "=="); - } - - void operator()(const NotEqualsFilter& f) { - stringifyBinaryFilter(f, "!="); - } - - void operator()(const LessThanFilter& f) { - stringifyBinaryFilter(f, "<"); - } - - void operator()(const LessThanEqualsFilter& f) { - stringifyBinaryFilter(f, "<="); - } - - void operator()(const GreaterThanFilter& f) { - stringifyBinaryFilter(f, ">"); - } - - void operator()(const GreaterThanEqualsFilter& f) { - stringifyBinaryFilter(f, ">="); - } - - void operator()(const InFilter& f) { - stringifySetFilter(f, "in"); - } - - void operator()(const NotInFilter& f) { - stringifySetFilter(f, "!in"); - } - - void operator()(const AllFilter& f) { - stringifyCompoundFilter(f, "all"); - } - - void operator()(const AnyFilter& f) { - stringifyCompoundFilter(f, "any"); - } - - void operator()(const NoneFilter& f) { - stringifyCompoundFilter(f, "none"); - } - - void operator()(const HasFilter& f) { - stringifyUnaryFilter("has", f.key); - } - - void operator()(const NotHasFilter& f) { - stringifyUnaryFilter("!has", f.key); - } - - void operator()(const TypeEqualsFilter& f) { - stringifyBinaryFilter(f, "==", "$type"); - } - - void operator()(const TypeNotEqualsFilter& f) { - stringifyBinaryFilter(f, "!=", "$type"); - } - - void operator()(const TypeInFilter& f) { - stringifySetFilter(f, "in", "$type"); - } - - void operator()(const TypeNotInFilter& f) { - stringifySetFilter(f, "!in", "$type"); - } - - void operator()(const IdentifierEqualsFilter& f) { - stringifyBinaryFilter(f, "==", "$id"); - } - - void operator()(const IdentifierNotEqualsFilter& f) { - stringifyBinaryFilter(f, "!=", "$id"); - } - - void operator()(const IdentifierInFilter& f) { - stringifySetFilter(f, "in", "$id"); - } - - void operator()(const IdentifierNotInFilter& f) { - stringifySetFilter(f, "!in", "$id"); - } - - void operator()(const HasIdentifierFilter&) { - stringifyUnaryFilter("has", "$id"); - } - - void operator()(const NotHasIdentifierFilter&) { - stringifyUnaryFilter("!has", "$id"); - } - - void operator()(const ExpressionFilter& filter) { - stringify(writer, filter.expression->serialize()); - } - -private: - template <class F> - void stringifyBinaryFilter(const F& f, const char * op) { - stringifyBinaryFilter(f, op, f.key); - } - - template <class F> - void stringifyBinaryFilter(const F& f, const char * op, const std::string& key) { - writer.StartArray(); - writer.String(op); - writer.String(key); - stringify(writer, f.value); - writer.EndArray(); - } - - template <class F> - void stringifySetFilter(const F& f, const char * op) { - stringifySetFilter(f, op, f.key); - } - - template <class F> - void stringifySetFilter(const F& f, const char * op, const std::string& key) { - writer.StartArray(); - writer.String(op); - writer.String(key); - for (const auto& value : f.values) { - stringify(writer, value); - } - writer.EndArray(); - } - - template <class F> - void stringifyCompoundFilter(const F& f, const char * op) { - writer.StartArray(); - writer.String(op); - for (const auto& filter : f.filters) { - Filter::visit(filter, *this); - } - writer.EndArray(); - } - - void stringifyUnaryFilter(const char * op, const std::string& key) { - writer.StartArray(); - writer.String(op); - writer.String(key); - writer.EndArray(); - } -}; - -template <class Writer> -void stringify(Writer& writer, const Filter& f) { - Filter::visit(f, StringifyFilter<Writer> { writer }); +void stringify(Writer& writer, const Filter& filter) { + if (!filter.expression) writer.Null(); + else stringify(writer, (*filter.expression)->serialize()); } template <class Writer> diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index bcde09e1b6..4226756fe4 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -19,7 +19,7 @@ namespace detail { The Signature<Fn> structs are wrappers around an "evaluate()" function whose purpose is to extract the necessary Type data from the evaluate function's type. There are three key (partial) specializations: - + Signature<R (Params...)>: Wraps a simple evaluate function (const T0&, const T1&, ...) -> Result<U> @@ -30,9 +30,9 @@ namespace detail { Signature<R (const EvaluationContext&, Params...)>: Wraps an evaluate function that needs to access the expression evaluation parameters in addition to its subexpressions, i.e., - (const EvaluationParams& const T0&, const T1&, ...) -> Result<U>. Needed + (const EvaluationParams&, const T0&, const T1&, ...) -> Result<U>. Needed for expressions like ["zoom"], ["get", key], etc. - + In each of the above evaluate signatures, T0, T1, etc. are the types of the successfully evaluated subexpressions. */ @@ -43,7 +43,7 @@ struct Signature; template <class R, class... Params> struct Signature<R (Params...)> : SignatureBase { using Args = std::array<std::unique_ptr<Expression>, sizeof...(Params)>; - + Signature(R (*evaluate_)(Params...), std::string name_) : SignatureBase( valueTypeToExpressionType<std::decay_t<typename R::Value>>(), @@ -55,7 +55,7 @@ struct Signature<R (Params...)> : SignatureBase { EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const { return applyImpl(evaluationParameters, args, std::index_sequence_for<Params...>{}); } - + std::unique_ptr<Expression> makeExpression(std::vector<std::unique_ptr<Expression>> args) const override { typename Signature::Args argsArray; std::copy_n(std::make_move_iterator(args.begin()), sizeof...(Params), argsArray.begin()); @@ -80,7 +80,7 @@ private: template <class R, typename T> struct Signature<R (const Varargs<T>&)> : SignatureBase { using Args = std::vector<std::unique_ptr<Expression>>; - + Signature(R (*evaluate_)(const Varargs<T>&), std::string name_) : SignatureBase( valueTypeToExpressionType<std::decay_t<typename R::Value>>(), @@ -89,11 +89,11 @@ struct Signature<R (const Varargs<T>&)> : SignatureBase { ), evaluate(evaluate_) {} - + std::unique_ptr<Expression> makeExpression(std::vector<std::unique_ptr<Expression>> args) const override { return std::make_unique<CompoundExpression<Signature>>(name, *this, std::move(args)); }; - + EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const { Varargs<T> evaluated; evaluated.reserve(args.size()); @@ -115,7 +115,7 @@ struct Signature<R (const Varargs<T>&)> : SignatureBase { template <class R, class... Params> struct Signature<R (const EvaluationContext&, Params...)> : SignatureBase { using Args = std::array<std::unique_ptr<Expression>, sizeof...(Params)>; - + Signature(R (*evaluate_)(const EvaluationContext&, Params...), std::string name_) : SignatureBase( valueTypeToExpressionType<std::decay_t<typename R::Value>>(), @@ -124,17 +124,17 @@ struct Signature<R (const EvaluationContext&, Params...)> : SignatureBase { ), evaluate(evaluate_) {} - + std::unique_ptr<Expression> makeExpression(std::vector<std::unique_ptr<Expression>> args) const override { typename Signature::Args argsArray; std::copy_n(std::make_move_iterator(args.begin()), sizeof...(Params), argsArray.begin()); return std::make_unique<CompoundExpression<Signature>>(name, *this, std::move(argsArray)); } - + EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const { return applyImpl(evaluationParameters, args, std::index_sequence_for<Params...>{}); } - + private: template <std::size_t ...I> EvaluationResult applyImpl(const EvaluationContext& evaluationParameters, const Args& args, std::index_sequence<I...>) const { @@ -150,6 +150,41 @@ private: R (*evaluate)(const EvaluationContext&, Params...); }; + +// Evaluate function needing EvaluationContext and Varargs +// (const EvaluationContext&, const Varargs<T>&) -> Result<U> +template <class R, typename T> +struct Signature<R (const EvaluationContext&, const Varargs<T>&)> : SignatureBase { + using Args = std::vector<std::unique_ptr<Expression>>; + + Signature(R (*evaluate_)(const EvaluationContext&, const Varargs<T>&), std::string name_) : + SignatureBase( + valueTypeToExpressionType<std::decay_t<typename R::Value>>(), + VarargsType { valueTypeToExpressionType<T>() }, + std::move(name_) + ), + evaluate(evaluate_) + {} + + std::unique_ptr<Expression> makeExpression(std::vector<std::unique_ptr<Expression>> args) const override { + return std::make_unique<CompoundExpression<Signature>>(name, *this, std::move(args)); + }; + + EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const { + Varargs<T> evaluated; + evaluated.reserve(args.size()); + for (const auto& arg : args) { + const EvaluationResult evaluatedArg = arg->evaluate(evaluationParameters); + if(!evaluatedArg) return evaluatedArg.error(); + evaluated.push_back(*fromExpressionValue<std::decay_t<T>>(*evaluatedArg)); + } + const R value = evaluate(evaluationParameters, evaluated); + if (!value) return value.error(); + return *value; + } + + R (*evaluate)(const EvaluationContext&, const Varargs<T>&); +}; // Machinery to pull out function types from class methods, lambdas, etc. template <class R, class... Params> @@ -181,29 +216,104 @@ static std::unique_ptr<detail::SignatureBase> makeSignature(Fn evaluateFunction, return std::make_unique<detail::Signature<Fn>>(evaluateFunction, std::move(name)); } +Value featureIdAsExpressionValue(EvaluationContext params) { + assert(params.feature); + auto id = params.feature->getID(); + if (!id) return Null; + return id->match([](const auto& idid) { + return toExpressionValue(mbgl::Value(idid)); + }); +}; + +optional<Value> featurePropertyAsExpressionValue(EvaluationContext params, const std::string& key) { + assert(params.feature); + auto property = params.feature->getValue(key); + return property ? toExpressionValue(*property) : optional<Value>(); +}; + +optional<std::string> featureTypeAsString(FeatureType type) { + switch(type) { + case FeatureType::Point: + return optional<std::string>("Point"); + case FeatureType::LineString: + return optional<std::string>("LineString"); + case FeatureType::Polygon: + return optional<std::string>("Polygon"); + case FeatureType::Unknown: + return optional<std::string>("Unknown"); + default: + return {}; + } +}; + +optional<double> featurePropertyAsDouble(EvaluationContext params, const std::string& key) { + assert(params.feature); + auto property = params.feature->getValue(key); + if (!property) return {}; + return property->match( + [](double value) { return value; }, + [](uint64_t value) { return optional<double>(static_cast<double>(value)); }, + [](int64_t value) { return optional<double>(static_cast<double>(value)); }, + [](auto) { return optional<double>(); } + ); +}; + +optional<std::string> featurePropertyAsString(EvaluationContext params, const std::string& key) { + assert(params.feature); + auto property = params.feature->getValue(key); + if (!property) return {}; + return property->match( + [](std::string value) { return value; }, + [](auto) { return optional<std::string>(); } + ); +}; + +optional<double> featureIdAsDouble(EvaluationContext params) { + assert(params.feature); + auto id = params.feature->getID(); + if (!id) return optional<double>(); + return id->match( + [](double value) { return value; }, + [](uint64_t value) { return optional<double>(static_cast<double>(value)); }, + [](int64_t value) { return optional<double>(static_cast<double>(value)); }, + [](auto) { return optional<double>(); } + ); +}; + +optional<std::string> featureIdAsString(EvaluationContext params) { + assert(params.feature); + auto id = params.feature->getID(); + if (!id) return optional<std::string>(); + return id->match( + [](std::string value) { return value; }, + [](auto) { return optional<std::string>(); } + ); +}; + std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initializeDefinitions() { std::unordered_map<std::string, CompoundExpressionRegistry::Definition> definitions; auto define = [&](std::string name, auto fn) { definitions[name].push_back(makeSignature(fn, name)); }; - + define("e", []() -> Result<double> { return 2.718281828459045; }); define("pi", []() -> Result<double> { return 3.141592653589793; }); define("ln2", []() -> Result<double> { return 0.6931471805599453; }); define("typeof", [](const Value& v) -> Result<std::string> { return toString(typeOf(v)); }); - + define("to-string", [](const Value& value) -> Result<std::string> { return value.match( + [](const NullValue&) -> Result<std::string> { return std::string(); }, [](const Color& c) -> Result<std::string> { return c.stringify(); }, // avoid quoting [](const std::string& s) -> Result<std::string> { return s; }, // avoid quoting [](const auto& v) -> Result<std::string> { return stringify(v); } ); }); - + define("to-boolean", [](const Value& v) -> Result<bool> { return v.match( - [&] (double f) { return (bool)f; }, + [&] (double f) { return static_cast<bool>(f); }, [&] (const std::string& s) { return s.length() > 0; }, [&] (bool b) { return b; }, [&] (const NullValue&) { return false; }, @@ -213,10 +323,10 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("to-rgba", [](const Color& color) -> Result<std::array<double, 4>> { return color.toArray(); }); - + define("rgba", rgba); define("rgb", [](double r, double g, double b) { return rgba(r, g, b, 1.0f); }); - + define("zoom", [](const EvaluationContext& params) -> Result<double> { if (!params.zoom) { return EvaluationError { @@ -225,7 +335,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali } return *(params.zoom); }); - + define("heatmap-density", [](const EvaluationContext& params) -> Result<double> { if (!params.heatmapDensity) { return EvaluationError { @@ -241,7 +351,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali "Feature data is unavailable in the current evaluation context." }; } - + return params.feature->getValue(key) ? true : false; }); define("has", [](const std::string& key, const std::unordered_map<std::string, Value>& object) -> Result<bool> { @@ -267,7 +377,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali } return object.at(key); }); - + define("properties", [](const EvaluationContext& params) -> Result<std::unordered_map<std::string, Value>> { if (!params.feature) { return EvaluationError { @@ -281,14 +391,14 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali } return result; }); - + define("geometry-type", [](const EvaluationContext& params) -> Result<std::string> { if (!params.feature) { return EvaluationError { "Feature data is unavailable in the current evaluation context." }; } - + auto type = params.feature->getType(); if (type == FeatureType::Point) { return "Point"; @@ -300,14 +410,14 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali return "Unknown"; } }); - + define("id", [](const EvaluationContext& params) -> Result<Value> { if (!params.feature) { return EvaluationError { "Feature data is unavailable in the current evaluation context." }; } - + auto id = params.feature->getID(); if (!id) { return Null; @@ -318,7 +428,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali } ); }); - + define("+", [](const Varargs<double>& args) -> Result<double> { double sum = 0.0f; for (auto arg : args) { @@ -348,7 +458,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("asin", [](double x) -> Result<double> { return asin(x); }); define("acos", [](double x) -> Result<double> { return acos(x); }); define("atan", [](double x) -> Result<double> { return atan(x); }); - + define("min", [](const Varargs<double>& args) -> Result<double> { double result = std::numeric_limits<double>::infinity(); for (double arg : args) { @@ -377,7 +487,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("<", [](const std::string& lhs, const std::string& rhs) -> Result<bool> { return lhs < rhs; }); define("<=", [](double lhs, double rhs) -> Result<bool> { return lhs <= rhs; }); define("<=", [](const std::string& lhs, const std::string& rhs) -> Result<bool> { return lhs <= rhs; }); - + define("!", [](bool e) -> Result<bool> { return !e; }); define("is-supported-script", [](const std::string& x) -> Result<bool> { @@ -400,7 +510,130 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("error", [](const std::string& input) -> Result<type::ErrorType> { return EvaluationError { input }; }); + + // Legacy Filters + define("filter-==", [](const EvaluationContext& params, const std::string& key, const Value &lhs) -> Result<bool> { + const auto rhs = featurePropertyAsExpressionValue(params, key); + return rhs ? lhs == *rhs : false; + }); + + define("filter-id-==", [](const EvaluationContext& params, const Value &lhs) -> Result<bool> { + return lhs == featureIdAsExpressionValue(params); + }); + + define("filter-type-==", [](const EvaluationContext& params, const std::string &lhs) -> Result<bool> { + if (!params.feature) return false; + return featureTypeAsString(params.feature->getType()) == lhs; + }); + + define("filter-<", [](const EvaluationContext& params, const std::string& key, double lhs) -> Result<bool> { + auto rhs = featurePropertyAsDouble(params, key); + return rhs ? rhs < lhs : false; + }); + + define("filter-<", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs < lhs : false; + }); + + define("filter-id-<", [](const EvaluationContext& params, double lhs) -> Result<bool> { + auto rhs = featureIdAsDouble(params); + return rhs ? rhs < lhs : false; + }); + + define("filter-id-<", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs < lhs : false; + }); + + define("filter->", [](const EvaluationContext& params, const std::string& key, double lhs) -> Result<bool> { + auto rhs = featurePropertyAsDouble(params, key); + return rhs ? rhs > lhs : false; + }); + + define("filter->", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs > lhs : false; + }); + + define("filter-id->", [](const EvaluationContext& params, double lhs) -> Result<bool> { + auto rhs = featureIdAsDouble(params); + return rhs ? rhs > lhs : false; + }); + + define("filter-id->", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs > lhs : false; + }); + + define("filter-<=", [](const EvaluationContext& params, const std::string& key, double lhs) -> Result<bool> { + auto rhs = featurePropertyAsDouble(params, key); + return rhs ? rhs <= lhs : false; + }); + + define("filter-<=", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs <= lhs : false; + }); + + define("filter-id-<=", [](const EvaluationContext& params, double lhs) -> Result<bool> { + auto rhs = featureIdAsDouble(params); + return rhs ? rhs <= lhs : false; + }); + define("filter-id-<=", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs <= lhs : false; + }); + + define("filter->=", [](const EvaluationContext& params, const std::string& key, double lhs) -> Result<bool> { + auto rhs = featurePropertyAsDouble(params, key); + return rhs ? rhs >= lhs : false; + }); + + define("filter->=", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> { + auto rhs = featurePropertyAsString(params, key); + return rhs ? rhs >= lhs : false; + }); + + define("filter-id->=", [](const EvaluationContext& params, double lhs) -> Result<bool> { + auto rhs = featureIdAsDouble(params); + return rhs ? rhs >= lhs : false; + }); + + define("filter-id->=", [](const EvaluationContext& params, std::string lhs) -> Result<bool> { + auto rhs = featureIdAsString(params); + return rhs ? rhs >= lhs : false; + }); + + define("filter-has", [](const EvaluationContext& params, const std::string& key) -> Result<bool> { + assert(params.feature); + return bool(params.feature->getValue(key)); + }); + + define("filter-has-id", [](const EvaluationContext& params) -> Result<bool> { + assert(params.feature); + return bool(params.feature->getID()); + }); + + define("filter-type-in", [](const EvaluationContext& params, const Varargs<std::string>& types) -> Result<bool> { + assert(params.feature); + optional<std::string> type = featureTypeAsString(params.feature->getType()); + return std::find(types.begin(), types.end(), type) != types.end(); + }); + + define("filter-id-in", [](const EvaluationContext& params, const Varargs<Value>& ids) -> Result<bool> { + auto id = featureIdAsExpressionValue(params); + return std::find(ids.begin(), ids.end(), id) != ids.end(); + }); + + define("filter-in", [](const EvaluationContext& params, const Varargs<Value>& varargs) -> Result<bool> { + if (varargs.size() < 2) return false; + assert(varargs[0].is<std::string>()); + auto value = featurePropertyAsExpressionValue(params, varargs[0].get<std::string>()); + return value ? std::find(varargs.begin() + 1, varargs.end(), *value) != varargs.end() : false; + }); + return definitions; } @@ -419,7 +652,7 @@ ParseResult parseCompoundExpression(const std::string name, const Convertible& v return ParseResult(); } const CompoundExpressionRegistry::Definition& definition = it->second; - + auto length = arrayLength(value); // Check if we have a single signature with the correct number of @@ -445,14 +678,14 @@ ParseResult parseCompoundExpression(const std::string name, const Convertible& v args.reserve(length - 1); for (std::size_t i = 1; i < length; i++) { optional<type::Type> expected; - + if (singleMatchingSignature) { expected = definition[*singleMatchingSignature]->params.match( [](const VarargsType& varargs) { return varargs.type; }, [&](const std::vector<type::Type>& params_) { return params_[i - 1]; } ); } - + auto parsed = ctx.parse(arrayMember(value, i), i, expected); if (!parsed) { return parsed; @@ -479,7 +712,7 @@ ParseResult createCompoundExpression(const Definition& definition, for (const std::unique_ptr<detail::SignatureBase>& signature : definition) { signatureContext.clearErrors(); - + if (signature->params.is<std::vector<type::Type>>()) { const std::vector<type::Type>& params = signature->params.get<std::vector<type::Type>>(); if (params.size() != args.size()) { @@ -507,12 +740,12 @@ ParseResult createCompoundExpression(const Definition& definition, } } } - + if (signatureContext.getErrors().size() == 0) { return ParseResult(signature->makeExpression(std::move(args))); } } - + if (definition.size() == 1) { ctx.appendErrors(std::move(signatureContext)); } else { @@ -545,10 +778,32 @@ ParseResult createCompoundExpression(const Definition& definition, } ctx.error("Expected arguments of type " + signatures + ", but found (" + actualTypes + ") instead."); } - + return ParseResult(); } +ParseResult createCompoundExpression(const std::string& name, ParsingContext& ctx) { + return createCompoundExpression(name, std::vector<std::unique_ptr<Expression>>(), ctx); +} + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + ParsingContext& ctx) { + std::vector<std::unique_ptr<Expression>> args; + args.push_back(std::move(arg1)); + return createCompoundExpression(name, std::move(args), ctx); +} + +ParseResult createCompoundExpression(const std::string& name, + std::unique_ptr<Expression> arg1, + std::unique_ptr<Expression> arg2, + ParsingContext& ctx) { + std::vector<std::unique_ptr<Expression>> args; + args.push_back(std::move(arg1)); + args.push_back(std::move(arg2)); + return createCompoundExpression(name, std::move(args), ctx); +} + } // namespace expression } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/expression/literal.cpp b/src/mbgl/style/expression/literal.cpp index 8a63980dba..f68cfd5cf5 100644 --- a/src/mbgl/style/expression/literal.cpp +++ b/src/mbgl/style/expression/literal.cpp @@ -109,6 +109,14 @@ mbgl::Value Literal::serialize() const { return *fromExpressionValue<mbgl::Value>(value); } } + +std::unique_ptr<Literal> createLiteral(const char* value) { + return createLiteral(std::string(value)); +} + +std::unique_ptr<Literal> createLiteral(Value value) { + return std::make_unique<Literal>(value); +} } // namespace expression } // namespace style diff --git a/src/mbgl/style/filter.cpp b/src/mbgl/style/filter.cpp index 51aa6bcf82..2559eb4816 100644 --- a/src/mbgl/style/filter.cpp +++ b/src/mbgl/style/filter.cpp @@ -1,12 +1,20 @@ #include <mbgl/style/filter.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/tile/geometry_tile_data.hpp> namespace mbgl { namespace style { bool Filter::operator()(const expression::EvaluationContext &context) const { - return FilterBase::visit(*this, FilterEvaluator { context }); + + if (!this->expression) return true; + + const expression::EvaluationResult result = (*this->expression)->evaluate(context); + if (result) { + const optional<bool> typed = expression::fromExpressionValue<bool>(*result); + return typed ? *typed : false; + } else { + return true; + } } } // namespace style diff --git a/src/mbgl/style/filter_evaluator.cpp b/src/mbgl/style/filter_evaluator.cpp deleted file mode 100644 index 72022172f4..0000000000 --- a/src/mbgl/style/filter_evaluator.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include <mbgl/style/filter.hpp> -#include <mbgl/style/filter_evaluator.hpp> -#include <mbgl/tile/geometry_tile_data.hpp> - -namespace mbgl { -namespace style { - -template <class Op> -struct Comparator { - const Op& op; - - template <class T> - bool operator()(const T& lhs, const T& rhs) const { - return op(lhs, rhs); - } - - template <class T0, class T1> - auto operator()(const T0& lhs, const T1& rhs) const - -> typename std::enable_if_t<std::is_arithmetic<T0>::value && !std::is_same<T0, bool>::value && - std::is_arithmetic<T1>::value && !std::is_same<T1, bool>::value, bool> { - return op(double(lhs), double(rhs)); - } - - template <class T0, class T1> - auto operator()(const T0&, const T1&) const - -> typename std::enable_if_t<!std::is_arithmetic<T0>::value || std::is_same<T0, bool>::value || - !std::is_arithmetic<T1>::value || std::is_same<T1, bool>::value, bool> { - return false; - } - - bool operator()(const NullValue&, - const NullValue&) const { - // Should be unreachable; null is not currently allowed by the style specification. - assert(false); - return false; - } - - bool operator()(const std::vector<Value>&, - const std::vector<Value>&) const { - // Should be unreachable; nested values are not currently allowed by the style specification. - assert(false); - return false; - } - - bool operator()(const PropertyMap&, - const PropertyMap&) const { - // Should be unreachable; nested values are not currently allowed by the style specification. - assert(false); - return false; - } -}; - -template <class Op> -bool compare(const Value& lhs, const Value& rhs, const Op& op) { - return Value::binary_visit(lhs, rhs, Comparator<Op> { op }); -} - -bool equal(const Value& lhs, const Value& rhs) { - return compare(lhs, rhs, [] (const auto& lhs_, const auto& rhs_) { return lhs_ == rhs_; }); -} - -bool FilterEvaluator::operator()(const NullFilter&) const { - return true; -} - -bool FilterEvaluator::operator()(const EqualsFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - return actual && equal(*actual, filter.value); -} - -bool FilterEvaluator::operator()(const NotEqualsFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - return !actual || !equal(*actual, filter.value); -} - -bool FilterEvaluator::operator()(const LessThanFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - return actual && compare(*actual, filter.value, [] (const auto& lhs_, const auto& rhs_) { return lhs_ < rhs_; }); -} - -bool FilterEvaluator::operator()(const LessThanEqualsFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - return actual && compare(*actual, filter.value, [] (const auto& lhs_, const auto& rhs_) { return lhs_ <= rhs_; }); -} - -bool FilterEvaluator::operator()(const GreaterThanFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - return actual && compare(*actual, filter.value, [] (const auto& lhs_, const auto& rhs_) { return lhs_ > rhs_; }); -} - -bool FilterEvaluator::operator()(const GreaterThanEqualsFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - return actual && compare(*actual, filter.value, [] (const auto& lhs_, const auto& rhs_) { return lhs_ >= rhs_; }); -} - -bool FilterEvaluator::operator()(const InFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - if (!actual) - return false; - for (const auto& v: filter.values) { - if (equal(*actual, v)) { - return true; - } - } - return false; -} - -bool FilterEvaluator::operator()(const NotInFilter& filter) const { - optional<Value> actual = context.feature->getValue(filter.key); - if (!actual) - return true; - for (const auto& v: filter.values) { - if (equal(*actual, v)) { - return false; - } - } - return true; -} - -bool FilterEvaluator::operator()(const AnyFilter& filter) const { - for (const auto& f: filter.filters) { - if (Filter::visit(f, *this)) { - return true; - } - } - return false; -} - -bool FilterEvaluator::operator()(const AllFilter& filter) const { - for (const auto& f: filter.filters) { - if (!Filter::visit(f, *this)) { - return false; - } - } - return true; -} - -bool FilterEvaluator::operator()(const NoneFilter& filter) const { - for (const auto& f: filter.filters) { - if (Filter::visit(f, *this)) { - return false; - } - } - return true; -} - -bool FilterEvaluator::operator()(const HasFilter& filter) const { - return bool(context.feature->getValue(filter.key)); -} - -bool FilterEvaluator::operator()(const NotHasFilter& filter) const { - return !context.feature->getValue(filter.key); -} - -bool FilterEvaluator::operator()(const TypeEqualsFilter& filter) const { - return context.feature->getType() == filter.value; -} - -bool FilterEvaluator::operator()(const TypeNotEqualsFilter& filter) const { - return context.feature->getType() != filter.value; -} - -bool FilterEvaluator::operator()(const TypeInFilter& filter) const { - for (const auto& v: filter.values) { - if (context.feature->getType() == v) { - return true; - } - } - return false; -} - -bool FilterEvaluator::operator()(const TypeNotInFilter& filter) const { - for (const auto& v: filter.values) { - if (context.feature->getType() == v) { - return false; - } - } - return true; -} - -bool FilterEvaluator::operator()(const IdentifierEqualsFilter& filter) const { - return context.feature->getID() == filter.value; -} - -bool FilterEvaluator::operator()(const IdentifierNotEqualsFilter& filter) const { - return context.feature->getID() != filter.value; -} - -bool FilterEvaluator::operator()(const IdentifierInFilter& filter) const { - for (const auto& v: filter.values) { - if (context.feature->getID() == v) { - return true; - } - } - return false; -} - -bool FilterEvaluator::operator()(const IdentifierNotInFilter& filter) const { - for (const auto& v: filter.values) { - if (context.feature->getID() == v) { - return false; - } - } - return true; -} - -bool FilterEvaluator::operator()(const HasIdentifierFilter&) const { - return bool(context.feature->getID()); -} - -bool FilterEvaluator::operator()(const NotHasIdentifierFilter&) const { - return !context.feature->getID(); -} - -bool FilterEvaluator::operator()(const ExpressionFilter& filter) const { - const expression::EvaluationResult result = filter.expression->evaluate(context); - if (result) { - const optional<bool> typed = expression::fromExpressionValue<bool>(*result); - return typed ? *typed : false; - } - return false; -} - -} // namespace style -} // namespace mbgl diff --git a/src/mbgl/tile/custom_geometry_tile.cpp b/src/mbgl/tile/custom_geometry_tile.cpp index a2fefcfa9f..272a1594d4 100644 --- a/src/mbgl/tile/custom_geometry_tile.cpp +++ b/src/mbgl/tile/custom_geometry_tile.cpp @@ -3,7 +3,6 @@ #include <mbgl/renderer/query.hpp> #include <mbgl/renderer/tile_parameters.hpp> #include <mbgl/actor/scheduler.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/util/string.hpp> #include <mbgl/tile/tile_observer.hpp> #include <mbgl/style/custom_tile_loader.hpp> diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp index f211c03569..7a83da2267 100644 --- a/src/mbgl/tile/geojson_tile.cpp +++ b/src/mbgl/tile/geojson_tile.cpp @@ -2,7 +2,6 @@ #include <mbgl/tile/geojson_tile_data.hpp> #include <mbgl/renderer/query.hpp> #include <mbgl/renderer/tile_parameters.hpp> -#include <mbgl/style/filter_evaluator.hpp> namespace mbgl { diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 8efe12d54f..af28fe3963 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -16,7 +16,6 @@ #include <mbgl/storage/file_source.hpp> #include <mbgl/geometry/feature_index.hpp> #include <mbgl/map/transform_state.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/actor/scheduler.hpp> diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index 2e7d588d9b..ca20c4b8ab 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -5,7 +5,6 @@ #include <mbgl/renderer/bucket_parameters.hpp> #include <mbgl/renderer/group_by_layout.hpp> #include <mbgl/style/filter.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/style/layers/symbol_layer_impl.hpp> #include <mbgl/renderer/layers/render_symbol_layer.hpp> #include <mbgl/renderer/buckets/symbol_bucket.hpp> diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index c67ff9064c..ffab52692b 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -13,6 +13,7 @@ using namespace mbgl; using namespace mbgl::style; +using namespace mbgl::style::expression; namespace { @@ -67,18 +68,19 @@ TEST(Query, QueryRenderedFeaturesFilterLayer) { TEST(Query, QueryRenderedFeaturesFilter) { QueryTest test; + ParsingContext context; auto zz = test.map.pixelForLatLng({ 0, 0 }); - const EqualsFilter eqFilter = { "key1", std::string("value1") }; + const Filter eqFilter(createCompoundExpression("filter-==", createLiteral("key1"), createLiteral("value1"), context)); auto features1 = test.frontend.getRenderer()->queryRenderedFeatures(zz, {{}, { eqFilter }}); EXPECT_EQ(features1.size(), 1u); - const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") }; + const Filter idNotEqFilter(createCompoundExpression("!", std::move(*createCompoundExpression("filter-id-==", createLiteral("feature1"), context)), context)); auto features2 = test.frontend.getRenderer()->queryRenderedFeatures(zz, {{{ "layer4" }}, { idNotEqFilter }}); EXPECT_EQ(features2.size(), 0u); - const GreaterThanFilter gtFilter = { "key2", 1.0 }; + const Filter gtFilter(createCompoundExpression("filter->", createLiteral("key2"), createLiteral(1.0), context)); auto features3 = test.frontend.getRenderer()->queryRenderedFeatures(zz, {{ }, { gtFilter }}); EXPECT_EQ(features3.size(), 1u); } @@ -108,16 +110,17 @@ TEST(Query, QuerySourceFeaturesOptionValidation) { TEST(Query, QuerySourceFeaturesFilter) { QueryTest test; + ParsingContext context; - const EqualsFilter eqFilter = { "key1", std::string("value1") }; + const Filter eqFilter(createCompoundExpression("filter-==", createLiteral("key1"), createLiteral("value1"), context)); auto features1 = test.frontend.getRenderer()->querySourceFeatures("source4", {{}, { eqFilter }}); EXPECT_EQ(features1.size(), 1u); - const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") }; + const Filter idNotEqFilter(createCompoundExpression("!", std::move(*createCompoundExpression("filter-id-==", createLiteral("feature1"), context)), context)); auto features2 = test.frontend.getRenderer()->querySourceFeatures("source4", {{}, { idNotEqFilter }}); EXPECT_EQ(features2.size(), 0u); - const GreaterThanFilter gtFilter = { "key2", 1.0 }; + const Filter gtFilter(createCompoundExpression("filter->", createLiteral("key2"), createLiteral(1.0), context)); auto features3 = test.frontend.getRenderer()->querySourceFeatures("source4", {{}, { gtFilter }}); EXPECT_EQ(features3.size(), 1u); } diff --git a/test/renderer/group_by_layout.test.cpp b/test/renderer/group_by_layout.test.cpp index 958f1bdf24..6cf17e2279 100644 --- a/test/renderer/group_by_layout.test.cpp +++ b/test/renderer/group_by_layout.test.cpp @@ -5,9 +5,11 @@ #include <mbgl/style/layers/background_layer.hpp> #include <mbgl/style/layers/circle_layer.hpp> #include <mbgl/style/layers/line_layer.hpp> +#include <mbgl/style/expression/compound_expression.hpp> using namespace mbgl; using namespace mbgl::style; +using namespace mbgl::style::expression; static std::vector<std::unique_ptr<RenderLayer>> toRenderLayers(const std::vector<std::unique_ptr<Layer>>& layers) { std::vector<std::unique_ptr<RenderLayer>> result; @@ -39,7 +41,8 @@ TEST(GroupByLayout, UnrelatedFilter) { std::vector<std::unique_ptr<Layer>> layers; layers.push_back(std::make_unique<LineLayer>("a", "source")); layers.push_back(std::make_unique<LineLayer>("b", "source")); - layers[0]->as<LineLayer>()->setFilter(EqualsFilter()); + ParsingContext context; + layers[0]->as<LineLayer>()->setFilter(Filter(createCompoundExpression("filter-has-id", context))); auto result = groupByLayout(toRenderLayers(layers)); ASSERT_EQ(2u, result.size()); } diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp index 136f276aaf..c3faf1f838 100644 --- a/test/style/conversion/stringify.test.cpp +++ b/test/style/conversion/stringify.test.cpp @@ -1,5 +1,6 @@ #include <mbgl/test/util.hpp> +#include <mbgl/style/expression/literal.hpp> #include <mbgl/style/conversion/stringify.hpp> #include <mbgl/style/types.hpp> #include <mbgl/style/layers/symbol_layer_properties.hpp> @@ -75,8 +76,12 @@ TEST(Stringify, Value) { } TEST(Stringify, Filter) { - ASSERT_EQ(stringify(NullFilter()), "null"); - ASSERT_EQ(stringify(EqualsFilter { "a", 1.0 }), "[\"==\",\"a\",1.0]"); + using namespace mbgl::style::expression; + + ASSERT_EQ(stringify(Filter()), "null"); + + ParsingContext context; + ASSERT_EQ(stringify(Filter(createCompoundExpression("filter-==", createLiteral("a"), createLiteral(1.0), context))), "[\"filter-==\",\"a\",1.0]"); } TEST(Stringify, CameraFunction) { diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp index 49edcaef45..c59a73eab1 100644 --- a/test/style/filter.test.cpp +++ b/test/style/filter.test.cpp @@ -4,7 +4,6 @@ #include <mbgl/test/stub_geometry_tile_feature.hpp> #include <mbgl/style/filter.hpp> -#include <mbgl/style/filter_evaluator.hpp> #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/filter.hpp> @@ -28,6 +27,24 @@ bool filter(const char * json, return (*filter)(context); } +void invalidFilter(const char * json) { + conversion::Error error; + optional<Filter> filter = conversion::convertJSON<Filter>(json, error); + EXPECT_FALSE(bool(filter)); + EXPECT_NE(error.message, ""); +} + +TEST(Filter, EqualsNull) { + auto f = R"(["==", "foo", null])"; + ASSERT_TRUE(filter(f, {{ "foo", mapbox::geometry::null_value }})); + + ASSERT_FALSE(filter(f, {{ "foo", int64_t(0) }})); + ASSERT_FALSE(filter(f, {{ "foo", int64_t(1) }})); + ASSERT_FALSE(filter(f, {{ "foo", std::string("0") }})); + ASSERT_FALSE(filter(f, {{ "foo", true }})); + ASSERT_FALSE(filter(f, {{ "foo", false }})); + ASSERT_FALSE(filter(f, {{ }})); +} TEST(Filter, EqualsString) { auto f = R"(["==", "foo", "bar"])"; ASSERT_TRUE(filter(f, {{ "foo", std::string("bar") }})); @@ -53,6 +70,12 @@ TEST(Filter, EqualsType) { auto f = R"(["==", "$type", "LineString"])"; ASSERT_FALSE(filter(f, {{}}, {}, FeatureType::Point, {})); ASSERT_TRUE(filter(f, {{}}, {}, FeatureType::LineString, {})); + ASSERT_FALSE(filter(f, {{}}, {}, FeatureType::Point, {})); + + invalidFilter("[\"==\", \"$type\"]"); + invalidFilter("[\"==\", \"$type\", null]"); + invalidFilter("[\"==\", \"$type\", \"foo\", 1]"); + invalidFilter("[\"==\", \"$type\", \"foo\", \"Point\"]"); } TEST(Filter, InType) { @@ -62,6 +85,14 @@ TEST(Filter, InType) { ASSERT_TRUE(filter(f, {{}}, {}, FeatureType::Polygon)); } +TEST(Filter, InID) { + auto f = R"(["in", "$id", "123", "1234", 1234])"; + ASSERT_FALSE(filter(f)); + ASSERT_TRUE(filter(f, {{}}, { uint64_t(1234) })); + ASSERT_TRUE(filter(f, {{}}, { std::string("1234") })); + ASSERT_FALSE(filter(f, {{}}, { std::string("4321") })); +} + TEST(Filter, Any) { ASSERT_FALSE(filter("[\"any\"]")); ASSERT_TRUE(filter("[\"any\", [\"==\", \"foo\", 1]]", {{ std::string("foo"), int64_t(1) }})); @@ -69,6 +100,13 @@ TEST(Filter, Any) { ASSERT_TRUE(filter("[\"any\", [\"==\", \"foo\", 0], [\"==\", \"foo\", 1]]", {{ std::string("foo"), int64_t(1) }})); } +TEST(Filter, AnyExpression) { + ASSERT_FALSE(filter("[\"any\"]")); + ASSERT_TRUE(filter("[\"any\", [\"==\", [\"get\", \"foo\"], 1]]", {{ std::string("foo"), int64_t(1) }})); + ASSERT_FALSE(filter("[\"any\", [\"==\", [\"get\", \"foo\"], 0]]", {{ std::string("foo"), int64_t(1) }})); + ASSERT_TRUE(filter("[\"any\", [\"==\", [\"get\", \"foo\"], 0], [\"==\", [\"get\", \"foo\"], 1]]", {{ std::string("foo"), int64_t(1) }})); +} + TEST(Filter, All) { ASSERT_TRUE(filter("[\"all\"]", {{}})); ASSERT_TRUE(filter("[\"all\", [\"==\", \"foo\", 1]]", {{ std::string("foo"), int64_t(1) }})); @@ -76,6 +114,12 @@ TEST(Filter, All) { ASSERT_FALSE(filter("[\"all\", [\"==\", \"foo\", 0], [\"==\", \"foo\", 1]]", {{ std::string("foo"), int64_t(1) }})); } +TEST(Filter, AllExpression) { + ASSERT_TRUE(filter("[\"all\", [\"==\", [\"get\", \"foo\"], 1]]", {{ std::string("foo"), int64_t(1) }})); + ASSERT_FALSE(filter("[\"all\", [\"==\", [\"get\", \"foo\"], 0]]", {{ std::string("foo"), int64_t(1) }})); + ASSERT_FALSE(filter("[\"all\", [\"==\", [\"get\", \"foo\"], 0], [\"==\", [\"get\", \"foo\"], 1]]", {{ std::string("foo"), int64_t(1) }})); +} + TEST(Filter, None) { ASSERT_TRUE(filter("[\"none\"]")); ASSERT_FALSE(filter("[\"none\", [\"==\", \"foo\", 1]]", {{ std::string("foo"), int64_t(1) }})); @@ -88,6 +132,7 @@ TEST(Filter, Has) { ASSERT_TRUE(filter("[\"has\", \"foo\"]", {{ std::string("foo"), int64_t(0) }})); ASSERT_TRUE(filter("[\"has\", \"foo\"]", {{ std::string("foo"), false }})); ASSERT_FALSE(filter("[\"has\", \"foo\"]")); + ASSERT_FALSE(filter("[\"has\", \"$id\"]")); } TEST(Filter, NotHas) { @@ -101,7 +146,11 @@ TEST(Filter, ID) { FeatureIdentifier id1 { uint64_t{ 1234 } }; ASSERT_TRUE(filter("[\"==\", \"$id\", 1234]", {{}}, id1)); ASSERT_FALSE(filter("[\"==\", \"$id\", \"1234\"]", {{}}, id1)); - + + FeatureIdentifier id2 { std::string{ "1" } }; + ASSERT_FALSE(filter("[\"<\", \"$id\", \"0\"]", {{}}, id2)); + ASSERT_TRUE(filter("[\"<\", \"$id\", \"1234\"]", {{}}, id2)); + ASSERT_FALSE(filter("[\"==\", \"$id\", 1234]", {{ "id", uint64_t(1234) }})); } @@ -115,6 +164,18 @@ TEST(Filter, PropertyExpression) { ASSERT_FALSE(filter("[\"==\", [\"get\", \"two\"], 4]", {{"two", int64_t(2)}})); } +TEST(Filter, LegacyProperty) { + ASSERT_TRUE(filter("[\"<=\", \"two\", 2]", {{"two", int64_t(2)}})); + ASSERT_FALSE(filter("[\"==\", \"two\", 4]", {{"two", int64_t(2)}})); + + ASSERT_FALSE(filter("[\"<=\", \"two\", \"2\"]", {{"two", int64_t(2)}})); + ASSERT_FALSE(filter("[\"==\", \"bool\", false]", {{"two", true}})); + + ASSERT_TRUE(filter("[\"<=\", \"two\", \"2\"]", {{"two", std::string("2")}})); + ASSERT_FALSE(filter("[\"<\", \"two\", \"1\"]", {{"two", std::string("2")}})); + ASSERT_FALSE(filter("[\"==\", \"two\", 4]", {{"two", std::string("2")}})); +} + TEST(Filter, ZoomExpressionNested) { ASSERT_TRUE(filter(R"(["==", ["get", "two"], ["zoom"]])", {{"two", int64_t(2)}}, {}, FeatureType::Point, {}, 2.0f)); ASSERT_FALSE(filter(R"(["==", ["get", "two"], ["+", ["zoom"], 1]])", {{"two", int64_t(2)}}, {}, FeatureType::Point, {}, 2.0f)); diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp index 77acca2868..624ed088c3 100644 --- a/test/style/style_layer.test.cpp +++ b/test/style/style_layer.test.cpp @@ -211,7 +211,7 @@ TEST(Layer, Observer) { EXPECT_EQ(layer.get(), &layer_); filterChanged = true; }; - layer->setFilter(NullFilter()); + layer->setFilter(Filter()); EXPECT_TRUE(filterChanged); // Notifies observer on visibility change. |