@@ -10,10 +10,8 @@ |
||
10 | 10 | use Route4Me\Enum\DistanceUnit; |
11 | 11 | use Route4Me\Enum\DeviceType; |
12 | 12 | use Route4Me\Enum\TravelMode; |
13 | -use Route4Me\Enum\Metric; |
|
14 | 13 | use Route4Me\RouteParameters; |
15 | 14 | use Route4Me\Address; |
16 | -use Route4Me\Route; |
|
17 | 15 | |
18 | 16 | Route4Me::setApiKey('11111111111111111111111111111111'); |
19 | 17 |
@@ -23,19 +23,19 @@ |
||
23 | 23 | |
24 | 24 | $addresses = array(); |
25 | 25 | foreach($json as $address) { |
26 | - $addresses[] = Address::fromArray($address); |
|
26 | + $addresses[] = Address::fromArray($address); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | $parameters = RouteParameters::fromArray(array( |
30 | - "algorithm_type" => AlgorithmType::TSP, |
|
31 | - "distance_unit" => DistanceUnit::MILES, |
|
32 | - "device_type" => DeviceType::WEB, |
|
33 | - "optimize" => OptimizationType::DISTANCE, |
|
34 | - "travel_mode" => TravelMode::DRIVING, |
|
35 | - "route_max_duration" => 86400, |
|
36 | - "vehicle_capacity" => 1, |
|
37 | - "vehicle_max_distance_mi" => 10000, |
|
38 | - "rt" => true |
|
30 | + "algorithm_type" => AlgorithmType::TSP, |
|
31 | + "distance_unit" => DistanceUnit::MILES, |
|
32 | + "device_type" => DeviceType::WEB, |
|
33 | + "optimize" => OptimizationType::DISTANCE, |
|
34 | + "travel_mode" => TravelMode::DRIVING, |
|
35 | + "route_max_duration" => 86400, |
|
36 | + "vehicle_capacity" => 1, |
|
37 | + "vehicle_max_distance_mi" => 10000, |
|
38 | + "rt" => true |
|
39 | 39 | )); |
40 | 40 | |
41 | 41 | $optimizationParams = new OptimizationProblemParams; |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $json = array_slice($json, 0, 10); |
23 | 23 | |
24 | 24 | $addresses = array(); |
25 | -foreach($json as $address) { |
|
25 | +foreach ($json as $address) { |
|
26 | 26 | $addresses[] = Address::fromArray($address); |
27 | 27 | } |
28 | 28 |
@@ -7,14 +7,11 @@ |
||
7 | 7 | use Route4Me\Enum\OptimizationType; |
8 | 8 | use Route4Me\OptimizationProblem; |
9 | 9 | use Route4Me\OptimizationProblemParams; |
10 | -use Route4Me\Enum\AlgorithmType; |
|
11 | 10 | use Route4Me\Enum\DistanceUnit; |
12 | 11 | use Route4Me\Enum\DeviceType; |
13 | -use Route4Me\Enum\TravelMode; |
|
14 | 12 | use Route4Me\Enum\Metric; |
15 | 13 | use Route4Me\RouteParameters; |
16 | 14 | use Route4Me\Address; |
17 | -use Route4Me\Route; |
|
18 | 15 | |
19 | 16 | Route4Me::setApiKey('11111111111111111111111111111111'); |
20 | 17 |
@@ -23,18 +23,18 @@ |
||
23 | 23 | |
24 | 24 | $addresses = array(); |
25 | 25 | foreach($json as $address) { |
26 | - $addresses[] = Address::fromArray($address); |
|
26 | + $addresses[] = Address::fromArray($address); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | $parameters = RouteParameters::fromArray(array( |
30 | - "algorithm_type" => Algorithmtype::TSP, |
|
31 | - "route_name" => "Single Driver Multiple TimeWindows 12 Stops", |
|
32 | - "route_date" => time() + 24*60*60, |
|
33 | - "route_time" => 5 * 3600 + 30 * 60, |
|
34 | - "distance_unit" => DistanceUnit::MILES, |
|
35 | - "device_type" => DeviceType::WEB, |
|
36 | - "optimize" => OptimizationType::DISTANCE, |
|
37 | - "metric" => Metric::GEODESIC |
|
30 | + "algorithm_type" => Algorithmtype::TSP, |
|
31 | + "route_name" => "Single Driver Multiple TimeWindows 12 Stops", |
|
32 | + "route_date" => time() + 24*60*60, |
|
33 | + "route_time" => 5 * 3600 + 30 * 60, |
|
34 | + "distance_unit" => DistanceUnit::MILES, |
|
35 | + "device_type" => DeviceType::WEB, |
|
36 | + "optimize" => OptimizationType::DISTANCE, |
|
37 | + "metric" => Metric::GEODESIC |
|
38 | 38 | )); |
39 | 39 | |
40 | 40 | $optimizationParams = new OptimizationProblemParams; |
@@ -22,14 +22,14 @@ |
||
22 | 22 | $json = json_decode(file_get_contents('./addresses.json'), true); |
23 | 23 | |
24 | 24 | $addresses = array(); |
25 | -foreach($json as $address) { |
|
25 | +foreach ($json as $address) { |
|
26 | 26 | $addresses[] = Address::fromArray($address); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $parameters = RouteParameters::fromArray(array( |
30 | 30 | "algorithm_type" => Algorithmtype::TSP, |
31 | 31 | "route_name" => "Single Driver Multiple TimeWindows 12 Stops", |
32 | - "route_date" => time() + 24*60*60, |
|
32 | + "route_date" => time() + 24 * 60 * 60, |
|
33 | 33 | "route_time" => 5 * 3600 + 30 * 60, |
34 | 34 | "distance_unit" => DistanceUnit::MILES, |
35 | 35 | "device_type" => DeviceType::WEB, |
@@ -51,8 +51,7 @@ |
||
51 | 51 | if (is_string($value)) |
52 | 52 | { |
53 | 53 | echo $key." --> ".$value."<br>"; |
54 | - } |
|
55 | - else |
|
54 | + } else |
|
56 | 55 | { |
57 | 56 | echo "************ $key ************* <br>"; |
58 | 57 | Route4Me::simplePrint((array)$value); |
@@ -5,10 +5,6 @@ |
||
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | |
8 | - use Route4Me\Enum\DeviceType; |
|
9 | - use Route4Me\Enum\Format; |
|
10 | - use Route4Me\TrackSetParams; |
|
11 | - use Route4Me\Track; |
|
12 | 8 | use Route4Me\Route; |
13 | 9 | |
14 | 10 | // The example refers to the process of an asset tracking by sending HTTP parameters. |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -25,8 +25,7 @@ |
||
25 | 25 | if (is_array($value)) |
26 | 26 | { |
27 | 27 | Route4Me::simplePrint($value); |
28 | - } |
|
29 | - else |
|
28 | + } else |
|
30 | 29 | { |
31 | 30 | echo "$key => $value <br>"; |
32 | 31 | } |
@@ -6,10 +6,6 @@ |
||
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | //require __DIR__.'/../vendor/autoload.php';; |
8 | 8 | |
9 | - use Route4Me\Enum\DeviceType; |
|
10 | - use Route4Me\Enum\Format; |
|
11 | - use Route4Me\TrackSetParams; |
|
12 | - use Route4Me\Track; |
|
13 | 9 | use Route4Me\Route; |
14 | 10 | |
15 | 11 | Route4Me::setApiKey('11111111111111111111111111111111'); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | //require __DIR__.'/../vendor/autoload.php';; |
@@ -25,8 +25,7 @@ |
||
25 | 25 | if (is_array($value)) |
26 | 26 | { |
27 | 27 | Route4Me::simplePrint($value); |
28 | - } |
|
29 | - else |
|
28 | + } else |
|
30 | 29 | { |
31 | 30 | echo "$key => $value <br>"; |
32 | 31 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Route4Me\Exception\BadParam; |
6 | 6 | use Route4Me\Route4Me; |
7 | -use GuzzleHttp\Client; |
|
8 | 7 | use Route4Me\Common; |
9 | 8 | |
10 | 9 | class Address extends Common |
@@ -9,55 +9,55 @@ discard block |
||
9 | 9 | |
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | - static public $apiUrl = '/api.v4/address.php'; |
|
12 | + static public $apiUrl = '/api.v4/address.php'; |
|
13 | 13 | static public $apiUrlMove='/actions/route/move_route_destination.php'; |
14 | 14 | static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
15 | 15 | static public $apiUrVisited='/actions/address/update_address_visited.php'; |
16 | 16 | |
17 | - public $route_destination_id; |
|
18 | - public $alias; |
|
19 | - public $member_id; |
|
20 | - public $address; |
|
21 | - public $is_depot = false; |
|
22 | - public $lat; |
|
23 | - public $lng; |
|
24 | - public $route_id; |
|
25 | - public $original_route_id; |
|
26 | - public $optimization_problem_id; |
|
27 | - public $sequence_no; |
|
28 | - public $geocoded; |
|
29 | - public $preferred_geocoding; |
|
30 | - public $failed_geocoding; |
|
31 | - public $geocodings = array(); |
|
32 | - public $contact_id; |
|
33 | - public $is_visited; |
|
34 | - public $customer_po; |
|
35 | - public $invoice_no; |
|
36 | - public $reference_no; |
|
37 | - public $order_no; |
|
38 | - public $weight; |
|
39 | - public $cost; |
|
40 | - public $revenue; |
|
41 | - public $cube; |
|
42 | - public $pieces; |
|
43 | - public $email; |
|
44 | - public $phone; |
|
45 | - public $destination_note_count; |
|
46 | - public $drive_time_to_next_destination; |
|
47 | - public $distance_to_next_destination; |
|
48 | - public $generated_time_window_start; |
|
49 | - public $generated_time_window_end; |
|
50 | - public $time_window_start; |
|
51 | - public $time_window_end; |
|
52 | - public $time; |
|
17 | + public $route_destination_id; |
|
18 | + public $alias; |
|
19 | + public $member_id; |
|
20 | + public $address; |
|
21 | + public $is_depot = false; |
|
22 | + public $lat; |
|
23 | + public $lng; |
|
24 | + public $route_id; |
|
25 | + public $original_route_id; |
|
26 | + public $optimization_problem_id; |
|
27 | + public $sequence_no; |
|
28 | + public $geocoded; |
|
29 | + public $preferred_geocoding; |
|
30 | + public $failed_geocoding; |
|
31 | + public $geocodings = array(); |
|
32 | + public $contact_id; |
|
33 | + public $is_visited; |
|
34 | + public $customer_po; |
|
35 | + public $invoice_no; |
|
36 | + public $reference_no; |
|
37 | + public $order_no; |
|
38 | + public $weight; |
|
39 | + public $cost; |
|
40 | + public $revenue; |
|
41 | + public $cube; |
|
42 | + public $pieces; |
|
43 | + public $email; |
|
44 | + public $phone; |
|
45 | + public $destination_note_count; |
|
46 | + public $drive_time_to_next_destination; |
|
47 | + public $distance_to_next_destination; |
|
48 | + public $generated_time_window_start; |
|
49 | + public $generated_time_window_end; |
|
50 | + public $time_window_start; |
|
51 | + public $time_window_end; |
|
52 | + public $time; |
|
53 | 53 | public $notes; |
54 | - public $timestamp_last_visited; |
|
55 | - public $custom_fields = array(); |
|
56 | - public $manifest = array(); |
|
54 | + public $timestamp_last_visited; |
|
55 | + public $custom_fields = array(); |
|
56 | + public $manifest = array(); |
|
57 | 57 | |
58 | - public static function fromArray(array $params) |
|
59 | - { |
|
60 | - /*if (!isset($params['address'])) { |
|
58 | + public static function fromArray(array $params) |
|
59 | + { |
|
60 | + /*if (!isset($params['address'])) { |
|
61 | 61 | throw new BadParam('address must be provided'); |
62 | 62 | } |
63 | 63 | |
@@ -69,142 +69,142 @@ discard block |
||
69 | 69 | throw new BadParam('lng must be provided'); |
70 | 70 | }*/ |
71 | 71 | |
72 | - $address = new Address(); |
|
73 | - foreach($params as $key => $value) { |
|
74 | - if (property_exists($address, $key)) { |
|
75 | - $address->{$key} = $value; |
|
76 | - } |
|
77 | - } |
|
72 | + $address = new Address(); |
|
73 | + foreach($params as $key => $value) { |
|
74 | + if (property_exists($address, $key)) { |
|
75 | + $address->{$key} = $value; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + return $address; |
|
80 | + } |
|
78 | 81 | |
79 | - return $address; |
|
80 | - } |
|
81 | - |
|
82 | - public static function getAddress($routeId, $addressId) |
|
83 | - { |
|
84 | - $address = Route4Me::makeRequst(array( |
|
85 | - 'url' => self::$apiUrl, |
|
86 | - 'method' => 'GET', |
|
87 | - 'query' => array( |
|
88 | - 'route_id' => $routeId, |
|
89 | - 'route_destination_id' => $addressId, |
|
90 | - ) |
|
91 | - )); |
|
92 | - |
|
93 | - return Address::fromArray($address); |
|
94 | - } |
|
82 | + public static function getAddress($routeId, $addressId) |
|
83 | + { |
|
84 | + $address = Route4Me::makeRequst(array( |
|
85 | + 'url' => self::$apiUrl, |
|
86 | + 'method' => 'GET', |
|
87 | + 'query' => array( |
|
88 | + 'route_id' => $routeId, |
|
89 | + 'route_destination_id' => $addressId, |
|
90 | + ) |
|
91 | + )); |
|
92 | + |
|
93 | + return Address::fromArray($address); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /*Get notes from the specified route destination |
97 | 97 | * Returns an address object with notes, if an address exists, otherwise - return null. |
98 | 98 | */ |
99 | - public static function GetAddressesNotes($noteParams) |
|
100 | - { |
|
101 | - $address = Route4Me::makeRequst(array( |
|
102 | - 'url' => self::$apiUrl, |
|
103 | - 'method' => 'GET', |
|
104 | - 'query' => array( |
|
105 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
106 | - 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
|
107 | - 'notes' => 1, |
|
108 | - ) |
|
109 | - )); |
|
110 | - |
|
111 | - return $address; |
|
112 | - } |
|
113 | - |
|
114 | - public function update() |
|
115 | - { |
|
116 | - $address = Route4Me::makeRequst(array( |
|
117 | - 'url' => self::$apiUrl, |
|
118 | - 'method' => 'PUT', |
|
119 | - 'body' => $this->toArray(), |
|
120 | - 'query' => array( |
|
121 | - 'route_id' => $this->route_id, |
|
122 | - 'route_destination_id' => $this->route_destination_id, |
|
123 | - ), |
|
124 | - )); |
|
125 | - |
|
126 | - return Address::fromArray($address); |
|
127 | - } |
|
99 | + public static function GetAddressesNotes($noteParams) |
|
100 | + { |
|
101 | + $address = Route4Me::makeRequst(array( |
|
102 | + 'url' => self::$apiUrl, |
|
103 | + 'method' => 'GET', |
|
104 | + 'query' => array( |
|
105 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
106 | + 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
|
107 | + 'notes' => 1, |
|
108 | + ) |
|
109 | + )); |
|
110 | + |
|
111 | + return $address; |
|
112 | + } |
|
113 | + |
|
114 | + public function update() |
|
115 | + { |
|
116 | + $address = Route4Me::makeRequst(array( |
|
117 | + 'url' => self::$apiUrl, |
|
118 | + 'method' => 'PUT', |
|
119 | + 'body' => $this->toArray(), |
|
120 | + 'query' => array( |
|
121 | + 'route_id' => $this->route_id, |
|
122 | + 'route_destination_id' => $this->route_destination_id, |
|
123 | + ), |
|
124 | + )); |
|
125 | + |
|
126 | + return Address::fromArray($address); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | public function markAddress($params, $body) |
130 | - { |
|
131 | - $result = Route4Me::makeRequst(array( |
|
132 | - 'url' => self::$apiUrl, |
|
133 | - 'method' => 'PUT', |
|
134 | - 'query' => array( |
|
135 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
136 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
137 | - ), |
|
138 | - 'body' => $body |
|
139 | - )); |
|
140 | - |
|
141 | - return $result; |
|
142 | - } |
|
130 | + { |
|
131 | + $result = Route4Me::makeRequst(array( |
|
132 | + 'url' => self::$apiUrl, |
|
133 | + 'method' => 'PUT', |
|
134 | + 'query' => array( |
|
135 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
136 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
137 | + ), |
|
138 | + 'body' => $body |
|
139 | + )); |
|
140 | + |
|
141 | + return $result; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | public function markAsDeparted($params) |
145 | 145 | { |
146 | 146 | $address = Route4Me::makeRequst(array( |
147 | - 'url' => self::$apiUrDeparted, |
|
148 | - 'method' => 'GET', |
|
149 | - 'query' => array( |
|
150 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
154 | - ), |
|
155 | - )); |
|
156 | - |
|
157 | - return $address; |
|
147 | + 'url' => self::$apiUrDeparted, |
|
148 | + 'method' => 'GET', |
|
149 | + 'query' => array( |
|
150 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
154 | + ), |
|
155 | + )); |
|
156 | + |
|
157 | + return $address; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function markAsVisited($params) |
161 | 161 | { |
162 | 162 | $address = Route4Me::makeRequst(array( |
163 | - 'url' => self::$apiUrVisited, |
|
164 | - 'method' => 'GET', |
|
165 | - 'query' => array( |
|
166 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
170 | - ), |
|
171 | - )); |
|
172 | - |
|
173 | - return $address; |
|
163 | + 'url' => self::$apiUrVisited, |
|
164 | + 'method' => 'GET', |
|
165 | + 'query' => array( |
|
166 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
170 | + ), |
|
171 | + )); |
|
172 | + |
|
173 | + return $address; |
|
174 | 174 | } |
175 | 175 | |
176 | - public function delete() |
|
177 | - { |
|
178 | - $address = Route4Me::makeRequst(array( |
|
179 | - 'url' => self::$apiUrl, |
|
180 | - 'method' => 'DELETE', |
|
181 | - 'query' => array( |
|
182 | - 'route_id' => $this->route_id, |
|
183 | - 'route_destination_id' => $this->route_destination_id, |
|
184 | - ) |
|
185 | - )); |
|
186 | - |
|
187 | - return (bool)$address['deleted']; |
|
188 | - } |
|
176 | + public function delete() |
|
177 | + { |
|
178 | + $address = Route4Me::makeRequst(array( |
|
179 | + 'url' => self::$apiUrl, |
|
180 | + 'method' => 'DELETE', |
|
181 | + 'query' => array( |
|
182 | + 'route_id' => $this->route_id, |
|
183 | + 'route_destination_id' => $this->route_destination_id, |
|
184 | + ) |
|
185 | + )); |
|
186 | + |
|
187 | + return (bool)$address['deleted']; |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public function MoveDestinationToRoute($params) |
191 | 191 | { |
192 | 192 | $result = Route4Me::makeRequst(array( |
193 | - 'url' => self::$apiUrlMove, |
|
194 | - 'method' => 'POST', |
|
195 | - 'query' => array( |
|
196 | - 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
197 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
198 | - 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
199 | - ) |
|
200 | - )); |
|
201 | - |
|
202 | - return $result; |
|
193 | + 'url' => self::$apiUrlMove, |
|
194 | + 'method' => 'POST', |
|
195 | + 'query' => array( |
|
196 | + 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
197 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
198 | + 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
199 | + ) |
|
200 | + )); |
|
201 | + |
|
202 | + return $result; |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
206 | - function getAddressId() |
|
207 | - { |
|
208 | - return $this->route_destination_id; |
|
209 | - } |
|
206 | + function getAddressId() |
|
207 | + { |
|
208 | + return $this->route_destination_id; |
|
209 | + } |
|
210 | 210 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | 12 | static public $apiUrl = '/api.v4/address.php'; |
13 | - static public $apiUrlMove='/actions/route/move_route_destination.php'; |
|
14 | - static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
|
15 | - static public $apiUrVisited='/actions/address/update_address_visited.php'; |
|
13 | + static public $apiUrlMove = '/actions/route/move_route_destination.php'; |
|
14 | + static public $apiUrDeparted = '/api/route/mark_address_departed.php'; |
|
15 | + static public $apiUrVisited = '/actions/address/update_address_visited.php'; |
|
16 | 16 | |
17 | 17 | public $route_destination_id; |
18 | 18 | public $alias; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | }*/ |
71 | 71 | |
72 | 72 | $address = new Address(); |
73 | - foreach($params as $key => $value) { |
|
73 | + foreach ($params as $key => $value) { |
|
74 | 74 | if (property_exists($address, $key)) { |
75 | 75 | $address->{$key} = $value; |
76 | 76 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'url' => self::$apiUrl, |
103 | 103 | 'method' => 'GET', |
104 | 104 | 'query' => array( |
105 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id']: null, |
|
105 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
106 | 106 | 'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null, |
107 | 107 | 'notes' => 1, |
108 | 108 | ) |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | 'url' => self::$apiUrl, |
133 | 133 | 'method' => 'PUT', |
134 | 134 | 'query' => array( |
135 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
135 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
136 | 136 | 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
137 | 137 | ), |
138 | 138 | 'body' => $body |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | 'url' => self::$apiUrDeparted, |
148 | 148 | 'method' => 'GET', |
149 | 149 | 'query' => array( |
150 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
151 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
152 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
153 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
150 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
151 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
152 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed'] : null, |
|
153 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
154 | 154 | ), |
155 | 155 | )); |
156 | 156 | |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | 'url' => self::$apiUrVisited, |
164 | 164 | 'method' => 'GET', |
165 | 165 | 'query' => array( |
166 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
167 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
168 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
169 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
166 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
167 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
168 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null, |
|
169 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
170 | 170 | ), |
171 | 171 | )); |
172 | 172 |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use Route4Me\OptimizationProblemParams; |
9 | 9 | use Route4Me\Route; |
10 | 10 | use Route4Me\Route4Me; |
11 | -use GuzzleHttp\Client; |
|
12 | 11 | |
13 | 12 | class OptimizationProblem extends Common |
14 | 13 | { |
@@ -155,7 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | $optimizations = array(); |
157 | 157 | foreach($json as $optimization) { |
158 | - if (gettype($optimization)!="array") continue; |
|
158 | + if (gettype($optimization)!="array") { |
|
159 | + continue; |
|
160 | + } |
|
159 | 161 | foreach ($optimization as $otp1) { |
160 | 162 | $optimizations[] = $otp1; |
161 | 163 | } |
@@ -169,7 +171,9 @@ discard block |
||
169 | 171 | |
170 | 172 | public function getAddresses($opt_id) |
171 | 173 | { |
172 | - if ($opt_id==null) return null; |
|
174 | + if ($opt_id==null) { |
|
175 | + return null; |
|
176 | + } |
|
173 | 177 | |
174 | 178 | $params = array( "optimization_problem_id" => $opt_id ); |
175 | 179 |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | 'url' => self::$apiUrl, |
70 | 70 | 'method' => 'POST', |
71 | 71 | 'query' => array( |
72 | - 'directions' => isset($params->directions) ? $params->directions: null, |
|
73 | - 'format' => isset($params->format) ? $params->format: null, |
|
74 | - 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output: null, |
|
75 | - 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url: null |
|
72 | + 'directions' => isset($params->directions) ? $params->directions : null, |
|
73 | + 'format' => isset($params->format) ? $params->format : null, |
|
74 | + 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output : null, |
|
75 | + 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null |
|
76 | 76 | ), |
77 | 77 | 'body' => array( |
78 | 78 | 'addresses' => $params->getAddressesArray(), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | if (isset($optimize['optimizations'])) { |
103 | 103 | $problems = array(); |
104 | - foreach($optimize['optimizations'] as $problem) { |
|
104 | + foreach ($optimize['optimizations'] as $problem) { |
|
105 | 105 | $problems[] = OptimizationProblem::fromArray($problem); |
106 | 106 | } |
107 | 107 | return $problems; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | return $this->routes; |
145 | 145 | } |
146 | 146 | |
147 | - public function getRandomOptimizationId($offset,$limit) |
|
147 | + public function getRandomOptimizationId($offset, $limit) |
|
148 | 148 | { |
149 | 149 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
150 | 150 | $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | )); |
157 | 157 | |
158 | 158 | $optimizations = array(); |
159 | - foreach($json as $optimization) { |
|
159 | + foreach ($json as $optimization) { |
|
160 | 160 | if (gettype($optimization)!="array") continue; |
161 | 161 | foreach ($optimization as $otp1) { |
162 | 162 | $optimizations[] = $otp1; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $num=rand(0,sizeof($optimizations)-1); |
|
166 | + $num = rand(0, sizeof($optimizations) - 1); |
|
167 | 167 | //echo "num=$num.<br>".sizeof($optimizations)."<br>"; |
168 | - $rOptimization=$optimizations[$num]; |
|
168 | + $rOptimization = $optimizations[$num]; |
|
169 | 169 | return $rOptimization; |
170 | 170 | } |
171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | { |
174 | 174 | if ($opt_id==null) return null; |
175 | 175 | |
176 | - $params = array( "optimization_problem_id" => $opt_id ); |
|
176 | + $params = array("optimization_problem_id" => $opt_id); |
|
177 | 177 | |
178 | 178 | $optimization = (array)$this->get($params); |
179 | 179 | |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | { |
188 | 188 | $addresses = (array)$this->getAddresses($opt_id); |
189 | 189 | |
190 | - if ($addresses == null) { |
|
190 | + if ($addresses==null) { |
|
191 | 191 | echo "There are no addresses in this optimization!.. Try again."; |
192 | 192 | return null; |
193 | 193 | } |
194 | 194 | |
195 | - $num=rand(0,sizeof($addresses)-1); |
|
196 | - $rAddress=$addresses[$num]; |
|
195 | + $num = rand(0, sizeof($addresses) - 1); |
|
196 | + $rAddress = $addresses[$num]; |
|
197 | 197 | |
198 | 198 | return $rAddress; |
199 | 199 | } |
@@ -12,156 +12,156 @@ discard block |
||
12 | 12 | |
13 | 13 | class OptimizationProblem extends Common |
14 | 14 | { |
15 | - static public $apiUrl = '/api.v4/optimization_problem.php'; |
|
15 | + static public $apiUrl = '/api.v4/optimization_problem.php'; |
|
16 | 16 | static public $apiUrl_addr = '/api.v4/address.php'; |
17 | - static public $apiHybridUrl = '/api.v4/hybrid_date_optimization.php'; |
|
18 | - static public $apiHybridDepotUrl = '/api/change_hybrid_optimization_depot.php'; |
|
17 | + static public $apiHybridUrl = '/api.v4/hybrid_date_optimization.php'; |
|
18 | + static public $apiHybridDepotUrl = '/api/change_hybrid_optimization_depot.php'; |
|
19 | 19 | |
20 | - public $optimization_problem_id; |
|
21 | - public $user_errors = array(); |
|
22 | - public $state; |
|
23 | - public $parameters; |
|
24 | - public $sent_to_background; |
|
25 | - public $addresses = array(); |
|
26 | - public $routes = array(); |
|
27 | - public $links = array(); |
|
20 | + public $optimization_problem_id; |
|
21 | + public $user_errors = array(); |
|
22 | + public $state; |
|
23 | + public $parameters; |
|
24 | + public $sent_to_background; |
|
25 | + public $addresses = array(); |
|
26 | + public $routes = array(); |
|
27 | + public $links = array(); |
|
28 | 28 | |
29 | - function __construct() |
|
30 | - { |
|
31 | - $this->parameters = new RouteParameters; |
|
32 | - } |
|
29 | + function __construct() |
|
30 | + { |
|
31 | + $this->parameters = new RouteParameters; |
|
32 | + } |
|
33 | 33 | |
34 | - public static function fromArray(array $params) |
|
35 | - { |
|
36 | - $problem = new OptimizationProblem; |
|
37 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
38 | - $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
39 | - $problem->state = Common::getValue($params, 'state', array()); |
|
40 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
41 | - $problem->links = Common::getValue($params, 'links', array()); |
|
34 | + public static function fromArray(array $params) |
|
35 | + { |
|
36 | + $problem = new OptimizationProblem; |
|
37 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
38 | + $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
39 | + $problem->state = Common::getValue($params, 'state', array()); |
|
40 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
41 | + $problem->links = Common::getValue($params, 'links', array()); |
|
42 | 42 | |
43 | - if (isset($params['parameters'])) { |
|
44 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
45 | - } |
|
43 | + if (isset($params['parameters'])) { |
|
44 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
45 | + } |
|
46 | 46 | |
47 | - if (isset($params['addresses'])) { |
|
48 | - $addresses = array(); |
|
49 | - foreach ($params['addresses'] as $address) { |
|
50 | - $addresses[] = Address::fromArray($address); |
|
51 | - } |
|
52 | - $problem->addresses = $addresses; |
|
53 | - } |
|
47 | + if (isset($params['addresses'])) { |
|
48 | + $addresses = array(); |
|
49 | + foreach ($params['addresses'] as $address) { |
|
50 | + $addresses[] = Address::fromArray($address); |
|
51 | + } |
|
52 | + $problem->addresses = $addresses; |
|
53 | + } |
|
54 | 54 | |
55 | - if (isset($params['routes'])) { |
|
56 | - $routes = array(); |
|
57 | - foreach ($params['routes'] as $route) { |
|
58 | - $routes[] = Route::fromArray($route); |
|
59 | - } |
|
60 | - $problem->routes = $routes; |
|
61 | - } |
|
55 | + if (isset($params['routes'])) { |
|
56 | + $routes = array(); |
|
57 | + foreach ($params['routes'] as $route) { |
|
58 | + $routes[] = Route::fromArray($route); |
|
59 | + } |
|
60 | + $problem->routes = $routes; |
|
61 | + } |
|
62 | 62 | |
63 | - return $problem; |
|
64 | - } |
|
63 | + return $problem; |
|
64 | + } |
|
65 | 65 | |
66 | - public static function optimize(OptimizationProblemParams $params) |
|
67 | - { |
|
68 | - $optimize = Route4Me::makeRequst(array( |
|
69 | - 'url' => self::$apiUrl, |
|
70 | - 'method' => 'POST', |
|
71 | - 'query' => array( |
|
72 | - 'directions' => isset($params->directions) ? $params->directions: null, |
|
73 | - 'format' => isset($params->format) ? $params->format: null, |
|
74 | - 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output: null, |
|
75 | - 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url: null |
|
76 | - ), |
|
77 | - 'body' => array( |
|
78 | - 'addresses' => $params->getAddressesArray(), |
|
79 | - 'parameters' => $params->getParametersArray() |
|
80 | - ) |
|
81 | - )); |
|
66 | + public static function optimize(OptimizationProblemParams $params) |
|
67 | + { |
|
68 | + $optimize = Route4Me::makeRequst(array( |
|
69 | + 'url' => self::$apiUrl, |
|
70 | + 'method' => 'POST', |
|
71 | + 'query' => array( |
|
72 | + 'directions' => isset($params->directions) ? $params->directions: null, |
|
73 | + 'format' => isset($params->format) ? $params->format: null, |
|
74 | + 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output: null, |
|
75 | + 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url: null |
|
76 | + ), |
|
77 | + 'body' => array( |
|
78 | + 'addresses' => $params->getAddressesArray(), |
|
79 | + 'parameters' => $params->getParametersArray() |
|
80 | + ) |
|
81 | + )); |
|
82 | 82 | |
83 | - return OptimizationProblem::fromArray($optimize); |
|
84 | - } |
|
83 | + return OptimizationProblem::fromArray($optimize); |
|
84 | + } |
|
85 | 85 | |
86 | - public static function get($params) |
|
87 | - { |
|
88 | - $optimize = Route4Me::makeRequst(array( |
|
89 | - 'url' => self::$apiUrl, |
|
90 | - 'method' => 'GET', |
|
91 | - 'query' => array( |
|
92 | - 'state' => isset($params['state']) ? $params['state'] : null, |
|
93 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
94 | - 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
95 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
96 | - ? $params['optimization_problem_id'] : null, |
|
97 | - 'wait_for_final_state' => isset($params['wait_for_final_state']) |
|
98 | - ? $params['wait_for_final_state'] : null, |
|
99 | - ) |
|
100 | - )); |
|
86 | + public static function get($params) |
|
87 | + { |
|
88 | + $optimize = Route4Me::makeRequst(array( |
|
89 | + 'url' => self::$apiUrl, |
|
90 | + 'method' => 'GET', |
|
91 | + 'query' => array( |
|
92 | + 'state' => isset($params['state']) ? $params['state'] : null, |
|
93 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
94 | + 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
95 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
96 | + ? $params['optimization_problem_id'] : null, |
|
97 | + 'wait_for_final_state' => isset($params['wait_for_final_state']) |
|
98 | + ? $params['wait_for_final_state'] : null, |
|
99 | + ) |
|
100 | + )); |
|
101 | 101 | |
102 | - if (isset($optimize['optimizations'])) { |
|
103 | - $problems = array(); |
|
104 | - foreach($optimize['optimizations'] as $problem) { |
|
105 | - $problems[] = OptimizationProblem::fromArray($problem); |
|
106 | - } |
|
107 | - return $problems; |
|
108 | - } else { |
|
109 | - return OptimizationProblem::fromArray($optimize); |
|
110 | - } |
|
111 | - } |
|
102 | + if (isset($optimize['optimizations'])) { |
|
103 | + $problems = array(); |
|
104 | + foreach($optimize['optimizations'] as $problem) { |
|
105 | + $problems[] = OptimizationProblem::fromArray($problem); |
|
106 | + } |
|
107 | + return $problems; |
|
108 | + } else { |
|
109 | + return OptimizationProblem::fromArray($optimize); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | - public static function reoptimize($params) |
|
114 | - { |
|
115 | - $param = new OptimizationProblemParams; |
|
116 | - $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
117 | - $param->reoptimize = 1; |
|
113 | + public static function reoptimize($params) |
|
114 | + { |
|
115 | + $param = new OptimizationProblemParams; |
|
116 | + $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
117 | + $param->reoptimize = 1; |
|
118 | 118 | |
119 | - return self::update((array)$param); |
|
120 | - } |
|
119 | + return self::update((array)$param); |
|
120 | + } |
|
121 | 121 | |
122 | - public static function update($params) |
|
123 | - { |
|
122 | + public static function update($params) |
|
123 | + { |
|
124 | 124 | $optimize = Route4Me::makeRequst(array( |
125 | - 'url' => self::$apiUrl, |
|
126 | - 'method' => 'PUT', |
|
127 | - 'query' => array( |
|
128 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
129 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
130 | - 'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null, |
|
131 | - ) |
|
132 | - )); |
|
125 | + 'url' => self::$apiUrl, |
|
126 | + 'method' => 'PUT', |
|
127 | + 'query' => array( |
|
128 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
129 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
130 | + 'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null, |
|
131 | + ) |
|
132 | + )); |
|
133 | 133 | |
134 | 134 | return $optimize; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - public function getOptimizationId() |
|
138 | - { |
|
139 | - return $this->optimization_problem_id; |
|
140 | - } |
|
137 | + public function getOptimizationId() |
|
138 | + { |
|
139 | + return $this->optimization_problem_id; |
|
140 | + } |
|
141 | 141 | |
142 | - public function getRoutes() |
|
143 | - { |
|
144 | - return $this->routes; |
|
145 | - } |
|
142 | + public function getRoutes() |
|
143 | + { |
|
144 | + return $this->routes; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | public function getRandomOptimizationId($offset,$limit) |
148 | 148 | { |
149 | 149 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
150 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
150 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
151 | 151 | |
152 | 152 | $json = Route4Me::makeRequst(array( |
153 | - 'url' => self::$apiUrl, |
|
154 | - 'method' => 'GET', |
|
155 | - 'query' => $query |
|
156 | - )); |
|
153 | + 'url' => self::$apiUrl, |
|
154 | + 'method' => 'GET', |
|
155 | + 'query' => $query |
|
156 | + )); |
|
157 | 157 | |
158 | 158 | $optimizations = array(); |
159 | - foreach($json as $optimization) { |
|
159 | + foreach($json as $optimization) { |
|
160 | 160 | if (gettype($optimization)!="array") continue; |
161 | 161 | foreach ($optimization as $otp1) { |
162 | 162 | $optimizations[] = $otp1; |
163 | 163 | } |
164 | - } |
|
164 | + } |
|
165 | 165 | |
166 | 166 | $num=rand(0,sizeof($optimizations)-1); |
167 | 167 | //echo "num=$num.<br>".sizeof($optimizations)."<br>"; |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | public function removeAddress($params) |
202 | 202 | { |
203 | 203 | $response = Route4Me::makeRequst(array( |
204 | - 'url' => self::$apiUrl_addr, |
|
205 | - 'method' => 'DELETE', |
|
206 | - 'query' => array( |
|
207 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
208 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
209 | - ) |
|
210 | - )); |
|
204 | + 'url' => self::$apiUrl_addr, |
|
205 | + 'method' => 'DELETE', |
|
206 | + 'query' => array( |
|
207 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
208 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
209 | + ) |
|
210 | + )); |
|
211 | 211 | |
212 | 212 | return $response; |
213 | 213 | } |
@@ -215,48 +215,48 @@ discard block |
||
215 | 215 | public function removeOptimization($params) |
216 | 216 | { |
217 | 217 | $response = Route4Me::makeRequst(array( |
218 | - 'url' => self::$apiUrl, |
|
219 | - 'method' => 'DELETE', |
|
220 | - 'query' => array( |
|
221 | - 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
222 | - ), |
|
223 | - 'body' => array( |
|
218 | + 'url' => self::$apiUrl, |
|
219 | + 'method' => 'DELETE', |
|
220 | + 'query' => array( |
|
221 | + 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
222 | + ), |
|
223 | + 'body' => array( |
|
224 | 224 | 'optimization_problem_ids' => isset($params['optimization_problem_ids']) ? $params['optimization_problem_ids'] : null, |
225 | 225 | ) |
226 | - )); |
|
226 | + )); |
|
227 | 227 | |
228 | 228 | return $response; |
229 | 229 | } |
230 | 230 | |
231 | - public function getHybridOptimization($params) |
|
232 | - { |
|
233 | - $optimize = Route4Me::makeRequst(array( |
|
234 | - 'url' => self::$apiHybridUrl, |
|
235 | - 'method' => 'GET', |
|
236 | - 'query' => array( |
|
237 | - 'target_date_string' => isset($params['target_date_string']) ? $params['target_date_string'] : null, |
|
238 | - 'timezone_offset_minutes' => isset($params['timezone_offset_minutes']) ? $params['timezone_offset_minutes'] : null |
|
239 | - ) |
|
240 | - )); |
|
231 | + public function getHybridOptimization($params) |
|
232 | + { |
|
233 | + $optimize = Route4Me::makeRequst(array( |
|
234 | + 'url' => self::$apiHybridUrl, |
|
235 | + 'method' => 'GET', |
|
236 | + 'query' => array( |
|
237 | + 'target_date_string' => isset($params['target_date_string']) ? $params['target_date_string'] : null, |
|
238 | + 'timezone_offset_minutes' => isset($params['timezone_offset_minutes']) ? $params['timezone_offset_minutes'] : null |
|
239 | + ) |
|
240 | + )); |
|
241 | 241 | |
242 | - return $optimize; |
|
243 | - } |
|
242 | + return $optimize; |
|
243 | + } |
|
244 | 244 | |
245 | - Public function addDepotsToHybrid($params) |
|
246 | - { |
|
247 | - $depots = Route4Me::makeRequst(array( |
|
248 | - 'url' => self::$apiHybridDepotUrl, |
|
249 | - 'method' => 'POST', |
|
250 | - 'query' => array( |
|
251 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
252 | - ), |
|
253 | - 'body' => array( |
|
254 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
255 | - 'delete_old_depots' => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null, |
|
256 | - 'new_depots' => isset($params['new_depots']) ? $params['new_depots'] : null, |
|
257 | - ) |
|
258 | - )); |
|
245 | + Public function addDepotsToHybrid($params) |
|
246 | + { |
|
247 | + $depots = Route4Me::makeRequst(array( |
|
248 | + 'url' => self::$apiHybridDepotUrl, |
|
249 | + 'method' => 'POST', |
|
250 | + 'query' => array( |
|
251 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
252 | + ), |
|
253 | + 'body' => array( |
|
254 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
255 | + 'delete_old_depots' => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null, |
|
256 | + 'new_depots' => isset($params['new_depots']) ? $params['new_depots'] : null, |
|
257 | + ) |
|
258 | + )); |
|
259 | 259 | |
260 | - return $depots; |
|
261 | - } |
|
260 | + return $depots; |
|
261 | + } |
|
262 | 262 | } |
@@ -4,10 +4,8 @@ |
||
4 | 4 | |
5 | 5 | use Route4Me\Common; |
6 | 6 | use Route4Me\Address; |
7 | -use Route4Me\Exception\BadParam; |
|
8 | 7 | use Route4Me\RouteParameters; |
9 | 8 | use Route4Me\Route4Me; |
10 | -use GuzzleHttp\Client; |
|
11 | 9 | |
12 | 10 | class Route extends Common |
13 | 11 | { |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | { |
14 | 14 | static public $apiUrl = '/api.v4/route.php'; |
15 | 15 | static public $apiUrlAddress = '/api.v4/address.php'; |
16 | - static public $apiUrlDuplicate='/actions/duplicate_route.php'; |
|
17 | - static public $apiUrlDelete='/actions/delete_routes.php'; |
|
18 | - static public $apiUrlReseq='/api.v3/route/reoptimize_2.php'; |
|
19 | - static public $apiUrlMerge='/actions/merge_routes.php'; |
|
20 | - static public $apiUrlShare='/actions/route/share_route.php'; |
|
21 | - static public $apiUrlNoteFile='/actions/addRouteNotes.php'; |
|
22 | - static public $apiUrlAsset='/api.v4/status.php'; |
|
23 | - static public $apiUrlDeviceLocation='/api/track/get_device_location.php'; |
|
16 | + static public $apiUrlDuplicate = '/actions/duplicate_route.php'; |
|
17 | + static public $apiUrlDelete = '/actions/delete_routes.php'; |
|
18 | + static public $apiUrlReseq = '/api.v3/route/reoptimize_2.php'; |
|
19 | + static public $apiUrlMerge = '/actions/merge_routes.php'; |
|
20 | + static public $apiUrlShare = '/actions/route/share_route.php'; |
|
21 | + static public $apiUrlNoteFile = '/actions/addRouteNotes.php'; |
|
22 | + static public $apiUrlAsset = '/api.v4/status.php'; |
|
23 | + static public $apiUrlDeviceLocation = '/api/track/get_device_location.php'; |
|
24 | 24 | //static public $apiUrlMove='/actions/route/move_route_destination.php'; |
25 | 25 | public $route_id; |
26 | 26 | public $route_destination_id; |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | return $route; |
78 | 78 | } |
79 | 79 | |
80 | - public static function getRoutes($routeId=null, $params=null) |
|
80 | + public static function getRoutes($routeId = null, $params = null) |
|
81 | 81 | { |
82 | 82 | $query = array( |
83 | 83 | 'api_key' => Route4Me::getApiKey() |
84 | 84 | ); |
85 | 85 | |
86 | 86 | if ($routeId) { |
87 | - $query['route_id'] = implode(',', (array) $routeId); |
|
87 | + $query['route_id'] = implode(',', (array)$routeId); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | if ($params) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return Route::fromArray($json); die(""); |
119 | 119 | } else { |
120 | 120 | $routes = array(); |
121 | - foreach($json as $route) { |
|
121 | + foreach ($json as $route) { |
|
122 | 122 | $routes[] = Route::fromArray($route); |
123 | 123 | } |
124 | 124 | return $routes; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | // Getting random route_id from existing routes between $offset and $offset+$limit |
230 | - public function getRandomRouteId($offset,$limit) |
|
230 | + public function getRandomRouteId($offset, $limit) |
|
231 | 231 | { |
232 | 232 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
233 | 233 | $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | )); |
240 | 240 | |
241 | 241 | $routes = array(); |
242 | - foreach($json as $route) { |
|
242 | + foreach ($json as $route) { |
|
243 | 243 | $routes[] = Route::fromArray($route); |
244 | 244 | } |
245 | 245 | |
246 | - $num=rand(0,sizeof($routes)-1); |
|
247 | - $rRoute=(array)$routes[$num]; |
|
246 | + $num = rand(0, sizeof($routes) - 1); |
|
247 | + $rRoute = (array)$routes[$num]; |
|
248 | 248 | |
249 | 249 | if (is_array($rRoute)) |
250 | 250 | { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | 'route_id' => isset($this->route_id) ? $this->route_id : null, |
263 | 263 | 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
264 | 264 | ), |
265 | - 'body' => array ( |
|
265 | + 'body' => array( |
|
266 | 266 | 'parameters' => $this->parameters, |
267 | 267 | ), |
268 | 268 | 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
326 | 326 | $rpath = realpath($fname); |
327 | 327 | //echo $rpath;die(""); |
328 | - $result= Route4Me::makeRequst(array( |
|
328 | + $result = Route4Me::makeRequst(array( |
|
329 | 329 | 'url' => self::$apiUrlNoteFile, |
330 | 330 | 'method' => 'POST', |
331 | 331 | 'query' => array( |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $result = Route4Me::makeRequst(array( |
358 | 358 | 'url' => self::$apiUrl, |
359 | 359 | 'method' => 'DELETE', |
360 | - 'query' => array( 'route_id' => $route_id ) |
|
360 | + 'query' => array('route_id' => $route_id) |
|
361 | 361 | )); |
362 | 362 | |
363 | 363 | // The code below doesn't work, altough this method is described as workable in REST API |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | |
377 | 377 | public function GetAddressesFromRoute($route_id) |
378 | 378 | { |
379 | - $route1=Route::getRoutes($route_id,null); |
|
379 | + $route1 = Route::getRoutes($route_id, null); |
|
380 | 380 | if (isset($route1)) { |
381 | 381 | return $route1->addresses(); |
382 | - } else { return null;} |
|
382 | + } else { return null; } |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | public function GetRandomAddressFromRoute($route_id) |
386 | 386 | { |
387 | - $route1=Route::getRoutes($route_id,null); |
|
387 | + $route1 = Route::getRoutes($route_id, null); |
|
388 | 388 | |
389 | 389 | if (isset($route1)) { |
390 | - $addresses=$route1->addresses; |
|
390 | + $addresses = $route1->addresses; |
|
391 | 391 | |
392 | - $rnd=rand(0,sizeof($addresses)-1); |
|
392 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
393 | 393 | |
394 | 394 | return $addresses[$rnd]; |
395 | 395 | |
396 | - } else { return null;} |
|
396 | + } else { return null; } |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | public function getRouteId() |
@@ -249,8 +249,9 @@ |
||
249 | 249 | if (is_array($rRoute)) |
250 | 250 | { |
251 | 251 | return $rRoute["route_id"]; |
252 | + } else { |
|
253 | + return null; |
|
252 | 254 | } |
253 | - else return null; |
|
254 | 255 | } |
255 | 256 | |
256 | 257 | public function update() |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | class Route extends Common |
13 | 13 | { |
14 | - static public $apiUrl = '/api.v4/route.php'; |
|
14 | + static public $apiUrl = '/api.v4/route.php'; |
|
15 | 15 | static public $apiUrlAddress = '/api.v4/address.php'; |
16 | 16 | static public $apiUrlDuplicate='/actions/duplicate_route.php'; |
17 | 17 | static public $apiUrlDelete='/actions/delete_routes.php'; |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | static public $apiUrlAsset='/api.v4/status.php'; |
23 | 23 | static public $apiUrlDeviceLocation='/api/track/get_device_location.php'; |
24 | 24 | //static public $apiUrlMove='/actions/route/move_route_destination.php'; |
25 | - public $route_id; |
|
25 | + public $route_id; |
|
26 | 26 | public $route_destination_id; |
27 | - public $optimization_problem_id; |
|
28 | - public $vehicle_alias; |
|
29 | - public $driver_alias; |
|
30 | - public $trip_distance; |
|
31 | - public $mpg; |
|
32 | - public $gas_price; |
|
33 | - public $route_duration_sec; |
|
34 | - public $parameters; |
|
35 | - public $addresses = array(); |
|
36 | - public $links = array(); |
|
37 | - public $directions = array(); |
|
38 | - public $path = array(); |
|
39 | - public $tracking_history = array(); |
|
27 | + public $optimization_problem_id; |
|
28 | + public $vehicle_alias; |
|
29 | + public $driver_alias; |
|
30 | + public $trip_distance; |
|
31 | + public $mpg; |
|
32 | + public $gas_price; |
|
33 | + public $route_duration_sec; |
|
34 | + public $parameters; |
|
35 | + public $addresses = array(); |
|
36 | + public $links = array(); |
|
37 | + public $directions = array(); |
|
38 | + public $path = array(); |
|
39 | + public $tracking_history = array(); |
|
40 | 40 | public $recipient_email; |
41 | 41 | public $httpheaders; |
42 | 42 | public $is_unrouted; |
@@ -44,101 +44,101 @@ discard block |
||
44 | 44 | public $dev_lat; |
45 | 45 | public $dev_lng; |
46 | 46 | |
47 | - public static function fromArray(array $params) |
|
48 | - { |
|
49 | - $route = new Route(); |
|
50 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
51 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
52 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
53 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
54 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
55 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
56 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
57 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
58 | - $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
59 | - |
|
60 | - // Make RouteParameters |
|
61 | - if (isset($params['parameters'])) { |
|
62 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
63 | - } |
|
64 | - |
|
65 | - if (isset($params['addresses'])) { |
|
66 | - $addresses = array(); |
|
67 | - foreach ($params['addresses'] as $address) { |
|
68 | - $addresses[] = Address::fromArray($address); |
|
69 | - } |
|
70 | - |
|
71 | - $route->addresses = $addresses; |
|
72 | - } |
|
73 | - |
|
74 | - $route->links = Common::getValue($params, 'links', array()); |
|
75 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
76 | - $route->path = Common::getValue($params, 'path', array()); |
|
77 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
78 | - |
|
79 | - return $route; |
|
80 | - } |
|
81 | - |
|
82 | - public static function getRoutes($routeId=null, $params=null) |
|
83 | - { |
|
84 | - $query = array( |
|
85 | - 'api_key' => Route4Me::getApiKey() |
|
86 | - ); |
|
87 | - |
|
88 | - if ($routeId) { |
|
89 | - $query['route_id'] = implode(',', (array) $routeId); |
|
90 | - } |
|
91 | - |
|
92 | - if ($params) { |
|
93 | - if (isset($params['directions'])) { |
|
94 | - $query['directions'] = $params['directions']; |
|
95 | - } |
|
96 | - |
|
97 | - if (isset($params['route_path_output'])) { |
|
98 | - $query['route_path_output'] = $params['route_path_output']; |
|
99 | - } |
|
100 | - |
|
101 | - if (isset($params['device_tracking_history'])) { |
|
102 | - $query['device_tracking_history'] = $params['device_tracking_history']; |
|
103 | - } |
|
47 | + public static function fromArray(array $params) |
|
48 | + { |
|
49 | + $route = new Route(); |
|
50 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
51 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
52 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
53 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
54 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
55 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
56 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
57 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
58 | + $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
59 | + |
|
60 | + // Make RouteParameters |
|
61 | + if (isset($params['parameters'])) { |
|
62 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
63 | + } |
|
64 | + |
|
65 | + if (isset($params['addresses'])) { |
|
66 | + $addresses = array(); |
|
67 | + foreach ($params['addresses'] as $address) { |
|
68 | + $addresses[] = Address::fromArray($address); |
|
69 | + } |
|
70 | + |
|
71 | + $route->addresses = $addresses; |
|
72 | + } |
|
73 | + |
|
74 | + $route->links = Common::getValue($params, 'links', array()); |
|
75 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
76 | + $route->path = Common::getValue($params, 'path', array()); |
|
77 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
78 | + |
|
79 | + return $route; |
|
80 | + } |
|
81 | + |
|
82 | + public static function getRoutes($routeId=null, $params=null) |
|
83 | + { |
|
84 | + $query = array( |
|
85 | + 'api_key' => Route4Me::getApiKey() |
|
86 | + ); |
|
87 | + |
|
88 | + if ($routeId) { |
|
89 | + $query['route_id'] = implode(',', (array) $routeId); |
|
90 | + } |
|
91 | + |
|
92 | + if ($params) { |
|
93 | + if (isset($params['directions'])) { |
|
94 | + $query['directions'] = $params['directions']; |
|
95 | + } |
|
96 | + |
|
97 | + if (isset($params['route_path_output'])) { |
|
98 | + $query['route_path_output'] = $params['route_path_output']; |
|
99 | + } |
|
100 | + |
|
101 | + if (isset($params['device_tracking_history'])) { |
|
102 | + $query['device_tracking_history'] = $params['device_tracking_history']; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | if (isset($params['query'])) { |
106 | - $query['query'] = $params['query']; |
|
107 | - } |
|
108 | - |
|
109 | - $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
110 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
111 | - } |
|
106 | + $query['query'] = $params['query']; |
|
107 | + } |
|
112 | 108 | |
113 | - $json = Route4Me::makeRequst(array( |
|
114 | - 'url' => self::$apiUrl, |
|
115 | - 'method' => 'GET', |
|
116 | - 'query' => $query |
|
117 | - )); |
|
109 | + $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
110 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
111 | + } |
|
118 | 112 | |
119 | - if ($routeId) { |
|
120 | - return Route::fromArray($json); die(""); |
|
121 | - } else { |
|
122 | - $routes = array(); |
|
123 | - foreach($json as $route) { |
|
124 | - $routes[] = Route::fromArray($route); |
|
125 | - } |
|
126 | - return $routes; |
|
127 | - } |
|
128 | - } |
|
113 | + $json = Route4Me::makeRequst(array( |
|
114 | + 'url' => self::$apiUrl, |
|
115 | + 'method' => 'GET', |
|
116 | + 'query' => $query |
|
117 | + )); |
|
118 | + |
|
119 | + if ($routeId) { |
|
120 | + return Route::fromArray($json); die(""); |
|
121 | + } else { |
|
122 | + $routes = array(); |
|
123 | + foreach($json as $route) { |
|
124 | + $routes[] = Route::fromArray($route); |
|
125 | + } |
|
126 | + return $routes; |
|
127 | + } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | public function getRoutePoints($routeId, $params) |
131 | 131 | { |
132 | 132 | $result = Route4Me::makeRequst(array( |
133 | - 'url' => self::$apiUrl, |
|
134 | - 'method' => 'GET', |
|
135 | - 'query' => array( |
|
136 | - 'api_key' => Route4Me::getApiKey(), |
|
137 | - 'route_id' => $routeId, |
|
138 | - 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
139 | - 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
140 | - ) |
|
141 | - )); |
|
133 | + 'url' => self::$apiUrl, |
|
134 | + 'method' => 'GET', |
|
135 | + 'query' => array( |
|
136 | + 'api_key' => Route4Me::getApiKey(), |
|
137 | + 'route_id' => $routeId, |
|
138 | + 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
139 | + 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
140 | + ) |
|
141 | + )); |
|
142 | 142 | |
143 | 143 | return $result; |
144 | 144 | } |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | public function duplicateRoute($route_id) |
147 | 147 | { |
148 | 148 | $result = Route4Me::makeRequst(array( |
149 | - 'url' => self::$apiUrlDuplicate, |
|
150 | - 'method' => 'GET', |
|
151 | - 'query' => array( |
|
152 | - 'api_key' => Route4Me::getApiKey(), |
|
153 | - 'route_id' => $route_id, |
|
154 | - 'to' => 'none', |
|
155 | - ) |
|
156 | - )); |
|
149 | + 'url' => self::$apiUrlDuplicate, |
|
150 | + 'method' => 'GET', |
|
151 | + 'query' => array( |
|
152 | + 'api_key' => Route4Me::getApiKey(), |
|
153 | + 'route_id' => $route_id, |
|
154 | + 'to' => 'none', |
|
155 | + ) |
|
156 | + )); |
|
157 | 157 | |
158 | 158 | return $result; |
159 | 159 | } |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | public function resequenceRoute($params) |
162 | 162 | { |
163 | 163 | $result = Route4Me::makeRequst(array( |
164 | - 'url' => self::$apiUrl, |
|
165 | - 'method' => 'PUT', |
|
166 | - 'query' => array( |
|
167 | - 'api_key' => Route4Me::getApiKey(), |
|
168 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
169 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
170 | - ), |
|
171 | - 'body' => array( |
|
164 | + 'url' => self::$apiUrl, |
|
165 | + 'method' => 'PUT', |
|
166 | + 'query' => array( |
|
167 | + 'api_key' => Route4Me::getApiKey(), |
|
168 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
169 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
170 | + ), |
|
171 | + 'body' => array( |
|
172 | 172 | 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
173 | 173 | ) |
174 | - )); |
|
174 | + )); |
|
175 | 175 | |
176 | 176 | return $result; |
177 | 177 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | public function resequenceAllAddresses($params) |
180 | 180 | { |
181 | 181 | $result = Route4Me::makeRequst(array( |
182 | - 'url' => self::$apiUrlReseq, |
|
183 | - 'method' => 'GET', |
|
184 | - 'query' => array( |
|
185 | - 'api_key' => Route4Me::getApiKey(), |
|
186 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
187 | - 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
188 | - 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
189 | - ) |
|
190 | - )); |
|
182 | + 'url' => self::$apiUrlReseq, |
|
183 | + 'method' => 'GET', |
|
184 | + 'query' => array( |
|
185 | + 'api_key' => Route4Me::getApiKey(), |
|
186 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
187 | + 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
188 | + 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
189 | + ) |
|
190 | + )); |
|
191 | 191 | |
192 | 192 | return $result; |
193 | 193 | |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | public function mergeRoutes($params) |
197 | 197 | { |
198 | 198 | $result = Route4Me::makeRequst(array( |
199 | - 'url' => self::$apiUrlMerge, |
|
200 | - 'method' => 'POST', |
|
201 | - 'query' => array( |
|
202 | - 'api_key' => Route4Me::getApiKey(), |
|
203 | - ), |
|
204 | - 'body' => array( |
|
199 | + 'url' => self::$apiUrlMerge, |
|
200 | + 'method' => 'POST', |
|
201 | + 'query' => array( |
|
202 | + 'api_key' => Route4Me::getApiKey(), |
|
203 | + ), |
|
204 | + 'body' => array( |
|
205 | 205 | 'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null, |
206 | 206 | ), |
207 | 207 | 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
208 | - )); |
|
208 | + )); |
|
209 | 209 | |
210 | 210 | return $result; |
211 | 211 | } |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | public function shareRoute($params) |
214 | 214 | { |
215 | 215 | $result = Route4Me::makeRequst(array( |
216 | - 'url' => self::$apiUrlShare, |
|
217 | - 'method' => 'POST', |
|
218 | - 'query' => array( |
|
219 | - 'api_key' => Route4Me::getApiKey(), |
|
220 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
221 | - ), |
|
222 | - 'body' => array( |
|
216 | + 'url' => self::$apiUrlShare, |
|
217 | + 'method' => 'POST', |
|
218 | + 'query' => array( |
|
219 | + 'api_key' => Route4Me::getApiKey(), |
|
220 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
221 | + ), |
|
222 | + 'body' => array( |
|
223 | 223 | 'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null, |
224 | 224 | ), |
225 | 225 | 'Content-Type' => 'multipart/form-data' |
226 | - )); |
|
226 | + )); |
|
227 | 227 | |
228 | 228 | return $result; |
229 | 229 | } |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | public function getRandomRouteId($offset,$limit) |
233 | 233 | { |
234 | 234 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
235 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
235 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
236 | 236 | |
237 | 237 | $json = Route4Me::makeRequst(array( |
238 | - 'url' => self::$apiUrl, |
|
239 | - 'method' => 'GET', |
|
240 | - 'query' => $query |
|
241 | - )); |
|
238 | + 'url' => self::$apiUrl, |
|
239 | + 'method' => 'GET', |
|
240 | + 'query' => $query |
|
241 | + )); |
|
242 | 242 | |
243 | 243 | $routes = array(); |
244 | - foreach($json as $route) { |
|
245 | - $routes[] = Route::fromArray($route); |
|
246 | - } |
|
244 | + foreach($json as $route) { |
|
245 | + $routes[] = Route::fromArray($route); |
|
246 | + } |
|
247 | 247 | |
248 | 248 | $num=rand(0,sizeof($routes)-1); |
249 | 249 | $rRoute=(array)$routes[$num]; |
@@ -255,71 +255,71 @@ discard block |
||
255 | 255 | else return null; |
256 | 256 | } |
257 | 257 | |
258 | - public function update() |
|
259 | - { |
|
260 | - $route = Route4Me::makeRequst(array( |
|
261 | - 'url' => self::$apiUrl, |
|
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' => $this->parameters, |
|
269 | - ), |
|
270 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
271 | - )); |
|
258 | + public function update() |
|
259 | + { |
|
260 | + $route = Route4Me::makeRequst(array( |
|
261 | + 'url' => self::$apiUrl, |
|
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' => $this->parameters, |
|
269 | + ), |
|
270 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
271 | + )); |
|
272 | 272 | |
273 | - return Route::fromArray($route); |
|
274 | - } |
|
273 | + return Route::fromArray($route); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | public function updateAddress() |
277 | - { |
|
278 | - $result = Route4Me::makeRequst(array( |
|
279 | - 'url' => self::$apiUrlAddress, |
|
280 | - 'method' => 'PUT', |
|
281 | - 'query' => array( |
|
282 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
283 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
284 | - ), |
|
285 | - 'body' => get_object_vars($this->parameters), |
|
286 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
287 | - )); |
|
277 | + { |
|
278 | + $result = Route4Me::makeRequst(array( |
|
279 | + 'url' => self::$apiUrlAddress, |
|
280 | + 'method' => 'PUT', |
|
281 | + 'query' => array( |
|
282 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
283 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
284 | + ), |
|
285 | + 'body' => get_object_vars($this->parameters), |
|
286 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
287 | + )); |
|
288 | 288 | |
289 | - return $result; |
|
290 | - } |
|
289 | + return $result; |
|
290 | + } |
|
291 | 291 | |
292 | - public function addAddresses(array $params) |
|
293 | - { |
|
294 | - $route = Route4Me::makeRequst(array( |
|
295 | - 'url' => self::$apiUrl, |
|
296 | - 'method' => 'PUT', |
|
297 | - 'query' => array( |
|
298 | - 'api_key' => Route4Me::getApiKey(), |
|
299 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
300 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
301 | - ) |
|
302 | - )); |
|
292 | + public function addAddresses(array $params) |
|
293 | + { |
|
294 | + $route = Route4Me::makeRequst(array( |
|
295 | + 'url' => self::$apiUrl, |
|
296 | + 'method' => 'PUT', |
|
297 | + 'query' => array( |
|
298 | + 'api_key' => Route4Me::getApiKey(), |
|
299 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
300 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
301 | + ) |
|
302 | + )); |
|
303 | 303 | |
304 | - return Route::fromArray($route); |
|
305 | - } |
|
304 | + return Route::fromArray($route); |
|
305 | + } |
|
306 | 306 | |
307 | 307 | public function insertAddressOptimalPosition(array $params) |
308 | 308 | { |
309 | 309 | $route = Route4Me::makeRequst(array( |
310 | - 'url' => self::$apiUrl, |
|
311 | - 'method' => 'PUT', |
|
312 | - 'query' => array( |
|
313 | - 'api_key' => Route4Me::getApiKey(), |
|
314 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
315 | - ), |
|
316 | - 'body' => array( |
|
310 | + 'url' => self::$apiUrl, |
|
311 | + 'method' => 'PUT', |
|
312 | + 'query' => array( |
|
313 | + 'api_key' => Route4Me::getApiKey(), |
|
314 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
315 | + ), |
|
316 | + 'body' => array( |
|
317 | 317 | 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
318 | 318 | 'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null, |
319 | 319 | ) |
320 | - )); |
|
320 | + )); |
|
321 | 321 | |
322 | - return Route::fromArray($route); |
|
322 | + return Route::fromArray($route); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | public function addNoteFile($params) |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | $rpath = realpath($fname); |
329 | 329 | //echo $rpath;die(""); |
330 | 330 | $result= Route4Me::makeRequst(array( |
331 | - 'url' => self::$apiUrlNoteFile, |
|
332 | - 'method' => 'POST', |
|
333 | - 'query' => array( |
|
334 | - 'api_key' => Route4Me::getApiKey(), |
|
335 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
336 | - 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
337 | - 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
338 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
339 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
340 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
341 | - ), |
|
342 | - 'body' => array( |
|
331 | + 'url' => self::$apiUrlNoteFile, |
|
332 | + 'method' => 'POST', |
|
333 | + 'query' => array( |
|
334 | + 'api_key' => Route4Me::getApiKey(), |
|
335 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
336 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
337 | + 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
338 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
339 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
340 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
341 | + ), |
|
342 | + 'body' => array( |
|
343 | 343 | 'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null, |
344 | 344 | 'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null, |
345 | 345 | 'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null, |
@@ -349,18 +349,18 @@ discard block |
||
349 | 349 | 'HTTPHEADER' => array( |
350 | 350 | 'Content-Type: application/x-www-form-urlencoded' |
351 | 351 | ) |
352 | - )); |
|
352 | + )); |
|
353 | 353 | |
354 | - return $result; |
|
354 | + return $result; |
|
355 | 355 | } |
356 | 356 | |
357 | - public function delete($route_id) |
|
358 | - { |
|
359 | - $result = Route4Me::makeRequst(array( |
|
360 | - 'url' => self::$apiUrl, |
|
361 | - 'method' => 'DELETE', |
|
362 | - 'query' => array( 'route_id' => $route_id ) |
|
363 | - )); |
|
357 | + public function delete($route_id) |
|
358 | + { |
|
359 | + $result = Route4Me::makeRequst(array( |
|
360 | + 'url' => self::$apiUrl, |
|
361 | + 'method' => 'DELETE', |
|
362 | + 'query' => array( 'route_id' => $route_id ) |
|
363 | + )); |
|
364 | 364 | |
365 | 365 | // The code below doesn't work, altough this method is described as workable in REST API |
366 | 366 | /* |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | ) |
374 | 374 | )); |
375 | 375 | */ |
376 | - return $result; |
|
377 | - } |
|
376 | + return $result; |
|
377 | + } |
|
378 | 378 | |
379 | 379 | public function GetAddressesFromRoute($route_id) |
380 | 380 | { |
@@ -398,63 +398,63 @@ discard block |
||
398 | 398 | } else { return null;} |
399 | 399 | } |
400 | 400 | |
401 | - public function getRouteId() |
|
402 | - { |
|
403 | - return $this->route_id; |
|
404 | - } |
|
401 | + public function getRouteId() |
|
402 | + { |
|
403 | + return $this->route_id; |
|
404 | + } |
|
405 | 405 | |
406 | - public function getOptimizationId() |
|
407 | - { |
|
408 | - return $this->optimization_problem_id; |
|
409 | - } |
|
406 | + public function getOptimizationId() |
|
407 | + { |
|
408 | + return $this->optimization_problem_id; |
|
409 | + } |
|
410 | 410 | |
411 | 411 | public function GetLastLocation(array $params) |
412 | 412 | { |
413 | 413 | $route = Route4Me::makeRequst(array( |
414 | - 'url' => self::$apiUrl, |
|
415 | - 'method' => 'GET', |
|
416 | - 'query' => array( |
|
417 | - 'api_key' => Route4Me::getApiKey(), |
|
418 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
419 | - 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
420 | - ) |
|
421 | - )); |
|
414 | + 'url' => self::$apiUrl, |
|
415 | + 'method' => 'GET', |
|
416 | + 'query' => array( |
|
417 | + 'api_key' => Route4Me::getApiKey(), |
|
418 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
419 | + 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
420 | + ) |
|
421 | + )); |
|
422 | 422 | |
423 | - return Route::fromArray($route); |
|
423 | + return Route::fromArray($route); |
|
424 | 424 | |
425 | 425 | } |
426 | 426 | |
427 | 427 | public function GetTrackingHistoryFromTimeRange(array $params) |
428 | 428 | { |
429 | 429 | $route = Route4Me::makeRequst(array( |
430 | - 'url' => self::$apiUrlDeviceLocation, |
|
431 | - 'method' => 'GET', |
|
432 | - 'query' => array( |
|
433 | - 'api_key' => Route4Me::getApiKey(), |
|
434 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
435 | - 'format' => isset($params['format']) ? $params['format'] : null, |
|
436 | - 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
437 | - 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
438 | - 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
439 | - ) |
|
440 | - )); |
|
441 | - |
|
442 | - return $route; |
|
430 | + 'url' => self::$apiUrlDeviceLocation, |
|
431 | + 'method' => 'GET', |
|
432 | + 'query' => array( |
|
433 | + 'api_key' => Route4Me::getApiKey(), |
|
434 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
435 | + 'format' => isset($params['format']) ? $params['format'] : null, |
|
436 | + 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
437 | + 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
438 | + 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
439 | + ) |
|
440 | + )); |
|
441 | + |
|
442 | + return $route; |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | 446 | public function GetAssetTracking(array $params) |
447 | 447 | { |
448 | 448 | $route = Route4Me::makeRequst(array( |
449 | - 'url' => self::$apiUrlAsset, |
|
450 | - 'method' => 'GET', |
|
451 | - 'query' => array( |
|
452 | - 'api_key' => Route4Me::getApiKey(), |
|
453 | - 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
454 | - ) |
|
455 | - )); |
|
456 | - |
|
457 | - return $route; |
|
449 | + 'url' => self::$apiUrlAsset, |
|
450 | + 'method' => 'GET', |
|
451 | + 'query' => array( |
|
452 | + 'api_key' => Route4Me::getApiKey(), |
|
453 | + 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
454 | + ) |
|
455 | + )); |
|
456 | + |
|
457 | + return $route; |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Geocoding; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | // Set the api key in the Route4me class |
14 | 14 | Route4Me::setApiKey('11111111111111111111111111111111'); |
15 | 15 | |
16 | - $gcParameters=(array)Geocoding::fromArray(array( |
|
16 | + $gcParameters = (array)Geocoding::fromArray(array( |
|
17 | 17 | "offset" => 0, |
18 | 18 | "limit" => 20 |
19 | 19 | )); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
5 | 5 | |
6 | - require $vdir.'/../vendor/autoload.php'; |
|
6 | + require $vdir.'/../vendor/autoload.php'; |
|
7 | 7 | |
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | use Route4Me\Geocoding; |