https://github.com/stremovskyy/gosrm
OSRM Library for GO
https://github.com/stremovskyy/gosrm
client-library go golang gosrm osrm osrm-backend
Last synced: about 1 year ago
JSON representation
OSRM Library for GO
- Host: GitHub
- URL: https://github.com/stremovskyy/gosrm
- Owner: stremovskyy
- License: mit
- Created: 2018-08-30T10:33:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-21T19:27:06.000Z (over 2 years ago)
- Last Synced: 2024-06-20T15:45:21.718Z (almost 2 years ago)
- Topics: client-library, go, golang, gosrm, osrm, osrm-backend
- Language: Go
- Size: 62.5 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# GOSRM - GO Client for OSRM
[](https://travis-ci.org/stremovskyy/gosrm)

[](https://godoc.org/github.com/stremovskyy/gosrm)
[](LICENSE)
[](https://goreportcard.com/report/github.com/stremovskyy/gosrm)
Advanced OSRM client for golang.
## Features
- Route Client
## Installation
```bash
go get github.com/stremovskyy/gosrm
```
## Quick Start
#### Route Service
```go
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)
}
```
#### Table Service
```go
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)
}
```
### Full Example
See `examples` folder