WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started by: Jasiu on June 28, 2018, 11:26:36 AM
-
The JSON / new API version of Ken's forecast script uses the zone ID to fetch any alerts to be displayed along with the forecast. Unfortunately, this sometimes misses advisories that only use the county codes and do not explicitly list the zones. I found what might be a quick fix to this.
In each case that ALERTAPIURL is defined, I changed the code:
// define('ALERTAPIURL','https://api.weather.gov/alerts?active=1&zone=');
define('ALERTAPIURL','https://api.weather.gov/alerts?active=1&point=');
And then when ALERTAPIURL is used...
// $alertURL = ALERTAPIURL.$NOAAZone;
$alertURL = ALERTAPIURL . $newlatlong;
This pulls in everything associated with the point no matter what codes are included.
I left the naming of the cache file (w/ zone name) the same and it seems to work, but I have a testing sample size of one so far. Will test further...
-
Good idea... I'll add to the script.
The only downside is the legend will display the lat/long of the alert instead of the alert zone name as far as I can tell.
Thanks for the find!