From a3d0ff777b015bac7c1b16a1dd0a030b915782b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Thu, 25 Oct 2018 16:57:48 +0200 Subject: [android] improved CustomGeometrySource constructor typing --- .../style/sources/CustomGeometrySource.java | 6 +-- .../style/sources/CustomGeometrySourceOptions.java | 48 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java index 667e7f487f..4129f2b2b4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java @@ -62,9 +62,9 @@ public class CustomGeometrySource extends Source { } /** - * Create a CustomGeometrySource with non-default CustomGeometrySourceOptions. - *

Supported options are minZoom, maxZoom, buffer, and tolerance.

- * @param id The source id. + * Create a CustomGeometrySource with non-default {@link CustomGeometrySourceOptions}. + * + * @param id The source id. * @param options CustomGeometrySourceOptions. * @param provider The tile provider that returns geometry data for this source. */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java index 4ada38c238..331d9b267f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java @@ -1,9 +1,11 @@ package com.mapbox.mapboxsdk.style.sources; +import java.util.HashMap; + /** * Builder class for composing CustomGeometrySource objects. */ -public class CustomGeometrySourceOptions extends GeoJsonOptions { +public class CustomGeometrySourceOptions extends HashMap { /** * If the data includes wrapped coordinates, setting this to true unwraps the coordinates. @@ -28,4 +30,48 @@ public class CustomGeometrySourceOptions extends GeoJsonOptions { return this; } + /** + * Minimum zoom level at which to create vector tiles (lower means more field of view detail at low zoom levels). + * + * @param minZoom the minimum zoom - Defaults to 0. + * @return the current instance for chaining + */ + public CustomGeometrySourceOptions withMinZoom(int minZoom) { + this.put("minzoom", minZoom); + 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 25.5 + * @return the current instance for chaining + */ + public CustomGeometrySourceOptions 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 CustomGeometrySourceOptions 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 CustomGeometrySourceOptions withTolerance(float tolerance) { + this.put("tolerance", tolerance); + return this; + } } -- cgit v1.2.1