diff options
author | Cameron Mace <cameron@mapbox.com> | 2016-12-16 16:19:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-16 16:19:15 -0500 |
commit | 20b958301eb208fe9ed0ae8edfb14b6f3741d8f2 (patch) | |
tree | 94ae0ce250cda159be13f9a21cc70c92d4908974 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources | |
parent | f95b4838ea816b9da0c151a953a1f98f97c79a39 (diff) | |
download | qtlocation-mapboxgl-20b958301eb208fe9ed0ae8edfb14b6f3741d8f2.tar.gz |
Adds checkstyle to CI (#7442)
* adds checkstyle to CI
* fixed gradlew path
* resolved testapp checkstyle violations
* added back mapboxMap variable for test
* checkstyle annotations
* checkstyle SDK round 1
* maps package checkstyle
* rest of SDK checkstyle
* checkstyle gesture library
* checkstyle test
* finished rest of test checkstyle
* resolved all checkstyle errors
* fixed class name
* removed old test file
* fixed camera postion test
* fixed native crash
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources')
8 files changed, 665 insertions, 660 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CannotAddSourceException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CannotAddSourceException.java index 9d5a837b5a..ddc4c58cf1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CannotAddSourceException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CannotAddSourceException.java @@ -5,8 +5,8 @@ package com.mapbox.mapboxsdk.style.sources; */ public class CannotAddSourceException extends RuntimeException { - public CannotAddSourceException(String message) { - super(message); - } + public CannotAddSourceException(String message) { + super(message); + } } 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 55a9799cb7..27a3d5c898 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 @@ -9,70 +9,72 @@ import java.util.HashMap; */ public class GeoJsonOptions extends HashMap<String, Object> { - /** - * 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); - return this; - } + /** + * 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); + return this; + } - /** - * 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); - return this; - } + /** + * 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); + return this; + } - /** - * 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); - return this; - } + /** + * 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); + return this; + } - /** - * 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); - return this; - } + /** + * 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); + return this; + } - /** - * 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); - return this; - } + /** + * 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); + return this; + } - /** - * 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); - return this; - } + /** + * 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); + return this; + } } 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 80730d143c..0c2ee42ea0 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 @@ -14,166 +14,166 @@ import java.util.HashMap; */ public class GeoJsonSource extends Source { - /** - * Internal use - * - * @param nativePtr - pointer to native peer - */ - public GeoJsonSource(long nativePtr) { - super(nativePtr); + /** + * Internal use + * + * @param nativePtr - pointer to native peer + */ + public GeoJsonSource(long nativePtr) { + super(nativePtr); + } + + /** + * Create an empty GeoJsonSource + * + * @param id the source id + */ + public GeoJsonSource(String id) { + initialize(id, null); + setGeoJson(FeatureCollection.fromFeatures(new ArrayList<Feature>())); + } + + /** + * Create an empty GeoJsonSource with non-default {@link GeoJsonOptions} + * + * @param id the source id + * @param options options + */ + public GeoJsonSource(String id, GeoJsonOptions options) { + initialize(id, options); + setGeoJson(FeatureCollection.fromFeatures(new ArrayList<Feature>())); + } + + /** + * Create a GeoJsonSource from a raw json string + * + * @param id the source id + * @param geoJson raw Json FeatureCollection + */ + public GeoJsonSource(String id, String geoJson) { + if (geoJson == null || geoJson.startsWith("http")) { + throw new IllegalArgumentException("Expected a raw json body"); } - - /** - * Create an empty GeoJsonSource - * - * @param id the source id - */ - public GeoJsonSource(String id) { - initialize(id, null); - setGeoJson(FeatureCollection.fromFeatures(new ArrayList<Feature>())); - } - - /** - * Create an empty GeoJsonSource with non-default {@link GeoJsonOptions} - * - * @param id the source id - * @param options options - */ - public GeoJsonSource(String id, GeoJsonOptions options) { - initialize(id, options); - setGeoJson(FeatureCollection.fromFeatures(new ArrayList<Feature>())); - } - - /** - * Create a GeoJsonSource from a raw json string - * - * @param id the source id - * @param geoJson raw Json FeatureCollection - */ - public GeoJsonSource(String id, String geoJson) { - if (geoJson == null || geoJson.startsWith("http")) { - throw new IllegalArgumentException("Expected a raw json body"); - } - initialize(id, null); - setGeoJson(geoJson); - } - - /** - * Create a GeoJsonSource from a raw json string and non-default {@link GeoJsonOptions} - * - * @param id the source id - * @param geoJson raw Json body - * @param options options - */ - public GeoJsonSource(String id, String geoJson, GeoJsonOptions options) { - if (geoJson == null || geoJson.startsWith("http")) { - throw new IllegalArgumentException("Expected a raw json body"); - } - initialize(id, options); - setGeoJson(geoJson); - } - - /** - * Create a GeoJsonSource from a remote geo json file - * - * @param id the source id - * @param url remote json file - */ - public GeoJsonSource(String id, URL url) { - initialize(id, null); - nativeSetUrl(url.toExternalForm()); - } - - /** - * Create a GeoJsonSource from a remote geo json file and non-default {@link GeoJsonOptions} - * - * @param id the source id - * @param url remote json file - * @param options options - */ - public GeoJsonSource(String id, URL url, GeoJsonOptions options) { - initialize(id, options); - nativeSetUrl(url.toExternalForm()); - } - - /** - * Create a GeoJsonSource from a {@link FeatureCollection} - * - * @param id the source id - * @param features the features - */ - public GeoJsonSource(String id, FeatureCollection features) { - initialize(id, null); - setGeoJson(features); - } - - /** - * Create a GeoJsonSource from a {@link FeatureCollection} and non-default {@link GeoJsonOptions} - * - * @param id the source id - * @param features the features - * @param options options - */ - public GeoJsonSource(String id, FeatureCollection features, GeoJsonOptions options) { - initialize(id, options); - setGeoJson(features); + initialize(id, null); + setGeoJson(geoJson); + } + + /** + * Create a GeoJsonSource from a raw json string and non-default {@link GeoJsonOptions} + * + * @param id the source id + * @param geoJson raw Json body + * @param options options + */ + public GeoJsonSource(String id, String geoJson, GeoJsonOptions options) { + if (geoJson == null || geoJson.startsWith("http")) { + throw new IllegalArgumentException("Expected a raw json body"); } - - /** - * 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); - } - - protected void setRawJson(String geoJson) { - //Wrap the String in a map as an Object is expected by the - //style conversion template - HashMap<String, String> wrapper = new HashMap<>(); - wrapper.put("data", geoJson); - nativeSetGeoJson(wrapper); - } - - protected native void initialize(String layerId, Object options); - - protected native void nativeSetUrl(String url); - - private native void nativeSetGeoJson(Object geoJson); - - @Override - protected native void finalize() throws Throwable; + initialize(id, options); + setGeoJson(geoJson); + } + + /** + * Create a GeoJsonSource from a remote geo json file + * + * @param id the source id + * @param url remote json file + */ + public GeoJsonSource(String id, URL url) { + initialize(id, null); + nativeSetUrl(url.toExternalForm()); + } + + /** + * Create a GeoJsonSource from a remote geo json file and non-default {@link GeoJsonOptions} + * + * @param id the source id + * @param url remote json file + * @param options options + */ + public GeoJsonSource(String id, URL url, GeoJsonOptions options) { + initialize(id, options); + nativeSetUrl(url.toExternalForm()); + } + + /** + * Create a GeoJsonSource from a {@link FeatureCollection} + * + * @param id the source id + * @param features the features + */ + public GeoJsonSource(String id, FeatureCollection features) { + initialize(id, null); + setGeoJson(features); + } + + /** + * Create a GeoJsonSource from a {@link FeatureCollection} and non-default {@link GeoJsonOptions} + * + * @param id the source id + * @param features the features + * @param options options + */ + public GeoJsonSource(String id, FeatureCollection features, GeoJsonOptions options) { + initialize(id, options); + 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); + } + + protected void setRawJson(String geoJson) { + //Wrap the String in a map as an Object is expected by the + //style conversion template + HashMap<String, String> wrapper = new HashMap<>(); + wrapper.put("data", geoJson); + nativeSetGeoJson(wrapper); + } + + protected native void initialize(String layerId, Object options); + + protected native void nativeSetUrl(String url); + + private native void nativeSetGeoJson(Object geoJson); + + @Override + protected native void finalize() throws Throwable; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/NoSuchSourceException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/NoSuchSourceException.java index 4622d72445..06d35b598b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/NoSuchSourceException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/NoSuchSourceException.java @@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.style.sources; */ public class NoSuchSourceException extends Exception { - public NoSuchSourceException(String message) { - super(message); - } + public NoSuchSourceException(String message) { + super(message); + } } 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 7a7ae49909..eabbdb8395 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 @@ -8,72 +8,72 @@ import java.net.URL; * @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; + public static final int DEFAULT_TILE_SIZE = 512; - /** - * Internal use - * - * @param nativePtr - pointer to native peer - */ - public RasterSource(long nativePtr) { - super(nativePtr); - } + /** + * 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, 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 + * + * @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 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} + * + * @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); - } + /** + * 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); + } - protected native void initialize(String layerId, Object payload, int tileSize); + protected native void initialize(String layerId, Object payload, int tileSize); - @Override - protected native void finalize() throws Throwable; + @Override + protected native void finalize() throws Throwable; } 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 0856b117dc..6826fed1b5 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 @@ -4,52 +4,52 @@ package com.mapbox.mapboxsdk.style.sources; * Base Peer class for sources. see source.hpp for the other half of the peer. */ 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; - } - - 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; - } - - protected native String nativeGetId(); - - protected void checkValidity() { - if (invalidated) { - throw new RuntimeException("Layer has been invalidated. Request a new reference after adding"); - } - } - - /** - * Internal use - invalidates the source for further use (after adding it to the map) - */ - public final void invalidate() { - this.invalidated = true; + private long nativePtr; + private boolean invalidated; + + /** + * Internal use + * + * @param nativePtr - pointer to native peer + */ + public Source(long nativePtr) { + this.nativePtr = nativePtr; + } + + 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; + } + + protected native String nativeGetId(); + + protected void checkValidity() { + if (invalidated) { + throw new RuntimeException("Layer has been invalidated. Request a new reference after adding"); } + } + + /** + * 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/TileSet.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java index b645020c21..9f403c2fb9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java @@ -13,304 +13,307 @@ import java.util.Map; * @see <a href="https://github.com/mapbox/tilejson-spec/tree/master/2.1.0">The tileset specification</a> */ public class TileSet { - private final String tilejson; - private String name; - private String description; - private String version; - private String attribution; - private String template; - private String legend; - private String scheme; - private final String[] tiles; - private String[] grids; - private String[] data; - private Float minZoom; - private Float maxZoom; - private Float[] bounds; - private Float[] center; - - /** - * @param tilejson A semver.org style version number. Describes the version of the TileJSON spec that is implemented by this JSON object. - * @param tiles An array of tile endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding integers. - * If multiple endpoints are specified, clients may use any combination of endpoints. All endpoints MUST return the same - * content for the same URL. The array MUST contain at least one endpoint. - * Example: "http:localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png" - */ - public TileSet(String tilejson, String... tiles) { - this.tilejson = tilejson; - this.tiles = tiles; + private final String tilejson; + private String name; + private String description; + private String version; + private String attribution; + private String template; + private String legend; + private String scheme; + private final String[] tiles; + private String[] grids; + private String[] data; + private Float minZoom; + private Float maxZoom; + private Float[] bounds; + private Float[] center; + + /** + * @param tilejson A semver.org style version number. Describes the version of the TileJSON spec that is implemented + * by this JSON object. + * @param tiles An array of tile endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding + * integers. + * If multiple endpoints are specified, clients may use any combination of endpoints. All endpoints + * MUST return the same + * content for the same URL. The array MUST contain at least one endpoint. + * Example: "http:localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png" + */ + public TileSet(String tilejson, String... tiles) { + this.tilejson = tilejson; + this.tiles = tiles; + } + + public String getTilejson() { + return tilejson; + } + + public String getName() { + return name; + } + + /** + * A name describing the tileset. The name can + * contain any legal character. Implementations SHOULD NOT interpret the + * name as HTML. + * "name": "compositing", + * + * @param name the name to be set + */ + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + /** + * A text description of the tileset. The + * description can contain any legal character. + * Implementations SHOULD NOT + * interpret the description as HTML. + * "description": "A simple, light grey world." + * + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getAttribution() { + return attribution; + } + + /** + * Default: null. Contains an attribution to be displayed + * when the map is shown to a user. Implementations MAY decide to treat this + * as HTML or literal text. For security reasons, make absolutely sure that + * this field can't be abused as a vector for XSS or beacon tracking. + * "attribution": "<a href='http:openstreetmap.org'>OSM contributors</a>", + * + * @param attribution the attribution to set + */ + public void setAttribution(String attribution) { + this.attribution = attribution; + } + + public String getTemplate() { + return template; + } + + /** + * Contains a mustache template to be used to + * format data from grids for interaction. + * See https:github.com/mapbox/utfgrid-spec/tree/master/1.2 + * for the interactivity specification. + * "template": "{{#__teaser__}}{{NAME}}{{/__teaser__}}" + * + * @param template the template to set + */ + public void setTemplate(String template) { + this.template = template; + } + + public String getLegend() { + return legend; + } + + /** + * Contains a legend to be displayed with the map. + * Implementations MAY decide to treat this as HTML or literal text. + * For security reasons, make absolutely sure that this field can't be + * abused as a vector for XSS or beacon tracking. + * "legend": "Dangerous zones are red, safe zones are green" + * + * @param legend the legend to set + */ + public void setLegend(String legend) { + this.legend = legend; + } + + public String getScheme() { + return scheme; + } + + /** + * Default: "xyz". Either "xyz" or "tms". Influences the y + * direction of the tile coordinates. + * The global-mercator (aka Spherical Mercator) profile is assumed. + * "scheme": "xyz" + * + * @param scheme the scheme to set + */ + public void setScheme(String scheme) { + this.scheme = scheme; + } + + public String[] getTiles() { + return tiles; + } + + public String[] getGrids() { + return grids; + } + + /** + * An array of interactivity endpoints. {z}, {x} + * and {y}, if present, are replaced with the corresponding integers. If multiple + * endpoints are specified, clients may use any combination of endpoints. + * All endpoints MUST return the same content for the same URL. + * If the array doesn't contain any entries, interactivity is not supported + * for this tileset. See https:github.com/mapbox/utfgrid-spec/tree/master/1.2 + * for the interactivity specification. + * <p> + * Example: "http:localhost:8888/admin/1.0.0/broadband/{z}/{x}/{y}.grid.json" + * </p> + * + * @param grids the grids to set + */ + public void setGrids(String... grids) { + this.grids = grids; + } + + public String[] getData() { + return data; + } + + /** + * An array of data files in GeoJSON format. + * {z}, {x} and {y}, if present, + * are replaced with the corresponding integers. If multiple + * endpoints are specified, clients may use any combination of endpoints. + * All endpoints MUST return the same content for the same URL. + * If the array doesn't contain any entries, then no data is present in + * the map. + * <p> + * "http:localhost:8888/admin/data.geojson" + * </p> + * + * @param data the data array to set + */ + public void setData(String... data) { + this.data = data; + } + + public float getMinZoom() { + return minZoom; + } + + /** + * 0. >= 0, < 22. An integer specifying the minimum zoom level. + * + * @param minZoom the minZoom level to set + */ + public void setMinZoom(float minZoom) { + this.minZoom = minZoom; + } + + public float getMaxZoom() { + return maxZoom; + } + + /** + * 0. >= 0, <= 22. An integer specifying the maximum zoom level. + * + * @param maxZoom the maxZoom level to set + */ + public void setMaxZoom(float maxZoom) { + this.maxZoom = maxZoom; + } + + public Float[] getBounds() { + return bounds; + } + + /** + * Default: [-180, -90, 180, 90]. The maximum extent of available map tiles. Bounds MUST define an area + * covered by all zoom levels. The bounds are represented in WGS:84 + * latitude and longitude values, in the order left, bottom, right, top. + * Values may be integers or floating point numbers. + * + * @param bounds the Float array to set + */ + public void setBounds(@Size(value = 4) Float... bounds) { + this.bounds = bounds; + } + + public Float[] getCenter() { + return center; + } + + /** + * The first value is the longitude, the second is latitude (both in + * WGS:84 values), the third value is the zoom level as an integer. + * Longitude and latitude MUST be within the specified bounds. + * The zoom level MUST be between minzoom and maxzoom. + * Implementations can use this value to set the default location. If the + * value is null, implementations may use their own algorithm for + * determining a default location. + * + * @param center the Float array to set + */ + public void setCenter(@Size(value = 2) Float... center) { + this.center = center; + } + + public void setCenter(LatLng center) { + this.center = new Float[] {(float) center.getLongitude(), (float) center.getLatitude()}; + } + + Map<String, Object> toValueObject() { + Map<String, Object> result = new HashMap<>(); + result.put("tilejson", tilejson); + result.put("tiles", tiles); + + if (name != null) { + result.put("name", name); } - - public String getTilejson() { - return tilejson; - } - - public String getName() { - return name; - } - - /** - * A name describing the tileset. The name can - * contain any legal character. Implementations SHOULD NOT interpret the - * name as HTML. - * "name": "compositing", - * - * @param name the name to be set - */ - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - /** - * A text description of the tileset. The - * description can contain any legal character. - * Implementations SHOULD NOT - * interpret the description as HTML. - * "description": "A simple, light grey world." - * - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; + if (description != null) { + result.put("description", description); } - - public String getAttribution() { - return attribution; + if (version != null) { + result.put("version", version); } - - /** - * Default: null. Contains an attribution to be displayed - * when the map is shown to a user. Implementations MAY decide to treat this - * as HTML or literal text. For security reasons, make absolutely sure that - * this field can't be abused as a vector for XSS or beacon tracking. - * "attribution": "<a href='http:openstreetmap.org'>OSM contributors</a>", - * - * @param attribution the attribution to set - */ - public void setAttribution(String attribution) { - this.attribution = attribution; + if (attribution != null) { + result.put("attribution", attribution); } - - public String getTemplate() { - return template; + if (template != null) { + result.put("template", template); } - - /** - * Contains a mustache template to be used to - * format data from grids for interaction. - * See https:github.com/mapbox/utfgrid-spec/tree/master/1.2 - * for the interactivity specification. - * "template": "{{#__teaser__}}{{NAME}}{{/__teaser__}}" - * - * @param template the template to set - */ - public void setTemplate(String template) { - this.template = template; + if (legend != null) { + result.put("legend", legend); } - - public String getLegend() { - return legend; + if (scheme != null) { + result.put("scheme", scheme); } - - /** - * Contains a legend to be displayed with the map. - * Implementations MAY decide to treat this as HTML or literal text. - * For security reasons, make absolutely sure that this field can't be - * abused as a vector for XSS or beacon tracking. - * "legend": "Dangerous zones are red, safe zones are green" - * - * @param legend the legend to set - */ - public void setLegend(String legend) { - this.legend = legend; + if (grids != null) { + result.put("grids", grids); } - - public String getScheme() { - return scheme; + if (data != null) { + result.put("data", data); } - - /** - * Default: "xyz". Either "xyz" or "tms". Influences the y - * direction of the tile coordinates. - * The global-mercator (aka Spherical Mercator) profile is assumed. - * "scheme": "xyz" - * - * @param scheme the scheme to set - */ - public void setScheme(String scheme) { - this.scheme = scheme; + if (minZoom != null) { + result.put("minzoom", minZoom); } - - public String[] getTiles() { - return tiles; + if (maxZoom != null) { + result.put("maxzoom", maxZoom); } - - public String[] getGrids() { - return grids; + if (bounds != null) { + result.put("bounds", bounds); } - - /** - * An array of interactivity endpoints. {z}, {x} - * and {y}, if present, are replaced with the corresponding integers. If multiple - * endpoints are specified, clients may use any combination of endpoints. - * All endpoints MUST return the same content for the same URL. - * If the array doesn't contain any entries, interactivity is not supported - * for this tileset. See https:github.com/mapbox/utfgrid-spec/tree/master/1.2 - * for the interactivity specification. - * <p> - * Example: "http:localhost:8888/admin/1.0.0/broadband/{z}/{x}/{y}.grid.json" - * </p> - * - * @param grids the grids to set - */ - public void setGrids(String... grids) { - this.grids = grids; + if (center != null) { + result.put("center", center); } - public String[] getData() { - return data; - } - - /** - * An array of data files in GeoJSON format. - * {z}, {x} and {y}, if present, - * are replaced with the corresponding integers. If multiple - * endpoints are specified, clients may use any combination of endpoints. - * All endpoints MUST return the same content for the same URL. - * If the array doesn't contain any entries, then no data is present in - * the map. - * <p> - * "http:localhost:8888/admin/data.geojson" - * </p> - * - * @param data the data array to set - */ - public void setData(String... data) { - this.data = data; - } - - public float getMinZoom() { - return minZoom; - } - - /** - * 0. >= 0, < 22. An integer specifying the minimum zoom level. - * - * @param minZoom the minZoom level to set - */ - public void setMinZoom(float minZoom) { - this.minZoom = minZoom; - } - - public float getMaxZoom() { - return maxZoom; - } - - /** - * 0. >= 0, <= 22. An integer specifying the maximum zoom level. - * - * @param maxZoom the maxZoom level to set - */ - public void setMaxZoom(float maxZoom) { - this.maxZoom = maxZoom; - } - - public Float[] getBounds() { - return bounds; - } - - /** - * Default: [-180, -90, 180, 90]. The maximum extent of available map tiles. Bounds MUST define an area - * covered by all zoom levels. The bounds are represented in WGS:84 - * latitude and longitude values, in the order left, bottom, right, top. - * Values may be integers or floating point numbers. - * - * @param bounds the Float array to set - */ - public void setBounds(@Size(value = 4) Float... bounds) { - this.bounds = bounds; - } - - public Float[] getCenter() { - return center; - } - - /** - * The first value is the longitude, the second is latitude (both in - * WGS:84 values), the third value is the zoom level as an integer. - * Longitude and latitude MUST be within the specified bounds. - * The zoom level MUST be between minzoom and maxzoom. - * Implementations can use this value to set the default location. If the - * value is null, implementations may use their own algorithm for - * determining a default location. - * - * @param center the Float array to set - */ - public void setCenter(@Size(value = 2) Float... center) { - this.center = center; - } - - public void setCenter(LatLng center) { - this.center = new Float[]{(float) center.getLongitude(), (float) center.getLatitude()}; - } - - Map<String, Object> toValueObject() { - Map<String, Object> result = new HashMap<>(); - result.put("tilejson", tilejson); - result.put("tiles", tiles); - - if (name != null) { - result.put("name", name); - } - if (description != null) { - result.put("description", description); - } - if (version != null) { - result.put("version", version); - } - if (attribution != null) { - result.put("attribution", attribution); - } - if (template != null) { - result.put("template", template); - } - if (legend != null) { - result.put("legend", legend); - } - if (scheme != null) { - result.put("scheme", scheme); - } - if (grids != null) { - result.put("grids", grids); - } - if (data != null) { - result.put("data", data); - } - if (minZoom != null) { - result.put("minzoom", minZoom); - } - if (maxZoom != null) { - result.put("maxzoom", maxZoom); - } - if (bounds != null) { - result.put("bounds", bounds); - } - if (center != null) { - result.put("center", center); - } - - return result; - } + return result; + } } 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 689ea7c6bc..feaca839d3 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 @@ -9,47 +9,47 @@ import java.net.URL; */ public class VectorSource extends Source { - /** - * Internal use - * - * @param nativePtr - pointer to native peer - */ - public VectorSource(long nativePtr) { - super(nativePtr); - } - - /** - * Create a vector source from a remote url - * - * @param id the source id - * @param url the url - */ - public VectorSource(String id, URL url) { - this(id, url.toExternalForm()); - } - - /** - * Create a vector source from a remote url - * - * @param id the source id - * @param url the url - */ - public VectorSource(String id, String url) { - initialize(id, url); - } - - /** - * Create a vector source from a tilset - * - * @param id the source id - * @param tileSet the tileset - */ - public VectorSource(String id, TileSet tileSet) { - initialize(id, tileSet.toValueObject()); - } - - protected native void initialize(String layerId, Object payload); - - @Override - protected native void finalize() throws Throwable; + /** + * Internal use + * + * @param nativePtr - pointer to native peer + */ + public VectorSource(long nativePtr) { + super(nativePtr); + } + + /** + * Create a vector source from a remote url + * + * @param id the source id + * @param url the url + */ + public VectorSource(String id, URL url) { + this(id, url.toExternalForm()); + } + + /** + * Create a vector source from a remote url + * + * @param id the source id + * @param url the url + */ + public VectorSource(String id, String url) { + initialize(id, url); + } + + /** + * Create a vector source from a tilset + * + * @param id the source id + * @param tileSet the tileset + */ + public VectorSource(String id, TileSet tileSet) { + initialize(id, tileSet.toValueObject()); + } + + protected native void initialize(String layerId, Object payload); + + @Override + protected native void finalize() throws Throwable; } |