forked from devit-tel/go.osrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.go
36 lines (32 loc) · 817 Bytes
/
table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package osrm
// TableRequest represents a request to the table method
type TableRequest struct {
Profile string
Coordinates Geometry
Sources, Destinations []int
Annotations Annotations
}
// TableResponse resresents a response from the table method
type TableResponse struct {
ResponseStatus
Durations [][]float32 `json:"durations"`
Distances [][]float32 `json:"distances"`
}
func (r TableRequest) request() *request {
opts := options{}
if len(r.Sources) > 0 {
opts.addInt("sources", r.Sources...)
}
if len(r.Destinations) > 0 {
opts.addInt("destinations", r.Destinations...)
}
if r.Annotations != "" {
opts.add("annotations", string(r.Annotations))
}
return &request{
profile: r.Profile,
coords: r.Coordinates,
service: "table",
options: opts,
}
}