@@ -9,409 +9,409 @@ |
||
9 | 9 | |
10 | 10 | class Route extends Common |
11 | 11 | { |
12 | - public $route_id; |
|
13 | - public $member_id; |
|
14 | - public $route_destination_id; |
|
15 | - public $optimization_problem_id; |
|
16 | - public $vehicle_alias; |
|
17 | - public $driver_alias; |
|
18 | - public $trip_distance; |
|
19 | - public $mpg; |
|
20 | - public $gas_price; |
|
21 | - public $route_duration_sec; |
|
22 | - public $destination_count; |
|
23 | - public $parameters; |
|
24 | - public $addresses = array(); |
|
25 | - public $links = array(); |
|
26 | - public $directions = array(); |
|
27 | - public $path = array(); |
|
28 | - public $tracking_history = array(); |
|
29 | - public $recipient_email; |
|
30 | - public $httpheaders; |
|
31 | - public $is_unrouted; |
|
32 | - public $time; |
|
12 | + public $route_id; |
|
13 | + public $member_id; |
|
14 | + public $route_destination_id; |
|
15 | + public $optimization_problem_id; |
|
16 | + public $vehicle_alias; |
|
17 | + public $driver_alias; |
|
18 | + public $trip_distance; |
|
19 | + public $mpg; |
|
20 | + public $gas_price; |
|
21 | + public $route_duration_sec; |
|
22 | + public $destination_count; |
|
23 | + public $parameters; |
|
24 | + public $addresses = array(); |
|
25 | + public $links = array(); |
|
26 | + public $directions = array(); |
|
27 | + public $path = array(); |
|
28 | + public $tracking_history = array(); |
|
29 | + public $recipient_email; |
|
30 | + public $httpheaders; |
|
31 | + public $is_unrouted; |
|
32 | + public $time; |
|
33 | 33 | |
34 | - public $dev_lat; |
|
35 | - public $dev_lng; |
|
34 | + public $dev_lat; |
|
35 | + public $dev_lng; |
|
36 | 36 | |
37 | - public $user_route_rating; |
|
38 | - public $member_email; |
|
39 | - public $member_first_name; |
|
40 | - public $member_last_name; |
|
41 | - public $channel_name; |
|
42 | - public $route_cost; |
|
43 | - public $route_revenue; |
|
44 | - public $net_revenue_per_distance_unit; |
|
45 | - public $created_timestamp; |
|
46 | - public $planned_total_route_duration; |
|
47 | - public $actual_travel_distance; |
|
48 | - public $actual_travel_time; |
|
49 | - public $actual_footsteps; |
|
50 | - public $working_time; |
|
51 | - public $driving_time; |
|
52 | - public $idling_time; |
|
53 | - public $paying_miles; |
|
54 | - public $geofence_polygon_type; |
|
55 | - public $geofence_polygon_size; |
|
56 | - public $notes; |
|
57 | - public $member_config_storage; |
|
37 | + public $user_route_rating; |
|
38 | + public $member_email; |
|
39 | + public $member_first_name; |
|
40 | + public $member_last_name; |
|
41 | + public $channel_name; |
|
42 | + public $route_cost; |
|
43 | + public $route_revenue; |
|
44 | + public $net_revenue_per_distance_unit; |
|
45 | + public $created_timestamp; |
|
46 | + public $planned_total_route_duration; |
|
47 | + public $actual_travel_distance; |
|
48 | + public $actual_travel_time; |
|
49 | + public $actual_footsteps; |
|
50 | + public $working_time; |
|
51 | + public $driving_time; |
|
52 | + public $idling_time; |
|
53 | + public $paying_miles; |
|
54 | + public $geofence_polygon_type; |
|
55 | + public $geofence_polygon_size; |
|
56 | + public $notes; |
|
57 | + public $member_config_storage; |
|
58 | 58 | |
59 | - public static function fromArray(array $params) |
|
60 | - { |
|
61 | - $route = new Route(); |
|
62 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
63 | - $route->member_id = Common::getValue($params, 'member_id'); |
|
64 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
65 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
66 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
67 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
68 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
69 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
70 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
71 | - $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
72 | - $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
59 | + public static function fromArray(array $params) |
|
60 | + { |
|
61 | + $route = new Route(); |
|
62 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
63 | + $route->member_id = Common::getValue($params, 'member_id'); |
|
64 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
65 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
66 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
67 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
68 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
69 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
70 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
71 | + $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
72 | + $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
73 | 73 | |
74 | - // Make RouteParameters |
|
75 | - if (isset($params['parameters'])) { |
|
76 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
77 | - } |
|
74 | + // Make RouteParameters |
|
75 | + if (isset($params['parameters'])) { |
|
76 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
77 | + } |
|
78 | 78 | |
79 | - if (isset($params['addresses'])) { |
|
80 | - $addresses = array(); |
|
81 | - foreach ($params['addresses'] as $address) { |
|
82 | - $addresses[] = Address::fromArray($address); |
|
83 | - } |
|
79 | + if (isset($params['addresses'])) { |
|
80 | + $addresses = array(); |
|
81 | + foreach ($params['addresses'] as $address) { |
|
82 | + $addresses[] = Address::fromArray($address); |
|
83 | + } |
|
84 | 84 | |
85 | - $route->addresses = $addresses; |
|
86 | - } |
|
85 | + $route->addresses = $addresses; |
|
86 | + } |
|
87 | 87 | |
88 | - $route->links = Common::getValue($params, 'links', array()); |
|
89 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
90 | - $route->path = Common::getValue($params, 'path', array()); |
|
91 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
88 | + $route->links = Common::getValue($params, 'links', array()); |
|
89 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
90 | + $route->path = Common::getValue($params, 'path', array()); |
|
91 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
92 | 92 | |
93 | - return $route; |
|
94 | - } |
|
93 | + return $route; |
|
94 | + } |
|
95 | 95 | |
96 | - public static function getRoutes($params = null) |
|
97 | - { |
|
98 | - $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
96 | + public static function getRoutes($params = null) |
|
97 | + { |
|
98 | + $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
99 | 99 | |
100 | - $result = Route4Me::makeRequst(array( |
|
101 | - 'url' => Endpoint::ROUTE_V4, |
|
102 | - 'method' => 'GET', |
|
103 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
104 | - )); |
|
100 | + $result = Route4Me::makeRequst(array( |
|
101 | + 'url' => Endpoint::ROUTE_V4, |
|
102 | + 'method' => 'GET', |
|
103 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
104 | + )); |
|
105 | 105 | |
106 | - if (isset($params['route_id'])) { |
|
107 | - return Route::fromArray($result); die(""); |
|
108 | - } else { |
|
109 | - $routes = array(); |
|
110 | - foreach ($result as $route) { |
|
111 | - $routes[] = Route::fromArray($route); |
|
112 | - } |
|
113 | - return $routes; |
|
114 | - } |
|
115 | - } |
|
106 | + if (isset($params['route_id'])) { |
|
107 | + return Route::fromArray($result); die(""); |
|
108 | + } else { |
|
109 | + $routes = array(); |
|
110 | + foreach ($result as $route) { |
|
111 | + $routes[] = Route::fromArray($route); |
|
112 | + } |
|
113 | + return $routes; |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - public function getRoutePoints($params) |
|
118 | - { |
|
119 | - $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
117 | + public function getRoutePoints($params) |
|
118 | + { |
|
119 | + $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
120 | 120 | |
121 | - $result = Route4Me::makeRequst(array( |
|
122 | - 'url' => Endpoint::ROUTE_V4, |
|
123 | - 'method' => 'GET', |
|
124 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
125 | - )); |
|
121 | + $result = Route4Me::makeRequst(array( |
|
122 | + 'url' => Endpoint::ROUTE_V4, |
|
123 | + 'method' => 'GET', |
|
124 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
125 | + )); |
|
126 | 126 | |
127 | - return $result; |
|
128 | - } |
|
127 | + return $result; |
|
128 | + } |
|
129 | 129 | |
130 | - public function duplicateRoute($route_id) |
|
131 | - { |
|
132 | - $result = Route4Me::makeRequst(array( |
|
133 | - 'url' => Endpoint::ROUTE_DUPLICATE, |
|
134 | - 'method' => 'GET', |
|
135 | - 'query' => array( |
|
136 | - 'route_id' => $route_id, |
|
137 | - 'to' => 'none', |
|
138 | - ) |
|
139 | - )); |
|
130 | + public function duplicateRoute($route_id) |
|
131 | + { |
|
132 | + $result = Route4Me::makeRequst(array( |
|
133 | + 'url' => Endpoint::ROUTE_DUPLICATE, |
|
134 | + 'method' => 'GET', |
|
135 | + 'query' => array( |
|
136 | + 'route_id' => $route_id, |
|
137 | + 'to' => 'none', |
|
138 | + ) |
|
139 | + )); |
|
140 | 140 | |
141 | - return $result; |
|
142 | - } |
|
141 | + return $result; |
|
142 | + } |
|
143 | 143 | |
144 | - public function resequenceRoute($params) |
|
145 | - { |
|
146 | - $allQueryFields = array('route_id', 'route_destination_id'); |
|
147 | - $allBodyFields = array('addresses'); |
|
144 | + public function resequenceRoute($params) |
|
145 | + { |
|
146 | + $allQueryFields = array('route_id', 'route_destination_id'); |
|
147 | + $allBodyFields = array('addresses'); |
|
148 | 148 | |
149 | - $result = Route4Me::makeRequst(array( |
|
150 | - 'url' => Endpoint::ROUTE_V4, |
|
151 | - 'method' => 'PUT', |
|
152 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
153 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
154 | - )); |
|
149 | + $result = Route4Me::makeRequst(array( |
|
150 | + 'url' => Endpoint::ROUTE_V4, |
|
151 | + 'method' => 'PUT', |
|
152 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
153 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
154 | + )); |
|
155 | 155 | |
156 | - return $result; |
|
157 | - } |
|
156 | + return $result; |
|
157 | + } |
|
158 | 158 | |
159 | - public function resequenceAllAddresses($params) |
|
160 | - { |
|
161 | - $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
159 | + public function resequenceAllAddresses($params) |
|
160 | + { |
|
161 | + $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
162 | 162 | |
163 | - $result = Route4Me::makeRequst(array( |
|
164 | - 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
165 | - 'method' => 'GET', |
|
166 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
167 | - )); |
|
163 | + $result = Route4Me::makeRequst(array( |
|
164 | + 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
165 | + 'method' => 'GET', |
|
166 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
167 | + )); |
|
168 | 168 | |
169 | - return $result; |
|
170 | - } |
|
169 | + return $result; |
|
170 | + } |
|
171 | 171 | |
172 | - public function mergeRoutes($params) |
|
173 | - { |
|
174 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
172 | + public function mergeRoutes($params) |
|
173 | + { |
|
174 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
175 | 175 | |
176 | - $result = Route4Me::makeRequst(array( |
|
177 | - 'url' => Endpoint::ROUTES_MERGE, |
|
178 | - 'method' => 'POST', |
|
179 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
180 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
181 | - )); |
|
176 | + $result = Route4Me::makeRequst(array( |
|
177 | + 'url' => Endpoint::ROUTES_MERGE, |
|
178 | + 'method' => 'POST', |
|
179 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
180 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
181 | + )); |
|
182 | 182 | |
183 | - return $result; |
|
184 | - } |
|
183 | + return $result; |
|
184 | + } |
|
185 | 185 | |
186 | - public function shareRoute($params) |
|
187 | - { |
|
188 | - $allQueryFields = array('route_id', 'response_format'); |
|
189 | - $allBodyFields = array('recipient_email'); |
|
186 | + public function shareRoute($params) |
|
187 | + { |
|
188 | + $allQueryFields = array('route_id', 'response_format'); |
|
189 | + $allBodyFields = array('recipient_email'); |
|
190 | 190 | |
191 | - $result = Route4Me::makeRequst(array( |
|
192 | - 'url' => Endpoint::ROUTE_SHARE, |
|
193 | - 'method' => 'POST', |
|
194 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
195 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
196 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
197 | - )); |
|
191 | + $result = Route4Me::makeRequst(array( |
|
192 | + 'url' => Endpoint::ROUTE_SHARE, |
|
193 | + 'method' => 'POST', |
|
194 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
195 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
196 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
197 | + )); |
|
198 | 198 | |
199 | - return $result; |
|
200 | - } |
|
199 | + return $result; |
|
200 | + } |
|
201 | 201 | |
202 | - // Returns random route_id from existing routes between $offset and $offset+$limit |
|
203 | - public function getRandomRouteId($offset, $limit) |
|
204 | - { |
|
205 | - $params = array( |
|
206 | - 'offset' => !is_null($offset) ? $offset : 0, |
|
207 | - 'limit' => !is_null($limit) ? $limit : 30 |
|
208 | - ); |
|
202 | + // Returns random route_id from existing routes between $offset and $offset+$limit |
|
203 | + public function getRandomRouteId($offset, $limit) |
|
204 | + { |
|
205 | + $params = array( |
|
206 | + 'offset' => !is_null($offset) ? $offset : 0, |
|
207 | + 'limit' => !is_null($limit) ? $limit : 30 |
|
208 | + ); |
|
209 | 209 | |
210 | - $routes = $this->getRoutes($params); |
|
210 | + $routes = $this->getRoutes($params); |
|
211 | 211 | |
212 | - if (is_null($routes) || sizeof($routes)<1) { |
|
213 | - echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
214 | - return null; |
|
215 | - } |
|
212 | + if (is_null($routes) || sizeof($routes)<1) { |
|
213 | + echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
214 | + return null; |
|
215 | + } |
|
216 | 216 | |
217 | - $randomIndex = rand(0, sizeof($routes) - 1); |
|
217 | + $randomIndex = rand(0, sizeof($routes) - 1); |
|
218 | 218 | |
219 | - return $routes[$randomIndex]->route_id; |
|
220 | - } |
|
219 | + return $routes[$randomIndex]->route_id; |
|
220 | + } |
|
221 | 221 | |
222 | - public function update() |
|
223 | - { |
|
224 | - $route = Route4Me::makeRequst(array( |
|
225 | - 'url' => Endpoint::ROUTE_V4, |
|
226 | - 'method' => 'PUT', |
|
227 | - 'query' => array( |
|
228 | - 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
229 | - ), |
|
230 | - 'body' => array( |
|
231 | - 'parameters' => $this->parameters, |
|
232 | - ), |
|
233 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
234 | - )); |
|
222 | + public function update() |
|
223 | + { |
|
224 | + $route = Route4Me::makeRequst(array( |
|
225 | + 'url' => Endpoint::ROUTE_V4, |
|
226 | + 'method' => 'PUT', |
|
227 | + 'query' => array( |
|
228 | + 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
229 | + ), |
|
230 | + 'body' => array( |
|
231 | + 'parameters' => $this->parameters, |
|
232 | + ), |
|
233 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
234 | + )); |
|
235 | 235 | |
236 | - return Route::fromArray($route); |
|
237 | - } |
|
236 | + return Route::fromArray($route); |
|
237 | + } |
|
238 | 238 | |
239 | - public function updateAddress($address = null) |
|
240 | - { |
|
241 | - $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
242 | - : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
239 | + public function updateAddress($address = null) |
|
240 | + { |
|
241 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
242 | + : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
243 | 243 | |
244 | - $result = Route4Me::makeRequst(array( |
|
245 | - 'url' => Endpoint::ADDRESS_V4, |
|
246 | - 'method' => 'PUT', |
|
247 | - 'query' => array( |
|
248 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
249 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
250 | - ), |
|
251 | - 'body' => $body, |
|
252 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
253 | - )); |
|
244 | + $result = Route4Me::makeRequst(array( |
|
245 | + 'url' => Endpoint::ADDRESS_V4, |
|
246 | + 'method' => 'PUT', |
|
247 | + 'query' => array( |
|
248 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
249 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
250 | + ), |
|
251 | + 'body' => $body, |
|
252 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
253 | + )); |
|
254 | 254 | |
255 | - return $result; |
|
256 | - } |
|
255 | + return $result; |
|
256 | + } |
|
257 | 257 | |
258 | - public function updateRouteAddress() |
|
259 | - { |
|
260 | - $result = Route4Me::makeRequst(array( |
|
261 | - 'url' => Endpoint::ADDRESS_V4, |
|
262 | - 'method' => 'PUT', |
|
263 | - 'query' => array( |
|
264 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
265 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
266 | - ), |
|
267 | - 'body' => array( |
|
268 | - "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
269 | - "addresses" => isset($this->addresses) ? $this->addresses : null |
|
270 | - ), |
|
271 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
272 | - )); |
|
258 | + public function updateRouteAddress() |
|
259 | + { |
|
260 | + $result = Route4Me::makeRequst(array( |
|
261 | + 'url' => Endpoint::ADDRESS_V4, |
|
262 | + 'method' => 'PUT', |
|
263 | + 'query' => array( |
|
264 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
265 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
266 | + ), |
|
267 | + 'body' => array( |
|
268 | + "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
269 | + "addresses" => isset($this->addresses) ? $this->addresses : null |
|
270 | + ), |
|
271 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
272 | + )); |
|
273 | 273 | |
274 | - return $result; |
|
275 | - } |
|
274 | + return $result; |
|
275 | + } |
|
276 | 276 | |
277 | - public function addAddresses($params) |
|
278 | - { |
|
279 | - $allQueryFields = array('route_id'); |
|
280 | - $allBodyFields = array('addresses'); |
|
277 | + public function addAddresses($params) |
|
278 | + { |
|
279 | + $allQueryFields = array('route_id'); |
|
280 | + $allBodyFields = array('addresses'); |
|
281 | 281 | |
282 | - $route = Route4Me::makeRequst(array( |
|
283 | - 'url' => Endpoint::ROUTE_V4, |
|
284 | - 'method' => 'PUT', |
|
285 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
286 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
287 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
288 | - )); |
|
282 | + $route = Route4Me::makeRequst(array( |
|
283 | + 'url' => Endpoint::ROUTE_V4, |
|
284 | + 'method' => 'PUT', |
|
285 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
286 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
287 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
288 | + )); |
|
289 | 289 | |
290 | - return Route::fromArray($route); |
|
291 | - } |
|
290 | + return Route::fromArray($route); |
|
291 | + } |
|
292 | 292 | |
293 | - public function insertAddressOptimalPosition(array $params) |
|
294 | - { |
|
295 | - $allQueryFields = array('route_id'); |
|
296 | - $allBodyFields = array('addresses', 'optimal_position'); |
|
293 | + public function insertAddressOptimalPosition(array $params) |
|
294 | + { |
|
295 | + $allQueryFields = array('route_id'); |
|
296 | + $allBodyFields = array('addresses', 'optimal_position'); |
|
297 | 297 | |
298 | - $route = Route4Me::makeRequst(array( |
|
299 | - 'url' => Endpoint::ROUTE_V4, |
|
300 | - 'method' => 'PUT', |
|
301 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
303 | - )); |
|
298 | + $route = Route4Me::makeRequst(array( |
|
299 | + 'url' => Endpoint::ROUTE_V4, |
|
300 | + 'method' => 'PUT', |
|
301 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
303 | + )); |
|
304 | 304 | |
305 | - return Route::fromArray($route); |
|
306 | - } |
|
305 | + return Route::fromArray($route); |
|
306 | + } |
|
307 | 307 | |
308 | - public function addNoteFile($params) |
|
309 | - { |
|
310 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
311 | - $rpath = realpath($fname); |
|
308 | + public function addNoteFile($params) |
|
309 | + { |
|
310 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
311 | + $rpath = realpath($fname); |
|
312 | 312 | |
313 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
314 | - $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
313 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
314 | + $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
315 | 315 | |
316 | - $result = Route4Me::makeRequst(array( |
|
317 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
318 | - 'method' => 'POST', |
|
319 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
320 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
321 | - 'FILE' => $rpath, |
|
322 | - 'HTTPHEADER' => array( |
|
323 | - 'Content-Type: application/x-www-form-urlencoded' |
|
324 | - ) |
|
325 | - )); |
|
316 | + $result = Route4Me::makeRequst(array( |
|
317 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
318 | + 'method' => 'POST', |
|
319 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
320 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
321 | + 'FILE' => $rpath, |
|
322 | + 'HTTPHEADER' => array( |
|
323 | + 'Content-Type: application/x-www-form-urlencoded' |
|
324 | + ) |
|
325 | + )); |
|
326 | 326 | |
327 | - return $result; |
|
328 | - } |
|
327 | + return $result; |
|
328 | + } |
|
329 | 329 | |
330 | - public function deleteRoutes($route_id) |
|
331 | - { |
|
332 | - $result = Route4Me::makeRequst(array( |
|
333 | - 'url' => Endpoint::ROUTES_DELETE, |
|
334 | - 'method' => 'DELETE', |
|
335 | - 'query' => array( |
|
336 | - 'route_id' => $route_id, |
|
337 | - ) |
|
338 | - )); |
|
330 | + public function deleteRoutes($route_id) |
|
331 | + { |
|
332 | + $result = Route4Me::makeRequst(array( |
|
333 | + 'url' => Endpoint::ROUTES_DELETE, |
|
334 | + 'method' => 'DELETE', |
|
335 | + 'query' => array( |
|
336 | + 'route_id' => $route_id, |
|
337 | + ) |
|
338 | + )); |
|
339 | 339 | |
340 | - return $result; |
|
341 | - } |
|
340 | + return $result; |
|
341 | + } |
|
342 | 342 | |
343 | - public function GetAddressesFromRoute($route_id) |
|
344 | - { |
|
345 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
343 | + public function GetAddressesFromRoute($route_id) |
|
344 | + { |
|
345 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
346 | 346 | |
347 | - if (isset($route1)) { |
|
348 | - return $route1->addresses; |
|
349 | - } else { |
|
350 | - return null; |
|
351 | - } |
|
352 | - } |
|
347 | + if (isset($route1)) { |
|
348 | + return $route1->addresses; |
|
349 | + } else { |
|
350 | + return null; |
|
351 | + } |
|
352 | + } |
|
353 | 353 | |
354 | - public function GetRandomAddressFromRoute($route_id) |
|
355 | - { |
|
356 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
354 | + public function GetRandomAddressFromRoute($route_id) |
|
355 | + { |
|
356 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
357 | 357 | |
358 | - if (isset($route1)) { |
|
359 | - $addresses = $route1->addresses; |
|
358 | + if (isset($route1)) { |
|
359 | + $addresses = $route1->addresses; |
|
360 | 360 | |
361 | - $rnd = rand(0, sizeof($addresses) - 1); |
|
361 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
362 | 362 | |
363 | - return $addresses[$rnd]; |
|
364 | - } else { |
|
365 | - return null; |
|
366 | - } |
|
367 | - } |
|
363 | + return $addresses[$rnd]; |
|
364 | + } else { |
|
365 | + return null; |
|
366 | + } |
|
367 | + } |
|
368 | 368 | |
369 | - public function getRouteId() |
|
370 | - { |
|
371 | - return $this->route_id; |
|
372 | - } |
|
369 | + public function getRouteId() |
|
370 | + { |
|
371 | + return $this->route_id; |
|
372 | + } |
|
373 | 373 | |
374 | - public function getOptimizationId() |
|
375 | - { |
|
376 | - return $this->optimization_problem_id; |
|
377 | - } |
|
374 | + public function getOptimizationId() |
|
375 | + { |
|
376 | + return $this->optimization_problem_id; |
|
377 | + } |
|
378 | 378 | |
379 | - public function GetLastLocation(array $params) |
|
380 | - { |
|
381 | - $allQueryFields = array('route_id', 'device_tracking_history'); |
|
379 | + public function GetLastLocation(array $params) |
|
380 | + { |
|
381 | + $allQueryFields = array('route_id', 'device_tracking_history'); |
|
382 | 382 | |
383 | - $route = Route4Me::makeRequst(array( |
|
384 | - 'url' => Endpoint::ROUTE_V4, |
|
385 | - 'method' => 'GET', |
|
386 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
387 | - )); |
|
383 | + $route = Route4Me::makeRequst(array( |
|
384 | + 'url' => Endpoint::ROUTE_V4, |
|
385 | + 'method' => 'GET', |
|
386 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
387 | + )); |
|
388 | 388 | |
389 | - return Route::fromArray($route); |
|
390 | - } |
|
389 | + return Route::fromArray($route); |
|
390 | + } |
|
391 | 391 | |
392 | - public function GetTrackingHistoryFromTimeRange(array $params) |
|
393 | - { |
|
394 | - $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
392 | + public function GetTrackingHistoryFromTimeRange(array $params) |
|
393 | + { |
|
394 | + $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
395 | 395 | |
396 | - $route = Route4Me::makeRequst(array( |
|
397 | - 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
398 | - 'method' => 'GET', |
|
399 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
400 | - )); |
|
396 | + $route = Route4Me::makeRequst(array( |
|
397 | + 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
398 | + 'method' => 'GET', |
|
399 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
400 | + )); |
|
401 | 401 | |
402 | - return $route; |
|
403 | - } |
|
402 | + return $route; |
|
403 | + } |
|
404 | 404 | |
405 | - public function GetAssetTracking(array $params) |
|
406 | - { |
|
407 | - $allQueryFields = array('tracking'); |
|
405 | + public function GetAssetTracking(array $params) |
|
406 | + { |
|
407 | + $allQueryFields = array('tracking'); |
|
408 | 408 | |
409 | - $route = Route4Me::makeRequst(array( |
|
410 | - 'url' => Endpoint::STATUS_V4, |
|
411 | - 'method' => 'GET', |
|
412 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
413 | - )); |
|
409 | + $route = Route4Me::makeRequst(array( |
|
410 | + 'url' => Endpoint::STATUS_V4, |
|
411 | + 'method' => 'GET', |
|
412 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
413 | + )); |
|
414 | 414 | |
415 | - return $route; |
|
416 | - } |
|
415 | + return $route; |
|
416 | + } |
|
417 | 417 | } |
@@ -171,7 +171,7 @@ |
||
171 | 171 | |
172 | 172 | public function mergeRoutes($params) |
173 | 173 | { |
174 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
174 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
175 | 175 | |
176 | 176 | $result = Route4Me::makeRequst(array( |
177 | 177 | 'url' => Endpoint::ROUTES_MERGE, |
@@ -11,236 +11,236 @@ |
||
11 | 11 | |
12 | 12 | class OptimizationProblem extends Common |
13 | 13 | { |
14 | - public $optimization_problem_id; |
|
15 | - public $user_errors = array(); |
|
16 | - public $state; |
|
17 | - public $optimization_errors = array(); |
|
18 | - public $parameters; |
|
19 | - public $sent_to_background; |
|
20 | - public $created_timestamp; |
|
21 | - public $scheduled_for; |
|
22 | - public $optimization_completed_timestamp; |
|
23 | - public $addresses = array(); |
|
24 | - public $routes = array(); |
|
25 | - public $links = array(); |
|
26 | - |
|
27 | - function __construct() |
|
28 | - { |
|
29 | - $this->parameters = new RouteParameters; |
|
30 | - } |
|
31 | - |
|
32 | - public static function fromArray(array $params) |
|
33 | - { |
|
34 | - $problem = new OptimizationProblem; |
|
35 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
36 | - $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
37 | - $problem->state = Common::getValue($params, 'state', array()); |
|
38 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
39 | - $problem->links = Common::getValue($params, 'links', array()); |
|
40 | - |
|
41 | - if (isset($params['parameters'])) { |
|
42 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
43 | - } |
|
44 | - |
|
45 | - if (isset($params['addresses'])) { |
|
46 | - $addresses = array(); |
|
14 | + public $optimization_problem_id; |
|
15 | + public $user_errors = array(); |
|
16 | + public $state; |
|
17 | + public $optimization_errors = array(); |
|
18 | + public $parameters; |
|
19 | + public $sent_to_background; |
|
20 | + public $created_timestamp; |
|
21 | + public $scheduled_for; |
|
22 | + public $optimization_completed_timestamp; |
|
23 | + public $addresses = array(); |
|
24 | + public $routes = array(); |
|
25 | + public $links = array(); |
|
26 | + |
|
27 | + function __construct() |
|
28 | + { |
|
29 | + $this->parameters = new RouteParameters; |
|
30 | + } |
|
31 | + |
|
32 | + public static function fromArray(array $params) |
|
33 | + { |
|
34 | + $problem = new OptimizationProblem; |
|
35 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
36 | + $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
37 | + $problem->state = Common::getValue($params, 'state', array()); |
|
38 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
39 | + $problem->links = Common::getValue($params, 'links', array()); |
|
40 | + |
|
41 | + if (isset($params['parameters'])) { |
|
42 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
43 | + } |
|
44 | + |
|
45 | + if (isset($params['addresses'])) { |
|
46 | + $addresses = array(); |
|
47 | 47 | |
48 | - foreach ($params['addresses'] as $address) { |
|
49 | - $addresses[] = Address::fromArray($address); |
|
50 | - } |
|
48 | + foreach ($params['addresses'] as $address) { |
|
49 | + $addresses[] = Address::fromArray($address); |
|
50 | + } |
|
51 | 51 | |
52 | - $problem->addresses = $addresses; |
|
53 | - } |
|
52 | + $problem->addresses = $addresses; |
|
53 | + } |
|
54 | 54 | |
55 | - if (isset($params['routes'])) { |
|
56 | - $routes = array(); |
|
55 | + if (isset($params['routes'])) { |
|
56 | + $routes = array(); |
|
57 | 57 | |
58 | - foreach ($params['routes'] as $route) { |
|
59 | - $routes[] = Route::fromArray($route); |
|
60 | - } |
|
58 | + foreach ($params['routes'] as $route) { |
|
59 | + $routes[] = Route::fromArray($route); |
|
60 | + } |
|
61 | 61 | |
62 | - $problem->routes = $routes; |
|
63 | - } |
|
64 | - |
|
65 | - return $problem; |
|
66 | - } |
|
67 | - |
|
68 | - public static function optimize(OptimizationProblemParams $params) |
|
69 | - { |
|
70 | - $allQueryFields = array('redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'); |
|
71 | - |
|
72 | - $optimize = Route4Me::makeRequst(array( |
|
73 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
74 | - 'method' => 'POST', |
|
75 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
76 | - 'body' => array( |
|
77 | - 'addresses' => $params->getAddressesArray(), |
|
78 | - 'parameters' => $params->getParametersArray() |
|
79 | - ) |
|
80 | - )); |
|
81 | - |
|
82 | - return OptimizationProblem::fromArray($optimize); |
|
83 | - } |
|
84 | - |
|
85 | - public static function get($params) |
|
86 | - { |
|
87 | - $allQueryFields = array('state', 'limit', 'format', 'offset', |
|
88 | - 'optimization_problem_id', 'wait_for_final_state'); |
|
89 | - |
|
90 | - $optimize = Route4Me::makeRequst(array( |
|
91 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
92 | - 'method' => 'GET', |
|
93 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
94 | - )); |
|
95 | - |
|
96 | - if (isset($optimize['optimizations'])) { |
|
97 | - $problems = array(); |
|
62 | + $problem->routes = $routes; |
|
63 | + } |
|
64 | + |
|
65 | + return $problem; |
|
66 | + } |
|
67 | + |
|
68 | + public static function optimize(OptimizationProblemParams $params) |
|
69 | + { |
|
70 | + $allQueryFields = array('redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'); |
|
71 | + |
|
72 | + $optimize = Route4Me::makeRequst(array( |
|
73 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
74 | + 'method' => 'POST', |
|
75 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
76 | + 'body' => array( |
|
77 | + 'addresses' => $params->getAddressesArray(), |
|
78 | + 'parameters' => $params->getParametersArray() |
|
79 | + ) |
|
80 | + )); |
|
81 | + |
|
82 | + return OptimizationProblem::fromArray($optimize); |
|
83 | + } |
|
84 | + |
|
85 | + public static function get($params) |
|
86 | + { |
|
87 | + $allQueryFields = array('state', 'limit', 'format', 'offset', |
|
88 | + 'optimization_problem_id', 'wait_for_final_state'); |
|
89 | + |
|
90 | + $optimize = Route4Me::makeRequst(array( |
|
91 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
92 | + 'method' => 'GET', |
|
93 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
94 | + )); |
|
95 | + |
|
96 | + if (isset($optimize['optimizations'])) { |
|
97 | + $problems = array(); |
|
98 | 98 | |
99 | - foreach ($optimize['optimizations'] as $problem) { |
|
100 | - $problems[] = OptimizationProblem::fromArray($problem); |
|
101 | - } |
|
99 | + foreach ($optimize['optimizations'] as $problem) { |
|
100 | + $problems[] = OptimizationProblem::fromArray($problem); |
|
101 | + } |
|
102 | 102 | |
103 | - return $problems; |
|
104 | - } else { |
|
105 | - return OptimizationProblem::fromArray($optimize); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public static function reoptimize($params) |
|
110 | - { |
|
111 | - $param = new OptimizationProblemParams; |
|
112 | - $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
113 | - $param->reoptimize = 1; |
|
114 | - |
|
115 | - return self::update((array)$param); |
|
116 | - } |
|
117 | - |
|
118 | - public static function update($params) |
|
119 | - { |
|
120 | - $allQueryFields = array('optimization_problem_id', 'reoptimize'); |
|
121 | - $allBodyFields = array('addresses'); |
|
122 | - |
|
123 | - $optimize = Route4Me::makeRequst(array( |
|
124 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
125 | - 'method' => 'PUT', |
|
126 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
127 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
128 | - )); |
|
129 | - |
|
130 | - return $optimize; |
|
131 | - } |
|
132 | - |
|
133 | - public function getOptimizationId() |
|
134 | - { |
|
135 | - return $this->optimization_problem_id; |
|
136 | - } |
|
137 | - |
|
138 | - public function getRoutes() |
|
139 | - { |
|
140 | - return $this->routes; |
|
141 | - } |
|
103 | + return $problems; |
|
104 | + } else { |
|
105 | + return OptimizationProblem::fromArray($optimize); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public static function reoptimize($params) |
|
110 | + { |
|
111 | + $param = new OptimizationProblemParams; |
|
112 | + $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
113 | + $param->reoptimize = 1; |
|
114 | + |
|
115 | + return self::update((array)$param); |
|
116 | + } |
|
117 | + |
|
118 | + public static function update($params) |
|
119 | + { |
|
120 | + $allQueryFields = array('optimization_problem_id', 'reoptimize'); |
|
121 | + $allBodyFields = array('addresses'); |
|
122 | + |
|
123 | + $optimize = Route4Me::makeRequst(array( |
|
124 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
125 | + 'method' => 'PUT', |
|
126 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
127 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
128 | + )); |
|
129 | + |
|
130 | + return $optimize; |
|
131 | + } |
|
132 | + |
|
133 | + public function getOptimizationId() |
|
134 | + { |
|
135 | + return $this->optimization_problem_id; |
|
136 | + } |
|
137 | + |
|
138 | + public function getRoutes() |
|
139 | + { |
|
140 | + return $this->routes; |
|
141 | + } |
|
142 | 142 | |
143 | - public function getRandomOptimizationId($offset, $limit) |
|
144 | - { |
|
145 | - $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
|
143 | + public function getRandomOptimizationId($offset, $limit) |
|
144 | + { |
|
145 | + $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
|
146 | 146 | |
147 | - $rOptimization = $optimizations[rand(0,sizeof($optimizations)-1)]; |
|
148 | - |
|
149 | - if(!isset($rOptimization->optimization_problem_id)) { |
|
150 | - if (sizeof($optimizations)>9) { |
|
151 | - $this->getRandomOptimizationId($offset, $limit); |
|
152 | - } else { |
|
153 | - return null; |
|
154 | - } |
|
155 | - } |
|
147 | + $rOptimization = $optimizations[rand(0,sizeof($optimizations)-1)]; |
|
148 | + |
|
149 | + if(!isset($rOptimization->optimization_problem_id)) { |
|
150 | + if (sizeof($optimizations)>9) { |
|
151 | + $this->getRandomOptimizationId($offset, $limit); |
|
152 | + } else { |
|
153 | + return null; |
|
154 | + } |
|
155 | + } |
|
156 | 156 | |
157 | - return $rOptimization->optimization_problem_id; |
|
158 | - } |
|
157 | + return $rOptimization->optimization_problem_id; |
|
158 | + } |
|
159 | 159 | |
160 | - public function getAddresses($opt_id) |
|
161 | - { |
|
162 | - if ($opt_id==null) { |
|
163 | - return null; |
|
164 | - } |
|
160 | + public function getAddresses($opt_id) |
|
161 | + { |
|
162 | + if ($opt_id==null) { |
|
163 | + return null; |
|
164 | + } |
|
165 | 165 | |
166 | - $params = array("optimization_problem_id" => $opt_id ); |
|
166 | + $params = array("optimization_problem_id" => $opt_id ); |
|
167 | 167 | |
168 | - $optimization = (array)$this->get($params); |
|
168 | + $optimization = (array)$this->get($params); |
|
169 | 169 | |
170 | - $addresses = $optimization["addresses"]; |
|
170 | + $addresses = $optimization["addresses"]; |
|
171 | 171 | |
172 | - return $addresses; |
|
173 | - } |
|
172 | + return $addresses; |
|
173 | + } |
|
174 | 174 | |
175 | - public function getRandomAddressFromOptimization($opt_id) |
|
176 | - { |
|
177 | - $addresses = (array)$this->getAddresses($opt_id); |
|
175 | + public function getRandomAddressFromOptimization($opt_id) |
|
176 | + { |
|
177 | + $addresses = (array)$this->getAddresses($opt_id); |
|
178 | 178 | |
179 | - if ($addresses==null) { |
|
180 | - echo "There are no addresses in this optimization!.. Try again."; |
|
181 | - return null; |
|
182 | - } |
|
179 | + if ($addresses==null) { |
|
180 | + echo "There are no addresses in this optimization!.. Try again."; |
|
181 | + return null; |
|
182 | + } |
|
183 | 183 | |
184 | - $num = rand(0, sizeof($addresses)-1); |
|
184 | + $num = rand(0, sizeof($addresses)-1); |
|
185 | 185 | |
186 | - $rAddress = $addresses[$num]; |
|
186 | + $rAddress = $addresses[$num]; |
|
187 | 187 | |
188 | - return $rAddress; |
|
189 | - } |
|
188 | + return $rAddress; |
|
189 | + } |
|
190 | 190 | |
191 | - public function removeAddress($params) |
|
192 | - { |
|
193 | - $allQueryFields = array('optimization_problem_id', 'route_destination_id'); |
|
194 | - |
|
195 | - $response = Route4Me::makeRequst(array( |
|
196 | - 'url' => Endpoint::ADDRESS_V4, |
|
197 | - 'method' => 'DELETE', |
|
198 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
199 | - )); |
|
200 | - |
|
201 | - return $response; |
|
202 | - } |
|
191 | + public function removeAddress($params) |
|
192 | + { |
|
193 | + $allQueryFields = array('optimization_problem_id', 'route_destination_id'); |
|
194 | + |
|
195 | + $response = Route4Me::makeRequst(array( |
|
196 | + 'url' => Endpoint::ADDRESS_V4, |
|
197 | + 'method' => 'DELETE', |
|
198 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
199 | + )); |
|
200 | + |
|
201 | + return $response; |
|
202 | + } |
|
203 | 203 | |
204 | - public function removeOptimization($params) |
|
205 | - { |
|
206 | - $allQueryFields = array('redirect'); |
|
207 | - $allBodyFields = array('optimization_problem_ids'); |
|
208 | - |
|
209 | - $response = Route4Me::makeRequst(array( |
|
210 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
211 | - 'method' => 'DELETE', |
|
212 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
213 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
214 | - )); |
|
215 | - |
|
216 | - return $response; |
|
217 | - } |
|
204 | + public function removeOptimization($params) |
|
205 | + { |
|
206 | + $allQueryFields = array('redirect'); |
|
207 | + $allBodyFields = array('optimization_problem_ids'); |
|
208 | + |
|
209 | + $response = Route4Me::makeRequst(array( |
|
210 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
211 | + 'method' => 'DELETE', |
|
212 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
213 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
214 | + )); |
|
215 | + |
|
216 | + return $response; |
|
217 | + } |
|
218 | 218 | |
219 | - public function getHybridOptimization($params) |
|
220 | - { |
|
221 | - $allQueryFields = array('target_date_string', 'timezone_offset_minutes'); |
|
222 | - |
|
223 | - $optimize = Route4Me::makeRequst(array( |
|
224 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
225 | - 'method' => 'GET', |
|
226 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
227 | - )); |
|
228 | - |
|
229 | - return $optimize; |
|
230 | - } |
|
219 | + public function getHybridOptimization($params) |
|
220 | + { |
|
221 | + $allQueryFields = array('target_date_string', 'timezone_offset_minutes'); |
|
222 | + |
|
223 | + $optimize = Route4Me::makeRequst(array( |
|
224 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
225 | + 'method' => 'GET', |
|
226 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
227 | + )); |
|
228 | + |
|
229 | + return $optimize; |
|
230 | + } |
|
231 | 231 | |
232 | - Public function addDepotsToHybrid($params) |
|
233 | - { |
|
234 | - $allQueryFields = array('optimization_problem_id'); |
|
235 | - $allBodyFields = array('optimization_problem_id', 'delete_old_depots', 'new_depots'); |
|
236 | - |
|
237 | - $depots = Route4Me::makeRequst(array( |
|
238 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
239 | - 'method' => 'POST', |
|
240 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
241 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
242 | - )); |
|
243 | - |
|
244 | - return $depots; |
|
245 | - } |
|
232 | + Public function addDepotsToHybrid($params) |
|
233 | + { |
|
234 | + $allQueryFields = array('optimization_problem_id'); |
|
235 | + $allBodyFields = array('optimization_problem_id', 'delete_old_depots', 'new_depots'); |
|
236 | + |
|
237 | + $depots = Route4Me::makeRequst(array( |
|
238 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
239 | + 'method' => 'POST', |
|
240 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
241 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
242 | + )); |
|
243 | + |
|
244 | + return $depots; |
|
245 | + } |
|
246 | 246 | } |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | { |
145 | 145 | $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
146 | 146 | |
147 | - $rOptimization = $optimizations[rand(0,sizeof($optimizations)-1)]; |
|
147 | + $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
148 | 148 | |
149 | - if(!isset($rOptimization->optimization_problem_id)) { |
|
149 | + if (!isset($rOptimization->optimization_problem_id)) { |
|
150 | 150 | if (sizeof($optimizations)>9) { |
151 | 151 | $this->getRandomOptimizationId($offset, $limit); |
152 | 152 | } else { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return null; |
164 | 164 | } |
165 | 165 | |
166 | - $params = array("optimization_problem_id" => $opt_id ); |
|
166 | + $params = array("optimization_problem_id" => $opt_id); |
|
167 | 167 | |
168 | 168 | $optimization = (array)$this->get($params); |
169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | return null; |
182 | 182 | } |
183 | 183 | |
184 | - $num = rand(0, sizeof($addresses)-1); |
|
184 | + $num = rand(0, sizeof($addresses) - 1); |
|
185 | 185 | |
186 | 186 | $rAddress = $addresses[$num]; |
187 | 187 |