From d2f0b74757c7265ba93b00e75072a8c97ffad27c Mon Sep 17 00:00:00 2001 From: langsmith Date: Wed, 8 Jan 2020 13:52:04 -0800 Subject: [PATCH] removed deprecated getCall() method in IsochroneService --- .../geojson/gson/BoundingBoxDeserializer.java | 75 --------------- .../geojson/gson/BoundingBoxSerializer.java | 73 -------------- .../geojson/gson/CoordinateTypeAdapter.java | 57 ----------- .../geojson/gson/GeometryDeserializer.java | 64 ------------- .../geojson/gson/GeometryTypeAdapter.java | 40 -------- .../geojson/gson/PointDeserializer.java | 61 ------------ .../mapbox/geojson/gson/PointSerializer.java | 65 ------------- .../gson/BoundingBoxDeserializerTest.java | 45 --------- .../gson/GeometryDeserializerTest.java | 12 --- .../geojson/gson/PointDeserializerTest.java | 95 ------------------- .../geojson/gson/PointSerializerTest.java | 52 ---------- .../api/isochrone/IsochroneService.java | 51 ---------- 12 files changed, 690 deletions(-) delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxDeserializer.java delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxSerializer.java delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/CoordinateTypeAdapter.java delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryDeserializer.java delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryTypeAdapter.java delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/PointDeserializer.java delete mode 100644 services-geojson/src/main/java/com/mapbox/geojson/gson/PointSerializer.java delete mode 100644 services-geojson/src/test/java/com/mapbox/geojson/gson/BoundingBoxDeserializerTest.java delete mode 100644 services-geojson/src/test/java/com/mapbox/geojson/gson/GeometryDeserializerTest.java delete mode 100644 services-geojson/src/test/java/com/mapbox/geojson/gson/PointDeserializerTest.java delete mode 100644 services-geojson/src/test/java/com/mapbox/geojson/gson/PointSerializerTest.java diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxDeserializer.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxDeserializer.java deleted file mode 100644 index c5a3c4b19..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxDeserializer.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.mapbox.geojson.BoundingBox; -import com.mapbox.geojson.exception.GeoJsonException; - -import java.lang.reflect.Type; - -/** - * When deserializing a GeoJSONs optional bounding box, we want to convert the JsonArray to a - * {@link BoundingBox} object for easier consumption in developers java applications. - * - * @since 3.0.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.gson.BoundingBoxTypeAdapter} - * should be used to serialize/deserialize coordinates as Points. - */ -@Deprecated -public class BoundingBoxDeserializer implements JsonDeserializer { - - /** - * Empty constructor to prevent relying on the default one. - * - * @since 3.0.0 - */ - public BoundingBoxDeserializer() { - // Empty Constructor - } - - /** - * When deserializing a GeoJSONs optional bounding box, we want to convert the JsonArray to a - * {@link BoundingBox} object for easier consumption in developers java applications. - * - * @param json a class representing an element of JSON - * @param typeOfT common superinterface for all types in the Java - * @param context context for deserialization that is passed to a custom deserializer during - * invocation of its {@link JsonDeserializer#deserialize(JsonElement, Type, - * JsonDeserializationContext)} method - * @return a new {@link BoundingBox} object representing the values originally in the JSON - * @throws JsonParseException this exception is raised if there is a serious issue that occurs - * during parsing of a Json string - * @since 3.0.0 - */ - @Override - public BoundingBox deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) { - - JsonArray rawCoordinates = json.getAsJsonArray(); - - if (rawCoordinates.size() == 6) { - return BoundingBox.fromLngLats( - rawCoordinates.get(0).getAsDouble(), - rawCoordinates.get(1).getAsDouble(), - rawCoordinates.get(2).getAsDouble(), - rawCoordinates.get(3).getAsDouble(), - rawCoordinates.get(4).getAsDouble(), - rawCoordinates.get(5).getAsDouble()); - } - if (rawCoordinates.size() == 4) { - return BoundingBox.fromLngLats( - rawCoordinates.get(0).getAsDouble(), - rawCoordinates.get(1).getAsDouble(), - rawCoordinates.get(2).getAsDouble(), - rawCoordinates.get(3).getAsDouble()); - } else { - throw new GeoJsonException("The value of the bbox member MUST be an array of length 2*n where" - + " n is the number of dimensions represented in the contained geometries, with all axes of" - + " the most southwesterly point followed by all axes of the more northeasterly point. The " - + "axes order of a bbox follows the axes order of geometries."); - } - } -} diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxSerializer.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxSerializer.java deleted file mode 100644 index 8de3b875a..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/BoundingBoxSerializer.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.mapbox.geojson.BoundingBox; -import com.mapbox.geojson.Point; -import com.mapbox.geojson.shifter.CoordinateShifterManager; -import com.mapbox.geojson.utils.GeoJsonUtils; - -import java.lang.reflect.Type; -import java.util.List; - -/** - * Serializer used for converting the {@link BoundingBox} object inside a GeoJson object to a JSON - * element which can be read by GSON and added to the final JSON output. - * - * @since 3.0.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.gson.BoundingBoxTypeAdapter} - * should be used to serialize/deserialize coordinates as Points. - */ -@Deprecated -public class BoundingBoxSerializer implements JsonSerializer { - - /** - * Empty constructor to prevent relying on the default one. - * - * @since 3.0.0 - */ - public BoundingBoxSerializer() { - // Empty Constructor - } - - /** - * Converts the {@link BoundingBox} object into a JsonArray. - * - * @param src a {@link BoundingBox} - * @param typeOfSrc common superinterface for all types in the Java - * @param context context for deserialization that is passed to a custom deserializer during - * invocation of its {@link com.google.gson.JsonDeserializationContext} method - * @return a JsonArray containing the raw coordinates - * @since 3.0.0 - */ - @Override - public JsonElement serialize(BoundingBox src, Type typeOfSrc, JsonSerializationContext context) { - JsonArray bbox = new JsonArray(); - - // Southwest - Point point = src.southwest(); - List unshiftedCoordinates = - CoordinateShifterManager.getCoordinateShifter().unshiftPoint(point); - - bbox.add(new JsonPrimitive(GeoJsonUtils.trim(unshiftedCoordinates.get(0)))); - bbox.add(new JsonPrimitive(GeoJsonUtils.trim(unshiftedCoordinates.get(1)))); - if (point.hasAltitude()) { - bbox.add(new JsonPrimitive(unshiftedCoordinates.get(2))); - } - - // Northeast - point = src.northeast(); - unshiftedCoordinates = - CoordinateShifterManager.getCoordinateShifter().unshiftPoint(point); - bbox.add(new JsonPrimitive(GeoJsonUtils.trim(unshiftedCoordinates.get(0)))); - bbox.add(new JsonPrimitive(GeoJsonUtils.trim(unshiftedCoordinates.get(1)))); - if (point.hasAltitude()) { - bbox.add(new JsonPrimitive(unshiftedCoordinates.get(2))); - } - - return bbox; - } -} diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/CoordinateTypeAdapter.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/CoordinateTypeAdapter.java deleted file mode 100644 index 052ad07e9..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/CoordinateTypeAdapter.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.mapbox.geojson.shifter.CoordinateShifterManager; -import com.mapbox.geojson.utils.GeoJsonUtils; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Adapter to read and write coordinates for Point class. - * - * @since 4.1.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.PointAsCoordinatesTypeAdapter} - * should be used to serialize/deserialize coordinates as Points. - */ -@Deprecated -public class CoordinateTypeAdapter extends TypeAdapter> { - @Override - public void write(JsonWriter out, List value) throws IOException { - - out.beginArray(); - - // Unshift coordinates - List unshiftedCoordinates = - CoordinateShifterManager.getCoordinateShifter().unshiftPoint(value); - - out.value(GeoJsonUtils.trim(unshiftedCoordinates.get(0))); - out.value(GeoJsonUtils.trim(unshiftedCoordinates.get(1))); - - // Includes altitude - if (value.size() > 2) { - out.value(unshiftedCoordinates.get(2)); - } - out.endArray(); - } - - @Override - public List read(JsonReader in) throws IOException { - List coordinates = new ArrayList(); - in.beginArray(); - while (in.hasNext()) { - coordinates.add(in.nextDouble()); - } - in.endArray(); - - if (coordinates.size() > 2) { - return CoordinateShifterManager.getCoordinateShifter() - .shiftLonLatAlt(coordinates.get(0), coordinates.get(1), coordinates.get(2)); - } - return CoordinateShifterManager.getCoordinateShifter() - .shiftLonLat(coordinates.get(0), coordinates.get(1)); - } -} diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryDeserializer.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryDeserializer.java deleted file mode 100644 index 7c4acdcbc..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryDeserializer.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.mapbox.geojson.Geometry; - -import java.lang.reflect.Type; - -/** - * Required to handle the "Unable to invoke no-args constructor for interface {@link Geometry} error - * that Gson shows when trying to deserialize a list of {@link Geometry}. - * - * @since 1.0.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.GeometryAdapterFactory} - * should be used to serialize/deserialize Geometries. - */ -@Deprecated -public class GeometryDeserializer implements JsonDeserializer { - - /** - * Empty constructor to prevent relying on the default one. - * - * @since 3.0.0 - */ - public GeometryDeserializer() { - // Empty Constructor - } - - /** - * Required to handle the "Unable to invoke no-args constructor for interface {@link Geometry} - * error that Gson shows when trying to deserialize a list of {@link Geometry}. - * - * @param json A class representing an element of Json. - * @param typeOfT Common superinterface for all types in the Java. - * @param context Context for deserialization that is passed to a custom deserializer during - * invocation of its {@link JsonDeserializer#deserialize(JsonElement, Type, - * JsonDeserializationContext)} method. - * @return either default deserialization on the specified object or JsonParseException. - * @throws JsonParseException This exception is raised if there is a serious issue that occurs - * during parsing of a Json string. - * @since 1.0.0 - */ - @Override - public Geometry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - String geometryType; - // Find the actual class name from the type property in the JSON. - if (json.isJsonObject()) { - geometryType = json.getAsJsonObject().get("type").getAsString(); - } else { - geometryType = json.getAsJsonArray().get(0).getAsJsonObject().get("type").getAsString(); - } - - try { - // Use the current context to deserialize it - Type classType = Class.forName("com.mapbox.geojson." + geometryType); - return context.deserialize(json, classType); - } catch (ClassNotFoundException classNotFoundException) { - // Unknown geometry - throw new JsonParseException(classNotFoundException); - } - } -} diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryTypeAdapter.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryTypeAdapter.java deleted file mode 100644 index 43e781ca1..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryTypeAdapter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.mapbox.geojson.CoordinateContainer; -import com.mapbox.geojson.Geometry; - -import java.io.IOException; - -/** - * Converts {@code Geometry} instances to JSON and JSON to - * instances of {@code Geometry}. - * - * @since 3.0.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.GeometryAdapterFactory} - * should be used to serialize/deserialize Geometries. - */ -@Deprecated -public class GeometryTypeAdapter extends TypeAdapter { - - - @Override - public void write(JsonWriter out, Geometry value) throws IOException { - out.beginObject(); - out.name("type").value(value.type()); - if (value.bbox() != null) { - out.name("bbox").jsonValue(value.bbox().toJson()); - } - if (value instanceof CoordinateContainer) { - out.name("coordinates").jsonValue(((CoordinateContainer) value).coordinates().toString()); - } - out.endObject(); - } - - @Override - public Geometry read(JsonReader in) throws IOException { - return null; - } -} diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/PointDeserializer.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/PointDeserializer.java deleted file mode 100644 index 8fd88ed88..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/PointDeserializer.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.mapbox.geojson.Point; - -import java.lang.reflect.Type; - -/** - * Deserialize the coordinates inside the json into {@link Point}s capturing the same information. - * Otherwise when deserializing, you'll most likely see this error: Required to handle the - * "Expected BEGIN_OBJECT but was BEGIN_ARRAY". - * - * @since 1.0.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.PointAsCoordinatesTypeAdapter} - * should be used to serialize/deserialize coordinates as Points. - */ -@Deprecated -public class PointDeserializer implements JsonDeserializer { - - /** - * Empty constructor to prevent relying on the default one. - * - * @since 3.0.0 - */ - public PointDeserializer() { - // Empty Constructor - } - - /** - * Deserialize the coordinates inside the json into {@link Point}s capturing the same information. - * Otherwise when deserializing, you'll most likely see this error: Required to handle the - * "Expected BEGIN_OBJECT but was BEGIN_ARRAY". - * - * @param json a class representing an element of Json - * @param typeOfT common superinterface for all types in the Java - * @param context Context for deserialization that is passed to a custom deserializer during - * invocation of its {@link JsonDeserializer#deserialize(JsonElement, Type, - * JsonDeserializationContext)} method - * @return either {@link Point} with an altitude or one that doesn't - * @since 1.0.0 - */ - @Override - public Point deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - JsonArray rawCoordinates = json.getAsJsonArray(); - - double longitude = rawCoordinates.get(0).getAsDouble(); - double latitude = rawCoordinates.get(1).getAsDouble(); - - // Includes altitude - if (rawCoordinates.size() > 2) { - double altitude = rawCoordinates.get(2).getAsDouble(); - return Point.fromLngLat(longitude, latitude, altitude); - } - - // It doesn't have altitude - return Point.fromLngLat(longitude, latitude); - } -} diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/PointSerializer.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/PointSerializer.java deleted file mode 100644 index b19ae06b1..000000000 --- a/services-geojson/src/main/java/com/mapbox/geojson/gson/PointSerializer.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.mapbox.geojson.Point; -import com.mapbox.geojson.shifter.CoordinateShifterManager; -import com.mapbox.geojson.utils.GeoJsonUtils; - -import java.lang.reflect.Type; -import java.util.List; - -/** - * Required to handle the special case where the altitude might be a Double.NaN, which isn't a valid - * double value as per JSON specification. - * - * @since 1.0.0 - * @deprecated this class is deprecated, {@link com.mapbox.geojson.PointAsCoordinatesTypeAdapter} - * should be used to serialize/deserialize coordinates as Points. - */ -@Deprecated -public class PointSerializer implements JsonSerializer { - - /** - * Empty constructor to prevent relying on the default one. - * - * @since 3.0.0 - */ - public PointSerializer() { - // Empty Constructor - } - - /** - * Required to handle the special case where the altitude might be a Double.NaN, which isn't a - * valid double value as per JSON specification. - * - * @param src A {@link Point} defined by a longitude, latitude, and optionally, an - * altitude. - * @param typeOfSrc Common superinterface for all types in the Java. - * @param context Context for deserialization that is passed to a custom deserializer during - * invocation of its {@link com.google.gson.JsonDeserializationContext} method. - * @return a JsonArray containing the raw coordinates. - * @since 1.0.0 - */ - @Override - public JsonElement serialize(Point src, Type typeOfSrc, JsonSerializationContext context) { - JsonArray rawCoordinates = new JsonArray(); - - // Unshift coordinates - List unshiftedCoordinates = - CoordinateShifterManager.getCoordinateShifter().unshiftPoint(src); - - rawCoordinates.add(new JsonPrimitive(GeoJsonUtils.trim(unshiftedCoordinates.get(0)))); - rawCoordinates.add(new JsonPrimitive(GeoJsonUtils.trim(unshiftedCoordinates.get(1)))); - - // Includes altitude - if (src.hasAltitude()) { - rawCoordinates.add(new JsonPrimitive(unshiftedCoordinates.get(2))); - } - - return rawCoordinates; - } -} diff --git a/services-geojson/src/test/java/com/mapbox/geojson/gson/BoundingBoxDeserializerTest.java b/services-geojson/src/test/java/com/mapbox/geojson/gson/BoundingBoxDeserializerTest.java deleted file mode 100644 index 891b1f065..000000000 --- a/services-geojson/src/test/java/com/mapbox/geojson/gson/BoundingBoxDeserializerTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.mapbox.core.TestUtils; -import com.mapbox.geojson.Feature; -import com.mapbox.geojson.FeatureCollection; -import com.mapbox.geojson.LineString; -import com.mapbox.geojson.Point; -import com.mapbox.geojson.exception.GeoJsonException; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -public class BoundingBoxDeserializerTest extends TestUtils { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void bboxDeserializer_handlesOnlyOneAltitudeCorrectly() throws Exception { - thrown.expect(GeoJsonException.class); - thrown.expectMessage("The value of the bbox member MUST be an array of length"); - String fixtureJson - = "{\"type\":\"Point\",\"bbox\":[1.0,2.0,3.0,4.0,5.0],\"coordinates\":[100,0]}"; - Point point = Point.fromJson(fixtureJson); - compareJson(fixtureJson, point.toJson()); - } - - @Test - public void bboxDeserializer_deserializeThreeDimensionalArray() { - String fixtureJson - = "{\"type\":\"LineString\",\"bbox\": " - + "[100.0,0.0,-100.0,105.0,1.0,0.0],\"coordinates\":[[100.0, 0.0],[101.0, 1.0]]}"; - LineString lineString = LineString.fromJson(fixtureJson); - compareJson(fixtureJson, lineString.toJson()); - } - - @Test - public void bboxDeserializer_deserializeTwoDimensionalArray() { - String fixtureJson - = "{\"type\":\"Point\",\"bbox\":[1,2,3,4],\"coordinates\":[100,0]}"; - Point point = Point.fromJson(fixtureJson); - compareJson(fixtureJson, point.toJson()); - } -} \ No newline at end of file diff --git a/services-geojson/src/test/java/com/mapbox/geojson/gson/GeometryDeserializerTest.java b/services-geojson/src/test/java/com/mapbox/geojson/gson/GeometryDeserializerTest.java deleted file mode 100644 index 5d380d2e2..000000000 --- a/services-geojson/src/test/java/com/mapbox/geojson/gson/GeometryDeserializerTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.mapbox.core.TestUtils; -import org.junit.Test; - -public class GeometryDeserializerTest extends TestUtils { - - @Test - public void name() throws Exception { - - } -} diff --git a/services-geojson/src/test/java/com/mapbox/geojson/gson/PointDeserializerTest.java b/services-geojson/src/test/java/com/mapbox/geojson/gson/PointDeserializerTest.java deleted file mode 100644 index e1d3d92d8..000000000 --- a/services-geojson/src/test/java/com/mapbox/geojson/gson/PointDeserializerTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.mapbox.geojson.gson; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; -import com.google.gson.reflect.TypeToken; -import com.mapbox.core.TestUtils; -import com.mapbox.geojson.Point; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.lang.reflect.Type; -import java.util.List; - -import static org.junit.Assert.assertEquals; - - -public class PointDeserializerTest extends TestUtils { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void deserialize_sanity() throws Exception { - String jsonString = "[100.0, 0.0]"; - GsonBuilder gsonBuilder = new GsonBuilder() - .registerTypeAdapter(Point.class, new PointDeserializer()); - Point point = gsonBuilder.create().fromJson(jsonString, Point.class); - - assertEquals(100, point.longitude(), DELTA); - assertEquals(0, point.latitude(), DELTA); - } - - @Test - public void point_doesNotDeserializeObject() throws Exception { - thrown.expect(JsonSyntaxException.class); - - String jsonString = "{ \"coordinates\": [100.0, 0.0, 200.0]}"; - GsonBuilder gsonBuilder = new GsonBuilder() - .registerTypeAdapter(Point.class, new PointDeserializer()); - gsonBuilder.create().fromJson(jsonString, Point.class); - } - - @Test - public void point_deserializeArray() throws Exception { - String jsonString = "[100.0, 0.0, 200.0]"; - GsonBuilder gsonBuilder = new GsonBuilder() - .registerTypeAdapter(Point.class, new PointDeserializer()); - Point point = gsonBuilder.create().fromJson(jsonString, Point.class); - - assertEquals(100, point.longitude(), DELTA); - assertEquals(0, point.latitude(), DELTA); - assertEquals(200, point.altitude(), DELTA); - } - - @Test - public void point_deserializeArrayOfArrays() throws Exception { - String jsonString = "[[50.0, 50.0, 100.0], [100.0, 100.0, 200.0]]"; - GsonBuilder gsonBuilder = new GsonBuilder() - .registerTypeAdapter(Point.class, new PointDeserializer()); - List points = gsonBuilder.create().fromJson(jsonString, - new TypeToken>() {}.getType()); - - assertEquals(50, points.get(0).longitude(), DELTA); - assertEquals(50, points.get(0).latitude(), DELTA); - assertEquals(100, points.get(0).altitude(), DELTA); - - - assertEquals(100, points.get(1).longitude(), DELTA); - assertEquals(100, points.get(1).latitude(), DELTA); - assertEquals(200, points.get(1).altitude(), DELTA); - } - - @Test - public void point_deserializeArrayOfArraysOfArrays() throws Exception { - String jsonString = "[[[50.0, 50.0, 100.0], [100.0, 100.0, 200.0]]]"; - GsonBuilder gsonBuilder = new GsonBuilder() - .registerTypeAdapter(Point.class, new PointDeserializer()); - - Type type = - new TypeToken>>() {}.getType(); - List> points = gsonBuilder.create().fromJson(jsonString, - type); - - assertEquals(50, points.get(0).get(0).longitude(), DELTA); - assertEquals(50, points.get(0).get(0).latitude(), DELTA); - assertEquals(100, points.get(0).get(0).altitude(), DELTA); - - - assertEquals(100, points.get(0).get(1).longitude(), DELTA); - assertEquals(100, points.get(0).get(1).latitude(), DELTA); - assertEquals(200, points.get(0).get(1).altitude(), DELTA); - } -} diff --git a/services-geojson/src/test/java/com/mapbox/geojson/gson/PointSerializerTest.java b/services-geojson/src/test/java/com/mapbox/geojson/gson/PointSerializerTest.java deleted file mode 100644 index 79b8b7ee0..000000000 --- a/services-geojson/src/test/java/com/mapbox/geojson/gson/PointSerializerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.mapbox.geojson.gson; - - -import com.mapbox.core.TestUtils; -import com.mapbox.geojson.BoundingBox; -import com.mapbox.geojson.Point; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PointSerializerTest extends TestUtils { - - private static final String POINT_FIXTURE = "sample-point.json"; - private static final String POINT_WITH_BBOX_FIXTURE = "sample-point-with-bbox.json"; - private static final String POINT_WITH_ALTITUDE_AND_BBOX_FIXTURE = "sample-point-with-altitude-and-bbox.json"; - private static final String POINT_WITH_ALTITUDE_NO_BBOX_FIXTURE = "sample-point-with-altitude-no-bbox.json"; - - @Test - public void point_hasAltitudeValueNoBoundingBox() throws Exception { - Point point = Point.fromLngLat(100, 0, 200); - compareJson(loadJsonFixture(POINT_WITH_ALTITUDE_NO_BBOX_FIXTURE), point.toJson()); - } - - @Test - public void point_hasAltitudeValueNoBoundingBoxAltCheck() throws Exception { - Point point = Point.fromLngLat(100, 0, 200); - assertEquals(200, point.altitude(), 0); - } - - @Test - public void point_hasAltitudeValueWithBoundingBox() throws Exception { - Point point = Point.fromLngLat(100, 0, 200, - BoundingBox.fromLngLats(-100, -10, 100, 100, 10, 200)); - compareJson(loadJsonFixture(POINT_WITH_ALTITUDE_AND_BBOX_FIXTURE), point.toJson()); - } - - @Test - public void point_hasBboxValue() throws Exception { - Point point = Point.fromLngLat(100, 0, - BoundingBox.fromLngLats(-100, -10, 100, 10)); - compareJson(loadJsonFixture(POINT_WITH_BBOX_FIXTURE), point.toJson()); - } - - @Test - public void point_hasAltitudeAsNan() throws Exception { - Point point = Point.fromLngLat(100, 0, Double.NaN); - String expectedString = loadJsonFixture(POINT_FIXTURE); - String jsonString = point.toJson(); - compareJson(expectedString, jsonString); - } -} diff --git a/services-isochrone/src/main/java/com/mapbox/api/isochrone/IsochroneService.java b/services-isochrone/src/main/java/com/mapbox/api/isochrone/IsochroneService.java index 8fec05554..62586c7c5 100644 --- a/services-isochrone/src/main/java/com/mapbox/api/isochrone/IsochroneService.java +++ b/services-isochrone/src/main/java/com/mapbox/api/isochrone/IsochroneService.java @@ -15,57 +15,6 @@ */ public interface IsochroneService { - /** - * Constructs the HTTP request for the specified parameters. - * - * @param profile A Mapbox Directions routing profile ID. Options are - * {@link IsochroneCriteria#PROFILE_DRIVING} for travel - * times by car, {@link IsochroneCriteria#PROFILE_WALKING} - * for pedestrian and hiking travel times,and - * {@link IsochroneCriteria#PROFILE_CYCLING} for travel times - * by bicycle. - * @param coordinates A {@link Point} object which represents a - * {longitude,latitude} coordinate pair around which to - * center the isochrone lines. - * @param contoursMinutes A single String which has a comma-separated time in minutes to use for - * each isochrone contour. - * @param accessToken A valid Mapbox access token. - * @param contoursColors The colors to use for each isochrone contour, specified as hex values - * without a leading # (for example, ff0000 for red). If this parameter is - * used, there must be the same number of colors as there are entries in - * contours_minutes. If no colors are specified, the Isochrone API will - * assign a default rainbow color scheme to the output. - * @param polygons Specify whether to return the contours as GeoJSON polygons (true) or - * linestrings (false, default). When polygons=true, any contour that - * forms a ring is returned as a polygon. - * @param denoise A floating point value from 0.0 to 1.0 that can be used to remove - * smaller contours. The default is 1.0. A value of 1.0 will only - * return the largest contour for a given time value. A value of 0.5 - * drops any contours that are less than half the area of the largest - * contour in the set of contours for that same time value. - * @param generalize A positive floating point value in meters used as the tolerance for - * Douglas-Peucker generalization. There is no upper bound. If no value is - * specified in the request, the Isochrone API will choose the most - * optimized generalization to use for the request. Note that the - * generalization of contours can lead to self-intersections, as well - * as intersections of adjacent contours. - * @return a {@link FeatureCollection} in a Call wrapper - * @since 4.6.0 - * @deprecated this method was missing the user parameter. Use the getCall() method below instead. - */ - @Deprecated - @GET("/isochrone/v1/{profile}/{coordinates}") - Call getCall( - @Path("profile") String profile, - @Path("coordinates") String coordinates, - @Query("contours_minutes") String contoursMinutes, - @Query("access_token") String accessToken, - @Query("contours_colors") String contoursColors, - @Query("polygons") Boolean polygons, - @Query("denoise") Float denoise, - @Query("generalize") Float generalize); - - /** * Constructs the HTTP request for the specified parameters. *