Skip to content

Commit 95f4abf

Browse files
authored
docs: update readme
1 parent f2ee611 commit 95f4abf

File tree

1 file changed

+65
-65
lines changed

1 file changed

+65
-65
lines changed

README.md

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### GOSRM
22
---
3-
**GOSRM** is an OSRM client written in Go. It implements all OSRM 5.x installations.
3+
**GOSRM** is an OSRM client written in Go. It implements all OSRM 5.x installations.
44
If you want to get the most out of this package I highly recommend to read OSRM [docs](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md).
55

66
#### Features
@@ -16,80 +16,80 @@ If you want to get the most out of this package I highly recommend to read OSRM
1616
---
1717
Requires Go >= 1.18: `go get github.com/mojixcoder/gosrm`
1818

19-
#### How to use
19+
#### How To Use
2020
---
2121
```go
2222
package main
2323

2424
import (
25-
"context"
26-
"fmt"
25+
"context"
26+
"fmt"
2727

28-
"github.com/mojixcoder/gosrm"
28+
"github.com/mojixcoder/gosrm"
2929
)
3030

3131
func main() {
32-
osrm, err := gosrm.New("http://router.project-osrm.org")
33-
checkErr(err)
34-
35-
nearestRes, err := gosrm.Nearest(context.Background(), osrm, gosrm.Request{
36-
Profile: gosrm.ProfileDriving,
37-
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}},
38-
}, gosrm.WithNumber(3), gosrm.WithBearings([]gosrm.Bearing{{Value: 0, Range: 20}}))
39-
checkErr(err)
40-
41-
fmt.Println("### Nearest Response ###")
42-
fmt.Printf("%#v\n", nearestRes)
43-
fmt.Println("##########")
44-
45-
// String type represents the type of geometries returned by OSRM.
46-
// It can be either string or gosrm.LineString based on geometries option.
47-
// If you don't specify any geometries the default is polyline and you can use string.
48-
routeRes, err := gosrm.Route[string](context.Background(), osrm, gosrm.Request{
49-
Profile: gosrm.ProfileDriving,
50-
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}, {13.397634, 52.529407}, {13.428555, 52.523219}},
51-
})
52-
checkErr(err)
53-
54-
fmt.Println("\n### Route Response ###")
55-
fmt.Printf("%#v\n", routeRes)
56-
fmt.Println("##########")
57-
58-
tableRes, err := gosrm.Table(context.Background(), osrm, gosrm.Request{
59-
Profile: gosrm.ProfileDriving,
60-
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}, {13.397634, 52.529407}, {13.428555, 52.523219}},
61-
}, gosrm.WithSources([]uint16{0, 1}), gosrm.WithDestinations([]uint16{2}))
62-
checkErr(err)
63-
64-
fmt.Println("\n### Table Response ###")
65-
fmt.Printf("%#v\n", tableRes)
66-
fmt.Println("##########")
67-
68-
// This time we use geojson geometries so geometry type is gosrm.LineString not string.
69-
matchRes, err := gosrm.Match[gosrm.LineString](context.Background(), osrm, gosrm.Request{
70-
Profile: gosrm.ProfileDriving,
71-
Coordinates: []gosrm.Coordinate{{13.3122, 52.5322}, {13.3065, 52.5283}},
72-
}, gosrm.WithAnnotations(gosrm.AnnotationsTrue), gosrm.WithGeometries(gosrm.GeometryGeoJSON))
73-
checkErr(err)
74-
75-
fmt.Println("\n### Match Response ###")
76-
fmt.Printf("%#v\n", matchRes)
77-
fmt.Println("##########")
78-
79-
tripRes, err := gosrm.Trip[string](context.Background(), osrm, gosrm.Request{
80-
Profile: gosrm.ProfileDriving,
81-
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}, {13.397634, 52.529407}, {13.428555, 52.523219}, {13.418555, 52.523215}},
82-
}, gosrm.WithSource(gosrm.SourceFirst), gosrm.WithDestination(gosrm.DestinationLast))
83-
checkErr(err)
84-
85-
fmt.Println("\n### Trip Response ###")
86-
fmt.Printf("%#v\n", tripRes)
87-
fmt.Println("##########")
32+
osrm, err := gosrm.New("http://router.project-osrm.org")
33+
checkErr(err)
34+
35+
nearestRes, err := gosrm.Nearest(context.Background(), osrm, gosrm.Request{
36+
Profile: gosrm.ProfileDriving,
37+
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}},
38+
}, gosrm.WithNumber(3), gosrm.WithBearings([]gosrm.Bearing{{Value: 0, Range: 20}}))
39+
checkErr(err)
40+
41+
fmt.Println("### Nearest Response ###")
42+
fmt.Printf("%#v\n", nearestRes)
43+
fmt.Println("##########")
44+
45+
// String type represents the type of geometries returned by OSRM.
46+
// It can be either string or gosrm.LineString based on geometries option.
47+
// If you don't specify any geometries the default is polyline and you can use string.
48+
routeRes, err := gosrm.Route[string](context.Background(), osrm, gosrm.Request{
49+
Profile: gosrm.ProfileDriving,
50+
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}, {13.397634, 52.529407}, {13.428555, 52.523219}},
51+
})
52+
checkErr(err)
53+
54+
fmt.Println("\n### Route Response ###")
55+
fmt.Printf("%#v\n", routeRes)
56+
fmt.Println("##########")
57+
58+
tableRes, err := gosrm.Table(context.Background(), osrm, gosrm.Request{
59+
Profile: gosrm.ProfileDriving,
60+
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}, {13.397634, 52.529407}, {13.428555, 52.523219}},
61+
}, gosrm.WithSources([]uint16{0, 1}), gosrm.WithDestinations([]uint16{2}))
62+
checkErr(err)
63+
64+
fmt.Println("\n### Table Response ###")
65+
fmt.Printf("%#v\n", tableRes)
66+
fmt.Println("##########")
67+
68+
// This time we use geojson geometries so geometry type is gosrm.LineString not string.
69+
matchRes, err := gosrm.Match[gosrm.LineString](context.Background(), osrm, gosrm.Request{
70+
Profile: gosrm.ProfileDriving,
71+
Coordinates: []gosrm.Coordinate{{13.3122, 52.5322}, {13.3065, 52.5283}},
72+
}, gosrm.WithAnnotations(gosrm.AnnotationsTrue), gosrm.WithGeometries(gosrm.GeometryGeoJSON))
73+
checkErr(err)
74+
75+
fmt.Println("\n### Match Response ###")
76+
fmt.Printf("%#v\n", matchRes)
77+
fmt.Println("##########")
78+
79+
tripRes, err := gosrm.Trip[string](context.Background(), osrm, gosrm.Request{
80+
Profile: gosrm.ProfileDriving,
81+
Coordinates: []gosrm.Coordinate{{13.388860, 52.517037}, {13.397634, 52.529407}, {13.428555, 52.523219}, {13.418555, 52.523215}},
82+
}, gosrm.WithSource(gosrm.SourceFirst), gosrm.WithDestination(gosrm.DestinationLast))
83+
checkErr(err)
84+
85+
fmt.Println("\n### Trip Response ###")
86+
fmt.Printf("%#v\n", tripRes)
87+
fmt.Println("##########")
8888
}
8989

9090
func checkErr(err error) {
91-
if err != nil {
92-
panic(err)
93-
}
91+
if err != nil {
92+
panic(err)
93+
}
9494
}
95-
```
95+
```

0 commit comments

Comments
 (0)