From 152d372b6170b7a2729465792f275fc93edead59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 17 Apr 2020 19:39:41 -0700 Subject: [PATCH] mbgl v1.6.0-rc.2 --- platform/darwin/src/MGLCircleStyleLayer.h | 17 +++++ platform/darwin/src/MGLCircleStyleLayer.mm | 20 ++++++ .../darwin/test/MGLCircleStyleLayerTests.mm | 70 +++++++++++++++++++ platform/ios/CHANGELOG.md | 6 ++ platform/macos/CHANGELOG.md | 18 +++-- scripts/style-spec.js | 5 +- vendor/mapbox-gl-native | 2 +- 7 files changed, 129 insertions(+), 9 deletions(-) diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index e2b043a72..540980176 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -120,6 +120,23 @@ MGL_EXPORT */ - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; +#pragma mark - Accessing the Layout Attributes + +/** + Sorts features in ascending order based on this value. Features with a higher + sort key will appear above features with a lower sort key. + + You can set this property to an expression containing any of the following: + + * Constant numeric values + * Predefined functions, including mathematical and string operators + * Conditional expressions + * Variable assignments and references to assigned variables + * Interpolation and step functions applied to the `$zoomLevel` variable and/or + feature attributes + */ +@property (nonatomic, null_resettable) NSExpression *circleSortKey; + #pragma mark - Accessing the Paint Attributes /** diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 6f82d85ce..bccd7e29f 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -91,6 +91,26 @@ namespace mbgl { return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } +#pragma mark - Accessing the Layout Attributes + +- (void)setCircleSortKey:(NSExpression *)circleSortKey { + MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleSortKey: %@", circleSortKey); + + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleSortKey, true); + self.rawLayer->setCircleSortKey(mbglValue); +} + +- (NSExpression *)circleSortKey { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getCircleSortKey(); + if (propertyValue.isUndefined()) { + propertyValue = self.rawLayer->getDefaultCircleSortKey(); + } + return MGLStyleValueTransformer().toExpression(propertyValue); +} + #pragma mark - Accessing the Paint Attributes - (void)setCircleBlur:(NSExpression *)circleBlur { diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.mm b/platform/darwin/test/MGLCircleStyleLayerTests.mm index 5f789f4fa..3222073e8 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.mm +++ b/platform/darwin/test/MGLCircleStyleLayerTests.mm @@ -49,6 +49,75 @@ MGLTransition transitionTest = MGLTransitionMake(5, 4); + // circle-sort-key + { + XCTAssertTrue(rawLayer->getCircleSortKey().isUndefined(), + @"circle-sort-key should be unset initially."); + NSExpression *defaultExpression = layer.circleSortKey; + + NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; + layer.circleSortKey = constantExpression; + mbgl::style::PropertyValue propertyValue = { 1.0 }; + XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, + @"Setting circleSortKey to a constant value expression should update circle-sort-key."); + XCTAssertEqualObjects(layer.circleSortKey, constantExpression, + @"circleSortKey should round-trip constant value expressions."); + + constantExpression = [NSExpression expressionWithFormat:@"1"]; + NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; + layer.circleSortKey = functionExpression; + + { + using namespace mbgl::style::expression::dsl; + propertyValue = mbgl::style::PropertyExpression( + step(zoom(), literal(1.0), 18.0, literal(1.0)) + ); + } + + XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, + @"Setting circleSortKey to a camera expression should update circle-sort-key."); + XCTAssertEqualObjects(layer.circleSortKey, functionExpression, + @"circleSortKey should round-trip camera expressions."); + + functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; + layer.circleSortKey = functionExpression; + + { + using namespace mbgl::style::expression::dsl; + propertyValue = mbgl::style::PropertyExpression( + interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) + ); + } + + XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, + @"Setting circleSortKey to a data expression should update circle-sort-key."); + NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; + XCTAssertEqualObjects(layer.circleSortKey, pedanticFunctionExpression, + @"circleSortKey should round-trip data expressions."); + + functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; + layer.circleSortKey = functionExpression; + + { + using namespace mbgl::style::expression::dsl; + propertyValue = mbgl::style::PropertyExpression( + interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) + ); + } + + XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, + @"Setting circleSortKey to a camera-data expression should update circle-sort-key."); + pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; + XCTAssertEqualObjects(layer.circleSortKey, pedanticFunctionExpression, + @"circleSortKey should round-trip camera-data expressions."); + + layer.circleSortKey = nil; + XCTAssertTrue(rawLayer->getCircleSortKey().isUndefined(), + @"Unsetting circleSortKey should return circle-sort-key to the default value."); + XCTAssertEqualObjects(layer.circleSortKey, defaultExpression, + @"circleSortKey should return the default value after being unset."); + } + // circle-blur { XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(), @@ -779,6 +848,7 @@ } - (void)testPropertyNames { + [self testPropertyName:@"circle-sort-key" isBoolean:NO]; [self testPropertyName:@"circle-blur" isBoolean:NO]; [self testPropertyName:@"circle-color" isBoolean:NO]; [self testPropertyName:@"circle-opacity" isBoolean:NO]; diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 0c3e66eee..ac9deaa6e 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -6,11 +6,17 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Styles and rendering +* Added the `distance` expression function for calculating the shortest distance between the evaluated feature and a GeoJSON `Point`, `MultiPoint`, `LineString`, or `MultiLineString` geometry that you specify. Use this function in expressions in style JSON or with the `MGL_FUNCTION()` syntax in an `NSExpression` format string. ([mapbox/mapbox-gl-native#16397](https://github.com/mapbox/mapbox-gl-native/pull/16397)) +* Added the `MGLCircleStyleLayer.circleSortKey` property. ([mapbox/mapbox-gl-native#15875](https://github.com/mapbox/mapbox-gl-native/pull/15875)) +* Fixed a crash when calling the `-[MGLStyle removeImageForName:]` method with the name of a nonexistent image. ([mapbox/mapbox-gl-native#16391](https://github.com/mapbox/mapbox-gl-native/pull/16391)) * Fixed an issue where properties such as `MGLFillStyleLayer.fillColor` and `MGLLineStyleLayer.lineColor` misinterpreted non-opaque `UIColor`s. ([#266](https://github.com/mapbox/mapbox-gl-native-ios/pull/266)) ### Other changes +* Fixed a crash when encountering an invalid polyline. ([mapbox/mapbox-gl-native#16409](https://github.com/mapbox/mapbox-gl-native/pull/16409)) * Fixed an issue where an `MGLMapSnapshotOptions` with an invalid `MGLMapCamera.centerCoordinate`, negative `MGLMapCamera.heading`, negative `MGLMapCamera.pitch`, and negative `MGLMapSnapshotOptions.zoomLevel` resulted in a snapshot centered on Null Island at zoom level 0 even if the style specified a different initial center coordinate or zoom level. ([#280](https://github.com/mapbox/mapbox-gl-native-ios/pull/280)) +* Fixed an error that occurred if your implementation of the `-[MGLOfflineStorageDelegate offlineStorage:URLForResourceOfKind:]` method returned a local file URL. ([mapbox/mapbox-gl-native#16428](https://github.com/mapbox/mapbox-gl-native/pull/16428)) +* Certain logging statements no longer run on the main thread. ([mapbox/mapbox-gl-native#16325](https://github.com/mapbox/mapbox-gl-native/pull/16325)) ## 5.8.0 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index d73fca5dc..75369dd37 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -1,10 +1,20 @@ # Changelog for Mapbox Maps SDK for macOS -## master +## 0.16.0 + +### Styles and rendering + +* Added the `distance` expression function for calculating the shortest distance between the evaluated feature and a GeoJSON `Point`, `MultiPoint`, `LineString`, or `MultiLineString` geometry that you specify. Use this function in expressions in style JSON or with the `MGL_FUNCTION()` syntax in an `NSExpression` format string. ([mapbox/mapbox-gl-native#16397](https://github.com/mapbox/mapbox-gl-native/pull/16397)) +* Added the `MGLCircleStyleLayer.circleSortKey` property. ([mapbox/mapbox-gl-native#15875](https://github.com/mapbox/mapbox-gl-native/pull/15875)) +* Fixed a crash when calling the `-[MGLStyle removeImageForName:]` method with the name of a nonexistent image. ([mapbox/mapbox-gl-native#16391](https://github.com/mapbox/mapbox-gl-native/pull/16391)) +* Fixed an issue where an `MGLMapSnapshotOptions` with an invalid `MGLMapCamera.centerCoordinate`, negative `MGLMapCamera.heading`, negative `MGLMapCamera.pitch`, and negative `MGLMapSnapshotOptions.zoomLevel` resulted in a snapshot centered on Null Island at zoom level 0 even if the style specified a different initial center coordinate or zoom level. ([#280](https://github.com/mapbox/mapbox-gl-native-ios/pull/280)) ### Other changes -* Fixed an issue where an `MGLMapSnapshotOptions` with an invalid `MGLMapCamera.centerCoordinate`, negative `MGLMapCamera.heading`, negative `MGLMapCamera.pitch`, and negative `MGLMapSnapshotOptions.zoomLevel` resulted in a snapshot centered on Null Island at zoom level 0 even if the style specified a different initial center coordinate or zoom level. ([#280](https://github.com/mapbox/mapbox-gl-native-ios/pull/280)) +* Fixed various crashes, including crashes on launch, on macOS 10.11.0 through 10.14._x_. ([mapbox/mapbox-gl-native#16412](https://github.com/mapbox/mapbox-gl-native/pull/16412)) +* Fixed a crash when encountering an invalid polyline. ([mapbox/mapbox-gl-native#16409](https://github.com/mapbox/mapbox-gl-native/pull/16409)) +* Fixed an error that occurred if your implementation of the `-[MGLOfflineStorageDelegate offlineStorage:URLForResourceOfKind:]` method returned a local file URL. ([mapbox/mapbox-gl-native#16428](https://github.com/mapbox/mapbox-gl-native/pull/16428)) +* Certain logging statements no longer run on the main thread. ([mapbox/mapbox-gl-native#16325](https://github.com/mapbox/mapbox-gl-native/pull/16325)) ## 0.15.0 @@ -12,7 +22,7 @@ * Added the `-[MGLMapViewDelegate mapView:shouldRemoveStyleImage:]` method for optimizing style image caching. ([#14769](https://github.com/mapbox/mapbox-gl-native/pull/14769)) * Added the `image` expression function for converting an image name into a style image. Use this function in expressions in style JSON or with the `MGL_FUNCTION()` syntax in an `NSExpression` format string. Image expressions are compatible with the `mgl_attributed:` expression function and `MGLAttributedExpression` classes for embedding icons inline in text labels. ([#15877](https://github.com/mapbox/mapbox-gl-native/pull/15877), [#15937](https://github.com/mapbox/mapbox-gl-native/pull/15937)) -* The `IN` and `CONTAINS` predicate operators can now test whether a string is a substring of another string or whether the evaluated feature (`SELF`) lies within a given `MGLShape` or `MGLFeature`. ([#183](https://github.com/mapbox/mapbox-gl-native-ios/pull/183), [#184](https://github.com/mapbox/mapbox-gl-native-ios/pull/184]) +* The `IN` and `CONTAINS` predicate operators can now test whether a string is a substring of another string or whether the evaluated feature (`SELF`) lies within a given `MGLShape` or `MGLFeature`. ([#183](https://github.com/mapbox/mapbox-gl-native-ios/pull/183), [#184](https://github.com/mapbox/mapbox-gl-native-ios/pull/184)) * Added the `MGLSymbolStyleLayer.textWritingModes` layout property. This property can be set to `MGLTextWritingModeHorizontal` or `MGLTextWritingModeVertical`. ([#14932](https://github.com/mapbox/mapbox-gl-native/pull/14932)) * Added the `MGLLineStyleLayer.lineSortKey` and `MGLFillStyleLayer.fillSortKey` properties. ([#179](https://github.com/mapbox/mapbox-gl-native-ios/pull/179)) * The `MGLIdeographicFontFamilyName` Info.plist key now also accepts an array of font family names, to customize font fallback behavior. It can also be set to a Boolean value of `NO` to force the SDK to typeset CJK characters in a remote font specified by `MGLSymbolStyleLayer.textFontNames`. ([#14862](https://github.com/mapbox/mapbox-gl-native/pull/14862)) @@ -71,7 +81,7 @@ ### Other changes -* Fixed a memory leak when zooming with any options enabled in the `MGLMapView.debugMask` property. ([#15179](https://github.com/mapbox/mapbox-gl-native/issues/15179)) +* Fixed a memory leak when zooming with any options enabled in the `MGLMapView.debugMask` property. ([#15395](https://github.com/mapbox/mapbox-gl-native/pull/15395)) * `MGLLoggingLevel` has been updated to better match core log levels. You can now use `MGLLoggingConfiguration.loggingLevel` to filter logs from core. ([#15120](https://github.com/mapbox/mapbox-gl-native/pull/15120)) ## 0.14.0 - May 22, 2018 diff --git a/scripts/style-spec.js b/scripts/style-spec.js index 374c3bcb6..c0f03407b 100644 --- a/scripts/style-spec.js +++ b/scripts/style-spec.js @@ -1,4 +1 @@ -var spec = module.exports = require('../vendor/mapbox-gl-native/mapbox-gl-js/src/style-spec/reference/v8'); - -// FIXME: https://github.com/mapbox/mapbox-gl-native/issues/15008 -delete spec.layout_circle["circle-sort-key"]; +module.exports = require('../vendor/mapbox-gl-native/mapbox-gl-js/src/style-spec/reference/v8'); diff --git a/vendor/mapbox-gl-native b/vendor/mapbox-gl-native index 77b883d80..de12a0647 160000 --- a/vendor/mapbox-gl-native +++ b/vendor/mapbox-gl-native @@ -1 +1 @@ -Subproject commit 77b883d80d2dee6612e0e3621c32b90adbd85e3e +Subproject commit de12a0647dd1d0681d051ff7e3797356db149a52