| @@ -4,8 +4,8 @@ | ||
| 4 | 4 | |
| 5 | 5 | class Avoidance | 
| 6 | 6 |  { | 
| 7 | - const HIGHWAYS = 'Highways'; | |
| 8 | - const TOLLS = 'Tolls'; | |
| 9 | - const MINIMIZE_HIGHWAYS = 'minimizeHighways'; | |
| 10 | - const MINIMIZE_TOLLS = 'minimizeTolls'; | |
| 7 | + const HIGHWAYS = 'Highways'; | |
| 8 | + const TOLLS = 'Tolls'; | |
| 9 | + const MINIMIZE_HIGHWAYS = 'minimizeHighways'; | |
| 10 | + const MINIMIZE_TOLLS = 'minimizeTolls'; | |
| 11 | 11 | } | 
| @@ -4,6 +4,6 @@ | ||
| 4 | 4 | |
| 5 | 5 | class DistanceUnit | 
| 6 | 6 |  { | 
| 7 | - const MILES = 'mi'; | |
| 8 | - const KILOMETERS = 'km'; | |
| 7 | + const MILES = 'mi'; | |
| 8 | + const KILOMETERS = 'km'; | |
| 9 | 9 | } | 
| @@ -4,8 +4,8 @@ | ||
| 4 | 4 | |
| 5 | 5 | class Format | 
| 6 | 6 |  { | 
| 7 | - const SERIALIZED = 'serialized'; | |
| 8 | - const CSV = 'csv'; | |
| 9 | - const XML = 'xml'; | |
| 10 | - const JSON = 'json'; | |
| 7 | + const SERIALIZED = 'serialized'; | |
| 8 | + const CSV = 'csv'; | |
| 9 | + const XML = 'xml'; | |
| 10 | + const JSON = 'json'; | |
| 11 | 11 | } | 
| @@ -9,102 +9,102 @@ | ||
| 9 | 9 | |
| 10 | 10 | class TrackSetParams extends Common | 
| 11 | 11 |  { | 
| 12 | - public $format; | |
| 13 | - public $member_id; | |
| 14 | - public $route_id; | |
| 15 | - public $tx_id; | |
| 16 | - public $vehicle_id; | |
| 17 | - public $course; | |
| 18 | - public $speed; | |
| 19 | - public $lat; | |
| 20 | - public $lng; | |
| 21 | - public $altitude; | |
| 22 | - public $device_type; | |
| 23 | - public $device_guid; | |
| 24 | - public $device_timestamp; | |
| 25 | - public $app_version; | |
| 26 | - | |
| 27 | - public static function fromArray(array $params) | |
| 28 | -    { | |
| 29 | - $param = new TrackSetParams; | |
| 30 | - | |
| 31 | -        if (!isset($params['format'])) { | |
| 32 | -            throw new BadParam("format must be provided."); | |
| 33 | - } | |
| 34 | - | |
| 35 | - $types = array( | |
| 36 | - Format::SERIALIZED, | |
| 37 | - Format::CSV, | |
| 38 | - Format::XML | |
| 39 | - ); | |
| 40 | -        if (!in_array($params['format'], $types)) { | |
| 41 | -            throw new BadParam("format is invalid."); | |
| 42 | - } | |
| 43 | - | |
| 44 | -        if (!isset($params['route_id'])) { | |
| 45 | -            throw new BadParam("route_id must be provided."); | |
| 46 | - } | |
| 47 | - | |
| 48 | -        if (!isset($params['member_id'])) { | |
| 49 | -            throw new BadParam("member_id must be provided."); | |
| 50 | - } | |
| 51 | - | |
| 52 | -        if (!isset($params['course'])) { | |
| 53 | -            throw new BadParam("course must be provided."); | |
| 54 | - } | |
| 55 | - | |
| 56 | -        if (!isset($params['speed'])) { | |
| 57 | -            throw new BadParam("speed must be provided."); | |
| 58 | - } | |
| 59 | - | |
| 60 | -        if (!isset($params['lat'])) { | |
| 61 | -            throw new BadParam("lat must be provided."); | |
| 62 | - } | |
| 63 | - | |
| 64 | -        if (!isset($params['lng'])) { | |
| 65 | -            throw new BadParam("lng must be provided."); | |
| 66 | - } | |
| 67 | - | |
| 68 | -        if (!isset($params['device_type'])) { | |
| 69 | -            throw new BadParam("device_type must be provided."); | |
| 70 | - } | |
| 71 | - | |
| 72 | - $deviceTypes = array( | |
| 73 | - DeviceType::IPHONE, | |
| 74 | - DeviceType::IPAD, | |
| 75 | - DeviceType::ANDROID_PHONE, | |
| 76 | - DeviceType::ANDROID_TABLET | |
| 77 | - ); | |
| 78 | -        if (!in_array($params['device_type'], $deviceTypes)) { | |
| 79 | -            throw new BadParam("device_type is invalid."); | |
| 80 | - } | |
| 81 | - | |
| 82 | -        if (!isset($params['device_guid'])) { | |
| 83 | -            throw new BadParam("device_guid must be provided."); | |
| 84 | - } | |
| 85 | - | |
| 86 | -        if (isset($params['device_timestamp'])) { | |
| 87 | -            $template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i'; | |
| 88 | -            if (!preg_match($template, $params['device_timestamp'])) { | |
| 89 | -                throw new BadParam("device_timestamp is invalid."); | |
| 90 | - } | |
| 91 | - } | |
| 92 | - | |
| 93 | - $param->format = self::getValue($params, 'format'); | |
| 94 | - $param->route_id = self::getValue($params, 'route_id'); | |
| 95 | - $param->member_id = self::getValue($params, 'member_id'); | |
| 96 | - $param->course = self::getValue($params, 'course'); | |
| 97 | - $param->speed = self::getValue($params, 'speed'); | |
| 98 | - $param->lat = self::getValue($params, 'lat'); | |
| 99 | - $param->lng = self::getValue($params, 'lng'); | |
| 100 | - $param->device_type = self::getValue($params, 'device_type'); | |
| 101 | - $param->device_guid = self::getValue($params, 'device_guid'); | |
| 102 | - $param->device_timestamp = self::getValue($params, 'device_timestamp'); | |
| 103 | - $param->vehicle_id = self::getValue($params, 'vehicle_id'); | |
| 104 | - $param->altitude = self::getValue($params, 'altitude'); | |
| 105 | - $param->app_version = self::getValue($params, 'app_version'); | |
| 106 | - $param->tx_id = self::getValue($params, 'tx_id'); | |
| 107 | - | |
| 108 | - return $param; | |
| 109 | - } | |
| 12 | + public $format; | |
| 13 | + public $member_id; | |
| 14 | + public $route_id; | |
| 15 | + public $tx_id; | |
| 16 | + public $vehicle_id; | |
| 17 | + public $course; | |
| 18 | + public $speed; | |
| 19 | + public $lat; | |
| 20 | + public $lng; | |
| 21 | + public $altitude; | |
| 22 | + public $device_type; | |
| 23 | + public $device_guid; | |
| 24 | + public $device_timestamp; | |
| 25 | + public $app_version; | |
| 26 | + | |
| 27 | + public static function fromArray(array $params) | |
| 28 | +	{ | |
| 29 | + $param = new TrackSetParams; | |
| 30 | + | |
| 31 | +		if (!isset($params['format'])) { | |
| 32 | +			throw new BadParam("format must be provided."); | |
| 33 | + } | |
| 34 | + | |
| 35 | + $types = array( | |
| 36 | + Format::SERIALIZED, | |
| 37 | + Format::CSV, | |
| 38 | + Format::XML | |
| 39 | + ); | |
| 40 | +		if (!in_array($params['format'], $types)) { | |
| 41 | +			throw new BadParam("format is invalid."); | |
| 42 | + } | |
| 43 | + | |
| 44 | +		if (!isset($params['route_id'])) { | |
| 45 | +			throw new BadParam("route_id must be provided."); | |
| 46 | + } | |
| 47 | + | |
| 48 | +		if (!isset($params['member_id'])) { | |
| 49 | +			throw new BadParam("member_id must be provided."); | |
| 50 | + } | |
| 51 | + | |
| 52 | +		if (!isset($params['course'])) { | |
| 53 | +			throw new BadParam("course must be provided."); | |
| 54 | + } | |
| 55 | + | |
| 56 | +		if (!isset($params['speed'])) { | |
| 57 | +			throw new BadParam("speed must be provided."); | |
| 58 | + } | |
| 59 | + | |
| 60 | +		if (!isset($params['lat'])) { | |
| 61 | +			throw new BadParam("lat must be provided."); | |
| 62 | + } | |
| 63 | + | |
| 64 | +		if (!isset($params['lng'])) { | |
| 65 | +			throw new BadParam("lng must be provided."); | |
| 66 | + } | |
| 67 | + | |
| 68 | +		if (!isset($params['device_type'])) { | |
| 69 | +			throw new BadParam("device_type must be provided."); | |
| 70 | + } | |
| 71 | + | |
| 72 | + $deviceTypes = array( | |
| 73 | + DeviceType::IPHONE, | |
| 74 | + DeviceType::IPAD, | |
| 75 | + DeviceType::ANDROID_PHONE, | |
| 76 | + DeviceType::ANDROID_TABLET | |
| 77 | + ); | |
| 78 | +		if (!in_array($params['device_type'], $deviceTypes)) { | |
| 79 | +			throw new BadParam("device_type is invalid."); | |
| 80 | + } | |
| 81 | + | |
| 82 | +		if (!isset($params['device_guid'])) { | |
| 83 | +			throw new BadParam("device_guid must be provided."); | |
| 84 | + } | |
| 85 | + | |
| 86 | +		if (isset($params['device_timestamp'])) { | |
| 87 | +			$template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i'; | |
| 88 | +			if (!preg_match($template, $params['device_timestamp'])) { | |
| 89 | +				throw new BadParam("device_timestamp is invalid."); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + $param->format = self::getValue($params, 'format'); | |
| 94 | + $param->route_id = self::getValue($params, 'route_id'); | |
| 95 | + $param->member_id = self::getValue($params, 'member_id'); | |
| 96 | + $param->course = self::getValue($params, 'course'); | |
| 97 | + $param->speed = self::getValue($params, 'speed'); | |
| 98 | + $param->lat = self::getValue($params, 'lat'); | |
| 99 | + $param->lng = self::getValue($params, 'lng'); | |
| 100 | + $param->device_type = self::getValue($params, 'device_type'); | |
| 101 | + $param->device_guid = self::getValue($params, 'device_guid'); | |
| 102 | + $param->device_timestamp = self::getValue($params, 'device_timestamp'); | |
| 103 | + $param->vehicle_id = self::getValue($params, 'vehicle_id'); | |
| 104 | + $param->altitude = self::getValue($params, 'altitude'); | |
| 105 | + $param->app_version = self::getValue($params, 'app_version'); | |
| 106 | + $param->tx_id = self::getValue($params, 'tx_id'); | |
| 107 | + | |
| 108 | + return $param; | |
| 109 | + } | |
| 110 | 110 | } | 
| @@ -17,19 +17,19 @@ | ||
| 17 | 17 | |
| 18 | 18 | // Itereate through all the existing activity types | 
| 19 | 19 |  foreach ($activityTypes->getConstants() as $prop => $value) { | 
| 20 | - $activityParameters = ActivityParameters::fromArray(array( | |
| 21 | - "activity_type" => $value, | |
| 22 | - "limit" => 2, | |
| 23 | - "offset" => 0 | |
| 24 | - )); | |
| 20 | + $activityParameters = ActivityParameters::fromArray(array( | |
| 21 | + "activity_type" => $value, | |
| 22 | + "limit" => 2, | |
| 23 | + "offset" => 0 | |
| 24 | + )); | |
| 25 | 25 | |
| 26 | - $activities = new ActivityParameters(); | |
| 27 | - $results = $activities->searcActivities($activityParameters); | |
| 26 | + $activities = new ActivityParameters(); | |
| 27 | + $results = $activities->searcActivities($activityParameters); | |
| 28 | 28 | |
| 29 | -    foreach ($results as $key => $activity) { | |
| 30 | - Route4Me::simplePrint($activity); | |
| 31 | - echo "<br>"; | |
| 32 | - } | |
| 29 | +	foreach ($results as $key => $activity) { | |
| 30 | + Route4Me::simplePrint($activity); | |
| 31 | + echo "<br>"; | |
| 32 | + } | |
| 33 | 33 | |
| 34 | - echo "------------------- <br><br>"; | |
| 34 | + echo "------------------- <br><br>"; | |
| 35 | 35 | } | 
| @@ -21,20 +21,20 @@ | ||
| 21 | 21 | |
| 22 | 22 | // Itereate through all the existing activity types | 
| 23 | 23 |  foreach ($activityTypes->getConstants() as $prop => $value) { | 
| 24 | - $activityParameters = ActivityParameters::fromArray(array( | |
| 25 | - "activity_type" => $value, | |
| 26 | - "limit" => 2, | |
| 27 | - "offset" => 0, | |
| 28 | - "route_id" => $route_id | |
| 29 | - )); | |
| 24 | + $activityParameters = ActivityParameters::fromArray(array( | |
| 25 | + "activity_type" => $value, | |
| 26 | + "limit" => 2, | |
| 27 | + "offset" => 0, | |
| 28 | + "route_id" => $route_id | |
| 29 | + )); | |
| 30 | 30 | |
| 31 | - $activities = new ActivityParameters(); | |
| 32 | - $results = $activities->searcActivities($activityParameters); | |
| 31 | + $activities = new ActivityParameters(); | |
| 32 | + $results = $activities->searcActivities($activityParameters); | |
| 33 | 33 | |
| 34 | -    foreach ($results as $key => $activity) { | |
| 35 | - Route4Me::simplePrint($activity); | |
| 36 | - echo "<br>"; | |
| 37 | - } | |
| 34 | +	foreach ($results as $key => $activity) { | |
| 35 | + Route4Me::simplePrint($activity); | |
| 36 | + echo "<br>"; | |
| 37 | + } | |
| 38 | 38 | |
| 39 | - echo "------------------- <br><br>"; | |
| 39 | + echo "------------------- <br><br>"; | |
| 40 | 40 | } | 
| @@ -17,9 +17,9 @@ | ||
| 17 | 17 | $route_id = $route->getRandomRouteId(0, 10); | 
| 18 | 18 | |
| 19 | 19 | $postParameters = ActivityParameters::fromArray(array( | 
| 20 | - "activity_type" => "user_message", | |
| 21 | - "activity_message" => "Hello - php!", | |
| 22 | - "route_id" => $route_id | |
| 20 | + "activity_type" => "user_message", | |
| 21 | + "activity_message" => "Hello - php!", | |
| 22 | + "route_id" => $route_id | |
| 23 | 23 | )); | 
| 24 | 24 | |
| 25 | 25 | $activities = new ActivityParameters(); | 
| @@ -30,19 +30,19 @@ | ||
| 30 | 30 | $addresses = array(); | 
| 31 | 31 | |
| 32 | 32 | $address1 = (array)Address::fromArray(array( | 
| 33 | - 'address' => '717 5th Ave New York, NY 10021', | |
| 34 | - 'alias' => 'Giorgio Armani', | |
| 35 | - 'lat' => 40.7669692, | |
| 36 | - 'lng' => 73.9693864, | |
| 37 | - 'time' => 0 | |
| 33 | + 'address' => '717 5th Ave New York, NY 10021', | |
| 34 | + 'alias' => 'Giorgio Armani', | |
| 35 | + 'lat' => 40.7669692, | |
| 36 | + 'lng' => 73.9693864, | |
| 37 | + 'time' => 0 | |
| 38 | 38 | )); | 
| 39 | 39 | |
| 40 | 40 | $addresses[0] = $address1; | 
| 41 | 41 | |
| 42 | 42 | $OptimizationParameters = (array)OptimizationProblem::fromArray(array( | 
| 43 | - "optimization_problem_id" => $optimization_problem_id, | |
| 44 | - "addresses" => $addresses, | |
| 45 | - "reoptimize" => 1, | |
| 43 | + "optimization_problem_id" => $optimization_problem_id, | |
| 44 | + "addresses" => $addresses, | |
| 45 | + "reoptimize" => 1, | |
| 46 | 46 | )); | 
| 47 | 47 | |
| 48 | 48 | $optimizationproblem = new OptimizationProblem(); | 
| @@ -25,20 +25,20 @@ | ||
| 25 | 25 | $addresses = array(); | 
| 26 | 26 | |
| 27 | 27 | $params = array( | 
| 28 | - "route_id" => $routeId, | |
| 29 | - "addresses" => array( | |
| 30 | - "0" => array( | |
| 31 | - "address" => "Cabo Rojo, Cabo Rojo 00623, Puerto Rico", | |
| 32 | - "alias" => "", | |
| 33 | - "lat" => 18.086627, | |
| 34 | - "lng" => -67.145735, | |
| 35 | - "curbside_lat" => 18.086627, | |
| 36 | - "curbside_lng" => -67.145735, | |
| 37 | - "is_departed" => false, | |
| 38 | - "is_visited" => false | |
| 39 | - ) | |
| 40 | - ), | |
| 41 | - "optimal_position" => true | |
| 28 | + "route_id" => $routeId, | |
| 29 | + "addresses" => array( | |
| 30 | + "0" => array( | |
| 31 | + "address" => "Cabo Rojo, Cabo Rojo 00623, Puerto Rico", | |
| 32 | + "alias" => "", | |
| 33 | + "lat" => 18.086627, | |
| 34 | + "lng" => -67.145735, | |
| 35 | + "curbside_lat" => 18.086627, | |
| 36 | + "curbside_lng" => -67.145735, | |
| 37 | + "is_departed" => false, | |
| 38 | + "is_visited" => false | |
| 39 | + ) | |
| 40 | + ), | |
| 41 | + "optimal_position" => true | |
| 42 | 42 | ); | 
| 43 | 43 | |
| 44 | 44 | $route1 = new Route(); |