summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-03-30 17:01:52 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-03-31 14:17:33 -0700
commit1a9bccbb850c637583c18e7409e3b87a0dd9ff79 (patch)
treecd158e3a469bfcbb1fbeab8efca43fc8ef698765 /platform
parent743d95405363e0eea1b80e8c28bde245211f7868 (diff)
downloadqtlocation-mapboxgl-1a9bccbb850c637583c18e7409e3b87a0dd9ff79.tar.gz
[core] Add DDS support for icon-image
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java45
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.h14
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.mm6
-rw-r--r--platform/darwin/test/MGLSymbolStyleLayerTests.mm7
5 files changed, 64 insertions, 14 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
index 7be8e24597..269a777050 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
@@ -1595,11 +1595,11 @@ public class PropertyFactory {
/**
* Name of image in sprite to use for drawing an image background. A string with {tokens} replaced, referencing the data property to pull from.
*
- * @param <Z> the zoom parameter type
- * @param function a wrapper {@link CameraFunction} for String
+ * @param <T> the function input type
+ * @param function a wrapper function for String
* @return property wrapper around a String function
*/
- public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> iconImage(CameraFunction<Z, String> function) {
+ public static <T> PropertyValue<Function<T, String>> iconImage(Function<T, String> function) {
return new LayoutPropertyValue<>("icon-image", function);
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
index 4c63509798..e8af375d66 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
@@ -495,6 +495,51 @@ public class SymbolLayerTest extends BaseStyleTest {
@Test
+ public void testIconImageAsIdentitySourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("icon-image");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ iconImage(property("FeaturePropertyA", Stops.<String>identity()))
+ );
+
+ // Verify
+ assertNotNull(layer.getIconImage());
+ assertNotNull(layer.getIconImage().getFunction());
+ assertEquals(SourceFunction.class, layer.getIconImage().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconImage().getFunction()).getProperty());
+ assertEquals(IdentityStops.class, layer.getIconImage().getFunction().getStops().getClass());
+ }
+
+ @Test
+ public void testIconImageAsIntervalSourceFunction() {
+ checkViewIsDisplayed(R.id.mapView);
+ Timber.i("icon-image");
+ assertNotNull(layer);
+
+ // Set
+ layer.setProperties(
+ iconImage(
+ property(
+ "FeaturePropertyA",
+ interval(
+ stop(1, iconImage("undefined"))
+ )
+ )
+ )
+ );
+
+ // Verify
+ assertNotNull(layer.getIconImage());
+ assertNotNull(layer.getIconImage().getFunction());
+ assertEquals(SourceFunction.class, layer.getIconImage().getFunction().getClass());
+ assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconImage().getFunction()).getProperty());
+ assertEquals(IntervalStops.class, layer.getIconImage().getFunction().getStops().getClass());
+ }
+
+ @Test
public void testIconRotateAsConstant() {
checkViewIsDisplayed(R.id.mapView);
Timber.i("icon-rotate");
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h
index 6d2cb18f50..2c32b36c31 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer.h
+++ b/platform/darwin/src/MGLSymbolStyleLayer.h
@@ -344,8 +344,18 @@ MGL_EXPORT
You can set this property to an instance of:
* `MGLConstantStyleValue`
- * `MGLCameraStyleFunction` with an interpolation mode of
- `MGLInterpolationModeInterval`
+ * `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<NSString *> *iconImageName;
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm
index b517909574..c01877f8dc 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer.mm
+++ b/platform/darwin/src/MGLSymbolStyleLayer.mm
@@ -240,7 +240,7 @@ namespace mbgl {
- (void)setIconImageName:(MGLStyleValue<NSString *> *)iconImageName {
MGLAssertStyleLayerIsValid();
- auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(iconImageName);
+ auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toDataDrivenPropertyValue(iconImageName);
self.rawLayer->setIconImage(mbglValue);
}
@@ -249,9 +249,9 @@ namespace mbgl {
auto propertyValue = self.rawLayer->getIconImage();
if (propertyValue.isUndefined()) {
- return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultIconImage());
+ return MGLStyleValueTransformer<std::string, NSString *>().toDataDrivenStyleValue(self.rawLayer->getDefaultIconImage());
}
- return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
+ return MGLStyleValueTransformer<std::string, NSString *>().toDataDrivenStyleValue(propertyValue);
}
- (void)setIconImage:(MGLStyleValue<NSString *> *)iconImage {
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
index c967be611d..eee61dd5d7 100644
--- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm
+++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
@@ -134,7 +134,7 @@
MGLStyleValue<NSString *> *constantStyleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Icon Image"];
layer.iconImageName = constantStyleValue;
- mbgl::style::PropertyValue<std::string> propertyValue = { "Icon Image" };
+ mbgl::style::DataDrivenPropertyValue<std::string> propertyValue = { "Icon Image" };
XCTAssertEqual(rawLayer->getIconImage(), propertyValue,
@"Setting iconImageName to a constant value should update icon-image.");
XCTAssertEqualObjects(layer.iconImageName, constantStyleValue,
@@ -158,11 +158,6 @@
@"Unsetting iconImageName should return icon-image to the default value.");
XCTAssertEqualObjects(layer.iconImageName, defaultStyleValue,
@"iconImageName should return the default value after being unset.");
-
- functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
- XCTAssertThrowsSpecificNamed(layer.iconImageName = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
- functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
- XCTAssertThrowsSpecificNamed(layer.iconImageName = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-offset