@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | class Common |
6 | 6 | { |
7 | - public static function getValue($array, $item, $default = null) |
|
8 | - { |
|
9 | - return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | - } |
|
7 | + public static function getValue($array, $item, $default = null) |
|
8 | + { |
|
9 | + return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | + } |
|
11 | 11 | |
12 | - public function toArray() |
|
13 | - { |
|
14 | - $params = array_filter(get_object_vars($this), function($item) { |
|
15 | - return ($item!==null) && !(is_array($item) && !count($item)); |
|
16 | - }); |
|
12 | + public function toArray() |
|
13 | + { |
|
14 | + $params = array_filter(get_object_vars($this), function($item) { |
|
15 | + return ($item!==null) && !(is_array($item) && !count($item)); |
|
16 | + }); |
|
17 | 17 | |
18 | - return $params; |
|
19 | - } |
|
18 | + return $params; |
|
19 | + } |
|
20 | 20 | } |
@@ -7,111 +7,111 @@ |
||
7 | 7 | |
8 | 8 | class AvoidanceZone extends Common |
9 | 9 | { |
10 | - public $territory_id; // Avoidance zone id |
|
11 | - public $territory_name; |
|
12 | - public $territory_color; |
|
13 | - public $orders; |
|
14 | - public $member_id; |
|
15 | - public $territory; // Territory parameters |
|
10 | + public $territory_id; // Avoidance zone id |
|
11 | + public $territory_name; |
|
12 | + public $territory_color; |
|
13 | + public $orders; |
|
14 | + public $member_id; |
|
15 | + public $territory; // Territory parameters |
|
16 | 16 | |
17 | - public static function fromArray(array $params) |
|
18 | - { |
|
19 | - if (!isset($params['territory_name'])) { |
|
20 | - throw new BadParam('Territory name must be provided'); |
|
21 | - } |
|
17 | + public static function fromArray(array $params) |
|
18 | + { |
|
19 | + if (!isset($params['territory_name'])) { |
|
20 | + throw new BadParam('Territory name must be provided'); |
|
21 | + } |
|
22 | 22 | |
23 | - if (!isset($params['territory_color'])) { |
|
24 | - throw new BadParam('Territory color must be provided'); |
|
25 | - } |
|
23 | + if (!isset($params['territory_color'])) { |
|
24 | + throw new BadParam('Territory color must be provided'); |
|
25 | + } |
|
26 | 26 | |
27 | - if (!isset($params['territory'])) { |
|
28 | - throw new BadParam('Territory must be provided'); |
|
29 | - } |
|
27 | + if (!isset($params['territory'])) { |
|
28 | + throw new BadParam('Territory must be provided'); |
|
29 | + } |
|
30 | 30 | |
31 | - $avoidanceZoneParameters = new AvoidanceZone(); |
|
31 | + $avoidanceZoneParameters = new AvoidanceZone(); |
|
32 | 32 | |
33 | - foreach($params as $key => $value) { |
|
34 | - if (property_exists($avoidanceZoneParameters, $key)) { |
|
35 | - $avoidanceZoneParameters->{$key} = $value; |
|
36 | - } |
|
37 | - } |
|
33 | + foreach($params as $key => $value) { |
|
34 | + if (property_exists($avoidanceZoneParameters, $key)) { |
|
35 | + $avoidanceZoneParameters->{$key} = $value; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - return $avoidanceZoneParameters; |
|
40 | - } |
|
39 | + return $avoidanceZoneParameters; |
|
40 | + } |
|
41 | 41 | |
42 | - public static function getAvoidanceZone($territory_id) |
|
43 | - { |
|
44 | - $avoidanceZone = Route4Me::makeRequst(array( |
|
45 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
46 | - 'method' => 'GET', |
|
47 | - 'query' => array( |
|
48 | - 'territory_id' => $territory_id |
|
49 | - ) |
|
50 | - )); |
|
42 | + public static function getAvoidanceZone($territory_id) |
|
43 | + { |
|
44 | + $avoidanceZone = Route4Me::makeRequst(array( |
|
45 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
46 | + 'method' => 'GET', |
|
47 | + 'query' => array( |
|
48 | + 'territory_id' => $territory_id |
|
49 | + ) |
|
50 | + )); |
|
51 | 51 | |
52 | - return $avoidanceZone; |
|
53 | - } |
|
52 | + return $avoidanceZone; |
|
53 | + } |
|
54 | 54 | |
55 | - public static function getAvoidanceZones($params) |
|
56 | - { |
|
57 | - $avoidanceZones = Route4Me::makeRequst(array( |
|
58 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
59 | - 'method' => 'GET', |
|
60 | - 'query' => array( |
|
61 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
62 | - 'limit' => isset($params->limit) ? $params->limit : null, |
|
63 | - ) |
|
64 | - )); |
|
55 | + public static function getAvoidanceZones($params) |
|
56 | + { |
|
57 | + $avoidanceZones = Route4Me::makeRequst(array( |
|
58 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
59 | + 'method' => 'GET', |
|
60 | + 'query' => array( |
|
61 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
62 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
63 | + ) |
|
64 | + )); |
|
65 | 65 | |
66 | - return $avoidanceZones; |
|
67 | - } |
|
66 | + return $avoidanceZones; |
|
67 | + } |
|
68 | 68 | |
69 | - public static function addAvoidanceZone($params) |
|
70 | - { |
|
71 | - $terParams = array(); |
|
69 | + public static function addAvoidanceZone($params) |
|
70 | + { |
|
71 | + $terParams = array(); |
|
72 | 72 | |
73 | - if (isset($params->territory['type'])) { |
|
74 | - $terParams['type'] = $params->territory['type']; |
|
75 | - } |
|
73 | + if (isset($params->territory['type'])) { |
|
74 | + $terParams['type'] = $params->territory['type']; |
|
75 | + } |
|
76 | 76 | |
77 | - if (isset($params->territory['data'])) { |
|
78 | - $terParams['data'] = $params->territory['data']; |
|
79 | - } |
|
77 | + if (isset($params->territory['data'])) { |
|
78 | + $terParams['data'] = $params->territory['data']; |
|
79 | + } |
|
80 | 80 | |
81 | - $abContacts = Route4Me::makeRequst(array( |
|
82 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
83 | - 'method' => 'POST', |
|
84 | - 'body' => array( |
|
85 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
86 | - 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
87 | - 'territory' => $terParams |
|
88 | - ) |
|
89 | - )); |
|
81 | + $abContacts = Route4Me::makeRequst(array( |
|
82 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
83 | + 'method' => 'POST', |
|
84 | + 'body' => array( |
|
85 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
86 | + 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
87 | + 'territory' => $terParams |
|
88 | + ) |
|
89 | + )); |
|
90 | 90 | |
91 | - return $abContacts; |
|
92 | - } |
|
91 | + return $abContacts; |
|
92 | + } |
|
93 | 93 | |
94 | - public function deleteAvoidanceZone($territory_id) |
|
95 | - { |
|
96 | - $result = Route4Me::makeRequst(array( |
|
97 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
98 | - 'method' => 'DELETEARRAY', |
|
99 | - 'query' => array( |
|
100 | - 'territory_id' => $territory_id |
|
101 | - ) |
|
102 | - )); |
|
94 | + public function deleteAvoidanceZone($territory_id) |
|
95 | + { |
|
96 | + $result = Route4Me::makeRequst(array( |
|
97 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
98 | + 'method' => 'DELETEARRAY', |
|
99 | + 'query' => array( |
|
100 | + 'territory_id' => $territory_id |
|
101 | + ) |
|
102 | + )); |
|
103 | 103 | |
104 | - return $result; |
|
105 | - } |
|
104 | + return $result; |
|
105 | + } |
|
106 | 106 | |
107 | - public function updateAvoidanceZone($params) |
|
108 | - { |
|
109 | - $avoidanceZone = Route4Me::makeRequst(array( |
|
110 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
111 | - 'method' => 'PUT', |
|
112 | - 'body' => $params, |
|
113 | - )); |
|
107 | + public function updateAvoidanceZone($params) |
|
108 | + { |
|
109 | + $avoidanceZone = Route4Me::makeRequst(array( |
|
110 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
111 | + 'method' => 'PUT', |
|
112 | + 'body' => $params, |
|
113 | + )); |
|
114 | 114 | |
115 | - return $avoidanceZone; |
|
116 | - } |
|
115 | + return $avoidanceZone; |
|
116 | + } |
|
117 | 117 | } |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | - "route_name" => "Multiple Depot, Multiple Driver with 24 Stops, Time Window", |
|
35 | - "route_date" => time() + 24*60*60, |
|
36 | - "route_time" => 60 * 60 * 7, |
|
37 | - "distance_unit" => DistanceUnit::MILES, |
|
38 | - "device_type" => DeviceType::WEB, |
|
39 | - "optimize" => OptimizationType::DISTANCE, |
|
40 | - "metric" => Metric::GEODESIC, |
|
41 | - "route_max_duration" => 86400, |
|
42 | - "travel_mode" => TravelMode::DRIVING, |
|
43 | - "vehicle_capacity" => 1, |
|
44 | - "vehicle_max_distance_mi" => 10000 |
|
33 | + "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | + "route_name" => "Multiple Depot, Multiple Driver with 24 Stops, Time Window", |
|
35 | + "route_date" => time() + 24*60*60, |
|
36 | + "route_time" => 60 * 60 * 7, |
|
37 | + "distance_unit" => DistanceUnit::MILES, |
|
38 | + "device_type" => DeviceType::WEB, |
|
39 | + "optimize" => OptimizationType::DISTANCE, |
|
40 | + "metric" => Metric::GEODESIC, |
|
41 | + "route_max_duration" => 86400, |
|
42 | + "travel_mode" => TravelMode::DRIVING, |
|
43 | + "vehicle_capacity" => 1, |
|
44 | + "vehicle_max_distance_mi" => 10000 |
|
45 | 45 | )); |
46 | 46 | |
47 | 47 | $optimizationParams = new OptimizationProblemParams; |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | $problem = OptimizationProblem::optimize($optimizationParams); |
52 | 52 | |
53 | 53 | foreach ((array)$problem as $key => $value) { |
54 | - if (is_string($value)) { |
|
55 | - echo $key." --> ".$value."<br>"; |
|
56 | - } else { |
|
57 | - echo "************ $key ************* <br>"; |
|
58 | - Route4Me::simplePrint((array)$value, true); |
|
59 | - echo "******************************* <br>"; |
|
60 | - } |
|
54 | + if (is_string($value)) { |
|
55 | + echo $key." --> ".$value."<br>"; |
|
56 | + } else { |
|
57 | + echo "************ $key ************* <br>"; |
|
58 | + Route4Me::simplePrint((array)$value, true); |
|
59 | + echo "******************************* <br>"; |
|
60 | + } |
|
61 | 61 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | 33 | "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
34 | 34 | "route_name" => "Multiple Depot, Multiple Driver with 24 Stops, Time Window", |
35 | - "route_date" => time() + 24*60*60, |
|
35 | + "route_date" => time() + 24 * 60 * 60, |
|
36 | 36 | "route_time" => 60 * 60 * 7, |
37 | 37 | "distance_unit" => DistanceUnit::MILES, |
38 | 38 | "device_type" => DeviceType::WEB, |
@@ -26,18 +26,18 @@ |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => AlgorithmType::TSP, |
|
34 | - "distance_unit" => DistanceUnit::MILES, |
|
35 | - "device_type" => DeviceType::WEB, |
|
36 | - "optimize" => OptimizationType::DISTANCE, |
|
37 | - "travel_mode" => TravelMode::DRIVING, |
|
38 | - "route_max_duration" => 86400, |
|
39 | - "vehicle_capacity" => 1, |
|
40 | - "vehicle_max_distance_mi" => 10000 |
|
33 | + "algorithm_type" => AlgorithmType::TSP, |
|
34 | + "distance_unit" => DistanceUnit::MILES, |
|
35 | + "device_type" => DeviceType::WEB, |
|
36 | + "optimize" => OptimizationType::DISTANCE, |
|
37 | + "travel_mode" => TravelMode::DRIVING, |
|
38 | + "route_max_duration" => 86400, |
|
39 | + "vehicle_capacity" => 1, |
|
40 | + "vehicle_max_distance_mi" => 10000 |
|
41 | 41 | )); |
42 | 42 | |
43 | 43 | $optimizationParams = new OptimizationProblemParams; |