Package com.cercalia.sdk.services
Class ProximityService
java.lang.Object
com.cercalia.sdk.CercaliaClient
com.cercalia.sdk.services.ProximityService
Service for finding nearby points of interest using the Cercalia Proximity API.
This service provides methods to find POIs near a center point, optionally filtered by category and with routing distance/time calculations.
ProximityService service = new ProximityService(config);
Coordinate center = new Coordinate(41.3851, 2.1734);
// 1. Find nearest POIs (e.g. gas stations)
ProximityResult result = service.findNearest(ProximityOptions.builder(center)
.categories("D00GASP")
.count(5)
.maxRadius(10000) // 10km
.build());
// 2. Find nearest POIs with routing info (distance/time)
ProximityResult routingResult = service.findNearestWithRouting(center, "D00GASP",
ProximityRouteWeight.TIME, 5);
- See Also:
-
Field Summary
Fields inherited from class com.cercalia.sdk.CercaliaClient
config, httpClient, logger, objectMapper -
Constructor Summary
ConstructorsConstructorDescriptionProximityService(@NotNull CercaliaConfig config) Creates a new ProximityService with the specified configuration. -
Method Summary
Modifier and TypeMethodDescription@NotNull ProximityResultfindNearest(@NotNull ProximityOptions options) Find nearest POIs from a center point.@NotNull CompletableFuture<ProximityResult>findNearestAsync(@NotNull ProximityOptions options) Find nearest POIs asynchronously.@NotNull ProximityResultfindNearestByCategory(@NotNull Coordinate center, @NotNull String categoryCode) Find nearest POIs by category with default count of 5.@NotNull ProximityResultfindNearestByCategory(@NotNull Coordinate center, @NotNull String categoryCode, int count) Find nearest POIs by category.@NotNull ProximityResultfindNearestWithRouting(@NotNull Coordinate center, @NotNull String categoryCode) Find nearest POIs with routing time (default count of 5).@NotNull ProximityResultfindNearestWithRouting(@NotNull Coordinate center, @NotNull String categoryCode, @NotNull ProximityRouteWeight weight, int count) Find nearest POIs with routing distance/time.Methods inherited from class com.cercalia.sdk.CercaliaClient
addIfPresent, addIfPresent, addIfPresent, addIfTrue, getConfig, newParams, newParams, request, request, requestAsync, requestAsync
-
Constructor Details
-
ProximityService
Creates a new ProximityService with the specified configuration.- Parameters:
config- the Cercalia configuration
-
-
Method Details
-
findNearest
Find nearest POIs from a center point.- Parameters:
options- the search options- Returns:
- the proximity search result
- Throws:
CercaliaException- if the request fails
-
findNearestAsync
@NotNull public @NotNull CompletableFuture<ProximityResult> findNearestAsync(@NotNull @NotNull ProximityOptions options) Find nearest POIs asynchronously.- Parameters:
options- the search options- Returns:
- CompletableFuture with the proximity result
-
findNearestByCategory
@NotNull public @NotNull ProximityResult findNearestByCategory(@NotNull @NotNull Coordinate center, @NotNull @NotNull String categoryCode, int count) Find nearest POIs by category.- Parameters:
center- the center coordinatecategoryCode- the category codecount- the number of results to return (default: 5)- Returns:
- the proximity search result
- Throws:
CercaliaException- if the request fails
-
findNearestByCategory
@NotNull public @NotNull ProximityResult findNearestByCategory(@NotNull @NotNull Coordinate center, @NotNull @NotNull String categoryCode) Find nearest POIs by category with default count of 5.- Parameters:
center- the center coordinatecategoryCode- the category code- Returns:
- the proximity search result
- Throws:
CercaliaException- if the request fails
-
findNearestWithRouting
@NotNull public @NotNull ProximityResult findNearestWithRouting(@NotNull @NotNull Coordinate center, @NotNull @NotNull String categoryCode, @NotNull @NotNull ProximityRouteWeight weight, int count) Find nearest POIs with routing distance/time.- Parameters:
center- the center coordinatecategoryCode- the category codeweight- the routing weight (time or distance)count- the number of results to return- Returns:
- the proximity search result
- Throws:
CercaliaException- if the request fails
-
findNearestWithRouting
@NotNull public @NotNull ProximityResult findNearestWithRouting(@NotNull @NotNull Coordinate center, @NotNull @NotNull String categoryCode) Find nearest POIs with routing time (default count of 5).- Parameters:
center- the center coordinatecategoryCode- the category code- Returns:
- the proximity search result
- Throws:
CercaliaException- if the request fails
-