Description
Reports are acquire from the Storm Prediction Center via a comma delimited file along with the associated map. Data is separated, sorted and put into a cache file while the map is converted to a ping file with more vibrant colors.
The script reads the data and formats it so it can be easy understood.
Features:
- No page scraping. Data and maps are downloaded in files for fast processing
- Easily adapts to your web page scheme
- User can get reports for all dates starting in 2005
- Dates and times of events are listed according to your time zone
Installation & Setup
You will not need to use all of the files extracted in the SPC zip file. Three of the files are for the SPC reports and each one is used differently depending on your web page set up. The other file is a small "png" file that is used as a background for each report.
Below is a description of the files and how to use them.
inc-SPCreports.php - The file to "include" in your web page. Instead of putting all of the code into a page, you would just include this file. This file is uploaded to the web folder where your web pages are located.
wxSPCreports.php - Use with the Carter Lake template package version 3. The SPC file is already included in this file. This file is uploaded to the web folder where your web pages are located.
SPCreports.php - This is a stand alone page. It is intended to be used by itself if that's all you want to display. It validates as XHTML 1.0 Strict.
bar5.png - A background image for the bar at each report. This image file is uploaded to the web folder where your images are stored.
Settings
inc-SPCreports.php
$upTime = 600; // time in seconds to retain cache file before updating 600=10 minutes 3600=60 minutes
Time in seconds to retain the cache file, and map, before updating.
$cacheFileDir = './cache/'; // default cache file directory
Folder/directory where the cache files will be written, used, and deleted when expired.
$ourTZ = 'America/New_York'; // Time Zone http://www.php.net/manual/en/timezones.america.php
Time zone of your location. All dates and times reflect on this setting. The link listed is where you can find the name of your time zone.
$sortEvent = 'latest'; // sort events by by 'severity' 'latest' 'first' 'state'
Default sorting of the reports. Choose from the latest reports first in descending order, the first report in ascending order, severity, or by state name. Selecting 'severity' displays the reports like the SPC's web site.
$divWidth = '630px'; // total width - minimum: 580px - Examples: 640px 90%
Width of the entire SPC reports. Adjust this to fit the width to your likings. The map is 578 pixels wide so the minimum setting should not be below 580px.
$showWFO = true ; // true= show weather forecast office false=don't show weather forecast office
Enables or disables the Weather Forecast Office being displayed at the end of each event.
$longWFO = true; // true=show (City, State) for WFO false=show WFO code (IWX) used only is above is true
If you have enabled the WFO to be displayed, you can choose to display the short WFO code of the city and state where the office is located. Example: true = (Los Angeles, CA) false = (LOX)
$imagesDir = './ajax-images/'; // path to image folder
Folder/directory where the small 'bar5.png' image file is placed.
$enhanceMap = true; // true=enhance map colors false=use original map
true=used enhanced map colors false=use original SPC map. No image processing.
COLORS
$bkgColor = '#EEE'; // Background color Examples: "gray" "#CCC" "#CCCCCC"
Background color for the entire reports.
$tBkg = '#FAEBEB'; // Tornado report background color RED
Background color for tornado reports.
$tFont = '#500'; // Tornado report font color red tint
Font color for tornado reports.
$wBkg = '#EBEBFA; // Tornado report background color BLUE
Background color for wind reports.
$wFont = '#005'; // Wind report font color blue tint
Font color for wind reports.
$htBkg = '#EBFAEB; // Hail report background color GREEN
Background color for hail reports.
$htFont = '#050'; // Hail report font color green tint
Font color for hail reports.
$dtColor = '#FC0'; // Date & time color Examples: "#FC0" "#FFCC00" "white"
Font color for the date and time at the top of each event.
If you do not use the Carter Lake templates
That's OK. You can use this program in any other web page as long as you include the key file
inc-SPCreports.php. You will not need the file named wxSPCreports.php.
Open the web page that you want to display the SPC reports. Decide where you want the reports displayed and insert this PHP line:
<?php include("inc-SPCreports.php"); ?>
Save the page and upload it back to the web server.
Uploading
After you have made changes in the inc-SPCreports.php file, save the file and upload it to the folder where your web pages are stored.
Upload bar5.png to the same folder where your images are stored. It will be the same location as set at $imagesDir .
Errors
Errors can happen.
I am no authority on YOUR web server however this program works on mine and on the servers that this program was beta tested on.
If an error does happen, most likely it is a permission level setting that your web host has placed restrictions on regarding the writing, reading, and deleting of files.
To troubleshoot errors, you can turn on the error reporting by un-commenting two lines in the inc-SPCreports.php file. Remove the double slashes before ini_set('display_errors', 1); and error_reporting(E_ALL); on lines 69 and 70. Errors shown will relate to the issues that you may be able to correct. After troubleshooting, comment those two lines by adding the double slashes.
If you are using the Carter Lake version3 template page supplied, you will get errors if your Carter Lake setup is version 2. This page does not mix with the older version.
Known Issues
Data downloaded from the SPC is in a comma delimited file. That means the data for a single event is separated by commas such as the time of event, the weather event, city, state, latitude, longitude, and comment. In some instances, the reports have extra commas placed in them and that will throw off the data causing undesired results. If you see this happen, email me and give me the details and date of the report.
Maps and data are not always updated at the same time by the SPC. The map may indicate X amount of reports while the data shows a different amount. This is due to the timing when these reports are originally posted by the SPC. Usually these even out as time goes by.
Contact Me
Email is the only way to contact me about this program.
curly@ricksturf.com
If you have question, I will need detailed information. Supply a link to the SPC report web page and details.
I answer all of my emails so don't hesitate on contacting me!