Skip to content

Commit fb76867

Browse files
Support annotations for TableRequest
1 parent 435fc3e commit fb76867

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

table.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type TableRequest struct {
55
Profile string
66
Coordinates Geometry
77
Sources, Destinations []int
8+
Annotations []string
89
}
910

1011
// TableResponse resresents a response from the table method
@@ -21,6 +22,9 @@ func (r TableRequest) request() *request {
2122
if len(r.Destinations) > 0 {
2223
opts.addInt("destinations", r.Destinations...)
2324
}
25+
if len(r.Annotations) > 0 {
26+
opts.add("annotations", r.Annotations...)
27+
}
2428

2529
return &request{
2630
profile: r.Profile,

table_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func TestNotEmptyTableRequestOptions(t *testing.T) {
1515
req := TableRequest{
1616
Sources: []int{0, 1, 2},
1717
Destinations: []int{1, 3},
18+
Annotations: []string{AnnotationsDuration.String(), AnnotationsDistance.String()},
1819
}
19-
assert.Equal(t, "destinations=1;3&sources=0;1;2", req.request().options.encode())
20+
assert.Equal(t, "annotations=duration;distance&destinations=1;3&sources=0;1;2", req.request().options.encode())
2021
}

0 commit comments

Comments
 (0)