Jump to content

Get Any METAR Form


Jon

Recommended Posts

Hi All,

Just thought this would come in handy basically the user enters the ICAO then the metar will display in an iframe,

Preview:

When no ICAO entered:

a.jpg

When an ICAO code has been entered (EGKK)

b.jpg

<form action="weather" method="post">
Get METAR For:
 <input type="text" name="icao" />
 <input type="submit" />
</form>

Latest METAR:
<iframe src="http://www.vatsim.net/data/metar.php?id=<?php echo $_POST["icao"]; ?>" class="metar" width="200" height="75" frameborder="0" scrolling="no">></iframe>

Kind Regards,

Jon

Link to comment
Share on other sites

  • 1 year later...

I don't like the iframes. That's why I use this:

<?php
$location = "EGLL";

get_metar($location);

function get_metar($location) {
$fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$location.TXT";
$metar = '';
$fileData = @file($fileName) or die('METAR not available');
if ($fileData != false) {
	list($i, $date) = each($fileData); 

	$utc = strtotime(trim($date));
	$time = date("D, F jS Y g:i A",$utc);

	while (list($i, $line) = each($fileData)) {
		$metar .= ' ' . trim($line);
		}
	$metar = trim(str_replace('  ', ' ', $metar));
	}
echo "METAR FOR $location (Issued: $time UTC):<br>$metar";
}
?>

You can change the location to <?php echo $schedule->depicao;?> or arricao in the schedule briefing or details. It's much better than the default METARs in phpVMS because they don't have to load.

Link to comment
Share on other sites

I don't like the iframes. That's why I use this:

<?php
$location = "EGLL";

get_metar($location);

function get_metar($location) {
$fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$location.TXT";
$metar = '';
$fileData = @file($fileName) or die('METAR not available');
if ($fileData != false) {
	list($i, $date) = each($fileData); 

	$utc = strtotime(trim($date));
	$time = date("D, F jS Y g:i A",$utc);

	while (list($i, $line) = each($fileData)) {
		$metar .= ' ' . trim($line);
		}
	$metar = trim(str_replace('  ', ' ', $metar));
	}
echo "METAR FOR $location (Issued: $time UTC):<br>$metar";
}
?>

You can change the location to <?php echo $schedule->depicao;?> or arricao in the schedule briefing or details. It's much better than the default METARs in phpVMS because they don't have to load.

We need to have a form attached to enter the ICAO of choice. When I read this correct it only shows a fixed ICAO or the dep/arricao in a scheduled flight.

post-2881-085226500 1325763772_thumb.jpg

Link to comment
Share on other sites

  • 2 years later...

Hi,

In what tpl did you change it?

I don't like the iframes. That's why I use this:

<?php
$location = "EGLL";

get_metar($location);

function get_metar($location) {
$fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$location.TXT";
   $metar = '';
   $fileData = @file($fileName) or die('METAR not available');
   if ($fileData != false) {
       list($i, $date) = each($fileData); 

       $utc = strtotime(trim($date));
       $time = date("D, F jS Y g:i A",$utc);

       while (list($i, $line) = each($fileData)) {
           $metar .= ' ' . trim($line);
           }
       $metar = trim(str_replace('  ', ' ', $metar));
       }
   echo "METAR FOR $location (Issued: $time UTC):<br>$metar";
   }
?>

You can change the location to <?php echo $schedule->depicao;?> or arricao in the schedule briefing or details. It's much better than the default METARs in phpVMS because they don't have to load.

Link to comment
Share on other sites

I use this script in my briefings, so schedule_briefing.tpl.

If you want it in that, use:

<?php
function get_metar($location){
$fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$location.TXT";
       $metar = '';
       $fileData = @file($fileName) or die('METAR not available');
       if ($fileData != false) {
               list($i, $date) = each($fileData); 

               $utc = strtotime(trim($date));
               $time = date("D, F jS Y g:i A",$utc);

               while (list($i, $line) = each($fileData)) {
                       $metar .= ' ' . trim($line);
                       }
               $metar = trim(str_replace('  ', ' ', $metar));
               }
       echo "METAR FOR $location (Issued: $time UTC):<br>$metar";
}

echo get_metar($schedule->depicao);
echo "</br>";
echo get_metar($schedule->arricao);
?>

Link to comment
Share on other sites

Thank you very much itrobb, for help, so also is possible to put this information over schedule_details.tlp?

I will visit now your site to see.

bruno

itrobb

I use this script in my briefings, so schedule_briefing.tpl.

If you want it in that, use:

<?php
function get_metar($location){
$fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$location.TXT";
$metar = '';
$fileData = @file($fileName) or die('METAR not available');
if ($fileData != false) {
list($i, $date) = each($fileData);

$utc = strtotime(trim($date));
$time = date("D, F jS Y g:i A",$utc);

while (list($i, $line) = each($fileData)) {
$metar .= ' ' . trim($line);
}
$metar = trim(str_replace(' ', ' ', $metar));
}
echo "METAR FOR $location (Issued: $time UTC):<br>$metar";
}

echo get_metar($schedule->depicao);
echo "</br>";
echo get_metar($schedule->arricao);
?>

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...