Re: Iconize weather info and something else
Brought to you by:
iridium
From: Ray v. B. <r_v...@ho...> - 2002-02-10 20:33:18
|
>I've actually got something working - take a look at > > http://www.gimpster.com/php/phpweather/demo2.php?sleep=5 > >The idea is this: > > o Instead of calling print_pretty_metar(), we call some other > function. This function will write 'Please wait...' in a <span> > tag with the id attribute set accordingly. The ICAO is saved in an > array > > o We call flush() after writing 'Please wait...'. This will push the > content from the server toward the client. This will (hopefully) > make the browser start rendering the page, so that the user see > the 'Please wait...' text. The browser wont start rendering the > page, if it doesn't know the size of the box containing the > 'Please wait...' text. > > o At the very end of the page, we go through the stored ICAOs. For > each stored ICAO, we retrieve the METAR, and retrieve the > pretty-print. > > o We then write some JavaScript that will replace the text in the > <span> tags inserted earlier in the text. > > o We call flush() again, so that the JavaScript is sent to the > client, and so that the browser will execute it. > > o We repeat this process until we have made scripts for all the > stored ICAOs. > >It works in my browser (which is Mozilla 0.9.7). It works for me too, IE5.0. Great! One suggestion though, you flush the page each time the function wait_for_report is called. To me, it seems that that is only required once: immediately after the </html> tag. The page is then sent to the browser, and the browser can start processing a complete page. Hmmm, while typing this, I'm not so sure anymore: doesn't the browser disconnect from the server when a complete page is received? If so, the remaining stuff (js with metar data) is not received anymore.... This is from your comment on my original post on icons: >Well, there has been some people working on this, but I haven't >received any code that solves the problem. The problem is (as I see >it) that there isn't a field in the METAR that tells you if the >weather is good or bad. You'll have to combine the information, and >either select an appropriate image from a huge list of ready-made >images, or perhaps generate the image on the fly using the GD library >from within PHP. I've been looking around on the internet. I downloaded several icon sets of which the single icons can be linked to metar-like data. Most of the icon sets concentrate on a combinatation of Sky Cover and Precipitation variants. A few examples: sun, sun with one cloud, sun with a lot of cloads, cloads only, light and heavy rain with different sun/cloud combinations. Thunderstorms with different sun/cloud combinations. Additionally, there are arrows pointing to different directions to indicate the wind direction. What I would like to do in the coming days is creating a table that maps the different icon files to a Sky Cover/Precipitation combination table. A <IMG SRC=icon.php> construction in the webpage calls the icon.php function. This function then searches the table for the proper image file, that is then returned directly. To keep this mechanism 'tunable', the names of the icons files are entered in a include file. If someone likes to take his own set of icons, he only has to change the file names in the include file. As far as I can see it, the icon.php function can use the internal results of the phpweather script. Like I said, I will start my first experiments probably this week, I keep you informed. Bye for now, Ray _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. |