## Snap a coordinate to the nearest road `NearestResult routing().nearestPost(RoutingNearestPostParamsparams, RequestOptionsrequestOptions = RequestOptions.none())` **post** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `RoutingNearestPostParams params` - `double lat` Latitude - `double lng` Longitude - `Optional outputFields` Comma-separated property fields to include - `Optional outputInclude` Extra computed fields: bbox, distance, center - `Optional outputPrecision` Coordinate decimal precision (1-15, default 7) - `Optional radius` Search radius in meters (default 500, max 5000) ### Returns - `class NearestResult:` GeoJSON Point Feature representing the nearest point on the road network to the input coordinate. Used for snapping GPS coordinates to roads. - `GeoJsonGeometry geometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates coordinates` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `List` - `List>` - `List>>` - `List>>>` - `Type type` Geometry type - `POINT("Point")` - `LINE_STRING("LineString")` - `POLYGON("Polygon")` - `MULTI_POINT("MultiPoint")` - `MULTI_LINE_STRING("MultiLineString")` - `MULTI_POLYGON("MultiPolygon")` - `Properties properties` Snap result metadata - `Optional distanceM` Distance from the input coordinate to the snapped point in meters - `Optional edgeId` ID of the road network edge that was snapped to - `Optional edgeLengthM` Length of the matched road edge in meters - `Optional highway` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `Optional osmWayId` OSM way ID of the matched road segment - `Optional surface` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `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.RoutingNearestPostParams; public final class Main { private Main() {} public static void main(String[] args) { PlazaClient client = PlazaOkHttpClient.fromEnv(); RoutingNearestPostParams params = RoutingNearestPostParams.builder() .lat(0.0) .lng(0.0) .build(); NearestResult nearestResult = client.routing().nearestPost(params); } } ``` #### Response ```json { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "distance_m": 12.4, "edge_id": 0, "edge_length_m": 0, "highway": "highway", "osm_way_id": 0, "surface": "surface" }, "type": "Feature" } ```