|
|
@ -160,9 +160,15 @@ if ($geocode["status"] == "OK") {
|
|
|
|
$city = $geocode["address"]["city"];
|
|
|
|
$city = $geocode["address"]["city"];
|
|
|
|
$state = $geocode["address"]["state"];
|
|
|
|
$state = $geocode["address"]["state"];
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$epa_url = "https://enviro.epa.gov/enviro/efservice/getEnvirofactsUVHOURLY/CITY/$city/STATE/$state/JSON";
|
|
|
|
$epauv = $memcache->get("gis.weather.epauv.$state.$city");
|
|
|
|
|
|
|
|
if ($epauv !== false) {
|
|
|
|
$epa_data = json_decode(ApiFetcher::get($epa_url), true);
|
|
|
|
$epa_data = json_decode($epauv, true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$epa_url = "https://enviro.epa.gov/enviro/efservice/getEnvirofactsUVHOURLY/CITY/$city/STATE/$state/JSON";
|
|
|
|
|
|
|
|
$epa_json = file_get_contents($epa_url);
|
|
|
|
|
|
|
|
$epa_data = json_decode($epa_json, true);
|
|
|
|
|
|
|
|
$memcache->set("gis.weather.epauv.$state.$city", $epa_json, 60 * 60 * 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find which returned result is closest to the current date and time
|
|
|
|
// Find which returned result is closest to the current date and time
|
|
|
|
$closest = $epa_data[0];
|
|
|
|
$closest = $epa_data[0];
|
|
|
|