diff options
author | Lauren Budorick <lauren@mapbox.com> | 2017-04-18 18:25:49 -0700 |
---|---|---|
committer | Lauren Budorick <lauren@mapbox.com> | 2017-04-24 17:11:01 -0700 |
commit | 0c49b97aac69485017541152d12c72db9f5fba51 (patch) | |
tree | 69926d99068c7ea73f29bf60277551969ef9107e | |
parent | f83ca8a74a1e3690e1ecc1a99e2ae6fdb589e82f (diff) | |
download | qtlocation-mapboxgl-0c49b97aac69485017541152d12c72db9f5fba51.tar.gz |
Rebase resolutions:
* Update mapbox-gl-js
* According platform-specific generated code updates
* Update test/style/conversion/light.test.cpp based on Light refactor
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.h | 18 | ||||
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.mm | 12 | ||||
-rw-r--r-- | platform/darwin/test/MGLSymbolStyleLayerTests.mm | 60 | ||||
-rwxr-xr-x | platform/ios/app/lbud_buildings_debug.json | 167 | ||||
-rw-r--r-- | test/style/conversion/light.test.cpp | 37 |
5 files changed, 91 insertions, 203 deletions
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index 204589a49c..b6c6372324 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -552,6 +552,15 @@ MGL_EXPORT * `MGLCameraStyleFunction` with an interpolation mode of: * `MGLInterpolationModeExponential` * `MGLInterpolationModeInterval` + * `MGLSourceStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + * `MGLInterpolationModeCategorical` + * `MGLInterpolationModeIdentity` + * `MGLCompositeStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + * `MGLInterpolationModeCategorical` */ @property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconScale; @@ -934,6 +943,15 @@ MGL_EXPORT * `MGLCameraStyleFunction` with an interpolation mode of: * `MGLInterpolationModeExponential` * `MGLInterpolationModeInterval` + * `MGLSourceStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + * `MGLInterpolationModeCategorical` + * `MGLInterpolationModeIdentity` + * `MGLCompositeStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + * `MGLInterpolationModeCategorical` */ @property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textFontSize; diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 1cdfc44532..5a8f8c6084 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -303,7 +303,7 @@ namespace mbgl { - (void)setIconScale:(MGLStyleValue<NSNumber *> *)iconScale { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(iconScale); + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(iconScale); self.rawLayer->setIconSize(mbglValue); } @@ -312,9 +312,9 @@ namespace mbgl { auto propertyValue = self.rawLayer->getIconSize(); if (propertyValue.isUndefined()) { - return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconSize()); + return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultIconSize()); } - return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); + return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue); } - (void)setIconSize:(MGLStyleValue<NSNumber *> *)iconSize { @@ -604,7 +604,7 @@ namespace mbgl { - (void)setTextFontSize:(MGLStyleValue<NSNumber *> *)textFontSize { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textFontSize); + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(textFontSize); self.rawLayer->setTextSize(mbglValue); } @@ -613,9 +613,9 @@ namespace mbgl { auto propertyValue = self.rawLayer->getTextSize(); if (propertyValue.isUndefined()) { - return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextSize()); + return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultTextSize()); } - return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); + return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue); } - (void)setTextSize:(MGLStyleValue<NSNumber *> *)textSize { diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm index eee61dd5d7..367ebf363c 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm @@ -405,7 +405,7 @@ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff]; layer.iconScale = constantStyleValue; - mbgl::style::PropertyValue<float> propertyValue = { 0xff }; + mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff }; XCTAssertEqual(rawLayer->getIconSize(), propertyValue, @"Setting iconScale to a constant value should update icon-size."); XCTAssertEqualObjects(layer.iconScale, constantStyleValue, @@ -422,6 +422,29 @@ XCTAssertEqualObjects(layer.iconScale, functionStyleValue, @"iconScale should round-trip camera functions."); + functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil]; + layer.iconScale = functionStyleValue; + + mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 }; + propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops }; + + XCTAssertEqual(rawLayer->getIconSize(), propertyValue, + @"Setting iconScale to a source function should update icon-size."); + XCTAssertEqualObjects(layer.iconScale, functionStyleValue, + @"iconScale should round-trip source functions."); + + functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil]; + layer.iconScale = functionStyleValue; + + std::map<float, float> innerStops { {18, 0xff} }; + mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 }; + + propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops }; + + XCTAssertEqual(rawLayer->getIconSize(), propertyValue, + @"Setting iconScale to a composite function should update icon-size."); + XCTAssertEqualObjects(layer.iconScale, functionStyleValue, + @"iconScale should round-trip composite functions."); layer.iconScale = nil; @@ -429,11 +452,6 @@ @"Unsetting iconScale should return icon-size to the default value."); XCTAssertEqualObjects(layer.iconScale, defaultStyleValue, @"iconScale should return the default value after being unset."); - - functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil]; - XCTAssertThrowsSpecificNamed(layer.iconScale = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); - functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil]; - XCTAssertThrowsSpecificNamed(layer.iconScale = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); } // icon-text-fit @@ -952,7 +970,7 @@ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff]; layer.textFontSize = constantStyleValue; - mbgl::style::PropertyValue<float> propertyValue = { 0xff }; + mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff }; XCTAssertEqual(rawLayer->getTextSize(), propertyValue, @"Setting textFontSize to a constant value should update text-size."); XCTAssertEqualObjects(layer.textFontSize, constantStyleValue, @@ -969,6 +987,29 @@ XCTAssertEqualObjects(layer.textFontSize, functionStyleValue, @"textFontSize should round-trip camera functions."); + functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil]; + layer.textFontSize = functionStyleValue; + + mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 }; + propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops }; + + XCTAssertEqual(rawLayer->getTextSize(), propertyValue, + @"Setting textFontSize to a source function should update text-size."); + XCTAssertEqualObjects(layer.textFontSize, functionStyleValue, + @"textFontSize should round-trip source functions."); + + functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil]; + layer.textFontSize = functionStyleValue; + + std::map<float, float> innerStops { {18, 0xff} }; + mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 }; + + propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops }; + + XCTAssertEqual(rawLayer->getTextSize(), propertyValue, + @"Setting textFontSize to a composite function should update text-size."); + XCTAssertEqualObjects(layer.textFontSize, functionStyleValue, + @"textFontSize should round-trip composite functions."); layer.textFontSize = nil; @@ -976,11 +1017,6 @@ @"Unsetting textFontSize should return text-size to the default value."); XCTAssertEqualObjects(layer.textFontSize, defaultStyleValue, @"textFontSize should return the default value after being unset."); - - functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil]; - XCTAssertThrowsSpecificNamed(layer.textFontSize = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); - functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil]; - XCTAssertThrowsSpecificNamed(layer.textFontSize = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); } // text-ignore-placement diff --git a/platform/ios/app/lbud_buildings_debug.json b/platform/ios/app/lbud_buildings_debug.json deleted file mode 100755 index a094495ace..0000000000 --- a/platform/ios/app/lbud_buildings_debug.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "version": 8, - "name": "buildings", - "metadata": { - "mapbox:autocomposite": true, - "mapbox:type": "default", - "mapbox:groups": {}, - "mapbox:trackposition": false - }, - "center": [ - -74.00335198896914, - 40.71014952920291 - ], - "zoom": 15.032371136814405, - "bearing": -74.59290123456799, - "pitch": 0, - "light": { - "intensity": 1, - "position": [ - 0.5, - 235, - 90 - ], - "color": "#00ff00", - "anchor": "map" - }, - "sources": { - "composite": { - "url": "mapbox://mapbox.mapbox-streets-v7", - "type": "vector" - } - }, - "sprite": "mapbox://sprites/lbud/ciyoshhyf004r2rmqr8bd4g3h", - "glyphs": "mapbox://fonts/lbud/{fontstack}/{range}.pbf", - "layers": [ - { - "id": "background", - "type": "background", - "layout": {}, - "paint": { - "background-color": "hsl(55, 11%, 96%)" - } - }, - { - "id": "water", - "type": "fill", - "source": "composite", - "source-layer": "water", - "layout": {}, - "paint": { - "fill-color": "hsl(185, 9%, 81%)" - } - }, - { - "id": "road-primary", - "type": "line", - "source": "composite", - "source-layer": "road", - "filter": [ - "==", - "$type", - "LineString" - ], - "layout": { - "line-cap": "round", - "line-join": "round" - }, - "paint": { - "line-width": { - "base": 1.5, - "stops": [ - [ - 5, - 0.75 - ], - [ - 18, - 15 - ] - ] - }, - "line-color": "#fff", - "line-opacity": { - "base": 1.2, - "stops": [ - [ - 5, - 0 - ], - [ - 5.5, - 1 - ] - ] - } - } - }, - { - "id": "extrusions", - "type": "fill-extrusion", - "source": "composite", - "source-layer": "building", - "minzoom": 15, - "filter": [ - "all", - [ - "==", - "extrude", - "true" - ], - [ - "==", - "underground", - "false" - ] - ], - "layout": {}, - "paint": { - "fill-extrusion-height": { - "base": 1, - "type": "exponential", - "property": "height", - "stops": [ - [ - 0, - 0 - ], - [ - 1000, - 1501 - ], - [ - 1001, - 10 - ] - ] - }, - "fill-extrusion-color": "hsl(194, 100%, 66%)", - "fill-extrusion-base": { - "base": 1, - "type": "exponential", - "property": "min_height", - "stops": [ - [ - 0, - 0 - ], - [ - 1000, - 1501 - ], - [ - 1001, - 10 - ] - ] - } - } - } - ], - "created": "2017-02-02T19:43:09.896Z", - "id": "ciyoshhyf004r2rmqr8bd4g3h", - "modified": "2017-03-08T03:09:48.377Z", - "owner": "lbud", - "visibility": "private", - "draft": false -} diff --git a/test/style/conversion/light.test.cpp b/test/style/conversion/light.test.cpp index 37c41cfc89..da0fd3054a 100644 --- a/test/style/conversion/light.test.cpp +++ b/test/style/conversion/light.test.cpp @@ -33,34 +33,35 @@ TEST(StyleConversion, Light) { auto light = parseLight("{\"color\":{\"stops\":[[14,\"blue\"],[16,\"red\"]]},\"intensity\":0.3,\"position\":[3,90,90]}"); ASSERT_TRUE((bool) light); - ASSERT_TRUE(light->get<LightAnchor>().isUndefined()); - ASSERT_FALSE(light->get<LightAnchor>().isConstant()); - ASSERT_FALSE(light->get<LightAnchor>().isCameraFunction()); + ASSERT_TRUE(light->get<LightAnchor>().value.isUndefined()); + ASSERT_FALSE(light->get<LightAnchor>().value.isConstant()); + ASSERT_FALSE(light->get<LightAnchor>().value.isCameraFunction()); - ASSERT_FALSE(light->get<LightIntensity>().isUndefined()); - ASSERT_TRUE(light->get<LightIntensity>().isConstant()); - ASSERT_EQ(light->get<LightIntensity>().asConstant(), 0.3f); - ASSERT_FALSE(light->get<LightAnchor>().isCameraFunction()); + ASSERT_FALSE(light->get<LightIntensity>().value.isUndefined()); + ASSERT_TRUE(light->get<LightIntensity>().value.isConstant()); + ASSERT_EQ(light->get<LightIntensity>().value.asConstant(), 0.3f); + ASSERT_FALSE(light->get<LightAnchor>().value.isCameraFunction()); - ASSERT_FALSE(light->get<LightColor>().isUndefined()); - ASSERT_FALSE(light->get<LightColor>().isConstant()); - ASSERT_TRUE(light->get<LightColor>().isCameraFunction()); + ASSERT_FALSE(light->get<LightColor>().value.isUndefined()); + ASSERT_FALSE(light->get<LightColor>().value.isConstant()); + ASSERT_TRUE(light->get<LightColor>().value.isCameraFunction()); - ASSERT_FALSE(light->get<LightPosition>().isUndefined()); - ASSERT_TRUE(light->get<LightPosition>().isConstant()); + ASSERT_FALSE(light->get<LightPosition>().value.isUndefined()); + ASSERT_TRUE(light->get<LightPosition>().value.isConstant()); std::array<float, 3> expected{{ 3, 90, 90 }}; - ASSERT_EQ(light->get<LightPosition>().asConstant(), mbgl::style::Position({ expected })); - ASSERT_FALSE(light->get<LightPosition>().isCameraFunction()); + ASSERT_EQ(light->get<LightPosition>().value.asConstant(), mbgl::style::Position({ expected })); + ASSERT_FALSE(light->get<LightPosition>().value.isCameraFunction()); } { auto light = parseLight("{\"color\":\"blue\",\"intensity\":0.3,\"color-transition\":{\"duration\":1000}}"); ASSERT_TRUE((bool) light); - ASSERT_FALSE(light->get<LightColor>().isUndefined()); - ASSERT_TRUE(light->get<LightColor>().isConstant()); - ASSERT_FALSE(light->get<LightColor>().isCameraFunction()); - ASSERT_EQ(light->getTransition<LightColor>().duration, mbgl::Duration(mbgl::Milliseconds(1000))); + ASSERT_FALSE(light->get<LightColor>().value.isUndefined()); + ASSERT_TRUE(light->get<LightColor>().value.isConstant()); + ASSERT_FALSE(light->get<LightColor>().value.isCameraFunction()); + ASSERT_EQ(light->get<LightColor>().transition.duration, mbgl::Duration(mbgl::Milliseconds(1000))); + ASSERT_FALSE((bool) light->get<LightColor>().transition.delay); } { |