## Snap a coordinate to the nearest road `routing().nearestPost(RoutingNearestPostParamsparams, RequestOptionsrequestOptions = RequestOptions.none()) : NearestResult` **post** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `params: RoutingNearestPostParams` - `lat: Double` Latitude - `lng: Double` Longitude - `outputFields: Optional` Comma-separated property fields to include - `outputInclude: Optional` Extra computed fields: bbox, distance, center - `outputPrecision: Optional` Coordinate decimal precision (1-15, default 7) - `radius: Optional` 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. - `geometry: GeoJsonGeometry` 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 - `distanceM: Optional` Distance from the input coordinate to the snapped point in meters - `edgeId: Optional` ID of the road network edge that was snapped to - `edgeLengthM: Optional` Length of the matched road edge in meters - `highway: Optional` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `osmWayId: Optional` OSM way ID of the matched road segment - `surface: Optional` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `type: Type` - `FEATURE("Feature")` ### Example ```kotlin 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 fun main() { val client: PlazaClient = PlazaOkHttpClient.fromEnv() val params: RoutingNearestPostParams = RoutingNearestPostParams.builder() .lat(0.0) .lng(0.0) .build() val 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" } ```