## Snap a coordinate to the nearest road `routing.nearest_post(**kwargs) -> NearestResult` **post** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `lat: Float` Latitude - `lng: Float` Longitude - `output_fields: String` Comma-separated property fields to include - `output_include: String` Extra computed fields: bbox, distance, center - `output_precision: Integer` Coordinate decimal precision (1-15, default 7) - `radius: Integer` 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: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `Array[Float]` [longitude, latitude] or [longitude, latitude, elevation] - `Array[Array[Float]]` Array of [lng, lat] positions - `Array[Array[Array[Float]]]` Array of linear rings / line strings - `Array[Array[Array[Array[Float]]]]` Array of polygons - `type: :Point | :LineString | :Polygon | 3 more` Geometry type - `:Point` - `:LineString` - `:Polygon` - `:MultiPoint` - `:MultiLineString` - `:MultiPolygon` - `properties: { distance_m, edge_id, edge_length_m, 3 more}` Snap result metadata - `distance_m: Float` Distance from the input coordinate to the snapped point in meters - `edge_id: Integer` ID of the road network edge that was snapped to - `edge_length_m: Float` Length of the matched road edge in meters - `highway: String` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `osm_way_id: Integer` OSM way ID of the matched road segment - `surface: String` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `type: :Feature` - `:Feature` ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) nearest_result = plaza.routing.nearest_post(lat: 0, lng: 0) puts(nearest_result) ``` #### 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" } ```