@@ -9,10 +9,10 @@ |
||
9 | 9 | Route4Me::setApiKey(Constants::API_KEY); |
10 | 10 | |
11 | 11 | $AddressBookLocationParameters = AddressBookLocation::fromArray([ |
12 | - 'first_name' => 'Test FirstName '.strval(rand(10000, 99999)), |
|
13 | - 'address_1' => 'Test Address1 '.strval(rand(10000, 99999)), |
|
14 | - 'cached_lat' => 38.024654, |
|
15 | - 'cached_lng' => -77.338814, |
|
12 | + 'first_name' => 'Test FirstName '.strval(rand(10000, 99999)), |
|
13 | + 'address_1' => 'Test Address1 '.strval(rand(10000, 99999)), |
|
14 | + 'cached_lat' => 38.024654, |
|
15 | + 'cached_lng' => -77.338814, |
|
16 | 16 | ]); |
17 | 17 | |
18 | 18 | $abContacts = new AddressBookLocation(); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | Route4Me::setApiKey(Constants::API_KEY); |
13 | 13 | |
14 | 14 | $AddressBookLocationParameters = AddressBookLocation::fromArray([ |
15 | - 'first_name' => 'Test FirstName '.strval(rand(10000, 99999)), |
|
16 | - 'address_1' => 'Test Address1 '.strval(rand(10000, 99999)), |
|
17 | - 'cached_lat' => 38.024654, |
|
18 | - 'cached_lng' => -77.338814, |
|
15 | + 'first_name' => 'Test FirstName '.strval(rand(10000, 99999)), |
|
16 | + 'address_1' => 'Test Address1 '.strval(rand(10000, 99999)), |
|
17 | + 'cached_lat' => 38.024654, |
|
18 | + 'cached_lng' => -77.338814, |
|
19 | 19 | ]); |
20 | 20 | |
21 | 21 | $abContacts = new AddressBookLocation(); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $address_id = -1; |
26 | 26 | |
27 | 27 | if (isset($createdContact['address_id'])) { |
28 | - $address_id = $createdContact['address_id']; |
|
28 | + $address_id = $createdContact['address_id']; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | assert($address_id != -1, 'Creating of Address Book Location was failed. Try again!.. <br>'); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $address_id = $createdContact['address_id']; |
29 | 29 | } |
30 | 30 | |
31 | -assert($address_id != -1, 'Creating of Address Book Location was failed. Try again!.. <br>'); |
|
31 | +assert($address_id!=-1, 'Creating of Address Book Location was failed. Try again!.. <br>'); |
|
32 | 32 | |
33 | 33 | echo 'Address Book Location with address_id = '.strval($address_id).' was successfully added<br>'; |
34 | 34 |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | Route4Me::setApiKey(Constants::API_KEY); |
13 | 13 | |
14 | 14 | $AddressBookLocationParameters = AddressBookLocation::fromArray([ |
15 | - 'first_name' => 'Test FirstName '.strval(rand(10000, 99999)), |
|
16 | - 'address_1' => 'Test Address1 '.strval(rand(10000, 99999)), |
|
17 | - 'cached_lat' => 38.024654, |
|
18 | - 'cached_lng' => -77.338814, |
|
15 | + 'first_name' => 'Test FirstName '.strval(rand(10000, 99999)), |
|
16 | + 'address_1' => 'Test Address1 '.strval(rand(10000, 99999)), |
|
17 | + 'cached_lat' => 38.024654, |
|
18 | + 'cached_lng' => -77.338814, |
|
19 | 19 | ]); |
20 | 20 | |
21 | 21 | $abLocation = new AddressBookLocation(); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | assert(isset($abcResult['address_id']), 'Cannot create an address book location. <br><br>'); |
28 | 28 | |
29 | 29 | if (isset($abcResult['address_id'])) { |
30 | - $address_id = $abcResult['address_id']; |
|
30 | + $address_id = $abcResult['address_id']; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | assert($address_id != -1, 'Cannot create an address book location. <br><br>'); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $address_id = $abcResult['address_id']; |
31 | 31 | } |
32 | 32 | |
33 | -assert($address_id != -1, 'Cannot create an address book location. <br><br>'); |
|
33 | +assert($address_id!=-1, 'Cannot create an address book location. <br><br>'); |
|
34 | 34 | |
35 | 35 | echo 'Address Book Location with <b>address_id = '.strval($address_id).'</b> and <b>first_name = '.$abcResult['first_name'].'</b> was successfully added<br>'; |
36 | 36 | |
@@ -40,6 +40,6 @@ discard block |
||
40 | 40 | |
41 | 41 | assert(isset($abcResult['first_name']), 'Cannot update the address book location. <br><br>'); |
42 | 42 | |
43 | -assert('Test First Name Updated' == $abcResult['first_name'], 'Cannot update the address book location. <br><br>'); |
|
43 | +assert('Test First Name Updated'==$abcResult['first_name'], 'Cannot update the address book location. <br><br>'); |
|
44 | 44 | |
45 | 45 | echo 'The field <b>first_name</b> in the address book location <b>'.$address_id.'</b> was update to <b>Test First Name Updated</b> successfuly <br>'; |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | // Example refers to getting the address book locations |
12 | 12 | |
13 | 13 | $AddressBookLocationParameters = [ |
14 | - 'limit' => 30, |
|
15 | - 'offset' => 0, |
|
14 | + 'limit' => 30, |
|
15 | + 'offset' => 0, |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | $abContacts = new AddressBookLocation(); |
@@ -22,6 +22,6 @@ discard block |
||
22 | 22 | $results = $abContacts->getValue($abcResults, 'results'); |
23 | 23 | |
24 | 24 | foreach ($results as $result) { |
25 | - Route4Me::simplePrint($result); |
|
26 | - echo '<br>'; |
|
25 | + Route4Me::simplePrint($result); |
|
26 | + echo '<br>'; |
|
27 | 27 | } |
@@ -16,9 +16,9 @@ |
||
16 | 16 | // Example refers to the process of searching for the routed locations |
17 | 17 | |
18 | 18 | $params = [ |
19 | - 'offset' => 0, |
|
20 | - 'limit' => 5, |
|
21 | - 'display' => 'routed', |
|
19 | + 'offset' => 0, |
|
20 | + 'limit' => 5, |
|
21 | + 'display' => 'routed', |
|
22 | 22 | ]; |
23 | 23 | |
24 | 24 | $abcResult = $abLocation->searchAddressBookLocations($params); |
@@ -16,10 +16,10 @@ |
||
16 | 16 | // Example refers to the process of searching for text and specifing returned fields. |
17 | 17 | |
18 | 18 | $params = [ |
19 | - 'query' => 'David', |
|
20 | - 'fields' => 'first_name,address_email', |
|
21 | - 'offset' => 0, |
|
22 | - 'limit' => 5, |
|
19 | + 'query' => 'David', |
|
20 | + 'fields' => 'first_name,address_email', |
|
21 | + 'offset' => 0, |
|
22 | + 'limit' => 5, |
|
23 | 23 | ]; |
24 | 24 | |
25 | 25 | $abcResult = $abLocation->searchAddressBookLocations($params); |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | // Get two random locations IDs |
12 | 12 | |
13 | 13 | $addressBookLocationParameters = [ |
14 | - 'limit' => 30, |
|
15 | - 'offset' => 0, |
|
14 | + 'limit' => 30, |
|
15 | + 'offset' => 0, |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | $abContacts = new AddressBookLocation(); |
@@ -36,6 +36,6 @@ discard block |
||
36 | 36 | $results = $abLocation->getValue($abcResult, 'results'); |
37 | 37 | |
38 | 38 | foreach ($results as $result) { |
39 | - Route4Me::simplePrint($result); |
|
40 | - echo '<br>'; |
|
39 | + Route4Me::simplePrint($result); |
|
40 | + echo '<br>'; |
|
41 | 41 | } |
@@ -13,10 +13,10 @@ |
||
13 | 13 | $abLocation = new AddressBookLocation(); |
14 | 14 | |
15 | 15 | $params = [ |
16 | - 'query' => 'Test', |
|
17 | - 'fields' => 'address_1,address_group,first_name,last_name', |
|
18 | - 'offset' => 0, |
|
19 | - 'limit' => 20, |
|
16 | + 'query' => 'Test', |
|
17 | + 'fields' => 'address_1,address_group,first_name,last_name', |
|
18 | + 'offset' => 0, |
|
19 | + 'limit' => 20, |
|
20 | 20 | ]; |
21 | 21 | |
22 | 22 | $abcResult = $abLocation->searchAddressBookLocations($params); |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | //********************************************************************** |
28 | 28 | // General Route Parameters |
29 | 29 | $parameters = RouteParameters::fromArray([ |
30 | - 'rt' => true, |
|
31 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
32 | - 'route_name' => 'Drivers Schedules - 3 Territories '.date('Y-m-d H:i:s', time()), |
|
33 | - 'distance_unit' => DistanceUnit::MILES, |
|
34 | - 'device_type' => DeviceType::WEB, |
|
35 | - 'optimize' => OptimizationType::DISTANCE, |
|
36 | - 'travel_mode' => TravelMode::DRIVING, |
|
37 | - 'parts' => 10, |
|
38 | - 'advanced_constraints' => [] |
|
30 | + 'rt' => true, |
|
31 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
32 | + 'route_name' => 'Drivers Schedules - 3 Territories '.date('Y-m-d H:i:s', time()), |
|
33 | + 'distance_unit' => DistanceUnit::MILES, |
|
34 | + 'device_type' => DeviceType::WEB, |
|
35 | + 'optimize' => OptimizationType::DISTANCE, |
|
36 | + 'travel_mode' => TravelMode::DRIVING, |
|
37 | + 'parts' => 10, |
|
38 | + 'advanced_constraints' => [] |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | //********************************************************************** |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | // Time Window Start: 8:00 am EST |
49 | 49 | // Time Window End: 11:00 am EST |
50 | 50 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
51 | - 'tags' => $zones[0], |
|
52 | - '$members_count' => 3, |
|
53 | - 'available_time_windows' => [[(8 + 5) * 3600 , (11 + 5) * 3600]] |
|
51 | + 'tags' => $zones[0], |
|
52 | + '$members_count' => 3, |
|
53 | + 'available_time_windows' => [[(8 + 5) * 3600 , (11 + 5) * 3600]] |
|
54 | 54 | ]); |
55 | 55 | |
56 | 56 | // Schedule 2 |
57 | 57 | // Time Window Start: 8:00 am EST |
58 | 58 | // Time Window End: 12:00 pm EST |
59 | 59 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
60 | - 'tags' => $zones[1], |
|
61 | - '$members_count' => 3, |
|
62 | - 'available_time_windows' => [[(8 + 5) * 3600 , (12 + 5) * 3600]] |
|
60 | + 'tags' => $zones[1], |
|
61 | + '$members_count' => 3, |
|
62 | + 'available_time_windows' => [[(8 + 5) * 3600 , (12 + 5) * 3600]] |
|
63 | 63 | ]); |
64 | 64 | |
65 | 65 | // Schedule 3 |
66 | 66 | // Time Window Start: 8:00 am EST |
67 | 67 | // Time Window End: 01:00 pm EST |
68 | 68 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
69 | - 'tags' => $zones[2], |
|
70 | - '$members_count' => 3, |
|
71 | - 'available_time_windows' => [[(8 + 5) * 3600 , (13 + 5) * 3600]] |
|
69 | + 'tags' => $zones[2], |
|
70 | + '$members_count' => 3, |
|
71 | + 'available_time_windows' => [[(8 + 5) * 3600 , (13 + 5) * 3600]] |
|
72 | 72 | ]); |
73 | 73 | |
74 | 74 | //********************************************************************** |
@@ -77,23 +77,23 @@ discard block |
||
77 | 77 | |
78 | 78 | // Depot |
79 | 79 | $addresses[] = Address::fromArray([ |
80 | - 'address' => 'DEPOT', |
|
81 | - 'is_depot' => true, |
|
82 | - 'lat' => 25.694341, |
|
83 | - 'lng' => -80.166036, |
|
84 | - 'time' => 0 |
|
80 | + 'address' => 'DEPOT', |
|
81 | + 'is_depot' => true, |
|
82 | + 'lat' => 25.694341, |
|
83 | + 'lng' => -80.166036, |
|
84 | + 'time' => 0 |
|
85 | 85 | ]); |
86 | 86 | |
87 | 87 | // Stops |
88 | 88 | foreach ($json as $address) { |
89 | - $addresses[] = Address::fromArray([ |
|
90 | - 'address' => $address['address'], |
|
91 | - 'is_depot' => false, |
|
92 | - 'lat' => $address['lat'], |
|
93 | - 'lng' => $address['lng'], |
|
94 | - 'time' => 300, |
|
95 | - 'tags' => $address['tags'] |
|
96 | - ]); |
|
89 | + $addresses[] = Address::fromArray([ |
|
90 | + 'address' => $address['address'], |
|
91 | + 'is_depot' => false, |
|
92 | + 'lat' => $address['lat'], |
|
93 | + 'lng' => $address['lng'], |
|
94 | + 'time' => 300, |
|
95 | + 'tags' => $address['tags'] |
|
96 | + ]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $optimizationParams = new OptimizationProblemParams(); |
@@ -108,6 +108,6 @@ discard block |
||
108 | 108 | echo "Routes:" . PHP_EOL; |
109 | 109 | foreach($problem->routes as $route) |
110 | 110 | { |
111 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
112 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
111 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
112 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
113 | 113 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
51 | 51 | 'tags' => $zones[0], |
52 | 52 | '$members_count' => 3, |
53 | - 'available_time_windows' => [[(8 + 5) * 3600 , (11 + 5) * 3600]] |
|
53 | + 'available_time_windows' => [[(8 + 5) * 3600, (11 + 5) * 3600]] |
|
54 | 54 | ]); |
55 | 55 | |
56 | 56 | // Schedule 2 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
60 | 60 | 'tags' => $zones[1], |
61 | 61 | '$members_count' => 3, |
62 | - 'available_time_windows' => [[(8 + 5) * 3600 , (12 + 5) * 3600]] |
|
62 | + 'available_time_windows' => [[(8 + 5) * 3600, (12 + 5) * 3600]] |
|
63 | 63 | ]); |
64 | 64 | |
65 | 65 | // Schedule 3 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
69 | 69 | 'tags' => $zones[2], |
70 | 70 | '$members_count' => 3, |
71 | - 'available_time_windows' => [[(8 + 5) * 3600 , (13 + 5) * 3600]] |
|
71 | + 'available_time_windows' => [[(8 + 5) * 3600, (13 + 5) * 3600]] |
|
72 | 72 | ]); |
73 | 73 | |
74 | 74 | //********************************************************************** |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | |
103 | 103 | $problem = OptimizationProblem::optimize($optimizationParams); |
104 | 104 | |
105 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
106 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
105 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
106 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
107 | 107 | |
108 | -echo "Routes:" . PHP_EOL; |
|
109 | -foreach($problem->routes as $route) |
|
108 | +echo "Routes:".PHP_EOL; |
|
109 | +foreach ($problem->routes as $route) |
|
110 | 110 | { |
111 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
112 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
111 | + echo "\tID: ".$route->route_id.PHP_EOL; |
|
112 | + echo "\tDistance: ".$route->trip_distance.PHP_EOL; |
|
113 | 113 | } |