[core] add raster-dem source type and hillshade layer type (#10642)

This commit is contained in:
Molly Lloyd
2018-01-23 10:49:23 -08:00
committed by GitHub
parent 2d15aed43c
commit f3294200c6
84 changed files with 4661 additions and 56 deletions

View File

@@ -0,0 +1,308 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.UiThread;
import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
/**
* Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB tiles
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-hillshade">The online documentation</a>
*/
@UiThread
public class HillshadeLayer extends Layer {
/**
* Creates a HillshadeLayer.
*
* @param nativePtr pointer used by core
*/
public HillshadeLayer(long nativePtr) {
super(nativePtr);
}
/**
* Creates a HillshadeLayer.
*
* @param layerId the id of the layer
* @param sourceId the id of the source
*/
public HillshadeLayer(String layerId, String sourceId) {
initialize(layerId, sourceId);
}
protected native void initialize(String layerId, String sourceId);
/**
* Set the source layer.
*
* @param sourceLayer the source layer to set
*/
public void setSourceLayer(String sourceLayer) {
nativeSetSourceLayer(sourceLayer);
}
/**
* Set the source Layer.
*
* @param sourceLayer the source layer to set
* @return This
*/
public HillshadeLayer withSourceLayer(String sourceLayer) {
setSourceLayer(sourceLayer);
return this;
}
/**
* Set a property or properties.
*
* @param properties the var-args properties
* @return This
*/
public HillshadeLayer withProperties(@NonNull PropertyValue<?>... properties) {
setProperties(properties);
return this;
}
// Property getters
/**
* Get the HillshadeIlluminationDirection property
*
* @return property wrapper value around Float
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getHillshadeIlluminationDirection() {
return (PropertyValue<Float>) new PropertyValue("hillshade-illumination-direction", nativeGetHillshadeIlluminationDirection());
}
/**
* Get the HillshadeIlluminationDirection property transition options
*
* @return transition options for Float
*/
public TransitionOptions getHillshadeIlluminationDirectionTransition() {
return nativeGetHillshadeIlluminationDirectionTransition();
}
/**
* Set the HillshadeIlluminationDirection property transition options
*
* @param options transition options for Float
*/
public void setHillshadeIlluminationDirectionTransition(TransitionOptions options) {
nativeSetHillshadeIlluminationDirectionTransition(options.getDuration(), options.getDelay());
}
/**
* Get the HillshadeIlluminationAnchor property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getHillshadeIlluminationAnchor() {
return (PropertyValue<String>) new PropertyValue("hillshade-illumination-anchor", nativeGetHillshadeIlluminationAnchor());
}
/**
* Get the HillshadeExaggeration property
*
* @return property wrapper value around Float
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getHillshadeExaggeration() {
return (PropertyValue<Float>) new PropertyValue("hillshade-exaggeration", nativeGetHillshadeExaggeration());
}
/**
* Get the HillshadeExaggeration property transition options
*
* @return transition options for Float
*/
public TransitionOptions getHillshadeExaggerationTransition() {
return nativeGetHillshadeExaggerationTransition();
}
/**
* Set the HillshadeExaggeration property transition options
*
* @param options transition options for Float
*/
public void setHillshadeExaggerationTransition(TransitionOptions options) {
nativeSetHillshadeExaggerationTransition(options.getDuration(), options.getDelay());
}
/**
* Get the HillshadeShadowColor property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getHillshadeShadowColor() {
return (PropertyValue<String>) new PropertyValue("hillshade-shadow-color", nativeGetHillshadeShadowColor());
}
/**
* The shading color of areas that face away from the light source.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getHillshadeShadowColorAsInt() {
PropertyValue<String> value = getHillshadeShadowColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("hillshade-shadow-color was set as a Function");
}
}
/**
* Get the HillshadeShadowColor property transition options
*
* @return transition options for String
*/
public TransitionOptions getHillshadeShadowColorTransition() {
return nativeGetHillshadeShadowColorTransition();
}
/**
* Set the HillshadeShadowColor property transition options
*
* @param options transition options for String
*/
public void setHillshadeShadowColorTransition(TransitionOptions options) {
nativeSetHillshadeShadowColorTransition(options.getDuration(), options.getDelay());
}
/**
* Get the HillshadeHighlightColor property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getHillshadeHighlightColor() {
return (PropertyValue<String>) new PropertyValue("hillshade-highlight-color", nativeGetHillshadeHighlightColor());
}
/**
* The shading color of areas that faces towards the light source.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getHillshadeHighlightColorAsInt() {
PropertyValue<String> value = getHillshadeHighlightColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("hillshade-highlight-color was set as a Function");
}
}
/**
* Get the HillshadeHighlightColor property transition options
*
* @return transition options for String
*/
public TransitionOptions getHillshadeHighlightColorTransition() {
return nativeGetHillshadeHighlightColorTransition();
}
/**
* Set the HillshadeHighlightColor property transition options
*
* @param options transition options for String
*/
public void setHillshadeHighlightColorTransition(TransitionOptions options) {
nativeSetHillshadeHighlightColorTransition(options.getDuration(), options.getDelay());
}
/**
* Get the HillshadeAccentColor property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getHillshadeAccentColor() {
return (PropertyValue<String>) new PropertyValue("hillshade-accent-color", nativeGetHillshadeAccentColor());
}
/**
* The shading color used to accentuate rugged terrain like sharp cliffs and gorges.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getHillshadeAccentColorAsInt() {
PropertyValue<String> value = getHillshadeAccentColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("hillshade-accent-color was set as a Function");
}
}
/**
* Get the HillshadeAccentColor property transition options
*
* @return transition options for String
*/
public TransitionOptions getHillshadeAccentColorTransition() {
return nativeGetHillshadeAccentColorTransition();
}
/**
* Set the HillshadeAccentColor property transition options
*
* @param options transition options for String
*/
public void setHillshadeAccentColorTransition(TransitionOptions options) {
nativeSetHillshadeAccentColorTransition(options.getDuration(), options.getDelay());
}
private native Object nativeGetHillshadeIlluminationDirection();
private native TransitionOptions nativeGetHillshadeIlluminationDirectionTransition();
private native void nativeSetHillshadeIlluminationDirectionTransition(long duration, long delay);
private native Object nativeGetHillshadeIlluminationAnchor();
private native Object nativeGetHillshadeExaggeration();
private native TransitionOptions nativeGetHillshadeExaggerationTransition();
private native void nativeSetHillshadeExaggerationTransition(long duration, long delay);
private native Object nativeGetHillshadeShadowColor();
private native TransitionOptions nativeGetHillshadeShadowColorTransition();
private native void nativeSetHillshadeShadowColorTransition(long duration, long delay);
private native Object nativeGetHillshadeHighlightColor();
private native TransitionOptions nativeGetHillshadeHighlightColorTransition();
private native void nativeSetHillshadeHighlightColorTransition(long duration, long delay);
private native Object nativeGetHillshadeAccentColor();
private native TransitionOptions nativeGetHillshadeAccentColorTransition();
private native void nativeSetHillshadeAccentColorTransition(long duration, long delay);
@Override
protected native void finalize() throws Throwable;
}

View File

@@ -570,6 +570,27 @@ public final class Property {
@Retention(RetentionPolicy.SOURCE)
public @interface FILL_EXTRUSION_TRANSLATE_ANCHOR {}
// HILLSHADE_ILLUMINATION_ANCHOR: Direction of light source when map is rotated.
/**
* The hillshade illumination is relative to the north direction.
*/
public static final String HILLSHADE_ILLUMINATION_ANCHOR_MAP = "map";
/**
* The hillshade illumination is relative to the top of the viewport.
*/
public static final String HILLSHADE_ILLUMINATION_ANCHOR_VIEWPORT = "viewport";
/**
* Direction of light source when map is rotated.
*/
@StringDef({
HILLSHADE_ILLUMINATION_ANCHOR_MAP,
HILLSHADE_ILLUMINATION_ANCHOR_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface HILLSHADE_ILLUMINATION_ANCHOR {}
// ANCHOR: Whether extruded geometries are lit relative to the map or viewport.
/**

View File

@@ -1987,6 +1987,234 @@ public class PropertyFactory {
return new PaintPropertyValue<>("raster-fade-duration", function);
}
/**
* The direction of the light source used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> hillshadeIlluminationDirection(Float value) {
return new PaintPropertyValue<>("hillshade-illumination-direction", value);
}
/**
* The direction of the light source used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> hillshadeIlluminationDirection(Expression expression) {
return new PaintPropertyValue<>("hillshade-illumination-direction", expression);
}
/**
* The direction of the light source used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @return property wrapper around a Float function
*/
@Deprecated
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> hillshadeIlluminationDirection(CameraFunction<Z, Float> function) {
return new PaintPropertyValue<>("hillshade-illumination-direction", function);
}
/**
* Direction of light source when map is rotated.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> hillshadeIlluminationAnchor(@Property.HILLSHADE_ILLUMINATION_ANCHOR String value) {
return new PaintPropertyValue<>("hillshade-illumination-anchor", value);
}
/**
* Direction of light source when map is rotated.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> hillshadeIlluminationAnchor(Expression expression) {
return new PaintPropertyValue<>("hillshade-illumination-anchor", expression);
}
/**
* Direction of light source when map is rotated.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @return property wrapper around a String function
*/
@Deprecated
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> hillshadeIlluminationAnchor(CameraFunction<Z, String> function) {
return new PaintPropertyValue<>("hillshade-illumination-anchor", function);
}
/**
* Intensity of the hillshade
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> hillshadeExaggeration(Float value) {
return new PaintPropertyValue<>("hillshade-exaggeration", value);
}
/**
* Intensity of the hillshade
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> hillshadeExaggeration(Expression expression) {
return new PaintPropertyValue<>("hillshade-exaggeration", expression);
}
/**
* Intensity of the hillshade
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @return property wrapper around a Float function
*/
@Deprecated
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> hillshadeExaggeration(CameraFunction<Z, Float> function) {
return new PaintPropertyValue<>("hillshade-exaggeration", function);
}
/**
* The shading color of areas that face away from the light source.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static PropertyValue<String> hillshadeShadowColor(@ColorInt int value) {
return new PaintPropertyValue<>("hillshade-shadow-color", colorToRgbaString(value));
}
/**
* The shading color of areas that face away from the light source.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> hillshadeShadowColor(String value) {
return new PaintPropertyValue<>("hillshade-shadow-color", value);
}
/**
* The shading color of areas that face away from the light source.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> hillshadeShadowColor(Expression expression) {
return new PaintPropertyValue<>("hillshade-shadow-color", expression);
}
/**
* The shading color of areas that face away from the light source.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @return property wrapper around a String function
*/
@Deprecated
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> hillshadeShadowColor(CameraFunction<Z, String> function) {
return new PaintPropertyValue<>("hillshade-shadow-color", function);
}
/**
* The shading color of areas that faces towards the light source.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static PropertyValue<String> hillshadeHighlightColor(@ColorInt int value) {
return new PaintPropertyValue<>("hillshade-highlight-color", colorToRgbaString(value));
}
/**
* The shading color of areas that faces towards the light source.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> hillshadeHighlightColor(String value) {
return new PaintPropertyValue<>("hillshade-highlight-color", value);
}
/**
* The shading color of areas that faces towards the light source.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> hillshadeHighlightColor(Expression expression) {
return new PaintPropertyValue<>("hillshade-highlight-color", expression);
}
/**
* The shading color of areas that faces towards the light source.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @return property wrapper around a String function
*/
@Deprecated
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> hillshadeHighlightColor(CameraFunction<Z, String> function) {
return new PaintPropertyValue<>("hillshade-highlight-color", function);
}
/**
* The shading color used to accentuate rugged terrain like sharp cliffs and gorges.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static PropertyValue<String> hillshadeAccentColor(@ColorInt int value) {
return new PaintPropertyValue<>("hillshade-accent-color", colorToRgbaString(value));
}
/**
* The shading color used to accentuate rugged terrain like sharp cliffs and gorges.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> hillshadeAccentColor(String value) {
return new PaintPropertyValue<>("hillshade-accent-color", value);
}
/**
* The shading color used to accentuate rugged terrain like sharp cliffs and gorges.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> hillshadeAccentColor(Expression expression) {
return new PaintPropertyValue<>("hillshade-accent-color", expression);
}
/**
* The shading color used to accentuate rugged terrain like sharp cliffs and gorges.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @return property wrapper around a String function
*/
@Deprecated
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> hillshadeAccentColor(CameraFunction<Z, String> function) {
return new PaintPropertyValue<>("hillshade-accent-color", function);
}
/**
* The color with which the background will be drawn.
*

View File

@@ -78,7 +78,7 @@ public class <%- camelize(type) %>Layer extends Layer {
}
<% } -%>
<% if (type !== 'background' && type !== 'raster') { -%>
<% if (type !== 'background' && type !== 'raster' && type !== 'hillshade') { -%>
/**
* Get the source layer.
*