예제 #1
0
    function getDistance($lat1, $lon1, $lat2, $lon2)
    {
        $radLat1 = $this->toRadians($lat1);
        $radLon1 = $this->toRadians($lon1);
        $radLat2 = $this->toRadians($lat2);
        $radLon2 = $this->toRadians($lon2);
        return acos(sin($radLat1) * sin($radLat2) + cos($radLat1) * cos($radLat2) * cos($radLon2 - $radLon1)) * $this->p_earthRadius;
    }
    // getDistance()
    function toRadians($degrees)
    {
        return $degrees * pi() / 180;
    }
}
$Weather = new Weather();
$Weather->load('30076');
/*
$zipcode = '30076';
$baseURL = 'http://www.weather.gov/xml/current_obs/index.xml';
*/
/*if($oStations = simpleXML_load_file($baseURL,"SimpleXMLElement",LIBXML_NOCDATA))
{
  print '<pre>';
  foreach($oStations->station as $station)
  {
    print_r($station);
  }
  print '</pre>';
}
else
{
예제 #2
0
            }
        } catch (Exception $e) {
            //echo "Error thrown: " . $e->getMessage();
            return false;
        }
        //error_log( '== ' . microtime(true) . ' end process XML', 0, '/var/log/httpd/error_log');
    }
    // processXML()
    function getDistance($lat1, $lon1, $lat2, $lon2)
    {
        //error_log( '== ' . microtime(true) . ' start get distance', 0, '/var/log/httpd/error_log');
        $radLat1 = $this->toRadians($lat1);
        $radLon1 = $this->toRadians($lon1);
        $radLat2 = $this->toRadians($lat2);
        $radLon2 = $this->toRadians($lon2);
        return acos(sin($radLat1) * sin($radLat2) + cos($radLat1) * cos($radLat2) * cos($radLon2 - $radLon1)) * $this->p_earthRadius;
        //error_log( '== ' . microtime(true) . ' end get distance', 0, '/var/log/httpd/error_log');
    }
    // getDistance()
    function toRadians($degrees)
    {
        //error_log( '== ' . microtime(true) . ' start to radians', 0, '/var/log/httpd/error_log');
        return $degrees * pi() / 180;
        //error_log( '== ' . microtime(true) . ' start to radians', 0, '/var/log/httpd/error_log');
    }
}
$weatherZip = isset($_REQUEST['weatherZip']) ? $_REQUEST['weatherZip'] : '30101';
//print $weatherZip;
$Weather = new Weather();
print $Weather->load($weatherZip);