forked from gojuno/go.osrm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrip.go
49 lines (44 loc) · 1.25 KB
/
trip.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
45
46
47
48
49
package osrm
type TripRequest struct {
Profile string
Coordinates Geometry
Roundtrip Roundtrip
Source Source
Destination Destination
Steps Steps
Annotations Annotations
Geometries Geometries
Overview Overview
}
type TripResponse struct {
ResponseStatus
Waypoints []TripWaypoint `json:"waypoints"`
Trips []Route `json:"trips"`
}
type TripWaypoint struct {
TripsIndex int `json:"trips_index"`
WaypointIndex int `json:"waypoint_index"`
Waypoint
}
func (r TripRequest) request() *request {
return &request{
profile: r.Profile,
coords: r.Coordinates,
service: "trip",
options: stepsOptions(r.Steps, r.Annotations, r.Overview, r.Geometries).
setStringer("roundtrip", valueOrDefault(r.Roundtrip, RoundtripDefault)).
setStringer("source", valueOrDefault(r.Source, SourceDefault)).
setStringer("destination", valueOrDefault(r.Destination, DestinationDefault)),
}
}
func (r TripRequest) IsSupported() bool {
fixedstart := r.Source == SourceFirst || (r.Source == SourceAny && r.Destination == DestinationAny)
fixedend := r.Destination == DestinationLast
roundtrip := r.Roundtrip == RoundtripTrue
if fixedstart && fixedend && !roundtrip {
return true
} else if roundtrip {
return true
}
return false
}