Thread: Generating weather maps
Brought to you by:
iridium
From: Jonas K. <me...@j0...> - 2004-03-03 20:22:37
|
Hello there, as Martin posted some days ago, I developed a little weather map with the help of phpWeather(see: http://www.j0nes.de/wetter/ - be patient, a lot of METARs have to be fetched *g* - but weather.noaa.gov seems to be down, so no data for now). Together with the idea of having lat/long-data for every station in the database, it would be possible to generate those maps for every country on the fly. I just checked how to figure out the positions on the map with latitude and longitude, and this works quite well - assuming that we have the exact location and range of the map. A problem might be to find suitable map data for each country. But... I found a nice Sourceforge project called GeoClass. It has some very nice features such as converting lat/long-positions to x/y-positions, getting position data from DB and storing them in a GeoObject or, even better, generating maps out of a .e00-textfile. You can find this project here: http://sourceforge.net/projects/geoclassphp/ I will have to take a closer look at this project. With the help of those classes weather map generation might get a lot easier. Cu Jonas Kaufmann |
From: Phil P. <phi...@sw...> - 2004-03-04 00:10:26
|
Very nice. A simple workaround for the "it's not fast" issue would be to schedule (eg cron) the map generation rather than recalculating it for each Page View. I believe most METARS are only released on an hourly schedule, though I think I recall reading somewhere that some locations generate half-hourly ones. One simple thing I'd always thought would look nice was a worldmap with every METAR station pinpointed. ImageMap to select a country, then show (for example) your country weather map, and image-map to get detailed METAR report. Phil P Jonas Kaufmann wrote: > Hello there, > > as Martin posted some days ago, I developed a little weather map with > the help of phpWeather(see: http://www.j0nes.de/wetter/ - be patient, > a lot of METARs have to be fetched *g* - but weather.noaa.gov seems to > be down, so no data for now). > Together with the idea of having lat/long-data for every station in > the database, it would be possible to generate those maps for every > country on the fly. > > I just checked how to figure out the positions on the map with > latitude and longitude, and this works quite well - assuming that we > have the exact location and range of the map. > A problem might be to find suitable map data for each country. > > But... I found a nice Sourceforge project called GeoClass. It has some > very nice features such as converting lat/long-positions to > x/y-positions, getting position data from DB and storing them in a > GeoObject or, even better, generating maps out of a .e00-textfile. > You can find this project here: http://sourceforge.net/projects/geoclassphp/ > I will have to take a closer look at this project. With the help of > those classes weather map generation might get a lot easier. > > Cu > Jonas Kaufmann > > > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > PHPWeather-devel mailing list > PHP...@li... > https://lists.sourceforge.net/lists/listinfo/phpweather-devel > > |
From: Jonas K. <me...@j0...> - 2004-03-04 11:20:33
|
Hello, > A simple workaround for the "it's not fast" issue would be to schedule > (eg cron) the map generation rather than recalculating it for each Page > View. Yes, this would be really useful. I already use a simple sort of caching, that is generating the map on the first request and storing it. Every other request in the next half hour gets the cached version of the map. Image generation itself is quite fast, getting all METARs takes a lot of time. So perhaps scheduling the METAR fetch might be sufficient. Another problem is that I have to fetch the METARs twice - one time in the map-generating script, the other time in the HTML-page to display the onMouseOver-Information for every station. Even with the built-in caching of phpWeather, I still have to query my database two times. Has anybody got an Idea how to solve this? > One simple thing I'd always thought would look nice was a worldmap with > every METAR station pinpointed. ImageMap to select a country, then show > (for example) your country weather map, and image-map to get detailed > METAR report. Nice idea. World map generation can also be done with the script I use. We also need positions for every country, so it would even be possible to generate the ImageMap to select a country dynamically. Cu Jonas |
From: Phil P. <phi...@sw...> - 2004-03-05 02:20:09
|
Jonas Kaufmann wrote: >>A simple workaround for the "it's not fast" issue would be to schedule >>(eg cron) the map generation rather than recalculating it for each Page >>View. > > > Yes, this would be really useful. I already use a simple sort of > caching, that is generating the map on the first request and storing > it. Every other request in the next half hour gets the cached version > of the map. Image generation itself is quite fast, getting all METARs > takes a lot of time. So perhaps scheduling the METAR fetch might be > sufficient. I use the PHP/PEAR Cache::Lite module to do my caching, nice and fast and pretty functional. > Another problem is that I have to fetch the METARs twice - one time in > the map-generating script, the other time in the HTML-page to display > the onMouseOver-Information for every station. Even with the built-in > caching of phpWeather, I still have to query my database two times. > Has anybody got an Idea how to solve this? Have the HTML page do the query, and send the data in the URL to the map generate script. Caching this is *trivial* with the Cache::Lite module. /* near the start of your script */ require 'Cache/Lite/Output.php'; $cacheOptions = array( 'cacheDir' => "/full/path/to/cache/directory", //NB cacheDir needs g+wx permissions ); $Cache_Lite = new Cache_Lite_Output($cacheOptions); /* when you need to cache something */ $cacheID = substr($_SERVER["REQUEST_URI"],0,strcspn($_SERVER["REQUEST_URI"],'#')); $Cache_Lite->setLifeTime(30*60); // cache LifeTime is in Seconds $cacheGroup = "weatherMap" ; // :-) just pick a friendly group name if(! ($Cache_Lite->start($cacheID,$cacheGroup))) { /* code here to generate page/image when not cached or cache is invalid */ $Cache_Lite->end(); } $cacheID is the unique identifier of what you're caching $cacheGroup is a name to group multiple cacheIDs (eg you can "flush ThisGroup from the cache", as opposed to flushing TheWholeCache) >>One simple thing I'd always thought would look nice was a worldmap with >>every METAR station pinpointed. ImageMap to select a country, then show >>(for example) your country weather map, and image-map to get detailed >>METAR report. > > > Nice idea. World map generation can also be done with the script I > use. We also need positions for every country, so it would > even be possible to generate the ImageMap to select a country > dynamically. You mean simply Lat/Long for each station? I've been looking in to that, (checkout my earlier posts in the archives) we can get the data easily (I just need to get my act together and clean it up and thunk it into the METAR station table) Enjoy, Phil P |
From: Jonas K. <me...@j0...> - 2004-03-05 10:39:56
|
Hello, > Have the HTML page do the query, and send the data in the URL to the map > generate script. Caching this is *trivial* with the Cache::Lite module. > [snip] Thanks, I will try this. >>>One simple thing I'd always thought would look nice was a worldmap with >>>every METAR station pinpointed. ImageMap to select a country, then show >>>(for example) your country weather map, and image-map to get detailed >>>METAR report. >> Nice idea. World map generation can also be done with the script I >> use. We also need positions for every country, so it would >> even be possible to generate the ImageMap to select a country >> dynamically. > You mean simply Lat/Long for each station? I've been looking in to that, > (checkout my earlier posts in the archives) we can get the data easily > (I just need to get my act together and clean it up and thunk it into > the METAR station table) No, we also need the positions of the upper left corner and the lower right corner of the map in addition to the lat/long-data for each station. Perhaps we could create a new table pw_countries (cc, country, min_lat, max_lat, min_long, max_long) to store this information. pw_stations could then be reduced to pw_stations(icao, cc). I don't know whether phpWeather uses the country field from pw_stations. Cu Jonas |
From: Jonas K. <me...@j0...> - 2004-04-18 18:01:35
|
Hello, I updated my approach to generate weather maps for every country with phpWeather. You can see the current version at http://www.j0nes.de/wetter/. Currently I included maps for Denmark, France, Germany and Spain, but other maps can also be integrated. I found a very useful class named Geoclass at http://sourceforge.net/projects/geoclassphp/. Geoclass can draw maps out of .e00 textfiles (which are freely available for almost every country at http://www.maproom.psu.edu/dcw/) and also does the transformation from latitude/longitude values to x/y-positions on the map. A drawback is that I need several values for every map that you have to figure out first (try and error), for example the range in latitude/longitude for this country or the size of the map in pixels and thus the width-to-height-ratio. What about the latitude/longitude values for all weather stations? Phil, browsing the archive I found postings that you had an idea how to put those values in the pw_stations table. Did you advance in this? Cu Jonas Kaufmann |