diff options
19 files changed, 473 insertions, 90 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java index 394a3ed5fd..893ffbc1ec 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java @@ -9,7 +9,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * Background Layer + * The background color or pattern of the map. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-background">The online documentation</a> */ public class BackgroundLayer extends Layer { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java index 79e5257ae9..a9f081b2fa 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java @@ -9,7 +9,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * Circle Layer + * A filled circle. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-circle">The online documentation</a> */ public class CircleLayer extends Layer { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java index 8c3bb01c39..e19dc20283 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java @@ -9,7 +9,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * Fill Layer + * A filled polygon with an optional stroked border. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-fill">The online documentation</a> */ public class FillLayer extends Layer { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java index a0d065a6e9..4d9791b125 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java @@ -1,16 +1,18 @@ package com.mapbox.mapboxsdk.style.layers; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; /** - * Utility to build filter expressions more easily: + * Utility to build filter expressions more easily. * - * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-filter">Style spec</a> + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-filter">The online documentation</a> */ public class Filter { + /** + * Base {@link Filter} statement. Subclassed to provide concrete statements. + */ public abstract static class Statement { protected final String operator; @@ -18,13 +20,26 @@ public class Filter { this.operator = operator; } + /** + * Generate a raw array representation of the filter + * + * @return the filter represented as an array + */ public abstract Object[] toArray(); } + /** + * Represents a {@link Filter} statement. Can be unary (eg `has()`, etc) or take any number of values. + */ public static class SimpleStatement extends Statement { private final String key; private final Object[] values; + /** + * @param operator the operator (eg `=`, etc) + * @param key the property key + * @param values the values to operate on, if any + */ public SimpleStatement(String operator, String key, Object... values) { super(operator); this.key = key; @@ -32,6 +47,9 @@ public class Filter { } + /** + * {@inheritDoc} + */ @Override public Object[] toArray() { ArrayList<Object> array = new ArrayList<>(2 + values.length); @@ -42,14 +60,24 @@ public class Filter { } } + /** + * Represents a collection of {@link Statement}s with an operator that describes their relationship + */ public static class CompoundStatement extends Statement { private final Statement[] statements; + /** + * @param operator the relationship operator + * @param statements the statements to compound + */ public CompoundStatement(String operator, Statement... statements) { super(operator); this.statements = statements; } + /** + * {@inheritDoc} + */ @Override public Object[] toArray() { ArrayList<Object> array = new ArrayList<>(1 + statements.length); @@ -61,54 +89,140 @@ public class Filter { } } + /** + * Groups a collection of statements in an 'all' relationship + * + * @param statements the collection of statements + * @return the statements compounded + */ public static Statement all(Statement... statements) { return new CompoundStatement("all", statements); } + /** + * Groups a collection of statements in an 'any' relationship + * + * @param statements the collection of statements + * @return the statements compounded + */ public static Statement any(Statement... statements) { return new CompoundStatement("any", statements); } + /** + * Groups a collection of statements in an 'none' relationship + * + * @param statements the collection of statements + * @return the statements compounded + */ public static Statement none(Statement... statements) { return new CompoundStatement("none", statements); } + /** + * Check the property's existence + * + * @param key the property key + * @return the statement + */ public static Statement has(String key) { return new SimpleStatement("has", key); } + /** + * Check the property's existence, negated + * + * @param key the property key + * @return the statement + */ public static Statement notHas(String key) { return new SimpleStatement("!has", key); } + /** + * Check the property equals the given value + * + * @param key the property key + * @param value the value to check against + * @return the statement + */ public static Statement eq(String key, Object value) { return new SimpleStatement("==", key, value); } + /** + * Check the property does not equals the given value + * + * @param key the property key + * @param value the value to check against + * @return the statement + */ public static Statement neq(String key, Object value) { return new SimpleStatement("!=", key, value); } + /** + * Check the property exceeds the given value + * + * @param key the property key + * @param value the value to check against + * @return the statement + */ public static Statement gt(String key, Object value) { return new SimpleStatement(">", key, value); } + /** + * Check the property exceeds or equals the given value + * + * @param key the property key + * @param value the value to check against + * @return the statement + */ public static Statement gte(String key, Object value) { return new SimpleStatement(">=", key, value); } + /** + * Check the property does not exceeds the given value + * + * @param key the property key + * @param value the value to check against + * @return the statement + */ public static Statement lt(String key, Object value) { return new SimpleStatement("<", key, value); } + /** + * Check the property equals or does not exceeds the given value + * + * @param key the property key + * @param value the value to check against + * @return the statement + */ public static Statement lte(String key, Object value) { return new SimpleStatement("<=", key, value); } + /** + * Check the property is within the given set + * + * @param key the property key + * @param values the set of values to check against + * @return the statement + */ public static Statement in(String key, Object... values) { return new SimpleStatement("in", key, values); } + /** + * Check the property is not within the given set + * + * @param key the property key + * @param values the set of values to check against + * @return the statement + */ public static Statement notIn(String key, Object... values) { return new SimpleStatement("!in", key, values); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java index 77454cc704..e147b5204f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java @@ -9,12 +9,22 @@ import java.util.HashMap; import java.util.Map; /** - * Representation of <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">Function</a> in the Mapbox style specification + * Functions are used to change properties in relation to the state of the map. + * <p> + * Currently, only zoom functions are supported. + * </p> * * @param <T> the target property's value type. Make sure it matches. + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The online documentation</a> */ public class Function<T> { + /** + * A stop represents a certain point in the range of this function + * + * @param <I> input + * @param <O> output + */ public static class Stop<I, O> { public final I in; public final O out; @@ -24,6 +34,9 @@ public class Function<T> { this.out = out; } + /** + * @return an array representation of the Stop + */ Object[] toValueObject() { return new Object[]{in, out}; } @@ -34,11 +47,31 @@ public class Function<T> { } } + /** + * Zoom functions allow the appearance of a map feature to change with map’s zoom. + * Zoom functions can be used to create the illusion of depth and control data density. + * Each stop is an array with two elements, the first is a zoom and the second is a function output value. + * + * @param stops the stops that define the function + * @param <T> the property type + * @return the {@link Function} + */ @SafeVarargs public static <T> Function<T> zoom(@NonNull @Size(min = 1) Stop<Float, T>... stops) { return new Function<T>(stops); } + + /** + * Zoom functions allow the appearance of a map feature to change with map’s zoom. + * Zoom functions can be used to create the illusion of depth and control data density. + * Each stop is an array with two elements, the first is a zoom and the second is a function output value. + * + * @param stops the stops that define the function + * @param base the exponential base of the interpolation curve - Default 1 + * @param <T> the property type + * @return the {@link Function} + */ @SafeVarargs public static <T> Function<T> zoom( @FloatRange(from = 0, to = 1, fromInclusive = false, toInclusive = false) float base, @@ -47,6 +80,14 @@ public class Function<T> { .withBase(base); } + /** + * Creates a stop to use in a {@link Function} + * + * @param in the input for the stop + * @param output the output for the stop + * @param <T> the output property type + * @return the {@link Stop} + */ public static <T> Stop<Float, T> stop(float in, Property<T> output) { return new Stop<>(in, output.value); } @@ -63,11 +104,17 @@ public class Function<T> { return this; } + /** + * @return the base + */ @Nullable public Float getBase() { return base; } + /** + * @return the stops in this function + */ public Stop<Float, T>[] getStops() { return stops; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java index 14bf21de84..896558a011 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java @@ -9,7 +9,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * Line Layer + * A stroked line. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-line">The online documentation</a> */ public class LineLayer extends Layer { 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 aecfb3ab58..383d4217a8 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 @@ -44,6 +44,9 @@ public abstract class Property<T> { */ public static final String LINE_CAP_SQUARE = "square"; + /** + * The display of line endings. + */ @StringDef({ LINE_CAP_BUTT, LINE_CAP_ROUND, @@ -67,6 +70,9 @@ public abstract class Property<T> { */ public static final String LINE_JOIN_MITER = "miter"; + /** + * The display of lines when joining. + */ @StringDef({ LINE_JOIN_BEVEL, LINE_JOIN_ROUND, @@ -82,10 +88,13 @@ public abstract class Property<T> { */ public static final String SYMBOL_PLACEMENT_POINT = "point"; /** - * The label is placed along the line of the geometry. Can only be used on `LineString` and `Polygon` geometries. + * The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries. */ public static final String SYMBOL_PLACEMENT_LINE = "line"; + /** + * Label placement relative to its geometry. + */ @StringDef({ SYMBOL_PLACEMENT_POINT, SYMBOL_PLACEMENT_LINE, @@ -96,18 +105,21 @@ public abstract class Property<T> { //ICON_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of icons. /** - * When `symbol-placement` is set to `point`, aligns icons east-west. When `symbol-placement` is set to `line`, aligns icon x-axes with the line. + * When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns icon x-axes with the line. */ public static final String ICON_ROTATION_ALIGNMENT_MAP = "map"; /** - * Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`. + * Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}. */ public static final String ICON_ROTATION_ALIGNMENT_VIEWPORT = "viewport"; /** - * When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line`, this is equivalent to `map`. + * When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}. */ public static final String ICON_ROTATION_ALIGNMENT_AUTO = "auto"; + /** + * In combination with `symbol-placement`, determines the rotation behavior of icons. + */ @StringDef({ ICON_ROTATION_ALIGNMENT_MAP, ICON_ROTATION_ALIGNMENT_VIEWPORT, @@ -135,6 +147,9 @@ public abstract class Property<T> { */ public static final String ICON_TEXT_FIT_BOTH = "both"; + /** + * Scales the icon to fit around the associated text. + */ @StringDef({ ICON_TEXT_FIT_NONE, ICON_TEXT_FIT_WIDTH, @@ -155,10 +170,13 @@ public abstract class Property<T> { */ public static final String TEXT_PITCH_ALIGNMENT_VIEWPORT = "viewport"; /** - * Automatically matches the value of `text-rotation-alignment`. + * Automatically matches the value of {@link TEXT_ROTATION_ALIGNMENT}. */ public static final String TEXT_PITCH_ALIGNMENT_AUTO = "auto"; + /** + * Orientation of text when map is pitched. + */ @StringDef({ TEXT_PITCH_ALIGNMENT_MAP, TEXT_PITCH_ALIGNMENT_VIEWPORT, @@ -170,18 +188,21 @@ public abstract class Property<T> { //TEXT_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text. /** - * When `symbol-placement` is set to `point`, aligns text east-west. When `symbol-placement` is set to `line`, aligns text x-axes with the line. + * When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns text x-axes with the line. */ public static final String TEXT_ROTATION_ALIGNMENT_MAP = "map"; /** - * Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`. + * Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}. */ public static final String TEXT_ROTATION_ALIGNMENT_VIEWPORT = "viewport"; /** - * When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line`, this is equivalent to `map`. + * When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}. */ public static final String TEXT_ROTATION_ALIGNMENT_AUTO = "auto"; + /** + * In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text. + */ @StringDef({ TEXT_ROTATION_ALIGNMENT_MAP, TEXT_ROTATION_ALIGNMENT_VIEWPORT, @@ -205,6 +226,9 @@ public abstract class Property<T> { */ public static final String TEXT_JUSTIFY_RIGHT = "right"; + /** + * Text justification options. + */ @StringDef({ TEXT_JUSTIFY_LEFT, TEXT_JUSTIFY_CENTER, @@ -252,6 +276,9 @@ public abstract class Property<T> { */ public static final String TEXT_ANCHOR_BOTTOM_RIGHT = "bottom-right"; + /** + * Part of the text placed closest to the anchor. + */ @StringDef({ TEXT_ANCHOR_CENTER, TEXT_ANCHOR_LEFT, @@ -281,6 +308,9 @@ public abstract class Property<T> { */ public static final String TEXT_TRANSFORM_LOWERCASE = "lowercase"; + /** + * Specifies how to capitalize text, similar to the CSS `text-transform` property. + */ @StringDef({ TEXT_TRANSFORM_NONE, TEXT_TRANSFORM_UPPERCASE, @@ -300,6 +330,9 @@ public abstract class Property<T> { */ public static final String FILL_TRANSLATE_ANCHOR_VIEWPORT = "viewport"; + /** + * Controls the translation reference point. + */ @StringDef({ FILL_TRANSLATE_ANCHOR_MAP, FILL_TRANSLATE_ANCHOR_VIEWPORT, @@ -318,6 +351,9 @@ public abstract class Property<T> { */ public static final String LINE_TRANSLATE_ANCHOR_VIEWPORT = "viewport"; + /** + * Controls the translation reference point. + */ @StringDef({ LINE_TRANSLATE_ANCHOR_MAP, LINE_TRANSLATE_ANCHOR_VIEWPORT, @@ -336,6 +372,9 @@ public abstract class Property<T> { */ public static final String ICON_TRANSLATE_ANCHOR_VIEWPORT = "viewport"; + /** + * Controls the translation reference point. + */ @StringDef({ ICON_TRANSLATE_ANCHOR_MAP, ICON_TRANSLATE_ANCHOR_VIEWPORT, @@ -354,6 +393,9 @@ public abstract class Property<T> { */ public static final String TEXT_TRANSLATE_ANCHOR_VIEWPORT = "viewport"; + /** + * Controls the translation reference point. + */ @StringDef({ TEXT_TRANSLATE_ANCHOR_MAP, TEXT_TRANSLATE_ANCHOR_VIEWPORT, @@ -372,6 +414,9 @@ public abstract class Property<T> { */ public static final String CIRCLE_TRANSLATE_ANCHOR_VIEWPORT = "viewport"; + /** + * Controls the translation reference point. + */ @StringDef({ CIRCLE_TRANSLATE_ANCHOR_MAP, CIRCLE_TRANSLATE_ANCHOR_VIEWPORT, @@ -390,6 +435,9 @@ public abstract class Property<T> { */ public static final String CIRCLE_PITCH_SCALE_VIEWPORT = "viewport"; + /** + * Controls the scaling behavior of the circle when the map is pitched. + */ @StringDef({ CIRCLE_PITCH_SCALE_MAP, CIRCLE_PITCH_SCALE_VIEWPORT, 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 7b408448ce..0cb8fdeff9 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 @@ -52,7 +52,7 @@ public class PropertyFactory { } /** - * The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1px stroke around the fill, if the stroke is used. + * The opacity of the entire fill layer. In contrast to the {@link PropertyFactory#fillColor}, this value will also affect the 1px stroke around the fill, if the stroke is used. * * @param value a Float value * @return property wrapper around Float @@ -62,7 +62,7 @@ public class PropertyFactory { } /** - * The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1px stroke around the fill, if the stroke is used. + * The opacity of the entire fill layer. In contrast to the {@link PropertyFactory#fillColor}, this value will also affect the 1px stroke around the fill, if the stroke is used. * * @param function a wrapper function for Float * @return property wrapper around a Float function @@ -102,7 +102,7 @@ public class PropertyFactory { } /** - * The outline color of the fill. Matches the value of `fillColor` if unspecified. + * The outline color of the fill. Matches the value of {@link PropertyFactory#fillColor} if unspecified. * * @param value a int color value * @return property wrapper around String color @@ -112,7 +112,7 @@ public class PropertyFactory { } /** - * The outline color of the fill. Matches the value of `fillColor` if unspecified. + * The outline color of the fill. Matches the value of {@link PropertyFactory#fillColor} if unspecified. * * @param value a String value * @return property wrapper around String @@ -122,7 +122,7 @@ public class PropertyFactory { } /** - * The outline color of the fill. Matches the value of `fillColor` if unspecified. + * The outline color of the fill. Matches the value of {@link PropertyFactory#fillColor} if unspecified. * * @param function a wrapper function for String * @return property wrapper around a String function @@ -1282,7 +1282,7 @@ public class PropertyFactory { } /** - * In combination with `symbolPlacement`, determines the rotation behavior of icons. + * In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of icons. * * @param value a String value * @return property wrapper around String @@ -1292,7 +1292,7 @@ public class PropertyFactory { } /** - * In combination with `symbolPlacement`, determines the rotation behavior of icons. + * In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of icons. * * @param function a wrapper function for String * @return property wrapper around a String function @@ -1342,7 +1342,7 @@ public class PropertyFactory { } /** - * Size of the additional area added to dimensions determined by `iconTextFit`, in clockwise order: top, right, bottom, left. + * Size of the additional area added to dimensions determined by {@link Property.ICON_TEXT_FIT}, in clockwise order: top, right, bottom, left. * * @param value a Float[] value * @return property wrapper around Float[] @@ -1352,7 +1352,7 @@ public class PropertyFactory { } /** - * Size of the additional area added to dimensions determined by `iconTextFit`, in clockwise order: top, right, bottom, left. + * Size of the additional area added to dimensions determined by {@link Property.ICON_TEXT_FIT}, in clockwise order: top, right, bottom, left. * * @param function a wrapper function for Float[] * @return property wrapper around a Float[] function @@ -1482,7 +1482,7 @@ public class PropertyFactory { } /** - * In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text. + * In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of the individual glyphs forming the text. * * @param value a String value * @return property wrapper around String @@ -1492,7 +1492,7 @@ public class PropertyFactory { } /** - * In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text. + * In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of the individual glyphs forming the text. * * @param function a wrapper function for String * @return property wrapper around a String function @@ -1742,7 +1742,7 @@ public class PropertyFactory { } /** - * Specifies how to capitalize text, similar to the CSS `text-transform` property. + * Specifies how to capitalize text, similar to the CSS {@link PropertyFactory#textTransform} property. * * @param value a String value * @return property wrapper around String @@ -1752,7 +1752,7 @@ public class PropertyFactory { } /** - * Specifies how to capitalize text, similar to the CSS `text-transform` property. + * Specifies how to capitalize text, similar to the CSS {@link PropertyFactory#textTransform} property. * * @param function a wrapper function for String * @return property wrapper around a String function 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 c3abb11b68..e5f33aced6 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 @@ -9,7 +9,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * Raster Layer + * Raster map textures such as satellite imagery. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-raster">The online documentation</a> */ public class RasterLayer extends Layer { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java index 0597828bc2..4ceebd8bc1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java @@ -9,7 +9,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * Symbol Layer + * An icon or a text label. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-symbol">The online documentation</a> */ public class SymbolLayer extends Layer { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs index b6c732b045..f7865c6b6c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs @@ -1,6 +1,7 @@ <% const type = locals.type; const properties = locals.properties; + const doc = locals.doc; -%> // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. package com.mapbox.mapboxsdk.style.layers; @@ -13,7 +14,9 @@ import android.support.annotation.NonNull; import static com.mapbox.mapboxsdk.utils.ColorUtils.*; /** - * <%- camelize(type) %> Layer + * <%- doc %> + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-<%- type %>">The online documentation</a> */ public class <%- camelize(type) %>Layer extends Layer { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs index de5330bd9c..bad6f87a8e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs @@ -37,11 +37,14 @@ public abstract class Property<T> { <% for (const value in property.values) { -%> /** - * <%- property.values[value].doc %> + * <%- propertyValueDoc(property, value) %> */ public static final String <%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %> = "<%- value %>"; <% } -%> + /** + * <%- property.doc %> + */ @StringDef({ <% for (const value of Object.keys(property.values)) { -%> <%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %>, diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs index cc829e9e96..a6e2aff839 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs @@ -38,7 +38,7 @@ public class PropertyFactory { <% for (const property of paintProperties) { -%> <% if (property.type == 'color') { -%> /** - * <%- propertyDoc(property.name, property) %> + * <%- propertyFactoryMethodDoc(property) %> * * @param value a int color value * @return property wrapper around String color @@ -49,7 +49,7 @@ public class PropertyFactory { <% } -%> /** - * <%- propertyDoc(property.name, property) %> + * <%- propertyFactoryMethodDoc(property) %> * * @param value a <%- propertyType(property) %> value * @return property wrapper around <%- propertyType(property) %> @@ -59,7 +59,7 @@ public class PropertyFactory { } /** - * <%- propertyDoc(property.name, property) %> + * <%- propertyFactoryMethodDoc(property) %> * * @param function a wrapper function for <%- propertyType(property) %> * @return property wrapper around a <%- propertyType(property) %> function @@ -71,7 +71,7 @@ public class PropertyFactory { <% } -%> <% for (const property of layoutProperties) { -%> /** - * <%- propertyDoc(property.name, property) %> + * <%- propertyFactoryMethodDoc(property) %> * * @param value a <%- propertyType(property) %> value * @return property wrapper around <%- propertyType(property) %> @@ -81,7 +81,7 @@ public class PropertyFactory { } /** - * <%- propertyDoc(property.name, property) %> + * <%- propertyFactoryMethodDoc(property) %> * * @param function a wrapper function for <%- propertyType(property) %> * @return property wrapper around a <%- propertyType(property) %> function diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java index d7a9282371..55a9799cb7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java @@ -3,13 +3,17 @@ package com.mapbox.mapboxsdk.style.sources; import java.util.HashMap; /** - * Options for the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">GeoJsonSource</a> + * Options for the {@link GeoJsonSource} + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">The online documentation</a> */ public class GeoJsonOptions extends HashMap<String, Object> { /** - * Defaults to 18. * Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels). + * + * @param maxZoom the maximum zoom - Defaults to 18. + * @return the current instance for chaining */ public GeoJsonOptions withMaxZoom(int maxZoom) { this.put("maxzoom", maxZoom); @@ -17,8 +21,10 @@ public class GeoJsonOptions extends HashMap<String, Object> { } /** - * Defaults to 128. * Tile buffer size on each side (measured in 1/512ths of a tile; higher means fewer rendering artifacts near tile edges but slower performance). + * + * @param buffer the buffer size - Defaults to 128. + * @return the current instance for chaining */ public GeoJsonOptions withBuffer(int buffer) { this.put("buffer", buffer); @@ -26,8 +32,10 @@ public class GeoJsonOptions extends HashMap<String, Object> { } /** - * Defaults to 0.375. * Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance). + * + * @param tolerance the tolerance - Defaults to 0.375 + * @return the current instance for chaining */ public GeoJsonOptions withTolerance(float tolerance) { this.put("tolerance", tolerance); @@ -35,8 +43,10 @@ public class GeoJsonOptions extends HashMap<String, Object> { } /** - * Defaults to false. * If the data is a collection of point features, setting this to true clusters the points by radius into groups. + * + * @param cluster cluster? - Defaults to false + * @return the current instance for chaining */ public GeoJsonOptions withCluster(boolean cluster) { this.put("cluster", cluster); @@ -44,8 +54,10 @@ public class GeoJsonOptions extends HashMap<String, Object> { } /** - * Defaults to 50. - * Radius of each cluster when clustering points, measured in 1/512ths of a tile. + * Max zoom to cluster points on. + * + * @param clusterMaxZoom clusterMaxZoom cluster maximum zoom - Defaults to one zoom less than maxzoom (so that last zoom features are not clustered) + * @return the current instance for chaining */ public GeoJsonOptions withClusterMaxZoom(int clusterMaxZoom) { this.put("clusterMaxZoom", clusterMaxZoom); @@ -53,7 +65,10 @@ public class GeoJsonOptions extends HashMap<String, Object> { } /** - * Max zoom to cluster points on. Defaults to one zoom less than maxzoom (so that last zoom features are not clustered). + * Radius of each cluster when clustering points, measured in 1/512ths of a tile. + * + * @param clusterRadius cluster radius - Defaults to 50 + * @return the current instance for chaining */ public GeoJsonOptions withClusterRadius(int clusterRadius) { this.put("clusterRadius", clusterRadius); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java index a66e0a4adc..80730d143c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; /** - * A GeoJson source. + * A GeoJson source. Exposes a {@link FeatureCollection} from Json. * * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a> */ @@ -16,6 +16,8 @@ public class GeoJsonSource extends Source { /** * Internal use + * + * @param nativePtr - pointer to native peer */ public GeoJsonSource(long nativePtr) { super(nativePtr); @@ -32,7 +34,7 @@ public class GeoJsonSource extends Source { } /** - * Create an empty GeoJsonSource + * Create an empty GeoJsonSource with non-default {@link GeoJsonOptions} * * @param id the source id * @param options options @@ -46,7 +48,7 @@ public class GeoJsonSource extends Source { * Create a GeoJsonSource from a raw json string * * @param id the source id - * @param geoJson raw Json body + * @param geoJson raw Json FeatureCollection */ public GeoJsonSource(String id, String geoJson) { if (geoJson == null || geoJson.startsWith("http")) { @@ -57,7 +59,7 @@ public class GeoJsonSource extends Source { } /** - * Create a GeoJsonSource from a raw json string + * Create a GeoJsonSource from a raw json string and non-default {@link GeoJsonOptions} * * @param id the source id * @param geoJson raw Json body @@ -83,7 +85,7 @@ public class GeoJsonSource extends Source { } /** - * Create a GeoJsonSource from a remote geo json file + * Create a GeoJsonSource from a remote geo json file and non-default {@link GeoJsonOptions} * * @param id the source id * @param url remote json file @@ -95,7 +97,7 @@ public class GeoJsonSource extends Source { } /** - * Create a GeoJsonSource from a FeatureCollection + * Create a GeoJsonSource from a {@link FeatureCollection} * * @param id the source id * @param features the features @@ -106,7 +108,7 @@ public class GeoJsonSource extends Source { } /** - * Create a GeoJsonSource from a FeatureCollection + * Create a GeoJsonSource from a {@link FeatureCollection} and non-default {@link GeoJsonOptions} * * @param id the source id * @param features the features @@ -117,21 +119,41 @@ public class GeoJsonSource extends Source { setGeoJson(features); } + /** + * Updates the GeoJson + * + * @param features the GeoJSON {@link FeatureCollection} + */ public void setGeoJson(FeatureCollection features) { checkValidity(); setGeoJson(features.toJson()); } + /** + * Updates the GeoJson + * + * @param json the raw GeoJson FeatureCollection string + */ public void setGeoJson(String json) { checkValidity(); setRawJson(json); } + /** + * Updates the url + * + * @param url the GeoJSON FeatureCollection url + */ public void setUrl(URL url) { checkValidity(); setUrl(url.toExternalForm()); } + /** + * Updates the url + * + * @param url the GeoJSON FeatureCollection url + */ public void setUrl(String url) { checkValidity(); nativeSetUrl(url); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java index 14bd8bb9ed..7a7ae49909 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java @@ -3,36 +3,71 @@ package com.mapbox.mapboxsdk.style.sources; import java.net.URL; /** - * Construct a Raster Source. + * Raster Source enables the use of raster tiles. * - * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specificition</a> + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specification</a> */ public class RasterSource extends Source { public static final int DEFAULT_TILE_SIZE = 512; /** * Internal use + * + * @param nativePtr - pointer to native peer */ public RasterSource(long nativePtr) { super(nativePtr); } + /** + * Create the raster source from an URL + * + * @param id the source id + * @param url the source url + */ public RasterSource(String id, URL url) { this(id, url.toExternalForm()); } + + /** + * Create the raster source from an URL + * + * @param id the source id + * @param url the source url + */ public RasterSource(String id, String url) { initialize(id, url, DEFAULT_TILE_SIZE); } + /** + * Create the raster source from an URL with a specific tile size + * + * @param id the source id + * @param url the source url + * @param tileSize the tile size + */ public RasterSource(String id, String url, int tileSize) { initialize(id, url, tileSize); } + /** + * Create the raster source from a {@link TileSet} + * + * @param id the source id + * @param tileSet the {@link TileSet} + */ public RasterSource(String id, TileSet tileSet) { initialize(id, tileSet.toValueObject(), DEFAULT_TILE_SIZE); } + /** + * Create the raster source from a {@link TileSet} with a specific tile size + * + * @param id the source id + * @param tileSet the {@link TileSet} + * @param tileSize tje tile size + */ public RasterSource(String id, TileSet tileSet, int tileSize) { initialize(id, tileSet.toValueObject(), tileSize); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java index 58ffa12e35..0856b117dc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java @@ -1,7 +1,5 @@ package com.mapbox.mapboxsdk.style.sources; -import java.util.HashMap; - /** * Base Peer class for sources. see source.hpp for the other half of the peer. */ @@ -9,6 +7,11 @@ public abstract class Source { private long nativePtr; private boolean invalidated; + /** + * Internal use + * + * @param nativePtr - pointer to native peer + */ public Source(long nativePtr) { this.nativePtr = nativePtr; } @@ -16,11 +19,21 @@ public abstract class Source { public Source() { } + /** + * Retrieve the source id + * + * @return the source id + */ public String getId() { checkValidity(); return nativeGetId(); } + /** + * Internal use + * + * @return the native peer pointer + */ public long getNativePtr() { return nativePtr; } @@ -33,6 +46,9 @@ public abstract class Source { } } + /** + * Internal use - invalidates the source for further use (after adding it to the map) + */ public final void invalidate() { this.invalidated = true; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java index a9c191f96a..689ea7c6bc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java @@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.style.sources; import java.net.URL; /** - * A vector source. + * Vector source enables the use of vector tiles. * * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-vector">the style specification</a> */ @@ -11,6 +11,8 @@ public class VectorSource extends Source { /** * Internal use + * + * @param nativePtr - pointer to native peer */ public VectorSource(long nativePtr) { super(nativePtr); diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js index 80a8e12db6..690ecc3b3c 100644 --- a/platform/android/scripts/generate-style-code.js +++ b/platform/android/scripts/generate-style-code.js @@ -5,6 +5,41 @@ const ejs = require('ejs'); const spec = require('mapbox-gl-style-spec').latest; const _ = require('lodash'); +// Specification parsing // + +//Collect layer types from spec +const layers = Object.keys(spec.layer.type.values).map((type) => { + const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => { + if (name !== 'visibility') { + spec[`layout_${type}`][name].name = name; + memo.push(spec[`layout_${type}`][name]); + } + return memo; + }, []); + + const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => { + spec[`paint_${type}`][name].name = name; + memo.push(spec[`paint_${type}`][name]); + return memo; + }, []); + + return { + type: type, + doc: spec.layer.type.values[type].doc, + layoutProperties: layoutProperties, + paintProperties: paintProperties, + properties: layoutProperties.concat(paintProperties) + }; +}); + +//Process all layer properties +const layoutProperties = _(layers).map('layoutProperties').flatten().value(); +const paintProperties = _(layers).map('paintProperties').flatten().value(); +const allProperties = _(layoutProperties).union(paintProperties).value(); +const enumProperties = _(allProperties).filter({'type': 'enum'}).value(); + +// Global functions // + global.iff = function (condition, val) { return condition() ? val : ""; } @@ -137,40 +172,71 @@ global.defaultValueJava = function(property) { } } -global.propertyDoc = function (propertyName, property) { - let doc = property.doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) { - if (str.substr(offset - 4, 3) !== 'CSS') { - symbol = camelizeWithLeadingLowercase(symbol); +/** + * Produces documentation for property factory methods + */ +global.propertyFactoryMethodDoc = function (property) { + let doc = property.doc; + //Match other items in back ticks + doc = doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) { + if (str.substr(offset - 4, 3) !== 'CSS' && symbol[0].toUpperCase() != symbol[0] && _(enumProperties).filter({'name': symbol}).value().length > 0) { + //Property 'enums' + symbol = snakeCaseUpper(symbol); + return '{@link Property.' + symbol + '}'; + } else if( _(allProperties).filter({'name': symbol}).value().length > 0) { + //Other properties + return '{@link PropertyFactory#' + camelizeWithLeadingLowercase(symbol) + '}'; + } else { + //Left overs + return '`' + symbol + '`'; } - return '`' + symbol + '`'; }); return doc; }; -//Process Layers -const layers = Object.keys(spec.layer.type.values).map((type) => { - const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => { - if (name !== 'visibility') { - spec[`layout_${type}`][name].name = name; - memo.push(spec[`layout_${type}`][name]); - } - return memo; - }, []); +/** + * Produces documentation for property value constants + */ +global.propertyValueDoc = function (property, value) { - const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => { - spec[`paint_${type}`][name].name = name; - memo.push(spec[`paint_${type}`][name]); - return memo; - }, []); + // Match references to other property names & values. + // Requires the format 'When `foo` is set to `bar`,'. + let doc = property.values[value].doc.replace(/When `(.+?)` is set to `(.+?)`,/g, function (m, peerPropertyName, propertyValue, offset, str) { + let otherProperty = snakeCaseUpper(peerPropertyName); + let otherValue = snakeCaseUpper(peerPropertyName) + '_' + snakeCaseUpper(propertyValue); + return 'When {@link ' + `${otherProperty}` + '} is set to {@link Property#' + `${otherValue}` + '},'; + }); - return { - type: type, - layoutProperties: layoutProperties, - paintProperties: paintProperties, - properties: layoutProperties.concat(paintProperties) - }; -}); + // Match references to our own property values. + // Requires the format 'is equivalent to `bar`'. + doc = doc.replace(/is equivalent to `(.+?)`/g, function(m, propertyValue, offset, str) { + propertyValue = snakeCaseUpper(property.name) + '_' + snakeCaseUpper(propertyValue); + return 'is equivalent to {@link Property#' + propertyValue + '}'; + }); + //Match other items in back ticks + doc = doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) { + if ('values' in property && Object.keys(property.values).indexOf(symbol) !== -1) { + //Property values + propertyValue = snakeCaseUpper(property.name) + '_' + snakeCaseUpper(symbol); + console.log("Transforming", symbol, propertyValue); + return '{@link Property#' + `${propertyValue}` + '}'; + } else if (str.substr(offset - 4, 3) !== 'CSS' && symbol[0].toUpperCase() != symbol[0]) { + //Property 'enums' + symbol = snakeCaseUpper(symbol); + return '{@link ' + symbol + '}'; + } else { + //Left overs + return symbol + } + }); + return doc; +}; + +// Template processing // + + +// Java + JNI Layers (Peer model) const layerHpp = ejs.compile(fs.readFileSync('platform/android/src/style/layers/layer.hpp.ejs', 'utf8'), {strict: true}); const layerCpp = ejs.compile(fs.readFileSync('platform/android/src/style/layers/layer.cpp.ejs', 'utf8'), {strict: true}); const layerJava = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs', 'utf8'), {strict: true}); @@ -183,32 +249,32 @@ for (const layer of layers) { fs.writeFileSync(`platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/${camelize(layer.type)}LayerTest.java`, layerJavaUnitTests(layer)); } -//Process all layer properties -const layoutProperties = _(layers).map('layoutProperties').flatten().value(); -const paintProperties = _(layers).map('paintProperties').flatten().value(); +// Java PropertyFactory const propertiesTemplate = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs', 'utf8'), {strict: true}); fs.writeFileSync( `platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java`, propertiesTemplate({layoutProperties: layoutProperties, paintProperties: paintProperties}) ); -//Create types for the enum properties -const enumProperties = _(layoutProperties).union(paintProperties).filter({'type': 'enum'}).value(); +// Java Property const enumPropertyJavaTemplate = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs', 'utf8'), {strict: true}); fs.writeFileSync( `platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java`, enumPropertyJavaTemplate({properties: enumProperties}) ); -//De-dup types before generating cpp headers +//De-duplicate enum properties before processing jni property templates const enumPropertiesDeDup = _(enumProperties).uniq(global.propertyNativeType).value(); + +// JNI Enum property conversion templates const enumPropertyHppTypeStringValueTemplate = ejs.compile(fs.readFileSync('platform/android/src/style/conversion/types_string_values.hpp.ejs', 'utf8'), {strict: true}); fs.writeFileSync( `platform/android/src/style/conversion/types_string_values.hpp`, enumPropertyHppTypeStringValueTemplate({properties: enumPropertiesDeDup}) ); +// JNI property value types conversion templates const enumPropertyHppTypeTemplate = ejs.compile(fs.readFileSync('platform/android/src/style/conversion/types.hpp.ejs', 'utf8'), {strict: true}); fs.writeFileSync( `platform/android/src/style/conversion/types.hpp`, |