Advanced OSRM client for golang.
- Route Client
go get github.com/stremovskyy/gosrm
package main
import (
"fmt"
"net/url"
"github.com/paulmach/go.geo"
"github.com/stremovskyy/gosrm"
)
func main() {
options := &gosrm.Options{
Url: url.URL{Host: "https://router.project-osrm.org/"},
Service: consts.ServiceRoute,
Version: consts.VersionFirst,
Profile: consts.ProfileDriving,
RequestTimeout: 5,
}
client := gosrm.NewClient(options)
routeRequest := &models.RouteRequest{
Coordinates: geo.PointSet{{36.232051849365234, 49.98765584451778}, {36.22089385986328, 50.03718650830641}},
}
response, err := client.Route(routeRequest)
if err != nil {
panic(err.Error())
}
fmt.Printf("%#v", response)
}
package main
import (
"fmt"
"net/url"
"github.com/paulmach/go.geo"
"github.com/stremovskyy/gosrm"
)
func main() {
options := &gosrm.Options{
Url: url.URL{Host: "https://router.project-osrm.org/"},
Service: consts.ServiceTable,
Version: consts.VersionFirst,
Profile: consts.ProfileDriving,
RequestTimeout: 5,
}
client := gosrm.NewClient(options)
sources := []int{1, 2}
destinations := []int{2, 1}
annotation := consts.TableAnnotationDurationDistance
scaleFactor := 1.2
tableRequest := &models.TableRequest{
Coordinates: geo.PointSet{{36.232051849365234, 49.98765584451778}, {36.22089385986328, 50.03718650830641}},
Sources: &sources,
Destinations: &destinations,
Annotations: &annotation,
ScaleFactor: &scaleFactor,
}
response, err := client.Table(tableRequest)
if err != nil {
panic(err.Error())
}
fmt.Printf("%#v", response)
}
See examples
folder