forked from devit-tel/go.osrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nearest.go
44 lines (37 loc) · 975 Bytes
/
nearest.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
37
38
39
40
41
42
43
44
package osrm
import geo "github.com/paulmach/go.geo"
// NearestRequest represents a request to the nearest method
type NearestRequest struct {
Profile string
Coordinates Geometry
Bearings []Bearing
Number int
}
// NearestResponse represents a response from the nearest method
type NearestResponse struct {
ResponseStatus
Waypoints []NearestWaypoint `json:"waypoints"`
}
// NearestWaypoint represents a nearest point on a nearest query
type NearestWaypoint struct {
Location geo.Point `json:"location"`
Distance float64 `json:"distance"`
Name string `json:"name"`
Hint string `json:"hint"`
Nodes []uint64 `json:"nodes"`
}
func (r NearestRequest) request() *request {
opts := options{}
if r.Number > 0 {
opts.addInt("number", r.Number)
}
if len(r.Bearings) > 0 {
opts.set("bearings", bearings(r.Bearings))
}
return &request{
profile: r.Profile,
service: "nearest",
coords: r.Coordinates,
options: opts,
}
}