@@ -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,124 +69,124 @@ 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 | + } |
|
| 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 | + } |
|
| 78 | 95 | |
| 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 | - } |
|
| 95 | - |
|
| 96 | - public function update() |
|
| 97 | - { |
|
| 98 | - $address = Route4Me::makeRequst(array( |
|
| 99 | - 'url' => self::$apiUrl, |
|
| 100 | - 'method' => 'PUT', |
|
| 101 | - 'body' => $this->toArray(), |
|
| 102 | - 'query' => array( |
|
| 103 | - 'route_id' => $this->route_id, |
|
| 104 | - 'route_destination_id' => $this->route_destination_id, |
|
| 105 | - ), |
|
| 106 | - )); |
|
| 107 | - |
|
| 108 | - return Address::fromArray($address); |
|
| 109 | - } |
|
| 96 | + public function update() |
|
| 97 | + { |
|
| 98 | + $address = Route4Me::makeRequst(array( |
|
| 99 | + 'url' => self::$apiUrl, |
|
| 100 | + 'method' => 'PUT', |
|
| 101 | + 'body' => $this->toArray(), |
|
| 102 | + 'query' => array( |
|
| 103 | + 'route_id' => $this->route_id, |
|
| 104 | + 'route_destination_id' => $this->route_destination_id, |
|
| 105 | + ), |
|
| 106 | + )); |
|
| 107 | + |
|
| 108 | + return Address::fromArray($address); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | public function markAddress($params, $body) |
| 112 | - { |
|
| 113 | - $result = Route4Me::makeRequst(array( |
|
| 114 | - 'url' => self::$apiUrl, |
|
| 115 | - 'method' => 'PUT', |
|
| 116 | - 'query' => array( |
|
| 117 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 118 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
| 119 | - ), |
|
| 120 | - 'body' => $body |
|
| 121 | - )); |
|
| 122 | - |
|
| 123 | - return $result; |
|
| 124 | - } |
|
| 112 | + { |
|
| 113 | + $result = Route4Me::makeRequst(array( |
|
| 114 | + 'url' => self::$apiUrl, |
|
| 115 | + 'method' => 'PUT', |
|
| 116 | + 'query' => array( |
|
| 117 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 118 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
| 119 | + ), |
|
| 120 | + 'body' => $body |
|
| 121 | + )); |
|
| 122 | + |
|
| 123 | + return $result; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | public function markAsDeparted($params) |
| 127 | 127 | { |
| 128 | 128 | $address = Route4Me::makeRequst(array( |
| 129 | - 'url' => self::$apiUrDeparted, |
|
| 130 | - 'method' => 'GET', |
|
| 131 | - 'query' => array( |
|
| 132 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 133 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 134 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
| 135 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 136 | - ), |
|
| 137 | - )); |
|
| 138 | - |
|
| 139 | - return $address; |
|
| 129 | + 'url' => self::$apiUrDeparted, |
|
| 130 | + 'method' => 'GET', |
|
| 131 | + 'query' => array( |
|
| 132 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 133 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 134 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
| 135 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 136 | + ), |
|
| 137 | + )); |
|
| 138 | + |
|
| 139 | + return $address; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function markAsVisited($params) |
| 143 | 143 | { |
| 144 | 144 | $address = Route4Me::makeRequst(array( |
| 145 | - 'url' => self::$apiUrVisited, |
|
| 146 | - 'method' => 'GET', |
|
| 147 | - 'query' => array( |
|
| 148 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 149 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 150 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
| 151 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 152 | - ), |
|
| 153 | - )); |
|
| 154 | - |
|
| 155 | - return $address; |
|
| 145 | + 'url' => self::$apiUrVisited, |
|
| 146 | + 'method' => 'GET', |
|
| 147 | + 'query' => array( |
|
| 148 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 149 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 150 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
| 151 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 152 | + ), |
|
| 153 | + )); |
|
| 154 | + |
|
| 155 | + return $address; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public function delete() |
|
| 159 | - { |
|
| 160 | - $address = Route4Me::makeRequst(array( |
|
| 161 | - 'url' => self::$apiUrl, |
|
| 162 | - 'method' => 'DELETE', |
|
| 163 | - 'query' => array( |
|
| 164 | - 'route_id' => $this->route_id, |
|
| 165 | - 'route_destination_id' => $this->route_destination_id, |
|
| 166 | - ) |
|
| 167 | - )); |
|
| 168 | - |
|
| 169 | - return (bool)$address['deleted']; |
|
| 170 | - } |
|
| 158 | + public function delete() |
|
| 159 | + { |
|
| 160 | + $address = Route4Me::makeRequst(array( |
|
| 161 | + 'url' => self::$apiUrl, |
|
| 162 | + 'method' => 'DELETE', |
|
| 163 | + 'query' => array( |
|
| 164 | + 'route_id' => $this->route_id, |
|
| 165 | + 'route_destination_id' => $this->route_destination_id, |
|
| 166 | + ) |
|
| 167 | + )); |
|
| 168 | + |
|
| 169 | + return (bool)$address['deleted']; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | public function MoveDestinationToRoute($params) |
| 173 | 173 | { |
| 174 | 174 | $result = Route4Me::makeRequst(array( |
| 175 | - 'url' => self::$apiUrlMove, |
|
| 176 | - 'method' => 'POST', |
|
| 177 | - 'query' => array( |
|
| 178 | - 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
| 179 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
| 180 | - 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
| 181 | - ) |
|
| 182 | - )); |
|
| 183 | - |
|
| 184 | - return $result; |
|
| 175 | + 'url' => self::$apiUrlMove, |
|
| 176 | + 'method' => 'POST', |
|
| 177 | + 'query' => array( |
|
| 178 | + 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
| 179 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
| 180 | + 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
| 181 | + ) |
|
| 182 | + )); |
|
| 183 | + |
|
| 184 | + return $result; |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - function getAddressId() |
|
| 189 | - { |
|
| 190 | - return $this->route_destination_id; |
|
| 191 | - } |
|
| 188 | + function getAddressId() |
|
| 189 | + { |
|
| 190 | + return $this->route_destination_id; |
|
| 191 | + } |
|
| 192 | 192 | } |
@@ -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 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | 'url' => self::$apiUrl, |
| 115 | 115 | 'method' => 'PUT', |
| 116 | 116 | 'query' => array( |
| 117 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 117 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 118 | 118 | 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
| 119 | 119 | ), |
| 120 | 120 | 'body' => $body |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | 'url' => self::$apiUrDeparted, |
| 130 | 130 | 'method' => 'GET', |
| 131 | 131 | 'query' => array( |
| 132 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 133 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 134 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
| 135 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 132 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 133 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
| 134 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed'] : null, |
|
| 135 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
| 136 | 136 | ), |
| 137 | 137 | )); |
| 138 | 138 | |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | 'url' => self::$apiUrVisited, |
| 146 | 146 | 'method' => 'GET', |
| 147 | 147 | 'query' => array( |
| 148 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
| 149 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
| 150 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
| 151 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
| 148 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 149 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
| 150 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null, |
|
| 151 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
| 152 | 152 | ), |
| 153 | 153 | )); |
| 154 | 154 | |
@@ -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 | |
@@ -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($address); |
|
| 59 | - } |
|
| 60 | - $problem->routes = $routes; |
|
| 61 | - } |
|
| 55 | + if (isset($params['routes'])) { |
|
| 56 | + $routes = array(); |
|
| 57 | + foreach ($params['routes'] as $route) { |
|
| 58 | + $routes[] = Route::fromArray($address); |
|
| 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 | } |
@@ -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 | } |
@@ -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 | { |
@@ -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,121 +22,121 @@ 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 | |
| 43 | 43 | public $dev_lat; |
| 44 | 44 | public $dev_lng; |
| 45 | 45 | |
| 46 | - public static function fromArray(array $params) |
|
| 47 | - { |
|
| 48 | - $route = new Route(); |
|
| 49 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
| 50 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 51 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
| 52 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
| 53 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
| 54 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
| 55 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
| 56 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
| 57 | - |
|
| 58 | - // Make RouteParameters |
|
| 59 | - if (isset($params['parameters'])) { |
|
| 60 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (isset($params['addresses'])) { |
|
| 64 | - $addresses = array(); |
|
| 65 | - foreach ($params['addresses'] as $address) { |
|
| 66 | - $addresses[] = Address::fromArray($address); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $route->addresses = $addresses; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $route->links = Common::getValue($params, 'links', array()); |
|
| 73 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
| 74 | - $route->path = Common::getValue($params, 'path', array()); |
|
| 75 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
| 76 | - |
|
| 77 | - return $route; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public static function getRoutes($routeId=null, $params=null) |
|
| 81 | - { |
|
| 82 | - $query = array( |
|
| 83 | - 'api_key' => Route4Me::getApiKey() |
|
| 84 | - ); |
|
| 85 | - |
|
| 86 | - if ($routeId) { |
|
| 87 | - $query['route_id'] = implode(',', (array) $routeId); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if ($params) { |
|
| 91 | - if (isset($params['directions'])) { |
|
| 92 | - $query['directions'] = $params['directions']; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if (isset($params['route_path_output'])) { |
|
| 96 | - $query['route_path_output'] = $params['route_path_output']; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if (isset($params['device_tracking_history'])) { |
|
| 100 | - $query['device_tracking_history'] = $params['device_tracking_history']; |
|
| 101 | - } |
|
| 46 | + public static function fromArray(array $params) |
|
| 47 | + { |
|
| 48 | + $route = new Route(); |
|
| 49 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
| 50 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 51 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
| 52 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
| 53 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
| 54 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
| 55 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
| 56 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
| 57 | + |
|
| 58 | + // Make RouteParameters |
|
| 59 | + if (isset($params['parameters'])) { |
|
| 60 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (isset($params['addresses'])) { |
|
| 64 | + $addresses = array(); |
|
| 65 | + foreach ($params['addresses'] as $address) { |
|
| 66 | + $addresses[] = Address::fromArray($address); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $route->addresses = $addresses; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $route->links = Common::getValue($params, 'links', array()); |
|
| 73 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
| 74 | + $route->path = Common::getValue($params, 'path', array()); |
|
| 75 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
| 76 | + |
|
| 77 | + return $route; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public static function getRoutes($routeId=null, $params=null) |
|
| 81 | + { |
|
| 82 | + $query = array( |
|
| 83 | + 'api_key' => Route4Me::getApiKey() |
|
| 84 | + ); |
|
| 85 | + |
|
| 86 | + if ($routeId) { |
|
| 87 | + $query['route_id'] = implode(',', (array) $routeId); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if ($params) { |
|
| 91 | + if (isset($params['directions'])) { |
|
| 92 | + $query['directions'] = $params['directions']; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if (isset($params['route_path_output'])) { |
|
| 96 | + $query['route_path_output'] = $params['route_path_output']; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if (isset($params['device_tracking_history'])) { |
|
| 100 | + $query['device_tracking_history'] = $params['device_tracking_history']; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | if (isset($params['query'])) { |
| 104 | - $query['query'] = $params['query']; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
| 108 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
| 109 | - } |
|
| 104 | + $query['query'] = $params['query']; |
|
| 105 | + } |
|
| 110 | 106 | |
| 111 | - $json = Route4Me::makeRequst(array( |
|
| 112 | - 'url' => self::$apiUrl, |
|
| 113 | - 'method' => 'GET', |
|
| 114 | - 'query' => $query |
|
| 115 | - )); |
|
| 107 | + $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
| 108 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
| 109 | + } |
|
| 116 | 110 | |
| 117 | - if ($routeId) { |
|
| 118 | - return Route::fromArray($json); die(""); |
|
| 119 | - } else { |
|
| 120 | - $routes = array(); |
|
| 121 | - foreach($json as $route) { |
|
| 122 | - $routes[] = Route::fromArray($route); |
|
| 123 | - } |
|
| 124 | - return $routes; |
|
| 125 | - } |
|
| 126 | - } |
|
| 111 | + $json = Route4Me::makeRequst(array( |
|
| 112 | + 'url' => self::$apiUrl, |
|
| 113 | + 'method' => 'GET', |
|
| 114 | + 'query' => $query |
|
| 115 | + )); |
|
| 116 | + |
|
| 117 | + if ($routeId) { |
|
| 118 | + return Route::fromArray($json); die(""); |
|
| 119 | + } else { |
|
| 120 | + $routes = array(); |
|
| 121 | + foreach($json as $route) { |
|
| 122 | + $routes[] = Route::fromArray($route); |
|
| 123 | + } |
|
| 124 | + return $routes; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | public function getRoutePoints($routeId, $params) |
| 129 | 129 | { |
| 130 | 130 | $result = Route4Me::makeRequst(array( |
| 131 | - 'url' => self::$apiUrl, |
|
| 132 | - 'method' => 'GET', |
|
| 133 | - 'query' => array( |
|
| 134 | - 'api_key' => Route4Me::getApiKey(), |
|
| 135 | - 'route_id' => $routeId, |
|
| 136 | - 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
| 137 | - 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
| 138 | - ) |
|
| 139 | - )); |
|
| 131 | + 'url' => self::$apiUrl, |
|
| 132 | + 'method' => 'GET', |
|
| 133 | + 'query' => array( |
|
| 134 | + 'api_key' => Route4Me::getApiKey(), |
|
| 135 | + 'route_id' => $routeId, |
|
| 136 | + 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
| 137 | + 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
| 138 | + ) |
|
| 139 | + )); |
|
| 140 | 140 | |
| 141 | 141 | return $result; |
| 142 | 142 | } |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | public function duplicateRoute($route_id) |
| 145 | 145 | { |
| 146 | 146 | $result = Route4Me::makeRequst(array( |
| 147 | - 'url' => self::$apiUrlDuplicate, |
|
| 148 | - 'method' => 'GET', |
|
| 149 | - 'query' => array( |
|
| 150 | - 'api_key' => Route4Me::getApiKey(), |
|
| 151 | - 'route_id' => $route_id, |
|
| 152 | - 'to' => 'none', |
|
| 153 | - ) |
|
| 154 | - )); |
|
| 147 | + 'url' => self::$apiUrlDuplicate, |
|
| 148 | + 'method' => 'GET', |
|
| 149 | + 'query' => array( |
|
| 150 | + 'api_key' => Route4Me::getApiKey(), |
|
| 151 | + 'route_id' => $route_id, |
|
| 152 | + 'to' => 'none', |
|
| 153 | + ) |
|
| 154 | + )); |
|
| 155 | 155 | |
| 156 | 156 | return $result; |
| 157 | 157 | } |
@@ -159,17 +159,17 @@ discard block |
||
| 159 | 159 | public function resequenceRoute($params) |
| 160 | 160 | { |
| 161 | 161 | $result = Route4Me::makeRequst(array( |
| 162 | - 'url' => self::$apiUrl, |
|
| 163 | - 'method' => 'PUT', |
|
| 164 | - 'query' => array( |
|
| 165 | - 'api_key' => Route4Me::getApiKey(), |
|
| 166 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 167 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
| 168 | - ), |
|
| 169 | - 'body' => array( |
|
| 162 | + 'url' => self::$apiUrl, |
|
| 163 | + 'method' => 'PUT', |
|
| 164 | + 'query' => array( |
|
| 165 | + 'api_key' => Route4Me::getApiKey(), |
|
| 166 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 167 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
| 168 | + ), |
|
| 169 | + 'body' => array( |
|
| 170 | 170 | 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
| 171 | 171 | ) |
| 172 | - )); |
|
| 172 | + )); |
|
| 173 | 173 | |
| 174 | 174 | return $result; |
| 175 | 175 | } |
@@ -177,15 +177,15 @@ discard block |
||
| 177 | 177 | public function resequenceAllAddresses($params) |
| 178 | 178 | { |
| 179 | 179 | $result = Route4Me::makeRequst(array( |
| 180 | - 'url' => self::$apiUrlReseq, |
|
| 181 | - 'method' => 'GET', |
|
| 182 | - 'query' => array( |
|
| 183 | - 'api_key' => Route4Me::getApiKey(), |
|
| 184 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 185 | - 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
| 186 | - 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
| 187 | - ) |
|
| 188 | - )); |
|
| 180 | + 'url' => self::$apiUrlReseq, |
|
| 181 | + 'method' => 'GET', |
|
| 182 | + 'query' => array( |
|
| 183 | + 'api_key' => Route4Me::getApiKey(), |
|
| 184 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 185 | + 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
| 186 | + 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
| 187 | + ) |
|
| 188 | + )); |
|
| 189 | 189 | |
| 190 | 190 | return $result; |
| 191 | 191 | |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | public function mergeRoutes($params) |
| 195 | 195 | { |
| 196 | 196 | $result = Route4Me::makeRequst(array( |
| 197 | - 'url' => self::$apiUrlMerge, |
|
| 198 | - 'method' => 'POST', |
|
| 199 | - 'query' => array( |
|
| 200 | - 'api_key' => Route4Me::getApiKey(), |
|
| 201 | - ), |
|
| 202 | - 'body' => array( |
|
| 197 | + 'url' => self::$apiUrlMerge, |
|
| 198 | + 'method' => 'POST', |
|
| 199 | + 'query' => array( |
|
| 200 | + 'api_key' => Route4Me::getApiKey(), |
|
| 201 | + ), |
|
| 202 | + 'body' => array( |
|
| 203 | 203 | 'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null, |
| 204 | 204 | ), |
| 205 | 205 | 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
| 206 | - )); |
|
| 206 | + )); |
|
| 207 | 207 | |
| 208 | 208 | return $result; |
| 209 | 209 | } |
@@ -211,17 +211,17 @@ discard block |
||
| 211 | 211 | public function shareRoute($params) |
| 212 | 212 | { |
| 213 | 213 | $result = Route4Me::makeRequst(array( |
| 214 | - 'url' => self::$apiUrlShare, |
|
| 215 | - 'method' => 'POST', |
|
| 216 | - 'query' => array( |
|
| 217 | - 'api_key' => Route4Me::getApiKey(), |
|
| 218 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 219 | - ), |
|
| 220 | - 'body' => array( |
|
| 214 | + 'url' => self::$apiUrlShare, |
|
| 215 | + 'method' => 'POST', |
|
| 216 | + 'query' => array( |
|
| 217 | + 'api_key' => Route4Me::getApiKey(), |
|
| 218 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 219 | + ), |
|
| 220 | + 'body' => array( |
|
| 221 | 221 | 'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null, |
| 222 | 222 | ), |
| 223 | 223 | 'Content-Type' => 'multipart/form-data' |
| 224 | - )); |
|
| 224 | + )); |
|
| 225 | 225 | |
| 226 | 226 | return $result; |
| 227 | 227 | } |
@@ -230,18 +230,18 @@ discard block |
||
| 230 | 230 | public function getRandomRouteId($offset,$limit) |
| 231 | 231 | { |
| 232 | 232 | $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
| 233 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
| 233 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
| 234 | 234 | |
| 235 | 235 | $json = Route4Me::makeRequst(array( |
| 236 | - 'url' => self::$apiUrl, |
|
| 237 | - 'method' => 'GET', |
|
| 238 | - 'query' => $query |
|
| 239 | - )); |
|
| 236 | + 'url' => self::$apiUrl, |
|
| 237 | + 'method' => 'GET', |
|
| 238 | + 'query' => $query |
|
| 239 | + )); |
|
| 240 | 240 | |
| 241 | 241 | $routes = array(); |
| 242 | - foreach($json as $route) { |
|
| 243 | - $routes[] = Route::fromArray($route); |
|
| 244 | - } |
|
| 242 | + foreach($json as $route) { |
|
| 243 | + $routes[] = Route::fromArray($route); |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | 246 | $num=rand(0,sizeof($routes)-1); |
| 247 | 247 | $rRoute=(array)$routes[$num]; |
@@ -253,71 +253,71 @@ discard block |
||
| 253 | 253 | else return null; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - public function update() |
|
| 257 | - { |
|
| 258 | - $route = Route4Me::makeRequst(array( |
|
| 259 | - 'url' => self::$apiUrl, |
|
| 260 | - 'method' => 'PUT', |
|
| 261 | - 'query' => array( |
|
| 262 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 263 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 264 | - ), |
|
| 265 | - 'body' => array ( |
|
| 266 | - 'parameters' => $this->parameters, |
|
| 267 | - ), |
|
| 268 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 269 | - )); |
|
| 256 | + public function update() |
|
| 257 | + { |
|
| 258 | + $route = Route4Me::makeRequst(array( |
|
| 259 | + 'url' => self::$apiUrl, |
|
| 260 | + 'method' => 'PUT', |
|
| 261 | + 'query' => array( |
|
| 262 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 263 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 264 | + ), |
|
| 265 | + 'body' => array ( |
|
| 266 | + 'parameters' => $this->parameters, |
|
| 267 | + ), |
|
| 268 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 269 | + )); |
|
| 270 | 270 | |
| 271 | - return Route::fromArray($route); |
|
| 272 | - } |
|
| 271 | + return Route::fromArray($route); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | public function updateAddress() |
| 275 | - { |
|
| 276 | - $result = Route4Me::makeRequst(array( |
|
| 277 | - 'url' => self::$apiUrlAddress, |
|
| 278 | - 'method' => 'PUT', |
|
| 279 | - 'query' => array( |
|
| 280 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 281 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 282 | - ), |
|
| 283 | - 'body' => get_object_vars($this->parameters), |
|
| 284 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 285 | - )); |
|
| 275 | + { |
|
| 276 | + $result = Route4Me::makeRequst(array( |
|
| 277 | + 'url' => self::$apiUrlAddress, |
|
| 278 | + 'method' => 'PUT', |
|
| 279 | + 'query' => array( |
|
| 280 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 281 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 282 | + ), |
|
| 283 | + 'body' => get_object_vars($this->parameters), |
|
| 284 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 285 | + )); |
|
| 286 | 286 | |
| 287 | - return $result; |
|
| 288 | - } |
|
| 287 | + return $result; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - public function addAddresses(array $params) |
|
| 291 | - { |
|
| 292 | - $route = Route4Me::makeRequst(array( |
|
| 293 | - 'url' => self::$apiUrl, |
|
| 294 | - 'method' => 'PUT', |
|
| 295 | - 'query' => array( |
|
| 296 | - 'api_key' => Route4Me::getApiKey(), |
|
| 297 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 298 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
| 299 | - ) |
|
| 300 | - )); |
|
| 290 | + public function addAddresses(array $params) |
|
| 291 | + { |
|
| 292 | + $route = Route4Me::makeRequst(array( |
|
| 293 | + 'url' => self::$apiUrl, |
|
| 294 | + 'method' => 'PUT', |
|
| 295 | + 'query' => array( |
|
| 296 | + 'api_key' => Route4Me::getApiKey(), |
|
| 297 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 298 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
| 299 | + ) |
|
| 300 | + )); |
|
| 301 | 301 | |
| 302 | - return Route::fromArray($route); |
|
| 303 | - } |
|
| 302 | + return Route::fromArray($route); |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | public function insertAddressOptimalPosition(array $params) |
| 306 | 306 | { |
| 307 | 307 | $route = Route4Me::makeRequst(array( |
| 308 | - 'url' => self::$apiUrl, |
|
| 309 | - 'method' => 'PUT', |
|
| 310 | - 'query' => array( |
|
| 311 | - 'api_key' => Route4Me::getApiKey(), |
|
| 312 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 313 | - ), |
|
| 314 | - 'body' => array( |
|
| 308 | + 'url' => self::$apiUrl, |
|
| 309 | + 'method' => 'PUT', |
|
| 310 | + 'query' => array( |
|
| 311 | + 'api_key' => Route4Me::getApiKey(), |
|
| 312 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 313 | + ), |
|
| 314 | + 'body' => array( |
|
| 315 | 315 | 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
| 316 | 316 | 'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null, |
| 317 | 317 | ) |
| 318 | - )); |
|
| 318 | + )); |
|
| 319 | 319 | |
| 320 | - return Route::fromArray($route); |
|
| 320 | + return Route::fromArray($route); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | public function addNoteFile($params) |
@@ -326,18 +326,18 @@ discard block |
||
| 326 | 326 | $rpath = realpath($fname); |
| 327 | 327 | //echo $rpath;die(""); |
| 328 | 328 | $result= Route4Me::makeRequst(array( |
| 329 | - 'url' => self::$apiUrlNoteFile, |
|
| 330 | - 'method' => 'POST', |
|
| 331 | - 'query' => array( |
|
| 332 | - 'api_key' => Route4Me::getApiKey(), |
|
| 333 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 334 | - 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
| 335 | - 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
| 336 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
| 337 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
| 338 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
| 339 | - ), |
|
| 340 | - 'body' => array( |
|
| 329 | + 'url' => self::$apiUrlNoteFile, |
|
| 330 | + 'method' => 'POST', |
|
| 331 | + 'query' => array( |
|
| 332 | + 'api_key' => Route4Me::getApiKey(), |
|
| 333 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 334 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
| 335 | + 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
| 336 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
| 337 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
| 338 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
| 339 | + ), |
|
| 340 | + 'body' => array( |
|
| 341 | 341 | 'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null, |
| 342 | 342 | 'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null, |
| 343 | 343 | 'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null, |
@@ -347,18 +347,18 @@ discard block |
||
| 347 | 347 | 'HTTPHEADER' => array( |
| 348 | 348 | 'Content-Type: application/x-www-form-urlencoded' |
| 349 | 349 | ) |
| 350 | - )); |
|
| 350 | + )); |
|
| 351 | 351 | |
| 352 | - return $result; |
|
| 352 | + return $result; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - public function delete($route_id) |
|
| 356 | - { |
|
| 357 | - $result = Route4Me::makeRequst(array( |
|
| 358 | - 'url' => self::$apiUrl, |
|
| 359 | - 'method' => 'DELETE', |
|
| 360 | - 'query' => array( 'route_id' => $route_id ) |
|
| 361 | - )); |
|
| 355 | + public function delete($route_id) |
|
| 356 | + { |
|
| 357 | + $result = Route4Me::makeRequst(array( |
|
| 358 | + 'url' => self::$apiUrl, |
|
| 359 | + 'method' => 'DELETE', |
|
| 360 | + 'query' => array( 'route_id' => $route_id ) |
|
| 361 | + )); |
|
| 362 | 362 | |
| 363 | 363 | // The code below doesn't work, altough this method is described as workable in REST API |
| 364 | 364 | /* |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | ) |
| 372 | 372 | )); |
| 373 | 373 | */ |
| 374 | - return $result; |
|
| 375 | - } |
|
| 374 | + return $result; |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | 377 | public function GetAddressesFromRoute($route_id) |
| 378 | 378 | { |
@@ -396,63 +396,63 @@ discard block |
||
| 396 | 396 | } else { return null;} |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - public function getRouteId() |
|
| 400 | - { |
|
| 401 | - return $this->route_id; |
|
| 402 | - } |
|
| 399 | + public function getRouteId() |
|
| 400 | + { |
|
| 401 | + return $this->route_id; |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - public function getOptimizationId() |
|
| 405 | - { |
|
| 406 | - return $this->optimization_problem_id; |
|
| 407 | - } |
|
| 404 | + public function getOptimizationId() |
|
| 405 | + { |
|
| 406 | + return $this->optimization_problem_id; |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | 409 | public function GetLastLocation(array $params) |
| 410 | 410 | { |
| 411 | 411 | $route = Route4Me::makeRequst(array( |
| 412 | - 'url' => self::$apiUrl, |
|
| 413 | - 'method' => 'GET', |
|
| 414 | - 'query' => array( |
|
| 415 | - 'api_key' => Route4Me::getApiKey(), |
|
| 416 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 417 | - 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
| 418 | - ) |
|
| 419 | - )); |
|
| 412 | + 'url' => self::$apiUrl, |
|
| 413 | + 'method' => 'GET', |
|
| 414 | + 'query' => array( |
|
| 415 | + 'api_key' => Route4Me::getApiKey(), |
|
| 416 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 417 | + 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
| 418 | + ) |
|
| 419 | + )); |
|
| 420 | 420 | |
| 421 | - return Route::fromArray($route); |
|
| 421 | + return Route::fromArray($route); |
|
| 422 | 422 | |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | public function GetTrackingHistoryFromTimeRange(array $params) |
| 426 | 426 | { |
| 427 | 427 | $route = Route4Me::makeRequst(array( |
| 428 | - 'url' => self::$apiUrlDeviceLocation, |
|
| 429 | - 'method' => 'GET', |
|
| 430 | - 'query' => array( |
|
| 431 | - 'api_key' => Route4Me::getApiKey(), |
|
| 432 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 433 | - 'format' => isset($params['format']) ? $params['format'] : null, |
|
| 434 | - 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
| 435 | - 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
| 436 | - 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
| 437 | - ) |
|
| 438 | - )); |
|
| 439 | - |
|
| 440 | - return $route; |
|
| 428 | + 'url' => self::$apiUrlDeviceLocation, |
|
| 429 | + 'method' => 'GET', |
|
| 430 | + 'query' => array( |
|
| 431 | + 'api_key' => Route4Me::getApiKey(), |
|
| 432 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
| 433 | + 'format' => isset($params['format']) ? $params['format'] : null, |
|
| 434 | + 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
| 435 | + 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
| 436 | + 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
| 437 | + ) |
|
| 438 | + )); |
|
| 439 | + |
|
| 440 | + return $route; |
|
| 441 | 441 | |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | public function GetAssetTracking(array $params) |
| 445 | 445 | { |
| 446 | 446 | $route = Route4Me::makeRequst(array( |
| 447 | - 'url' => self::$apiUrlAsset, |
|
| 448 | - 'method' => 'GET', |
|
| 449 | - 'query' => array( |
|
| 450 | - 'api_key' => Route4Me::getApiKey(), |
|
| 451 | - 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
| 452 | - ) |
|
| 453 | - )); |
|
| 454 | - |
|
| 455 | - return $route; |
|
| 447 | + 'url' => self::$apiUrlAsset, |
|
| 448 | + 'method' => 'GET', |
|
| 449 | + 'query' => array( |
|
| 450 | + 'api_key' => Route4Me::getApiKey(), |
|
| 451 | + 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
| 452 | + ) |
|
| 453 | + )); |
|
| 454 | + |
|
| 455 | + return $route; |
|
| 456 | 456 | |
| 457 | 457 | } |
| 458 | 458 | } |
@@ -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() |
@@ -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; |