From fb7686786fb75536f08b9db1108703e03075b9dc Mon Sep 17 00:00:00 2001 From: Kevin Chen Date: Mon, 23 May 2022 17:38:18 -0400 Subject: [PATCH] Support annotations for TableRequest --- table.go | 4 ++++ table_test.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/table.go b/table.go index a539131..088de0e 100644 --- a/table.go +++ b/table.go @@ -5,6 +5,7 @@ type TableRequest struct { Profile string Coordinates Geometry Sources, Destinations []int + Annotations []string } // TableResponse resresents a response from the table method @@ -21,6 +22,9 @@ func (r TableRequest) request() *request { if len(r.Destinations) > 0 { opts.addInt("destinations", r.Destinations...) } + if len(r.Annotations) > 0 { + opts.add("annotations", r.Annotations...) + } return &request{ profile: r.Profile, diff --git a/table_test.go b/table_test.go index cf8a55f..b30a07a 100644 --- a/table_test.go +++ b/table_test.go @@ -15,6 +15,7 @@ func TestNotEmptyTableRequestOptions(t *testing.T) { req := TableRequest{ Sources: []int{0, 1, 2}, Destinations: []int{1, 3}, + Annotations: []string{AnnotationsDuration.String(), AnnotationsDistance.String()}, } - assert.Equal(t, "destinations=1;3&sources=0;1;2", req.request().options.encode()) + assert.Equal(t, "annotations=duration;distance&destinations=1;3&sources=0;1;2", req.request().options.encode()) }