Package com.cercalia.sdk.services
Class IsochroneService
java.lang.Object
com.cercalia.sdk.CercaliaClient
com.cercalia.sdk.services.IsochroneService
Service for calculating isochrones (service areas) using the Cercalia API.
An isochrone is a polygon representing the area reachable from a center point within a given time or distance constraint.
IsochroneService service = new IsochroneService(config);
Coordinate center = new Coordinate(41.3851, 2.1734);
// 1. Calculate a single isochrone (e.g. 10 minutes)
IsochroneResult result = service.calculate(center, IsochroneOptions.builder()
.value(10)
.weight(IsochroneWeight.TIME)
.method(IsochroneMethod.CONCAVEHULL)
.build());
// 2. Calculate multiple concentric isochrones (e.g. 5, 10, 15 minutes)
List<IsochroneResult> results = service.calculateMultiple(center,
new int[]{5, 10, 15}, IsochroneWeight.TIME);
- See Also:
-
Field Summary
Fields inherited from class com.cercalia.sdk.CercaliaClient
config, httpClient, logger, objectMapper -
Constructor Summary
ConstructorsConstructorDescriptionIsochroneService(@NotNull CercaliaConfig config) Creates a new IsochroneService with the specified configuration. -
Method Summary
Modifier and TypeMethodDescription@NotNull IsochroneResultcalculate(@NotNull Coordinate center, @NotNull IsochroneOptions options) Calculate a single isochrone (service area) from a center point.@NotNull CompletableFuture<IsochroneResult>calculateAsync(@NotNull Coordinate center, @NotNull IsochroneOptions options) Calculate a single isochrone asynchronously.@NotNull List<IsochroneResult>calculateMultiple(@NotNull Coordinate center, @org.jetbrains.annotations.NotNull int[] values, @NotNull IsochroneWeight weight) Calculate multiple isochrones (concentric service areas) in a single API request.@NotNull List<IsochroneResult>calculateMultiple(@NotNull Coordinate center, @org.jetbrains.annotations.NotNull int[] values, @NotNull IsochroneWeight weight, @NotNull IsochroneMethod method) Calculate multiple isochrones (concentric service areas) in a single API request.@NotNull CompletableFuture<List<IsochroneResult>>calculateMultipleAsync(@NotNull Coordinate center, @org.jetbrains.annotations.NotNull int[] values, @NotNull IsochroneWeight weight) Calculate multiple isochrones asynchronously.Methods inherited from class com.cercalia.sdk.CercaliaClient
addIfPresent, addIfPresent, addIfPresent, addIfTrue, getConfig, newParams, newParams, request, request, requestAsync, requestAsync
-
Constructor Details
-
IsochroneService
Creates a new IsochroneService with the specified configuration.- Parameters:
config- the Cercalia configuration
-
-
Method Details
-
calculate
@NotNull public @NotNull IsochroneResult calculate(@NotNull @NotNull Coordinate center, @NotNull @NotNull IsochroneOptions options) Calculate a single isochrone (service area) from a center point.- Parameters:
center- the center coordinate for the isochrone (WGS84)options- the isochrone calculation options (value, weight, method)- Returns:
- IsochroneResult with WKT polygon geometry
- Throws:
CercaliaException- if the request failsIllegalArgumentException- if value is not greater than zero
-
calculateAsync
@NotNull public @NotNull CompletableFuture<IsochroneResult> calculateAsync(@NotNull @NotNull Coordinate center, @NotNull @NotNull IsochroneOptions options) Calculate a single isochrone asynchronously.- Parameters:
center- the center coordinateoptions- the isochrone calculation options- Returns:
- CompletableFuture with the IsochroneResult
-
calculateMultiple
@NotNull public @NotNull List<IsochroneResult> calculateMultiple(@NotNull @NotNull Coordinate center, @NotNull @org.jetbrains.annotations.NotNull int[] values, @NotNull @NotNull IsochroneWeight weight) Calculate multiple isochrones (concentric service areas) in a single API request.- Parameters:
center- the center coordinate (WGS84)values- array of values (e.g., [5, 10, 15] for 5, 10, 15 minutes)weight- the weight type (time or distance)- Returns:
- list of IsochroneResult, one for each value
- Throws:
CercaliaException- if the request fails
-
calculateMultiple
@NotNull public @NotNull List<IsochroneResult> calculateMultiple(@NotNull @NotNull Coordinate center, @NotNull @org.jetbrains.annotations.NotNull int[] values, @NotNull @NotNull IsochroneWeight weight, @NotNull @NotNull IsochroneMethod method) Calculate multiple isochrones (concentric service areas) in a single API request.- Parameters:
center- the center coordinate (WGS84)values- array of values (e.g., [5, 10, 15] for 5, 10, 15 minutes)weight- the weight type (time or distance)method- the method for polygon calculation- Returns:
- list of IsochroneResult, one for each value
- Throws:
CercaliaException- if the request fails
-
calculateMultipleAsync
@NotNull public @NotNull CompletableFuture<List<IsochroneResult>> calculateMultipleAsync(@NotNull @NotNull Coordinate center, @NotNull @org.jetbrains.annotations.NotNull int[] values, @NotNull @NotNull IsochroneWeight weight) Calculate multiple isochrones asynchronously.- Parameters:
center- the center coordinatevalues- array of valuesweight- the weight type- Returns:
- CompletableFuture with list of IsochroneResult
-