@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | assert(!is_null($addresses), "Cannot retrieve a random route ID"); |
25 | 25 | |
26 | 26 | foreach ($addresses as $addr1) { |
27 | - if (!is_null($addr1->tracking_number)) { |
|
28 | - $trackingNumber = $addr1->tracking_number; |
|
29 | - break; |
|
30 | - } |
|
27 | + if (!is_null($addr1->tracking_number)) { |
|
28 | + $trackingNumber = $addr1->tracking_number; |
|
29 | + break; |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | assert(!is_null($trackingNumber), "Cannot select a tracking number"); |
34 | 34 | |
35 | 35 | $params = [ |
36 | - 'tracking' => $trackingNumber, |
|
36 | + 'tracking' => $trackingNumber, |
|
37 | 37 | ]; |
38 | 38 | |
39 | 39 | $route = new Route(); |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $result = $route->GetAssetTracking($params); |
42 | 42 | |
43 | 43 | foreach ($result as $key => $value) { |
44 | - if (is_array($value)) { |
|
45 | - Route4Me::simplePrint($value, true); |
|
46 | - } else { |
|
47 | - echo "$key => $value <br>"; |
|
48 | - } |
|
44 | + if (is_array($value)) { |
|
45 | + Route4Me::simplePrint($value, true); |
|
46 | + } else { |
|
47 | + echo "$key => $value <br>"; |
|
48 | + } |
|
49 | 49 | } |
@@ -27,16 +27,16 @@ |
||
27 | 27 | // Set GPS postion to the selected route |
28 | 28 | // Set right member_id corresponding to the API key |
29 | 29 | $params = TrackSetParams::fromArray([ |
30 | - 'format' => Format::CSV, |
|
31 | - 'route_id' => $routeId, |
|
32 | - 'member_id' => 1, |
|
33 | - 'course' => 1, |
|
34 | - 'speed' => 120, |
|
35 | - 'lat' => 41.8927521, |
|
36 | - 'lng' => -109.0803888, |
|
37 | - 'device_type' => 'android_phone', |
|
38 | - 'device_guid' => 'qweqweqwe', |
|
39 | - 'device_timestamp' => date('Y-m-d H:i:s', strtotime('-1 day')), |
|
30 | + 'format' => Format::CSV, |
|
31 | + 'route_id' => $routeId, |
|
32 | + 'member_id' => 1, |
|
33 | + 'course' => 1, |
|
34 | + 'speed' => 120, |
|
35 | + 'lat' => 41.8927521, |
|
36 | + 'lng' => -109.0803888, |
|
37 | + 'device_type' => 'android_phone', |
|
38 | + 'device_guid' => 'qweqweqwe', |
|
39 | + 'device_timestamp' => date('Y-m-d H:i:s', strtotime('-1 day')), |
|
40 | 40 | ]); |
41 | 41 | |
42 | 42 | $status = Track::set($params); |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | // Set GPS postion to the selected route |
28 | 28 | // Set right member_id corresponding to the API key |
29 | 29 | $params = TrackSetParams::fromArray([ |
30 | - 'format' => Format::SERIALIZED, |
|
31 | - 'route_id' => $routeId, |
|
32 | - 'member_id' => 1, |
|
33 | - 'course' => 1, |
|
34 | - 'speed' => 120, |
|
35 | - 'lat' => 41.8927521, |
|
36 | - 'lng' => -109.0803888, |
|
37 | - 'device_type' => 'android_phone', |
|
38 | - 'device_guid' => 'qweqweqwe', |
|
39 | - 'device_timestamp' => date('Y-m-d H:i:s', strtotime('-2 day')), |
|
30 | + 'format' => Format::SERIALIZED, |
|
31 | + 'route_id' => $routeId, |
|
32 | + 'member_id' => 1, |
|
33 | + 'course' => 1, |
|
34 | + 'speed' => 120, |
|
35 | + 'lat' => 41.8927521, |
|
36 | + 'lng' => -109.0803888, |
|
37 | + 'device_type' => 'android_phone', |
|
38 | + 'device_guid' => 'qweqweqwe', |
|
39 | + 'device_timestamp' => date('Y-m-d H:i:s', strtotime('-2 day')), |
|
40 | 40 | ]); |
41 | 41 | |
42 | 42 | $status = Track::set($params); |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | $endDate = time() + 1 * 24 * 3600; |
51 | 51 | |
52 | 52 | $params = [ |
53 | - 'route_id' => $routeId, |
|
54 | - 'format' => Format::JSON, |
|
55 | - 'time_period' => 'custom', |
|
56 | - 'start_date' => $startDate, |
|
57 | - 'end_date' => $endDate, |
|
53 | + 'route_id' => $routeId, |
|
54 | + 'format' => Format::JSON, |
|
55 | + 'time_period' => 'custom', |
|
56 | + 'start_date' => $startDate, |
|
57 | + 'end_date' => $endDate, |
|
58 | 58 | ]; |
59 | 59 | |
60 | 60 | $result = $route->GetTrackingHistoryFromTimeRange($params); |
61 | 61 | |
62 | 62 | foreach ($result as $key => $value) { |
63 | - if (is_array($value)) { |
|
64 | - Route4Me::simplePrint($value); |
|
65 | - } else { |
|
66 | - echo "$key => $value <br>"; |
|
67 | - } |
|
63 | + if (is_array($value)) { |
|
64 | + Route4Me::simplePrint($value); |
|
65 | + } else { |
|
66 | + echo "$key => $value <br>"; |
|
67 | + } |
|
68 | 68 | } |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | // Set GPS postion to the selected route |
28 | 28 | // Set right member_id corresponding to the API key |
29 | 29 | $params = TrackSetParams::fromArray([ |
30 | - 'format' => Format::SERIALIZED, |
|
31 | - 'route_id' => $routeId, |
|
32 | - 'member_id' => 105323, |
|
33 | - 'course' => 3, |
|
34 | - 'speed' => 100, |
|
35 | - 'lat' => 41.8927521, |
|
36 | - 'lng' => -109.0803888, |
|
37 | - 'device_type' => DeviceType::IPHONE, |
|
38 | - 'device_guid' => 'qweqweqwe', |
|
39 | - 'device_timestamp' => date('Y-m-d H:i:s'), |
|
30 | + 'format' => Format::SERIALIZED, |
|
31 | + 'route_id' => $routeId, |
|
32 | + 'member_id' => 105323, |
|
33 | + 'course' => 3, |
|
34 | + 'speed' => 100, |
|
35 | + 'lat' => 41.8927521, |
|
36 | + 'lng' => -109.0803888, |
|
37 | + 'device_type' => DeviceType::IPHONE, |
|
38 | + 'device_guid' => 'qweqweqwe', |
|
39 | + 'device_timestamp' => date('Y-m-d H:i:s'), |
|
40 | 40 | ]); |
41 | 41 | |
42 | 42 | $status = Track::set($params); |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | assert($status['status'], "Cannot send GPS position to the selected route"); |
47 | 47 | |
48 | 48 | if (!$status) { |
49 | - echo 'Setting of GPS position failed'; |
|
49 | + echo 'Setting of GPS position failed'; |
|
50 | 50 | |
51 | - return; |
|
51 | + return; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $params = [ |
55 | - 'route_id' => $routeId, |
|
56 | - 'device_tracking_history' => '1', |
|
55 | + 'route_id' => $routeId, |
|
56 | + 'device_tracking_history' => '1', |
|
57 | 57 | ]; |
58 | 58 | |
59 | 59 | $result = $route->GetLastLocation($params); |
60 | 60 | |
61 | 61 | if (isset($result->tracking_history)) { |
62 | - foreach ($result->tracking_history as $history) { |
|
63 | - echo 'Speed --> '.$history['s'].'<br>'; |
|
64 | - echo 'course --> '.$history['d'].'<br>'; |
|
65 | - echo 'Timestamp --> '.$history['ts_friendly'].'<br>'; |
|
66 | - echo 'Latitude --> '.$history['lt'].'<br>'; |
|
67 | - echo 'Longitude --> '.$history['lg'].'<br>'; |
|
68 | - echo '========================================<br><br>'; |
|
69 | - } |
|
62 | + foreach ($result->tracking_history as $history) { |
|
63 | + echo 'Speed --> '.$history['s'].'<br>'; |
|
64 | + echo 'course --> '.$history['d'].'<br>'; |
|
65 | + echo 'Timestamp --> '.$history['ts_friendly'].'<br>'; |
|
66 | + echo 'Latitude --> '.$history['lt'].'<br>'; |
|
67 | + echo 'Longitude --> '.$history['lg'].'<br>'; |
|
68 | + echo '========================================<br><br>'; |
|
69 | + } |
|
70 | 70 | } |
@@ -22,9 +22,9 @@ |
||
22 | 22 | $queriedUserLocations = $track->getUserLocations($email); |
23 | 23 | |
24 | 24 | foreach ($queriedUserLocations As $memberId => $userLocation) { |
25 | - echo $userLocation['member_data']['member_first_name'].' '.$userLocation['member_data']['member_last_name']." --> "; |
|
26 | - if (isset($userLocation['tracking']['position_lng'])) { |
|
27 | - echo "Longitude: ".$userLocation['tracking']['position_lng'].", Latitude: ".$userLocation['tracking']['position_lat']; |
|
28 | - } |
|
29 | - echo "<br>"; |
|
25 | + echo $userLocation['member_data']['member_first_name'].' '.$userLocation['member_data']['member_last_name']." --> "; |
|
26 | + if (isset($userLocation['tracking']['position_lng'])) { |
|
27 | + echo "Longitude: ".$userLocation['tracking']['position_lng'].", Latitude: ".$userLocation['tracking']['position_lat']; |
|
28 | + } |
|
29 | + echo "<br>"; |
|
30 | 30 | } |
@@ -25,25 +25,25 @@ discard block |
||
25 | 25 | $addresses = []; |
26 | 26 | |
27 | 27 | foreach ($json as $address) { |
28 | - $addresses[] = Address::fromArray($address); |
|
28 | + $addresses[] = Address::fromArray($address); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | //region Optimization With Duration Priority FineTuning |
32 | 32 | $parameters = RouteParameters::fromArray([ |
33 | - 'route_name' => 'Optimization With Duration Priority FineTuning. '.date('Y-m-d H:i'), |
|
34 | - 'algorithm_type' => AlgorithmType::CVRP_TW_SD, |
|
35 | - 'route_time' => 23200, |
|
36 | - 'optimize' => OptimizationType::TIME, |
|
37 | - 'device_type' => DeviceType::WEB, |
|
38 | - 'udu_distance_unit' => 'km', |
|
39 | - 'route_max_duration' => 86400, |
|
40 | - 'travel_mode' => TravelMode::DRIVING, |
|
41 | - 'vehicle_capacity' => 30, |
|
42 | - 'vehicle_max_distance_mi' => 10000, |
|
43 | - 'rt' => true, |
|
44 | - 'target_duration' => 100, |
|
45 | - 'target_distance' => 0, |
|
46 | - 'target_wait_by_tail_size' => 0 |
|
33 | + 'route_name' => 'Optimization With Duration Priority FineTuning. '.date('Y-m-d H:i'), |
|
34 | + 'algorithm_type' => AlgorithmType::CVRP_TW_SD, |
|
35 | + 'route_time' => 23200, |
|
36 | + 'optimize' => OptimizationType::TIME, |
|
37 | + 'device_type' => DeviceType::WEB, |
|
38 | + 'udu_distance_unit' => 'km', |
|
39 | + 'route_max_duration' => 86400, |
|
40 | + 'travel_mode' => TravelMode::DRIVING, |
|
41 | + 'vehicle_capacity' => 30, |
|
42 | + 'vehicle_max_distance_mi' => 10000, |
|
43 | + 'rt' => true, |
|
44 | + 'target_duration' => 100, |
|
45 | + 'target_distance' => 0, |
|
46 | + 'target_wait_by_tail_size' => 0 |
|
47 | 47 | |
48 | 48 | ]); |
49 | 49 | |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | |
72 | 72 | //region Optimization With Distance Priority FineTuning |
73 | 73 | $parameters = RouteParameters::fromArray([ |
74 | - 'route_name' => 'Optimization With Distance Priority FineTuning. '.date('Y-m-d H:i'), |
|
75 | - 'algorithm_type' => AlgorithmType::CVRP_TW_SD, |
|
76 | - 'route_time' => 23200, |
|
77 | - 'optimize' => OptimizationType::TIME, |
|
78 | - 'device_type' => DeviceType::WEB, |
|
79 | - 'udu_distance_unit' => 'km', |
|
80 | - 'route_max_duration' => 86400, |
|
81 | - 'travel_mode' => TravelMode::DRIVING, |
|
82 | - 'vehicle_capacity' => 30, |
|
83 | - 'vehicle_max_distance_mi' => 10000, |
|
84 | - 'rt' => true, |
|
85 | - 'target_duration' => 0, |
|
86 | - 'target_distance' => 100, |
|
87 | - 'target_wait_by_tail_size' => 0 |
|
74 | + 'route_name' => 'Optimization With Distance Priority FineTuning. '.date('Y-m-d H:i'), |
|
75 | + 'algorithm_type' => AlgorithmType::CVRP_TW_SD, |
|
76 | + 'route_time' => 23200, |
|
77 | + 'optimize' => OptimizationType::TIME, |
|
78 | + 'device_type' => DeviceType::WEB, |
|
79 | + 'udu_distance_unit' => 'km', |
|
80 | + 'route_max_duration' => 86400, |
|
81 | + 'travel_mode' => TravelMode::DRIVING, |
|
82 | + 'vehicle_capacity' => 30, |
|
83 | + 'vehicle_max_distance_mi' => 10000, |
|
84 | + 'rt' => true, |
|
85 | + 'target_duration' => 0, |
|
86 | + 'target_distance' => 100, |
|
87 | + 'target_wait_by_tail_size' => 0 |
|
88 | 88 | |
89 | 89 | ]); |
90 | 90 | |
@@ -112,20 +112,20 @@ discard block |
||
112 | 112 | |
113 | 113 | //region Optimization With TimeWaiting Priority FineTuning |
114 | 114 | $parameters = RouteParameters::fromArray([ |
115 | - 'route_name' => 'Optimization With WaitingTime Priority FineTuning. '.date('Y-m-d H:i'), |
|
116 | - 'algorithm_type' => AlgorithmType::CVRP_TW_SD, |
|
117 | - 'route_time' => 23200, |
|
118 | - 'optimize' => OptimizationType::TIME, |
|
119 | - 'device_type' => DeviceType::WEB, |
|
120 | - 'udu_distance_unit' => 'km', |
|
121 | - 'route_max_duration' => 86400, |
|
122 | - 'travel_mode' => TravelMode::DRIVING, |
|
123 | - 'vehicle_capacity' => 30, |
|
124 | - 'vehicle_max_distance_mi' => 10000, |
|
125 | - 'rt' => true, |
|
126 | - 'target_duration' => 0, |
|
127 | - 'target_distance' => 0, |
|
128 | - 'target_wait_by_tail_size' => 100 |
|
115 | + 'route_name' => 'Optimization With WaitingTime Priority FineTuning. '.date('Y-m-d H:i'), |
|
116 | + 'algorithm_type' => AlgorithmType::CVRP_TW_SD, |
|
117 | + 'route_time' => 23200, |
|
118 | + 'optimize' => OptimizationType::TIME, |
|
119 | + 'device_type' => DeviceType::WEB, |
|
120 | + 'udu_distance_unit' => 'km', |
|
121 | + 'route_max_duration' => 86400, |
|
122 | + 'travel_mode' => TravelMode::DRIVING, |
|
123 | + 'vehicle_capacity' => 30, |
|
124 | + 'vehicle_max_distance_mi' => 10000, |
|
125 | + 'rt' => true, |
|
126 | + 'target_duration' => 0, |
|
127 | + 'target_distance' => 0, |
|
128 | + 'target_wait_by_tail_size' => 100 |
|
129 | 129 | |
130 | 130 | ]); |
131 | 131 |
@@ -18,27 +18,27 @@ discard block |
||
18 | 18 | |
19 | 19 | $addresses = []; |
20 | 20 | foreach ($json as $address) { |
21 | - $addresses[] = Address::fromArray($address); |
|
21 | + $addresses[] = Address::fromArray($address); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | $parameters = RouteParameters::fromArray([ |
25 | - 'algorithm_type' => Algorithmtype::TSP, |
|
26 | - 'store_route' => false, |
|
27 | - 'route_name' => 'Single Driver Multiple TimeWindows 12 Stops', |
|
28 | - 'shared_publicly' => true, |
|
29 | - 'route_date' => time() + 24 * 60 * 60, |
|
30 | - 'route_time' => 5 * 3600 + 30 * 60, |
|
31 | - 'distance_unit' => DistanceUnit::MILES, |
|
32 | - 'device_type' => DeviceType::WEB, |
|
33 | - 'optimize' => OptimizationType::DISTANCE, |
|
25 | + 'algorithm_type' => Algorithmtype::TSP, |
|
26 | + 'store_route' => false, |
|
27 | + 'route_name' => 'Single Driver Multiple TimeWindows 12 Stops', |
|
28 | + 'shared_publicly' => true, |
|
29 | + 'route_date' => time() + 24 * 60 * 60, |
|
30 | + 'route_time' => 5 * 3600 + 30 * 60, |
|
31 | + 'distance_unit' => DistanceUnit::MILES, |
|
32 | + 'device_type' => DeviceType::WEB, |
|
33 | + 'optimize' => OptimizationType::DISTANCE, |
|
34 | 34 | ]); |
35 | 35 | |
36 | 36 | $optimizationParams = OptimizationProblemParams::fromArray([ |
37 | - 'addresses' => $addresses, |
|
38 | - 'parameters' => $parameters, |
|
39 | - 'optimized_callback_url' => @'https://requestb.in/1o6cgge1', |
|
40 | - 'show_directions' => true, |
|
41 | - 'redirect' => false, |
|
37 | + 'addresses' => $addresses, |
|
38 | + 'parameters' => $parameters, |
|
39 | + 'optimized_callback_url' => @'https://requestb.in/1o6cgge1', |
|
40 | + 'show_directions' => true, |
|
41 | + 'redirect' => false, |
|
42 | 42 | ]); |
43 | 43 | |
44 | 44 | $optimizationParams = new OptimizationProblemParams(); |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | $problem = OptimizationProblem::optimize($optimizationParams); |
49 | 49 | |
50 | 50 | foreach ((array) $problem as $key => $value) { |
51 | - if (is_string($value)) { |
|
52 | - echo $key.' --> '.$value.'<br>'; |
|
53 | - } else { |
|
54 | - echo "************ $key ************* <br>"; |
|
55 | - Route4Me::simplePrint((array) $value, true); |
|
56 | - echo '******************************* <br>'; |
|
57 | - } |
|
51 | + if (is_string($value)) { |
|
52 | + echo $key.' --> '.$value.'<br>'; |
|
53 | + } else { |
|
54 | + echo "************ $key ************* <br>"; |
|
55 | + Route4Me::simplePrint((array) $value, true); |
|
56 | + echo '******************************* <br>'; |
|
57 | + } |
|
58 | 58 | } |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | Route4Me::setApiKey(Constants::API_KEY); |
10 | 10 | |
11 | 11 | $routeParameters = [ |
12 | - 'limit' => 5, |
|
13 | - 'offset' => 0, |
|
12 | + 'limit' => 5, |
|
13 | + 'offset' => 0, |
|
14 | 14 | ]; |
15 | 15 | |
16 | 16 | $optimizationProblem = new OptimizationProblem(); |
@@ -18,5 +18,5 @@ discard block |
||
18 | 18 | $optimizations = $optimizationProblem->get($routeParameters); |
19 | 19 | |
20 | 20 | foreach ($optimizations as $optimization) { |
21 | - echo 'Optimization problem ID -> '.$optimization->optimization_problem_id.'<br>'; |
|
21 | + echo 'Optimization problem ID -> '.$optimization->optimization_problem_id.'<br>'; |
|
22 | 22 | } |
@@ -20,11 +20,11 @@ |
||
20 | 20 | |
21 | 21 | // Get an optimization problem |
22 | 22 | $optimizationProblemParams = [ |
23 | - 'optimization_problem_id' => $optimizationProblemId, |
|
23 | + 'optimization_problem_id' => $optimizationProblemId, |
|
24 | 24 | ]; |
25 | 25 | |
26 | 26 | $optimizationProblem = $optimization->get($optimizationProblemParams); |
27 | 27 | |
28 | 28 | foreach ((array) $optimizationProblem as $probParts) { |
29 | - Route4Me::simplePrint((array) $probParts); |
|
29 | + Route4Me::simplePrint((array) $probParts); |
|
30 | 30 | } |