Controller bug and Distance class

Fixed a bug in the Controller that was throwing some notices when a module didn't return any data. Also finished up the calculateDistance() method in the Distance class. Seems I left it in somewhat of a bug filled incomplete state last week.
This commit is contained in:
Josh Sherman 2012-12-18 13:24:19 -05:00
parent 63fd4db19a
commit 340b336a49
3 changed files with 10 additions and 12 deletions

View file

@ -385,7 +385,7 @@ class Controller extends Object
{ {
$module_return = $module->$default_method(); $module_return = $module->$default_method();
if ($module_return === null) if (!is_array($module_return))
{ {
$module_return = $module->return; $module_return = $module->return;
} }

View file

@ -41,7 +41,6 @@ class Distance
if (count($pieces) == 2) if (count($pieces) == 2)
{ {
var_dump($arguments[0], $pieces[0], $pieces[1]);
return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]); return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]);
} }
@ -113,15 +112,15 @@ class Distance
* @static * @static
* @param mixed $latitude_from starting latitude * @param mixed $latitude_from starting latitude
* @param mixed $longitude_from starting longitude * @param mixed $longitude_from starting longitude
* @param mixed $latitude_from starting latitude * @param mixed $latitude_to ending latitude
* @param mixed $longitude_from starting longitude * @param mixed $longitude_to ending longitude
* @param string $unit optional units to return, miles by default * @param string $unit optional units to return, miles by default
* @return mixed distance between the points in the desired unit * @return mixed distance between the points in the desired unit
*/ */
public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $latitude_from, $unit = 'miles') public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $longitude_to, $unit = 'miles')
{ {
$unit = ucwords(strtolower($unit)); $unit = ucwords(strtolower($unit));
$theta = $lontitude_from - $longitude_to; $theta = $longitude_from - $longitude_to;
$distance = $distance =
sin(deg2rad($latitude_from)) sin(deg2rad($latitude_from))

11
jar.php
View file

@ -1413,7 +1413,7 @@ class Controller extends Object
{ {
$module_return = $module->$default_method(); $module_return = $module->$default_method();
if ($module_return === null) if (!is_array($module_return))
{ {
$module_return = $module->return; $module_return = $module->return;
} }
@ -2908,7 +2908,6 @@ class Distance
if (count($pieces) == 2) if (count($pieces) == 2)
{ {
var_dump($arguments[0], $pieces[0], $pieces[1]);
return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]); return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]);
} }
@ -2980,15 +2979,15 @@ class Distance
* @static * @static
* @param mixed $latitude_from starting latitude * @param mixed $latitude_from starting latitude
* @param mixed $longitude_from starting longitude * @param mixed $longitude_from starting longitude
* @param mixed $latitude_from starting latitude * @param mixed $latitude_to ending latitude
* @param mixed $longitude_from starting longitude * @param mixed $longitude_to ending longitude
* @param string $unit optional units to return, miles by default * @param string $unit optional units to return, miles by default
* @return mixed distance between the points in the desired unit * @return mixed distance between the points in the desired unit
*/ */
public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $latitude_from, $unit = 'miles') public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $longitude_to, $unit = 'miles')
{ {
$unit = ucwords(strtolower($unit)); $unit = ucwords(strtolower($unit));
$theta = $lontitude_from - $longitude_to; $theta = $longitude_from - $longitude_to;
$distance = $distance =
sin(deg2rad($latitude_from)) sin(deg2rad($latitude_from))