This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanner_types.go
194 lines (169 loc) · 6.69 KB
/
planner_types.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package geoapify
type Location struct {
ID string `json:"id,omitempty"`
LonLat `json:"location"`
}
type Break struct {
Duration uint `json:"duration,omitempty"`
TimeWindows [][2]uint `json:"time_windows,omitempty"`
}
type Agent struct {
Start LonLat `json:"start_location,omitempty"`
StartLocIndex uint `json:"start_location_index,omitempty"`
End LonLat `json:"end_location,omitempty"`
EndLocIndex uint `json:"end_location_index,omitempty"`
PickupCapacity uint `json:"pickup_capacity,omitempty"`
DlvyCapacity uint `json:"delivery_capacity,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
Breaks []Break `json:"breaks,omitempty"`
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
TimeWindows [][2]uint `json:"time_windows,omitempty"`
}
type Job struct {
LocIndex uint `json:"location_index,omitempty"`
Priority uint8 `json:"priority,omitempty"` // 0..100: 0 lowest
Duration uint `json:"duration,omitempty"`
PickupAmount uint `json:"pickup_amount,omitempty"`
DlvyAmount uint `json:"delivery_amount,omitempty"`
Requirements []string `json:"requirements,omitempty"`
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
TimeWindows [][2]uint `json:"time_windows,omitempty"`
LonLat `json:"location,omitempty"`
}
type Destination struct {
LonLat `json:"location,omitempty"`
LocIndex uint `json:"location_index,omitempty"`
Duration uint `json:"duration,omitempty"`
TimeWindows [][2]uint `json:"time_windows,omitempty"`
}
type Shipment struct {
ID string `json:"id,omitempty"`
Pickup Destination `json:"pickup,omitempty"`
Delivery Destination `json:"delivery,omitempty"`
Requirements []string `json:"requirements,omitempty"`
Priority uint8 `json:"priority,omitempty"` // 0..100: 0 lowest
Description string `json:"description,omitempty"`
}
type Avoid struct {
Type string `json:"type"` // e.g. tolls
Importance uint8 `json:"importance,omitempty"`
}
// Request is the API to describe the target routes that need to be planned.
// Mode must be one of [walk, hike, scooter, motorcycle, drive, truck,
// light_truck, medium_truck, truck_dangerous_goods, heavy_truck,
// long_truck, bicycle, mountain_bike, road_bike, bus, drive_shortest,
// drive_traffic_approximated, truck_traffic_approximated]
type Request struct {
Mode string `json:"mode,omitempty"`
Agents []Agent `json:"agents,omitempty"`
Jobs []Job `json:"jobs,omitempty"`
Shipments []Shipment `json:"shipments,omitempty"`
Locations []Location `json:"locations,omitempty"`
Traffic string `json:"traffic,omitempty"` // approximated
Avoid []Avoid `json:"avoid,omitempty"`
}
/* ************************ */
type Action struct {
Type string `json:"type"` // start|end|pickup|delivery
StartTime uint `json:"start_time,omitempty"`
Duration uint `json:"duration,omitempty"`
ShipmentIndex uint `json:"shipment_index,omitempty"`
ShipmentID string `json:"shipment_id,omitempty"`
JobID string `json:"job_id,omitempty"`
WaypointIndex uint `json:"waypoint_index,omitempty"`
Index uint `json:"index,omitempty"`
JobIndex uint `json:"job_index,omitempty"`
}
type Waypoint struct {
OriginalLoc LonLat `json:"original_location,omitempty"`
OriginalLocIndex uint `json:"original_location_index,omitempty"`
OriginalLocID string `json:"original_location_id,omitempty"`
Location LonLat `json:"location"`
StartTime uint `json:"start_time,omitempty"`
Duration uint `json:"duration,omitempty"`
Actions []Action `json:"actions,omitempty"`
PrevLegIndex uint `json:"prev_leg_index,omitempty"`
NextLegIndex uint `json:"next_leg_index,omitempty"`
}
type Step struct {
Distance uint `json:"distance,omitempty"` // meters
Time uint `json:"time,omitempty"` // seconds
FromIndex uint `json:"from_index,omitempty"`
ToIndex uint `json:"to_index,omitempty"`
}
type Leg struct {
Distance uint `json:"distance,omitempty"` // meters
Time uint `json:"time,omitempty"` // seconds
Steps []Step `json:"steps,omitempty"`
FromWaypointIndex uint `json:"from_waypoint_index,omitempty"`
ToWaypointIndex uint `json:"to_waypoint_index,omitempty"`
}
type AgentPlan struct {
AgentIndex uint `json:"agent_index"`
Distance uint `json:"distance,omitempty"` // meters
Time uint `json:"time,omitempty"` // seconds
TotalTime uint `json:"total_time,omitempty"`
StartTime uint `json:"start_time,omitempty"`
EndTime uint `json:"end_time,omitempty"`
Mode string `json:"mode,omitempty"`
Actions []Action `json:"actions,omitempty"`
Waypoints []Waypoint `json:"waypoints,omitempty"`
Legs []Leg `json:"legs,omitempty"`
}
type Params struct {
Mode string `json:"mode,omitempty"`
Agents []Agent `json:"agents,omitempty"`
Jobs []Job `json:"jobs,omitempty"`
}
type Issues struct {
Shipments []uint `json:"unassigned_shipments,omitempty"`
Agents []uint `json:"unassigned_agents,omitempty"`
}
type Properties struct {
Mode string `json:"mode,omitempty"`
Params `json:"params,omitempty"`
Issues `json:"issues,omitempty"`
}
type Geometry struct {
Type string `json:"type"` // MultiLineString
Coordinates [][]LonLat
}
type Feature struct {
Geometry `json:"geometry"`
Type string `json:"type"` // Feature
Properties AgentPlan `json:"properties"`
}
// Plan is the route(s) output as planned by Geoapify based on the given input
type Plan struct {
Type string `json:"type"` // FeatureCollection
Features []Feature `json:"features,omitempty"`
Properties `json:"properties,omitempty"`
}
/* ************************ */
type BatchInput struct {
ID string `json:"id,omitempty"`
Body Request `json:"body,omitempty"`
Params Params `json:"params"`
}
// BatchRequest is the input for long-running / batch job request
//
// Max number of inputs / len(BatchInput) is 1000
type BatchRequest struct {
API string `json:"api"`
Inputs []BatchInput `json:"inputs"`
Params Params `json:"params,omitempty"`
}
type Result struct {
Params Params `json:"params,omitempty"`
Body Request `json:"body,omitemtpy"`
Plan `json:"result,omitempty"`
}
// BatchResponse is the output for long-running / batch job request
type BatchResponse struct {
ID string `json:"id"`
API string `json:"api"`
Params Params `json:"params,omitempty"`
Results []Result `json:"results,omitempty"`
}