## Snap a coordinate to the nearest road `client.Routing.Nearest(ctx, query) (*NearestResult, error)` **get** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `query RoutingNearestParams` - `Lat param.Field[float64]` Latitude - `Lng param.Field[float64]` Longitude - `Radius param.Field[int64]` Search radius in meters (default 500, max 5000) ### Returns - `type NearestResult struct{…}` GeoJSON Point Feature snapped to the nearest road segment - `Geometry GeoJsonGeometry` - `Coordinates GeoJsonGeometryCoordinatesUnion` GeoJSON coordinates array (nesting depth varies by geometry type) - `type GeoJsonGeometryCoordinatesArray []float64` - `type GeoJsonGeometryCoordinatesArray [][]float64` - `type GeoJsonGeometryCoordinatesArray [][][]float64` - `type GeoJsonGeometryCoordinatesArray [][][][]float64` - `Type GeoJsonGeometryType` - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties NearestResultProperties` - `DistanceM float64` Distance to nearest road in meters - `EdgeID int64` Road edge ID - `Type NearestResultType` - `const NearestResultTypeFeature NearestResultType = "Feature"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) nearestResult, err := client.Routing.Nearest(context.TODO(), githubcomplazafyiplazago.RoutingNearestParams{ Lat: githubcomplazafyiplazago.F(0.000000), Lng: githubcomplazafyiplazago.F(0.000000), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", nearestResult.Geometry) } ``` #### Response ```json { "geometry": { "coordinates": [ 0 ], "type": "Point" }, "properties": { "distance_m": 0, "edge_id": 0 }, "type": "Feature" } ```