index
int64
repo_id
string
file_path
string
content
string
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/directions/NBRoute.java
package ai.nextbillion.api.models.directions; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import java.util.List; import ai.nextbillion.api.models.NBLocation; @AutoValue public abstract class NBRoute { /////////////////////////////////////////////////////////////////////////// // Params /////////////////////////////////////////////////////////////////////////// public abstract double distance(); @SerializedName("distance_full") public abstract double distanceFull(); public abstract double duration(); @Nullable @SerializedName("end_location") public abstract NBLocation endLocation(); public abstract String geometry(); public abstract List<NBRouteLeg> legs(); @Nullable @SerializedName("start_location") public abstract NBLocation startLocation(); /////////////////////////////////////////////////////////////////////////// // Params End /////////////////////////////////////////////////////////////////////////// public static TypeAdapter<NBRoute> typeAdapter(Gson gson) { return new AutoValue_NBRoute.GsonTypeAdapter(gson); } public static Builder builder() { return new AutoValue_NBRoute.Builder(); } public abstract Builder toBuilder(); @AutoValue.Builder public abstract static class Builder { public abstract Builder distance(double distance); public abstract Builder distanceFull(double distanceFull); public abstract Builder duration(double duration); public abstract Builder endLocation(NBLocation endLocation); public abstract Builder geometry(String geometry); public abstract Builder legs(List<NBRouteLeg> legs); public abstract Builder startLocation(NBLocation startLocation); public abstract NBRoute build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/directions/NBRouteLeg.java
package ai.nextbillion.api.models.directions; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import java.util.List; import ai.nextbillion.api.models.NBDistance; import ai.nextbillion.api.models.NBDuration; import ai.nextbillion.api.models.NBLocation; @AutoValue public abstract class NBRouteLeg { public abstract NBDistance distance(); public abstract NBDuration duration(); @Nullable @SerializedName("end_location") public abstract NBLocation endLocation(); @Nullable @SerializedName("start_location") public abstract NBLocation startLocation(); @Nullable public abstract List<NBLegStep> steps(); public static TypeAdapter<NBRouteLeg> typeAdapter(Gson gson) { return new AutoValue_NBRouteLeg.GsonTypeAdapter(gson); } public static Builder builder() { return new AutoValue_NBRouteLeg.Builder(); } public abstract Builder toBuilder(); @AutoValue.Builder public abstract static class Builder { public abstract Builder distance(NBDistance distance); public abstract Builder duration(NBDuration duration); public abstract Builder endLocation(NBLocation endLocation); public abstract Builder startLocation(NBLocation startLocation); public abstract Builder steps(List<NBLegStep> steps); public abstract NBRouteLeg build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/nearby/NBNearBy.java
package ai.nextbillion.api.nearby; import com.google.auto.value.AutoValue; import com.google.gson.GsonBuilder; import com.nbmap.core.NbmapService; import com.nbmap.core.constants.Constants; import com.nbmap.core.exceptions.ServicesException; import com.nbmap.core.utils.NbmapUtils; import retrofit2.Call; @AutoValue public abstract class NBNearBy extends NbmapService<NBNearByResponse, NBNearByService> { public NBNearBy() { super(NBNearByService.class); } @Override protected GsonBuilder getGsonBuilder() { return super.getGsonBuilder(); } @Override protected Call<NBNearByResponse> initializeCall() { return null; } @Override protected abstract String baseUrl(); ////////////////////Query Params/////////////////////////////////////////// abstract String currentLocation(); abstract int maxCount(); abstract int searchRadius(); abstract String serviceType(); abstract String accessToken(); ////////////////////Query Params Ends////////////////////////////////////// public static Builder builder() { return new AutoValue_NBNearBy.Builder().baseUrl(Constants.BASE_API_URL); } /////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////// @AutoValue.Builder public abstract static class Builder { abstract Builder currentLocation(String currentLocation); abstract Builder maxCount(int maxCount); abstract Builder searchRadius(int radius); abstract Builder serviceType(String serviceType); abstract Builder accessToken(String token); public abstract Builder baseUrl(String baseUrl); abstract NBNearBy autoBuild(); public NBNearBy build() { NBNearBy nearBy = autoBuild(); if (!NbmapUtils.isAccessTokenValid(nearBy.accessToken())) { throw new ServicesException("Using Nbmap Services requires setting a valid access token."); } return nearBy; } } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/nearby/NBNearByResponse.java
package ai.nextbillion.api.nearby; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import java.io.Serializable; import java.util.List; import ai.nextbillion.api.models.NBLocation; import ai.nextbillion.api.models.NBNearByObject; @AutoValue public abstract class NBNearByResponse implements Serializable { public abstract Builder toBuilder(); public static Builder builder() { return new AutoValue_NBNearByResponse.Builder(); } public static TypeAdapter<NBNearByResponse> typeAdapter(Gson gson) { return new AutoValue_NBNearByResponse.GsonTypeAdapter(gson); } public abstract NBLocation currentlocation(); public abstract int maxcount(); public abstract String servicetype(); public abstract int searchradius(); public abstract String status(); public abstract String msg(); public abstract List<NBNearByObject> results(); /////////////////////////////////////////////////////////////////////////// // Builder /////////////////////////////////////////////////////////////////////////// @AutoValue.Builder public abstract static class Builder { public abstract Builder currentlocation(NBLocation currentLocation); public abstract Builder maxcount(int maxCount); public abstract Builder servicetype(String serviceType); public abstract Builder searchradius(int searchRadius); public abstract Builder status(String status); public abstract Builder msg(String msg); public abstract Builder results(List<NBNearByObject> results); public abstract NBNearByResponse build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/nearby/NBNearByResponseFactory.java
package ai.nextbillion.api.nearby; public class NBNearByResponseFactory { }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/nearby/NBNearByService.java
package ai.nextbillion.api.nearby; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Query; public interface NBNearByService { @GET("/getnearby") Call<NBNearByResponse> getNearBy( @Query("currentlocation") String location, @Query("key") String key, @Query("maxcount") int maxCount, @Query("searchradius") int radius, @Query("servicetype") String serviceType ); }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/nearby/package-info.java
/** * Contains the constants used throughout the GeoJson classes. */ package ai.nextbillion.api.nearby;
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/posttriproute/NBPostTripRoute.java
package ai.nextbillion.api.posttriproute; import com.google.auto.value.AutoValue; import com.google.gson.GsonBuilder; import com.nbmap.core.NbmapService; import com.nbmap.core.constants.Constants; import retrofit2.Call; @AutoValue public abstract class NBPostTripRoute extends NbmapService<NBPostTripRouteResponse, NBPostTripRouteService> { public NBPostTripRoute() { super(NBPostTripRouteService.class); } /////////////////////////////////////////////////////////////////////////// // Override /////////////////////////////////////////////////////////////////////////// @Override protected GsonBuilder getGsonBuilder() { return super.getGsonBuilder(); } @Override protected Call<NBPostTripRouteResponse> initializeCall() { return null; } @Override protected abstract String baseUrl(); /////////////////////////////////////////////////////////////////////////// // Params /////////////////////////////////////////////////////////////////////////// abstract boolean debug(); abstract String accessToken(); abstract String mode(); abstract String timestamps(); abstract boolean tolerateOutlier(); abstract String wayPoints(); /////////////////////////////////////////////////////////////////////////// // Builder /////////////////////////////////////////////////////////////////////////// public static Builder builder() { return new AutoValue_NBPostTripRoute.Builder().baseUrl(Constants.BASE_API_URL); } @AutoValue.Builder public abstract static class Builder { abstract Builder debug(boolean debug); abstract Builder accessToken(String accessToken); abstract Builder mode(String mode); abstract Builder baseUrl(String baseUrl); abstract Builder timestamps(String timestamps); abstract Builder tolerateOutlier(boolean tolerateOutlier); abstract Builder wayPoints(String wayPoints); abstract NBPostTripRoute build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/posttriproute/NBPostTripRouteResponse.java
package ai.nextbillion.api.posttriproute; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import ai.nextbillion.api.models.NBSimpleRoute; @AutoValue public abstract class NBPostTripRouteResponse { public abstract String errorMessage(); public abstract String mode(); public abstract String status(); public abstract NBSimpleRoute route(); public abstract Builder toBuilder(); public static Builder builder() { return new AutoValue_NBPostTripRouteResponse.Builder(); } public static TypeAdapter<NBPostTripRouteResponse> typeAdapter(Gson gson) { return new AutoValue_NBPostTripRouteResponse.GsonTypeAdapter(gson); } @AutoValue.Builder public abstract static class Builder { public abstract Builder errorMessage(String errorMessage); public abstract Builder mode(String mode); public abstract Builder status(String status); public abstract Builder route(NBSimpleRoute route); public abstract NBPostTripRouteResponse build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/posttriproute/NBPostTripRouteResponseFactory.java
package ai.nextbillion.api.posttriproute; public class NBPostTripRouteResponseFactory { }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/posttriproute/NBPostTripRouteService.java
package ai.nextbillion.api.posttriproute; import retrofit2.Call; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; public interface NBPostTripRouteService { @FormUrlEncoded @POST("/postTripRoute/json") Call<NBPostTripRouteResponse> getPostTripRoute( @Field("debug") boolean debug, @Field("key") String accessToken, @Field("mode") String mode, @Field("timestamps") String timestamps, @Field("tolerate_outlier") boolean tolerateOutlier, @Field("waypoints") String wayPoints ); }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/posttriproute/package-info.java
/** * Contains the constants used throughout the GeoJson classes. */ package ai.nextbillion.api.posttriproute;
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/snaptoroad/NBSnapToRoad.java
package ai.nextbillion.api.snaptoroad; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.core.NbmapService; import java.util.List; import ai.nextbillion.api.models.NBLocation; import ai.nextbillion.api.utils.FormatUtils; import retrofit2.Call; @AutoValue public abstract class NBSnapToRoad extends NbmapService<NBSnapToRoadResponse, NBSnapToRoadService> { protected NBSnapToRoad() { super(NBSnapToRoadService.class); } @Override protected GsonBuilder getGsonBuilder() { return super.getGsonBuilder().registerTypeAdapterFactory(NBSnapToRoadsAdapterFactory.create()); } @Override protected Call<NBSnapToRoadResponse> initializeCall() { return getService().getSnapToRoads( interpolate(), key(), locationsToString(path()), listToString(radiuses()), timestamps(), tolerateOutlier() ); } /////////////////////////////////////////////////////////////////////////// // Params converter /////////////////////////////////////////////////////////////////////////// private String locationsToString(@NonNull List<NBLocation> locations) { return FormatUtils.join("|", locations); } private String listToString(@NonNull List<String> list) { return FormatUtils.join("|", list); } /////////////////////////////////////////////////////////////////////////// // Params /////////////////////////////////////////////////////////////////////////// public abstract boolean interpolate(); @Override public abstract String baseUrl(); public abstract String key(); public abstract List<NBLocation> path(); @Nullable public abstract List<String> radiuses(); @Nullable public abstract String timestamps(); public abstract boolean tolerateOutlier(); /////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////// public static TypeAdapter<NBSnapToRoad> typeAdapter(Gson gson) { return new AutoValue_NBSnapToRoad.GsonTypeAdapter(gson); } public static Builder builder() { return new AutoValue_NBSnapToRoad.Builder(); } public abstract Builder toBuilder(); @AutoValue.Builder public abstract static class Builder { public abstract Builder interpolate(boolean interpolate); public abstract Builder key(String accessToken); public abstract Builder path(List<NBLocation> path); public abstract Builder radiuses(List<String> radiuses); public abstract Builder timestamps(String timestamps); public abstract Builder tolerateOutlier(boolean tolerateOutlier); public abstract Builder baseUrl(String baseUrl); public abstract NBSnapToRoad build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/snaptoroad/NBSnapToRoadResponse.java
package ai.nextbillion.api.snaptoroad; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import java.util.List; import ai.nextbillion.api.models.NBSnappedPoint; @AutoValue public abstract class NBSnapToRoadResponse { public abstract int distance(); public abstract List<String> geometry(); public abstract String status(); public abstract List<NBSnappedPoint> snappedPoints(); public abstract Builder toBuilder(); public static Builder builder() { return new AutoValue_NBSnapToRoadResponse.Builder(); } public static TypeAdapter<NBSnapToRoadResponse> typeAdapter(Gson gson) { return new AutoValue_NBSnapToRoadResponse.GsonTypeAdapter(gson); } @AutoValue.Builder public abstract static class Builder { public abstract Builder distance(int distance); public abstract Builder geometry(List<String> geometry); public abstract Builder status(String status); public abstract Builder snappedPoints(List<NBSnappedPoint> snappedPoints); public abstract NBSnapToRoadResponse build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/snaptoroad/NBSnapToRoadResponseFactory.java
package ai.nextbillion.api.snaptoroad; public class NBSnapToRoadResponseFactory { }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/snaptoroad/NBSnapToRoadService.java
package ai.nextbillion.api.snaptoroad; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Query; public interface NBSnapToRoadService { @GET("/snapToRoads/json") Call<NBSnapToRoadResponse> getSnapToRoads( @Query("interpolate") boolean interpolate, @Query("key") String accessToken, @Query("path") String path, @Query("radiuses") String radiuses, @Query("timestamps") String timestamps, @Query("tolerate_outlier") boolean tolerateOutlier ); }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/snaptoroad/NBSnapToRoadsAdapterFactory.java
package ai.nextbillion.api.snaptoroad; import com.google.gson.TypeAdapterFactory; import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory; @GsonTypeAdapterFactory public abstract class NBSnapToRoadsAdapterFactory implements TypeAdapterFactory { public static TypeAdapterFactory create() { return new AutoValueGson_NBSnapToRoadsAdapterFactory(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/snaptoroad/package-info.java
/** * Contains the constants used throughout the GeoJson classes. */ package ai.nextbillion.api.snaptoroad;
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/utils/FormatUtils.java
package ai.nextbillion.api.utils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.nbmap.geojson.Point; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * Methods to convert models to Strings. */ public class FormatUtils { /** * Returns a string containing the tokens joined by delimiters. Doesn't remove trailing nulls. * * @param delimiter the delimiter on which to split. * @param tokens A list of objects to be joined. Strings will be formed from the objects by * calling object.toString(). * @return {@link String} */ @Nullable public static String join(@NonNull CharSequence delimiter, @Nullable List<?> tokens) { return join(delimiter, tokens, false); } /** * Returns a string containing the tokens joined by delimiters. * * @param delimiter the delimiter on which to split. * @param tokens A list of objects to be joined. Strings will be formed from the objects by * calling object.toString(). * @param removeTrailingNulls true if trailing nulls should be removed. * @return {@link String} */ @Nullable public static String join(@NonNull CharSequence delimiter, @Nullable List<?> tokens, boolean removeTrailingNulls) { if (tokens == null || tokens.size() < 1) { return null; } int lastNonNullToken = tokens.size() - 1; if (removeTrailingNulls) { for (int i = tokens.size() - 1; i >= 0; i--) { Object token = tokens.get(i); if (token != null) { break; } else { lastNonNullToken--; } } } StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (int i = 0; i <= lastNonNullToken; i++) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } Object token = tokens.get(i); if (token != null) { sb.append(token); } } return sb.toString(); } /** * Useful to remove any trailing zeros and prevent a coordinate being over 7 significant figures. * * @param coordinate a double value representing a coordinate. * @return a formatted string. */ @NonNull public static String formatCoordinate(double coordinate) { DecimalFormat decimalFormat = new DecimalFormat("0.######", new DecimalFormatSymbols(Locale.US)); return String.format(Locale.US, "%s", decimalFormat.format(coordinate)); } /** * Used in various APIs to format the user provided radiuses to a String matching the APIs * format. * * @param radiuses a list of doubles represents the radius values * @return a String ready for being passed into the Retrofit call */ @Nullable public static String formatRadiuses(@Nullable List<Double> radiuses) { if (radiuses == null || radiuses.size() == 0) { return null; } List<String> radiusesToJoin = new ArrayList<>(); for (Double radius : radiuses) { if (radius == null) { radiusesToJoin.add(null); } else if (radius == Double.POSITIVE_INFINITY) { radiusesToJoin.add("unlimited"); } else { radiusesToJoin.add(String.format(Locale.US, "%s", formatCoordinate(radius))); } } return join(";", radiusesToJoin); } /** * Formats the bearing variables from the raw values to a string which can than be used for the * request URL. * * @param bearings a List of list of doubles representing bearing values * @return a string with the bearing values */ @Nullable public static String formatBearings(@Nullable List<List<Double>> bearings) { if (bearings == null || bearings.isEmpty()) { return null; } List<String> bearingsToJoin = new ArrayList<>(); for (List<Double> bearing : bearings) { if (bearing == null) { bearingsToJoin.add(null); } else { if (bearing.size() != 2) { throw new RuntimeException("Bearing size should be 2."); } Double angle = bearing.get(0); Double tolerance = bearing.get(1); if (angle == null || tolerance == null) { bearingsToJoin.add(null); } else { if (angle < 0 || angle > 360 || tolerance < 0 || tolerance > 360) { throw new RuntimeException("Angle and tolerance have to be from 0 to 360."); } bearingsToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(angle), formatCoordinate(tolerance))); } } } return join(";", bearingsToJoin); } /** * Converts the list of integer arrays to a string ready for API consumption. * * @param distributions the list of integer arrays representing the distribution * @return a string with the distribution values */ @Nullable public static String formatDistributions(@Nullable List<Integer[]> distributions) { if (distributions == null || distributions.isEmpty()) { return null; } List<String> distributionsToJoin = new ArrayList<>(); for (Integer[] array : distributions) { if (array.length == 0) { distributionsToJoin.add(null); } else { distributionsToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(array[0]), formatCoordinate(array[1]))); } } return join(";", distributionsToJoin); } /** * Converts String list with approaches values to a string ready for API consumption. An approach * could be unrestricted, curb or null. * * @param approaches a list representing approaches to each coordinate. * @return a formatted string. */ @Nullable public static String formatApproaches(@Nullable List<String> approaches) { if (approaches == null || approaches.isEmpty()) { return null; } for (String approach : approaches) { if (approach != null && !approach.equals("unrestricted") && !approach.equals("curb") && !approach.isEmpty()) { return null; } } return join(";", approaches); } /** * Converts String list with waypoint_names values to a string ready for API consumption. * * @param waypointNames a string representing approaches to each coordinate. * @return a formatted string. */ @Nullable public static String formatWaypointNames(@Nullable List<String> waypointNames) { if (waypointNames == null || waypointNames.isEmpty()) { return null; } return join(";", waypointNames); } /** * Converts a list of Points to String. * * @param coordinates a list of coordinates. * @return a formatted string. */ @Nullable public static String formatCoordinates(@NonNull List<Point> coordinates) { List<String> coordinatesToJoin = new ArrayList<>(); for (Point point : coordinates) { coordinatesToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(point.longitude()), formatCoordinate(point.latitude()))); } return join(";", coordinatesToJoin); } /** * Converts array of Points with waypoint_targets values to a string ready for API consumption. * * @param points a list representing approaches to each coordinate. * @return a formatted string. */ @Nullable public static String formatPointsList(@Nullable List<Point> points) { if (points == null || points.isEmpty()) { return null; } List<String> coordinatesToJoin = new ArrayList<>(); for (Point point : points) { if (point == null) { coordinatesToJoin.add(null); } else { coordinatesToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(point.longitude()), formatCoordinate(point.latitude()))); } } return join(";", coordinatesToJoin); } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/utils/ParseUtils.java
package ai.nextbillion.api.utils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.nbmap.geojson.Point; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Methods to convert Strings to Lists of objects. */ public class ParseUtils { private static final String SEMICOLON = ";"; private static final String COMMA = ","; private static final String UNLIMITED = "unlimited"; private static final String TRUE = "true"; private static final String FALSE = "false"; /** * Parse a String to a list of Integers. * * @param original an original String. * @return List of Integers */ @Nullable public static List<Integer> parseToIntegers(@Nullable String original) { if (original == null) { return null; } List<Integer> integers = new ArrayList<>(); String[] strings = original.split(SEMICOLON); for (String index : strings) { if (index != null) { if (index.isEmpty()) { integers.add(null); } else { integers.add(Integer.valueOf(index)); } } } return integers; } /** * Parse a String to a list of Strings using ";" as a separator. * * @param original an original String. * @return List of Strings */ @Nullable public static List<String> parseToStrings(@Nullable String original) { return parseToStrings(original, SEMICOLON); } /** * Parse a String to a list of Strings. * * @param original an original String. * @param separator a String used as a separator. * @return List of Strings */ @Nullable public static List<String> parseToStrings(@Nullable String original, @NonNull String separator) { if (original == null) { return null; } List<String> result = new ArrayList<>(); String[] strings = original.split(separator, -1); for (String str : strings) { if (str != null) { if (str.isEmpty()) { result.add(null); } else { result.add(str); } } } return result; } /** * Parse a String to a list of Points. * * @param original an original String. * @return List of Points */ @Nullable public static List<Point> parseToPoints(@Nullable String original) { if (original == null) { return null; } List<Point> points = new ArrayList<>(); String[] targets = original.split(SEMICOLON, -1); for (String target : targets) { if (target != null) { if (target.isEmpty()) { points.add(null); } else { String[] point = target.split(COMMA); points.add(Point.fromLngLat(Double.valueOf(point[0]), Double.valueOf(point[1]))); } } } return points; } /** * Parse a String to a list of Points. * * @param original an original String. * @return List of Doubles */ @Nullable public static List<Double> parseToDoubles(@Nullable String original) { if (original == null) { return null; } List<Double> doubles = new ArrayList<>(); String[] strings = original.split(SEMICOLON, -1); for (String str : strings) { if (str != null) { if (str.isEmpty()) { doubles.add(null); } else if (str.equals(UNLIMITED)) { doubles.add(Double.POSITIVE_INFINITY); } else { doubles.add(Double.valueOf(str)); } } } return doubles; } /** * Parse a String to a list of list of Doubles. * * @param original an original String. * @return List of List of Doubles */ @Nullable public static List<List<Double>> parseToListOfListOfDoubles(@Nullable String original) { if (original == null) { return null; } List<List<Double>> result = new ArrayList<>(); String[] pairs = original.split(SEMICOLON, -1); for (String pair : pairs) { if (pair.isEmpty()) { result.add(null); } else { String[] values = pair.split(COMMA); if (values.length == 2) { result.add(Arrays.asList(Double.valueOf(values[0]), Double.valueOf(values[1]))); } } } return result; } /** * Parse a String to a list of Boolean. * * @param original an original String. * @return List of Booleans */ @Nullable public static List<Boolean> parseToBooleans(@Nullable String original) { if (original == null) { return null; } List<Boolean> booleans = new ArrayList<>(); if (original.isEmpty()) { return booleans; } String[] strings = original.split(SEMICOLON, -1); for (String str : strings) { if (str != null) { if (str.isEmpty()) { booleans.add(null); } else if (str.equalsIgnoreCase(TRUE)) { booleans.add(true); } else if (str.equalsIgnoreCase(FALSE)) { booleans.add(false); } else { booleans.add(null); } } } return booleans; } }
0
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/utils/package-info.java
/** * Contains classes with utilities useful for model classes. * */ package ai.nextbillion.api.utils;
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/NbmapService.java
package com.nbmap.core; import com.google.gson.GsonBuilder; import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; /** * Nbmap specific services used internally within the SDK. Subclasses must implement baseUrl and * initializeCall. * * @param <T> Type parameter for response. * @param <S> Type parameter for service interface. * @since 1.0.0 */ public abstract class NbmapService<T, S> { protected static final int MAX_URL_SIZE = 1024 * 8; private final Class<S> APIServiceType; private boolean enableDebug; protected OkHttpClient okHttpClient; private okhttp3.Call.Factory callFactory; private Retrofit retrofit; private Call<T> call; private S service; /** * Constructor for creating a new NbmapService setting the service type for use when * initializing retrofit. Subclasses should pass their service class to this constructor. * * @param serviceType for initializing retrofit * @since 3.0.0 */ public NbmapService(Class<S> serviceType) { this.APIServiceType = serviceType; } /** * Should return base url for retrofit calls. * * @return baseUrl as a string * @since 3.0.0 */ protected abstract String baseUrl(); /** * Abstract method for getting Retrofit {@link Call} from the subclass. Subclasses should override * this method and construct and return the call. * * @return call * @since 3.0.0 */ protected abstract Call<T> initializeCall(); /** * Get call if already created, otherwise get it from subclass implementation. * * @return call * @since 3.0.0 */ protected Call<T> getCall() { if (call == null) { call = initializeCall(); } return call; } /** * Wrapper method for Retrofits {@link Call#execute()} call returning a response specific to the * API implementing this class. * * @return the response once the call completes successfully * @throws IOException Signals that an I/O exception of some sort has occurred * @since 3.0.0 */ public Response<T> executeCall() throws IOException { return getCall().execute(); } /** * Wrapper method for Retrofits {@link Call#enqueue(Callback)} call returning a response specific * to the API implementing this class. Use this method to make a request on the Main Thread. * * @param callback a {@link Callback} which is used once the API response is created. * @since 3.0.0 */ public void enqueueCall(Callback<T> callback) { getCall().enqueue(callback); } /** * Wrapper method for Retrofits {@link Call#cancel()} call, important to manually cancel call if * the user dismisses the calling activity or no longer needs the returned results. * * @since 3.0.0 */ public void cancelCall() { getCall().cancel(); } /** * Wrapper method for Retrofits {@link Call#clone()} call, useful for getting call information. * * @return cloned call * @since 3.0.0 */ public Call<T> cloneCall() { return getCall().clone(); } /** * Creates the Retrofit object and the service if they are not already created. Subclasses can * override getGsonBuilder to add anything to the GsonBuilder. * * @return new service if not already created, otherwise the existing service * @since 3.0.0 */ protected S getService() { // No need to recreate it if (service != null) { return service; } Retrofit.Builder retrofitBuilder = new Retrofit.Builder() .baseUrl(baseUrl()) .addConverterFactory(GsonConverterFactory.create(getGsonBuilder().create())); if (getCallFactory() != null) { retrofitBuilder.callFactory(getCallFactory()); } else { retrofitBuilder.client(getOkHttpClient()); } retrofit = retrofitBuilder.build(); service = (S) retrofit.create(APIServiceType); return service; } /** * Returns the retrofit instance. * * @return retrofit, or null if it hasn't been initialized yet. * @since 3.0.0 */ public Retrofit getRetrofit() { return retrofit; } /** * Gets the GsonConverterFactory. Subclasses can override to register TypeAdapterFactories, etc. * * @return GsonBuilder for Retrofit * @since 3.0.0 */ protected GsonBuilder getGsonBuilder() { return new GsonBuilder(); } /** * Returns if debug logging is enabled in Okhttp. * * @return whether enableDebug is true * @since 3.0.0 */ public boolean isEnableDebug() { return enableDebug; } /** * Enable for more verbose log output while making request. * * @param enableDebug true if you'd like Okhttp to log * @since 3.0.0 */ public void enableDebug(boolean enableDebug) { this.enableDebug = enableDebug; } /** * Gets the call factory for creating {@link Call} instances. * * @return the call factory, or the default OkHttp client if it's null. * @since 2.0.0 */ public okhttp3.Call.Factory getCallFactory() { return callFactory; } /** * Specify a custom call factory for creating {@link Call} instances. * * @param callFactory implementation * @since 2.0.0 */ public void setCallFactory(okhttp3.Call.Factory callFactory) { this.callFactory = callFactory; } /** * Used Internally. * * @return OkHttpClient * @since 1.0.0 */ protected synchronized OkHttpClient getOkHttpClient() { if (okHttpClient == null) { if (isEnableDebug()) { HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BASIC); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(logging); okHttpClient = httpClient.build(); } else { okHttpClient = new OkHttpClient(); } } return okHttpClient; } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/package-info.java
/** * Contains common classes and methods shared between all other service modules. * * @since 3.0.0 */ package com.nbmap.core;
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/constants/Constants.java
package com.nbmap.core.constants; import com.nbmap.core.BuildConfig; import java.util.Locale; /** * Includes common variables used throughout the Nbmap Service modules. * * @since 3.0.0 */ public final class Constants { /** * User agent for HTTP requests. * * @since 1.0.0 */ public static final String HEADER_USER_AGENT = String.format(Locale.US, "NbmapJava/%s (%s)", BuildConfig.VERSION, BuildConfig.GIT_REVISION); /** * Base URL for all API calls, not hardcoded to enable testing. * * @since 1.0.0 */ public static final String BASE_API_URL = "https://api.nextbillion.io"; /** * The default user variable used for all the Nbmap user names. * * @since 1.0.0 */ public static final String NBMAP_USER = "nbmap"; /** * Use a precision of 6 decimal places when encoding or decoding a polyline. * * @since 2.1.0 */ public static final int PRECISION_6 = 6; /** * Use a precision of 5 decimal places when encoding or decoding a polyline. * * @since 1.0.0 */ public static final int PRECISION_5 = 5; private Constants() { // Empty constructor prevents users from initializing this class } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/constants/package-info.java
/** * Contains the core service constant values useful for all other modules. * * @since 3.0.0 */ package com.nbmap.core.constants;
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/exceptions/ServicesException.java
package com.nbmap.core.exceptions; /** * A form of {@code Throwable} that indicates conditions that a reasonable application might * want to catch. * * @since 1.0.0 */ public class ServicesException extends RuntimeException { /** * A form of {@code Throwable} that indicates conditions that a reasonable application might * want to catch. * * @param message the detail message (which is saved for later retrieval by the * {@link #getMessage()} method). * @since 1.0.0 */ public ServicesException(String message) { super(message); } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/exceptions/package-info.java
/** * Contains a simple services runtime exception which can be used throughout the project. * * @since 3.0.0 */ package com.nbmap.core.exceptions;
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/internal/Preconditions.java
package com.nbmap.core.internal; import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; import androidx.annotation.RestrictTo; /** * Contains simple precondition checks. * * @since 3.0.0 */ @RestrictTo(LIBRARY_GROUP) public final class Preconditions { /** * Checks if the passed in value is not Null. Throws a NPE if the value is null. * * @param value The object to be checked fo null * @param message The message to be associated with NPE, if value is null * @since 3.0.0 */ public static void checkNotNull(Object value, String message) { if (value == null) { throw new NullPointerException(message); } } private Preconditions() { throw new AssertionError("No instances."); } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/internal/package-info.java
/** * Contains simple precondition checks which can be used throughout the project. * * @since 3.0.0 */ package com.nbmap.core.internal;
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/utils/ApiCallHelper.java
package com.nbmap.core.utils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.nbmap.core.constants.Constants; import java.util.Locale; /** * Static class with methods for assisting in making Nbmap API calls. * * @since 3.0.0 */ public final class ApiCallHelper { private static final String ONLY_PRINTABLE_CHARS = "[^\\p{ASCII}]"; private ApiCallHelper() { // Private constructor preventing instances of class } /** * Computes a full user agent header of the form: * {@code NbmapJava/1.2.0 Mac OS X/10.11.5 (x86_64)}. * * @param clientAppName Application Name * @return {@link String} representing the header user agent * @since 1.0.0 */ public static String getHeaderUserAgent(@Nullable String clientAppName) { String osName = System.getProperty("os.name"); String osVersion = System.getProperty("os.version"); String osArch = System.getProperty("os.arch"); if (TextUtils.isEmpty(osName) || TextUtils.isEmpty(osVersion) || TextUtils.isEmpty(osArch)) { return Constants.HEADER_USER_AGENT; } else { return getHeaderUserAgent(clientAppName, osName, osVersion, osArch); } } /** * Computes a full user agent header of the form: * {@code NbmapJava/1.2.0 Mac OS X/10.11.5 (x86_64)}. * * @param clientAppName Application Name * @param osName OS name * @param osVersion OS version * @param osArch OS Achitecture * @return {@link String} representing the header user agent * @since 1.0.0 */ public static String getHeaderUserAgent(@Nullable String clientAppName, @NonNull String osName, @NonNull String osVersion, @NonNull String osArch) { osName = osName.replaceAll(ONLY_PRINTABLE_CHARS, ""); osVersion = osVersion.replaceAll(ONLY_PRINTABLE_CHARS, ""); osArch = osArch.replaceAll(ONLY_PRINTABLE_CHARS, ""); String baseUa = String.format( Locale.US, "%s %s/%s (%s)", Constants.HEADER_USER_AGENT, osName, osVersion, osArch); return TextUtils.isEmpty(clientAppName) ? baseUa : String.format(Locale.US, "%s %s", clientAppName, baseUa); } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/utils/ColorUtils.java
package com.nbmap.core.utils; /** * Utils class for assisting with color transformations and other operations being done on colors. * * @since 3.0.0 */ public final class ColorUtils { private ColorUtils() { // No Instance. } /** * Converts red, green, blue values to a hex string that can then be used in a URL when making API * request. Note that this does <b>Not</b> add the hex key before the string. * * @param red the value of the color which needs to be converted * @param green the value of the color which needs to be converted * @param blue the value of the color which needs to be converted * @return the hex color value as a string * @since 3.1.0 */ public static String toHexString(int red, int green, int blue) { String hexColor = String.format("%02X%02X%02X", red, green, blue); if (hexColor.length() < 6) { hexColor = "000000".substring(0, 6 - hexColor.length()) + hexColor; } return hexColor; } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/utils/NbmapUtils.java
package com.nbmap.core.utils; /** * Misc utils around Nbmap services. * * @since 1.0.0 */ public final class NbmapUtils { private NbmapUtils() { // Empty private constructor since only static methods are found inside class. } /** * Checks that the provided access token is not empty or null, and that it starts with * the right prefixes. Note that this method does not check Nbmap servers to verify that * it actually belongs to an account. * * @param accessToken A Nbmap access token. * @return true if the provided access token is valid, false otherwise. * @since 1.0.0 */ public static boolean isAccessTokenValid(String accessToken) { return !TextUtils.isEmpty(accessToken); } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/utils/TextUtils.java
package com.nbmap.core.utils; import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.List; import java.util.Locale; /** * We avoid including a full library like org.apache.commons:commons-lang3 to avoid an unnecessary * large number of methods, which is inconvenient to Android devs. * * @see <a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/TextUtils.java">Some code came from this source.</a> * @since 1.0.0 */ public final class TextUtils { private TextUtils() { // Empty private constructor preventing class from getting initialized } /** * Returns true if the string is null or 0-length. * * @param str the string to be examined * @return true if str is null or zero length * @since 1.0.0 */ public static boolean isEmpty(CharSequence str) { return str == null || str.length() == 0; } /** * Returns a string containing the tokens joined by delimiters. * * @param delimiter the delimeter on which to split. * @param tokens An array objects to be joined. Strings will be formed from the objects by * calling object.toString(). * @return {@link String} * @since 1.0.0 */ public static String join(CharSequence delimiter, Object[] tokens) { if (tokens == null || tokens.length < 1) { return null; } StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token : tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } sb.append(token); } return sb.toString(); } /** * Useful to remove any trailing zeros and prevent a coordinate being over 7 significant figures. * * @param coordinate a double value representing a coordinate. * @return a formatted string. * @since 2.1.0 */ public static String formatCoordinate(double coordinate) { DecimalFormat decimalFormat = new DecimalFormat("0.######", new DecimalFormatSymbols(Locale.US)); return String.format(Locale.US, "%s", decimalFormat.format(coordinate)); } /** * Allows the specific adjusting of a coordinates precision. * * @param coordinate a double value representing a coordinate. * @param precision an integer value you'd like the precision to be at. * @return a formatted string. * @since 2.1.0 */ public static String formatCoordinate(double coordinate, int precision) { String pattern = "0." + new String(new char[precision]).replace("\0", "0"); DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(Locale.US); df.applyPattern(pattern); df.setRoundingMode(RoundingMode.FLOOR); return df.format(coordinate); } /** * Used in various APIs to format the user provided radiuses to a String matching the APIs format. * * @param radiuses a double array which represents the radius values * @return a String ready for being passed into the Retrofit call * @since 3.0.0 * @deprecated use FormatUtils.formatRadiuses(List) */ @Deprecated public static String formatRadiuses(double[] radiuses) { if (radiuses == null || radiuses.length == 0) { return null; } String[] radiusesFormatted = new String[radiuses.length]; for (int i = 0; i < radiuses.length; i++) { if (radiuses[i] == Double.POSITIVE_INFINITY) { radiusesFormatted[i] = "unlimited"; } else { radiusesFormatted[i] = String.format(Locale.US, "%s", TextUtils.formatCoordinate(radiuses[i])); } } return join(";", radiusesFormatted); } /** * Formats the bearing variables from the raw values to a string which can than be used for the * request URL. * * @param bearings a List of doubles representing bearing values * @return a string with the bearing values * @since 3.0.0 * @deprecated use FormatUtils.formatBearing(List) */ @Deprecated public static String formatBearing(List<Double[]> bearings) { if (bearings.isEmpty()) { return null; } String[] bearingFormatted = new String[bearings.size()]; for (int i = 0; i < bearings.size(); i++) { if (bearings.get(i).length == 0) { bearingFormatted[i] = ""; } else { bearingFormatted[i] = String.format(Locale.US, "%s,%s", TextUtils.formatCoordinate(bearings.get(i)[0]), TextUtils.formatCoordinate(bearings.get(i)[1])); } } return TextUtils.join(";", bearingFormatted); } /** * converts the list of integer arrays to a string ready for API consumption. * * @param distributions the list of integer arrays representing the distribution * @return a string with the distribution values * @since 3.0.0 * @deprecated use FormatUtils.formatDistributions(List) */ @Deprecated public static String formatDistributions(List<Integer[]> distributions) { if (distributions.isEmpty()) { return null; } String[] distributionsFormatted = new String[distributions.size()]; for (int i = 0; i < distributions.size(); i++) { if (distributions.get(i).length == 0) { distributionsFormatted[i] = ""; } else { distributionsFormatted[i] = String.format(Locale.US, "%s,%s", TextUtils.formatCoordinate(distributions.get(i)[0]), TextUtils.formatCoordinate(distributions.get(i)[1])); } } return TextUtils.join(";", distributionsFormatted); } /** * Converts String array with approaches values * to a string ready for API consumption. * An approach could be unrestricted, curb or null. * * @param approaches a string representing approaches to each coordinate. * @return a formatted string. * @since 3.2.0 * @deprecated use FormatUtils.formatApproaches(List) */ @Deprecated public static String formatApproaches(String[] approaches) { for (int i = 0; i < approaches.length; i++) { if (approaches[i] == null) { approaches[i] = ""; } else if (!approaches[i].equals("unrestricted") && !approaches[i].equals("curb") && !approaches[i].isEmpty()) { return null; } } return TextUtils.join(";", approaches); } /** * Converts String array with waypoint_names values * to a string ready for API consumption. * * @param waypointNames a string representing approaches to each coordinate. * @return a formatted string. * @since 3.3.0 * @deprecated use FormatUtils.formatWaypointNames(List) */ @Deprecated public static String formatWaypointNames(String[] waypointNames) { for (int i = 0; i < waypointNames.length; i++) { if (waypointNames[i] == null) { waypointNames[i] = ""; } } return TextUtils.join(";", waypointNames); } }
0
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core
java-sources/ai/nextbillion/nbmap-sdk-core/0.1.2/com/nbmap/core/utils/package-info.java
/** * Contains classes with utilities useful throughout the project. * * @since 1.0.0 */ package com.nbmap.core.utils;
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/DirectionsAdapterFactory.java
package com.nbmap.api.directions.v5; import com.google.gson.TypeAdapterFactory; import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory; /** * Required so that AutoValue can generate specific type adapters when needed inside the direction * packages. * * @since 3.0.0 */ @GsonTypeAdapterFactory public abstract class DirectionsAdapterFactory implements TypeAdapterFactory { /** * Creates a TypeAdapter that AutoValues uses to generate specific type adapters when needed * inside the direction package classes. * * @return 3.0.0 */ public static TypeAdapterFactory create() { return new AutoValueGson_DirectionsAdapterFactory(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/DirectionsCriteria.java
package com.nbmap.api.directions.v5; import androidx.annotation.StringDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Constants and properties used to customize the directions request. * * @since 1.0.0 */ public final class DirectionsCriteria { /** * Nbmap default username. * * @since 1.0.0 */ public static final String PROFILE_DEFAULT_USER = "nbmap"; /** * For car and motorcycle routing. This profile factors in current and historic traffic * conditions to avoid slowdowns. * * @since 2.0.0 */ public static final String PROFILE_DRIVING_TRAFFIC = "driving-traffic"; /** * For car and motorcycle routing. This profile shows the fastest routes by preferring * high-speed roads like highways. * * @since 1.0.0 */ public static final String PROFILE_DRIVING = "driving"; /** * For pedestrian and hiking routing. This profile shows the shortest path by using sidewalks * and trails. * * @since 1.0.0 */ public static final String PROFILE_WALKING = "walking"; /** * For bicycle routing. This profile shows routes that are short and safe for cyclist, avoiding * highways and preferring streets with bike lanes. * * @since 1.0.0 */ public static final String PROFILE_CYCLING = "cycling"; /** * Format to return route geometry will be an encoded polyline. * * @since 1.0.0 */ public static final String GEOMETRY_POLYLINE = "polyline"; /** * Format to return route geometry will be an encoded polyline with precision 6. * * @since 2.0.0 */ public static final String GEOMETRY_POLYLINE6 = "polyline6"; /** * A simplified version of the {@link #OVERVIEW_FULL} geometry. If not specified simplified is * the default. * * @since 1.0.0 */ public static final String OVERVIEW_SIMPLIFIED = "simplified"; /** * The most detailed geometry available. * * @since 1.0.0 */ public static final String OVERVIEW_FULL = "full"; /** * No overview geometry. * * @since 1.0.0 */ public static final String OVERVIEW_FALSE = "false"; /** * The duration, in seconds, between each pair of coordinates. * * @since 2.1.0 */ public static final String ANNOTATION_DURATION = "duration"; /** * The distance, in meters, between each pair of coordinates. * * @since 2.1.0 */ public static final String ANNOTATION_DISTANCE = "distance"; /** * The speed, in km/h, between each pair of coordinates. * * @since 2.1.0 */ public static final String ANNOTATION_SPEED = "speed"; /** * The congestion, provided as a String, between each pair of coordinates. * * @since 2.2.0 */ public static final String ANNOTATION_CONGESTION = "congestion"; /** * The posted speed limit, between each pair of coordinates. * * @since 2.1.0 */ public static final String ANNOTATION_MAXSPEED = "maxspeed"; /** * The closure of sections of a route. */ public static final String ANNOTATION_CLOSURE = "closure"; /** * Exclude all tolls along the returned directions route. * * @since 3.0.0 */ public static final String EXCLUDE_TOLL = "toll"; /** * Exclude all motorways along the returned directions route. * * @since 3.0.0 */ public static final String EXCLUDE_MOTORWAY = "motorway"; /** * Exclude all ferries along the returned directions route. * * @since 3.0.0 */ public static final String EXCLUDE_FERRY = "ferry"; /** * Exclude all tunnels along the returned directions route. * * @since 3.0.0 */ public static final String EXCLUDE_TUNNEL = "tunnel"; /** * Exclude all roads with access restrictions along the returned directions route. * * @since 3.0.0 */ public static final String EXCLUDE_RESTRICTED = "restricted"; /** * Change the units to imperial for voice and visual information. Note that this won't change * other results such as raw distance measurements which will always be returned in meters. * * @since 3.0.0 */ public static final String IMPERIAL = "imperial"; /** * Change the units to metric for voice and visual information. Note that this won't change * other results such as raw distance measurements which will always be returned in meters. * * @since 3.0.0 */ public static final String METRIC = "metric"; /** * Returned route starts at the first provided coordinate in the list. Used specifically for the * Optimization API. * * @since 2.1.0 */ public static final String SOURCE_FIRST = "first"; /** * Returned route starts at any of the provided coordinate in the list. Used specifically for the * Optimization API. * * @since 2.1.0 */ public static final String SOURCE_ANY = "any"; /** * Returned route ends at any of the provided coordinate in the list. Used specifically for the * Optimization API. * * @since 3.0.0 */ public static final String DESTINATION_ANY = "any"; /** * Returned route ends at the last provided coordinate in the list. Used specifically for the * Optimization API. * * @since 3.0.0 */ public static final String DESTINATION_LAST = "last"; /** * The routes can approach waypoints from either side of the road. <p> * * Used in MapMatching and Directions API. * * @since 3.2.0 */ public static final String APPROACH_UNRESTRICTED = "unrestricted"; /** * The route will be returned so that on arrival, * the waypoint will be found on the side that corresponds with the driving_side of * the region in which the returned route is located. <p> * * Used in MapMatching and Directions API. * * @since 3.2.0 */ public static final String APPROACH_CURB = "curb"; private DirectionsCriteria() { //not called } /** * Retention policy for the various direction profiles. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { PROFILE_DRIVING_TRAFFIC, PROFILE_DRIVING, PROFILE_WALKING, PROFILE_CYCLING }) public @interface ProfileCriteria { } /** * Retention policy for the various direction geometries. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { GEOMETRY_POLYLINE, GEOMETRY_POLYLINE6 }) public @interface GeometriesCriteria { } /** * Retention policy for the various direction overviews. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { OVERVIEW_FALSE, OVERVIEW_FULL, OVERVIEW_SIMPLIFIED }) public @interface OverviewCriteria { } /** * Retention policy for the various direction annotations. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { ANNOTATION_CONGESTION, ANNOTATION_DISTANCE, ANNOTATION_DURATION, ANNOTATION_SPEED, ANNOTATION_MAXSPEED }) public @interface AnnotationCriteria { } /** * Retention policy for the various direction exclusions. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { EXCLUDE_FERRY, EXCLUDE_MOTORWAY, EXCLUDE_TOLL, EXCLUDE_TUNNEL, EXCLUDE_RESTRICTED }) public @interface ExcludeCriteria { } /** * Retention policy for the various units of measurements. * * @since 0.3.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { IMPERIAL, METRIC }) public @interface VoiceUnitCriteria { } /** * Retention policy for the source parameter in the Optimization API. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { SOURCE_ANY, SOURCE_FIRST }) public @interface SourceCriteria { } /** * Retention policy for the destination parameter in the Optimization API. * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { DESTINATION_ANY, DESTINATION_LAST }) public @interface DestinationCriteria { } /** * Retention policy for the approaches parameter in the MapMatching and Directions API. * * @since 3.2.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { APPROACH_UNRESTRICTED, APPROACH_CURB }) public @interface ApproachesCriteria { } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/WalkingOptions.java
package com.nbmap.api.directions.v5; import androidx.annotation.FloatRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; /** * Class for specifying options for use with the walking profile. * @since 4.8.0 */ @AutoValue public abstract class WalkingOptions { /** * Walking speed in meters per second. Must be between 0.14 and 6.94 meters per second. * Defaults to 1.42 meters per second * * @return walkingSpeed in meters per second * @since 4.8.0 */ @SerializedName("walking_speed") @Nullable public abstract Double walkingSpeed(); /** * A bias which determines whether the route should prefer or avoid the use of roads or paths * that are set aside for pedestrian-only use (walkways). The allowed range of values is from * -1 to 1, where -1 indicates indicates preference to avoid walkways, 1 indicates preference * to favor walkways, and 0 indicates no preference (the default). * * @return walkwayBias bias to prefer or avoid walkways * @since 4.8.0 */ @SerializedName("walkway_bias") @Nullable public abstract Double walkwayBias(); /** * A bias which determines whether the route should prefer or avoid the use of alleys. The * allowed range of values is from -1 to 1, where -1 indicates indicates preference to avoid * alleys, 1 indicates preference to favor alleys, and 0 indicates no preference (the default). * * @return alleyBias bias to prefer or avoid alleys * @since 4.8.0 */ @SerializedName("alley_bias") @Nullable public abstract Double alleyBias(); /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a WalkingOptions object * @return a new instance of this class defined by the values passed inside this static factory * method * @since 4.8.0 */ public static WalkingOptions fromJson(String json) { GsonBuilder gsonBuilder = new GsonBuilder() .registerTypeAdapterFactory(WalkingOptionsAdapterFactory.create()); return gsonBuilder.create().fromJson(json, WalkingOptions.class); } /** * This takes the currently defined values found inside this instance and converts it to a json * string. * * @return a Json string which represents this WalkingOptions object * @since 4.8.0 */ public final String toJson() { Gson gson = new GsonBuilder() .registerTypeAdapterFactory(WalkingOptionsAdapterFactory.create()) .create(); return gson.toJson(this, WalkingOptions.class); } /** * Convert the current {@link WalkingOptions} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link WalkingOptions}. * * @return a {@link WalkingOptions.Builder} with the same values set to match the ones defined * in this {@link WalkingOptions} */ @NonNull public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 4.8.0 */ public static TypeAdapter<WalkingOptions> typeAdapter(Gson gson) { return new AutoValue_WalkingOptions.GsonTypeAdapter(gson); } /** * Build a new {@link WalkingOptions} object with no defaults. * * @return a {@link Builder} object for creating a {@link WalkingOptions} object * @since 4.8.0 */ public static Builder builder() { return new AutoValue_WalkingOptions.Builder(); } /** * This builder is used to create a new object with specifications relating to walking directions. * * @since 4.8.0 */ @AutoValue.Builder public abstract static class Builder { /** * Walking speed in meters per second. Must be between 0.14 and 6.94 meters per second. * Defaults to 1.42 meters per second * * @param walkingSpeed in meters per second * @return this builder * @since 4.8.0 */ public abstract Builder walkingSpeed( @Nullable @FloatRange(from = 0.14, to = 6.94) Double walkingSpeed); /** * A bias which determines whether the route should prefer or avoid the use of roads or paths * that are set aside for pedestrian-only use (walkways). The allowed range of values is from * -1 to 1, where -1 indicates indicates preference to avoid walkways, 1 indicates preference * to favor walkways, and 0 indicates no preference (the default). * * @param walkwayBias bias to prefer or avoid walkways * @return this builder * @since 4.8.0 */ public abstract Builder walkwayBias( @Nullable @FloatRange(from = -1, to = 1) Double walkwayBias); /** * A bias which determines whether the route should prefer or avoid the use of alleys. The * allowed range of values is from -1 to 1, where -1 indicates indicates preference to avoid * alleys, 1 indicates preference to favor alleys, and 0 indicates no preference (the default). * * @param alleyBias bias to prefer or avoid alleys * @return this builder * @since 4.8.0 */ public abstract Builder alleyBias( @Nullable @FloatRange(from = -1, to = 1) Double alleyBias); /** * Builds a WalkingOptions object with specified configurations. * * @return WalkingOptions object * @since 4.8.0 */ public abstract WalkingOptions build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/WalkingOptionsAdapterFactory.java
package com.nbmap.api.directions.v5; import com.google.gson.TypeAdapterFactory; import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory; /** * Required so that AutoValue can generate specific type adapters when needed inside the direction * packages. * * @since 4.8.0 */ @GsonTypeAdapterFactory public abstract class WalkingOptionsAdapterFactory implements TypeAdapterFactory { /** * Create a new instance of this WalkingOptions type adapter factory. This is passed into the Gson * Builder. * * @return a new GSON TypeAdapterFactory * @since 4.8.0 */ public static TypeAdapterFactory create() { return new AutoValueGson_WalkingOptionsAdapterFactory(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/package-info.java
/** * Contains classes for accessing the Nbmap Directions API. * * @since 1.0.0 */ package com.nbmap.api.directions.v5;
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/Admin.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; /** * An objects describing the administrative boundaries the route leg travels through. */ @AutoValue public abstract class Admin extends DirectionsJsonObject { /** * Contains the 2 character ISO 3166-1 alpha-2 code that applies to a country boundary. * Example: `"US"`. */ @Nullable @SerializedName("iso_3166_1") public abstract String countryCode(); /** * Contains the 3 character ISO 3166-1 alpha-3 code that applies to a country boundary. * Example: `"USA"`. */ @Nullable @SerializedName("iso_3166_1_alpha3") public abstract String countryCodeAlpha3(); /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_Admin.Builder(); } /** * Convert the current {@link Admin} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link Admin}. * * @return a {@link Builder} with the same values set to match the ones defined in this {@link * Admin} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<Admin> typeAdapter(Gson gson) { return new AutoValue_Admin.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Incident * @return a new instance of this class defined by the values passed in the method */ public static Admin fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, Admin.class); } /** * This builder can be used to set the values describing the {@link Admin}. */ @AutoValue.Builder public abstract static class Builder { /** * The 2 character ISO 3166-1 alpha-2 code that applies to a country boundary. * Example: `"US"`. * * @param countryCode 2 character ISO 3166-1 alpha-2 code */ public abstract Builder countryCode(@Nullable String countryCode); /** * The 3 character ISO 3166-1 alpha-3 code that applies to a country boundary. * Example: `"USA"`. * * @param countryCodeAlpha3 3 character ISO 3166-1 alpha-3 code */ public abstract Builder countryCodeAlpha3(@Nullable String countryCodeAlpha3); /** * Build a new {@link Admin} object. * * @return a new {@link Admin} using the provided values in this builder */ public abstract Admin build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/BannerComponents.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringDef; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** * A part of the {@link BannerText} which includes a snippet of the full banner text instruction. In * cases where data is available, an image url will be provided to visually include a road shield. * To receive this information, your request must have * <tt>NbmapDirections.Builder#bannerInstructions()</tt> set to true. * * @since 3.0.0 */ @AutoValue public abstract class BannerComponents extends DirectionsJsonObject implements Comparable<BannerComponents> { /** * Default. Indicates the text is part of the instructions and no other type. * * @since 3.0.0 */ public static final String TEXT = "text"; /** * This is text that can be replaced by an imageBaseURL icon. * * @since 3.0.0 */ public static final String ICON = "icon"; /** * This is text that can be dropped, and should be dropped if you are rendering icons. * * @since 3.0.0 */ public static final String DELIMITER = "delimiter"; /** * Indicates the exit number for the maneuver. * * @since 3.0.0 */ public static final String EXIT_NUMBER = "exit-number"; /** * Provides the the word for exit in the local language. * * @since 3.0.0 */ public static final String EXIT = "exit"; /** * Indicates which lanes can be used to complete the maneuver. * * @since 3.0.0 */ public static final String LANE = "lane"; /** * This view gives guidance through junctions and is used to complete maneuvers. */ public static final String GUIDANCE_VIEW = "guidance-view"; /** * This view gives guidance through signboards and is used to complete maneuvers. */ public static final String SIGNBOARD = "signboard"; /** * This view gives guidance through junctions and is used to complete maneuvers. */ public static final String JCT = "jct"; /** * Banner component types. * https://docs.nbmap.com/api/navigation/#banner-instruction-object * * @since 3.0.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { TEXT, ICON, DELIMITER, EXIT_NUMBER, EXIT, LANE, GUIDANCE_VIEW }) public @interface BannerComponentsType { } /** * Banner component types. * https://docs.nbmap.com/api/navigation/#banner-instruction-object * */ @Retention(RetentionPolicy.CLASS) @StringDef( { JCT, SIGNBOARD }) public @interface BannerComponentsSubType { } /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_BannerComponents.Builder(); } /** * A snippet of the full {@link BannerText#text()} which can be used for visually altering parts * of the full string. * * @return a single snippet of the full text instruction * @since 3.0.0 */ @NonNull public abstract String text(); /** * String giving you more context about the component which may help in visual markup/display * choices. If the type of the components is unknown it should be treated as text. * <p> * Possible values: * <ul> * <li><strong>text (default)</strong>: indicates the text is part of * the instructions and no other type</li> * <li><strong>icon</strong>: this is text that can be replaced by an icon, see imageBaseURL</li> * <li><strong>delimiter</strong>: this is text that can be dropped and * should be dropped if you are rendering icons</li> * <li><strong>exit-number</strong>: the exit number for the maneuver</li> * <li><strong>exit</strong>: the word for exit in the local language</li> * </ul> * * @return String type from above list * @since 3.0.0 */ @NonNull @BannerComponentsType public abstract String type(); /** * String giving you more context about {@link BannerComponentsType} which * may help in visual markup/display choices. * <p> * Possible values: * <ul> * <li><strong>jct</strong>: indicates a junction guidance view.</li> * <li><strong>signboard</strong>: indicates a signboard guidance view.</li> * </ul> * * @return String type from above list */ @Nullable @BannerComponentsType public abstract String subType(); /** * The abbreviated form of text. * <p> * If this is present, there will also be an abbr_priority value. * * @return abbreviated form of {@link BannerComponents#text()}. * @since 3.0.0 */ @Nullable @SerializedName("abbr") public abstract String abbreviation(); /** * An integer indicating the order in which the abbreviation abbr should be used in * place of text. The highest priority is 0 and a higher integer value indicates a lower * priority. There are no gaps in integer values. * <p> * Multiple components can have the same abbreviationPriority and when this happens all * components with the same abbr_priority should be abbreviated at the same time. * Finding no larger values of abbreviationPriority indicates that the string is * fully abbreviated. * * @return Integer indicating the order of the abbreviation * @since 3.0.0 */ @Nullable @SerializedName("abbr_priority") public abstract Integer abbreviationPriority(); /** * In some cases when the {@link LegStep} is a highway or major roadway, there might be a shield * icon that's included to better identify to your user to roadway. Note that this doesn't * return the image itself but rather the url which can be used to download the file. * * @return the url which can be used to download the shield icon if one is available * @since 3.0.0 */ @Nullable @SerializedName("imageBaseURL") public abstract String imageBaseUrl(); /** * In some cases when the {@link StepManeuver} will be difficult to navigate, an image * can describe how to proceed. The domain name for this image is a Junction View. * Unlike the imageBaseUrl, this image url does not include image density encodings. * * @return the url which can be used to download the image. * @since 5.0.0 */ @Nullable @SerializedName("imageURL") public abstract String imageUrl(); /** * A List of directions indicating which way you can go from a lane * (left, right, or straight). If the value is ['left', 'straight'], * the driver can go straight or left from that lane. * Present if this is a lane component. * * @return List of allowed directions from that lane. * @since 3.2.0 */ @Nullable public abstract List<String> directions(); /** * A boolean telling you if that lane can be used to complete the upcoming maneuver. * If multiple lanes are active, then they can all be used to complete the upcoming maneuver. * Present if this is a lane component. * * @return List of allowed directions from that lane. * @since 3.2.0 */ @Nullable public abstract Boolean active(); /** * Convert the current {@link BannerComponents} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link BannerComponents}. * * @return a {@link BannerComponents.Builder} with the same values set to match the ones defined * in this {@link BannerComponents} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<BannerComponents> typeAdapter(Gson gson) { return new AutoValue_BannerComponents.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a BannerComponents * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static BannerComponents fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, BannerComponents.class); } /** * Allows ability to sort/compare by abbreviation priority. This is null-safe for values of * abbreviationPriority, and treats BannerComponents with a null abreviationPriority as having an * abbreviationPriority of infinity. This method returns a negative integer, zero, or a positive * integer as this object is less than, equal to, or greater than the specified object. * * @param bannerComponents to compare to * @return the compareTo int value * @since 3.0.0 */ @Override public int compareTo(BannerComponents bannerComponents) { Integer ab1 = this.abbreviationPriority(); Integer ab2 = bannerComponents.abbreviationPriority(); if (ab1 == null && ab2 == null) { return 0; } else if (ab1 == null) { return 1; } else if (ab2 == null) { return -1; } else { return ab1.compareTo(ab2); } } /** * This builder can be used to set the values describing the {@link BannerComponents}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * A snippet of the full {@link BannerText#text()} which can be used for visually altering parts * of the full string. * * @param text a single snippet of the full text instruction * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder text(@NonNull String text); /** * String giving you more context about the component which may help in visual markup/display * choices. If the type of the components is unknown it should be treated as text. * <p> * Possible values: * <ul> * <li><strong>text (default)</strong>: indicates the text is part of the instructions * and no other type</li> * <li><strong>icon</strong>: this is text that can be replaced by an icon, * see imageBaseURL</li> * <li><strong>delimiter</strong>: this is text that can be dropped and should be dropped * if you are rendering icons</li> * <li><strong>exit-number</strong>: the exit number for the maneuver</li> * <li><strong>exit</strong>: the word for exit in the local language</li> * </ul> * * @param type String type from above list * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder type(@NonNull @BannerComponentsType String type); /** * String giving you more context about {@link BannerComponentsType} * which may help in visual markup/display choices. * <p> * Possible values: * <ul> * <li><strong>jct</strong>: indicates a junction guidance view.</li> * <li><strong>signboard</strong>: indicates a signboard guidance view.</li> * </ul> * * @param subType String subType from above list * @return String type from above list */ @NonNull @BannerComponentsType public abstract Builder subType(@Nullable @BannerComponentsSubType String subType); /** * The abbreviated form of text. * * @param abbreviation for the given text of this component * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder abbreviation(@Nullable String abbreviation); /** * An integer indicating the order in which the abbreviation abbr should be used in * place of text. The highest priority is 0 and a higher integer value indicates a lower * priority. There are no gaps in integer values. * <p> * Multiple components can have the same abbreviationPriority and when this happens all * components with the same abbr_priority should be abbreviated at the same time. * Finding no larger values of abbreviationPriority indicates that the string is * fully abbreviated. * * @param abbreviationPriority Integer indicating the order of the abbreviation * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder abbreviationPriority(@Nullable Integer abbreviationPriority); /** * In some cases when the {@link LegStep} is a highway or major roadway, there might be a shield * icon that's included to better identify to your user to roadway. Note that this doesn't * return the image itself but rather the url which can be used to download the file. * * @param imageBaseUrl the url which can be used to download the shield icon if one is avaliable * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder imageBaseUrl(@Nullable String imageBaseUrl); /** * In some cases when the {@link StepManeuver} will be difficult to navigate, an image * can describe how to proceed. The domain name for this image is a Junction View. * Unlike the imageBaseUrl, this image url does not include image density encodings. * * @param imageUrl the url which can be used to download the image * @return this builder for chaining options together * @since 5.0.0 */ public abstract Builder imageUrl(@Nullable String imageUrl); /** * A List of directions indicating which way you can go from a lane * (left, right, or straight). If the value is ['left', 'straight'], * the driver can go straight or left from that lane. * Present if this is a lane component. * * @param directions List of allowed directions from that lane * @return this builder for chaining options together * @since 3.2.0 */ public abstract Builder directions(List<String> directions); /** * A boolean telling you if that lane can be used to complete the upcoming maneuver. * If multiple lanes are active, then they can all be used to complete the upcoming maneuver. * Present if this is a lane component. * * @param activeState true, if the lane could be used for upcoming maneuver, false - otherwise * @return this builder for chaining options together * @since 3.2.0 */ public abstract Builder active(Boolean activeState); /** * Build a new {@link BannerComponents} object. * * @return a new {@link BannerComponents} using the provided values in this builder * @since 3.0.0 */ public abstract BannerComponents build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/BannerInstructions.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; /** * Visual instruction information related to a particular {@link LegStep} useful for making UI * elements inside your application such as banners. To receive this information, your request must * <tt>NbmapDirections.Builder#bannerInstructions()</tt> have set to true. * * @since 3.0.0 */ @AutoValue public abstract class BannerInstructions extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_BannerInstructions.Builder(); } /** * Distance in meters from the beginning of the step at which the visual instruction should be * visible. * * @return double value representing the length from the steps first point to where the banner * instruction should be displayed * @since 3.0.0 */ public abstract double distanceAlongGeometry(); /** * A plain text representation stored inside a {@link BannerText} object. * * @return a {@link BannerText} object which includes text for visually displaying current step * information to the user * @since 3.0.0 */ @NonNull public abstract BannerText primary(); /** * Ancillary visual information about the {@link LegStep}. * * @return {@link BannerText} representing the secondary visual information * @since 3.0.0 */ @Nullable public abstract BannerText secondary(); /** * Additional information that is included if we feel the driver needs a heads up about something. * Can include information about the next maneuver (the one after the upcoming one), * if the step is short - can be null, or can be lane information. * If we have lane information, that trumps information about the next maneuver. * * @return {@link BannerText} representing the sub visual information * @since 3.2.0 */ @Nullable public abstract BannerText sub(); /** * Optional image to display for an upcoming maneuver. Used to provide a visual * for complex junctions and maneuver. If the step is short the image should be displayed * for the duration of the step, otherwise it is shown as you approach the maneuver. * * @return {@link BannerView} representing the secondary visual information * @since 5.0.0 */ @Nullable public abstract BannerView view(); /** * Convert the current {@link BannerInstructions} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link BannerInstructions}. * * @return a {@link BannerInstructions.Builder} with the same values set to match the ones defined * in this {@link BannerInstructions} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<BannerInstructions> typeAdapter(Gson gson) { return new AutoValue_BannerInstructions.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a BannerInstructions * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static BannerInstructions fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, BannerInstructions.class); } /** * This builder can be used to set the values describing the {@link BannerInstructions}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Distance in meters from the beginning of the step at which the visual instruction should be * visible. * * @param distanceAlongGeometry double value representing the length from the steps first point * to where the banner instruction should be displayed * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder distanceAlongGeometry(double distanceAlongGeometry); /** * Main visual information about the {@link LegStep}. * * @param primary {@link BannerText} representing the primary visual information * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder primary(@NonNull BannerText primary); /** * Ancillary visual information about the {@link LegStep}. * * @param secondary {@link BannerText} representing the secondary visual information * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder secondary(@Nullable BannerText secondary); /** * Additional information that is included * if we feel the driver needs a heads up about something. * Can include information about the next maneuver (the one after the upcoming one), * if the step is short - can be null, or can be lane information. * If we have lane information, that trumps information about the next maneuver. * * @param sub {@link BannerText} representing the sub visual information * @return {@link BannerText} representing the sub visual information * @since 3.2.0 */ public abstract Builder sub(@Nullable BannerText sub); /** * Optional image to display for an upcoming maneuver. Used to provide a visual * for complex junctions and maneuver. If the step is short the image should be displayed * for the duration of the step, otherwise it is shown as you approach the maneuver. * * @param view {@link BannerView} representing the sub visual information * @return this builder for chaining options together * @since 5.0.0 */ public abstract Builder view(@Nullable BannerView view); /** * Build a new {@link BannerInstructions} object. * * @return a new {@link BannerInstructions} using the provided values in this builder * @since 3.0.0 */ public abstract BannerInstructions build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/BannerText.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.util.List; /** * Includes both plain text information that can be visualized inside your navigation application * along with the text string broken down into {@link BannerComponents} which may or may not * include a image url. To receive this information, your request must have * <tt>NbmapDirections.Builder#bannerInstructions()</tt> set to true. * * @since 3.0.0 */ @AutoValue public abstract class BannerText extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_BannerText.Builder(); } /** * Plain text with all the {@link BannerComponents} text combined. * * @return plain text with all the {@link BannerComponents} text items combined * @since 3.0.0 */ @NonNull public abstract String text(); /** * A part or element of the {@link BannerInstructions}. * * @return a {@link BannerComponents} specific to a {@link LegStep} * @since 3.0.0 */ @Nullable public abstract List<BannerComponents> components(); /** * This indicates the type of maneuver. * * @return String with type of maneuver * @see StepManeuver.StepManeuverType * @since 3.0.0 */ @Nullable @StepManeuver.StepManeuverType public abstract String type(); /** * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the * change in direction accomplished through the turn. If the type is of depart/arrive, the * modifier indicates the position of waypoint from the current direction of travel. * * @return String with modifier * @since 3.0.0 */ @Nullable @ManeuverModifier.Type public abstract String modifier(); /** * The degrees at which you will be exiting a roundabout, assuming `180` indicates * going straight through the roundabout. * * @return at which you will be exiting a roundabout * @since 3.0.0 */ @Nullable public abstract Double degrees(); /** * A string representing which side the of the street people drive on * in that location. Can be 'left' or 'right'. * * @return String either `left` or `right` * @since 3.0.0 */ @Nullable @SerializedName("driving_side") public abstract String drivingSide(); /** * Convert the current {@link BannerText} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link BannerText}. * * @return a {@link BannerText.Builder} with the same values set to match the ones defined * in this {@link BannerText} * @since 3.1.0 */ public abstract BannerText.Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<BannerText> typeAdapter(Gson gson) { return new AutoValue_BannerText.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a BannerText * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static BannerText fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, BannerText.class); } /** * This builder can be used to set the values describing the {@link BannerText}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Plain text with all the {@link BannerComponents} text combined. * * @param text plain text with all the {@link BannerComponents} text items combined * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder text(@NonNull String text); /** * A part or element of the {@link BannerInstructions}. * * @param components a {@link BannerComponents} specific to a {@link LegStep} * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder components(List<BannerComponents> components); /** * This indicates the type of maneuver. See {@link BannerText#type()} for a full list of * options. * * @param type String with type of maneuver * @return this builder for chaining options together * @see StepManeuver.StepManeuverType * @since 3.0.0 */ public abstract Builder type(@Nullable @StepManeuver.StepManeuverType String type); /** * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the * change in direction accomplished through the turn. If the type is of depart/arrive, the * modifier indicates the position of waypoint from the current direction of travel. * * @param modifier String with modifier * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder modifier(@Nullable String modifier); /** * The degrees at which you will be exiting a roundabout, assuming `180` indicates * going straight through the roundabout. * * @param degrees at which you will be exiting a roundabout * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder degrees(Double degrees); /** * A string representing which side the of the street people drive on in * that location. Can be 'left' or 'right'. * * @param drivingSide either `left` or `right` * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder drivingSide(@Nullable String drivingSide); /** * Build a new {@link BannerText} object. * * @return a new {@link BannerText} using the provided values in this builder * @since 3.0.0 */ public abstract BannerText build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/BannerView.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.util.List; /** * Includes both plain text information that can be visualized inside your navigation application * along with the text string broken down into {@link BannerComponents} which may or may not * include a image url. To receive this information, your request must have * <tt>NbmapDirections.Builder#bannerInstructions()</tt> set to true. * * @since 5.0.0 */ @AutoValue public abstract class BannerView extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 5.0.0 */ public static Builder builder() { return new AutoValue_BannerView.Builder(); } /** * Plain text with all the {@link BannerComponents} text combined. * * @return plain text with all the {@link BannerComponents} text items combined * @since 5.0.0 */ @NonNull public abstract String text(); /** * A part or element of the {@link BannerInstructions}. * * @return a {@link BannerComponents} specific to a {@link LegStep} * @since 5.0.0 */ @Nullable public abstract List<BannerComponents> components(); /** * This indicates the type of maneuver. * * @return String with type of maneuver * @see StepManeuver.StepManeuverType * @since 5.0.0 */ @Nullable @StepManeuver.StepManeuverType public abstract String type(); /** * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the * change in direction accomplished through the turn. If the type is of depart/arrive, the * modifier indicates the position of waypoint from the current direction of travel. * * @return String with modifier * @since 5.0.0 */ @Nullable @ManeuverModifier.Type public abstract String modifier(); /** * Convert the current {@link BannerView} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link BannerView}. * * @return a {@link BannerView.Builder} with the same values set to match the ones defined * in this {@link BannerView} * @since 5.0.0 */ public abstract BannerView.Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 5.0.0 */ public static TypeAdapter<BannerView> typeAdapter(Gson gson) { return new AutoValue_BannerView.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a BannerText * @return a new instance of this class defined by the values passed inside this static factory * method * @since 5.0.0 */ public static BannerView fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, BannerView.class); } /** * This builder can be used to set the values describing the {@link BannerView}. * * @since 5.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Plain text with all the {@link BannerComponents} text combined. * * @param text plain text with all the {@link BannerComponents} text items combined * @return this builder for chaining options together * @since 5.0.0 */ public abstract Builder text(@NonNull String text); /** * A part or element of the {@link BannerInstructions}. * * @param components a {@link BannerComponents} specific to a {@link LegStep} * @return this builder for chaining options together * @since 5.0.0 */ public abstract Builder components(List<BannerComponents> components); /** * This indicates the type of maneuver. See {@link BannerView#type()} for a full list of * options. * * @param type String with type of maneuver * @return this builder for chaining options together * @see StepManeuver.StepManeuverType * @since 5.0.0 */ public abstract Builder type(@Nullable @StepManeuver.StepManeuverType String type); /** * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the * change in direction accomplished through the turn. If the type is of depart/arrive, the * modifier indicates the position of waypoint from the current direction of travel. * * @param modifier String with modifier * @return this builder for chaining options together * @since 5.0.0 */ public abstract Builder modifier(@Nullable String modifier); /** * Build a new {@link BannerView} object. * * @return a new {@link BannerView} using the provided values in this builder * @since 5.0.0 */ public abstract BannerView build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/Closure.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; /** * An object indicating the geometry indexes defining a road closure. */ @AutoValue public abstract class Closure extends DirectionsJsonObject { /** * Closure's geometry index start point. */ @Nullable @SerializedName("geometry_index_start") public abstract Integer geometryIndexStart(); /** * Closure's geometry index end point. */ @Nullable @SerializedName("geometry_index_end") public abstract Integer geometryIndexEnd(); /** * Create a new instance of this class by using the {@link Closure.Builder} class. * * @return this classes {@link Closure.Builder} for creating a new instance */ public static Closure.Builder builder() { return new AutoValue_Closure.Builder(); } /** * Convert the current {@link Closure} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link Closure}. * * @return a {@link Closure.Builder} with the same values set to match the ones * defined in this {@link Closure} */ public abstract Closure.Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<Closure> typeAdapter(Gson gson) { return new AutoValue_Closure.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Incident * @return a new instance of this class defined by the values passed in the method */ public static Closure fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, Closure.class); } /** * This builder can be used to set the values describing the {@link Closure}. */ @AutoValue.Builder public abstract static class Builder { /** * Closure's geometry index start point. * * @param geometryIndexStart start index */ public abstract Builder geometryIndexStart(@Nullable Integer geometryIndexStart); /** * Closure's geometry index end point. * * @param geometryIndexEnd end index */ public abstract Builder geometryIndexEnd(@Nullable Integer geometryIndexEnd); /** * Build a new {@link Closure} object. * * @return a new {@link Closure} using the provided values in this builder */ public abstract Closure build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/Congestion.java
package com.nbmap.api.directions.v5.models; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; /** * Quantitative descriptor of congestion. */ @AutoValue public abstract class Congestion extends DirectionsJsonObject { /** * Quantitative descriptor of congestion. 0 to 100. */ public abstract int value(); /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_Congestion.Builder(); } /** * Convert the current {@link Congestion} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link Congestion}. * * @return a {@link Builder} with the same values set to match the ones defined in this * {@link Congestion} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<Congestion> typeAdapter(Gson gson) { return new AutoValue_Congestion.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Congestion * @return a new instance of this class defined by the values passed in the method */ public static Congestion fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, Congestion.class); } /** * This builder can be used to set the values describing the {@link Congestion}. */ @AutoValue.Builder public abstract static class Builder { /** * Quantitative descriptor of congestion. 0 to 100. * @param value 0 to 100 */ public abstract Builder value(int value); /** * Build a new instance of {@link Congestion}. * @return a new instance of {@link Congestion}. */ public abstract Congestion build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/DirectionsError.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import java.io.Serializable; /** * If an InvalidInput error is thrown, this class can be used to get both the code and the message * which holds an explanation of the invalid input. * * @since 3.0.0 */ @AutoValue public abstract class DirectionsError implements Serializable { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_DirectionsError.Builder(); } /** * String indicating the state of the response. This is a separate code than the HTTP status code. * On normal valid responses, the value will be Ok. The possible responses are listed below: * <ul> * <li><strong>Ok</strong>:200 Normal success case</li> * <li><strong>NoRoute</strong>: 200 There was no route found for the given coordinates. Check * for impossible routes (e.g. routes over oceans without ferry connections).</li> * <li><strong>NoSegment</strong>: 200 No road segment could be matched for coordinates. Check for * coordinates too far away from a road.</li> * <li><strong>ProfileNotFound</strong>: 404 Use a valid profile as described above</li> * <li><strong>InvalidInput</strong>: 422</li> * </ul> * * @return a string with one of the given values described in the list above * @since 3.0.0 */ @Nullable public abstract String code(); /** * Provides a short message with the explanation of the invalid input. * * @return a string containing the message API Directions response * @since 3.0.0 */ @Nullable public abstract String message(); /** * Convert the current {@link DirectionsError} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link DirectionsError}. * * @return a {@link DirectionsError.Builder} with the same values set to match the ones defined * in this {@link DirectionsError} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<DirectionsError> typeAdapter(Gson gson) { return new AutoValue_DirectionsError.GsonTypeAdapter(gson); } /** * This builder can be used to set the values describing the {@link DirectionsError}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * String indicating the state of the response. This is a separate code than the HTTP status * code. On normal valid responses, the value will be Ok. The possible responses are listed * below: * <ul> * <li><strong>Ok</strong>:200 Normal success case</li> * <li><strong>NoRoute</strong>: 200 There was no route found for the given coordinates. Check * for impossible routes (e.g. routes over oceans without ferry connections).</li> * <li><strong>NoSegment</strong>: 200 No road segment could be matched for coordinates. Check * for coordinates too far away from a road.</li> * <li><strong>ProfileNotFound</strong>: 404 Use a valid profile as described above</li> * <li><strong>InvalidInput</strong>: 422</li> * </ul> * * @param code a string with one of the given values described in the list above * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder code(String code); /** * Provides a short message with the explanation of the invalid input. * * @param message a string containing the message API Directions response * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder message(String message); /** * Build a new {@link DirectionsError} object. * * @return a new {@link DirectionsError} using the provided values in this builder * @since 3.0.0 */ public abstract DirectionsError build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/DirectionsJsonObject.java
package com.nbmap.api.directions.v5.models; import com.google.gson.GsonBuilder; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.WalkingOptionsAdapterFactory; import com.nbmap.geojson.Point; import com.nbmap.geojson.PointAsCoordinatesTypeAdapter; import java.io.Serializable; /** * Provides a base class for Directions model classes. * * @since 3.4.0 */ public class DirectionsJsonObject implements Serializable { /** * This takes the currently defined values found inside this instance and converts it to a json * string. * * @return a JSON string which represents this DirectionsJsonObject * @since 3.4.0 */ public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter()); gson.registerTypeAdapterFactory(WalkingOptionsAdapterFactory.create()); return gson.create().toJson(this); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/DirectionsResponse.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.geojson.Point; import com.nbmap.geojson.PointAsCoordinatesTypeAdapter; import java.util.List; /** * This is the root Nbmap Directions API response. Inside this class are several nested classes * chained together to make up a similar structure to the original APIs JSON response. * * @see <a href="https://www.nbmap.com/api-documentation/navigation/#directions-response-object">Direction * Response Object</a> * @since 1.0.0 */ @AutoValue public abstract class DirectionsResponse extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ @NonNull public static Builder builder() { return new AutoValue_DirectionsResponse.Builder(); } /** * String indicating the state of the response. This is a separate code than the HTTP status code. * On normal valid responses, the value will be Ok. The possible responses are listed below: * <ul> * <li><strong>Ok</strong>:200 Normal success case</li> * <li><strong>NoRoute</strong>: 200 There was no route found for the given coordinates. Check * for impossible routes (e.g. routes over oceans without ferry connections).</li> * <li><strong>NoSegment</strong>: 200 No road segment could be matched for coordinates. Check for * coordinates too far away from a road.</li> * <li><strong>ProfileNotFound</strong>: 404 Use a valid profile as described above</li> * <li><strong>InvalidInput</strong>: 422</li> * </ul> * * @return a string with one of the given values described in the list above * @since 1.0.0 */ @NonNull public abstract String code(); /** * Optionally shows up in a directions response if an error or something unexpected occurred. * * @return a string containing the message API Directions response with if an error occurred * @since 3.0.0 */ @Nullable public abstract String message(); /** * List of {@link DirectionsWaypoint} objects. Each {@code waypoint} is an input coordinate * snapped to the road and path network. The {@code waypoint} appear in the list in the order of * the input coordinates. * * @return list of {@link DirectionsWaypoint} objects ordered from start of route till the end * @since 1.0.0 */ @Nullable public abstract List<DirectionsWaypoint> waypoints(); /** * List containing all the different route options. It's ordered by descending recommendation * rank. In other words, object 0 in the List is the highest recommended route. if you don't * setAlternatives to true (default is false) in your builder this should always be a List of * size 1. At most this will return 2 {@link DirectionsRoute} objects. * * @return list of {@link DirectionsRoute} objects * @since 1.0.0 */ @NonNull public abstract List<DirectionsRoute> routes(); /** * A universally unique identifier (UUID) for identifying and executing a similar specific route * in the future. * * @return a String representing the UUID given by the directions request * @since 3.0.0 */ @Nullable public abstract String uuid(); /** * Convert the current {@link DirectionsResponse} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link DirectionsResponse}. * * @return a {@link DirectionsResponse.Builder} with the same values set to match the ones defined * in this {@link DirectionsResponse} * @since 3.0.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<DirectionsResponse> typeAdapter(Gson gson) { return new AutoValue_DirectionsResponse.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a GeoJson Directions Response * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static DirectionsResponse fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter()); return gson.create().fromJson(json, DirectionsResponse.class); } /** * This builder can be used to set the values describing the {@link DirectionsResponse}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * String indicating the state of the response. This is a separate code than the HTTP status * code. On normal valid responses, the value will be Ok. For a full list of possible responses, * see {@link DirectionsResponse#code()}. * * @param code a string with one of the given values described in the list above * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder code(@NonNull String code); /** * Optionally shows up in a directions response if an error or something unexpected occurred. * * @param message a string containing the message API Directions response with if an error * occurred * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder message(@Nullable String message); /** * List of {@link DirectionsWaypoint} objects. Each {@code waypoint} is an input coordinate * snapped to the road and path network. The {@code waypoint} appear in the list in the order of * the input coordinates. * * @param waypoints list of {@link DirectionsWaypoint} objects ordered from start of route till * the end * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder waypoints(@Nullable List<DirectionsWaypoint> waypoints); /** * List containing all the different route options. It's ordered by descending recommendation * rank. In other words, object 0 in the List is the highest recommended route. if you don't * setAlternatives to true (default is false) in your builder this should always be a List of * size 1. At most this will return 2 {@link DirectionsRoute} objects. * * @param routes list of {@link DirectionsRoute} objects * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder routes(@NonNull List<DirectionsRoute> routes); abstract List<DirectionsRoute> routes(); /** * A universally unique identifier (UUID) for identifying and executing a similar specific route * in the future. * * @param uuid a String representing the UUID given by the directions request * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder uuid(@Nullable String uuid); abstract DirectionsResponse autoBuild(); /** * Build a new {@link DirectionsResponse} object. * * @return a new {@link DirectionsResponse} using the provided values in this builder * @since 3.0.0 */ public DirectionsResponse build() { for (int i = 0; i < routes().size(); i++) { routes().set(i, routes().get(i).toBuilder().routeIndex(String.valueOf(i)).build()); } return autoBuild(); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/DirectionsRoute.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.geojson.Point; import com.nbmap.geojson.PointAsCoordinatesTypeAdapter; import java.util.List; /** * Detailed information about an individual route such as the duration, distance and geometry. * * @since 1.0.0 */ @AutoValue public abstract class DirectionsRoute extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_DirectionsRoute.Builder(); } /** * The index of this route in the original network response. * * @return string of an int value representing the index * @since 4.4.0 */ @Nullable public abstract String routeIndex(); /** * The distance traveled from origin to destination. * * @return a double number with unit meters * @since 1.0.0 */ @NonNull public abstract Double distance(); /** * The estimated travel time from origin to destination. * * @return a double number with unit seconds * @since 1.0.0 */ @NonNull public abstract Double duration(); /** * The typical travel time from this route's origin to destination. There's a delay along * this route if you subtract this durationTypical() value from the route's duration() * value and the resulting difference is greater than 0. The delay is because of any * number of real-world situations (road repair, traffic jam, etc). * * @return a double number with unit seconds * @since 5.5.0 */ @Nullable @SerializedName("duration_typical") public abstract Double durationTypical(); /** * Gives the geometry of the route. Commonly used to draw the route on the map view. * * @return an encoded polyline string * @since 1.0.0 */ @Nullable public abstract String geometry(); /** * The calculated weight of the route. * * @return the weight value provided from the API as a {@code double} value * @since 2.1.0 */ @Nullable public abstract Double weight(); /** * The name of the weight profile used while calculating during extraction phase. The default is * {@code routability} which is duration based, with additional penalties for less desirable * maneuvers. * * @return a String representing the weight profile used while calculating the route * @since 2.1.0 */ @Nullable @SerializedName("weight_name") public abstract String weightName(); /** * A Leg is a route between only two waypoints. * * @return list of {@link RouteLeg} objects * @since 1.0.0 */ @Nullable public abstract List<RouteLeg> legs(); /** * Holds onto the parameter information used when making the directions request. Useful for * re-requesting a directions route using the same information previously used. * * @return a {@link RouteOptions}s object which holds onto critical information from the request * that cannot be derived directly from the directions route * @since 3.0.0 */ @Nullable public abstract RouteOptions routeOptions(); /** * String of the language to be used for voice instructions. Defaults to en, and * can be any accepted instruction language. Will be <tt>null</tt> when the language provided * <tt>NbmapDirections.Builder#language()</tt> via is not compatible with API Voice. * * @return String compatible with voice instructions, null otherwise * @since 3.1.0 */ @Nullable @SerializedName("voiceLocale") public abstract String voiceLanguage(); /** * Convert the current {@link DirectionsRoute} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link DirectionsRoute}. * * @return a {@link DirectionsRoute.Builder} with the same values set to match the ones defined * in this {@link DirectionsRoute} * @since 3.0.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<DirectionsRoute> typeAdapter(Gson gson) { return new AutoValue_DirectionsRoute.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a GeoJson Directions Route * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static DirectionsRoute fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter()); return gson.create().fromJson(json, DirectionsRoute.class); } /** * This builder can be used to set the values describing the {@link DirectionsRoute}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * The distance traveled from origin to destination. * * @param distance a double number with unit meters * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder distance(@NonNull Double distance); /** * The estimated travel time from origin to destination. * * @param duration a double number with unit seconds * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder duration(@NonNull Double duration); /** * The typical travel time from this route's origin to destination. There's a delay along * this route if you subtract this durationTypical() value from the route's duration() * value and the resulting difference is greater than 0. The delay is because of any * number of real-world situations (road repair, traffic jam, etc). * * @param durationTypical a double number with unit seconds * @return this builder for chaining options together * @since 5.5.0 */ public abstract Builder durationTypical(@Nullable Double durationTypical); /** * Gives the geometry of the route. Commonly used to draw the route on the map view. * * @param geometry an encoded polyline string * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder geometry(@Nullable String geometry); /** * The calculated weight of the route. * * @param weight the weight value provided from the API as a {@code double} value * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder weight(@Nullable Double weight); /** * The name of the weight profile used while calculating during extraction phase. The default is * {@code routability} which is duration based, with additional penalties for less desirable * maneuvers. * * @param weightName a String representing the weight profile used while calculating the route * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder weightName(@Nullable String weightName); /** * A Leg is a route between only two waypoints. * * @param legs list of {@link RouteLeg} objects * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder legs(@Nullable List<RouteLeg> legs); /** * Holds onto the parameter information used when making the directions request. * * @param routeOptions a {@link RouteOptions}s object which holds onto critical information from * the request that cannot be derived directly from the directions route * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder routeOptions(@Nullable RouteOptions routeOptions); /** * String of the language to be used for voice instructions. Defaults to en, and * can be any accepted instruction language. * * @param voiceLanguage String compatible with voice instructions, null otherwise * @return this builder for chaining options together * @since 3.1.0 */ public abstract Builder voiceLanguage(@Nullable String voiceLanguage); abstract Builder routeIndex(String routeIndex); /** * Build a new {@link DirectionsRoute} object. * * @return a new {@link DirectionsRoute} using the provided values in this builder * @since 3.0.0 */ public abstract DirectionsRoute build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/DirectionsWaypoint.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.geojson.Point; /** * An input coordinate snapped to the roads network. * * @since 1.0.0 */ @AutoValue public abstract class DirectionsWaypoint extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_DirectionsWaypoint.Builder(); } /** * Provides the way name which the waypoint's coordinate is snapped to. * * @return string with the name of the way the coordinate snapped to * @since 1.0.0 */ @Nullable public abstract String name(); /** * A {@link Point} representing this waypoint location. * * @return GeoJson Point representing this waypoint location * @since 3.0.0 */ @Nullable public Point location() { return Point.fromLngLat(rawLocation()[0], rawLocation()[1]); } /** * A {@link Point} representing this waypoint location. * * @return GeoJson Point representing this waypoint location * @since 3.0.0 */ @Nullable @SerializedName("location") @SuppressWarnings("mutable") abstract double[] rawLocation(); /** * Convert the current {@link DirectionsWaypoint} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link DirectionsWaypoint}. * * @return a {@link DirectionsWaypoint.Builder} with the same values set to match the ones defined * in this {@link DirectionsWaypoint} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<DirectionsWaypoint> typeAdapter(Gson gson) { return new AutoValue_DirectionsWaypoint.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a DirectionsWaypoint * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static DirectionsWaypoint fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, DirectionsWaypoint.class); } /** * This builder can be used to set the values describing the {@link DirectionsWaypoint}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Provides the way name which the waypoint's coordinate is snapped to. * * @param name string with the name of the way the coordinate snapped to * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder name(@Nullable String name); /** * The rawLocation as a double array. Once the {@link DirectionsWaypoint} objects created, * this raw location gets converted into a {@link Point} object and is public exposed as such. * The double array should have a length of two, index 0 being the longitude and index 1 being * latitude. * * @param rawLocation a double array with a length of two, index 0 being the longitude and * index 1 being latitude. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder rawLocation(@Nullable double[] rawLocation); /** * Build a new {@link DirectionsWaypoint} object. * * @return a new {@link DirectionsWaypoint} using the provided values in this builder * @since 3.0.0 */ public abstract DirectionsWaypoint build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/Incident.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringDef; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** * Reproduces one of road incidents type ({@link IncidentType}) that might be on the way. */ @AutoValue public abstract class Incident extends DirectionsJsonObject { /** * {@link IncidentType} accident. */ public static final String INCIDENT_ACCIDENT = "accident"; /** * {@link IncidentType} congestion. */ public static final String INCIDENT_CONGESTION = "congestion"; /** * {@link IncidentType} construction. */ public static final String INCIDENT_CONSTRUCTION = "construction"; /** * {@link IncidentType} disabled vehicle. ? */ public static final String INCIDENT_DISABLED_VEHICLE = "disabled_vehicle"; /** * {@link IncidentType} lane restriction. */ public static final String INCIDENT_LANE_RESTRICTION = "lane_restriction"; /** * {@link IncidentType} mass transit. */ public static final String INCIDENT_MASS_TRANSIT = "mass_transit"; /** * {@link IncidentType} miscellaneous. */ public static final String INCIDENT_MISCELLANEOUS = "miscellaneous"; /** * {@link IncidentType} other news. */ public static final String INCIDENT_OTHER_NEWS = "other_news"; /** * {@link IncidentType} planned event. */ public static final String INCIDENT_PLANNED_EVENT = "planned_event"; /** * {@link IncidentType} road closure. */ public static final String INCIDENT_ROAD_CLOSURE = "road_closure"; /** * {@link IncidentType} road hazard. */ public static final String INCIDENT_ROAD_HAZARD = "road_hazard"; /** * {@link IncidentType} weather. */ public static final String INCIDENT_WEATHER = "weather"; /** * Incident type. */ @Retention(RetentionPolicy.CLASS) @StringDef({ INCIDENT_ACCIDENT, INCIDENT_CONGESTION, INCIDENT_CONSTRUCTION, INCIDENT_DISABLED_VEHICLE, INCIDENT_LANE_RESTRICTION, INCIDENT_MASS_TRANSIT, INCIDENT_MISCELLANEOUS, INCIDENT_OTHER_NEWS, INCIDENT_PLANNED_EVENT, INCIDENT_ROAD_CLOSURE, INCIDENT_ROAD_HAZARD, INCIDENT_WEATHER }) public @interface IncidentType { } /** * {@link ImpactType} unknown. */ public static final String IMPACT_UNKNOWN = "unknown"; /** * {@link ImpactType} critical. */ public static final String IMPACT_CRITICAL = "critical"; /** * {@link ImpactType} major. */ public static final String IMPACT_MAJOR = "major"; /** * {@link ImpactType} minor. */ public static final String IMPACT_MINOR = "minor"; /** * {@link ImpactType} low. */ public static final String IMPACT_LOW = "low"; /** * Impact type. */ @Retention(RetentionPolicy.CLASS) @StringDef({ IMPACT_UNKNOWN, IMPACT_CRITICAL, IMPACT_MAJOR, IMPACT_MINOR, IMPACT_LOW }) public @interface ImpactType { } /** * Unique identifier for incident. It might be the only one <b>non-null</b> filed which meant * that incident started on previous leg and one has an incident with the same <b>id</b>. */ @NonNull public abstract String id(); /** * One of incident types. * * @see IncidentType */ @Nullable @IncidentType public abstract String type(); /** * <b>True</b> if road is closed and no possibility to pass through there. <b>False</b> * otherwise. */ @Nullable public abstract Boolean closed(); /** * Quantitative descriptor of congestion. */ @Nullable public abstract Congestion congestion(); /** * Human-readable description of the incident suitable for displaying to the users. */ @Nullable public abstract String description(); /** * Human-readable long description of the incident suitable for displaying to the users. */ @Nullable @SerializedName("long_description") public abstract String longDescription(); /** * Severity level of incident. * * @see ImpactType */ @Nullable @ImpactType public abstract String impact(); /** * Sub-type of the incident. */ @Nullable @SerializedName("sub_type") public abstract String subType(); /** * Sub-type-specific description. */ @Nullable @SerializedName("sub_type_description") public abstract String subTypeDescription(); /** * AlertC codes. * * @see <a href="https://www.iso.org/standard/59231.html">AlertC</a> */ @Nullable @SerializedName("alertc_codes") public abstract List<Integer> alertcCodes(); /** * Incident's geometry index start point. */ @Nullable @SerializedName("geometry_index_start") public abstract Integer geometryIndexStart(); /** * Incident's geometry index end point. */ @Nullable @SerializedName("geometry_index_end") public abstract Integer geometryIndexEnd(); /** * Time the incident was created/updated in ISO8601 format. Not the same * {@link #startTime()}/{@link #endTime()}, incident can be created/updated before the incident. */ @Nullable @SerializedName("creation_time") public abstract String creationTime(); /** * Start time of the incident in ISO8601 format. */ @Nullable @SerializedName("start_time") public abstract String startTime(); /** * End time of the incident in ISO8601 format. */ @Nullable @SerializedName("end_time") public abstract String endTime(); /** * Create a new instance of this class by using the {@link Incident.Builder} class. * * @return this classes {@link Incident.Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_Incident.Builder(); } /** * Convert the current {@link Incident} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link Incident}. * * @return a {@link Builder} with the same values set to match the ones defined in this * {@link Incident} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<Incident> typeAdapter(Gson gson) { return new AutoValue_Incident.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Incident * @return a new instance of this class defined by the values passed in the method */ public static Incident fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, Incident.class); } /** * This builder can be used to set the values describing the {@link Incident}. */ @AutoValue.Builder public abstract static class Builder { /** * Unique identifier for incident. It might be the only one <b>non-null</b> filed which meant * that incident started on previous leg and one has an incident with the same <b>id</b>. * * @param id String */ public abstract Builder id(@NonNull String id); /** * One of incident types. * * @param type incident type * @see IncidentType */ public abstract Builder type(@Nullable @IncidentType String type); /** * <b>True</b> if road is closed and no possibility to pass through there. <b>False</b> * otherwise. * * @param closed is way closed */ public abstract Builder closed(@Nullable Boolean closed); /** * Quantitative descriptor of congestion. * * @param congestion congestion */ public abstract Builder congestion(@Nullable Congestion congestion); /** * Human-readable description of the incident suitable for displaying to the users. * * @param description incident description */ public abstract Builder description(@Nullable String description); /** * Human-readable long description of the incident suitable for displaying to the users. * * @param longDescription incident long description */ public abstract Builder longDescription(@Nullable String longDescription); /** * Severity level of incident. * * @param impact impact type * @see ImpactType */ public abstract Builder impact(@Nullable @ImpactType String impact); /** * Sub-type of the incident. * * @param subType syp-type */ public abstract Builder subType(@Nullable String subType); /** * Sub-type-specific description. * * @param subTypeDescription sub-type description */ public abstract Builder subTypeDescription(@Nullable String subTypeDescription); /** * AlertC codes. * * @param alertcCodes list of alert codes * @see <a href="https://www.iso.org/standard/59231.html">AlertC</a> */ public abstract Builder alertcCodes(@Nullable List<Integer> alertcCodes); /** * Incident's geometry index start point. * * @param geometryIndexStart start index */ public abstract Builder geometryIndexStart(@Nullable Integer geometryIndexStart); /** * Incident's geometry index end point. * * @param geometryIndexEnd end index */ public abstract Builder geometryIndexEnd(@Nullable Integer geometryIndexEnd); /** * Time the incident was created/updated in ISO8601 format. * * @param creationTime ISO8601 format */ public abstract Builder creationTime(@Nullable String creationTime); /** * Start time in ISO8601 format. * * @param startTime ISO8601 format */ public abstract Builder startTime(@Nullable String startTime); /** * End time in ISO8601 format. * * @param endTime ISO8601 format */ public abstract Builder endTime(@Nullable String endTime); /** * Build a new instance of {@link Incident}. * * @return a new instance of {@link Incident}. */ public abstract Incident build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/IntersectionLanes.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.util.List; /** * Object representing lanes in an intersection. * * @since 2.0.0 */ @AutoValue public abstract class IntersectionLanes extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_IntersectionLanes.Builder(); } /** * Provides a boolean value you can use to determine if the given lane is valid for the user to * complete the maneuver. * * @return Boolean value for whether this lane can be taken to complete the maneuver. For * instance, if the lane array has four objects and the first two are marked as valid, then the * driver can take either of the left lanes and stay on the route. * @since 2.0.0 */ @Nullable public abstract Boolean valid(); /** * Indicates whether this lane is a preferred lane (true) or not (false). * A preferred lane is a lane that is recommended if there are multiple lanes available. * For example, if guidance indicates that the driver must turn left at an intersection * and there are multiple left turn lanes, the left turn lane that will better prepare * the driver for the next maneuver will be marked as active. * Only available on the nbmap/driving profile. * * @return Indicates whether this lane is a preferred lane (true) or not (false). */ @Nullable public abstract Boolean active(); /** * When either valid or active is set to true, this property shows which of the lane indications * is applicable to the current route, when there is more than one. For example, if a lane allows * you to go left or straight but your current route is guiding you to the left, * then this value will be set to left. * See indications for possible values. * When both active and valid are false, this property will not be included in the response. * Only available on the nbmap/driving profile. * * @return which of the lane indications is applicable to the current route, * when there is more than one */ @Nullable @SerializedName("valid_indication") public abstract String validIndication(); /** * Array that can be made up of multiple signs such as {@code left}, {@code right}, etc. * * @return Array of signs for each turn lane. There can be multiple signs. For example, a turning * lane can have a sign with an arrow pointing left and another sign with an arrow pointing * straight. * @since 2.0.0 */ @Nullable public abstract List<String> indications(); /** * Convert the current {@link IntersectionLanes} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link IntersectionLanes}. * * @return a {@link IntersectionLanes.Builder} with the same values set to match the ones defined * in this {@link IntersectionLanes} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<IntersectionLanes> typeAdapter(Gson gson) { return new AutoValue_IntersectionLanes.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an IntersectionLanes * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static IntersectionLanes fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, IntersectionLanes.class); } /** * This builder can be used to set the values describing the {@link IntersectionLanes}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Provide a boolean value you can use to determine if the given lane is valid for the user to * complete the maneuver. * * @param valid Boolean value for whether this lane can be taken to complete the maneuver. For * instance, if the lane array has four objects and the first two are marked as * valid, then the driver can take either of the left lanes and stay on the route. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder valid(@Nullable Boolean valid); /** * Indicates whether this lane is a preferred lane (true) or not (false). * * @param active Boolean value that indicates whether this lane is a preferred lane (true) * or not (false). * @return this builder for chaining options together */ public abstract Builder active(@Nullable Boolean active); /** * Shows which of the lane indications is applicable to the current route, * when there is more than one. * * @param validIndication lane indications applicable to the current route, * when there is more than one. * @return this builder for chaining options together */ public abstract Builder validIndication(@Nullable String validIndication); /** * list that can be made up of multiple signs such as {@code left}, {@code right}, etc. * * @param indications list of signs for each turn lane. There can be multiple signs. For * example, a turning lane can have a sign with an arrow pointing left and * another sign with an arrow pointing straight. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder indications(@Nullable List<String> indications); /** * Build a new {@link IntersectionLanes} object. * * @return a new {@link IntersectionLanes} using the provided values in this builder * @since 3.0.0 */ public abstract IntersectionLanes build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/LegAnnotation.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.util.List; /** * An annotations object that contains additional details about each line segment along the route * geometry. Each entry in an annotations field corresponds to a coordinate along the route * geometry. * * @since 2.1.0 */ @AutoValue public abstract class LegAnnotation extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_LegAnnotation.Builder(); } /** * The distance, in meters, between each pair of coordinates. * * @return a list with each entry being a distance value between two of the routeLeg geometry * coordinates * @since 2.1.0 */ @Nullable public abstract List<Double> distance(); /** * The speed, in meters per second, between each pair of coordinates. * * @return a list with each entry being a speed value between two of the routeLeg geometry * coordinates * @since 2.1.0 */ @Nullable public abstract List<Double> duration(); /** * The speed, in meters per second, between each pair of coordinates. * * @return a list with each entry being a speed value between two of the routeLeg geometry * coordinates * @since 2.1.0 */ @Nullable public abstract List<Double> speed(); /** * The posted speed limit, between each pair of coordinates. * Maxspeed is only available for the `nbmap/driving` and `nbmap/driving-traffic` * profiles, other profiles will return `unknown`s only. * * @return a list with each entry being a {@link MaxSpeed} value between two of * the routeLeg geometry coordinates * @since 3.0.0 */ @Nullable public abstract List<MaxSpeed> maxspeed(); /** * The congestion between each pair of coordinates. * * @return a list of Strings with each entry being a congestion value between two of the routeLeg * geometry coordinates * @since 2.2.0 */ @Nullable public abstract List<String> congestion(); /** * Convert the current {@link LegAnnotation} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link LegAnnotation}. * * @return a {@link LegAnnotation.Builder} with the same values set to match the ones defined * in this {@link LegAnnotation} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<LegAnnotation> typeAdapter(Gson gson) { return new AutoValue_LegAnnotation.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a LegAnnotation * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static LegAnnotation fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, LegAnnotation.class); } /** * This builder can be used to set the values describing the {@link LegAnnotation}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * The distance, in meters, between each pair of coordinates. * * @param distance a list with each entry being a distance value between two of the routeLeg * geometry coordinates * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder distance(@Nullable List<Double> distance); /** * The speed, in meters per second, between each pair of coordinates. * * @param duration a list with each entry being a speed value between two of the routeLeg * geometry coordinates * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder duration(@Nullable List<Double> duration); /** * The speed, in meters per second, between each pair of coordinates. * * @param speed a list with each entry being a speed value between two of the routeLeg geometry * coordinates * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder speed(@Nullable List<Double> speed); /** * The posted speed limit, between each pair of coordinates. * Maxspeed is only available for the `nbmap/driving` and `nbmap/driving-traffic` * profiles, other profiles will return `unknown`s only. * * @param maxspeed list of speeds between each pair of coordinates * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder maxspeed(@Nullable List<MaxSpeed> maxspeed); /** * The congestion between each pair of coordinates. * * @param congestion a list of Strings with each entry being a congestion value between two of * the routeLeg geometry coordinates * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder congestion(@Nullable List<String> congestion); /** * Build a new {@link LegAnnotation} object. * * @return a new {@link LegAnnotation} using the provided values in this builder * @since 3.0.0 */ public abstract LegAnnotation build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/LegStep.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringDef; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** * Includes one {@link StepManeuver} object and travel to the following {@link LegStep}. * * @since 1.0.0 */ @AutoValue public abstract class LegStep extends DirectionsJsonObject { /** * {@link LegStep.SpeedLimitSign} accident. */ public static final String MUTCD = "mutcd"; /** * {@link LegStep.SpeedLimitSign} congestion. */ public static final String VIENNA = "vienna"; /** * Speed limit sign. */ @Retention(RetentionPolicy.CLASS) @StringDef({ MUTCD, VIENNA }) public @interface SpeedLimitSign { } /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_LegStep.Builder(); } /** * The distance traveled from the maneuver to the next {@link LegStep}. * * @return a double number with unit meters * @since 1.0.0 */ public abstract double distance(); /** * The estimated travel time from the maneuver to the next {@link LegStep}. * * @return a double number with unit seconds * @since 1.0.0 */ public abstract double duration(); /** * The typical travel time for traversing this LegStep. There's a delay along the LegStep * if you subtract this durationTypical() value from the LegStep duration() value and * the resulting difference is greater than 0. The delay is because of any number * of real-world situations (road repair, traffic jam, etc). * * @return a double number with unit seconds * @since 5.5.0 */ @Nullable @SerializedName("duration_typical") public abstract Double durationTypical(); /** * Speed limit unit as per the locale. * * @return unit of the speed limit */ @Nullable @SpeedLimit.Unit public abstract String speedLimitUnit(); /** * Speed limit sign type. * * @see LegStep.SpeedLimitSign */ @Nullable @LegStep.SpeedLimitSign public abstract String speedLimitSign(); /** * Gives the geometry of the leg step. * * @return an encoded polyline string * @since 1.0.0 */ @Nullable public abstract String geometry(); /** * String with the name of the way along which the travel proceeds. * * @return a {@code String} representing the way along which the travel proceeds * @since 1.0.0 */ @Nullable public abstract String name(); /** * Any road designations associated with the road or path leading from this step&#39;s * maneuver to the next step&#39;s maneuver. Optionally included, if data is available. * If multiple road designations are associated with the road, they are separated by semicolons. * A road designation typically consists of an alphabetic network code (identifying the road type * or numbering system), a space or hyphen, and a route number. You should not assume that * the network code is globally unique: for example, a network code of &quot;NH&quot; may appear * on a &quot;National Highway&quot; or &quot;New Hampshire&quot;. Moreover, a route number may * not even uniquely identify a road within a given network. * * @return String with reference number or code of the way along which the travel proceeds. * Optionally included, if data is available. * @since 2.0.0 */ @Nullable public abstract String ref(); /** * String with the destinations of the way along which the travel proceeds. * * @return String with the destinations of the way along which the travel proceeds. Optionally * included, if data is available * @since 2.0.0 */ @Nullable public abstract String destinations(); /** * indicates the mode of transportation in the step. * * @return String indicating the mode of transportation. * @since 1.0.0 */ @NonNull public abstract String mode(); /** * The pronunciation hint of the way name. Will be undefined if no pronunciation is hit. * * @return String with the pronunciation * @since 2.0.0 */ @Nullable public abstract String pronunciation(); /** * An optional string indicating the name of the rotary. This will only be a nonnull when the * maneuver type equals {@code rotary}. * * @return String with the rotary name * @since 2.0.0 */ @Nullable @SerializedName("rotary_name") public abstract String rotaryName(); /** * An optional string indicating the pronunciation of the name of the rotary. This will only be a * nonnull when the maneuver type equals {@code rotary}. * * @return String in IPA with the rotary name's pronunciation. * @since 2.0.0 */ @Nullable @SerializedName("rotary_pronunciation") public abstract String rotaryPronunciation(); /** * A {@link StepManeuver} object that typically represents the first coordinate making up the * {@link LegStep#geometry()}. * * @return new {@link StepManeuver} object * @since 1.0.0 */ @NonNull public abstract StepManeuver maneuver(); /** * The voice instructions object is useful for navigation sessions providing well spoken text * instructions along with the distance from the maneuver the instructions should be said. * * @return a list of voice instructions which can be triggered on this current step * @since 3.0.0 */ @Nullable public abstract List<VoiceInstructions> voiceInstructions(); /** * If in your request you set <tt>NbmapDirections.Builder#bannerInstructions()</tt> to true, * you'll receive a list of {@link BannerInstructions} which encompasses all information necessary * for creating a visual cue about a given {@link LegStep}. * * @return a list of {@link BannerInstructions}s which help display visual cues * inside your application * @since 3.0.0 */ @Nullable public abstract List<BannerInstructions> bannerInstructions(); /** * The legal driving side at the location for this step. Result will either be {@code left} or * {@code right}. * * @return a string with either a left or right value * @since 3.0.0 */ @Nullable @SerializedName("driving_side") public abstract String drivingSide(); /** * Specifies a decimal precision of edge weights, default value 1. * * @return a decimal precision double value * @since 2.1.0 */ public abstract double weight(); /** * Provides a list of all the intersections connected to the current way the user is traveling * along. * * @return list of {@link StepIntersection} representing all intersections along the step * @since 1.3.0 */ @Nullable public abstract List<StepIntersection> intersections(); /** * String with the exit numbers or names of the way. Optionally included, if data is available. * * @return a String identifying the exit number or name * @since 3.0.0 */ @Nullable public abstract String exits(); /** * Convert the current {@link LegStep} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link LegStep}. * * @return a {@link LegStep.Builder} with the same values set to match the ones defined * in this {@link LegStep} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<LegStep> typeAdapter(Gson gson) { return new AutoValue_LegStep.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a LegStep * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static LegStep fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, LegStep.class); } /** * This builder can be used to set the values describing the {@link LegStep}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * The distance traveled from the maneuver to the next {@link LegStep}. * * @param distance a double number with unit meters * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder distance(double distance); /** * The estimated travel time from the maneuver to the next {@link LegStep}. * * @param duration a double number with unit seconds * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder duration(double duration); /** * The typical travel time for traversing this LegStep. There's a delay along the LegStep * if you subtract this durationTypical() value from the LegStep duration() value and * the resulting difference is greater than 0. The delay is because of any number * of real-world situations (road repair, traffic jam, etc). * * @param durationTypical a double number with unit seconds * @return this builder for chaining options together * @since 5.5.0 */ public abstract Builder durationTypical(@Nullable Double durationTypical); /** * Speed limit unit as per the locale. * * @param speedLimitUnit speed limit unit * @return this builder for chaining options together * @see SpeedLimit.Unit */ public abstract Builder speedLimitUnit(@Nullable @SpeedLimit.Unit String speedLimitUnit); /** * Speed limit sign type. * * @param speedLimitSign speed limit sign * @return this builder for chaining options together * @see SpeedLimitSign */ public abstract Builder speedLimitSign(@Nullable @SpeedLimitSign String speedLimitSign); /** * Gives the geometry of the leg step. * * @param geometry an encoded polyline string * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder geometry(@Nullable String geometry); /** * String with the name of the way along which the travel proceeds. * * @param name a {@code String} representing the way along which the travel proceeds * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder name(@Nullable String name); /** * String with reference number or code of the way along which the travel proceeds. * * @param ref String with reference number or code of the way along which the travel proceeds. * Optionally included, if data is available * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder ref(@Nullable String ref); /** * String with the destinations of the way along which the travel proceeds. * * @param destinations String with the destinations of the way along which the travel proceeds. * Optionally included, if data is available * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder destinations(@Nullable String destinations); /** * Indicates the mode of transportation in the step. * * @param mode String indicating the mode of transportation * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder mode(@NonNull String mode); /** * The pronunciation hint of the way name. Will be undefined if no pronunciation is hit. * * @param pronunciation String with the pronunciation * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder pronunciation(@Nullable String pronunciation); /** * An optional string indicating the name of the rotary. This will only be a nonnull when the * maneuver type equals {@code rotary}. * * @param rotaryName String with the rotary name * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder rotaryName(@Nullable String rotaryName); /** * An optional string indicating the pronunciation of the name of the rotary. This will only be * a nonnull when the maneuver type equals {@code rotary}. * * @param rotaryPronunciation String in IPA with the rotary name's pronunciation. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder rotaryPronunciation(@Nullable String rotaryPronunciation); /** * A {@link StepManeuver} object that typically represents the first coordinate making up the * {@link LegStep#geometry()}. * * @param maneuver new {@link StepManeuver} object * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder maneuver(@NonNull StepManeuver maneuver); /** * The voice instructions object is useful for navigation sessions providing well spoken text * instructions along with the distance from the maneuver the instructions should be said. * * @param voiceInstructions a list of voice instructions which can be triggered on this current * step * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder voiceInstructions(@NonNull List<VoiceInstructions> voiceInstructions); /** * If in your request you set <tt>NbmapDirections.Builder#bannerInstructions()</tt> to true, * you'll receive a list of {@link BannerInstructions} which encompasses all information * necessary for creating a visual cue about a given {@link LegStep}. * * @param bannerInstructions a list of {@link BannerInstructions}s which help display visual * cues inside your application * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder bannerInstructions( @NonNull List<BannerInstructions> bannerInstructions); /** * The legal driving side at the location for this step. Result will either be {@code left} or * {@code right}. * * @param drivingSide a string with either a left or right value * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder drivingSide(@Nullable String drivingSide); /** * Specifies a decimal precision of edge weights, default value 1. * * @param weight a decimal precision double value * @return this builder for chaining options together * @since 2.1.0 */ public abstract Builder weight(double weight); /** * Provide a list of all the intersections connected to the current way the user is traveling * along. * * @param intersections list of {@link StepIntersection} representing all intersections along * the step * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder intersections(@NonNull List<StepIntersection> intersections); /** * String with the exit numbers or names of the way. Optionally included, if data is available. * * @param exits a String identifying the exit number or name * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder exits(@Nullable String exits); /** * Build a new {@link LegStep} object. * * @return a new {@link LegStep} using the provided values in this builder * @since 3.0.0 */ public abstract LegStep build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/ManeuverModifier.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.StringDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Constants for the {@link StepManeuver#modifier()}. * * @since 5.2.0 */ public final class ManeuverModifier { /** * Indicates "uturn" maneuver modifier. * * @since 5.2.0 */ public static final String UTURN = "uturn"; /** * Indicates "sharp right" maneuver modifier. * * @since 5.2.0 */ public static final String SHARP_RIGHT = "sharp right"; /** * Indicates "right" maneuver modifier. * * @since 5.2.0 */ public static final String RIGHT = "right"; /** * Indicates "slight right" maneuver modifier. * * @since 5.2.0 */ public static final String SLIGHT_RIGHT = "slight right"; /** * Indicates "straight" maneuver modifier. * * @since 5.2.0 */ public static final String STRAIGHT = "straight"; /** * Indicates "slight left" maneuver modifier. * * @since 5.2.0 */ public static final String SLIGHT_LEFT = "slight left"; /** * Indicates "left" maneuver modifier. * * @since 5.2.0 */ public static final String LEFT = "left"; /** * Indicates "sharp left" maneuver modifier. * * @since 5.2.0 */ public static final String SHARP_LEFT = "sharp left"; /** * Representation of ManeuverModifier in form of logical types. * * @since 5.2.1 */ @Retention(RetentionPolicy.CLASS) @StringDef({ ManeuverModifier.UTURN, ManeuverModifier.SHARP_RIGHT, ManeuverModifier.RIGHT, ManeuverModifier.SLIGHT_RIGHT, ManeuverModifier.STRAIGHT, ManeuverModifier.SLIGHT_LEFT, ManeuverModifier.LEFT, ManeuverModifier.SHARP_LEFT }) public @interface Type { } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/MaxSpeed.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; /** * Object representing max speeds along a route. * * @since 3.0.0 */ @AutoValue public abstract class MaxSpeed extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_MaxSpeed.Builder(); } /** * Number indicating the posted speed limit. * * @return number indicating the posted speed limit * @since 3.0.0 */ @Nullable public abstract Integer speed(); /** * String indicating the unit of speed, either as `km/h` or `mph`. * * @return String unit either as `km/h` or `mph` * @since 3.0.0 */ @Nullable @SpeedLimit.Unit public abstract String unit(); /** * Boolean is true if the speed limit is not known, otherwise null. * * @return Boolean true if speed limit is not known, otherwise null * @since 3.0.0 */ @Nullable public abstract Boolean unknown(); /** * Boolean is `true` if the speed limit is unlimited, otherwise null. * * @return Boolean true if speed limit is unlimited, otherwise null * @since 3.0.0 */ @Nullable public abstract Boolean none(); /** * Convert the current {@link MaxSpeed} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link MaxSpeed}. * * @return a {@link MaxSpeed.Builder} with the same values set to match the ones defined * in this {@link MaxSpeed} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<MaxSpeed> typeAdapter(Gson gson) { return new AutoValue_MaxSpeed.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a MaxSpeed * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static MaxSpeed fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, MaxSpeed.class); } /** * This builder can be used to set the values describing the {@link MaxSpeed}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Number indicating the posted speed limit. * * @param speed indicating the posted speed limit * @return a {@link Builder} object * @since 3.0.0 */ public abstract Builder speed(@Nullable Integer speed); /** * String indicating the unit of speed, either as `km/h` or `mph`. * * @param unit either as `km/h` or `mph` * @return a {@link Builder} object * @since 3.0.0 */ public abstract Builder unit(@Nullable @SpeedLimit.Unit String unit); /** * Boolean is true if the speed limit is not known, otherwise null. * * @param unknown true if speed limit is not known, otherwise null * @return a {@link Builder} object * @since 3.0.0 */ public abstract Builder unknown(@Nullable Boolean unknown); /** * Boolean is `true` if the speed limit is unlimited, otherwise null. * * @param none true if speed limit is unlimited, otherwise null * @return a {@link Builder} object * @since 3.0.0 */ public abstract Builder none(@Nullable Boolean none); /** * Build a new {@link MaxSpeed} object. * * @return a new {@link MaxSpeed} using the provided values in this builder * @since 3.0.0 */ public abstract MaxSpeed build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/NbmapStreetsV8.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.DirectionsCriteria; /** * An object containing detailed information about the road exiting the intersection along the * route. * Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. */ @AutoValue public abstract class NbmapStreetsV8 extends DirectionsJsonObject { /** * The road class of the road exiting the intersection as defined by the *<a href="https://docs.nbmap.com/vector-tiles/reference/nbmap-streets-v8/#--road---class-text"> * Nbmap Streets v8 road class specification</a>. * Valid values are the same as those supported by Nbmap Streets v8. * Examples include: `motorway`, `motorway_link`, `primary`, and `street`. * Note that adding new possible values is not considered a breaking change. * * @return class of the road. */ @Nullable @SerializedName("class") public abstract String roadClass(); /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_NbmapStreetsV8.Builder(); } /** * Convert the current {@link NbmapStreetsV8} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link NbmapStreetsV8}. * * @return a {@link Builder} with the same values set to match the ones defined in this {@link * NbmapStreetsV8} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<NbmapStreetsV8> typeAdapter(Gson gson) { return new AutoValue_NbmapStreetsV8.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Incident * @return a new instance of this class defined by the values passed in the method */ public static NbmapStreetsV8 fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, NbmapStreetsV8.class); } /** * This builder can be used to set the values describing the {@link NbmapStreetsV8}. */ @AutoValue.Builder public abstract static class Builder { /** * Class of the road exiting the intersection. * * @param roadClass class of the road exiting the intersection. * @return this builder for chaining options together */ public abstract Builder roadClass(@Nullable String roadClass); /** * Build a new {@link NbmapStreetsV8} object. * * @return a new {@link NbmapStreetsV8} using the provided values in this builder */ public abstract NbmapStreetsV8 build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/RestStop.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.DirectionsCriteria; /** * An object containing information about passing rest stops along the route. * Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. */ @AutoValue public abstract class RestStop extends DirectionsJsonObject { /** * The type of rest stop, either `rest_area` (includes parking only) or `service_area` * (includes amenities such as gas or restaurants). * Note that adding new possible types is not considered a breaking change. */ @Nullable public abstract String type(); /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_RestStop.Builder(); } /** * Convert the current {@link RestStop} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link RestStop}. * * @return a {@link Builder} with the same values set to match the ones defined in this {@link * RestStop} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<RestStop> typeAdapter(Gson gson) { return new AutoValue_RestStop.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Incident * @return a new instance of this class defined by the values passed in the method */ public static RestStop fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, RestStop.class); } /** * This builder can be used to set the values describing the {@link RestStop}. */ @AutoValue.Builder public abstract static class Builder { /** * The type of rest stop, either `rest_area` (includes parking only) or `service_area` * (includes amenities such as gas or restaurants). * Note that adding new possible types is not considered a breaking change. * * @param type rest stop type */ public abstract Builder type(@Nullable String type); /** * Build a new {@link RestStop} object. * * @return a new {@link RestStop} using the provided values in this builder */ public abstract RestStop build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/RouteLeg.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import java.util.List; /** * A route between only two {@link DirectionsWaypoint}. * * @since 1.0.0 */ @AutoValue public abstract class RouteLeg extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_RouteLeg.Builder(); } /** * The distance traveled from one waypoint to another. * * @return a double number with unit meters * @since 1.0.0 */ @Nullable public abstract Double distance(); /** * The estimated travel time from one waypoint to another. * * @return a double number with unit seconds * @since 1.0.0 */ @Nullable public abstract Double duration(); /** * The typical travel time for traversing this RouteLeg. There's a delay along the RouteLeg * if you subtract this durationTypical() value from the RouteLeg duration() value and * the resulting difference is greater than 0. The delay is because of any number * of real-world situations (road repair, traffic jam, etc). * * @return a double number with unit seconds * @since 5.5.0 */ @Nullable @SerializedName("duration_typical") public abstract Double durationTypical(); /** * A short human-readable summary of major roads traversed. Useful to distinguish alternatives. * * @return String with summary * @since 1.0.0 */ @Nullable public abstract String summary(); /** * An array of objects describing the administrative boundaries the route leg travels through. * Use {@link StepIntersection#adminIndex()} on the intersection object * to look up the admin for each intersection in this array. */ @Nullable public abstract List<Admin> admins(); /** * Gives a List including all the steps to get from one waypoint to another. * * @return List of {@link LegStep} * @since 1.0.0 */ @Nullable public abstract List<LegStep> steps(); /** * A list of incidents that occur on this leg. * * @return a list of {@link Incident} */ @Nullable public abstract List<Incident> incidents(); /** * A {@link LegAnnotation} that contains additional details about each line segment along the * route geometry. If you'd like to receiving this, you must request it inside your Directions * request before executing the call. * * @return a {@link LegAnnotation} object * @since 2.1.0 */ @Nullable public abstract LegAnnotation annotation(); /** * A list of closures that occur on this leg. * * @return a list of {@link Incident} */ @Nullable public abstract List<Closure> closures(); /** * Convert the current {@link RouteLeg} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link RouteLeg}. * * @return a {@link RouteLeg.Builder} with the same values set to match the ones defined * in this {@link RouteLeg} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<RouteLeg> typeAdapter(Gson gson) { return new AutoValue_RouteLeg.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a RouteLeg * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static RouteLeg fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, RouteLeg.class); } /** * This builder can be used to set the values describing the {@link RouteLeg}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * The distance traveled from one waypoint to another. * * @param distance a double number with unit meters * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder distance(@Nullable Double distance); /** * The estimated travel time from one waypoint to another. * * @param duration a double number with unit seconds * @return this builder for chaining options together * @since 1.0.0 */ public abstract Builder duration(@Nullable Double duration); /** * The typical travel time for traversing this RouteLeg. There's a delay along the RouteLeg * if you subtract this durationTypical() value from the RouteLeg duration() value and * the resulting difference is greater than 0. The delay is because of any number * of real-world situations (road repair, traffic jam, etc). * * @param durationTypical a double number with unit seconds * @return this builder for chaining options together * @since 5.5.0 */ public abstract Builder durationTypical(@Nullable Double durationTypical); /** * A short human-readable summary of major roads traversed. Useful to distinguish alternatives. * * @param summary String with summary * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder summary(@Nullable String summary); /** * An array of objects describing the administrative boundaries the route leg travels through. * Use {@link StepIntersection#adminIndex()} on the intersection object * to look up the admin for each intersection in this array. * * @param admins Array with admins * @return this builder for chaining options together */ public abstract Builder admins(@Nullable List<Admin> admins); /** * Gives a List including all the steps to get from one waypoint to another. * * @param steps List of {@link LegStep} * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder steps(@Nullable List<LegStep> steps); /** * A list of incidents that occur on this leg. * * @param incidents a list of {@link Incident} * @return this builder for chaining options together */ public abstract Builder incidents(@Nullable List<Incident> incidents); /** * A {@link LegAnnotation} that contains additional details about each line segment along the * route geometry. If you'd like to receiving this, you must request it inside your Directions * request before executing the call. * * @param annotation a {@link LegAnnotation} object * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder annotation(@Nullable LegAnnotation annotation); /** * A list of closures that occur on this leg. * * @param closures a list of {@link Closure} * @return this builder for chaining options together */ public abstract Builder closures(@Nullable List<Closure> closures); /** * Build a new {@link RouteLeg} object. * * @return a new {@link RouteLeg} using the provided values in this builder * @since 3.0.0 */ public abstract RouteLeg build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/RouteOptions.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.DirectionsCriteria; import com.nbmap.api.directions.v5.WalkingOptions; import com.nbmap.api.directions.v5.WalkingOptionsAdapterFactory; import com.nbmap.api.directions.v5.utils.FormatUtils; import com.nbmap.api.directions.v5.utils.ParseUtils; import com.nbmap.geojson.Point; import com.nbmap.geojson.PointAsCoordinatesTypeAdapter; import java.util.List; /** * Provides information connected to your request that help when a new directions request is needing * using the identical parameters as the original request. * <p> * For example, if I request a driving (profile) with alternatives and continueStraight set to true. * I make the request but loose reference and information which built the original request. Thus, If * I only want to change a single variable such as the destination coordinate, i'd have to have all * the other route information stores so the request was made identical to the previous but only now * using this new destination point. * <p> * Using this class can provide you wth the information used when the {@link DirectionsRoute} was * made. * * @since 3.0.0 */ @AutoValue public abstract class RouteOptions extends DirectionsJsonObject { /** * Build a new instance of this RouteOptions class optionally settling values. * * @return {@link RouteOptions.Builder} * @since 3.0.0 */ public static Builder builder() { return new AutoValue_RouteOptions.Builder(); } /** * The same base URL which was used during the request that resulted in this root directions * response. * * @return string value representing the base URL * @since 3.0.0 */ @NonNull public abstract String baseUrl(); /** * The same user which was used during the request that resulted in this root directions response. * * @return string value representing the user * @since 3.0.0 */ @NonNull public abstract String user(); /** * The routing profile to use. Possible values are * {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}, {@link DirectionsCriteria#PROFILE_DRIVING}, * {@link DirectionsCriteria#PROFILE_WALKING}, or {@link DirectionsCriteria#PROFILE_CYCLING}. * The same profile which was used during the request that resulted in this root directions * response. <tt>NbmapDirections.Builder</tt> ensures that a profile is always set even if the * <tt>NbmapDirections</tt> requesting object doesn't specifically set a profile. * * @return string value representing the profile defined in * {@link DirectionsCriteria.ProfileCriteria} * @since 3.0.0 */ @NonNull public abstract String profile(); /** * A list of Points to visit in order. * There can be between two and 25 coordinates for most requests, or up to three coordinates for * {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC} requests. * Note that these coordinates are different than the direction responses * {@link DirectionsWaypoint}s that these are the non-snapped coordinates. * * @return a list of {@link Point}s which represent the route origin, destination, * and optionally, waypoints * @since 3.0.0 */ @NonNull public abstract List<Point> coordinates(); /** * Whether to try to return alternative routes (true) or not (false, default). An alternative * route is a route that is significantly different than the fastest route, but also still * reasonably fast. Such a route does not exist in all circumstances. Up to two alternatives may * be returned. This is available for {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}, * {@link DirectionsCriteria#PROFILE_DRIVING}, {@link DirectionsCriteria#PROFILE_CYCLING}. * * @return boolean object representing the setting for alternatives * @since 3.0.0 */ @Nullable public abstract Boolean alternatives(); /** * The language of returned turn-by-turn text instructions. The default is en (English). * Must be used in conjunction with {@link RouteOptions.Builder#steps(Boolean)}. * * @return the language as a string used during the request, * if english, this will most likely be empty * @since 3.0.0 */ @Nullable public abstract String language(); /** * The maximum distance a coordinate can be moved to snap to the road network in meters. There * must be as many radiuses as there are coordinates in the request, each separated by ;. * Values can be any number greater than 0, the string unlimited or empty string. * * @return a string representing the radiuses separated by ;. * @since 3.0.0 */ @Nullable public abstract String radiuses(); /** * The maximum distance a coordinate can be moved to snap to the road network in meters. There * must be as many radiuses as there are coordinates in the request. * Values can be any number greater than 0, the string unlimited, or null. * * @return a list of radiuses */ @Nullable public List<Double> radiusesList() { return ParseUtils.parseToDoubles(radiuses()); } /** * Influences the direction in which a route starts from a waypoint. Used to filter the road * segment the waypoint will be placed on by direction. This is useful for making sure the new * routes of rerouted vehicles continue traveling in their current direction. A request that does * this would provide bearing and radius values for the first waypoint and leave the remaining * values empty. Returns two comma-separated values per waypoint: an angle clockwise from true * north between 0 and 360, and the range of degrees by which the angle can deviate (recommended * value is 45° or 90°), formatted as {angle, degrees}. If provided, the list of bearings must be * the same length as the list of coordinates. * * @return a string representing the bearings with the ; separator. Angle and degrees for every * bearing value are comma-separated. * @since 3.0.0 */ @Nullable public abstract String bearings(); /** * Influences the direction in which a route starts from a waypoint. Used to filter the road * segment the waypoint will be placed on by direction. This is useful for making sure the new * routes of rerouted vehicles continue traveling in their current direction. A request that does * this would provide bearing and radius values for the first waypoint and leave the remaining * values empty. Returns a list of values, each value is a list of an angle clockwise from true * north between 0 and 360, and the range of degrees by which the angle can deviate (recommended * value is 45° or 90°). * If provided, the list of bearings must be the same length as the list of coordinates. * * @return a List of list of doubles representing the bearings used in the original request. * The first value in the list is the angle, the second one is the degrees. */ @Nullable public List<List<Double>> bearingsList() { return ParseUtils.parseToListOfListOfDoubles(bearings()); } /** * The allowed direction of travel when departing intermediate waypoints. If true, the route * will continue in the same direction of travel. If false, the route may continue in the opposite * direction of travel. Defaults to true for {@link DirectionsCriteria#PROFILE_DRIVING} and false * for {@link DirectionsCriteria#PROFILE_WALKING} and {@link DirectionsCriteria#PROFILE_CYCLING}. * * @return a boolean value representing whether or not continueStraight was enabled or * not during the initial request * @since 3.0.0 */ @SerializedName("continue_straight") @Nullable public abstract Boolean continueStraight(); /** * Whether to emit instructions at roundabout exits (true) or not (false, default). Without * this parameter, roundabout maneuvers are given as a single instruction that includes both * entering and exiting the roundabout. With roundabout_exits=true, this maneuver becomes two * instructions, one for entering the roundabout and one for exiting it. Must be used in * conjunction with {@link RouteOptions#steps()}=true. * * @return a boolean value representing whether or not roundaboutExits was enabled or disabled * during the initial route request * @since 3.1.0 */ @SerializedName("roundabout_exits") @Nullable public abstract Boolean roundaboutExits(); /** * The format of the returned geometry. Allowed values are: * {@link DirectionsCriteria#GEOMETRY_POLYLINE} (default, a polyline with a precision of five * decimal places), {@link DirectionsCriteria#GEOMETRY_POLYLINE6} (a polyline with a precision * of six decimal places). * * @return String geometry type from {@link DirectionsCriteria.GeometriesCriteria}. * @since 3.1.0 */ @Nullable public abstract String geometries(); /** * Displays the requested type of overview geometry. Can be * {@link DirectionsCriteria#OVERVIEW_FULL} (the most detailed geometry * available), {@link DirectionsCriteria#OVERVIEW_SIMPLIFIED} (default, a simplified version of * the full geometry), or {@link DirectionsCriteria#OVERVIEW_FALSE} (no overview geometry). * * @return null or one of the options found in {@link DirectionsCriteria.OverviewCriteria} * @since 3.1.0 */ @Nullable public abstract String overview(); /** * Whether to return steps and turn-by-turn instructions (true) or not (false, default). * If steps is set to true, the following guidance-related parameters will be available: * {@link RouteOptions#bannerInstructions()}, {@link RouteOptions#language()}, * {@link RouteOptions#roundaboutExits()}, {@link RouteOptions#voiceInstructions()}, * {@link RouteOptions#voiceUnits()}, {@link RouteOptions#waypointNamesList()}, * {@link RouteOptions#waypointTargetsList()}, waypoints from {@link RouteOptions#coordinates()} * * @return true if you'd like step information, false otherwise * @since 3.1.0 */ @Nullable public abstract Boolean steps(); /** * A comma-separated list of annotations. Defines whether to return additional metadata along the * route. Possible values are: * {@link DirectionsCriteria#ANNOTATION_DURATION} * {@link DirectionsCriteria#ANNOTATION_DISTANCE} * {@link DirectionsCriteria#ANNOTATION_SPEED} * {@link DirectionsCriteria#ANNOTATION_CONGESTION} * {@link DirectionsCriteria#ANNOTATION_MAXSPEED} * See the {@link RouteLeg} object for more details on what is included with annotations. * Must be used in conjunction with overview=full. * * @return a string containing any of the annotations that were used during the request * @since 3.0.0 */ @Nullable public abstract String annotations(); /** * A list of annotations. Defines whether to return additional metadata along the * route. Possible values are: * {@link DirectionsCriteria#ANNOTATION_DURATION} * {@link DirectionsCriteria#ANNOTATION_DISTANCE} * {@link DirectionsCriteria#ANNOTATION_SPEED} * {@link DirectionsCriteria#ANNOTATION_CONGESTION} * {@link DirectionsCriteria#ANNOTATION_MAXSPEED} * See the {@link RouteLeg} object for more details on what is included with annotations. * Must be used in conjunction with overview=full. * * @return a list of annotations that were used during the request */ @Nullable public List<String> annotationsList() { return ParseUtils.parseToStrings(annotations(), ","); } /** * Exclude certain road types from routing. The default is to not exclude anything from the * profile selected. The following exclude flags are available for each profile: * * {@link DirectionsCriteria#PROFILE_DRIVING}: One of {@link DirectionsCriteria#EXCLUDE_TOLL}, * {@link DirectionsCriteria#EXCLUDE_MOTORWAY}, or {@link DirectionsCriteria#EXCLUDE_FERRY}. * * {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}: One of * {@link DirectionsCriteria#EXCLUDE_TOLL}, {@link DirectionsCriteria#EXCLUDE_MOTORWAY}, or * {@link DirectionsCriteria#EXCLUDE_FERRY}. * * {@link DirectionsCriteria#PROFILE_WALKING}: No excludes supported * * {@link DirectionsCriteria#PROFILE_CYCLING}: {@link DirectionsCriteria#EXCLUDE_FERRY} * * @return a string matching one of the {@link DirectionsCriteria.ExcludeCriteria} exclusions * @since 3.0.0 */ @Nullable public abstract String exclude(); /** * Whether to return SSML marked-up text for voice guidance along the route (true) or not * (false, default). * Must be used in conjunction with {@link RouteOptions#steps()}=true. * * @return true if the original request included voice instructions * @since 3.0.0 */ @SerializedName("voice_instructions") @Nullable public abstract Boolean voiceInstructions(); /** * Whether to return banner objects associated with the route steps (true) or not * (false, default). Must be used in conjunction with {@link RouteOptions#steps()}=true * * @return true if the original request included banner instructions * @since 3.0.0 */ @SerializedName("banner_instructions") @Nullable public abstract Boolean bannerInstructions(); /** * A type of units to return in the text for voice instructions. * Can be {@link DirectionsCriteria#IMPERIAL} (default) or {@link DirectionsCriteria#METRIC}. * Must be used in conjunction with {@link RouteOptions#steps()}=true and * {@link RouteOptions#voiceInstructions()} ()}=true. * * @return a string matching either imperial or metric * @since 3.0.0 */ @SerializedName("voice_units") @Nullable public abstract String voiceUnits(); /** * A valid Nbmap access token used to making the request. * * @return a string representing the Nbmap access token * @since 3.0.0 */ @SerializedName("access_token") @NonNull public abstract String accessToken(); /** * A universally unique identifier (UUID) for identifying and executing a similar specific route * in the future. <tt>NbmapDirections</tt> always waits for the response object which ensures * this value will never be null. * * @return a string containing the request UUID * @since 3.0.0 */ @SerializedName("uuid") @NonNull public abstract String requestUuid(); /** * Indicates from which side of the road to approach a waypoint. * Accepts {@link DirectionsCriteria#APPROACH_UNRESTRICTED} (default) or * {@link DirectionsCriteria#APPROACH_CURB} . * If set to {@link DirectionsCriteria#APPROACH_UNRESTRICTED}, the route can approach waypoints * from either side of the road. * If set to {@link DirectionsCriteria#APPROACH_CURB}, the route will be returned so that on * arrival, the waypoint will be found on the side that corresponds with the driving_side of the * region in which the returned route is located. * If provided, the list of approaches must be the same length as the list of waypoints. * * @return a string representing approaches for each waypoint * @since 3.2.0 */ @Nullable public abstract String approaches(); /** * Indicates from which side of the road to approach a waypoint. * Accepts {@link DirectionsCriteria#APPROACH_UNRESTRICTED} (default) or * {@link DirectionsCriteria#APPROACH_CURB} . * If set to {@link DirectionsCriteria#APPROACH_UNRESTRICTED}, the route can approach waypoints * from either side of the road. * If set to {@link DirectionsCriteria#APPROACH_CURB}, the route will be returned so that on * arrival, the waypoint will be found on the side that corresponds with the driving_side of the * region in which the returned route is located. * If provided, the list of approaches must be the same length as the list of waypoints. * * @return a list of strings representing approaches for each waypoint */ @Nullable public List<String> approachesList() { return ParseUtils.parseToStrings(approaches()); } /** * Indicates which input coordinates should be treated as waypoints. * <p> * Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, * but must contain the first ( 0 ) and last coordinates' index separated by ; . * {@link #steps()} * </p> * * @return a string representing indices to be used as waypoints * @since 4.4.0 */ @SerializedName("waypoints") @Nullable public abstract String waypointIndices(); /** * Indicates which input coordinates should be treated as waypoints. * <p> * Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, * but must contain the first ( 0 ) and last coordinates' index. * {@link #steps()} * </p> * * @return a List of Integers representing indices to be used as waypoints */ @Nullable public List<Integer> waypointIndicesList() { return ParseUtils.parseToIntegers(waypointIndices()); } /** * A semicolon-separated list of custom names for entries in the list of * {@link RouteOptions#coordinates()}, used for the arrival instruction in banners and voice * instructions. Values can be any string, and the total number of all characters cannot exceed * 500. If provided, the list of waypoint_names must be the same length as the list of * coordinates. The first value in the list corresponds to the route origin, not the first * destination. * Must be used in conjunction with {@link RouteOptions#steps()} = true. * @return a string representing names for each waypoint * @since 3.3.0 */ @SerializedName("waypoint_names") @Nullable public abstract String waypointNames(); /** * A semicolon-separated list of custom names for entries in the list of * {@link RouteOptions#coordinates()}, used for the arrival instruction in banners and voice * instructions. Values can be any string, and the total number of all characters cannot exceed * 500. If provided, the list of waypoint_names must be the same length as the list of * coordinates. The first value in the list corresponds to the route origin, not the first * destination. * Must be used in conjunction with {@link RouteOptions#steps()} = true. * * @return a list of strings representing names for each waypoint */ @Nullable public List<String> waypointNamesList() { return ParseUtils.parseToStrings(waypointNames()); } /** * A semicolon-separated list of coordinate pairs used to specify drop-off * locations that are distinct from the locations specified in coordinates. * If this parameter is provided, the Directions API will compute the side of the street, * left or right, for each target based on the waypoint_targets and the driving direction. * The maneuver.modifier, banner and voice instructions will be updated with the computed * side of street. The number of waypoint targets must be the same as the number of coordinates. * Must be used with {@link RouteOptions#steps()} = true. * @return a list of Points representing coordinate pairs for drop-off locations * @since 4.3.0 */ @SerializedName("waypoint_targets") @Nullable public abstract String waypointTargets(); /** * A list of points used to specify drop-off * locations that are distinct from the locations specified in coordinates. * If this parameter is provided, the Directions API will compute the side of the street, * left or right, for each target based on the waypoint_targets and the driving direction. * The maneuver.modifier, banner and voice instructions will be updated with the computed * side of street. The number of waypoint targets must be the same as the number of coordinates. * Must be used with {@link RouteOptions#steps()} = true. * @return a list of Points representing coordinate pairs for drop-off locations */ @Nullable public List<Point> waypointTargetsList() { return ParseUtils.parseToPoints(waypointTargets()); } /** * To be used to specify settings for use with the walking profile. * * @return options to use for walking profile * @since 4.8.0 */ @Nullable public abstract WalkingOptions walkingOptions(); /** * A semicolon-separated list of booleans affecting snapping of waypoint locations to road * segments. * If true, road segments closed due to live-traffic closures will be considered for snapping. * If false, they will not be considered for snapping. * If provided, the number of snappingClosures must be the same as the number of * coordinates. * Must be used with {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC} * * @return a String representing a list of booleans */ @SerializedName("snapping_closures") @Nullable public abstract String snappingClosures(); /** * A list of booleans affecting snapping of waypoint locations to road segments. * If true, road segments closed due to live-traffic closures will be considered for snapping. * If false, they will not be considered for snapping. * If provided, the number of snappingClosures must be the same as the number of * coordinates. * Must be used with {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC} * * @return a list of booleans */ @Nullable public List<Boolean> snappingClosuresList() { return ParseUtils.parseToBooleans(snappingClosures()); } /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<RouteOptions> typeAdapter(Gson gson) { return new AutoValue_RouteOptions.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a RouteOptions * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ @NonNull public static RouteOptions fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter()); gson.registerTypeAdapterFactory(WalkingOptionsAdapterFactory.create()); return gson.create().fromJson(json, RouteOptions.class); } /** * Convert the current {@link RouteOptions} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link RouteOptions}. * * @return a {@link RouteOptions.Builder} with the same values set to match the ones defined * in this {@link RouteOptions} */ @NonNull public abstract Builder toBuilder(); /** * This builder can be used to set the values describing the {@link RouteOptions}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * The base URL that was used during the request time and resulted in this responses * result. * * @param baseUrl base URL used for original request * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder baseUrl(@NonNull String baseUrl); /** * The user value that was used during the request. * * @param user string representing the user field in the calling url * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder user(@NonNull String user); /** * The routing profile to use. Possible values are * {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}, * {@link DirectionsCriteria#PROFILE_DRIVING}, {@link DirectionsCriteria#PROFILE_WALKING}, or * {@link DirectionsCriteria#PROFILE_CYCLING}. * The same profile which was used during the request that resulted in this root directions * response. <tt>NbmapDirections.Builder</tt> ensures that a profile is always set even if the * <tt>NbmapDirections</tt> requesting object doesn't specifically set a profile. * * @param profile One of the direction profiles defined in * {@link DirectionsCriteria.ProfileCriteria} * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder profile(@NonNull @DirectionsCriteria.ProfileCriteria String profile); /** * A list of Points to visit in order. * There can be between two and 25 coordinates for most requests, or up to three coordinates for * {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC} requests. * Note that these coordinates are different than the direction responses * {@link DirectionsWaypoint}s that these are the non-snapped coordinates. * * @param coordinates a list of {@link Point}s which represent the route origin, destination, * and optionally, waypoints * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder coordinates(@NonNull List<Point> coordinates); /** * Whether to try to return alternative routes (true) or not (false, default). An alternative * route is a route that is significantly different than the fastest route, but also still * reasonably fast. Such a route does not exist in all circumstances. Up to two alternatives may * be returned. This is available for{@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}, * {@link DirectionsCriteria#PROFILE_DRIVING}, {@link DirectionsCriteria#PROFILE_CYCLING}. * * @param alternatives true if the request contained additional route request, otherwise false * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder alternatives(@NonNull Boolean alternatives); /** * The language of returned turn-by-turn text instructions. The default is en (English). * Must be used in conjunction with {@link RouteOptions#steps()} = true. * * @param language a string with the language which was requested in the url * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder language(@NonNull String language); /** * The maximum distance a coordinate can be moved to snap to the road network in meters. There * must be as many radiuses as there are coordinates in the request, each separated by ;. * Values can be any number greater than 0 or the string unlimited. * * @param radiuses a String of radius values, each separated by ;. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder radiuses(@NonNull String radiuses); /** * The maximum distance a coordinate can be moved to snap to the road network in meters. There * must be as many radiuses as there are coordinates in the request. * Values can be any number greater than 0 or {@link Double#POSITIVE_INFINITY}. * * @param radiuses a list of radius values * @return this builder for chaining options together */ public Builder radiusesList(@NonNull List<Double> radiuses) { String result = FormatUtils.formatRadiuses(radiuses); if (result != null) { radiuses(result); } return this; } /** * Influences the direction in which a route starts from a waypoint. Used to filter the road * segment the waypoint will be placed on by direction. This is useful for making sure the new * routes of rerouted vehicles continue traveling in their current direction. A request that * does this would provide bearing and radius values for the first waypoint and leave the * remaining values empty. Takes two comma-separated values per waypoint: an angle clockwise * from true north between 0 and 360, and the range of degrees by which the angle can deviate * (recommended value is 45° or 90°), formatted as {angle, degrees}. If provided, the list of * bearings must be the same length as the list of coordinates. However, you can skip a * coordinate and show its position in the list with the ; separator. * * @param bearings a string representing the bearings with the ; separator. Angle and degrees * for every bearing value are comma-separated. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder bearings(@NonNull String bearings); /** * Influences the direction in which a route starts from a waypoint. Used to filter the road * segment the waypoint will be placed on by direction. This is useful for making sure the new * routes of rerouted vehicles continue traveling in their current direction. A request that * does this would provide bearing and radius values for the first waypoint and leave the * remaining values empty. Takes a List of list of doubles: the first value in the list is an * angle clockwise from true north between 0 and 360, the second value is the range of degrees * by which the angle can deviate (recommended value is 45° or 90°). * If provided, the list of bearings must be the same length as the list of coordinates. * However, you can skip a coordinate and show its position in the list with the null value. * * @param bearings a List of list of doubles representing the bearings used in the original * request. The first value in the list is the angle, the second one is the * degrees. * @return this builder for chaining options together */ public Builder bearingsList(@NonNull List<List<Double>> bearings) { String result = FormatUtils.formatBearings(bearings); if (result != null) { bearings(result); } return this; } /** * Sets the allowed direction of travel when departing intermediate waypoints. If true, the * route will continue in the same direction of travel. If false, the route may continue in the * opposite direction of travel. Defaults to true for {@link DirectionsCriteria#PROFILE_DRIVING} * and false for {@link DirectionsCriteria#PROFILE_WALKING} and * {@link DirectionsCriteria#PROFILE_CYCLING}. * * @param continueStraight true if you'd like the user to continue straight from the starting * point * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder continueStraight(@NonNull Boolean continueStraight); /** * Whether to emit instructions at roundabout exits (true) or not (false, default). Without * this parameter, roundabout maneuvers are given as a single instruction that includes both * entering and exiting the roundabout. With roundabout_exits=true, this maneuver becomes two * instructions, one for entering the roundabout and one for exiting it. Must be used in * conjunction with {@link RouteOptions.Builder#steps(Boolean)} * * @param roundaboutExits true if you'd like extra roundabout instructions * @return this builder for chaining options together * @since 3.1.0 */ public abstract Builder roundaboutExits(@NonNull Boolean roundaboutExits); /** * The format of the returned geometry. Allowed values are: * {@link DirectionsCriteria#GEOMETRY_POLYLINE} (default, a polyline with a precision of five * decimal places), {@link DirectionsCriteria#GEOMETRY_POLYLINE6} (a polyline with a precision * of six decimal places). * A null value will reset this field to the APIs default value vs this SDKs default value of * {@link DirectionsCriteria#GEOMETRY_POLYLINE6}. * * @param geometries one of the options found in {@link DirectionsCriteria.GeometriesCriteria}. * @return this builder for chaining options together * @since 3.1.0 */ public abstract Builder geometries( @NonNull @DirectionsCriteria.GeometriesCriteria String geometries); /** * Displays the requested type of overview geometry. Can be * {@link DirectionsCriteria#OVERVIEW_FULL} (the most detailed geometry * available), {@link DirectionsCriteria#OVERVIEW_SIMPLIFIED} (default, a simplified version of * the full geometry), or {@link DirectionsCriteria#OVERVIEW_FALSE} (no overview geometry). * * @param overview one of the options found in {@link DirectionsCriteria.OverviewCriteria} * @return this builder for chaining options together * @since 3.1.0 */ public abstract Builder overview( @NonNull @DirectionsCriteria.OverviewCriteria String overview ); /** * Whether to return steps and turn-by-turn instructions (true) or not (false, default). * If steps is set to true, the following guidance-related parameters will be available: * {@link RouteOptions#bannerInstructions()}, {@link RouteOptions#language()}, * {@link RouteOptions#roundaboutExits()}, {@link RouteOptions#voiceInstructions()}, * {@link RouteOptions#voiceUnits()}, {@link RouteOptions#waypointNamesList()}, * {@link RouteOptions#waypointTargetsList()}, waypoints from {@link RouteOptions#coordinates()} * * @param steps true if you'd like step information, false otherwise * @return this builder for chaining options together * @since 3.1.0 */ public abstract Builder steps(@NonNull Boolean steps); /** * Whether to return additional metadata along the route. Possible values are: * {@link DirectionsCriteria#ANNOTATION_DURATION} * {@link DirectionsCriteria#ANNOTATION_DISTANCE} * {@link DirectionsCriteria#ANNOTATION_SPEED} * {@link DirectionsCriteria#ANNOTATION_CONGESTION} * {@link DirectionsCriteria#ANNOTATION_MAXSPEED} * You can include several annotations as a comma-separated list. See the * {@link RouteLeg} object for more details on what is included with annotations. * Must be used in conjunction with overview=full. * * @param annotations in string format and separated by commas if more than one annotation was * requested * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder annotations(@NonNull String annotations); /** * Whether to return additional metadata along the route. Possible values are: * {@link DirectionsCriteria#ANNOTATION_DURATION} * {@link DirectionsCriteria#ANNOTATION_DISTANCE} * {@link DirectionsCriteria#ANNOTATION_SPEED} * {@link DirectionsCriteria#ANNOTATION_CONGESTION} * {@link DirectionsCriteria#ANNOTATION_MAXSPEED} * * See the {@link RouteLeg} object for more details on what is included with * annotations. * Must be used in conjunction with overview=full. * * @param annotations a list of annotations * @return this builder for chaining options together */ public Builder annotationsList(@NonNull List<String> annotations) { String result = FormatUtils.join(",", annotations); if (result != null) { annotations(result); } return this; } /** * Whether to return SSML marked-up text for voice guidance along the route (true) or not * (false, default). * Must be used in conjunction with {@link RouteOptions.Builder#steps(Boolean)}. * * @param voiceInstructions true if the original request included voice instructions * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder voiceInstructions(@NonNull Boolean voiceInstructions); /** * Whether to return banner objects associated with the route steps (true) or not * (false, default). Must be used in conjunction with * {@link RouteOptions.Builder#steps(Boolean)} * * @param bannerInstructions true if the original request included banner instructions * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder bannerInstructions(@NonNull Boolean bannerInstructions); /** * Specify which type of units to return in the text for voice instructions. * Can be {@link DirectionsCriteria#IMPERIAL} (default) or {@link DirectionsCriteria#METRIC}. * Must be used in conjunction with {@link RouteOptions.Builder#steps(Boolean)}=true and * {@link RouteOptions.Builder#voiceInstructions(Boolean)}=true. * * @param voiceUnits string matching either imperial or metric * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder voiceUnits(@NonNull String voiceUnits); /** * A valid Nbmap access token used to making the request. * * @param accessToken a string containing a valid Nbmap access token * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder accessToken(@NonNull String accessToken); /** * A universally unique identifier (UUID) for identifying and executing a similar specific route * in the future. * * @param requestUuid a string containing the request UUID * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder requestUuid(@NonNull String requestUuid); /** * Exclude certain road types from routing. The default is to not exclude anything from the * profile selected. The following exclude flags are available for each profile: * * {@link DirectionsCriteria#PROFILE_DRIVING}: One of {@link DirectionsCriteria#EXCLUDE_TOLL}, * {@link DirectionsCriteria#EXCLUDE_MOTORWAY}, or {@link DirectionsCriteria#EXCLUDE_FERRY}. * * {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}: One of * {@link DirectionsCriteria#EXCLUDE_TOLL}, {@link DirectionsCriteria#EXCLUDE_MOTORWAY}, or * {@link DirectionsCriteria#EXCLUDE_FERRY}. * * {@link DirectionsCriteria#PROFILE_WALKING}: No excludes supported * * {@link DirectionsCriteria#PROFILE_CYCLING}: {@link DirectionsCriteria#EXCLUDE_FERRY} * * @param exclude a string matching one of the {@link DirectionsCriteria.ExcludeCriteria} * exclusions * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder exclude(@NonNull String exclude); /** * Indicates from which side of the road to approach a waypoint. * Accepts {@link DirectionsCriteria#APPROACH_UNRESTRICTED} (default) or * {@link DirectionsCriteria#APPROACH_CURB} . * If set to {@link DirectionsCriteria#APPROACH_UNRESTRICTED}, the route can approach waypoints * from either side of the road. * If set to {@link DirectionsCriteria#APPROACH_CURB}, the route will be returned so that on * arrival, the waypoint will be found on the side that corresponds with the driving_side of the * region in which the returned route is located. * If provided, the list of approaches must be the same length as the list of waypoints. * However, you can skip a coordinate and show its position in the list with the ; separator. * The same approaches the user originally made when the request was made. * * @param approaches unrestricted, curb or omitted (;) * @return this builder for chaining options together * @since 3.2.0 */ public abstract Builder approaches(@NonNull String approaches); /** * Indicates from which side of the road to approach a waypoint. * Accepts {@link DirectionsCriteria#APPROACH_UNRESTRICTED} (default) or * {@link DirectionsCriteria#APPROACH_CURB} . * If set to {@link DirectionsCriteria#APPROACH_UNRESTRICTED}, the route can approach waypoints * from either side of the road. * If set to {@link DirectionsCriteria#APPROACH_CURB}, the route will be returned so that on * arrival, the waypoint will be found on the side that corresponds with the driving_side of the * region in which the returned route is located. * If provided, the list of approaches must be the same length as the list of waypoints. * However, you can skip a coordinate and show its position in the list with null value. * The same approaches the user originally made when the request was made. * * @param approaches a list of Strings * @return this builder for chaining options together */ public Builder approachesList(@NonNull List<String> approaches) { String result = FormatUtils.formatApproaches(approaches); if (result != null) { approaches(result); } return this; } /** * Indicates which input coordinates should be treated as waypoints. * <p> * Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, * but must contain the first ( 0 ) and last coordinates' index separated by ; . * {@link #steps()} * </p> * The same waypoint indices the user originally made when the request was made. * * @param waypointIndices to be used as waypoints * @return this builder for chaining options together * @since 4.4.0 */ public abstract Builder waypointIndices(@NonNull String waypointIndices); /** * Indicates which input coordinates should be treated as waypoints. * <p> * Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, * but must contain the first ( 0 ) and last coordinates'. * {@link #steps()} * </p> * The same waypoint indices the user originally made when the request was made. * * @param indices a list to be used as waypoints * @return this builder for chaining options together */ public Builder waypointIndicesList(@NonNull List<Integer> indices) { String result = FormatUtils.join(";", indices); if (result != null) { waypointIndices(result); } return this; } /** * A semicolon-separated list of custom names for entries in the list of * {@link RouteOptions#coordinates()}, used for the arrival instruction in banners and voice * instructions. Values can be any string, and the total number of all characters cannot exceed * 500. If provided, the list of waypoint_names must be the same length as the list of * coordinates, but you can skip a coordinate pair and show its position in the list with the ; * separator. The first value in the list corresponds to the route origin, not the first * destination. To leave the origin unnamed, begin the list with a semicolon. * Must be used in conjunction with {@link RouteOptions.Builder#steps(Boolean)} = true. * * @param waypointNames unrestricted, curb or omitted (;) * @return this builder for chaining options together * @since 3.3.0 */ public abstract Builder waypointNames(@NonNull String waypointNames); /** * A semicolon-separated list of custom names for entries in the list of * {@link RouteOptions#coordinates()}, used for the arrival instruction in banners and voice * instructions. Values can be any string, and the total number of all characters cannot exceed * 500. If provided, the list of waypoint_names must be the same length as the list of * coordinates, but you can skip a coordinate pair and show its position in the list with the * null value. The first value in the list corresponds to the route origin, not the first * destination. To leave the origin unnamed, begin the list with a null value. * Must be used in conjunction with {@link RouteOptions.Builder#steps(Boolean)} = true. * * @param waypointNames a list of Strings * @return this builder for chaining options together */ public Builder waypointNamesList(@NonNull List<String> waypointNames) { String result = FormatUtils.formatWaypointNames(waypointNames); if (result != null) { waypointNames(result); } return this; } /** * A semicolon-separated list of coordinate pairs used to specify drop-off * locations that are distinct from the locations specified in coordinates. * If this parameter is provided, the Directions API will compute the side of the street, * left or right, for each target based on the waypoint_targets and the driving direction. * The maneuver.modifier, banner and voice instructions will be updated with the computed * side of street. The number of waypoint targets must be the same as the number of coordinates, * but you can skip a coordinate pair and show its position in the list with the ; separator. * Must be used with {@link RouteOptions.Builder#steps(Boolean)} = true. * The same waypoint targets the user originally made when the request was made. * * @param waypointTargets list of coordinate pairs for drop-off locations (;) * @return this builder for chaining options together * @since 4.3.0 */ public abstract Builder waypointTargets(@NonNull String waypointTargets); /** * A list of coordinate pairs used to specify drop-off * locations that are distinct from the locations specified in coordinates. * If this parameter is provided, the Directions API will compute the side of the street, * left or right, for each target based on the waypoint_targets and the driving direction. * The maneuver.modifier, banner and voice instructions will be updated with the computed * side of street. The number of waypoint targets must be the same as the number of coordinates, * but you can skip a coordinate pair and show its position in the list with the null value. * Must be used with {@link RouteOptions.Builder#steps(Boolean)} = true. * The same waypoint targets the user originally made when the request was made. * * @param waypointTargets list of Points for drop-off locations * @return this builder for chaining options together */ public Builder waypointTargetsList(@NonNull List<Point> waypointTargets) { waypointTargets(FormatUtils.formatPointsList(waypointTargets)); return this; } /** * To be used to specify settings for use with the walking profile. * * @param walkingOptions options to use for walking profile * @return this builder for chaining options together * @since 4.8.0 */ public abstract Builder walkingOptions(@NonNull WalkingOptions walkingOptions); /** * A semicolon-separated list of booleans affecting snapping of waypoint locations to road * segments. * If true, road segments closed due to live-traffic closures will be considered for snapping. * If false, they will not be considered for snapping. * If provided, the number of snappingClosures must be the same as the number of * coordinates. * You can skip a coordinate and show its position in the list with the ; separator. * If unspecified, this parameter defaults to false. * Must be used with {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC} * * @param snappingClosures a semicolon-separated list of booleans * @return this builder for chaining options together */ public abstract Builder snappingClosures(@NonNull String snappingClosures); /** * A list of booleans affecting snapping of waypoint locations to road segments. * If true, road segments closed due to live-traffic closures will be considered for snapping. * If false, they will not be considered for snapping. * If provided, the number of snappingClosures must be the same as the number of * coordinates. * You can skip a coordinate and show its position in the list with null value. * If unspecified, this parameter defaults to false. * Must be used with {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC} * * @param snappingClosures a list of booleans * @return this builder for chaining options together */ public Builder snappingClosures(@NonNull List<Boolean> snappingClosures) { String result = FormatUtils.join(";", snappingClosures); if (result != null) { snappingClosures(result); } else { snappingClosures(""); } return this; } /** * Builds a new instance of the {@link RouteOptions} object. * * @return a new {@link RouteOptions} instance * @since 3.0.0 */ public abstract RouteOptions build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/SpeedLimit.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.StringDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * The file exposes speed limit annotations. */ public class SpeedLimit { /** * Speed limit unit in km/h. */ public static final String KMPH = "km/h"; /** * Speed limit unit in mph. */ public static final String MPH = "mph"; /** * Speed limit unit. */ @Retention(RetentionPolicy.CLASS) @StringDef({ MPH, KMPH }) public @interface Unit { } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/StepIntersection.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.DirectionsCriteria; import com.nbmap.geojson.Point; import java.util.List; /** * Object representing an intersection along the step. * * @since 1.3.0 */ @AutoValue public abstract class StepIntersection extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_StepIntersection.Builder(); } /** * A {@link Point} representing this intersection location. * * @return GeoJson Point representing this intersection location * @since 3.0.0 */ @NonNull public Point location() { return Point.fromLngLat(rawLocation()[0], rawLocation()[1]); } /** * A {@link Point} representing this intersection location. Since the rawLocation isn't public, * it's okay to be mutable as long as nothing in this SDK changes values. * * @return GeoJson Point representing this intersection location * @since 3.0.0 */ @NonNull @SerializedName("location") @SuppressWarnings( {"mutable", "WeakerAccess"}) protected abstract double[] rawLocation(); /** * An integer list of bearing values available at the step intersection. * * @return An array of bearing values (for example [0,90,180,270]) that are available at the * intersection. The bearings describe all available roads at the intersection. * @since 1.3.0 */ @Nullable public abstract List<Integer> bearings(); /** * A list of strings signifying the classes of the road exiting the intersection. Possible * values: * <ul> * <li><strong>toll</strong>: the road continues on a toll road</li> * <li><strong>ferry</strong>: the road continues on a ferry</li> * <li><strong>restricted</strong>: the road continues on with access restrictions</li> * <li><strong>motorway</strong>: the road continues on a motorway</li> * <li><strong>tunnel</strong>: the road continues on a tunnel</li> * </ul> * * @return a string list containing the classes of the road exiting the intersection * @since 3.0.0 */ @Nullable public abstract List<String> classes(); /** * A list of entry flags, corresponding in a 1:1 relationship to the bearings. A value of true * indicates that the respective road could be entered on a valid route. false indicates that the * turn onto the respective road would violate a restriction. * * @return a list of entry flags, corresponding in a 1:1 relationship to the bearings * @since 1.3.0 */ @Nullable public abstract List<Boolean> entry(); /** * Index into bearings/entry array. Used to calculate the bearing before the turn. Namely, the * clockwise angle from true north to the direction of travel before the maneuver/passing the * intersection. To get the bearing in the direction of driving, the bearing has to be rotated by * a value of 180. The value is not supplied for departure * maneuvers. * * @return index into bearings/entry array * @since 1.3.0 */ @Nullable public abstract Integer in(); /** * Index out of the bearings/entry array. Used to extract the bearing after the turn. Namely, The * clockwise angle from true north to the direction of travel after the maneuver/passing the * intersection. The value is not supplied for arrive maneuvers. * * @return index out of the bearings/entry array * @since 1.3.0 */ @Nullable public abstract Integer out(); /** * Array of lane objects that represent the available turn lanes at the intersection. If no lane * information is available for an intersection, the lanes property will not be present. Lanes are * provided in their order on the street, from left to right. * * @return array of lane objects that represent the available turn lanes at the intersection * @since 2.0.0 */ @Nullable public abstract List<IntersectionLanes> lanes(); /** * The zero-based index for the intersection. * This value can be used to apply the duration annotation that corresponds with the intersection. * Only available on the driving profile. * * @return index for the intersection */ @Nullable @SerializedName("geometry_index") public abstract Integer geometryIndex(); /** * A boolean indicating whether the road exiting the intersection is considered to be in an urban * area. This value is determined by the density of the surrounding road network. * Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. * * @return a value indicating whether the road exiting the intersection is in an urban area */ @Nullable @SerializedName("is_urban") public abstract Boolean isUrban(); /** * The zero-based index into the admin list on the route leg for this intersection. * Use this field to look up the ISO-3166-1 country code for this point on the route. * Only available on the `driving` profile. * * @return a zero-based index into the admin list on the route leg. * @see RouteLeg#admins() */ @Nullable @SerializedName("admin_index") public abstract Integer adminIndex(); /** * An object containing information about passing rest stops along the route. * Only available on the `driving` profile. * * @return an object containing information about passing rest stops along the route. */ @Nullable @SerializedName("rest_stop") public abstract RestStop restStop(); /** * An object containing information about a toll collection point along the route. * This is a payment booth or overhead electronic gantry * <a href="https://wiki.openstreetmap.org/wiki/Tag:barrier%3Dtoll_booth"> * payment booth or overhead electronic gantry</a> * where toll charge is collected. * Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. * * @return an object containing information about a toll collection point along the route. */ @Nullable @SerializedName("toll_collection") public abstract TollCollection tollCollection(); /** * An object containing detailed information about the road exiting the intersection along the * route. Properties in this object correspond to properties in the {@link #classes()} * specification. Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. * * @return an object containing detailed road information. */ @Nullable @SerializedName("nbmap_streets_v8") public abstract NbmapStreetsV8 nbmapStreetsV8(); /** * Name of the tunnel. Value may be present if {@link #classes} contains "tunnel". * * @return name of the tunnel */ @Nullable @SerializedName("tunnel_name") public abstract String tunnelName(); /** * Convert the current {@link StepIntersection} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link StepIntersection}. * * @return a {@link StepIntersection.Builder} with the same values set to match the ones defined * in this {@link StepIntersection} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<StepIntersection> typeAdapter(Gson gson) { return new AutoValue_StepIntersection.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a StepIntersection * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static StepIntersection fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, StepIntersection.class); } /** * This builder can be used to set the values describing the {@link StepIntersection}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * An integer array of bearing values available at the step intersection. * * @param bearing An array of bearing values (for example [0,90,180,270]) that are available at * the intersection. The bearings describe all available roads at the * intersection. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder bearings(@Nullable List<Integer> bearing); /** * A list of strings signifying the classes of the road exiting the intersection. Possible * values: * <ul> * <li><strong>toll</strong>: the road continues on a toll road</li> * <li><strong>ferry</strong>: the road continues on a ferry</li> * <li><strong>restricted</strong>: the road continues on with access restrictions</li> * <li><strong>motorway</strong>: the road continues on a motorway</li> * </ul> * * @param classes a list of strings containing the classes of the road exiting the intersection * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder classes(@Nullable List<String> classes); /** * A list of entry flags, corresponding in a 1:1 relationship to the bearings. A value of true * indicates that the respective road could be entered on a valid route. false indicates that * the turn onto the respective road would violate a restriction. * * @param entry a {@link Boolean} list of entry flags, corresponding in a 1:1 relationship to * the bearings * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder entry(@Nullable List<Boolean> entry); /** * Index into bearings/entry array. Used to calculate the bearing before the turn. Namely, the * clockwise angle from true north to the direction of travel before the maneuver/passing the * intersection. To get the bearing in the direction of driving, the bearing has to be rotated * by a value of 180. The value is not supplied for departure * maneuvers. * * @param in index into bearings/entry array * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder in(@Nullable Integer in); /** * Index out of the bearings/entry array. Used to extract the bearing after the turn. Namely, * The clockwise angle from true north to the direction of travel after the maneuver/passing the * intersection. The value is not supplied for arrive maneuvers. * * @param out index out of the bearings/entry array * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder out(@Nullable Integer out); /** * Array of lane objects that represent the available turn lanes at the intersection. If no lane * information is available for an intersection, the lanes property will not be present. Lanes * are provided in their order on the street, from left to right. * * @param lanes array of lane objects that represent the available turn lanes at the * intersection * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder lanes(@Nullable List<IntersectionLanes> lanes); /** * The zero-based index for the intersection. * This value can be used to apply the duration annotation * that corresponds with the intersection. * Only available on the driving profile. * * @param geometryIndex index for the intersection * @return this builder for chaining options together */ public abstract Builder geometryIndex(@Nullable Integer geometryIndex); /** * A boolean indicating whether the road exiting the intersection is considered to be in an * urban area. This value is determined by the density of the surrounding road network. * Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. * * @param isUrban indicating whether the road exiting the intersection is in an urban area * @return this builder for chaining options together */ @Nullable public abstract Builder isUrban(@Nullable Boolean isUrban); /** * The zero-based index into the admin list on the route leg for this intersection. * Use this field to look up the ISO-3166-1 country code for this point on the route. * Only available on the `driving` profile. * * @param adminIndex zero-based index into the admin list on the route leg for this intersection * @return this builder for chaining options together */ @Nullable public abstract Builder adminIndex(@Nullable Integer adminIndex); /** * An object containing information about passing rest stops along the route. * Only available on the `driving` profile. * * @param restStop object containing information about passing rest stops along the route. * @return this builder for chaining options together */ @Nullable public abstract Builder restStop(@Nullable RestStop restStop); /** * An object containing information about a toll collection point along the route. * This is a payment booth or overhead electronic gantry * <a href="https://wiki.openstreetmap.org/wiki/Tag:barrier%3Dtoll_booth"> * payment booth or overhead electronic gantry</a> * where toll charge is collected. * * @param tollCollection object containing information about * a toll collection point along the route. * @return this builder for chaining options together */ @Nullable public abstract Builder tollCollection(@Nullable TollCollection tollCollection); /** * An object containing detailed information about the road exiting the intersection along the * route. Properties in this object correspond to properties in the {@link #classes()} * specification. Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. * * @param street an object containing detailed road information. * @return this builder for chaining options together */ @Nullable public abstract Builder nbmapStreetsV8(@Nullable NbmapStreetsV8 street); /** * Name of the tunnel. Value is present only if class is tunnel. * * @param tunnelName name of the tunnel * @return this builder for chaining options together */ public abstract Builder tunnelName(@Nullable String tunnelName); /** * The rawLocation as a double array. Once the {@link StepIntersection} object's created, * this raw location gets converted into a {@link Point} object and is public exposed as such. * The double array should have a length of two, index 0 being the longitude and index 1 being * latitude. * * @param rawLocation a double array with a length of two, index 0 being the longitude and * index 1 being latitude. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder rawLocation(@NonNull double[] rawLocation); /** * Build a new {@link StepIntersection} object. * * @return a new {@link StepIntersection} using the provided values in this builder * @since 3.0.0 */ public abstract StepIntersection build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/StepManeuver.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.FloatRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringDef; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.SerializedName; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.geojson.Point; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Gives maneuver information about one {@link LegStep}. * * @since 1.0.0 */ @AutoValue public abstract class StepManeuver extends DirectionsJsonObject { /** * A basic turn in the direction of the modifier. * * @since 4.1.0 */ public static final String TURN = "turn"; /** * The road name changes (after a mandatory turn). * * @since 4.1.0 */ public static final String NEW_NAME = "new name"; /** * Indicates departure from a leg. * The modifier value indicates the position of the departure point * in relation to the current direction of travel. * * @since 4.1.0 */ public static final String DEPART = "depart"; /** * Indicates arrival to a destination of a leg. * The modifier value indicates the position of the arrival point * in relation to the current direction of travel. * * @since 4.1.0 */ public static final String ARRIVE = "arrive"; /** * Merge onto a street. * * @since 4.1.0 */ public static final String MERGE = "merge"; /** * Take a ramp to enter a highway. * @since 4.1.0 */ public static final String ON_RAMP = "on ramp"; /** * Take a ramp to exit a highway. * * @since 4.1.0 */ public static final String OFF_RAMP = "off ramp"; /** * Take the left or right side of a fork. * * @since 4.1.0 */ public static final String FORK = "fork"; /** * Road ends in a T intersection. * * @since 4.1.0 */ public static final String END_OF_ROAD = "end of road"; /** * Continue on a street after a turn. * * @since 4.1.0 */ public static final String CONTINUE = "continue"; /** * Traverse roundabout. * Has an additional property exit in the route step that contains * the exit number. The modifier specifies the direction of entering the roundabout. * * @since 4.1.0 */ public static final String ROUNDABOUT = "roundabout"; /** * A traffic circle. While very similar to a larger version of a roundabout, * it does not necessarily follow roundabout rules for right of way. * It can offer {@link LegStep#rotaryName()} parameters, * {@link LegStep#rotaryPronunciation()} ()} parameters, or both, * in addition to the {@link #exit()} property. * * @since 4.1.0 */ public static final String ROTARY = "rotary"; /** * A small roundabout that is treated as an intersection. * * @since 4.1.0 */ public static final String ROUNDABOUT_TURN = "roundabout turn"; /** * Indicates a change of driving conditions, for example changing the mode * from driving to ferry. * * @since 4.1.0 */ public static final String NOTIFICATION = "notification"; /** * Indicates the exit maneuver from a roundabout. * Will not appear in results unless you supply true to the {@link #exit()} query * parameter in the request. * * @since 4.1.0 */ public static final String EXIT_ROUNDABOUT = "exit roundabout"; /** * Indicates the exit maneuver from a rotary. * Will not appear in results unless you supply true * to the <tt>NbmapDirections.Builder#roundaboutExits()</tt> query parameter in the request. * * @since 4.1.0 */ public static final String EXIT_ROTARY = "exit rotary"; /** * Maneuver types. * * @since 4.1.0 */ @Retention(RetentionPolicy.CLASS) @StringDef( { TURN, NEW_NAME, DEPART, ARRIVE, MERGE, ON_RAMP, OFF_RAMP, FORK, END_OF_ROAD, CONTINUE, ROUNDABOUT, ROTARY, ROUNDABOUT_TURN, NOTIFICATION, EXIT_ROUNDABOUT, EXIT_ROTARY }) public @interface StepManeuverType { } /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_StepManeuver.Builder(); } /** * A {@link Point} representing this intersection location. * * @return GeoJson Point representing this intersection location * @since 3.0.0 */ @NonNull public Point location() { return Point.fromLngLat(rawLocation()[0], rawLocation()[1]); } /** * A {@link Point} representing this intersection location. Since the rawLocation isn't public, * it's okay to be mutable as long as nothing in this SDK changes values. * * @return GeoJson Point representing this intersection location * @since 3.0.0 */ @NonNull @SerializedName("location") @SuppressWarnings( {"mutable", "WeakerAccess"}) protected abstract double[] rawLocation(); /** * Number between 0 and 360 indicating the clockwise angle from true north to the direction of * travel right before the maneuver. * * @return double with value from 0 to 360 * @since 1.0.0 */ @Nullable @SerializedName("bearing_before") public abstract Double bearingBefore(); /** * Number between 0 and 360 indicating the clockwise angle from true north to the direction of * travel right after the maneuver. * * @return double with value from 0 to 360 * @since 1.0.0 */ @Nullable @SerializedName("bearing_after") public abstract Double bearingAfter(); /** * A human-readable instruction of how to execute the returned maneuver. This String is built * using OSRM-Text-Instructions and can be further customized inside either the Nbmap Navigation * SDK for Android or using the OSRM-Text-Instructions.java project in Project-OSRM. * * @return String with instruction * @see <a href='https://github.com/nbmap/nbmap-navigation-android'>Navigation SDK</a> * @see <a href='https://github.com/Project-OSRM/osrm-text-instructions.java'> * OSRM-Text-Instructions.java</a> * @since 1.0.0 */ @Nullable public abstract String instruction(); /** * This indicates the type of maneuver. * @see StepManeuverType * @return String with type of maneuver * @since 1.0.0 */ @Nullable @StepManeuverType public abstract String type(); /** * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the * change in direction accomplished through the turn. If the type is of depart/arrive, the * modifier indicates the position of waypoint from the current direction of travel. * * @return String with modifier * @since 1.0.0 */ @Nullable public abstract String modifier(); /** * An optional integer indicating number of the exit to take. If exit is undefined the destination * is on the roundabout. The property exists for the following type properties: * <p> * else - indicates the number of intersections passed until the turn. * roundabout - traverse roundabout * rotary - a traffic circle * </p> * * @return an integer indicating number of the exit to take * @since 2.0.0 */ @Nullable public abstract Integer exit(); /** * Convert the current {@link StepManeuver} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link StepManeuver}. * * @return a {@link StepManeuver.Builder} with the same values set to match the ones defined * in this {@link StepManeuver} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<StepManeuver> typeAdapter(Gson gson) { return new AutoValue_StepManeuver.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a StepManeuver * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static StepManeuver fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, StepManeuver.class); } /** * This builder can be used to set the values describing the {@link StepManeuver}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * The rawLocation as a double array. Once the {@link StepManeuver} object's created, this raw * location gets converted into a {@link Point} object and is public exposed as such. The double * array should have a length of two, index 0 being the longitude and index 1 being latitude. * * @param rawLocation a double array with a length of two, index 0 being the longitude and * index 1 being latitude. * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder rawLocation(@NonNull double[] rawLocation); /** * Number between 0 and 360 indicating the clockwise angle from true north to the direction of * travel right before the maneuver. * * @param bearingBefore double with value from 0 to 360 * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder bearingBefore( @Nullable @FloatRange(from = 0, to = 360) Double bearingBefore); /** * Number between 0 and 360 indicating the clockwise angle from true north to the direction of * travel right after the maneuver. * * @param bearingAfter double with value from 0 to 360 * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder bearingAfter( @Nullable @FloatRange(from = 0, to = 360) Double bearingAfter); /** * A human-readable instruction of how to execute the returned maneuver. This String is built * using OSRM-Text-Instructions and can be further customized inside either the Nbmap * Navigation SDK for Android or using the OSRM-Text-Instructions.java project in Project-OSRM. * * @param instruction String with instruction * @return this builder for chaining options together * @see <a href='https://github.com/nbmap/nbmap-navigation-android'>Navigation SDK</a> * @see <a href='https://github.com/Project-OSRM/osrm-text-instructions.java'>OSRM-Text-Instructions.java</a> * @since 3.0.0 */ public abstract Builder instruction(@Nullable String instruction); /** * This indicates the type of maneuver. See {@link StepManeuver#type()} for a full list of * options. * * @param type String with type of maneuver * @see StepManeuverType * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder type(@Nullable @StepManeuverType String type); /** * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the * change in direction accomplished through the turn. If the type is of depart/arrive, the * modifier indicates the position of waypoint from the current direction of travel. * * @param modifier String with modifier * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder modifier(@Nullable @ManeuverModifier.Type String modifier); /** * An optional integer indicating number of the exit to take. If exit is undefined the * destination is on the roundabout. The property exists for the following type properties: * <p> * else - indicates the number of intersections passed until the turn. * roundabout - traverse roundabout * rotary - a traffic circle * </p> * * @param exit an integer indicating number of the exit to take * @return this builder for chaining options together * @since 2.0.0 */ public abstract Builder exit(@Nullable Integer exit); /** * Build a new {@link StepManeuver} object. * * @return a new {@link StepManeuver} using the provided values in this builder * @since 3.0.0 */ public abstract StepManeuver build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/TollCollection.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.DirectionsCriteria; /** * An object containing information about a toll collection point along the route. * This is a payment booth or overhead electronic gantry * <a href="https://wiki.openstreetmap.org/wiki/Tag:barrier%3Dtoll_booth"> * payment booth or overhead electronic gantry</a> * where toll charge is collected. * Only available on the {@link DirectionsCriteria#PROFILE_DRIVING} profile. */ @AutoValue public abstract class TollCollection extends DirectionsJsonObject { /** * The type of toll collection point, either `toll_booth` or `toll_gantry`. * Note that adding new possible types is not considered a breaking change. */ @Nullable public abstract String type(); /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_TollCollection.Builder(); } /** * Convert the current {@link TollCollection} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link TollCollection}. * * @return a {@link Builder} with the same values set to match the ones defined in this {@link * TollCollection} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<TollCollection> typeAdapter(Gson gson) { return new AutoValue_TollCollection.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining an Incident * @return a new instance of this class defined by the values passed in the method */ public static TollCollection fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, TollCollection.class); } /** * This builder can be used to set the values describing the {@link TollCollection}. */ @AutoValue.Builder public abstract static class Builder { /** * The type of toll collection point, either `toll_booth` or `toll_gantry`. * Note that adding new possible types is not considered a breaking change. * * @param type toll collection type */ public abstract Builder type(@Nullable String type); /** * Build a new {@link TollCollection} object. * * @return a new {@link TollCollection} using the provided values in this builder */ public abstract TollCollection build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/VoiceInstructions.java
package com.nbmap.api.directions.v5.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; /** * This class provides information thats useful for properly making navigation announcements at the * correct time. Essentially, a distance and a string are given, using Turf Distance measurement * methods you can measure the users current location to the next steps maneuver point and if the * measured distance is less than the one the API provides, the announcement should be made. * * @since 3.0.0 */ @AutoValue public abstract class VoiceInstructions extends DirectionsJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 3.0.0 */ public static Builder builder() { return new AutoValue_VoiceInstructions.Builder(); } /** * This provides the missing piece in which is needed to announce instructions at accurate * times. If the user is less distance away from the maneuver than what this * {@code distanceAlongGeometry()} than, the announcement should be called. * * @return double value representing the distance to next maneuver in unit meters * @since 3.0.0 */ @Nullable public abstract Double distanceAlongGeometry(); /** * Provides the instruction string which was build on the server-side and can sometimes * concatenate instructions together if maneuver instructions are too close to each other. * * @return a string with the readable instructions ready to be read or displayed to a user * @since 3.0.0 */ @Nullable public abstract String announcement(); /** * Get the same instruction string you'd get from {@link #announcement()} but this one includes * Speech Synthesis Markup Language which helps voice synthesiser read information more humanely. * * @return a string with the SSML instructions * @since 3.0.0 */ @Nullable public abstract String ssmlAnnouncement(); /** * Convert the current {@link VoiceInstructions} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link VoiceInstructions}. * * @return a {@link VoiceInstructions.Builder} with the same values set to match the ones defined * in this {@link VoiceInstructions} * @since 3.1.0 */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 3.0.0 */ public static TypeAdapter<VoiceInstructions> typeAdapter(Gson gson) { return new AutoValue_VoiceInstructions.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a VoiceInstructions * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.4.0 */ public static VoiceInstructions fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, VoiceInstructions.class); } /** * This builder can be used to set the values describing the {@link VoiceInstructions}. * * @since 3.0.0 */ @AutoValue.Builder public abstract static class Builder { /** * Returns the missing piece in which is needed to announce instructions at accurate * times. If the user is less distance away from the maneuver than what this * {@code distanceAlongGeometry()} than, the announcement should be called. * * @param distanceAlongGeometry double value representing the distance to next maneuver in unit * meters * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder distanceAlongGeometry(Double distanceAlongGeometry); /** * Provides the instruction string which was build on the server-side and can sometimes * concatenate instructions together if maneuver instructions are too close to each other. * * @param announcement a string with the readable instructions ready to be read or displayed to * a user * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder announcement(String announcement); /** * Get the same instruction string you'd get from {@link #announcement()} but this one includes * Speech Synthesis Markup Language which helps voice synthesiser read information more * humanely. * * @param ssmlAnnouncement a string with the SSML instructions * @return this builder for chaining options together * @since 3.0.0 */ public abstract Builder ssmlAnnouncement(String ssmlAnnouncement); /** * This uses the provided parameters set using the {@link Builder} and creates a new instance of * {@link VoiceInstructions}. * * @return a new instance of Voice Instructions * @since 3.0.0 */ public abstract VoiceInstructions build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/models/package-info.java
/** * Contains models mapping to Nbmap Directions API. */ package com.nbmap.api.directions.v5.models;
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/utils/FormatUtils.java
package com.nbmap.api.directions.v5.utils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.nbmap.geojson.Point; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * Methods to convert models to Strings. */ public class FormatUtils { /** * Returns a string containing the tokens joined by delimiters. Doesn't remove trailing nulls. * * @param delimiter the delimiter on which to split. * @param tokens A list of objects to be joined. Strings will be formed from the objects by * calling object.toString(). * @return {@link String} */ @Nullable public static String join(@NonNull CharSequence delimiter, @Nullable List<?> tokens) { return join(delimiter, tokens, false); } /** * Returns a string containing the tokens joined by delimiters. * * @param delimiter the delimiter on which to split. * @param tokens A list of objects to be joined. Strings will be formed from the objects by * calling object.toString(). * @param removeTrailingNulls true if trailing nulls should be removed. * @return {@link String} */ @Nullable public static String join(@NonNull CharSequence delimiter, @Nullable List<?> tokens, boolean removeTrailingNulls) { if (tokens == null || tokens.size() < 1) { return null; } int lastNonNullToken = tokens.size() - 1; if (removeTrailingNulls) { for (int i = tokens.size() - 1; i >= 0; i--) { Object token = tokens.get(i); if (token != null) { break; } else { lastNonNullToken--; } } } StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (int i = 0; i <= lastNonNullToken; i++) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } Object token = tokens.get(i); if (token != null) { sb.append(token); } } return sb.toString(); } /** * Useful to remove any trailing zeros and prevent a coordinate being over 7 significant figures. * * @param coordinate a double value representing a coordinate. * @return a formatted string. */ @NonNull public static String formatCoordinate(double coordinate) { DecimalFormat decimalFormat = new DecimalFormat("0.######", new DecimalFormatSymbols(Locale.US)); return String.format(Locale.US, "%s", decimalFormat.format(coordinate)); } /** * Used in various APIs to format the user provided radiuses to a String matching the APIs * format. * * @param radiuses a list of doubles represents the radius values * @return a String ready for being passed into the Retrofit call */ @Nullable public static String formatRadiuses(@Nullable List<Double> radiuses) { if (radiuses == null || radiuses.size() == 0) { return null; } List<String> radiusesToJoin = new ArrayList<>(); for (Double radius : radiuses) { if (radius == null) { radiusesToJoin.add(null); } else if (radius == Double.POSITIVE_INFINITY) { radiusesToJoin.add("unlimited"); } else { radiusesToJoin.add(String.format(Locale.US, "%s", formatCoordinate(radius))); } } return join(";", radiusesToJoin); } /** * Formats the bearing variables from the raw values to a string which can than be used for the * request URL. * * @param bearings a List of list of doubles representing bearing values * @return a string with the bearing values */ @Nullable public static String formatBearings(@Nullable List<List<Double>> bearings) { if (bearings == null || bearings.isEmpty()) { return null; } List<String> bearingsToJoin = new ArrayList<>(); for (List<Double> bearing : bearings) { if (bearing == null) { bearingsToJoin.add(null); } else { if (bearing.size() != 2) { throw new RuntimeException("Bearing size should be 2."); } Double angle = bearing.get(0); Double tolerance = bearing.get(1); if (angle == null || tolerance == null) { bearingsToJoin.add(null); } else { if (angle < 0 || angle > 360 || tolerance < 0 || tolerance > 360) { throw new RuntimeException("Angle and tolerance have to be from 0 to 360."); } bearingsToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(angle), formatCoordinate(tolerance))); } } } return join(";", bearingsToJoin); } /** * Converts the list of integer arrays to a string ready for API consumption. * * @param distributions the list of integer arrays representing the distribution * @return a string with the distribution values */ @Nullable public static String formatDistributions(@Nullable List<Integer[]> distributions) { if (distributions == null || distributions.isEmpty()) { return null; } List<String> distributionsToJoin = new ArrayList<>(); for (Integer[] array : distributions) { if (array.length == 0) { distributionsToJoin.add(null); } else { distributionsToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(array[0]), formatCoordinate(array[1]))); } } return join(";", distributionsToJoin); } /** * Converts String list with approaches values to a string ready for API consumption. An approach * could be unrestricted, curb or null. * * @param approaches a list representing approaches to each coordinate. * @return a formatted string. */ @Nullable public static String formatApproaches(@Nullable List<String> approaches) { if (approaches == null || approaches.isEmpty()) { return null; } for (String approach : approaches) { if (approach != null && !approach.equals("unrestricted") && !approach.equals("curb") && !approach.isEmpty()) { return null; } } return join(";", approaches); } /** * Converts String list with waypoint_names values to a string ready for API consumption. * * @param waypointNames a string representing approaches to each coordinate. * @return a formatted string. */ @Nullable public static String formatWaypointNames(@Nullable List<String> waypointNames) { if (waypointNames == null || waypointNames.isEmpty()) { return null; } return join(";", waypointNames); } /** * Converts a list of Points to String. * * @param coordinates a list of coordinates. * @return a formatted string. */ @Nullable public static String formatCoordinates(@NonNull List<Point> coordinates) { List<String> coordinatesToJoin = new ArrayList<>(); for (Point point : coordinates) { coordinatesToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(point.longitude()), formatCoordinate(point.latitude()))); } return join(";", coordinatesToJoin); } /** * Converts array of Points with waypoint_targets values to a string ready for API consumption. * * @param points a list representing approaches to each coordinate. * @return a formatted string. */ @Nullable public static String formatPointsList(@Nullable List<Point> points) { if (points == null || points.isEmpty()) { return null; } List<String> coordinatesToJoin = new ArrayList<>(); for (Point point : points) { if (point == null) { coordinatesToJoin.add(null); } else { coordinatesToJoin.add(String.format(Locale.US, "%s,%s", formatCoordinate(point.longitude()), formatCoordinate(point.latitude()))); } } return join(";", coordinatesToJoin); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/utils/ParseUtils.java
package com.nbmap.api.directions.v5.utils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.nbmap.geojson.Point; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Methods to convert Strings to Lists of objects. */ public class ParseUtils { private static final String SEMICOLON = ";"; private static final String COMMA = ","; private static final String UNLIMITED = "unlimited"; private static final String TRUE = "true"; private static final String FALSE = "false"; /** * Parse a String to a list of Integers. * * @param original an original String. * @return List of Integers */ @Nullable public static List<Integer> parseToIntegers(@Nullable String original) { if (original == null) { return null; } List<Integer> integers = new ArrayList<>(); String[] strings = original.split(SEMICOLON); for (String index : strings) { if (index != null) { if (index.isEmpty()) { integers.add(null); } else { integers.add(Integer.valueOf(index)); } } } return integers; } /** * Parse a String to a list of Strings using ";" as a separator. * * @param original an original String. * @return List of Strings */ @Nullable public static List<String> parseToStrings(@Nullable String original) { return parseToStrings(original, SEMICOLON); } /** * Parse a String to a list of Strings. * * @param original an original String. * @param separator a String used as a separator. * @return List of Strings */ @Nullable public static List<String> parseToStrings(@Nullable String original, @NonNull String separator) { if (original == null) { return null; } List<String> result = new ArrayList<>(); String[] strings = original.split(separator, -1); for (String str : strings) { if (str != null) { if (str.isEmpty()) { result.add(null); } else { result.add(str); } } } return result; } /** * Parse a String to a list of Points. * * @param original an original String. * @return List of Points */ @Nullable public static List<Point> parseToPoints(@Nullable String original) { if (original == null) { return null; } List<Point> points = new ArrayList<>(); String[] targets = original.split(SEMICOLON, -1); for (String target : targets) { if (target != null) { if (target.isEmpty()) { points.add(null); } else { String[] point = target.split(COMMA); points.add(Point.fromLngLat(Double.valueOf(point[0]), Double.valueOf(point[1]))); } } } return points; } /** * Parse a String to a list of Points. * * @param original an original String. * @return List of Doubles */ @Nullable public static List<Double> parseToDoubles(@Nullable String original) { if (original == null) { return null; } List<Double> doubles = new ArrayList<>(); String[] strings = original.split(SEMICOLON, -1); for (String str : strings) { if (str != null) { if (str.isEmpty()) { doubles.add(null); } else if (str.equals(UNLIMITED)) { doubles.add(Double.POSITIVE_INFINITY); } else { doubles.add(Double.valueOf(str)); } } } return doubles; } /** * Parse a String to a list of list of Doubles. * * @param original an original String. * @return List of List of Doubles */ @Nullable public static List<List<Double>> parseToListOfListOfDoubles(@Nullable String original) { if (original == null) { return null; } List<List<Double>> result = new ArrayList<>(); String[] pairs = original.split(SEMICOLON, -1); for (String pair : pairs) { if (pair.isEmpty()) { result.add(null); } else { String[] values = pair.split(COMMA); if (values.length == 2) { result.add(Arrays.asList(Double.valueOf(values[0]), Double.valueOf(values[1]))); } } } return result; } /** * Parse a String to a list of Boolean. * * @param original an original String. * @return List of Booleans */ @Nullable public static List<Boolean> parseToBooleans(@Nullable String original) { if (original == null) { return null; } List<Boolean> booleans = new ArrayList<>(); if (original.isEmpty()) { return booleans; } String[] strings = original.split(SEMICOLON, -1); for (String str : strings) { if (str != null) { if (str.isEmpty()) { booleans.add(null); } else if (str.equalsIgnoreCase(TRUE)) { booleans.add(true); } else if (str.equalsIgnoreCase(FALSE)) { booleans.add(false); } else { booleans.add(null); } } } return booleans; } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5
java-sources/ai/nextbillion/nbmap-sdk-directions-models/0.1.2/com/nbmap/api/directions/v5/utils/package-info.java
/** * Contains classes with utilities useful for model classes. * */ package com.nbmap.api.directions.v5.utils;
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/DirectionsRefreshAdapterFactory.java
package com.nbmap.api.directionsrefresh.v1; import com.google.gson.TypeAdapterFactory; import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory; /** * Required so that AutoValue can generate specific type adapters when needed inside the direction * packages. */ @GsonTypeAdapterFactory public abstract class DirectionsRefreshAdapterFactory implements TypeAdapterFactory { /** * Creates a TypeAdapter that AutoValues uses to generate specific type adapters when needed * inside the direction package classes. */ public static TypeAdapterFactory create() { return new AutoValueGson_DirectionsRefreshAdapterFactory(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/package-info.java
/** * Contains classes for accessing the Directions Refresh API response. */ package com.nbmap.api.directionsrefresh.v1;
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/models/DirectionsRefreshJsonObject.java
package com.nbmap.api.directionsrefresh.v1.models; import com.google.gson.GsonBuilder; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directionsrefresh.v1.DirectionsRefreshAdapterFactory; import com.nbmap.geojson.Point; import com.nbmap.geojson.PointAsCoordinatesTypeAdapter; import java.io.Serializable; /** * Provides a base class for Directions model classes. */ public class DirectionsRefreshJsonObject implements Serializable { /** * This takes the currently defined values found inside this instance and converts it to a json * string. * * @return a JSON string which represents this DirectionsJsonObject */ public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter()); gson.registerTypeAdapterFactory(DirectionsRefreshAdapterFactory.create()); return gson.create().toJson(this); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/models/DirectionsRefreshResponse.java
package com.nbmap.api.directionsrefresh.v1.models; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directionsrefresh.v1.DirectionsRefreshAdapterFactory; /** * Response object for Directions Refresh requests. * * @since 4.4.0 */ @AutoValue public abstract class DirectionsRefreshResponse extends DirectionsRefreshJsonObject { /** * String indicating the state of the response. This is a separate code than the HTTP status code. * On normal valid responses, the value will be Ok. The possible responses are listed below: * <ul> * <li><strong>Ok</strong>:200 Normal success case</li> * <li><strong>NoRoute</strong>: 200 There was no route found for the given coordinates. Check * for impossible routes (e.g. routes over oceans without ferry connections).</li> * <li><strong>NoSegment</strong>: 200 No road segment could be matched for coordinates. Check for * coordinates too far away from a road.</li> * <li><strong>ProfileNotFound</strong>: 404 Use a valid profile as described above</li> * <li><strong>InvalidInput</strong>: 422</li> * </ul> * * @return a string with one of the given values described in the list above * @since 4.4.0 */ @NonNull public abstract String code(); /** * Optionally shows up in a response if an error or something unexpected occurred. * * @return a string containing the message * @since 4.4.0 */ @Nullable public abstract String message(); /** * Barebones {@link DirectionsRouteRefresh} which only contains a list of * {@link RouteLegRefresh}s, which only contain lists of the * refreshed annotations. * * @return barebones route with annotation data * @since 4.4.0 */ @Nullable public abstract DirectionsRouteRefresh route(); /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance * @since 4.4.0 */ @NonNull public static Builder builder() { return new AutoValue_DirectionsRefreshResponse.Builder(); } /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class * @since 4.4.0 */ public static TypeAdapter<DirectionsRefreshResponse> typeAdapter(Gson gson) { return new AutoValue_DirectionsRefreshResponse.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a Directions Refresh response * @return a new instance of this class defined by the values passed inside this static factory * method * @since 4.4.0 */ public static DirectionsRefreshResponse fromJson(String json) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(DirectionsRefreshAdapterFactory.create()) .registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gsonBuilder.create().fromJson(json, DirectionsRefreshResponse.class); } /** * This builder can be used to set the values describing the {@link DirectionsRefreshResponse}. * @since 4.4.0 */ @AutoValue.Builder public abstract static class Builder { /** * String indicating the state of the response. This is a separate code than the HTTP status * code. On normal valid responses, the value will be Ok. For a full list of possible responses, * see {@link DirectionsRefreshResponse#code()}. * * @param code a string with one of the given values described in the list above * @return this builder * @since 4.4.0 */ public abstract Builder code(String code); /** * Optionally shows up in a response if an error or something unexpected occurred. * * @param message a string containing the message * @return this builder * @since 4.4.0 */ public abstract Builder message(String message); /** * Barebones {@link DirectionsRouteRefresh} which only contains a list of * {@link RouteLegRefresh}s, which only contain lists of the * refreshed annotations. * * @param directionsRouteRefresh route containing annotation data * @return this builder * @since 4.4.0 */ public abstract Builder route(DirectionsRouteRefresh directionsRouteRefresh); /** * Builds a new {@link DirectionsRefreshResponse} object. * * @return a new {@link DirectionsRefreshResponse} object * @since 4.4.0 */ public abstract DirectionsRefreshResponse build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/models/DirectionsRouteRefresh.java
package com.nbmap.api.directionsrefresh.v1.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.models.DirectionsWaypoint; import com.nbmap.api.directionsrefresh.v1.DirectionsRefreshAdapterFactory; import java.util.List; /** * Detailed information about an individual route such as the duration, distance and geometry. */ @AutoValue public abstract class DirectionsRouteRefresh extends DirectionsRefreshJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_DirectionsRouteRefresh.Builder(); } /** * A Leg Refresh is an object contain refresh data between only two {@link DirectionsWaypoint}. * * @return list of {@link RouteLegRefresh} objects */ @Nullable public abstract List<RouteLegRefresh> legs(); /** * Convert the current {@link DirectionsRouteRefresh} to its builder holding the currently * assigned values. This allows you to modify a single property and then rebuild the object * resulting in an updated and modified {@link DirectionsRouteRefresh}. * * @return a {@link DirectionsRouteRefresh.Builder} with the same values set to match the ones * defined in this {@link DirectionsRouteRefresh} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<DirectionsRouteRefresh> typeAdapter(Gson gson) { return new AutoValue_DirectionsRouteRefresh.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a GeoJson Directions Route * @return a new instance of this class defined by the values passed inside this static factory * method */ public static DirectionsRouteRefresh fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsRefreshAdapterFactory.create()); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); return gson.create().fromJson(json, DirectionsRouteRefresh.class); } /** * This builder can be used to set the values describing the {@link DirectionsRouteRefresh}. */ @AutoValue.Builder public abstract static class Builder { /** * A Leg Refresh is an object contain refresh data between only two {@link DirectionsWaypoint}. * * @param legs list of {@link RouteLegRefresh} objects * @return this builder for chaining options together */ public abstract Builder legs(@Nullable List<RouteLegRefresh> legs); /** * Build a new {@link DirectionsRouteRefresh} object. * * @return a new {@link DirectionsRouteRefresh} using the provided values in this builder */ public abstract DirectionsRouteRefresh build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/models/RouteLegRefresh.java
package com.nbmap.api.directionsrefresh.v1.models; import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.api.directions.v5.DirectionsAdapterFactory; import com.nbmap.api.directions.v5.models.DirectionsWaypoint; import com.nbmap.api.directions.v5.models.LegAnnotation; import com.nbmap.api.directionsrefresh.v1.DirectionsRefreshAdapterFactory; /** * A route refresh data between only two {@link DirectionsWaypoint}. */ @AutoValue public abstract class RouteLegRefresh extends DirectionsRefreshJsonObject { /** * Create a new instance of this class by using the {@link Builder} class. * * @return this classes {@link Builder} for creating a new instance */ public static Builder builder() { return new AutoValue_RouteLegRefresh.Builder(); } /** * A {@link LegAnnotation} that contains additional details about each line segment along the * route geometry. If you'd like to receiving this, you must request it inside your Directions * request before executing the call. * * @return a {@link LegAnnotation} object */ @Nullable public abstract LegAnnotation annotation(); /** * Convert the current {@link RouteLegRefresh} to its builder holding the currently assigned * values. This allows you to modify a single property and then rebuild the object resulting in * an updated and modified {@link RouteLegRefresh}. * * @return a {@link RouteLegRefresh.Builder} with the same values set to match the ones defined * in this {@link RouteLegRefresh} */ public abstract Builder toBuilder(); /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the type adapter for this class */ public static TypeAdapter<RouteLegRefresh> typeAdapter(Gson gson) { return new AutoValue_RouteLegRefresh.GsonTypeAdapter(gson); } /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a RouteLeg * @return a new instance of this class defined by the values passed inside this static factory * method */ public static RouteLegRefresh fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); gson.registerTypeAdapterFactory(DirectionsRefreshAdapterFactory.create()); return gson.create().fromJson(json, RouteLegRefresh.class); } /** * This builder can be used to set the values describing the {@link RouteLegRefresh}. */ @AutoValue.Builder public abstract static class Builder { /** * A {@link LegAnnotation} that contains additional details about each line segment along the * route geometry. If you'd like to receiving this, you must request it inside your Directions * request before executing the call. * * @param annotation a {@link LegAnnotation} object * @return this builder for chaining options together */ public abstract Builder annotation(@Nullable LegAnnotation annotation); /** * Build a new {@link RouteLegRefresh} object. * * @return a new {@link RouteLegRefresh} using the provided values in this builder */ public abstract RouteLegRefresh build(); } }
0
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1
java-sources/ai/nextbillion/nbmap-sdk-directions-refresh-models/0.1.2/com/nbmap/api/directionsrefresh/v1/models/package-info.java
/** * Contains the model classes which represent the Directions Refresh API response. */ package com.nbmap.api.directionsrefresh.v1.models;
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/BaseCoordinatesTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.exception.GeoJsonException; import com.nbmap.geojson.shifter.CoordinateShifterManager; import com.nbmap.geojson.utils.GeoJsonUtils; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Base class for converting {@code T} instance of coordinates to JSON and * JSON to instance of {@code T}. * * @param <T> Type of coordinates * @since 4.6.0 */ @Keep abstract class BaseCoordinatesTypeAdapter<T> extends TypeAdapter<T> { protected void writePoint(JsonWriter out, Point point) throws IOException { if (point == null) { return; } writePointList(out, point.coordinates()); } protected Point readPoint(JsonReader in) throws IOException { List<Double> coordinates = readPointList(in); if (coordinates != null && coordinates.size() > 1) { return new Point("Point",null, coordinates); } throw new GeoJsonException(" Point coordinates should be non-null double array"); } protected void writePointList(JsonWriter out, List<Double> value) throws IOException { if (value == null) { return; } out.beginArray(); // Unshift coordinates List<Double> 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(); } protected List<Double> readPointList(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { throw new NullPointerException(); } List<Double> coordinates = new ArrayList<Double>(); 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)); } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/BaseGeometryTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.exception.GeoJsonException; import com.nbmap.geojson.gson.BoundingBoxTypeAdapter; import java.io.IOException; /** * Base class for converting {@code Geometry} instances to JSON and * JSON to instances of {@code Geometry}. * * @param <G> Geometry * @param <T> Type of coordinates * @since 4.6.0 */ @Keep abstract class BaseGeometryTypeAdapter<G, T> extends TypeAdapter<G> { private volatile TypeAdapter<String> stringAdapter; private volatile TypeAdapter<BoundingBox> boundingBoxAdapter; private volatile TypeAdapter<T> coordinatesAdapter; private final Gson gson; BaseGeometryTypeAdapter(Gson gson, TypeAdapter<T> coordinatesAdapter) { this.gson = gson; this.coordinatesAdapter = coordinatesAdapter; this.boundingBoxAdapter = new BoundingBoxTypeAdapter(); } public void writeCoordinateContainer(JsonWriter jsonWriter, CoordinateContainer<T> object) throws IOException { if (object == null) { jsonWriter.nullValue(); return; } jsonWriter.beginObject(); jsonWriter.name("type"); if (object.type() == null) { jsonWriter.nullValue(); } else { TypeAdapter<String> stringAdapter = this.stringAdapter; if (stringAdapter == null) { stringAdapter = gson.getAdapter(String.class); this.stringAdapter = stringAdapter; } stringAdapter.write(jsonWriter, object.type()); } jsonWriter.name("bbox"); if (object.bbox() == null) { jsonWriter.nullValue(); } else { TypeAdapter<BoundingBox> boundingBoxAdapter = this.boundingBoxAdapter; if (boundingBoxAdapter == null) { boundingBoxAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxAdapter = boundingBoxAdapter; } boundingBoxAdapter.write(jsonWriter, object.bbox()); } jsonWriter.name("coordinates"); if (object.coordinates() == null) { jsonWriter.nullValue(); } else { TypeAdapter<T> coordinatesAdapter = this.coordinatesAdapter; if (coordinatesAdapter == null) { throw new GeoJsonException("Coordinates type adapter is null"); } coordinatesAdapter.write(jsonWriter, object.coordinates()); } jsonWriter.endObject(); } public CoordinateContainer<T> readCoordinateContainer(JsonReader jsonReader) throws IOException { if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); return null; } jsonReader.beginObject(); String type = null; BoundingBox bbox = null; T coordinates = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); continue; } switch (name) { case "type": TypeAdapter<String> stringAdapter = this.stringAdapter; if (stringAdapter == null) { stringAdapter = gson.getAdapter(String.class); this.stringAdapter = stringAdapter; } type = stringAdapter.read(jsonReader); break; case "bbox": TypeAdapter<BoundingBox> boundingBoxAdapter = this.boundingBoxAdapter; if (boundingBoxAdapter == null) { boundingBoxAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxAdapter = boundingBoxAdapter; } bbox = boundingBoxAdapter.read(jsonReader); break; case "coordinates": TypeAdapter<T> coordinatesAdapter = this.coordinatesAdapter; if (coordinatesAdapter == null) { throw new GeoJsonException("Coordinates type adapter is null"); } coordinates = coordinatesAdapter.read(jsonReader); break; default: jsonReader.skipValue(); } } jsonReader.endObject(); return createCoordinateContainer(type, bbox, coordinates); } abstract CoordinateContainer<T> createCoordinateContainer(String type, BoundingBox bbox, T coordinates); }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/BoundingBox.java
package com.nbmap.geojson; import static com.nbmap.geojson.constants.GeoJsonConstants.MIN_LATITUDE; import static com.nbmap.geojson.constants.GeoJsonConstants.MIN_LONGITUDE; import androidx.annotation.FloatRange; import androidx.annotation.Keep; import androidx.annotation.NonNull; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.nbmap.geojson.constants.GeoJsonConstants; import com.nbmap.geojson.gson.BoundingBoxTypeAdapter; import java.io.Serializable; /** * A GeoJson object MAY have a member named "bbox" to include information on the coordinate range * for its Geometries, Features, or FeatureCollections. * <p> * This class simplifies the build process for creating a bounding box and working with them when * deserialized. specific parameter naming helps define which coordinates belong where when a * bounding box instance is being created. Note that since GeoJson objects only have the option of * including a bounding box JSON element, the {@code bbox} value returned by a GeoJson object might * be null. * <p> * At a minimum, a bounding box will have two {@link Point}s or four coordinates which define the * box. A 3rd dimensional bounding box can be produced if elevation or altitude is defined. * * @since 3.0.0 */ @Keep public class BoundingBox implements Serializable { private final Point southwest; private final Point northeast; /** * Create a new instance of this class by passing in a formatted valid JSON String. * * @param json a formatted valid JSON string defining a Bounding Box * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static BoundingBox fromJson(String json) { Gson gson = new GsonBuilder() .registerTypeAdapter(BoundingBox.class, new BoundingBoxTypeAdapter()) .create(); return gson.fromJson(json, BoundingBox.class); } /** * Define a new instance of this class by passing in two {@link Point}s, representing both the * southwest and northwest corners of the bounding box. * * @param southwest represents the bottom left corner of the bounding box when the camera is * pointing due north * @param northeast represents the top right corner of the bounding box when the camera is * pointing due north * @return a new instance of this class defined by the provided points * @since 3.0.0 */ public static BoundingBox fromPoints(@NonNull Point southwest, @NonNull Point northeast) { return new BoundingBox(southwest, northeast); } /** * Define a new instance of this class by passing in four coordinates in the same order they would * appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate * values which can exist and comply with the GeoJson spec. * * @param west the left side of the bounding box when the map is facing due north * @param south the bottom side of the bounding box when the map is facing due north * @param east the right side of the bounding box when the map is facing due north * @param north the top side of the bounding box when the map is facing due north * @return a new instance of this class defined by the provided coordinates * @since 3.0.0 * @deprecated As of 3.1.0, use {@link #fromLngLats} instead. */ @Deprecated public static BoundingBox fromCoordinates( @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double west, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double south, @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double east, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double north) { return fromLngLats(west, south, east, north); } /** * Define a new instance of this class by passing in four coordinates in the same order they would * appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate * values which can exist and comply with the GeoJson spec. * * @param west the left side of the bounding box when the map is facing due north * @param south the bottom side of the bounding box when the map is facing due north * @param southwestAltitude the southwest corner altitude or elevation when the map is facing due * north * @param east the right side of the bounding box when the map is facing due north * @param north the top side of the bounding box when the map is facing due north * @param northEastAltitude the northeast corner altitude or elevation when the map is facing due * north * @return a new instance of this class defined by the provided coordinates * @since 3.0.0 * @deprecated As of 3.1.0, use {@link #fromLngLats} instead. * */ @Deprecated public static BoundingBox fromCoordinates( @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double west, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double south, double southwestAltitude, @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double east, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double north, double northEastAltitude) { return fromLngLats(west, south, southwestAltitude, east, north, northEastAltitude); } /** * Define a new instance of this class by passing in four coordinates in the same order they would * appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate * values which can exist and comply with the GeoJson spec. * * @param west the left side of the bounding box when the map is facing due north * @param south the bottom side of the bounding box when the map is facing due north * @param east the right side of the bounding box when the map is facing due north * @param north the top side of the bounding box when the map is facing due north * @return a new instance of this class defined by the provided coordinates * @since 3.1.0 */ public static BoundingBox fromLngLats( @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double west, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double south, @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double east, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double north) { return new BoundingBox(Point.fromLngLat(west, south), Point.fromLngLat(east, north)); } /** * Define a new instance of this class by passing in four coordinates in the same order they would * appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate * values which can exist and comply with the GeoJson spec. * * @param west the left side of the bounding box when the map is facing due north * @param south the bottom side of the bounding box when the map is facing due north * @param southwestAltitude the southwest corner altitude or elevation when the map is facing due * north * @param east the right side of the bounding box when the map is facing due north * @param north the top side of the bounding box when the map is facing due north * @param northEastAltitude the northeast corner altitude or elevation when the map is facing due * north * @return a new instance of this class defined by the provided coordinates * @since 3.1.0 */ public static BoundingBox fromLngLats( @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double west, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double south, double southwestAltitude, @FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double east, @FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double north, double northEastAltitude) { return new BoundingBox( Point.fromLngLat(west, south, southwestAltitude), Point.fromLngLat(east, north, northEastAltitude)); } BoundingBox(Point southwest, Point northeast) { if (southwest == null) { throw new NullPointerException("Null southwest"); } this.southwest = southwest; if (northeast == null) { throw new NullPointerException("Null northeast"); } this.northeast = northeast; } /** * Provides the {@link Point} which represents the southwest corner of this bounding box when the * map is facing due north. * * @return a {@link Point} which defines this bounding boxes southwest corner * @since 3.0.0 */ @NonNull public Point southwest() { return southwest; } /** * Provides the {@link Point} which represents the northeast corner of this bounding box when the * map is facing due north. * * @return a {@link Point} which defines this bounding boxes northeast corner * @since 3.0.0 */ @NonNull public Point northeast() { return northeast; } /** * Convenience method for getting the bounding box most westerly point (longitude) as a double * coordinate. * * @return the most westerly coordinate inside this bounding box * @since 3.0.0 */ public final double west() { return southwest().longitude(); } /** * Convenience method for getting the bounding box most southerly point (latitude) as a double * coordinate. * * @return the most southerly coordinate inside this bounding box * @since 3.0.0 */ public final double south() { return southwest().latitude(); } /** * Convenience method for getting the bounding box most easterly point (longitude) as a double * coordinate. * * @return the most easterly coordinate inside this bounding box * @since 3.0.0 */ public final double east() { return northeast().longitude(); } /** * Convenience method for getting the bounding box most westerly point (longitude) as a double * coordinate. * * @return the most westerly coordinate inside this bounding box * @since 3.0.0 */ public final double north() { return northeast().latitude(); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<BoundingBox> typeAdapter(Gson gson) { return new BoundingBoxTypeAdapter(); } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this Bounding box * @since 3.0.0 */ public final String toJson() { Gson gson = new GsonBuilder() .registerTypeAdapter(BoundingBox.class, new BoundingBoxTypeAdapter()) .create(); return gson.toJson(this, BoundingBox.class); } @Override public String toString() { return "BoundingBox{" + "southwest=" + southwest + ", " + "northeast=" + northeast + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof BoundingBox) { BoundingBox that = (BoundingBox) obj; return (this.southwest.equals(that.southwest())) && (this.northeast.equals(that.northeast())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= southwest.hashCode(); hashCode *= 1000003; hashCode ^= northeast.hashCode(); return hashCode; } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/CoordinateContainer.java
package com.nbmap.geojson; import androidx.annotation.Keep; /** * Each of the s geometries which make up GeoJson implement this interface and consume a varying * dimension of {@link Point} list. Since this is varying, each geometry object fulfills the * contract by replacing the generic with a well defined list of Points. * * @param <T> a generic allowing varying dimensions for each GeoJson geometry * @since 3.0.0 */ @Keep public interface CoordinateContainer<T> extends Geometry { /** * the coordinates which define the geometry. Typically a list of points but for some geometry * such as polygon this can be a list of a list of points, thus the return is generic here. * * @return the {@link Point}s which make up the coordinates defining the geometry * @since 3.0.0 */ T coordinates(); }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/Feature.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.BoundingBoxTypeAdapter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; /** * This defines a GeoJson Feature object which represents a spatially bound thing. Every Feature * object is a GeoJson object no matter where it occurs in a GeoJson text. A Feature object will * always have a "TYPE" member with the value "Feature". * <p> * A Feature object has a member with the name "geometry". The value of the geometry member SHALL be * either a Geometry object or, in the case that the Feature is unlocated, a JSON null value. * <p> * A Feature object has a member with the name "properties". The value of the properties member is * an object (any JSON object or a JSON null value). * <p> * If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of * the Feature object through the {@link #id()} method, and the value of this member is either a * JSON string or number. * <p> * An example of a serialized feature is given below: * <pre> * { * "TYPE": "Feature", * "geometry": { * "TYPE": "Point", * "coordinates": [102.0, 0.5] * }, * "properties": { * "prop0": "value0" * } * </pre> * * @since 1.0.0 */ @Keep public final class Feature implements GeoJson { private static final String TYPE = "Feature"; private final String type; @JsonAdapter(BoundingBoxTypeAdapter.class) private final BoundingBox bbox; private final String id; private final Geometry geometry; private final JsonObject properties; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a Feature object from scratch it is better to use one of the other provided static * factory methods such as {@link #fromGeometry(Geometry)}. * * @param json a formatted valid JSON string defining a GeoJson Feature * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Feature fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); gson.registerTypeAdapterFactory(GeometryAdapterFactory.create()); Feature feature = gson.create().fromJson(json, Feature.class); // Even thought properties are Nullable, // Feature object will be created with properties set to an empty object, // so that addProperties() would work if (feature.properties() != null) { return feature; } return new Feature(TYPE, feature.bbox(), feature.id(), feature.geometry(), new JsonObject()); } /** * Create a new instance of this class by giving the feature a {@link Geometry}. * * @param geometry a single geometry which makes up this feature object * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Feature fromGeometry(@Nullable Geometry geometry) { return new Feature(TYPE, null, null, geometry, new JsonObject()); } /** * Create a new instance of this class by giving the feature a {@link Geometry}. You can also pass * in a double array defining a bounding box. * * @param geometry a single geometry which makes up this feature object * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Feature fromGeometry(@Nullable Geometry geometry, @Nullable BoundingBox bbox) { return new Feature(TYPE, bbox, null, geometry, new JsonObject()); } /** * Create a new instance of this class by giving the feature a {@link Geometry} and optionally a * set of properties. * * @param geometry a single geometry which makes up this feature object * @param properties a {@link JsonObject} containing the feature properties * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Feature fromGeometry(@Nullable Geometry geometry, @Nullable JsonObject properties) { return new Feature(TYPE, null, null, geometry, properties == null ? new JsonObject() : properties); } /** * Create a new instance of this class by giving the feature a {@link Geometry}, optionally a * set of properties, and optionally pass in a bbox. * * @param geometry a single geometry which makes up this feature object * @param bbox optionally include a bbox definition as a double array * @param properties a {@link JsonObject} containing the feature properties * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Feature fromGeometry(@Nullable Geometry geometry, @Nullable JsonObject properties, @Nullable BoundingBox bbox) { return new Feature(TYPE, bbox, null, geometry, properties == null ? new JsonObject() : properties); } /** * Create a new instance of this class by giving the feature a {@link Geometry}, optionally a * set of properties, and a String which represents the objects id. * * @param geometry a single geometry which makes up this feature object * @param properties a {@link JsonObject} containing the feature properties * @param id common identifier of this feature * @return {@link Feature} * @since 1.0.0 */ public static Feature fromGeometry(@Nullable Geometry geometry, @Nullable JsonObject properties, @Nullable String id) { return new Feature(TYPE, null, id, geometry, properties == null ? new JsonObject() : properties); } /** * Create a new instance of this class by giving the feature a {@link Geometry}, optionally a * set of properties, and a String which represents the objects id. * * @param geometry a single geometry which makes up this feature object * @param properties a {@link JsonObject} containing the feature properties * @param bbox optionally include a bbox definition as a double array * @param id common identifier of this feature * @return {@link Feature} * @since 1.0.0 */ public static Feature fromGeometry(@Nullable Geometry geometry, @NonNull JsonObject properties, @Nullable String id, @Nullable BoundingBox bbox) { return new Feature(TYPE, bbox, id, geometry, properties == null ? new JsonObject() : properties); } Feature(String type, @Nullable BoundingBox bbox, @Nullable String id, @Nullable Geometry geometry, @Nullable JsonObject properties) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; this.id = id; this.geometry = geometry; this.properties = properties; } /** * This describes the TYPE of GeoJson geometry this object is, thus this will always return * {@link Feature}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code Feature} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * A feature may have a commonly used identifier which is either a unique String or number. * * @return a String containing this features unique identification or null if one wasn't given * during creation. * @since 1.0.0 */ @Nullable public String id() { return id; } /** * The geometry which makes up this feature. A Geometry object represents points, curves, and * surfaces in coordinate space. One of the seven geometries provided inside this library can be * passed in through one of the static factory methods. * * @return a single defined {@link Geometry} which makes this feature spatially aware * @since 1.0.0 */ @Nullable public Geometry geometry() { return geometry; } /** * This contains the JSON object which holds the feature properties. The value of the properties * member is a {@link JsonObject} and might be empty if no properties are provided. * * @return a {@link JsonObject} which holds this features current properties * @since 1.0.0 */ @Nullable public JsonObject properties() { return properties; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this Feature * @since 1.0.0 */ @Override public String toJson() { Gson gson = new GsonBuilder() .registerTypeAdapterFactory(GeoJsonAdapterFactory.create()) .registerTypeAdapterFactory(GeometryAdapterFactory.create()) .create(); // Empty properties -> should not appear in json string Feature feature = this; if (properties().size() == 0) { feature = new Feature(TYPE, bbox(), id(), geometry(), null); } return gson.toJson(feature); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<Feature> typeAdapter(Gson gson) { return new Feature.GsonTypeAdapter(gson); } /** * Convenience method to add a String member. * * @param key name of the member * @param value the String value associated with the member * @since 1.0.0 */ public void addStringProperty(String key, String value) { properties().addProperty(key, value); } /** * Convenience method to add a Number member. * * @param key name of the member * @param value the Number value associated with the member * @since 1.0.0 */ public void addNumberProperty(String key, Number value) { properties().addProperty(key, value); } /** * Convenience method to add a Boolean member. * * @param key name of the member * @param value the Boolean value associated with the member * @since 1.0.0 */ public void addBooleanProperty(String key, Boolean value) { properties().addProperty(key, value); } /** * Convenience method to add a Character member. * * @param key name of the member * @param value the Character value associated with the member * @since 1.0.0 */ public void addCharacterProperty(String key, Character value) { properties().addProperty(key, value); } /** * Convenience method to add a JsonElement member. * * @param key name of the member * @param value the JsonElement value associated with the member * @since 1.0.0 */ public void addProperty(String key, JsonElement value) { properties().add(key, value); } /** * Convenience method to get a String member. * * @param key name of the member * @return the value of the member, null if it doesn't exist * @since 1.0.0 */ public String getStringProperty(String key) { JsonElement propertyKey = properties().get(key); return propertyKey == null ? null : propertyKey.getAsString(); } /** * Convenience method to get a Number member. * * @param key name of the member * @return the value of the member, null if it doesn't exist * @since 1.0.0 */ public Number getNumberProperty(String key) { JsonElement propertyKey = properties().get(key); return propertyKey == null ? null : propertyKey.getAsNumber(); } /** * Convenience method to get a Boolean member. * * @param key name of the member * @return the value of the member, null if it doesn't exist * @since 1.0.0 */ public Boolean getBooleanProperty(String key) { JsonElement propertyKey = properties().get(key); return propertyKey == null ? null : propertyKey.getAsBoolean(); } /** * Convenience method to get a Character member. * * @param key name of the member * @return the value of the member, null if it doesn't exist * @since 1.0.0 */ public Character getCharacterProperty(String key) { JsonElement propertyKey = properties().get(key); return propertyKey == null ? null : propertyKey.getAsCharacter(); } /** * Convenience method to get a JsonElement member. * * @param key name of the member * @return the value of the member, null if it doesn't exist * @since 1.0.0 */ public JsonElement getProperty(String key) { return properties().get(key); } /** * Removes the property from the object properties. * * @param key name of the member * @return Removed {@code property} from the key string passed in through the parameter. * @since 1.0.0 */ public JsonElement removeProperty(String key) { return properties().remove(key); } /** * Convenience method to check if a member with the specified name is present in this object. * * @param key name of the member * @return true if there is the member has the specified name, false otherwise. * @since 1.0.0 */ public boolean hasProperty(String key) { return properties().has(key); } /** * Convenience method to check for a member by name as well as non-null value. * * @param key name of the member * @return true if member is present with non-null value, false otherwise. * @since 1.3.0 */ public boolean hasNonNullValueForProperty(String key) { return hasProperty(key) && !getProperty(key).isJsonNull(); } @Override public String toString() { return "Feature{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "id=" + id + ", " + "geometry=" + geometry + ", " + "properties=" + properties + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Feature) { Feature that = (Feature) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && ((this.id == null) ? (that.id() == null) : this.id.equals(that.id())) && ((this.geometry == null) ? (that.geometry() == null) : this.geometry.equals(that.geometry())) && ((this.properties == null) ? (that.properties() == null) : this.properties.equals(that.properties())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= (id == null) ? 0 : id.hashCode(); hashCode *= 1000003; hashCode ^= (geometry == null) ? 0 : geometry.hashCode(); hashCode *= 1000003; hashCode ^= (properties == null) ? 0 : properties.hashCode(); return hashCode; } /** * TypeAdapter to serialize/deserialize Feature objects. * * @since 4.6.0 */ static final class GsonTypeAdapter extends TypeAdapter<Feature> { private volatile TypeAdapter<String> stringTypeAdapter; private volatile TypeAdapter<BoundingBox> boundingBoxTypeAdapter; private volatile TypeAdapter<Geometry> geometryTypeAdapter; private volatile TypeAdapter<JsonObject> jsonObjectTypeAdapter; private final Gson gson; GsonTypeAdapter(Gson gson) { this.gson = gson; } @Override public void write(JsonWriter jsonWriter, Feature object) throws IOException { if (object == null) { jsonWriter.nullValue(); return; } jsonWriter.beginObject(); jsonWriter.name("type"); if (object.type() == null) { jsonWriter.nullValue(); } else { TypeAdapter<String> stringTypeAdapter = this.stringTypeAdapter; if (stringTypeAdapter == null) { stringTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = stringTypeAdapter; } stringTypeAdapter.write(jsonWriter, object.type()); } jsonWriter.name("bbox"); if (object.bbox() == null) { jsonWriter.nullValue(); } else { TypeAdapter<BoundingBox> boundingBoxTypeAdapter = this.boundingBoxTypeAdapter; if (boundingBoxTypeAdapter == null) { boundingBoxTypeAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxTypeAdapter = boundingBoxTypeAdapter; } boundingBoxTypeAdapter.write(jsonWriter, object.bbox()); } jsonWriter.name("id"); if (object.id() == null) { jsonWriter.nullValue(); } else { TypeAdapter<String> stringTypeAdapter = this.stringTypeAdapter; if (stringTypeAdapter == null) { stringTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = stringTypeAdapter; } stringTypeAdapter.write(jsonWriter, object.id()); } jsonWriter.name("geometry"); if (object.geometry() == null) { jsonWriter.nullValue(); } else { TypeAdapter<Geometry> geometryTypeAdapter = this.geometryTypeAdapter; if (geometryTypeAdapter == null) { geometryTypeAdapter = gson.getAdapter(Geometry.class); this.geometryTypeAdapter = geometryTypeAdapter; } geometryTypeAdapter.write(jsonWriter, object.geometry()); } jsonWriter.name("properties"); if (object.properties() == null) { jsonWriter.nullValue(); } else { TypeAdapter<JsonObject> jsonObjectTypeAdapter = this.jsonObjectTypeAdapter; if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = gson.getAdapter(JsonObject.class); this.jsonObjectTypeAdapter = jsonObjectTypeAdapter; } jsonObjectTypeAdapter.write(jsonWriter, object.properties()); } jsonWriter.endObject(); } @Override public Feature read(JsonReader jsonReader) throws IOException { if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); return null; } jsonReader.beginObject(); String type = null; BoundingBox bbox = null; String id = null; Geometry geometry = null; JsonObject properties = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); continue; } switch (name) { case "type": TypeAdapter<String> strTypeAdapter = this.stringTypeAdapter; if (strTypeAdapter == null) { strTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = strTypeAdapter; } type = strTypeAdapter.read(jsonReader); break; case "bbox": TypeAdapter<BoundingBox> boundingBoxTypeAdapter = this.boundingBoxTypeAdapter; if (boundingBoxTypeAdapter == null) { boundingBoxTypeAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxTypeAdapter = boundingBoxTypeAdapter; } bbox = boundingBoxTypeAdapter.read(jsonReader); break; case "id": strTypeAdapter = this.stringTypeAdapter; if (strTypeAdapter == null) { strTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = strTypeAdapter; } id = strTypeAdapter.read(jsonReader); break; case "geometry": TypeAdapter<Geometry> geometryTypeAdapter = this.geometryTypeAdapter; if (geometryTypeAdapter == null) { geometryTypeAdapter = gson.getAdapter(Geometry.class); this.geometryTypeAdapter = geometryTypeAdapter; } geometry = geometryTypeAdapter.read(jsonReader); break; case "properties": TypeAdapter<JsonObject> jsonObjectTypeAdapter = this.jsonObjectTypeAdapter; if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = gson.getAdapter(JsonObject.class); this.jsonObjectTypeAdapter = jsonObjectTypeAdapter; } properties = jsonObjectTypeAdapter.read(jsonReader); break; default: jsonReader.skipValue(); } } jsonReader.endObject(); return new Feature(type, bbox, id, geometry, properties); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/FeatureCollection.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.BoundingBoxTypeAdapter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; import java.util.Arrays; import java.util.List; /** * This represents a GeoJson Feature Collection which holds a list of {@link Feature} objects (when * serialized the feature list becomes a JSON array). * <p> * Note that the feature list could potentially be empty. Features within the list must follow the * specifications defined inside the {@link Feature} class. * <p> * An example of a Feature Collections given below: * <pre> * { * "TYPE": "FeatureCollection", * "bbox": [100.0, 0.0, -100.0, 105.0, 1.0, 0.0], * "features": [ * //... * ] * } * </pre> * * @since 1.0.0 */ @Keep public final class FeatureCollection implements GeoJson { private static final String TYPE = "FeatureCollection"; private final String type; @JsonAdapter(BoundingBoxTypeAdapter.class) private final BoundingBox bbox; private final List<Feature> features; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a FeatureCollection object from scratch it is better to use one of the other provided * static factory methods such as {@link #fromFeatures(List)}. * * @param json a formatted valid JSON string defining a GeoJson Feature Collection * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static FeatureCollection fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); gson.registerTypeAdapterFactory(GeometryAdapterFactory.create()); return gson.create().fromJson(json, FeatureCollection.class); } /** * Create a new instance of this class by giving the feature collection an array of * {@link Feature}s. The array of features itself isn't null but it can be empty and have a length * of 0. * * @param features an array of features * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static FeatureCollection fromFeatures(@NonNull Feature[] features) { return new FeatureCollection(TYPE, null, Arrays.asList(features)); } /** * Create a new instance of this class by giving the feature collection a list of * {@link Feature}s. The list of features itself isn't null but it can empty and have a size of 0. * * @param features a list of features * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static FeatureCollection fromFeatures(@NonNull List<Feature> features) { return new FeatureCollection(TYPE, null, features); } /** * Create a new instance of this class by giving the feature collection an array of * {@link Feature}s. The array of features itself isn't null but it can be empty and have a length * of 0. * * @param features an array of features * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static FeatureCollection fromFeatures(@NonNull Feature[] features, @Nullable BoundingBox bbox) { return new FeatureCollection(TYPE, bbox, Arrays.asList(features)); } /** * Create a new instance of this class by giving the feature collection a list of * {@link Feature}s. The list of features itself isn't null but it can be empty and have a size of * 0. * * @param features a list of features * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static FeatureCollection fromFeatures(@NonNull List<Feature> features, @Nullable BoundingBox bbox) { return new FeatureCollection(TYPE, bbox, features); } /** * Create a new instance of this class by giving the feature collection a single {@link Feature}. * * @param feature a single feature * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static FeatureCollection fromFeature(@NonNull Feature feature) { List<Feature> featureList = Arrays.asList(feature); return new FeatureCollection(TYPE, null, featureList); } /** * Create a new instance of this class by giving the feature collection a single {@link Feature}. * * @param feature a single feature * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static FeatureCollection fromFeature(@NonNull Feature feature, @Nullable BoundingBox bbox) { List<Feature> featureList = Arrays.asList(feature); return new FeatureCollection(TYPE, bbox, featureList); } FeatureCollection(String type, @Nullable BoundingBox bbox, @Nullable List<Feature> features) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; this.features = features; } /** * This describes the type of GeoJson this object is, thus this will always return * {@link FeatureCollection}. * * @return a String which describes the TYPE of GeoJson, for this object it will always return * {@code FeatureCollection} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * This provides the list of feature making up this Feature Collection. Note that if the * FeatureCollection was created through {@link #fromJson(String)} this list could be null. * Otherwise, the list can't be null but the size of the list can equal 0. * * @return a list of {@link Feature}s which make up this Feature Collection * @since 1.0.0 */ @Nullable public List<Feature> features() { return features; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this Feature Collection * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); gson.registerTypeAdapterFactory(GeometryAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<FeatureCollection> typeAdapter(Gson gson) { return new FeatureCollection.GsonTypeAdapter(gson); } @Override public String toString() { return "FeatureCollection{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "features=" + features + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof FeatureCollection) { FeatureCollection that = (FeatureCollection) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && ((this.features == null) ? (that.features() == null) : this.features.equals(that.features())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= (features == null) ? 0 : features.hashCode(); return hashCode; } /** * TypeAdapter to serialize/deserialize FeatureCollection objects. * * @since 4.6.0 */ static final class GsonTypeAdapter extends TypeAdapter<FeatureCollection> { private volatile TypeAdapter<String> stringAdapter; private volatile TypeAdapter<BoundingBox> boundingBoxAdapter; private volatile TypeAdapter<List<Feature>> listFeatureAdapter; private final Gson gson; GsonTypeAdapter(Gson gson) { this.gson = gson; } @Override public void write(JsonWriter jsonWriter, FeatureCollection object) throws IOException { if (object == null) { jsonWriter.nullValue(); return; } jsonWriter.beginObject(); jsonWriter.name("type"); if (object.type() == null) { jsonWriter.nullValue(); } else { TypeAdapter<String> stringAdapter = this.stringAdapter; if (stringAdapter == null) { stringAdapter = gson.getAdapter(String.class); this.stringAdapter = stringAdapter; } stringAdapter.write(jsonWriter, object.type()); } jsonWriter.name("bbox"); if (object.bbox() == null) { jsonWriter.nullValue(); } else { TypeAdapter<BoundingBox> boundingBoxTypeAdapter = this.boundingBoxAdapter; if (boundingBoxTypeAdapter == null) { boundingBoxTypeAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxAdapter = boundingBoxTypeAdapter; } boundingBoxTypeAdapter.write(jsonWriter, object.bbox()); } jsonWriter.name("features"); if (object.features() == null) { jsonWriter.nullValue(); } else { TypeAdapter<List<Feature>> listFeatureAdapter = this.listFeatureAdapter; if (listFeatureAdapter == null) { TypeToken typeToken = TypeToken.getParameterized(List.class, Feature.class); listFeatureAdapter = (TypeAdapter<List<Feature>>) gson.getAdapter(typeToken); this.listFeatureAdapter = listFeatureAdapter; } listFeatureAdapter.write(jsonWriter, object.features()); } jsonWriter.endObject(); } @Override public FeatureCollection read(JsonReader jsonReader) throws IOException { if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); return null; } jsonReader.beginObject(); String type = null; BoundingBox bbox = null; List<Feature> features = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); continue; } switch (name) { case "type": TypeAdapter<String> stringAdapter = this.stringAdapter; if (stringAdapter == null) { stringAdapter = gson.getAdapter(String.class); this.stringAdapter = stringAdapter; } type = stringAdapter.read(jsonReader); break; case "bbox": TypeAdapter<BoundingBox> boundingBoxAdapter = this.boundingBoxAdapter; if (boundingBoxAdapter == null) { boundingBoxAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxAdapter = boundingBoxAdapter; } bbox = boundingBoxAdapter.read(jsonReader); break; case "features": TypeAdapter<List<Feature>> listFeatureAdapter = this.listFeatureAdapter; if (listFeatureAdapter == null) { TypeToken typeToken = TypeToken.getParameterized(List.class, Feature.class); listFeatureAdapter = (TypeAdapter<List<Feature>>) gson.getAdapter(typeToken); this.listFeatureAdapter = listFeatureAdapter; } features = listFeatureAdapter.read(jsonReader); break; default: jsonReader.skipValue(); } } jsonReader.endObject(); return new FeatureCollection(type, bbox, features); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/GeoJson.java
package com.nbmap.geojson; import androidx.annotation.Keep; import java.io.Serializable; /** * Generic implementation for all GeoJson objects defining common traits that each GeoJson object * has. This logic is carried over to {@link Geometry} which is an interface which all seven GeoJson * geometries implement. * * @since 1.0.0 */ @Keep public interface GeoJson extends Serializable { /** * This describes the type of GeoJson geometry, Feature, or FeatureCollection this object is. * Every GeoJson Object will have this defined once an instance is created and will never return * null. * * @return a String which describes the type of geometry, for this object it will always return * {@code Feature} * @since 1.0.0 */ String type(); /** * This takes the currently defined values found inside the GeoJson instance and converts it to a * GeoJson string. * * @return a JSON string which represents this Feature * @since 1.0.0 */ String toJson(); /** * A GeoJson object MAY have a member named "bbox" to include information on the coordinate range * for its Geometries, Features, or FeatureCollections. 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. * * @return a double array with the length 2*n where n is the number of dimensions represented in * the contained geometries * @since 3.0.0 */ BoundingBox bbox(); }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/Geometry.java
package com.nbmap.geojson; import androidx.annotation.Keep; /** * Each of the six geometries and {@link GeometryCollection} * which make up GeoJson implement this interface. * * @since 1.0.0 */ @Keep public interface Geometry extends GeoJson { }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/GeometryAdapterFactory.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.TypeAdapterFactory; import com.nbmap.geojson.internal.typeadapters.RuntimeTypeAdapterFactory; /** * A Geometry type adapter factory for convenience for serialization/deserialization. * @since 4.6.0 */ @Keep public abstract class GeometryAdapterFactory implements TypeAdapterFactory { private static TypeAdapterFactory geometryTypeFactory; /** * Create a new instance of Geometry type adapter factory, this is passed into the Gson * Builder. * * @return a new GSON TypeAdapterFactory * @since 4.4.0 */ public static TypeAdapterFactory create() { if (geometryTypeFactory == null) { geometryTypeFactory = RuntimeTypeAdapterFactory.of(Geometry.class, "type", true) .registerSubtype(GeometryCollection.class, "GeometryCollection") .registerSubtype(Point.class, "Point") .registerSubtype(MultiPoint.class, "MultiPoint") .registerSubtype(LineString.class, "LineString") .registerSubtype(MultiLineString.class, "MultiLineString") .registerSubtype(Polygon.class, "Polygon") .registerSubtype(MultiPolygon.class, "MultiPolygon"); } return geometryTypeFactory; } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/GeometryCollection.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; import java.util.Arrays; import java.util.List; /** * A GeoJson object with TYPE "GeometryCollection" is a Geometry object. * <p> * A GeometryCollection has a member with the name "geometries". The value of "geometries" is a List * Each element of this list is a GeoJson Geometry object. It is possible for this list to be empty. * <p> * Unlike the other geometry types, a GeometryCollection can be a heterogeneous composition of * smaller Geometry objects. For example, a Geometry object in the shape of a lowercase roman "i" * can be composed of one point and one LineString. * <p> * GeometryCollections have a different syntax from single TYPE Geometry objects (Point, * LineString, and Polygon) and homogeneously typed multipart Geometry objects (MultiPoint, * MultiLineString, and MultiPolygon) but have no different semantics. Although a * GeometryCollection object has no "coordinates" member, it does have coordinates: the coordinates * of all its parts belong to the collection. The "geometries" member of a GeometryCollection * describes the parts of this composition. Implementations SHOULD NOT apply any additional * semantics to the "geometries" array. * <p> * To maximize interoperability, implementations SHOULD avoid nested GeometryCollections. * Furthermore, GeometryCollections composed of a single part or a number of parts of a single TYPE * SHOULD be avoided when that single part or a single object of multipart TYPE (MultiPoint, * MultiLineString, or MultiPolygon) could be used instead. * <p> * An example of a serialized GeometryCollections given below: * <pre> * { * "TYPE": "GeometryCollection", * "geometries": [{ * "TYPE": "Point", * "coordinates": [100.0, 0.0] * }, { * "TYPE": "LineString", * "coordinates": [ * [101.0, 0.0], * [102.0, 1.0] * ] * }] * } * </pre> * * @since 1.0.0 */ @Keep public final class GeometryCollection implements Geometry { private static final String TYPE = "GeometryCollection"; private final String type; private final BoundingBox bbox; private final List<Geometry> geometries; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a GeometryCollection object from scratch it is better to use one of the other provided * static factory methods such as {@link #fromGeometries(List)}. * * @param json a formatted valid JSON string defining a GeoJson Geometry Collection * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static GeometryCollection fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); gson.registerTypeAdapterFactory(GeometryAdapterFactory.create()); return gson.create().fromJson(json, GeometryCollection.class); } /** * Create a new instance of this class by giving the collection a list of {@link Geometry}. * * @param geometries a non-null list of geometry which makes up this collection * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries) { return new GeometryCollection(TYPE, null, geometries); } /** * Create a new instance of this class by giving the collection a list of {@link Geometry}. * * @param geometries a non-null list of geometry which makes up this collection * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries, @Nullable BoundingBox bbox) { return new GeometryCollection(TYPE, bbox, geometries); } /** * Create a new instance of this class by giving the collection a single GeoJSON {@link Geometry}. * * @param geometry a non-null object of type geometry which makes up this collection * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static GeometryCollection fromGeometry(@NonNull Geometry geometry) { List<Geometry> geometries = Arrays.asList(geometry); return new GeometryCollection(TYPE, null, geometries); } /** * Create a new instance of this class by giving the collection a single GeoJSON {@link Geometry}. * * @param geometry a non-null object of type geometry which makes up this collection * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static GeometryCollection fromGeometry(@NonNull Geometry geometry, @Nullable BoundingBox bbox) { List<Geometry> geometries = Arrays.asList(geometry); return new GeometryCollection(TYPE, bbox, geometries); } /** * Create a new instance of this class by giving the collection a list of {@link Geometry} and * bounding box. * * @param geometries a non-null list of geometry which makes up this collection * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 4.6.0 */ GeometryCollection(String type, @Nullable BoundingBox bbox, List<Geometry> geometries) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (geometries == null) { throw new NullPointerException("Null geometries"); } this.geometries = geometries; } /** * This describes the TYPE of GeoJson this object is, thus this will always return * {@link GeometryCollection}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code GeometryCollection} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * This provides the list of geometry making up this Geometry Collection. Note that if the * Geometry Collection was created through {@link #fromJson(String)} this list could be null. * Otherwise, the list can't be null but the size of the list can equal 0. * * @return a list of {@link Geometry} which make up this Geometry Collection * @since 1.0.0 */ @NonNull public List<Geometry> geometries() { return geometries; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this GeometryCollection * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); gson.registerTypeAdapterFactory(GeometryAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<GeometryCollection> typeAdapter(Gson gson) { return new GeometryCollection.GsonTypeAdapter(gson); } @Override public String toString() { return "GeometryCollection{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "geometries=" + geometries + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof GeometryCollection) { GeometryCollection that = (GeometryCollection) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.geometries.equals(that.geometries())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= geometries.hashCode(); return hashCode; } /** * TypeAdapter to serialize/deserialize GeometryCollection objects. * * @since 4.6.0 */ static final class GsonTypeAdapter extends TypeAdapter<GeometryCollection> { private volatile TypeAdapter<String> stringTypeAdapter; private volatile TypeAdapter<BoundingBox> boundingBoxTypeAdapter; private volatile TypeAdapter<List<Geometry>> listGeometryAdapter; private final Gson gson; GsonTypeAdapter(Gson gson) { this.gson = gson; } @Override public void write(JsonWriter jsonWriter, GeometryCollection object) throws IOException { if (object == null) { jsonWriter.nullValue(); return; } jsonWriter.beginObject(); jsonWriter.name("type"); if (object.type() == null) { jsonWriter.nullValue(); } else { TypeAdapter<String> stringTypeAdapter = this.stringTypeAdapter; if (stringTypeAdapter == null) { stringTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = stringTypeAdapter; } stringTypeAdapter.write(jsonWriter, object.type()); } jsonWriter.name("bbox"); if (object.bbox() == null) { jsonWriter.nullValue(); } else { TypeAdapter<BoundingBox> boundingBoxTypeAdapter = this.boundingBoxTypeAdapter; if (boundingBoxTypeAdapter == null) { boundingBoxTypeAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxTypeAdapter = boundingBoxTypeAdapter; } boundingBoxTypeAdapter.write(jsonWriter, object.bbox()); } jsonWriter.name("geometries"); if (object.geometries() == null) { jsonWriter.nullValue(); } else { TypeAdapter<List<Geometry>> listGeometryAdapter = this.listGeometryAdapter; if (listGeometryAdapter == null) { TypeToken typeToken = TypeToken.getParameterized(List.class, Geometry.class); listGeometryAdapter = (TypeAdapter<List<Geometry>>) gson.getAdapter(typeToken); this.listGeometryAdapter = listGeometryAdapter; } listGeometryAdapter.write(jsonWriter, object.geometries()); } jsonWriter.endObject(); } @Override public GeometryCollection read(JsonReader jsonReader) throws IOException { if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); return null; } jsonReader.beginObject(); String type = null; BoundingBox bbox = null; List<Geometry> geometries = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); continue; } switch (name) { case "type": TypeAdapter<String> stringTypeAdapter = this.stringTypeAdapter; if (stringTypeAdapter == null) { stringTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = stringTypeAdapter; } type = stringTypeAdapter.read(jsonReader); break; case "bbox": TypeAdapter<BoundingBox> boundingBoxTypeAdapter = this.boundingBoxTypeAdapter; if (boundingBoxTypeAdapter == null) { boundingBoxTypeAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxTypeAdapter = boundingBoxTypeAdapter; } bbox = boundingBoxTypeAdapter.read(jsonReader); break; case "geometries": TypeAdapter<List<Geometry>> listGeometryAdapter = this.listGeometryAdapter; if (listGeometryAdapter == null) { TypeToken typeToken = TypeToken.getParameterized(List.class, Geometry.class); listGeometryAdapter = (TypeAdapter<List<Geometry>>) gson.getAdapter(typeToken); this.listGeometryAdapter = listGeometryAdapter; } geometries = listGeometryAdapter.read(jsonReader); break; default: jsonReader.skipValue(); } } jsonReader.endObject(); return new GeometryCollection(type == null ? "GeometryCollection" : type, bbox, geometries); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/LineString.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import com.nbmap.geojson.utils.PolylineUtils; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * A linestring represents two or more geographic points that share a relationship and is one of the * seven geometries found in the GeoJson spec. * <p> * This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this * class becomes an immutable object which should be initiated using its static factory methods. * </p><p> * The list of points must be equal to or greater than 2. A LineString has non-zero length and * zero area. It may approximate a curve and need not be straight. Unlike a LinearRing, a LineString * is not closed. * </p><p> * When representing a LineString that crosses the antimeridian, interoperability is improved by * modifying their geometry. Any geometry that crosses the antimeridian SHOULD be represented by * cutting it in two such that neither part's representation crosses the antimeridian. * </p><p> * For example, a line extending from 45 degrees N, 170 degrees E across the antimeridian to 45 * degrees N, 170 degrees W should be cut in two and represented as a MultiLineString. * </p><p> * A sample GeoJson LineString's provided below (in it's serialized state). * <pre> * { * "TYPE": "LineString", * "coordinates": [ * [100.0, 0.0], * [101.0, 1.0] * ] * } * </pre> * Look over the {@link Point} documentation to get more * information about formatting your list of point objects correctly. * * @since 1.0.0 */ @Keep public final class LineString implements CoordinateContainer<List<Point>> { private static final String TYPE = "LineString"; private final String type; private final BoundingBox bbox; private final List<Point> coordinates; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a LineString object from scratch it is better to use one of the other provided static * factory methods such as {@link #fromLngLats(List)}. For a valid lineString to exist, it must * have at least 2 coordinate entries. The LineString should also have non-zero distance and zero * area. * * @param json a formatted valid JSON string defining a GeoJson LineString * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static LineString fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, LineString.class); } /** * Create a new instance of this class by defining a {@link MultiPoint} object and passing. The * multipoint object should comply with the GeoJson specifications described in the documentation. * * @param multiPoint which will make up the LineString geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static LineString fromLngLats(@NonNull MultiPoint multiPoint) { return new LineString(TYPE, null, multiPoint.coordinates()); } /** * Create a new instance of this class by defining a list of {@link Point}s which follow the * correct specifications described in the Point documentation. Note that there should not be any * duplicate points inside the list and the points combined should create a LineString with a * distance greater than 0. * <p> * Note that if less than 2 points are passed in, a runtime exception will occur. * </p> * * @param points a list of {@link Point}s which make up the LineString geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static LineString fromLngLats(@NonNull List<Point> points) { return new LineString(TYPE, null, points); } /** * Create a new instance of this class by defining a list of {@link Point}s which follow the * correct specifications described in the Point documentation. Note that there should not be any * duplicate points inside the list and the points combined should create a LineString with a * distance greater than 0. * <p> * Note that if less than 2 points are passed in, a runtime exception will occur. * </p> * * @param points a list of {@link Point}s which make up the LineString geometry * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static LineString fromLngLats(@NonNull List<Point> points, @Nullable BoundingBox bbox) { return new LineString(TYPE, bbox, points); } /** * Create a new instance of this class by defining a {@link MultiPoint} object and passing. The * multipoint object should comply with the GeoJson specifications described in the documentation. * * @param multiPoint which will make up the LineString geometry * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static LineString fromLngLats(@NonNull MultiPoint multiPoint, @Nullable BoundingBox bbox) { return new LineString(TYPE, bbox, multiPoint.coordinates()); } LineString(String type, @Nullable BoundingBox bbox, List<Point> coordinates) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (coordinates == null) { throw new NullPointerException("Null coordinates"); } this.coordinates = coordinates; } static LineString fromLngLats(double[][] coordinates) { ArrayList<Point> converted = new ArrayList<>(coordinates.length); for (int i = 0; i < coordinates.length; i++) { converted.add(Point.fromLngLat(coordinates[i])); } return LineString.fromLngLats(converted); } /** * Create a new instance of this class by convert a polyline string into a lineString. This is * handy when an API provides you with an encoded string representing the line geometry and you'd * like to convert it to a useful LineString object. Note that the precision that the string * geometry was encoded with needs to be known and passed into this method using the precision * parameter. * * @param polyline encoded string geometry to decode into a new LineString instance * @param precision The encoded precision which must match the same precision used when the string * was first encoded * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static LineString fromPolyline(@NonNull String polyline, int precision) { return LineString.fromLngLats(PolylineUtils.decode(polyline, precision), null); } /** * This describes the TYPE of GeoJson geometry this object is, thus this will always return * {@link LineString}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code LineString} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * Provides the list of {@link Point}s that make up the LineString geometry. * * @return a list of points * @since 3.0.0 */ @NonNull @Override public List<Point> coordinates() { return coordinates; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this LineString geometry * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } /** * Encode this LineString into a Polyline string for easier serializing. When passing geometry * information over a mobile network connection, encoding the geometry first will generally result * in less bandwidth usage. * * @param precision the encoded precision which fits your best use-case * @return a string describing the geometry of this LineString * @since 1.0.0 */ public String toPolyline(int precision) { return PolylineUtils.encode(coordinates(), precision); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<LineString> typeAdapter(Gson gson) { return new LineString.GsonTypeAdapter(gson); } @Override public String toString() { return "LineString{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "coordinates=" + coordinates + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof LineString) { LineString that = (LineString) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.coordinates.equals(that.coordinates())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= coordinates.hashCode(); return hashCode; } /** * TypeAdapter for LineString geometry. * * @since 4.6.0 */ static final class GsonTypeAdapter extends BaseGeometryTypeAdapter<LineString, List<Point>> { GsonTypeAdapter(Gson gson) { super(gson, new ListOfPointCoordinatesTypeAdapter()); } @Override public void write(JsonWriter jsonWriter, LineString object) throws IOException { writeCoordinateContainer(jsonWriter, object); } @Override public LineString read(JsonReader jsonReader) throws IOException { return (LineString) readCoordinateContainer(jsonReader); } @Override CoordinateContainer<List<Point>> createCoordinateContainer(String type, BoundingBox bbox, List<Point> coordinates) { return new LineString(type == null ? "LineString" : type, bbox, coordinates); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/ListOfDoublesCoordinatesTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.List; /** * Type Adapter to serialize/deserialize Poinr into/from for double array. * * @since 4.6.0 */ @Keep class ListOfDoublesCoordinatesTypeAdapter extends BaseCoordinatesTypeAdapter<List<Double>> { @Override public void write(JsonWriter out, List<Double> value) throws IOException { writePointList(out, value); } @Override public List<Double> read(JsonReader in) throws IOException { return readPointList(in); } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/ListOfListOfPointCoordinatesTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.exception.GeoJsonException; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Type Adapter to serialize/deserialize ist &lt;List&lt;Point&gt;&gt; * into/from three dimentional double array. * * @since 4.6.0 */ @Keep class ListOfListOfPointCoordinatesTypeAdapter extends BaseCoordinatesTypeAdapter<List<List<Point>>> { @Override public void write(JsonWriter out, List<List<Point>> points) throws IOException { if (points == null) { out.nullValue(); return; } out.beginArray(); for (List<Point> listOfPoints : points) { out.beginArray(); for (Point point : listOfPoints) { writePoint(out, point); } out.endArray(); } out.endArray(); } @Override public List<List<Point>> read(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { throw new NullPointerException(); } if (in.peek() == JsonToken.BEGIN_ARRAY) { in.beginArray(); List<List<Point>> points = new ArrayList<>(); while (in.peek() == JsonToken.BEGIN_ARRAY) { in.beginArray(); List<Point> listOfPoints = new ArrayList<>(); while (in.peek() == JsonToken.BEGIN_ARRAY) { listOfPoints.add(readPoint(in)); } in.endArray(); points.add(listOfPoints); } in.endArray(); return points; } throw new GeoJsonException("coordinates should be array of array of array of double"); } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/ListOfPointCoordinatesTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.exception.GeoJsonException; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Type Adapter to serialize/deserialize List&lt;Point&gt; into/from two dimentional double array. * * @since 4.6.0 */ @Keep class ListOfPointCoordinatesTypeAdapter extends BaseCoordinatesTypeAdapter<List<Point>> { @Override public void write(JsonWriter out, List<Point> points) throws IOException { if (points == null) { out.nullValue(); return; } out.beginArray(); for (Point point : points) { writePoint(out, point); } out.endArray(); } @Override public List<Point> read(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { throw new NullPointerException(); } if (in.peek() == JsonToken.BEGIN_ARRAY) { List<Point> points = new ArrayList<>(); in.beginArray(); while (in.peek() == JsonToken.BEGIN_ARRAY) { points.add(readPoint(in)); } in.endArray(); return points; } throw new GeoJsonException("coordinates should be non-null array of array of double"); } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/ListofListofListOfPointCoordinatesTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.exception.GeoJsonException; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Type Adapter to serialize/deserialize List&lt;List&lt;List&lt;Point&gt;&gt;&gt; into/from * four dimentional double array. * * @since 4.6.0 */ @Keep class ListofListofListOfPointCoordinatesTypeAdapter extends BaseCoordinatesTypeAdapter<List<List<List<Point>>>> { @Override public void write(JsonWriter out, List<List<List<Point>>> points) throws IOException { if (points == null) { out.nullValue(); return; } out.beginArray(); for (List<List<Point>> listOfListOfPoints : points) { out.beginArray(); for (List<Point> listOfPoints : listOfListOfPoints) { out.beginArray(); for (Point point : listOfPoints) { writePoint(out, point); } out.endArray(); } out.endArray(); } out.endArray(); } @Override public List<List<List<Point>>> read(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { throw new NullPointerException(); } if (in.peek() == JsonToken.BEGIN_ARRAY) { in.beginArray(); List<List<List<Point>>> listOfListOflistOfPoints = new ArrayList<>(); while (in.peek() == JsonToken.BEGIN_ARRAY) { in.beginArray(); List<List<Point>> listOfListOfPoints = new ArrayList<>(); while (in.peek() == JsonToken.BEGIN_ARRAY) { in.beginArray(); List<Point> listOfPoints = new ArrayList<>(); while (in.peek() == JsonToken.BEGIN_ARRAY) { listOfPoints.add(readPoint(in)); } in.endArray(); listOfListOfPoints.add(listOfPoints); } in.endArray(); listOfListOflistOfPoints.add(listOfListOfPoints); } in.endArray(); return listOfListOflistOfPoints; } throw new GeoJsonException("coordinates should be array of array of array of double"); } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/MultiLineString.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * A multilinestring is an array of LineString coordinate arrays. * <p> * This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this * class becomes an immutable object which should be initiated using its static factory methods. * </p><p> * When representing a LineString that crosses the antimeridian, interoperability is improved by * modifying their geometry. Any geometry that crosses the antimeridian SHOULD be represented by * cutting it in two such that neither part's representation crosses the antimeridian. * </p><p> * For example, a line extending from 45 degrees N, 170 degrees E across the antimeridian to 45 * degrees N, 170 degrees W should be cut in two and represented as a MultiLineString. * </p><p> * A sample GeoJson MultiLineString's provided below (in it's serialized state). * <pre> * { * "type": "MultiLineString", * "coordinates": [ * [ * [100.0, 0.0], * [101.0, 1.0] * ], * [ * [102.0, 2.0], * [103.0, 3.0] * ] * ] * } * </pre> * Look over the {@link LineString} documentation to get more information about * formatting your list of linestring objects correctly. * * @since 1.0.0 */ @Keep public final class MultiLineString implements CoordinateContainer<List<List<Point>>> { private static final String TYPE = "MultiLineString"; private final String type; private final BoundingBox bbox; private final List<List<Point>> coordinates; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a MultiLineString object from scratch it is better to use one of the other provided * static factory methods such as {@link #fromLineStrings(List)}. * * @param json a formatted valid JSON string defining a GeoJson MultiLineString * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static MultiLineString fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, MultiLineString.class); } /** * Create a new instance of this class by defining a list of {@link LineString} objects and * passing that list in as a parameter in this method. The LineStrings should comply with the * GeoJson specifications described in the documentation. * * @param lineStrings a list of LineStrings which make up this MultiLineString * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiLineString fromLineStrings(@NonNull List<LineString> lineStrings) { List<List<Point>> coordinates = new ArrayList<>(lineStrings.size()); for (LineString lineString : lineStrings) { coordinates.add(lineString.coordinates()); } return new MultiLineString(TYPE, null, coordinates); } /** * Create a new instance of this class by defining a list of {@link LineString} objects and * passing that list in as a parameter in this method. The LineStrings should comply with the * GeoJson specifications described in the documentation. Optionally, pass in an instance of a * {@link BoundingBox} which better describes this MultiLineString. * * @param lineStrings a list of LineStrings which make up this MultiLineString * @param bbox optionally include a bbox definition * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiLineString fromLineStrings(@NonNull List<LineString> lineStrings, @Nullable BoundingBox bbox) { List<List<Point>> coordinates = new ArrayList<>(lineStrings.size()); for (LineString lineString : lineStrings) { coordinates.add(lineString.coordinates()); } return new MultiLineString(TYPE, bbox, coordinates); } /** * Create a new instance of this class by passing in a single {@link LineString} object. The * LineStrings should comply with the GeoJson specifications described in the documentation. * * @param lineString a single LineString which make up this MultiLineString * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiLineString fromLineString(@NonNull LineString lineString) { List<List<Point>> coordinates = Arrays.asList(lineString.coordinates()); return new MultiLineString(TYPE, null, coordinates); } /** * Create a new instance of this class by passing in a single {@link LineString} object. The * LineStrings should comply with the GeoJson specifications described in the documentation. * * @param lineString a single LineString which make up this MultiLineString * @param bbox optionally include a bbox definition * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiLineString fromLineString(@NonNull LineString lineString, @Nullable BoundingBox bbox) { List<List<Point>> coordinates = Arrays.asList(lineString.coordinates()); return new MultiLineString(TYPE, bbox, coordinates); } /** * Create a new instance of this class by defining a list of a list of {@link Point}s which follow * the correct specifications described in the Point documentation. Note that there should not be * any duplicate points inside the list and the points combined should create a LineString with a * distance greater than 0. * * @param points a list of {@link Point}s which make up the MultiLineString geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiLineString fromLngLats(@NonNull List<List<Point>> points) { return new MultiLineString(TYPE, null, points); } /** * Create a new instance of this class by defining a list of a list of {@link Point}s which follow * the correct specifications described in the Point documentation. Note that there should not be * any duplicate points inside the list and the points combined should create a LineString with a * distance greater than 0. * * @param points a list of {@link Point}s which make up the MultiLineString geometry * @param bbox optionally include a bbox definition * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiLineString fromLngLats(@NonNull List<List<Point>> points, @Nullable BoundingBox bbox) { return new MultiLineString(TYPE, bbox, points); } static MultiLineString fromLngLats(double[][][] coordinates) { List<List<Point>> multiLine = new ArrayList<>(coordinates.length); for (int i = 0; i < coordinates.length; i++) { List<Point> lineString = new ArrayList<>(coordinates[i].length); for (int j = 0; j < coordinates[i].length; j++) { lineString.add(Point.fromLngLat(coordinates[i][j])); } multiLine.add(lineString); } return new MultiLineString(TYPE, null, multiLine); } MultiLineString(String type, @Nullable BoundingBox bbox, List<List<Point>> coordinates) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (coordinates == null) { throw new NullPointerException("Null coordinates"); } this.coordinates = coordinates; } /** * This describes the TYPE of GeoJson geometry this object is, thus this will always return * {@link MultiLineString}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code MultiLineString} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * Provides the list of list of {@link Point}s that make up the MultiLineString geometry. * * @return a list of points * @since 3.0.0 */ @NonNull @Override public List<List<Point>> coordinates() { return coordinates; } /** * Returns a list of LineStrings which are currently making up this MultiLineString. * * @return a list of {@link LineString}s * @since 3.0.0 */ public List<LineString> lineStrings() { List<List<Point>> coordinates = coordinates(); List<LineString> lineStrings = new ArrayList<>(coordinates.size()); for (List<Point> points : coordinates) { lineStrings.add(LineString.fromLngLats(points)); } return lineStrings; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this MultiLineString geometry * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson type adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<MultiLineString> typeAdapter(Gson gson) { return new MultiLineString.GsonTypeAdapter(gson); } @Override public String toString() { return "MultiLineString{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "coordinates=" + coordinates + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof MultiLineString) { MultiLineString that = (MultiLineString) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.coordinates.equals(that.coordinates())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= coordinates.hashCode(); return hashCode; } /** * TypeAdapter for MultiLineString geometry. * * @since 4.6.0 */ static final class GsonTypeAdapter extends BaseGeometryTypeAdapter<MultiLineString, List<List<Point>>> { GsonTypeAdapter(Gson gson) { super(gson, new ListOfListOfPointCoordinatesTypeAdapter()); } @Override public void write(JsonWriter jsonWriter, MultiLineString object) throws IOException { writeCoordinateContainer(jsonWriter, object); } @Override public MultiLineString read(JsonReader jsonReader) throws IOException { return (MultiLineString) readCoordinateContainer(jsonReader); } @Override CoordinateContainer<List<List<Point>>> createCoordinateContainer(String type, BoundingBox bbox, List<List<Point>> coords) { return new MultiLineString(type == null ? "MultiLineString" : type, bbox, coords); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/MultiPoint.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * A MultiPoint represents two or more geographic points that share a relationship and is one of the * seven geometries found in the GeoJson spec. <p> This adheres to the RFC 7946 internet standard * when serialized into JSON. When deserialized, this class becomes an immutable object which should * be initiated using its static factory methods. The list of points must be equal to or greater * than 2. </p><p> A sample GeoJson MultiPoint's provided below (in it's serialized state). * <pre> * { * "TYPE": "MultiPoint", * "coordinates": [ * [100.0, 0.0], * [101.0, 1.0] * ] * } * </pre> * Look over the {@link Point} documentation to get more * information about formatting your list of point objects correctly. * * @since 1.0.0 */ @Keep public final class MultiPoint implements CoordinateContainer<List<Point>> { private static final String TYPE = "MultiPoint"; private final String type; private final BoundingBox bbox; private final List<Point> coordinates; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a MultiPoint object from scratch it is better to use one of the other provided static * factory methods such as {@link #fromLngLats(List)}. For a valid MultiPoint to exist, it must * have at least 2 coordinate entries. * * @param json a formatted valid JSON string defining a GeoJson MultiPoint * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static MultiPoint fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, MultiPoint.class); } /** * Create a new instance of this class by defining a list of {@link Point}s which follow the * correct specifications described in the Point documentation. Note that there should not be any * duplicate points inside the list. <p> Note that if less than 2 points are passed in, a runtime * exception will occur. </p> * * @param points a list of {@link Point}s which make up the LineString geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPoint fromLngLats(@NonNull List<Point> points) { return new MultiPoint(TYPE, null, points); } /** * Create a new instance of this class by defining a list of {@link Point}s which follow the * correct specifications described in the Point documentation. Note that there should not be any * duplicate points inside the list. <p> Note that if less than 2 points are passed in, a runtime * exception will occur. </p> * * @param points a list of {@link Point}s which make up the LineString geometry * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPoint fromLngLats(@NonNull List<Point> points, @Nullable BoundingBox bbox) { return new MultiPoint(TYPE, bbox, points); } static MultiPoint fromLngLats(@NonNull double[][] coordinates) { ArrayList<Point> converted = new ArrayList<>(coordinates.length); for (int i = 0; i < coordinates.length; i++) { converted.add(Point.fromLngLat(coordinates[i])); } return new MultiPoint(TYPE, null, converted); } MultiPoint(String type, @Nullable BoundingBox bbox, List<Point> coordinates) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (coordinates == null) { throw new NullPointerException("Null coordinates"); } this.coordinates = coordinates; } /** * This describes the TYPE of GeoJson this object is, thus this will always return {@link * MultiPoint}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code MultiPoint} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of size * 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * provides the list of {@link Point}s that make up the MultiPoint geometry. * * @return a list of points * @since 3.0.0 */ @NonNull @Override public List<Point> coordinates() { return coordinates; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this MultiPoint geometry * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<MultiPoint> typeAdapter(Gson gson) { return new MultiPoint.GsonTypeAdapter(gson); } @Override public String toString() { return "MultiPoint{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "coordinates=" + coordinates + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof MultiPoint) { MultiPoint that = (MultiPoint) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.coordinates.equals(that.coordinates())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= coordinates.hashCode(); return hashCode; } /** * TypeAdapter for MultiPoint geometry. * * @since 4.6.0 */ static final class GsonTypeAdapter extends BaseGeometryTypeAdapter<MultiPoint, List<Point>> { GsonTypeAdapter(Gson gson) { super(gson, new ListOfPointCoordinatesTypeAdapter()); } @Override public void write(JsonWriter jsonWriter, MultiPoint object) throws IOException { writeCoordinateContainer(jsonWriter, object); } @Override public MultiPoint read(JsonReader jsonReader) throws IOException { return (MultiPoint) readCoordinateContainer(jsonReader); } @Override CoordinateContainer<List<Point>> createCoordinateContainer(String type, BoundingBox bbox, List<Point> coordinates) { return new MultiPoint(type == null ? "MultiPoint" : type, bbox, coordinates); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/MultiPolygon.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * A multiPolygon is an array of Polygon coordinate arrays. * <p> * This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this * class becomes an immutable object which should be initiated using its static factory methods. * </p><p> * When representing a Polygon that crosses the antimeridian, interoperability is improved by * modifying their geometry. Any geometry that crosses the antimeridian SHOULD be represented by * cutting it in two such that neither part's representation crosses the antimeridian. * </p><p> * For example, a line extending from 45 degrees N, 170 degrees E across the antimeridian to 45 * degrees N, 170 degrees W should be cut in two and represented as a MultiLineString. * </p><p> * A sample GeoJson MultiPolygon's provided below (in it's serialized state). * <pre> * { * "type": "MultiPolygon", * "coordinates": [ * [ * [ * [102.0, 2.0], * [103.0, 2.0], * [103.0, 3.0], * [102.0, 3.0], * [102.0, 2.0] * ] * ], * [ * [ * [100.0, 0.0], * [101.0, 0.0], * [101.0, 1.0], * [100.0, 1.0], * [100.0, 0.0] * ], * [ * [100.2, 0.2], * [100.2, 0.8], * [100.8, 0.8], * [100.8, 0.2], * [100.2, 0.2] * ] * ] * ] * } * </pre> * Look over the {@link Polygon} documentation to get more information about * formatting your list of Polygon objects correctly. * * @since 1.0.0 */ @Keep public final class MultiPolygon implements CoordinateContainer<List<List<List<Point>>>> { private static final String TYPE = "MultiPolygon"; private final String type; private final BoundingBox bbox; private final List<List<List<Point>>> coordinates; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a MultiPolygon object from scratch it is better to use one of the other provided * static factory methods such as {@link #fromPolygons(List)}. * * @param json a formatted valid JSON string defining a GeoJson MultiPolygon * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static MultiPolygon fromJson(String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, MultiPolygon.class); } /** * Create a new instance of this class by defining a list of {@link Polygon} objects and passing * that list in as a parameter in this method. The Polygons should comply with the GeoJson * specifications described in the documentation. * * @param polygons a list of Polygons which make up this MultiPolygon * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPolygon fromPolygons(@NonNull List<Polygon> polygons) { List<List<List<Point>>> coordinates = new ArrayList<>(polygons.size()); for (Polygon polygon : polygons) { coordinates.add(polygon.coordinates()); } return new MultiPolygon(TYPE, null, coordinates); } /** * Create a new instance of this class by defining a list of {@link Polygon} objects and passing * that list in as a parameter in this method. The Polygons should comply with the GeoJson * specifications described in the documentation. Optionally, pass in an instance of a * {@link BoundingBox} which better describes this MultiPolygon. * * @param polygons a list of Polygons which make up this MultiPolygon * @param bbox optionally include a bbox definition * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPolygon fromPolygons(@NonNull List<Polygon> polygons, @Nullable BoundingBox bbox) { List<List<List<Point>>> coordinates = new ArrayList<>(polygons.size()); for (Polygon polygon : polygons) { coordinates.add(polygon.coordinates()); } return new MultiPolygon(TYPE, bbox, coordinates); } /** * Create a new instance of this class by defining a single {@link Polygon} objects and passing * it in as a parameter in this method. The Polygon should comply with the GeoJson * specifications described in the documentation. * * @param polygon a single Polygon which make up this MultiPolygon * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPolygon fromPolygon(@NonNull Polygon polygon) { List<List<List<Point>>> coordinates = Arrays.asList(polygon.coordinates()); return new MultiPolygon(TYPE, null, coordinates); } /** * Create a new instance of this class by defining a single {@link Polygon} objects and passing * it in as a parameter in this method. The Polygon should comply with the GeoJson * specifications described in the documentation. * * @param polygon a single Polygon which make up this MultiPolygon * @param bbox optionally include a bbox definition * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPolygon fromPolygon(@NonNull Polygon polygon, @Nullable BoundingBox bbox) { List<List<List<Point>>> coordinates = Arrays.asList(polygon.coordinates()); return new MultiPolygon(TYPE, bbox, coordinates); } /** * Create a new instance of this class by defining a list of a list of a list of {@link Point}s * which follow the correct specifications described in the Point documentation. * * @param points a list of {@link Point}s which make up the MultiPolygon geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPolygon fromLngLats(@NonNull List<List<List<Point>>> points) { return new MultiPolygon(TYPE, null, points); } /** * Create a new instance of this class by defining a list of a list of a list of {@link Point}s * which follow the correct specifications described in the Point documentation. * * @param points a list of {@link Point}s which make up the MultiPolygon geometry * @param bbox optionally include a bbox definition * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static MultiPolygon fromLngLats(@NonNull List<List<List<Point>>> points, @Nullable BoundingBox bbox) { return new MultiPolygon(TYPE, bbox, points); } static MultiPolygon fromLngLats(@NonNull double[][][][] coordinates) { List<List<List<Point>>> converted = new ArrayList<>(coordinates.length); for (int i = 0; i < coordinates.length; i++) { List<List<Point>> innerOneList = new ArrayList<>(coordinates[i].length); for (int j = 0; j < coordinates[i].length; j++) { List<Point> innerTwoList = new ArrayList<>(coordinates[i][j].length); for (int k = 0; k < coordinates[i][j].length; k++) { innerTwoList.add(Point.fromLngLat(coordinates[i][j][k])); } innerOneList.add(innerTwoList); } converted.add(innerOneList); } return new MultiPolygon(TYPE, null, converted); } MultiPolygon(String type, @Nullable BoundingBox bbox, List<List<List<Point>>> coordinates) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (coordinates == null) { throw new NullPointerException("Null coordinates"); } this.coordinates = coordinates; } /** * Returns a list of polygons which make up this MultiPolygon instance. * * @return a list of {@link Polygon}s which make up this MultiPolygon instance * @since 3.0.0 */ public List<Polygon> polygons() { List<List<List<Point>>> coordinates = coordinates(); List<Polygon> polygons = new ArrayList<>(coordinates.size()); for (List<List<Point>> points : coordinates) { polygons.add(Polygon.fromLngLats(points)); } return polygons; } /** * This describes the TYPE of GeoJson geometry this object is, thus this will always return * {@link MultiPolygon}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code MultiPolygon} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * Provides the list of list of list of {@link Point}s that make up the MultiPolygon geometry. * * @return a list of points * @since 3.0.0 */ @NonNull @Override public List<List<List<Point>>> coordinates() { return coordinates; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this MultiPolygon geometry * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<MultiPolygon> typeAdapter(Gson gson) { return new MultiPolygon.GsonTypeAdapter(gson); } @Override public String toString() { return "Polygon{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "coordinates=" + coordinates + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof MultiPolygon) { MultiPolygon that = (MultiPolygon) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.coordinates.equals(that.coordinates())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= coordinates.hashCode(); return hashCode; } /** * TypeAdapter for MultiPolygon geometry. * * @since 4.6.0 */ static final class GsonTypeAdapter extends BaseGeometryTypeAdapter<MultiPolygon, List<List<List<Point>>>> { GsonTypeAdapter(Gson gson) { super(gson, new ListofListofListOfPointCoordinatesTypeAdapter()); } @Override public void write(JsonWriter jsonWriter, MultiPolygon object) throws IOException { writeCoordinateContainer(jsonWriter, object); } @Override public MultiPolygon read(JsonReader jsonReader) throws IOException { return (MultiPolygon) readCoordinateContainer(jsonReader); } @Override CoordinateContainer<List<List<List<Point>>>> createCoordinateContainer(String type, BoundingBox bbox, List<List<List<Point>>> coords) { return new MultiPolygon(type == null ? "MultiPolygon" : type, bbox, coords); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/Point.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import com.nbmap.geojson.shifter.CoordinateShifterManager; import java.io.IOException; import java.util.List; /** * A point represents a single geographic position and is one of the seven Geometries found in the * GeoJson spec. * <p> * This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this * class becomes an immutable object which should be initiated using its static factory methods. * </p><p> * Coordinates are in x, y order (easting, northing for projected coordinates), longitude, and * latitude for geographic coordinates), precisely in that order and using double values. Altitude * or elevation MAY be included as an optional third parameter while creating this object. * <p> * The size of a GeoJson text in bytes is a major interoperability consideration, and precision of * coordinate values has a large impact on the size of texts when serialized. For geographic * coordinates with units of degrees, 6 decimal places (a default common in, e.g., sprintf) amounts * to about 10 centimeters, a precision well within that of current GPS systems. Implementations * should consider the cost of using a greater precision than necessary. * <p> * Furthermore, pertaining to altitude, the WGS 84 datum is a relatively coarse approximation of the * geoid, with the height varying by up to 5 m (but generally between 2 and 3 meters) higher or * lower relative to a surface parallel to Earth's mean sea level. * <p> * A sample GeoJson Point's provided below (in its serialized state). * <pre> * { * "type": "Point", * "coordinates": [100.0, 0.0] * } * </pre> * * @since 1.0.0 */ @Keep public final class Point implements CoordinateContainer<List<Double>> { private static final String TYPE = "Point"; @NonNull private final String type; @Nullable private final BoundingBox bbox; @NonNull private final List<Double> coordinates; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a Point object from scratch it is better to use one of the other provided static * factory methods such as {@link #fromLngLat(double, double)}. While no limit is placed * on decimal precision, for performance reasons when serializing and deserializing it is * suggested to limit decimal precision to within 6 decimal places. * * @param json a formatted valid JSON string defining a GeoJson Point * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Point fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, Point.class); } /** * Create a new instance of this class defining a longitude and latitude value in that respective * order. While no limit is placed on decimal precision, for performance reasons * when serializing and deserializing it is suggested to limit decimal precision to within 6 * decimal places. * * @param longitude a double value representing the x position of this point * @param latitude a double value representing the y position of this point * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Point fromLngLat(double longitude, double latitude) { List<Double> coordinates = CoordinateShifterManager.getCoordinateShifter().shiftLonLat(longitude, latitude); return new Point(TYPE, null, coordinates); } /** * Create a new instance of this class defining a longitude and latitude value in that respective * order. While no limit is placed on decimal precision, for performance reasons * when serializing and deserializing it is suggested to limit decimal precision to within 6 * decimal places. An optional altitude value can be passed in and can vary between negative * infinity and positive infinity. * * @param longitude a double value representing the x position of this point * @param latitude a double value representing the y position of this point * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Point fromLngLat(double longitude, double latitude, @Nullable BoundingBox bbox) { List<Double> coordinates = CoordinateShifterManager.getCoordinateShifter().shiftLonLat(longitude, latitude); return new Point(TYPE, bbox, coordinates); } /** * Create a new instance of this class defining a longitude and latitude value in that respective * order. While no limit is placed on decimal precision, for performance reasons * when serializing and deserializing it is suggested to limit decimal precision to within 6 * decimal places. An optional altitude value can be passed in and can vary between negative * infinity and positive infinity. * * @param longitude a double value representing the x position of this point * @param latitude a double value representing the y position of this point * @param altitude a double value which can be negative or positive infinity representing either * elevation or altitude * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Point fromLngLat(double longitude, double latitude, double altitude) { List<Double> coordinates = CoordinateShifterManager.getCoordinateShifter().shiftLonLatAlt(longitude, latitude, altitude); return new Point(TYPE, null, coordinates); } /** * Create a new instance of this class defining a longitude and latitude value in that respective * order. While no limit is placed on decimal precision, for performance reasons * when serializing and deserializing it is suggested to limit decimal precision to within 6 * decimal places. An optional altitude value can be passed in and can vary between negative * infinity and positive infinity. * * @param longitude a double value representing the x position of this point * @param latitude a double value representing the y position of this point * @param altitude a double value which can be negative or positive infinity representing either * elevation or altitude * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Point fromLngLat(double longitude, double latitude, double altitude, @Nullable BoundingBox bbox) { List<Double> coordinates = CoordinateShifterManager.getCoordinateShifter().shiftLonLatAlt(longitude, latitude, altitude); return new Point(TYPE, bbox, coordinates); } static Point fromLngLat(@NonNull double[] coords) { if (coords.length == 2) { return Point.fromLngLat(coords[0], coords[1]); } else if (coords.length > 2) { return Point.fromLngLat(coords[0], coords[1], coords[2]); } return null; } Point(String type, @Nullable BoundingBox bbox, List<Double> coordinates) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (coordinates == null || coordinates.size() == 0) { throw new NullPointerException("Null coordinates"); } this.coordinates = coordinates; } /** * This returns a double value representing the x or easting position of * this point. ideally, this value would be restricted to 6 decimal places to correctly follow the * GeoJson spec. * * @return a double value representing the x or easting position of this * point * @since 3.0.0 */ public double longitude() { return coordinates().get(0); } /** * This returns a double value representing the y or northing position of * this point. ideally, this value would be restricted to 6 decimal places to correctly follow the * GeoJson spec. * * @return a double value representing the y or northing position of this * point * @since 3.0.0 */ public double latitude() { return coordinates().get(1); } /** * Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the * coordinate array. {@link #hasAltitude()} can be used to determine if this value was set during * initialization of this Point instance. This double value should only be used to represent * either the elevation or altitude value at this particular point. * * @return a double value ranging from negative to positive infinity * @since 3.0.0 */ public double altitude() { if (coordinates().size() < 3) { return Double.NaN; } return coordinates().get(2); } /** * Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the * coordinate array. If an altitude value was provided while initializing this instance, this will * return true. * * @return true if this instance of point contains an altitude value * @since 3.0.0 */ public boolean hasAltitude() { return !Double.isNaN(altitude()); } /** * This describes the TYPE of GeoJson geometry this object is, thus this will always return * {@link Point}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code Point} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * Provide a single double array containing the longitude, latitude, and optionally an * altitude/elevation. {@link #longitude()}, {@link #latitude()}, and {@link #altitude()} are all * avaliable which make getting specific coordinates more direct. * * @return a double array which holds this points coordinates * @since 3.0.0 */ @NonNull @Override public List<Double> coordinates() { return coordinates; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this Point geometry * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<Point> typeAdapter(Gson gson) { return new Point.GsonTypeAdapter(gson); } @Override public String toString() { return "Point{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "coordinates=" + coordinates + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Point) { Point that = (Point) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.coordinates.equals(that.coordinates())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= coordinates.hashCode(); return hashCode; } /** * TypeAdapter for Point geometry. * * @since 4.6.0 */ static final class GsonTypeAdapter extends BaseGeometryTypeAdapter<Point, List<Double>> { GsonTypeAdapter(Gson gson) { super(gson, new ListOfDoublesCoordinatesTypeAdapter()); } @Override @SuppressWarnings("unchecked") public void write(JsonWriter jsonWriter, Point object) throws IOException { writeCoordinateContainer(jsonWriter, object); } @Override @SuppressWarnings("unchecked") public Point read(JsonReader jsonReader) throws IOException { return (Point)readCoordinateContainer(jsonReader); } @Override CoordinateContainer<List<Double>> createCoordinateContainer(String type, BoundingBox bbox, List<Double> coordinates) { return new Point(type == null ? "Point" : type, bbox, coordinates); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/PointAsCoordinatesTypeAdapter.java
package com.nbmap.geojson; import androidx.annotation.Keep; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; /** * TypeAdapter to serialize Point as coordinates, i.e array of doubles and * to deserialize into Point out of array of doubles. * * @since 4.6.0 */ @Keep public class PointAsCoordinatesTypeAdapter extends BaseCoordinatesTypeAdapter<Point> { @Override public void write(JsonWriter out, Point value) throws IOException { writePoint(out, value); } @Override public Point read(JsonReader in) throws IOException { return readPoint(in); } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/Polygon.java
package com.nbmap.geojson; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Size; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.nbmap.geojson.exception.GeoJsonException; import com.nbmap.geojson.gson.GeoJsonAdapterFactory; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * This class represents a GeoJson Polygon which may or may not include polygon holes. * <p> * To specify a constraint specific to Polygons, it is useful to introduce the concept of a linear * ring: * <ul> * <li>A linear ring is a closed LineString with four or more coordinates.</li> * <li>The first and last coordinates are equivalent, and they MUST contain identical values; their * representation SHOULD also be identical.</li> * <li>A linear ring is the boundary of a surface or the boundary of a hole in a surface.</li> * <li>A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., * exterior rings are counterclockwise, and holes are clockwise.</li> * </ul> * Note that most of the rules listed above are checked when a Polygon instance is created (the * exception being the last rule). If one of the rules is broken, a {@link RuntimeException} will * occur. * <p> * Though a linear ring is not explicitly represented as a GeoJson geometry TYPE, it leads to a * canonical formulation of the Polygon geometry TYPE. When initializing a new instance of this * class, a LineString for the outer and optionally an inner are checked to ensure a valid linear * ring. * <p> * An example of a serialized polygon with no holes is given below: * <pre> * { * "TYPE": "Polygon", * "coordinates": [ * [[100.0, 0.0], * [101.0, 0.0], * [101.0, 1.0], * [100.0, 1.0], * [100.0, 0.0]] * ] * } * </pre> * * @since 1.0.0 */ @Keep public final class Polygon implements CoordinateContainer<List<List<Point>>> { private static final String TYPE = "Polygon"; private final String type; private final BoundingBox bbox; private final List<List<Point>> coordinates; /** * Create a new instance of this class by passing in a formatted valid JSON String. If you are * creating a Polygon object from scratch it is better to use one of the other provided static * factory methods such as {@link #fromOuterInner(LineString, LineString...)}. For a valid * For a valid Polygon to exist, it must follow the linear ring rules and the first list of * coordinates are considered the outer ring by default. * * @param json a formatted valid JSON string defining a GeoJson Polygon * @return a new instance of this class defined by the values passed inside this static factory * method * @since 1.0.0 */ public static Polygon fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, Polygon.class); } /** * Create a new instance of this class by defining a list of {@link Point}s which follow the * correct specifications described in the Point documentation. Note that the first and last point * in the list should be the same enclosing the linear ring. * * @param coordinates a list of a list of points which represent the polygon geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Polygon fromLngLats(@NonNull List<List<Point>> coordinates) { return new Polygon(TYPE, null, coordinates); } /** * Create a new instance of this class by defining a list of {@link Point}s which follow the * correct specifications described in the Point documentation. Note that the first and last point * in the list should be the same enclosing the linear ring. * * @param coordinates a list of a list of points which represent the polygon geometry * @param bbox optionally include a bbox definition as a double array * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Polygon fromLngLats(@NonNull List<List<Point>> coordinates, @Nullable BoundingBox bbox) { return new Polygon(TYPE, bbox, coordinates); } /** * Create a new instance of this class by passing in three dimensional double array which defines * the geometry of this polygon. * * @param coordinates a three dimensional double array defining this polygons geometry * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ static Polygon fromLngLats(@NonNull double[][][] coordinates) { List<List<Point>> converted = new ArrayList<>(coordinates.length); for (double[][] coordinate : coordinates) { List<Point> innerList = new ArrayList<>(coordinate.length); for (double[] pointCoordinate : coordinate) { innerList.add(Point.fromLngLat(pointCoordinate)); } converted.add(innerList); } return new Polygon(TYPE, null, converted); } /** * Create a new instance of this class by passing in an outer {@link LineString} and optionally * one or more inner LineStrings. Each of these LineStrings should follow the linear ring rules. * <p> * Note that if a LineString breaks one of the linear ring rules, a {@link RuntimeException} will * be thrown. * * @param outer a LineString which defines the outer perimeter of the polygon * @param inner one or more LineStrings representing holes inside the outer perimeter * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Polygon fromOuterInner(@NonNull LineString outer, @Nullable LineString... inner) { isLinearRing(outer); List<List<Point>> coordinates = new ArrayList<>(); coordinates.add(outer.coordinates()); // If inner rings are set to null, return early. if (inner == null) { return new Polygon(TYPE, null, coordinates); } for (LineString lineString : inner) { isLinearRing(lineString); coordinates.add(lineString.coordinates()); } return new Polygon(TYPE, null, coordinates); } /** * Create a new instance of this class by passing in an outer {@link LineString} and optionally * one or more inner LineStrings. Each of these LineStrings should follow the linear ring rules. * <p> * Note that if a LineString breaks one of the linear ring rules, a {@link RuntimeException} will * be thrown. * * @param outer a LineString which defines the outer perimeter of the polygon * @param bbox optionally include a bbox definition as a double array * @param inner one or more LineStrings representing holes inside the outer perimeter * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Polygon fromOuterInner(@NonNull LineString outer, @Nullable BoundingBox bbox, @Nullable LineString... inner) { isLinearRing(outer); List<List<Point>> coordinates = new ArrayList<>(); coordinates.add(outer.coordinates()); // If inner rings are set to null, return early. if (inner == null) { return new Polygon(TYPE, bbox, coordinates); } for (LineString lineString : inner) { isLinearRing(lineString); coordinates.add(lineString.coordinates()); } return new Polygon(TYPE, bbox, coordinates); } /** * Create a new instance of this class by passing in an outer {@link LineString} and optionally * one or more inner LineStrings contained within a list. Each of these LineStrings should follow * the linear ring rules. * <p> * Note that if a LineString breaks one of the linear ring rules, a {@link RuntimeException} will * be thrown. * * @param outer a LineString which defines the outer perimeter of the polygon * @param inner one or more LineStrings inside a list representing holes inside the outer * perimeter * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Polygon fromOuterInner(@NonNull LineString outer, @Nullable @Size(min = 1) List<LineString> inner) { isLinearRing(outer); List<List<Point>> coordinates = new ArrayList<>(); coordinates.add(outer.coordinates()); // If inner rings are set to null, return early. if (inner == null || inner.isEmpty()) { return new Polygon(TYPE, null, coordinates); } for (LineString lineString : inner) { isLinearRing(lineString); coordinates.add(lineString.coordinates()); } return new Polygon(TYPE, null, coordinates); } /** * Create a new instance of this class by passing in an outer {@link LineString} and optionally * one or more inner LineStrings contained within a list. Each of these LineStrings should follow * the linear ring rules. * <p> * Note that if a LineString breaks one of the linear ring rules, a {@link RuntimeException} will * be thrown. * * @param outer a LineString which defines the outer perimeter of the polygon * @param bbox optionally include a bbox definition as a double array * @param inner one or more LineStrings inside a list representing holes inside the outer * perimeter * @return a new instance of this class defined by the values passed inside this static factory * method * @since 3.0.0 */ public static Polygon fromOuterInner(@NonNull LineString outer, @Nullable BoundingBox bbox, @Nullable @Size(min = 1) List<LineString> inner) { isLinearRing(outer); List<List<Point>> coordinates = new ArrayList<>(); coordinates.add(outer.coordinates()); // If inner rings are set to null, return early. if (inner == null) { return new Polygon(TYPE, bbox, coordinates); } for (LineString lineString : inner) { isLinearRing(lineString); coordinates.add(lineString.coordinates()); } return new Polygon(TYPE, bbox, coordinates); } Polygon(String type, @Nullable BoundingBox bbox, List<List<Point>> coordinates) { if (type == null) { throw new NullPointerException("Null type"); } this.type = type; this.bbox = bbox; if (coordinates == null) { throw new NullPointerException("Null coordinates"); } this.coordinates = coordinates; } /** * Convenience method to get the outer {@link LineString} which defines the outer perimeter of * the polygon. * * @return a {@link LineString} defining the outer perimeter of this polygon * @since 3.0.0 */ @Nullable public LineString outer() { return LineString.fromLngLats(coordinates().get(0)); } /** * Convenience method to get a list of inner {@link LineString}s defining holes inside the * polygon. It is not guaranteed that this instance of Polygon contains holes and thus, might * return a null or empty list. * * @return a List of {@link LineString}s defining holes inside the polygon * @since 3.0.0 */ @Nullable public List<LineString> inner() { List<List<Point>> coordinates = coordinates(); if (coordinates.size() <= 1) { return new ArrayList(0); } List<LineString> inner = new ArrayList<>(coordinates.size() - 1); for (List<Point> points : coordinates.subList(1, coordinates.size())) { inner.add(LineString.fromLngLats(points)); } return inner; } /** * This describes the TYPE of GeoJson geometry this object is, thus this will always return * {@link Polygon}. * * @return a String which describes the TYPE of geometry, for this object it will always return * {@code Polygon} * @since 1.0.0 */ @NonNull @Override public String type() { return type; } /** * A Feature Collection might have a member named {@code bbox} to include information on the * coordinate range for it's {@link Feature}s. The value of the bbox member MUST be a list of * size 2*n where n is the number of dimensions represented in the contained feature 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. * * @return a list of double coordinate values describing a bounding box * @since 3.0.0 */ @Nullable @Override public BoundingBox bbox() { return bbox; } /** * Provides the list of {@link Point}s that make up the Polygon geometry. The first list holds the * different LineStrings, first being the outer ring and the following entries being inner holes * (if they exist). * * @return a list of points * @since 3.0.0 */ @NonNull @Override public List<List<Point>> coordinates() { return coordinates; } /** * This takes the currently defined values found inside this instance and converts it to a GeoJson * string. * * @return a JSON string which represents this Polygon geometry * @since 1.0.0 */ @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } /** * Gson TYPE adapter for parsing Gson to this class. * * @param gson the built {@link Gson} object * @return the TYPE adapter for this class * @since 3.0.0 */ public static TypeAdapter<Polygon> typeAdapter(Gson gson) { return new Polygon.GsonTypeAdapter(gson); } /** * Checks to ensure that the LineStrings defining the polygon correctly and adhering to the linear * ring rules. * * @param lineString {@link LineString} the polygon geometry * @return true if number of coordinates are 4 or more, and first and last coordinates * are identical, else false * @throws GeoJsonException if number of coordinates are less than 4, * or first and last coordinates are not identical * @since 3.0.0 */ private static boolean isLinearRing(LineString lineString) { if (lineString.coordinates().size() < 4) { throw new GeoJsonException("LinearRings need to be made up of 4 or more coordinates."); } if (!(lineString.coordinates().get(0).equals( lineString.coordinates().get(lineString.coordinates().size() - 1)))) { throw new GeoJsonException("LinearRings require first and last coordinate to be identical."); } return true; } @Override public String toString() { return "Polygon{" + "type=" + type + ", " + "bbox=" + bbox + ", " + "coordinates=" + coordinates + "}"; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Polygon) { Polygon that = (Polygon) obj; return (this.type.equals(that.type())) && ((this.bbox == null) ? (that.bbox() == null) : this.bbox.equals(that.bbox())) && (this.coordinates.equals(that.coordinates())); } return false; } @Override public int hashCode() { int hashCode = 1; hashCode *= 1000003; hashCode ^= type.hashCode(); hashCode *= 1000003; hashCode ^= (bbox == null) ? 0 : bbox.hashCode(); hashCode *= 1000003; hashCode ^= coordinates.hashCode(); return hashCode; } /** * TypeAdapter for Polygon geometry. * * @since 4.6.0 */ static final class GsonTypeAdapter extends BaseGeometryTypeAdapter<Polygon, List<List<Point>>> { GsonTypeAdapter(Gson gson) { super(gson, new ListOfListOfPointCoordinatesTypeAdapter()); } @Override public void write(JsonWriter jsonWriter, Polygon object) throws IOException { writeCoordinateContainer(jsonWriter, object); } @Override public Polygon read(JsonReader jsonReader) throws IOException { return (Polygon) readCoordinateContainer(jsonReader); } @Override CoordinateContainer<List<List<Point>>> createCoordinateContainer(String type, BoundingBox bbox, List<List<Point>> coords) { return new Polygon(type == null ? "Polygon" : type, bbox, coords); } } }
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/package-info.java
/** * Contains the Nbmap Java GeoJson classes. */ package com.nbmap.geojson;
0
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson
java-sources/ai/nextbillion/nbmap-sdk-geojson/0.1.2/com/nbmap/geojson/constants/GeoJsonConstants.java
package com.nbmap.geojson.constants; /** * Contains constants used throughout the GeoJson classes. * * @since 3.0.0 */ public final class GeoJsonConstants { /** * A Mercator project has a finite longitude values, this constant represents the lowest value * available to represent a geolocation. * * @since 3.0.0 */ public static final double MIN_LONGITUDE = -180; /** * A Mercator project has a finite longitude values, this constant represents the highest value * available to represent a geolocation. * * @since 3.0.0 */ public static final double MAX_LONGITUDE = 180; /** * While on a Mercator projected map the width (longitude) has a finite values, the height * (latitude) can be infinitely long. This constant restrains the lower latitude value to -90 in * order to preserve map readability and allows easier logic for tile selection. * * @since 3.0.0 */ public static final double MIN_LATITUDE = -90; /** * While on a Mercator projected map the width (longitude) has a finite values, the height * (latitude) can be infinitely long. This constant restrains the upper latitude value to 90 in * order to preserve map readability and allows easier logic for tile selection. * * @since 3.0.0 */ public static final double MAX_LATITUDE = 90; private GeoJsonConstants() { // Private constructor to prevent initializing of this class. } }