Re: Generating weather maps
Brought to you by:
iridium
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 |