@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | $addresses = array(); |
| 28 | 28 | |
| 29 | 29 | foreach ($json as $address) { |
| 30 | - $addresses[] = Address::fromArray($address); |
|
| 30 | + $addresses[] = Address::fromArray($address); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | $parameters = RouteParameters::fromArray(array( |
| 34 | - "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
| 35 | - "route_name" => "Multiple Depot, Multiple Driver, Time Window", |
|
| 36 | - "route_date" => time() + 24 * 60 * 60, |
|
| 37 | - "route_time" => 60 * 60 * 7, |
|
| 38 | - "rt" => TRUE, |
|
| 39 | - "distance_unit" => DistanceUnit::MILES, |
|
| 40 | - "device_type" => DeviceType::WEB, |
|
| 41 | - "optimize" => OptimizationType::TIME, |
|
| 42 | - "metric" => Metric::GEODESIC, |
|
| 43 | - "route_max_duration" => 86400 * 3, |
|
| 44 | - "travel_mode" => TravelMode::DRIVING, |
|
| 45 | - "vehicle_capacity" => 99, |
|
| 46 | - "vehicle_max_distance_mi" => 99999 |
|
| 34 | + "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
| 35 | + "route_name" => "Multiple Depot, Multiple Driver, Time Window", |
|
| 36 | + "route_date" => time() + 24 * 60 * 60, |
|
| 37 | + "route_time" => 60 * 60 * 7, |
|
| 38 | + "rt" => TRUE, |
|
| 39 | + "distance_unit" => DistanceUnit::MILES, |
|
| 40 | + "device_type" => DeviceType::WEB, |
|
| 41 | + "optimize" => OptimizationType::TIME, |
|
| 42 | + "metric" => Metric::GEODESIC, |
|
| 43 | + "route_max_duration" => 86400 * 3, |
|
| 44 | + "travel_mode" => TravelMode::DRIVING, |
|
| 45 | + "vehicle_capacity" => 99, |
|
| 46 | + "vehicle_max_distance_mi" => 99999 |
|
| 47 | 47 | )); |
| 48 | 48 | |
| 49 | 49 | $optimizationParams = new OptimizationProblemParams; |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | $problem = OptimizationProblem::optimize($optimizationParams); |
| 54 | 54 | |
| 55 | 55 | foreach ((array)$problem as $key => $value) { |
| 56 | - if (is_string($value)) { |
|
| 57 | - echo $key." --> ".$value."<br>"; |
|
| 58 | - } else { |
|
| 59 | - echo "************ $key ************* <br>"; |
|
| 60 | - Route4Me::simplePrint((array)$value, true); |
|
| 61 | - echo "******************************* <br>"; |
|
| 62 | - } |
|
| 56 | + if (is_string($value)) { |
|
| 57 | + echo $key." --> ".$value."<br>"; |
|
| 58 | + } else { |
|
| 59 | + echo "************ $key ************* <br>"; |
|
| 60 | + Route4Me::simplePrint((array)$value, true); |
|
| 61 | + echo "******************************* <br>"; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -6,78 +6,78 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ActivityParameters extends Common |
| 8 | 8 | { |
| 9 | - public $route_id; |
|
| 10 | - public $device_id; |
|
| 11 | - public $member_id; |
|
| 12 | - public $team; |
|
| 13 | - public $limit; |
|
| 14 | - public $offset; |
|
| 15 | - public $start; |
|
| 16 | - public $end; |
|
| 17 | - public $activity_type; |
|
| 18 | - public $activity_message; |
|
| 9 | + public $route_id; |
|
| 10 | + public $device_id; |
|
| 11 | + public $member_id; |
|
| 12 | + public $team; |
|
| 13 | + public $limit; |
|
| 14 | + public $offset; |
|
| 15 | + public $start; |
|
| 16 | + public $end; |
|
| 17 | + public $activity_type; |
|
| 18 | + public $activity_message; |
|
| 19 | 19 | |
| 20 | - public $activity_id; |
|
| 21 | - public $activity_timestamp; |
|
| 22 | - public $route_destination_id; |
|
| 23 | - public $note_id; |
|
| 24 | - public $member; |
|
| 25 | - public $note_type; |
|
| 26 | - public $note_contents; |
|
| 27 | - public $route_name; |
|
| 28 | - public $note_file; |
|
| 29 | - public $destination_name; |
|
| 30 | - public $destination_alias; |
|
| 20 | + public $activity_id; |
|
| 21 | + public $activity_timestamp; |
|
| 22 | + public $route_destination_id; |
|
| 23 | + public $note_id; |
|
| 24 | + public $member; |
|
| 25 | + public $note_type; |
|
| 26 | + public $note_contents; |
|
| 27 | + public $route_name; |
|
| 28 | + public $note_file; |
|
| 29 | + public $destination_name; |
|
| 30 | + public $destination_alias; |
|
| 31 | 31 | |
| 32 | - public static function fromArray(array $params) |
|
| 33 | - { |
|
| 34 | - $activityparameters = new ActivityParameters(); |
|
| 32 | + public static function fromArray(array $params) |
|
| 33 | + { |
|
| 34 | + $activityparameters = new ActivityParameters(); |
|
| 35 | 35 | |
| 36 | - foreach ($params as $key => $value) { |
|
| 37 | - if (property_exists($activityparameters, $key)) { |
|
| 38 | - $activityparameters->{$key} = $value; |
|
| 39 | - } |
|
| 40 | - } |
|
| 36 | + foreach ($params as $key => $value) { |
|
| 37 | + if (property_exists($activityparameters, $key)) { |
|
| 38 | + $activityparameters->{$key} = $value; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return $activityparameters; |
|
| 43 | - } |
|
| 42 | + return $activityparameters; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public static function getActivities($params) |
|
| 46 | - { |
|
| 47 | - $allQueryFields = array('route_id', 'team', 'limit', 'offset', 'start'); |
|
| 45 | + public static function getActivities($params) |
|
| 46 | + { |
|
| 47 | + $allQueryFields = array('route_id', 'team', 'limit', 'offset', 'start'); |
|
| 48 | 48 | |
| 49 | - $activity = Route4Me::makeRequst(array( |
|
| 50 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
| 51 | - 'method' => 'GET', |
|
| 52 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 53 | - )); |
|
| 49 | + $activity = Route4Me::makeRequst(array( |
|
| 50 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
| 51 | + 'method' => 'GET', |
|
| 52 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 53 | + )); |
|
| 54 | 54 | |
| 55 | - return $activity; |
|
| 56 | - } |
|
| 55 | + return $activity; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public static function searcActivities($params) |
|
| 59 | - { |
|
| 60 | - $allQueryFields = array('route_id', 'limit', 'offset', 'activity_type'); |
|
| 58 | + public static function searcActivities($params) |
|
| 59 | + { |
|
| 60 | + $allQueryFields = array('route_id', 'limit', 'offset', 'activity_type'); |
|
| 61 | 61 | |
| 62 | - $activity = Route4Me::makeRequst(array( |
|
| 63 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
| 64 | - 'method' => 'GET', |
|
| 65 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 66 | - )); |
|
| 62 | + $activity = Route4Me::makeRequst(array( |
|
| 63 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
| 64 | + 'method' => 'GET', |
|
| 65 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 66 | + )); |
|
| 67 | 67 | |
| 68 | - return $activity; |
|
| 69 | - } |
|
| 68 | + return $activity; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public static function sendUserMessage($params) |
|
| 72 | - { |
|
| 73 | - $allBodyFields = array('activity_type', 'activity_message', 'route_id'); |
|
| 71 | + public static function sendUserMessage($params) |
|
| 72 | + { |
|
| 73 | + $allBodyFields = array('activity_type', 'activity_message', 'route_id'); |
|
| 74 | 74 | |
| 75 | - $result = Route4Me::makeRequst(array( |
|
| 76 | - 'url' => Endpoint::ACTIVITY_FEED, |
|
| 77 | - 'method' => 'POST', |
|
| 78 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 79 | - )); |
|
| 75 | + $result = Route4Me::makeRequst(array( |
|
| 76 | + 'url' => Endpoint::ACTIVITY_FEED, |
|
| 77 | + 'method' => 'POST', |
|
| 78 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 79 | + )); |
|
| 80 | 80 | |
| 81 | - return $result; |
|
| 82 | - } |
|
| 81 | + return $result; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -7,93 +7,93 @@ |
||
| 7 | 7 | |
| 8 | 8 | class OptimizationProblemParams extends Common |
| 9 | 9 | { |
| 10 | - public $optimization_problem_id; |
|
| 11 | - public $reoptimize; |
|
| 12 | - public $addresses = array(); |
|
| 13 | - public $parameters; |
|
| 14 | - public $directions; |
|
| 15 | - public $format; |
|
| 16 | - public $route_path_output; |
|
| 17 | - public $optimized_callback_url; |
|
| 18 | - public $redirect = true; |
|
| 10 | + public $optimization_problem_id; |
|
| 11 | + public $reoptimize; |
|
| 12 | + public $addresses = array(); |
|
| 13 | + public $parameters; |
|
| 14 | + public $directions; |
|
| 15 | + public $format; |
|
| 16 | + public $route_path_output; |
|
| 17 | + public $optimized_callback_url; |
|
| 18 | + public $redirect = true; |
|
| 19 | 19 | |
| 20 | - public static function fromArray($params) |
|
| 21 | - { |
|
| 22 | - $param = new OptimizationProblemParams; |
|
| 23 | - if (!isset($params['addresses'])) { |
|
| 24 | - throw new BadParam('addresses must be provided.'); |
|
| 25 | - } |
|
| 20 | + public static function fromArray($params) |
|
| 21 | + { |
|
| 22 | + $param = new OptimizationProblemParams; |
|
| 23 | + if (!isset($params['addresses'])) { |
|
| 24 | + throw new BadParam('addresses must be provided.'); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - if (!isset($params['parameters'])) { |
|
| 28 | - throw new BadParam('parameters must be provided.'); |
|
| 29 | - } |
|
| 27 | + if (!isset($params['parameters'])) { |
|
| 28 | + throw new BadParam('parameters must be provided.'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - if ($params['parameters'] instanceof RouteParameters) { |
|
| 32 | - $param->setParameters($params['parameters']); |
|
| 33 | - } else { |
|
| 34 | - $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
| 35 | - } |
|
| 31 | + if ($params['parameters'] instanceof RouteParameters) { |
|
| 32 | + $param->setParameters($params['parameters']); |
|
| 33 | + } else { |
|
| 34 | + $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - foreach ($params['addresses'] as $address) { |
|
| 38 | - if (!($address instanceof Address)) { |
|
| 39 | - $address = Address::fromArray($address); |
|
| 40 | - } |
|
| 37 | + foreach ($params['addresses'] as $address) { |
|
| 38 | + if (!($address instanceof Address)) { |
|
| 39 | + $address = Address::fromArray($address); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $param->addAddress($address); |
|
| 43 | - } |
|
| 42 | + $param->addAddress($address); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $param->directions = self::getValue($params, 'directions'); |
|
| 46 | - $param->format = self::getValue($params, 'format'); |
|
| 47 | - $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
| 48 | - $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
| 49 | - $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
| 50 | - $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
| 51 | - $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN); |
|
| 45 | + $param->directions = self::getValue($params, 'directions'); |
|
| 46 | + $param->format = self::getValue($params, 'format'); |
|
| 47 | + $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
| 48 | + $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
| 49 | + $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
| 50 | + $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
| 51 | + $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN); |
|
| 52 | 52 | |
| 53 | - return $param; |
|
| 54 | - } |
|
| 53 | + return $param; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - public function __construct() |
|
| 57 | - { |
|
| 58 | - $this->parameters = new RouteParameters; |
|
| 59 | - } |
|
| 56 | + public function __construct() |
|
| 57 | + { |
|
| 58 | + $this->parameters = new RouteParameters; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function setParameters(RouteParameters $params) |
|
| 62 | - { |
|
| 63 | - $this->parameters = $params; |
|
| 61 | + public function setParameters(RouteParameters $params) |
|
| 62 | + { |
|
| 63 | + $this->parameters = $params; |
|
| 64 | 64 | |
| 65 | - return $this; |
|
| 66 | - } |
|
| 65 | + return $this; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function addAddress(Address $address) |
|
| 69 | - { |
|
| 70 | - $this->addresses[] = $address; |
|
| 68 | + public function addAddress(Address $address) |
|
| 69 | + { |
|
| 70 | + $this->addresses[] = $address; |
|
| 71 | 71 | |
| 72 | - return $this; |
|
| 73 | - } |
|
| 72 | + return $this; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function getAddressesArray() |
|
| 76 | - { |
|
| 77 | - $addresses = array(); |
|
| 75 | + public function getAddressesArray() |
|
| 76 | + { |
|
| 77 | + $addresses = array(); |
|
| 78 | 78 | |
| 79 | - foreach ($this->addresses as $address) { |
|
| 80 | - $addresses[] = $address->toArray(); |
|
| 81 | - } |
|
| 79 | + foreach ($this->addresses as $address) { |
|
| 80 | + $addresses[] = $address->toArray(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - return $addresses; |
|
| 84 | - } |
|
| 83 | + return $addresses; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function getParametersArray() |
|
| 87 | - { |
|
| 88 | - return $this->parameters->toArray(); |
|
| 89 | - } |
|
| 86 | + public function getParametersArray() |
|
| 87 | + { |
|
| 88 | + return $this->parameters->toArray(); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - public function setAddresses(array $addresses) |
|
| 92 | - { |
|
| 93 | - foreach ($addresses as $address) { |
|
| 94 | - $this->addAddress($address); |
|
| 95 | - } |
|
| 91 | + public function setAddresses(array $addresses) |
|
| 92 | + { |
|
| 93 | + foreach ($addresses as $address) { |
|
| 94 | + $this->addAddress($address); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $this; |
|
| 98 | - } |
|
| 97 | + return $this; |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -3,13 +3,13 @@ |
||
| 3 | 3 | |
| 4 | 4 | class AlgorithmType |
| 5 | 5 | { |
| 6 | - const TSP = 1; |
|
| 7 | - const VRP = 2; |
|
| 8 | - const CVRP_TW_SD = 3; |
|
| 9 | - const CVRP_TW_MD = 4; |
|
| 10 | - const TSP_TW = 5; |
|
| 11 | - const TSP_TW_CR = 6; |
|
| 12 | - const BBCVRP = 7; |
|
| 13 | - const ALG_NONE = 100; |
|
| 14 | - const ALG_LEGACY_DISTRIBUTED = 101; |
|
| 6 | + const TSP = 1; |
|
| 7 | + const VRP = 2; |
|
| 8 | + const CVRP_TW_SD = 3; |
|
| 9 | + const CVRP_TW_MD = 4; |
|
| 10 | + const TSP_TW = 5; |
|
| 11 | + const TSP_TW_CR = 6; |
|
| 12 | + const BBCVRP = 7; |
|
| 13 | + const ALG_NONE = 100; |
|
| 14 | + const ALG_LEGACY_DISTRIBUTED = 101; |
|
| 15 | 15 | } |
@@ -7,111 +7,111 @@ |
||
| 7 | 7 | |
| 8 | 8 | class AvoidanceZone extends Common |
| 9 | 9 | { |
| 10 | - public $territory_id; // Avoidance zone id |
|
| 11 | - public $territory_name; |
|
| 12 | - public $territory_color; |
|
| 13 | - public $orders; |
|
| 14 | - public $member_id; |
|
| 15 | - public $territory; // Territory parameters |
|
| 10 | + public $territory_id; // Avoidance zone id |
|
| 11 | + public $territory_name; |
|
| 12 | + public $territory_color; |
|
| 13 | + public $orders; |
|
| 14 | + public $member_id; |
|
| 15 | + public $territory; // Territory parameters |
|
| 16 | 16 | |
| 17 | - public static function fromArray(array $params) |
|
| 18 | - { |
|
| 19 | - if (!isset($params['territory_name'])) { |
|
| 20 | - throw new BadParam('Territory name must be provided'); |
|
| 21 | - } |
|
| 17 | + public static function fromArray(array $params) |
|
| 18 | + { |
|
| 19 | + if (!isset($params['territory_name'])) { |
|
| 20 | + throw new BadParam('Territory name must be provided'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - if (!isset($params['territory_color'])) { |
|
| 24 | - throw new BadParam('Territory color must be provided'); |
|
| 25 | - } |
|
| 23 | + if (!isset($params['territory_color'])) { |
|
| 24 | + throw new BadParam('Territory color must be provided'); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - if (!isset($params['territory'])) { |
|
| 28 | - throw new BadParam('Territory must be provided'); |
|
| 29 | - } |
|
| 27 | + if (!isset($params['territory'])) { |
|
| 28 | + throw new BadParam('Territory must be provided'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $avoidanceZoneParameters = new AvoidanceZone(); |
|
| 31 | + $avoidanceZoneParameters = new AvoidanceZone(); |
|
| 32 | 32 | |
| 33 | - foreach ($params as $key => $value) { |
|
| 34 | - if (property_exists($avoidanceZoneParameters, $key)) { |
|
| 35 | - $avoidanceZoneParameters->{$key} = $value; |
|
| 36 | - } |
|
| 37 | - } |
|
| 33 | + foreach ($params as $key => $value) { |
|
| 34 | + if (property_exists($avoidanceZoneParameters, $key)) { |
|
| 35 | + $avoidanceZoneParameters->{$key} = $value; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return $avoidanceZoneParameters; |
|
| 40 | - } |
|
| 39 | + return $avoidanceZoneParameters; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public static function getAvoidanceZone($territory_id) |
|
| 43 | - { |
|
| 44 | - $avoidanceZone = Route4Me::makeRequst(array( |
|
| 45 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 46 | - 'method' => 'GET', |
|
| 47 | - 'query' => array( |
|
| 48 | - 'territory_id' => $territory_id |
|
| 49 | - ) |
|
| 50 | - )); |
|
| 42 | + public static function getAvoidanceZone($territory_id) |
|
| 43 | + { |
|
| 44 | + $avoidanceZone = Route4Me::makeRequst(array( |
|
| 45 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 46 | + 'method' => 'GET', |
|
| 47 | + 'query' => array( |
|
| 48 | + 'territory_id' => $territory_id |
|
| 49 | + ) |
|
| 50 | + )); |
|
| 51 | 51 | |
| 52 | - return $avoidanceZone; |
|
| 53 | - } |
|
| 52 | + return $avoidanceZone; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public static function getAvoidanceZones($params) |
|
| 56 | - { |
|
| 57 | - $avoidanceZones = Route4Me::makeRequst(array( |
|
| 58 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 59 | - 'method' => 'GET', |
|
| 60 | - 'query' => array( |
|
| 61 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
| 62 | - 'limit' => isset($params->limit) ? $params->limit : null, |
|
| 63 | - ) |
|
| 64 | - )); |
|
| 55 | + public static function getAvoidanceZones($params) |
|
| 56 | + { |
|
| 57 | + $avoidanceZones = Route4Me::makeRequst(array( |
|
| 58 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 59 | + 'method' => 'GET', |
|
| 60 | + 'query' => array( |
|
| 61 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
| 62 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
| 63 | + ) |
|
| 64 | + )); |
|
| 65 | 65 | |
| 66 | - return $avoidanceZones; |
|
| 67 | - } |
|
| 66 | + return $avoidanceZones; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public static function addAvoidanceZone($params) |
|
| 70 | - { |
|
| 71 | - $terParams = array(); |
|
| 69 | + public static function addAvoidanceZone($params) |
|
| 70 | + { |
|
| 71 | + $terParams = array(); |
|
| 72 | 72 | |
| 73 | - if (isset($params->territory['type'])) { |
|
| 74 | - $terParams['type'] = $params->territory['type']; |
|
| 75 | - } |
|
| 73 | + if (isset($params->territory['type'])) { |
|
| 74 | + $terParams['type'] = $params->territory['type']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - if (isset($params->territory['data'])) { |
|
| 78 | - $terParams['data'] = $params->territory['data']; |
|
| 79 | - } |
|
| 77 | + if (isset($params->territory['data'])) { |
|
| 78 | + $terParams['data'] = $params->territory['data']; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $abContacts = Route4Me::makeRequst(array( |
|
| 82 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 83 | - 'method' => 'POST', |
|
| 84 | - 'body' => array( |
|
| 85 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
| 86 | - 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
| 87 | - 'territory' => $terParams |
|
| 88 | - ) |
|
| 89 | - )); |
|
| 81 | + $abContacts = Route4Me::makeRequst(array( |
|
| 82 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 83 | + 'method' => 'POST', |
|
| 84 | + 'body' => array( |
|
| 85 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
| 86 | + 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
| 87 | + 'territory' => $terParams |
|
| 88 | + ) |
|
| 89 | + )); |
|
| 90 | 90 | |
| 91 | - return $abContacts; |
|
| 92 | - } |
|
| 91 | + return $abContacts; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function deleteAvoidanceZone($territory_id) |
|
| 95 | - { |
|
| 96 | - $result = Route4Me::makeRequst(array( |
|
| 97 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 98 | - 'method' => 'DELETEARRAY', |
|
| 99 | - 'query' => array( |
|
| 100 | - 'territory_id' => $territory_id |
|
| 101 | - ) |
|
| 102 | - )); |
|
| 94 | + public function deleteAvoidanceZone($territory_id) |
|
| 95 | + { |
|
| 96 | + $result = Route4Me::makeRequst(array( |
|
| 97 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 98 | + 'method' => 'DELETEARRAY', |
|
| 99 | + 'query' => array( |
|
| 100 | + 'territory_id' => $territory_id |
|
| 101 | + ) |
|
| 102 | + )); |
|
| 103 | 103 | |
| 104 | - return $result; |
|
| 105 | - } |
|
| 104 | + return $result; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - public function updateAvoidanceZone($params) |
|
| 108 | - { |
|
| 109 | - $avoidanceZone = Route4Me::makeRequst(array( |
|
| 110 | - 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 111 | - 'method' => 'PUT', |
|
| 112 | - 'body' => $params, |
|
| 113 | - )); |
|
| 107 | + public function updateAvoidanceZone($params) |
|
| 108 | + { |
|
| 109 | + $avoidanceZone = Route4Me::makeRequst(array( |
|
| 110 | + 'url' => Endpoint::AVOIDANCE_ZONE, |
|
| 111 | + 'method' => 'PUT', |
|
| 112 | + 'body' => $params, |
|
| 113 | + )); |
|
| 114 | 114 | |
| 115 | - return $avoidanceZone; |
|
| 116 | - } |
|
| 115 | + return $avoidanceZone; |
|
| 116 | + } |
|
| 117 | 117 | } |
@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | $addresses = array(); |
| 30 | 30 | |
| 31 | 31 | foreach ($json as $address) { |
| 32 | - $addresses[] = Address::fromArray($address); |
|
| 32 | + $addresses[] = Address::fromArray($address); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $parameters = RouteParameters::fromArray(array( |
| 36 | - "algorithm_type" => AlgorithmType::TSP, |
|
| 37 | - "distance_unit" => DistanceUnit::MILES, |
|
| 38 | - "device_type" => DeviceType::WEB, |
|
| 39 | - "optimize" => OptimizationType::DISTANCE, |
|
| 40 | - "travel_mode" => TravelMode::DRIVING, |
|
| 41 | - "route_max_duration" => 86400, |
|
| 42 | - "vehicle_capacity" => 1, |
|
| 43 | - "vehicle_max_distance_mi" => 10000, |
|
| 44 | - "rt" => true, |
|
| 45 | - "optimized_callback_url" => "https://requestb.in/1o6cgge1" |
|
| 36 | + "algorithm_type" => AlgorithmType::TSP, |
|
| 37 | + "distance_unit" => DistanceUnit::MILES, |
|
| 38 | + "device_type" => DeviceType::WEB, |
|
| 39 | + "optimize" => OptimizationType::DISTANCE, |
|
| 40 | + "travel_mode" => TravelMode::DRIVING, |
|
| 41 | + "route_max_duration" => 86400, |
|
| 42 | + "vehicle_capacity" => 1, |
|
| 43 | + "vehicle_max_distance_mi" => 10000, |
|
| 44 | + "rt" => true, |
|
| 45 | + "optimized_callback_url" => "https://requestb.in/1o6cgge1" |
|
| 46 | 46 | )); |
| 47 | 47 | |
| 48 | 48 | $optimizationParams = new OptimizationProblemParams; |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | $problems = OptimizationProblem::optimize($optimizationParams); |
| 53 | 53 | |
| 54 | 54 | foreach ($problems as $problem) { |
| 55 | - if (is_array($problem) || is_object($problem)) { |
|
| 56 | - foreach ($problem as $key => $value) { |
|
| 57 | - if (!is_object($value)) { |
|
| 58 | - echo $key." --> ".$value."<br>"; |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 55 | + if (is_array($problem) || is_object($problem)) { |
|
| 56 | + foreach ($problem as $key => $value) { |
|
| 57 | + if (!is_object($value)) { |
|
| 58 | + echo $key." --> ".$value."<br>"; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | } |