@@ -30,7 +30,7 @@ |
||
| 30 | 30 | $route->parameters = new \stdClass(); |
| 31 | 31 | |
| 32 | 32 | $route->parameters = array( |
| 33 | - "recompute_directions" => 1 |
|
| 33 | + "recompute_directions" => 1 |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | 36 | $route->httpheaders = 'Content-type: application/json'; |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | |
| 22 | 22 | // Resequence all addresses |
| 23 | 23 | $params = array( |
| 24 | - "route_id" => $route_id, |
|
| 25 | - "disable_optimization" => 0, |
|
| 26 | - "optimize" => "Distance" |
|
| 24 | + "route_id" => $route_id, |
|
| 25 | + "disable_optimization" => 0, |
|
| 26 | + "optimize" => "Distance" |
|
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | $resequence = $route->resequenceAllAddresses($params); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | echo "Random route ID 1 -> $randomRouteID1 <br> Random route ID 2 -> $randomRouteID2 <br>"; |
| 26 | 26 | |
| 27 | 27 | // Remove selected routes |
| 28 | -$route_ids = join(',',array($randomRouteID1,$randomRouteID2)); |
|
| 28 | +$route_ids = join(',', array($randomRouteID1, $randomRouteID2)); |
|
| 29 | 29 | |
| 30 | 30 | $result = $route->delete($route_ids); |
| 31 | 31 | |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | $count = 0; |
| 26 | 26 | |
| 27 | 27 | while ($route_id1 == $route_id2) { |
| 28 | - $route_id2 = $route->getRandomRouteId(0, 20); |
|
| 28 | + $route_id2 = $route->getRandomRouteId(0, 20); |
|
| 29 | 29 | |
| 30 | - $count++; |
|
| 30 | + $count++; |
|
| 31 | 31 | |
| 32 | - if ($count>5) break; // prevent from the infinite cycle, if there are less than 2 routes. |
|
| 32 | + if ($count>5) break; // prevent from the infinite cycle, if there are less than 2 routes. |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | echo "Route ID 1 -> $route_id1 <br> Route ID 2 -> $route_id2 <br>"; |
@@ -41,21 +41,21 @@ discard block |
||
| 41 | 41 | $depot = null; |
| 42 | 42 | |
| 43 | 43 | foreach ($addresses as $address) { |
| 44 | - if (isset($address->is_depot)) { |
|
| 45 | - if ($address->is_depot == true) { |
|
| 46 | - $depot = $address; |
|
| 47 | - break; |
|
| 48 | - } |
|
| 49 | - } |
|
| 44 | + if (isset($address->is_depot)) { |
|
| 45 | + if ($address->is_depot == true) { |
|
| 46 | + $depot = $address; |
|
| 47 | + break; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Merge the selected routes |
| 53 | 53 | $params = array( |
| 54 | - "route_ids" => $route_id1.",".$route_id2, |
|
| 55 | - "depot_address" => $depot->address, |
|
| 56 | - "remove_origin" => false, |
|
| 57 | - "depot_lat" => $depot->lat, |
|
| 58 | - "depot_lat" => $depot->lng |
|
| 54 | + "route_ids" => $route_id1.",".$route_id2, |
|
| 55 | + "depot_address" => $depot->address, |
|
| 56 | + "remove_origin" => false, |
|
| 57 | + "depot_lat" => $depot->lat, |
|
| 58 | + "depot_lat" => $depot->lng |
|
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | $result = $route->mergeRoutes($params); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $count = 0; |
| 26 | 26 | |
| 27 | -while ($route_id1 == $route_id2) { |
|
| 27 | +while ($route_id1==$route_id2) { |
|
| 28 | 28 | $route_id2 = $route->getRandomRouteId(0, 20); |
| 29 | 29 | |
| 30 | 30 | $count++; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | foreach ($addresses as $address) { |
| 44 | 44 | if (isset($address->is_depot)) { |
| 45 | - if ($address->is_depot == true) { |
|
| 45 | + if ($address->is_depot==true) { |
|
| 46 | 46 | $depot = $address; |
| 47 | 47 | break; |
| 48 | 48 | } |
@@ -29,7 +29,10 @@ |
||
| 29 | 29 | |
| 30 | 30 | $count++; |
| 31 | 31 | |
| 32 | - if ($count>5) break; // prevent from the infinite cycle, if there are less than 2 routes. |
|
| 32 | + if ($count>5) { |
|
| 33 | + break; |
|
| 34 | + } |
|
| 35 | + // prevent from the infinite cycle, if there are less than 2 routes. |
|
| 33 | 36 | } |
| 34 | 37 | |
| 35 | 38 | echo "Route ID 1 -> $route_id1 <br> Route ID 2 -> $route_id2 <br>"; |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | Route4Me::setApiKey('11111111111111111111111111111111'); |
| 12 | 12 | |
| 13 | 13 | $RouteParameters = array( |
| 14 | - "limit" => 30, |
|
| 15 | - "offset" => 0 |
|
| 14 | + "limit" => 30, |
|
| 15 | + "offset" => 0 |
|
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | 18 | $route = new Route(); |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | foreach ($routeResults as $routeResult) |
| 23 | 23 | { |
| 24 | - $results = (array)$routeResult; |
|
| 24 | + $results = (array)$routeResult; |
|
| 25 | 25 | |
| 26 | - Route4Me::simplePrint($results); |
|
| 26 | + Route4Me::simplePrint($results); |
|
| 27 | 27 | |
| 28 | - echo "<br>"; |
|
| 28 | + echo "<br>"; |
|
| 29 | 29 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | $route = new Route(); |
| 19 | 19 | |
| 20 | -$routeResults = $route->getRoutes(null,$RouteParameters); |
|
| 20 | +$routeResults = $route->getRoutes(null, $RouteParameters); |
|
| 21 | 21 | |
| 22 | 22 | foreach ($routeResults as $routeResult) |
| 23 | 23 | { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -20,6 +20,6 @@ discard block |
||
| 20 | 20 | assert(!is_null($route_id), "Can't retrieve a random route ID"); |
| 21 | 21 | |
| 22 | 22 | // get a route by ID |
| 23 | -$routeResults = (array)$route->getRoutes($route_id,null); |
|
| 23 | +$routeResults = (array)$route->getRoutes($route_id, null); |
|
| 24 | 24 | |
| 25 | 25 | Route4Me::simplePrint($routeResults); |
@@ -23,22 +23,22 @@ |
||
| 23 | 23 | |
| 24 | 24 | // Get a route with the path points |
| 25 | 25 | $params = array( |
| 26 | - "route_path_output" => "Points" |
|
| 26 | + "route_path_output" => "Points" |
|
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | $routeResults = (array)$route->getRoutePoints($route_id,$params); |
| 30 | 30 | |
| 31 | 31 | if (isset($routeResults['addresses'])) { |
| 32 | - foreach ($routeResults['addresses'] as $key => $address) { |
|
| 33 | - $araddress = (array)$address; |
|
| 32 | + foreach ($routeResults['addresses'] as $key => $address) { |
|
| 33 | + $araddress = (array)$address; |
|
| 34 | 34 | |
| 35 | - if (isset($araddress['route_destination_id'])) echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
| 35 | + if (isset($araddress['route_destination_id'])) echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
| 36 | 36 | |
| 37 | - if (isset($araddress['path_to_next'])) { |
|
| 38 | - echo "path_to_next:<br>"; |
|
| 39 | - Route4Me::simplePrint($araddress['path_to_next']); |
|
| 40 | - } |
|
| 37 | + if (isset($araddress['path_to_next'])) { |
|
| 38 | + echo "path_to_next:<br>"; |
|
| 39 | + Route4Me::simplePrint($araddress['path_to_next']); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - echo "<br>"; |
|
| 43 | - } |
|
| 42 | + echo "<br>"; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | "route_path_output" => "Points" |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | -$routeResults = (array)$route->getRoutePoints($route_id,$params); |
|
| 29 | +$routeResults = (array)$route->getRoutePoints($route_id, $params); |
|
| 30 | 30 | |
| 31 | 31 | if (isset($routeResults['addresses'])) { |
| 32 | 32 | foreach ($routeResults['addresses'] as $key => $address) { |
@@ -32,7 +32,9 @@ |
||
| 32 | 32 | foreach ($routeResults['addresses'] as $key => $address) { |
| 33 | 33 | $araddress = (array)$address; |
| 34 | 34 | |
| 35 | - if (isset($araddress['route_destination_id'])) echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
| 35 | + if (isset($araddress['route_destination_id'])) { |
|
| 36 | + echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | if (isset($araddress['path_to_next'])) { |
| 38 | 40 | echo "path_to_next:<br>"; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | // The example refers to the process of searching for the specified text throughout all routes, belonging to the user's account. |
| 14 | 14 | |
| 15 | 15 | $RouteParameters = array( |
| 16 | - "query" => 'Automated' |
|
| 16 | + "query" => 'Automated' |
|
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | 19 | $route = new Route(); |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | foreach ($routeResults as $routeResult) |
| 24 | 24 | { |
| 25 | - $results = (array)$routeResult; |
|
| 25 | + $results = (array)$routeResult; |
|
| 26 | 26 | |
| 27 | - if (isset($results['route_id'])) echo "Route ID - > " . $results['route_id'] . "<br>"; |
|
| 27 | + if (isset($results['route_id'])) echo "Route ID - > " . $results['route_id'] . "<br>"; |
|
| 28 | 28 | |
| 29 | - if (isset($results['parameters']->route_name)) echo "Route name - > " . $results['parameters']->route_name . "<br>"; |
|
| 29 | + if (isset($results['parameters']->route_name)) echo "Route name - > " . $results['parameters']->route_name . "<br>"; |
|
| 30 | 30 | |
| 31 | - echo "<br>"; |
|
| 31 | + echo "<br>"; |
|
| 32 | 32 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -18,15 +18,15 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | $route = new Route(); |
| 20 | 20 | |
| 21 | -$routeResults = $route->getRoutes(null,$RouteParameters); |
|
| 21 | +$routeResults = $route->getRoutes(null, $RouteParameters); |
|
| 22 | 22 | |
| 23 | 23 | foreach ($routeResults as $routeResult) |
| 24 | 24 | { |
| 25 | 25 | $results = (array)$routeResult; |
| 26 | 26 | |
| 27 | - if (isset($results['route_id'])) echo "Route ID - > " . $results['route_id'] . "<br>"; |
|
| 27 | + if (isset($results['route_id'])) echo "Route ID - > ".$results['route_id']."<br>"; |
|
| 28 | 28 | |
| 29 | - if (isset($results['parameters']->route_name)) echo "Route name - > " . $results['parameters']->route_name . "<br>"; |
|
| 29 | + if (isset($results['parameters']->route_name)) echo "Route name - > ".$results['parameters']->route_name."<br>"; |
|
| 30 | 30 | |
| 31 | 31 | echo "<br>"; |
| 32 | 32 | } |
@@ -24,9 +24,13 @@ |
||
| 24 | 24 | { |
| 25 | 25 | $results = (array)$routeResult; |
| 26 | 26 | |
| 27 | - if (isset($results['route_id'])) echo "Route ID - > " . $results['route_id'] . "<br>"; |
|
| 27 | + if (isset($results['route_id'])) { |
|
| 28 | + echo "Route ID - > " . $results['route_id'] . "<br>"; |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | - if (isset($results['parameters']->route_name)) echo "Route name - > " . $results['parameters']->route_name . "<br>"; |
|
| 31 | + if (isset($results['parameters']->route_name)) { |
|
| 32 | + echo "Route name - > " . $results['parameters']->route_name . "<br>"; |
|
| 33 | + } |
|
| 30 | 34 | |
| 31 | 35 | echo "<br>"; |
| 32 | 36 | } |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | // Select a route with more than 4 addresses. |
| 20 | 20 | $routesParams = array( |
| 21 | - "offset" => 0, |
|
| 22 | - "limit" => 20 |
|
| 21 | + "offset" => 0, |
|
| 22 | + "limit" => 20 |
|
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | 25 | $routes = $route->getRoutes(null,$routesParams); |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | $selectedRoute = null; |
| 28 | 28 | |
| 29 | 29 | foreach ($routes as $route1) { |
| 30 | - if (isset($route1->destination_count)) { |
|
| 31 | - if ($route1->destination_count>4) { |
|
| 32 | - $selectedRoute = $route->getRoutes($route1->route_id); |
|
| 33 | - break; |
|
| 34 | - } |
|
| 35 | - } |
|
| 30 | + if (isset($route1->destination_count)) { |
|
| 31 | + if ($route1->destination_count>4) { |
|
| 32 | + $selectedRoute = $route->getRoutes($route1->route_id); |
|
| 33 | + break; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | assert(!is_null($selectedRoute), "Can't select a route with more than 4 addresses"); |
@@ -44,19 +44,19 @@ discard block |
||
| 44 | 44 | echo "Route ID-> $routeID, Route destination ID -> $routeDestinationID <br>"; |
| 45 | 45 | |
| 46 | 46 | $params = array( |
| 47 | - "route_id" => $routeID, |
|
| 48 | - "route_destination_id" => $routeDestinationID, |
|
| 49 | - "addresses" => array( |
|
| 50 | - "0" => array( |
|
| 51 | - "route_destination_id" => $routeDestinationID, |
|
| 52 | - "sequence_no" => 3 |
|
| 53 | - ) |
|
| 54 | - ) |
|
| 47 | + "route_id" => $routeID, |
|
| 48 | + "route_destination_id" => $routeDestinationID, |
|
| 49 | + "addresses" => array( |
|
| 50 | + "0" => array( |
|
| 51 | + "route_destination_id" => $routeDestinationID, |
|
| 52 | + "sequence_no" => 3 |
|
| 53 | + ) |
|
| 54 | + ) |
|
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | $response = $route->resequenceRoute($params); |
| 58 | 58 | |
| 59 | 59 | foreach ($response['addresses'] as $address) { |
| 60 | - Route4Me::simplePrint($address); |
|
| 61 | - echo "<br>"; |
|
| 60 | + Route4Me::simplePrint($address); |
|
| 61 | + echo "<br>"; |
|
| 62 | 62 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
| 4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
| 5 | 5 | require $root.'/vendor/autoload.php'; |
| 6 | 6 | |
| 7 | 7 | use Route4Me\Route4Me; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | "limit" => 20 |
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | -$routes = $route->getRoutes(null,$routesParams); |
|
| 25 | +$routes = $route->getRoutes(null, $routesParams); |
|
| 26 | 26 | |
| 27 | 27 | $selectedRoute = null; |
| 28 | 28 | |