## Snap a coordinate to the nearest road `NearestResult routing().nearest(RoutingNearestParamsparams, RequestOptionsrequestOptions = RequestOptions.none())` **get** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `RoutingNearestParams params` - `double lat` Latitude - `double lng` Longitude - `Optional radius` Search radius in meters (default 500, max 5000) ### Returns - `class NearestResult:` GeoJSON Point Feature snapped to the nearest road segment - `GeoJsonGeometry geometry` - `Coordinates coordinates` GeoJSON coordinates array (nesting depth varies by geometry type) - `List` - `List>` - `List>>` - `List>>>` - `Type type` - `POINT("Point")` - `LINE_STRING("LineString")` - `POLYGON("Polygon")` - `MULTI_POINT("MultiPoint")` - `MULTI_LINE_STRING("MultiLineString")` - `MULTI_POLYGON("MultiPolygon")` - `Properties properties` - `Optional distanceM` Distance to nearest road in meters - `Optional edgeId` Road edge ID - `Type type` - `FEATURE("Feature")` ### Example ```java package com.plazafyi.example; import com.plazafyi.client.PlazaClient; import com.plazafyi.client.okhttp.PlazaOkHttpClient; import com.plazafyi.models.routing.NearestResult; import com.plazafyi.models.routing.RoutingNearestParams; public final class Main { private Main() {} public static void main(String[] args) { PlazaClient client = PlazaOkHttpClient.fromEnv(); RoutingNearestParams params = RoutingNearestParams.builder() .lat(0.0) .lng(0.0) .build(); NearestResult nearestResult = client.routing().nearest(params); } } ``` #### Response ```json { "geometry": { "coordinates": [ 0 ], "type": "Point" }, "properties": { "distance_m": 0, "edge_id": 0 }, "type": "Feature" } ```