summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMolly Lloyd <molly@mapbox.com>2018-06-19 10:41:01 -0700
committerMolly Lloyd <molly@mapbox.com>2018-06-19 14:54:38 -0700
commite371917c18d20fc5c9c3aea00a89d436d5f30f40 (patch)
tree2f1d0230ef90db6b5ecfe6bbb59c27b9f76f71b0
parent325ad2f711d038876c0180ac1022c265521e9578 (diff)
downloadqtlocation-mapboxgl-e371917c18d20fc5c9c3aea00a89d436d5f30f40.tar.gz
update style-code for raster-resampling
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp6
m---------mapbox-gl-js0
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java21
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java20
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java14
-rw-r--r--platform/android/src/style/conversion/types.hpp7
-rw-r--r--platform/android/src/style/conversion/types_string_values.hpp14
-rw-r--r--platform/android/src/style/layers/raster_layer.cpp7
-rw-r--r--platform/android/src/style/layers/raster_layer.hpp2
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.h72
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.mm40
-rw-r--r--platform/darwin/test/MGLRasterStyleLayerTests.mm49
-rw-r--r--src/mbgl/style/conversion/make_property_setters.hpp2
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp27
-rw-r--r--src/mbgl/style/layers/raster_layer_properties.hpp5
16 files changed, 299 insertions, 0 deletions
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index 8111364709..8e7849c27d 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -67,6 +67,12 @@ public:
void setRasterContrastTransition(const TransitionOptions&);
TransitionOptions getRasterContrastTransition() const;
+ static PropertyValue<RasterResamplingType> getDefaultRasterResampling();
+ PropertyValue<RasterResamplingType> getRasterResampling() const;
+ void setRasterResampling(PropertyValue<RasterResamplingType>);
+ void setRasterResamplingTransition(const TransitionOptions&);
+ TransitionOptions getRasterResamplingTransition() const;
+
static PropertyValue<float> getDefaultRasterFadeDuration();
PropertyValue<float> getRasterFadeDuration() const;
void setRasterFadeDuration(PropertyValue<float>);
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject 45b0be007cd5df6837e5381e067b9c2a42b7850
+Subproject f546de26b9b531a84fe621a5f51f4c0f791e57f
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
index e52474c35b..c264d773c5 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
@@ -570,6 +570,27 @@ public final class Property {
@Retention(RetentionPolicy.SOURCE)
public @interface FILL_EXTRUSION_TRANSLATE_ANCHOR {}
+ // RASTER_RESAMPLING: The resampling/interpolation method to use for overscaling, also known as texture magnification filter
+
+ /**
+ * (Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled
+ */
+ public static final String RASTER_RESAMPLING_LINEAR = "linear";
+ /**
+ * Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled
+ */
+ public static final String RASTER_RESAMPLING_NEAREST = "nearest";
+
+ /**
+ * The resampling/interpolation method to use for overscaling, also known as texture magnification filter
+ */
+ @StringDef({
+ RASTER_RESAMPLING_LINEAR,
+ RASTER_RESAMPLING_NEAREST,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface RASTER_RESAMPLING {}
+
// HILLSHADE_ILLUMINATION_ANCHOR: Direction of light source when map is rotated.
/**
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 57638920be..5338fb84f6 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
@@ -1336,6 +1336,26 @@ public class PropertyFactory {
}
/**
+ * The resampling/interpolation method to use for overscaling, also known as texture magnification filter
+ *
+ * @param value a String value
+ * @return property wrapper around String
+ */
+ public static PropertyValue<String> rasterResampling(@Property.RASTER_RESAMPLING String value) {
+ return new PaintPropertyValue<>("raster-resampling", value);
+ }
+
+ /**
+ * The resampling/interpolation method to use for overscaling, also known as texture magnification filter
+ *
+ * @param expression an expression statement
+ * @return property wrapper around an expression statement
+ */
+ public static PropertyValue<Expression> rasterResampling(Expression expression) {
+ return new PaintPropertyValue<>("raster-resampling", expression);
+ }
+
+ /**
* Fade duration when a new tile is added.
*
* @param value a Float value
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java
index 218ed36744..1214f7b11c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java
@@ -264,6 +264,17 @@ public class RasterLayer extends Layer {
}
/**
+ * Get the RasterResampling property
+ *
+ * @return property wrapper value around String
+ */
+ @SuppressWarnings("unchecked")
+ public PropertyValue<String> getRasterResampling() {
+ checkThread();
+ return (PropertyValue<String>) new PropertyValue("raster-resampling", nativeGetRasterResampling());
+ }
+
+ /**
* Get the RasterFadeDuration property
*
* @return property wrapper value around Float
@@ -310,6 +321,8 @@ public class RasterLayer extends Layer {
private native void nativeSetRasterContrastTransition(long duration, long delay);
+ private native Object nativeGetRasterResampling();
+
private native Object nativeGetRasterFadeDuration();
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
index 6e5afdb479..8440fad20a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
@@ -242,6 +242,20 @@ public class RasterLayerTest extends BaseActivityTest {
}
@Test
+ public void testRasterResamplingAsConstant() {
+ validateTestSetup();
+ setupLayer();
+ Timber.i("raster-resampling");
+ invoke(mapboxMap, (uiController, mapboxMap) -> {
+ assertNotNull(layer);
+
+ // Set and Get
+ layer.setProperties(rasterResampling(RASTER_RESAMPLING_LINEAR));
+ assertEquals((String) layer.getRasterResampling().getValue(), (String) RASTER_RESAMPLING_LINEAR);
+ });
+ }
+
+ @Test
public void testRasterFadeDurationAsConstant() {
validateTestSetup();
setupLayer();
diff --git a/platform/android/src/style/conversion/types.hpp b/platform/android/src/style/conversion/types.hpp
index 8a75b870b3..e87782fad0 100644
--- a/platform/android/src/style/conversion/types.hpp
+++ b/platform/android/src/style/conversion/types.hpp
@@ -93,6 +93,13 @@ struct Converter<jni::jobject*, mbgl::style::CirclePitchScaleType> {
};
template <>
+struct Converter<jni::jobject*, mbgl::style::RasterResamplingType> {
+ Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::RasterResamplingType& value) const {
+ return convert<jni::jobject*, std::string>(env, toString(value));
+ }
+};
+
+template <>
struct Converter<jni::jobject*, mbgl::style::HillshadeIlluminationAnchorType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::HillshadeIlluminationAnchorType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
diff --git a/platform/android/src/style/conversion/types_string_values.hpp b/platform/android/src/style/conversion/types_string_values.hpp
index 7e4fd4a7f7..ff79fa4f1c 100644
--- a/platform/android/src/style/conversion/types_string_values.hpp
+++ b/platform/android/src/style/conversion/types_string_values.hpp
@@ -206,6 +206,20 @@ namespace conversion {
}
}
+ // raster-resampling
+ inline std::string toString(mbgl::style::RasterResamplingType value) {
+ switch (value) {
+ case mbgl::style::RasterResamplingType::Linear:
+ return "linear";
+ break;
+ case mbgl::style::RasterResamplingType::Nearest:
+ return "nearest";
+ break;
+ default:
+ throw std::runtime_error("Not implemented");
+ }
+ }
+
// hillshade-illumination-anchor
inline std::string toString(mbgl::style::HillshadeIlluminationAnchorType value) {
switch (value) {
diff --git a/platform/android/src/style/layers/raster_layer.cpp b/platform/android/src/style/layers/raster_layer.cpp
index 6d36298bb1..53086951e4 100644
--- a/platform/android/src/style/layers/raster_layer.cpp
+++ b/platform/android/src/style/layers/raster_layer.cpp
@@ -149,6 +149,12 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterContrastTransition(options);
}
+ jni::Object<jni::ObjectTag> RasterLayer::getRasterResampling(jni::JNIEnv& env) {
+ using namespace mbgl::android::conversion;
+ Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterResampling());
+ return jni::Object<jni::ObjectTag>(*converted);
+ }
+
jni::Object<jni::ObjectTag> RasterLayer::getRasterFadeDuration(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterFadeDuration());
@@ -193,6 +199,7 @@ namespace android {
METHOD(&RasterLayer::getRasterContrastTransition, "nativeGetRasterContrastTransition"),
METHOD(&RasterLayer::setRasterContrastTransition, "nativeSetRasterContrastTransition"),
METHOD(&RasterLayer::getRasterContrast, "nativeGetRasterContrast"),
+ METHOD(&RasterLayer::getRasterResampling, "nativeGetRasterResampling"),
METHOD(&RasterLayer::getRasterFadeDuration, "nativeGetRasterFadeDuration"));
}
diff --git a/platform/android/src/style/layers/raster_layer.hpp b/platform/android/src/style/layers/raster_layer.hpp
index ed6fc3e1b2..d1c1b45234 100644
--- a/platform/android/src/style/layers/raster_layer.hpp
+++ b/platform/android/src/style/layers/raster_layer.hpp
@@ -53,6 +53,8 @@ public:
void setRasterContrastTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Object<TransitionOptions> getRasterContrastTransition(jni::JNIEnv&);
+ jni::Object<jni::ObjectTag> getRasterResampling(jni::JNIEnv&);
+
jni::Object<jni::ObjectTag> getRasterFadeDuration(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h
index ff055d24f6..e351295289 100644
--- a/platform/darwin/src/MGLRasterStyleLayer.h
+++ b/platform/darwin/src/MGLRasterStyleLayer.h
@@ -7,6 +7,27 @@
NS_ASSUME_NONNULL_BEGIN
/**
+ The resampling/interpolation method to use for overscaling, also known as
+ texture magnification filter
+
+ Values of this type are used in the `MGLRasterStyleLayer.rasterResampling`
+ property.
+ */
+typedef NS_ENUM(NSUInteger, MGLRasterResampling) {
+ /**
+ (Bi)linear filtering interpolates point values using the weighted average
+ of the four closest original source points creating a smooth but blurry
+ look when overscaled
+ */
+ MGLRasterResamplingLinear,
+ /**
+ Nearest neighbor filtering interpolates point values using the nearest
+ original source point creating a sharp but pointated look when overscaled
+ */
+ MGLRasterResamplingNearest,
+};
+
+/**
An `MGLRasterStyleLayer` is a style layer that renders georeferenced raster
imagery on the map, especially raster tiles.
@@ -233,6 +254,34 @@ MGL_EXPORT
@property (nonatomic) MGLTransition rasterOpacityTransition;
/**
+ The resampling/interpolation method to use for overscaling, also known as
+ texture magnification filter
+
+ The default value of this property is an expression that evaluates to `linear`.
+ 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:
+
+ * Constant `MGLRasterResampling` values
+ * Any of the following constant string values:
+ * `linear`: (Bi)linear filtering interpolates pixel values using the weighted
+ average of the four closest original source pixels creating a smooth but blurry
+ look when overscaled
+ * `nearest`: Nearest neighbor filtering interpolates pixel values using the
+ nearest original source pixel creating a sharp but pixelated look when
+ overscaled
+ * Predefined functions, including mathematical and string operators
+ * Conditional expressions
+ * Variable assignments and references to assigned variables
+ * Step functions applied to the `$zoomLevel` variable
+
+ This property does not support applying interpolation functions to the
+ `$zoomLevel` variable or applying interpolation or step functions to feature
+ attributes.
+ */
+@property (nonatomic, null_resettable) NSExpression *rasterResampling;
+
+/**
Increase or reduce the saturation of the image.
The default value of this property is an expression that evaluates to the float
@@ -260,4 +309,27 @@ MGL_EXPORT
@end
+/**
+ Methods for wrapping an enumeration value for a style layer attribute in an
+ `MGLRasterStyleLayer` object and unwrapping its raw value.
+ */
+@interface NSValue (MGLRasterStyleLayerAdditions)
+
+#pragma mark Working with Raster Style Layer Attribute Values
+
+/**
+ Creates a new value object containing the given `MGLRasterResampling` enumeration.
+
+ @param rasterResampling The value for the new object.
+ @return A new value object that contains the enumeration value.
+ */
++ (instancetype)valueWithMGLRasterResampling:(MGLRasterResampling)rasterResampling;
+
+/**
+ The `MGLRasterResampling` enumeration representation of the value.
+ */
+@property (readonly) MGLRasterResampling MGLRasterResamplingValue;
+
+@end
+
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm
index 0e31512491..e150e24863 100644
--- a/platform/darwin/src/MGLRasterStyleLayer.mm
+++ b/platform/darwin/src/MGLRasterStyleLayer.mm
@@ -11,6 +11,15 @@
#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
+namespace mbgl {
+
+ MBGL_DEFINE_ENUM(MGLRasterResampling, {
+ { MGLRasterResamplingLinear, "linear" },
+ { MGLRasterResamplingNearest, "nearest" },
+ });
+
+}
+
@interface MGLRasterStyleLayer ()
@property (nonatomic, readonly) mbgl::style::RasterLayer *rawLayer;
@@ -252,6 +261,23 @@
return transition;
}
+- (void)setRasterResampling:(NSExpression *)rasterResampling {
+ MGLAssertStyleLayerIsValid();
+
+ auto mbglValue = MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResampling>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::RasterResamplingType>>(rasterResampling);
+ self.rawLayer->setRasterResampling(mbglValue);
+}
+
+- (NSExpression *)rasterResampling {
+ MGLAssertStyleLayerIsValid();
+
+ auto propertyValue = self.rawLayer->getRasterResampling();
+ if (propertyValue.isUndefined()) {
+ propertyValue = self.rawLayer->getDefaultRasterResampling();
+ }
+ return MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResampling>().toExpression(propertyValue);
+}
+
- (void)setRasterSaturation:(NSExpression *)rasterSaturation {
MGLAssertStyleLayerIsValid();
@@ -288,3 +314,17 @@
}
@end
+
+@implementation NSValue (MGLRasterStyleLayerAdditions)
+
++ (NSValue *)valueWithMGLRasterResampling:(MGLRasterResampling)rasterResampling {
+ return [NSValue value:&rasterResampling withObjCType:@encode(MGLRasterResampling)];
+}
+
+- (MGLRasterResampling)MGLRasterResamplingValue {
+ MGLRasterResampling rasterResampling;
+ [self getValue:&rasterResampling];
+ return rasterResampling;
+}
+
+@end
diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.mm b/platform/darwin/test/MGLRasterStyleLayerTests.mm
index cf5175812e..f71cc24d07 100644
--- a/platform/darwin/test/MGLRasterStyleLayerTests.mm
+++ b/platform/darwin/test/MGLRasterStyleLayerTests.mm
@@ -306,6 +306,49 @@
XCTAssertEqual(rasterOpacityTransition.duration, transitionTest.duration);
}
+ // raster-resampling
+ {
+ XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(),
+ @"raster-resampling should be unset initially.");
+ NSExpression *defaultExpression = layer.rasterResampling;
+
+ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'nearest'"];
+ layer.rasterResampling = constantExpression;
+ mbgl::style::PropertyValue<mbgl::style::RasterResamplingType> propertyValue = { mbgl::style::RasterResamplingType::Nearest };
+ XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
+ @"Setting rasterResampling to a constant value expression should update raster-resampling.");
+ XCTAssertEqualObjects(layer.rasterResampling, constantExpression,
+ @"rasterResampling should round-trip constant value expressions.");
+
+ constantExpression = [NSExpression expressionWithFormat:@"'nearest'"];
+ NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
+ layer.rasterResampling = functionExpression;
+
+ mbgl::style::IntervalStops<mbgl::style::RasterResamplingType> intervalStops = {{
+ { -INFINITY, mbgl::style::RasterResamplingType::Nearest },
+ { 18, mbgl::style::RasterResamplingType::Nearest },
+ }};
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::RasterResamplingType> { intervalStops };
+
+ XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
+ @"Setting rasterResampling to a camera expression should update raster-resampling.");
+ XCTAssertEqualObjects(layer.rasterResampling, functionExpression,
+ @"rasterResampling should round-trip camera expressions.");
+
+
+ layer.rasterResampling = nil;
+ XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(),
+ @"Unsetting rasterResampling should return raster-resampling to the default value.");
+ XCTAssertEqualObjects(layer.rasterResampling, defaultExpression,
+ @"rasterResampling should return the default value after being unset.");
+
+ functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
+ XCTAssertThrowsSpecificNamed(layer.rasterResampling = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
+ functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
+ functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
+ XCTAssertThrowsSpecificNamed(layer.rasterResampling = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
+ }
+
// raster-saturation
{
XCTAssertTrue(rawLayer->getRasterSaturation().isUndefined(),
@@ -366,7 +409,13 @@
[self testPropertyName:@"raster-fade-duration" isBoolean:NO];
[self testPropertyName:@"raster-hue-rotation" isBoolean:NO];
[self testPropertyName:@"raster-opacity" isBoolean:NO];
+ [self testPropertyName:@"raster-resampling" isBoolean:NO];
[self testPropertyName:@"raster-saturation" isBoolean:NO];
}
+- (void)testValueAdditions {
+ XCTAssertEqual([NSValue valueWithMGLRasterResampling:MGLRasterResamplingLinear].MGLRasterResamplingValue, MGLRasterResamplingLinear);
+ XCTAssertEqual([NSValue valueWithMGLRasterResampling:MGLRasterResamplingNearest].MGLRasterResamplingValue, MGLRasterResamplingNearest);
+}
+
@end
diff --git a/src/mbgl/style/conversion/make_property_setters.hpp b/src/mbgl/style/conversion/make_property_setters.hpp
index 25c8fdb1ca..40461fc1e7 100644
--- a/src/mbgl/style/conversion/make_property_setters.hpp
+++ b/src/mbgl/style/conversion/make_property_setters.hpp
@@ -206,6 +206,8 @@ inline auto makePaintPropertySetters() {
result["raster-saturation-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterSaturationTransition>;
result["raster-contrast"] = &setProperty<RasterLayer, PropertyValue<float>, &RasterLayer::setRasterContrast>;
result["raster-contrast-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterContrastTransition>;
+ result["raster-resampling"] = &setProperty<RasterLayer, PropertyValue<RasterResamplingType>, &RasterLayer::setRasterResampling>;
+ result["raster-resampling-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterResamplingTransition>;
result["raster-fade-duration"] = &setProperty<RasterLayer, PropertyValue<float>, &RasterLayer::setRasterFadeDuration>;
result["raster-fade-duration-transition"] = &setTransition<RasterLayer, &RasterLayer::setRasterFadeDurationTransition>;
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 36b2e3e027..e5b03df0f6 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -236,6 +236,33 @@ TransitionOptions RasterLayer::getRasterContrastTransition() const {
return impl().paint.template get<RasterContrast>().options;
}
+PropertyValue<RasterResamplingType> RasterLayer::getDefaultRasterResampling() {
+ return { RasterResamplingType::Linear };
+}
+
+PropertyValue<RasterResamplingType> RasterLayer::getRasterResampling() const {
+ return impl().paint.template get<RasterResampling>().value;
+}
+
+void RasterLayer::setRasterResampling(PropertyValue<RasterResamplingType> value) {
+ if (value == getRasterResampling())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<RasterResampling>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void RasterLayer::setRasterResamplingTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<RasterResampling>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions RasterLayer::getRasterResamplingTransition() const {
+ return impl().paint.template get<RasterResampling>().options;
+}
+
PropertyValue<float> RasterLayer::getDefaultRasterFadeDuration() {
return { 300 };
}
diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp
index 12df09f32c..08818c9fb3 100644
--- a/src/mbgl/style/layers/raster_layer_properties.hpp
+++ b/src/mbgl/style/layers/raster_layer_properties.hpp
@@ -36,6 +36,10 @@ struct RasterContrast : PaintProperty<float> {
static float defaultValue() { return 0; }
};
+struct RasterResampling : PaintProperty<RasterResamplingType> {
+ static RasterResamplingType defaultValue() { return RasterResamplingType::Linear; }
+};
+
struct RasterFadeDuration : PaintProperty<float> {
static float defaultValue() { return 300; }
};
@@ -47,6 +51,7 @@ class RasterPaintProperties : public Properties<
RasterBrightnessMax,
RasterSaturation,
RasterContrast,
+ RasterResampling,
RasterFadeDuration
> {};