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:
parent
63fd4db19a
commit
340b336a49
3 changed files with 10 additions and 12 deletions
|
@ -385,7 +385,7 @@ class Controller extends Object
|
|||
{
|
||||
$module_return = $module->$default_method();
|
||||
|
||||
if ($module_return === null)
|
||||
if (!is_array($module_return))
|
||||
{
|
||||
$module_return = $module->return;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ class Distance
|
|||
|
||||
if (count($pieces) == 2)
|
||||
{
|
||||
var_dump($arguments[0], $pieces[0], $pieces[1]);
|
||||
return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]);
|
||||
}
|
||||
|
||||
|
@ -113,15 +112,15 @@ class Distance
|
|||
* @static
|
||||
* @param mixed $latitude_from starting latitude
|
||||
* @param mixed $longitude_from starting longitude
|
||||
* @param mixed $latitude_from starting latitude
|
||||
* @param mixed $longitude_from starting longitude
|
||||
* @param mixed $latitude_to ending latitude
|
||||
* @param mixed $longitude_to ending longitude
|
||||
* @param string $unit optional units to return, miles by default
|
||||
* @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));
|
||||
$theta = $lontitude_from - $longitude_to;
|
||||
$theta = $longitude_from - $longitude_to;
|
||||
|
||||
$distance =
|
||||
sin(deg2rad($latitude_from))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue