GRLevelX placefile generator for risk hazards from NOAA-NWS Storm Prediction Center
This script set gets JSON outlook data from the SPC GIS Convective Outlooks and formats a placefile for GRLevelX software to display outlines of the areas with risk hazards. A mouse-over the line will popup a text tooltip with details about the risk area.
The SPC-placefile.php script is to be accessed by including the website URL in the GRLevelX placefile manager window. There are 'stub' scripts to invoke SPC-placefile.php with various days selected:
- day1.php Selects risk areas for Day 1. (same as invoking
SPC-placefile.php?day=1) - day2.php Selects risk areas for Day 2. (same as invoking
SPC-placefile.php?day=2) - day3.php Selects risk areas for Day 3. (same as invoking
SPC-placefile.php?day=3) - day4.php Selects risk areas for Day 4. (same as invoking
SPC-placefile.php?day=4) - day5.php Selects risk areas for Day 5. (same as invoking
SPC-placefile.php?day=5) - day6.php Selects risk areas for Day 6. (same as invoking
SPC-placefile.php?day=6) - day7.php Selects risk areas for Day 7. (same as invoking
SPC-placefile.php?day=7) - day8.php Selects risk areas for Day 8. (same as invoking
SPC-placefile.php?day=8)
For ease of usage, the above 8 scripts should be the end-point targets for the GRLevelX placefile manager window.
The cache files are named SPC-N.json (N=1..8) and are created/maintained automatically with a default 8 minute cache lifetime.
This script generates a GRLevelX placefile from the cached JSON
file from SPC GIS on demand by a GRLevel3 instance.
If you run the script for debugging in a browser, add ?version=1.5&dpi=96&lat={latitude}&lon={longitude} to
the URL so it knows what to select for display. The output of the script is always text/plain;charset=ISO-8859-1 for the placefile.
Viewing the placefile in a browser will show GRLevel3 comments (lines starting with ';') showing how each alert is handled.
In the GRLevel3 placefile manager window, just add the script URL without a query string -- GRLevel3 will automatically add those based on the current radar site selected.
Additional documentation is in each script for further modification convenience.
Upload the files/directories into a directory under the document root of your website.
(We used 'placefiles' in the examples below)
Then you can test the placefile script by using your browser to go to
https://your.website.com/placefiles/day1.php?version=1.5&dpi=96&lat=37.0&lon=-122.0
If that returns a placefile, then add your placefile URL (minus the URL query string) into the GRLevelX placefile manager window.
# -----------------------------------------------
# Settings
$timeFormat = "d-M-Y g:ia T"; # display format for times
$cacheFilenameTemplate = 'SPC-%s.json'; # store json cache file
$cacheTimeMax = 480; # number of seconds cache is 'fresh'
$doLogging = true;
$doDebug = false; # =true; turn on additional display, may break placefile for GRLevelX
$TZ = "America/Los_Angeles";
$SPCcolors= false; # =true, use JSON 'stroke' color; =false, use built-in colors
$latitude = 37.155;