## Snap a coordinate to the nearest road `client.routing.nearestPost(RoutingNearestPostParamsparams, RequestOptionsoptions?): NearestResult` **post** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `params: RoutingNearestPostParams` - `lat: number` Latitude - `lng: number` Longitude - `outputFields?: string` Comma-separated property fields to include - `outputInclude?: string` Extra computed fields: bbox, distance, center - `outputPrecision?: number` Coordinate decimal precision (1-15, default 7) - `radius?: number` Search radius in meters (default 500, max 5000) ### Returns - `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: Array | Array> | Array>> | Array>>>` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `Array` - `Array>` - `Array>>` - `Array>>>` - `type: "Point" | "LineString" | "Polygon" | 3 more` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: Properties` Snap result metadata - `distance_m?: number` Distance from the input coordinate to the snapped point in meters - `edge_id?: number` ID of the road network edge that was snapped to - `edge_length_m?: number` Length of the matched road edge in meters - `highway?: string | null` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `osm_way_id?: number` OSM way ID of the matched road segment - `surface?: string | null` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `type: "Feature"` - `"Feature"` ### Example ```typescript import Plaza from '@plazafyi/sdk'; const client = new Plaza({ apiKey: process.env['PLAZA_API_KEY'], // This is the default and can be omitted }); const nearestResult = await client.routing.nearestPost({ lat: 0, lng: 0 }); console.log(nearestResult.geometry); ``` #### 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" } ```