From e1af62e87dfd77d1c38802f082c4981dab1beeab Mon Sep 17 00:00:00 2001 From: Molly Lloyd Date: Thu, 21 Jun 2018 14:37:17 -0700 Subject: [core] add raster-resampling property (#12176) * update style-code for raster-resampling * implement user-defined raster-resampling * invert filter condition * raster-resampling -> raster-resampling-mode for darwin language conventions --- .../com/mapbox/mapboxsdk/style/layers/Property.java | 21 +++++++++++++++++++++ .../mapboxsdk/style/layers/PropertyFactory.java | 20 ++++++++++++++++++++ .../mapbox/mapboxsdk/style/layers/RasterLayer.java | 13 +++++++++++++ 3 files changed, 54 insertions(+) (limited to 'platform/android/MapboxGLAndroidSDK') 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 @@ -1335,6 +1335,26 @@ public class PropertyFactory { return new PaintPropertyValue<>("raster-contrast", expression); } + /** + * 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 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 rasterResampling(Expression expression) { + return new PaintPropertyValue<>("raster-resampling", expression); + } + /** * Fade duration when a new tile is added. * 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 @@ -263,6 +263,17 @@ public class RasterLayer extends Layer { nativeSetRasterContrastTransition(options.getDuration(), options.getDelay()); } + /** + * Get the RasterResampling property + * + * @return property wrapper value around String + */ + @SuppressWarnings("unchecked") + public PropertyValue getRasterResampling() { + checkThread(); + return (PropertyValue) new PropertyValue("raster-resampling", nativeGetRasterResampling()); + } + /** * Get the RasterFadeDuration property * @@ -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 -- cgit v1.2.1