Welcome to Geeklog, Anonymous Wednesday, December 04 2024 @ 04:31 pm EST

Geeklog Forums

Weather Forecast for U.S. cities


Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
I’ve created a quick port of a phpWebsite module so that Geeklog sites in the United States can provide local weather forecasts. For more about the original idea for this, see this story.

This uses http://www.crh.noaa.gov/zipcity.php?inputstring=95821 (where you change the specific zip to get different cities) and some magic that parses the Web page so that it can be displayed using locally stored icons and wrapped inside Geeklog. You can see an example here.

The forecast data is cached for a specified period of time.

This is NOT a full port of the original module. I’ll leave that to people who need international weather forecasts. However, this can be easily incorporated into squatty’s weather block. You can see an example here.

The files and installation instructions are available here.

John Hughes

 Quote

Status: offline

Tony

Site Admin
Admin
Registered: 12/17/01
Posts: 405
Location:Urbandale, Iowa
Impressive! I did find a small bug. If you type in my area code (50310) you get the content OK but the block headers don't show up. I'll install on my site tonight and see if i can't fix it.---The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.
 Quote

Status: offline

Tony

Site Admin
Admin
Registered: 12/17/01
Posts: 405
Location:Urbandale, Iowa
It appears that none of the preg_replace() calls work in replace_titleimages(). Any ideas?---The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
This is a problem with NOAA using different templates in different regions. That's one of the big problems with just taking NOAA's html and then massaging it. It ought to be easy enough to fix but I've got no idea how many different templates NOAA uses.
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
This weather forecast is a straight copy of the NOAA imformation. As a result, any variation in the NOAA template causes a problem. In this case, the title image coding was broken in two lines. Rather than figure out how to test for that and fix it, I've decided to leave the title images as icons.

I've updated the index.php to convert the title images to local icons and added the title icons to the icons folder. The package is available here.

John Hughes

 Quote

cdriscoll

Anonymous
A quick note: You will need to create the images/fcicons folder in your weather directory and move the jpg's into that folder for it to work with the current index.php file. Great addition John!
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
I do not believe you have to do this. I've just re-installed the distribution index.php and it works with weather/icons/ as the folders. The index.php changes all of the image src to the local icon folder specified. The default is weather/icons. The title images have been added to the weather/icons/ folder with all of the other icons.
 Quote

cdriscoll

Anonymous
Ok. Maybe I did something wrong, but mine did work when I created that folder with the new index.php file. So it remains a suggestion for anyone that runs into trouble.
 Quote

cdriscoll

Anonymous
Also, what URL is the 2 Day History, More Local Wx, and Hazardous Weather Outlook supposed to be. It seems to be referencing files on my local site that do not exist. Am I missing some files, or is the URL supposed to go out the the noaa.gov site?
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
This a bug in the translation of the NOAA page to the local site. The URLs that appear under Detailed 7-Day Forecast need to be translated.
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
I've fixed this so that the URLs are correct.

The original module changed all URLs to local files that localized the additional information. That would be a great feature to restore, but for right now all I want is the local information and for all the links to go to the correct NOAA site.

I've checked this on a couple of different zips and it appears to work OK.

Just replace the index.php (after you modify the defaults)

The files have been updated here

 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
Remember that the weather forecast information is cached in the database. If you are replacing index.php and trying to see if it fixes a problem you need to either empty the cache manually using phpMyAdmin or use a different zip code that you haven't tried in the last hour. In a perfect world there would be an admin page with a purge cache feature, but that will have to wait.
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
I've created an alternate version of the index.php that correctly strips out the title icons -- 7-Day Forecast, etc. -- from the original NOAA HTML.

The advantage is that the page loads a little faster since it has five fewer images. I also like the flexibility of using style.css to modify the section titles.

This version appears to work in both Iowa and California. My first effort didn't like Iowa. If you notice a region where the title icons don't get replaced, let me know.

The examples listed in the original post use the alternate version with the title images replaced with text.

Both the original version and the alternate are available here.

 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
The Local Weather Forecast add-on that I created may have caused a database corruption problem I had on one of my sites. I have changed the way the cached information is handled (added slashes to data) and I have not had a recurrence of the sql errors that I believe may have damaged my site's database. Before I made this change I was getting sql errors when the data was stored in the cache. This did not happen every time. Just sometimes. But it seemed to happen more often with certain zip codes. (Perhaps caused by regional differences in the original html.) The file links in the original story will take you to the new version.
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
The examples mentioned in the original article showing how the standalone 7-day weather forecast works with squatty's weather block have been removed. The weather block distributed by squatty incorporates the 7-day weather feature.
 Quote

All times are EST. The time is now 04:31 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content