Snap a coordinate to the nearest road
client.Routing.NearestPost(ctx, body) (*NearestResult, error)
POST/api/v1/nearest
Snap a coordinate to the nearest road
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.NearestPost(context.TODO(), githubcomplazafyiplazago.RoutingNearestPostParams{
Lat: githubcomplazafyiplazago.F(0.000000),
Lng: githubcomplazafyiplazago.F(0.000000),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", nearestResult.Geometry)
}
{
"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"
}Returns Examples
{
"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"
}