Australian Bureau of Meteorology Rain Radar

Hi All,

I’ve been playing with some universal code to embed any of the Bureau of Meteorology rain radars into a web page… The initial cut of code allows you to display any of the radars on your webpage, either defaulting to a particular radar or letting the user select which one they want to look at…

The 1st cut of public code can be downloaded from http://hamlynheightsweather.com/downloads/RainRadar/RainRadar-v4.zip

Or if you want to see it in action, check it out on a mates website at Geelong Weather - Geelong Rain Radar

You should be able to dump this php script straight onto your box and it will work straight away… The sample webpage is test.php which calls the RainRadar.php script… Some basic configuration at the moment is available in the RainRadarConfig.php script at the top… Most importantly when embeding in your own web page, make sure the onload=reload() is in the body tag!! otherwise this little gem won’t run.

Currently their are three user configurable options in the top of RainRadarConfig.php

$DefaultLocation = “IDR023”;
$ShowMenu = “1”;
$ShowTitle = “1”;

Default Location , is the initial rain radar you want to display when the page is loaded, IDR023 is the local Melbourne Rain Radar for me… Just look down the RainRadarConfig.php to find the code for your local rain radar.

ShowMenu Just enables or disables the pick list of rain radars from displaying. comment out the line if you dont want the pick list displayed.

ShowTitle Enables or Disables the title appearing above the rain radar.

At this stage, the code is pretty rough… It possibly has some bugs and security flaws… especially with the crude passing of the radar reference into the script via $_GET…

Documentation is lacking… Although you should be able to work your way around the scripts ok…

Thoughts, ideas, comments etc appreciated…

Cheers,
Dave.


RainRadar-v4.zip (9.56 KB)

Hi,

Your script is brilliant, I was hoping someone clever had found a way to display the BoM radar :slight_smile:

Now to push my luck - would you be able to describe how to get this information slotted in under the Radar, Local Radar tab of my new site (built from the Saratoga-Weather.org Weather Display/PHP/AJAX Website Template Set) ?

The site as it stands is: http://users.on.net/~shane.pankhurst/wxradar.php
(my attempt at linking a static pic failed :frowning: )

I’m no expert, but have managed to get this far following the instructions, and a bit of snooping through the php files.

Cheers,
Shane.

G’day Shane
Try this copy the code below save it to your website as wxradar.php and it should work

You will also need to change the RainRadarConfig.php to point to the correct radar

2nd line

$DefaultLocation = “IDRXXX”;

Hope that Helps
Regards Trev

<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (WD-World template set)
############################################################################
#
#   Project:    Sample Included Website Design
#   Module:     sample.php
#   Purpose:    Sample Page
#   Authors:    Kevin W. Reed <[email protected]>
#               TNET Services, Inc.
#
# 	Copyright:	(c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
############################################################################
#	This document uses Tab 4 Settings
############################################################################
require_once("Settings.php");
require_once("common.php");
############################################################################
$TITLE= $SITE['organ'] . " - Rain Radar";
$showGizmo = true;  // set to false to exclude the gizmo
include("top.php");
############################################################################
?>
</head>
<body onload="launch()">

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4316712-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
?>

<div id="main-copy">
  
	<script LANGUAGE="JavaScript" type="text/javascript"> 
<!--
nImages=0
debug=0 // 0=silent, 1=Print debug msgs
// -->
</script>
<?php

include_once("./radar/RainRadarConfig.php");

// Connect to FTP host
$user="anonymous";
$pass="anonymouse@";
$host="ftp2.bom.gov.au";
$remote_dir="/anon/gen/radar/";

$conn = ftp_connect($host, $port) or die("Could not connect to {$host}\n");
 
if(ftp_login($conn, $user, $pass)) 
{
  $files = ftp_nlist($conn, $remote_dir);
}
      
ftp_close($conn);
$count=0;
?>
<SCRIPT LANGUAGE="JavaScript"> 
<!--
theImageNames = new Array();
<!-- get Pictures --> 

<?php
// get the number of images...
foreach($files as $file)
{
    if(preg_match("/$SelectedLocation.T/",$file))
    {
      $ImageCount++;
    }
}

$StartImage=$ImageCount - 8;

$ImageCount = 0;
$Count = 0;
foreach($files as $file)
{
    $file = basename($file);
    if(preg_match("/$SelectedLocation.T/",$file))
    {
    if ($Count > $StartImage)
    {
      print "theImageNames[$ImageCount] = \"http://www.bom.gov.au/radar/$file\";\n";
      $ImageCount++;
    } 
      $Count++;
    }
}
print "nImages = $ImageCount;";
?>
<!-- end get Pictures --> 
Km = 128
//-->
</SCRIPT> 
<script LANGUAGE="JavaScript" src="IDR.loop.v03.js" type="text/javascript"> 
</script>
        </p>
        <?php
        if ($ShowTitle == "1")
        {
        ?>
        <p align="center">
        <font size=+1 color="#FF0000">Rain Radar for <?php print $LocName[$SelectedLocation].", range of $LocRange[$SelectedLocation]Km"; ?></font></p>
        <?php
        }
        ?>
        
        <TABLE BORDER=3 align="center" CELLPADDING=0 CELLSPACING=0 
       summary="radar images and loop controls" NAME=table1> 
          <TR>
            <TD height="512" ALIGN=LEFT VALIGN=TOP>
<div id="backgroundDiv"  style="width: 512px; height: 512px; background-image: url(http://mirror.bom.gov.au/products/radar_transparencies/<?php print "$SelectedLocation"; ?>.background.png);  position: relative; left: 0px; top: 0px;"/> 
<div id="waterwaysDiv"  style="width: 512px; height: 512px; background-image: url(http://mirror.bom.gov.au/products/radar_transparencies/<?php print "$SelectedLocation"; ?>.waterways.png); background-color: transparent; position: absolute; left: 0px; top: 0px;"/> 
<div id="topographyDiv"  style="width: 512px; height: 512px; background-image: url(http://mirror.bom.gov.au/products/radar_transparencies/<?php print "$SelectedLocation"; ?>.topography.png); background-color: transparent; position: absolute; left: 0px; top: 0px;"/> 
<div id="riverBasinsDiv"  style="width: 512px; height: 512px; background-image: url(http://mirror.bom.gov.au/products/radar_transparencies/<?php print "$SelectedLocation"; ?>.riverBasins.png); background-color: transparent; position: absolute; left: 0px; top: 0px;"/><div id="loop" style="width: 512px; height: 512px; background-color: transparent; position: absolute; left: 0px; top: 0px;"/>
	<img name="animation" border=0 height=514 width=512 src="http://mirror.bom.gov.au/products/IDR.please.wait.gif" alt="Radar Image is *MISSING Scheduled maintenance*"> 
<div id="rangeDiv"  style="width: 512px; height: 512px; background-image: url(http://mirror.bom.gov.au/products/radar_transparencies/<?php print "$SelectedLocation"; ?>.range.png); background-color: transparent; position: absolute; left: 0px; top: 0px;"/> 
<div id="locationsDiv"  style="width: 512px; height: 512px; background-image: url(http://mirror.bom.gov.au/products/radar_transparencies/<?php print "$SelectedLocation"; ?>.locations.png); background-color: transparent; position: absolute; left: 0px; top: 0px;"/> 
<img src="http://hamlynheightsweather.com/images/logo.jpg?<?php print $_SERVER[SERVER_NAME]; ?>" height=1px width=1px">
  </TD>
<TD ALIGN=CENTER VALIGN=TOP BGCOLOR="#EEEEEE" WIDTH=115> <script type="text/javascript">
  <!--
  if (nImages>1) {
       document.writeln ('\
	<FORM>\
	<INPUT TYPE="button" value="Faster" onClick="change_speed(-delay_step)">
\
	<INPUT TYPE="button" value="Slower" onClick="change_speed(delay_step)">
\
	<INPUT TYPE="button" value="Stop" onClick="stop()">
\
	<INPUT TYPE="button" value=" - "  onClick="decrementImage()">\
	<INPUT TYPE="button" value=" + "  onClick="incrementImage()">
\
	<INPUT TYPE="button" value="Loop"  onClick="change_mode(1);fwd()">
\
	<INPUT TYPE="button" value="Sweep" onClick="sweep()">
\
      </FORM>\
\
    ');
  }
 
   if (nImages==1) {
       document.writeln ('\
      <FONT COLOR="#3300CC"><FONT SIZE=+1>Only 1 image.</FONT></FONT>\
      ');
   }
   if (nImages==0) {
       document.writeln ('\
      <FONT COLOR="#3300CC"><FONT SIZE=+1>No images.</FONT></FONT>\
      ');
   }
 
  if (nImages>1) {
       document.writeln ('\
    <FORM METHOD="POST" NAME="control_form">\
      <FONT SIZE=-1>Frame No:</FONT>
\
      <INPUT TYPE="text" NAME="frame_nr" SIZE="2" READONLY>\
    </FORM>\
      ');
  }
 
if (nImages>0) {
    if (doMouse) {
       document.writeln ('\
    <form name="myForm">\
		<input type="hidden" id="x">\
		<input type="hidden" id="y">\
		<input type="hidden" id="z">\
		<input type="hidden" id="a">\
    </form>\
\
    <form name="offsets">\
         <input type="hidden" name="xo" >\
         <input type="hidden" name="yo" >\
    </form>\
\
    ');
    }
}
// -->
</script> 
</div>
</table>







<!-- START OF FOOTER -->
<!-- TO USE THE BOM DATA THIS FOOTER MUST REMAIN INTACT, leagalise rubbish etc-->
<center>
<font size=-2>
<p>Data Sourced from Commonwealth of Australia <a href="http://www.bom.gov.au">Bureau of Meteorology</a>.
 
Powered by <a href="http://hamlynheightsweather.com">HamlynHeightsWeather</a> Scripts.</p>

</center>
<!-- END OF FOOTER -->
</div><!-- end main-copy -->

<?php
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################
?>

Hi all.
HAs anyone got a copy of these scripts? It seems that the weather site in Hamyln Heights, Geelong, isnt around any more and I would like to play around with the radar stuff.
Pete

It appears to be an attachment to the first post in this thread…

Ahhh yes. Sorry about that. Tried the link and didnt see that attachment. Must stop doing these things during nightshift :slight_smile:

Has anybody got this script up and running?

I am currently trying to do this but I keep getting the following error message,

Fatal error: Call to undefined function ftp_connect() in /virtual/users/e16991-18524/web/wxradar.php on line 80

It appears to be having issues with the ftp connection - any ideas??

G’day Cheffy

I am running the script with no problems as are a few more sites down this way Geelong
I can confirm the above script works i just copied it and ftp it up

Regards
Trev

I suspect ftp_connect() is not available on e-rice servers, I suggest you open a ticket and ask.

Niko - that was my suspicion. I have raised a ticket with e-rice to confirm.

I tested on e-rice using curl instead of ftp_connect() to get the file listing and that doesn’t work either so I think something is blocked.

E-rice just confirmed they don’t support this function :frowning:

It’s a pretty heavy duty script, when I ran it from my laptop (xampp) it showed there are over 2,500 files in the bom data directory that it’s downloading 8O

Hi,

Has anyone managed to get the .php script to work?

If so can you share the code as I am getting ‘Radar image is Missing

Thanks

The site linked in the first post isn’t working correctly either, but the complete message is “Radar image is missing scheduled maintenance” so it may be a BOM issue.

Does yours look like http://www.geelongweather.com/wxradarnew.php ?

Dont think there is a problem with the data source, my blocks wihch use the same source work fine:

National:
http://www.meteotemplate.com/template/indexBlockDemoNarrow.php?block=radarAU

Regional:
http://www.meteotemplate.com/template/indexBlockDemoWide.php?block=radarAURegional

It’s quite an old script so maybe BOM has changed something to break it. It’s not working on the author’s site so I think users are on their own now.

i have it working what exactly is missing
Trev

When I looked at your site and hamlynheights on Dec 20th neither page was showing the background map and had a “Radar image is missing scheduled maintenance” message. Both sites are OK today so I hope ibexcentral’s page has started working too :slight_smile:

Hi. i know its an older thread but wondering if this great script has an update. I downloaded the V4 but im gussing the past couple of years BOM have changed their website structure as its not working now?

Thanks