Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
mbgl v1.6.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Apr 20, 2020
1 parent 23b5b46 commit 72e4b5a
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 5 deletions.
17 changes: 17 additions & 0 deletions platform/darwin/src/MGLCircleStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
20 changes: 20 additions & 0 deletions platform/darwin/src/MGLCircleStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ - (NSPredicate *)predicate
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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleSortKey, true);
self.rawLayer->setCircleSortKey(mbglValue);
}

- (NSExpression *)circleSortKey {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getCircleSortKey();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultCircleSortKey();
}
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
}

#pragma mark - Accessing the Paint Attributes

- (void)setCircleBlur:(NSExpression *)circleBlur {
Expand Down
70 changes: 70 additions & 0 deletions platform/darwin/test/MGLCircleStyleLayerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,75 @@ - (void)testProperties {
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<float> 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<float>(
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<float>(
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<float>(
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(),
Expand Down Expand Up @@ -779,6 +848,7 @@ - (void)testProperties {
}

- (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];
Expand Down
7 changes: 7 additions & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.

## 5.9.0

* 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 a crash when encountering an invalid polyline. ([mapbox/mapbox-gl-native#16409](https://github.com/mapbox/mapbox-gl-native/pull/16409))
* 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

### Styles and rendering
Expand Down
7 changes: 7 additions & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog for Mapbox Maps SDK for macOS

## 0.16.0

* 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 a crash when encountering an invalid polyline. ([mapbox/mapbox-gl-native#16409](https://github.com/mapbox/mapbox-gl-native/pull/16409))
* 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

### Styles and rendering
Expand Down
5 changes: 1 addition & 4 deletions scripts/style-spec.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion vendor/mapbox-gl-native
Submodule mapbox-gl-native updated 633 files

0 comments on commit 72e4b5a

Please sign in to comment.