Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.
PLEASE READ - Webmaster Support Forum
This forum will be retired in the near future. Please direct all queries to our dedicated GitHub support page https://github.com/vatsimnetwork/developer-info/discussions 
Here you can find documentation on our services and we are continuing to migrate pertinent information into the Wiki pages https://github.com/vatsimnetwork/developer-info/wiki

VATITA style maps


Luca Benelli
 Share

Recommended Posts

Luca Benelli
Posted
Posted

Having the data.txt file on your file system the following PHP file will generate a map of the kind shown in the following links:

 

http://www.ellebi.org/luca/vatsim/map.php?region=wd&call=0

http://www.ellebi.org/luca/vatsim/map.php?region=i2&call=0

http://www.ellebi.org/luca/vatsim/map.php?region=it

 

You obviously need to set it up to recreate your FIR boundaries and check the code to adapt a couple of parts where italian specific ICAO codes are in use.

 

You will also need to give it the starting images, you can try with my base images which you can find here:

 

http://www.ellebi.org/luca/vatsim/wd.jpg

http://www.ellebi.org/luca/vatsim/i2.jpg

http://www.ellebi.org/luca/vatsim/it.jpg

 

This code is quite old and can surely be cleaned up or made "faster", any usefule changes, please post them back and i'll try to integrate them in this first post.

 

Use it as you like (as long as it's VATSIM related) but keep in mind the data file usage limitations. (status.txt every 24h, data file no more than once every 2 mins and use a random server each time.)

 

Useful sources for the FIR/ARTCC data are the servinfo files, for the maps images mine come from the NASA website.

 

 


<?php
error_reporting(E_ERROR);
//error_reporting(E_ALL);
/**********************
TO DO:
CHECK DATA FILE TIME (report "outdated info")
**********************/

/*********************
If $region is valid let's show something
if no region defined show basic map.
*********************/

$region=$_GET['region'];
//$x=$_GET['x'];
//$y=$_GET['y'];
$call=$_GET['call'];

//if (!isset($region)){
//        $region="wd";
//   }  //!isdfef $region
if (!isset($call)){
       $call=1;
  }

/**********************
Define FIRS and airport positions
**********************/

               $liup=array(
14.98,36.50,14.52,36.82,14.38,36.85,
13.65,37.12,13.18,37.33,13.02,37.33,12.53,37.17,11.95,36.80,11.50,36.62,11.48,37.50,09.05,38.55,
08.97,38.47,08.80,38.58,08.85,38.63,08.00,39.20,08.00,39.98,07.62,40.15,07.38,40.47,07.37,40.73,
07.45,40.92,07.60,41.08,07.88,41.22,08.32,41.32,09.48,41.32,09.73,41.67,9.75,43.17,7.70,43.73,
7.75,43.82,7.77,43.92,7.75,44.02,7.62,44.13,7.25,44.15,7.07,44.80,
7.15,44.97,6.95,45.18,7.30,45.73,7.33,45.78,7.38,45.90,7.45,45.92,7.53,45.97,7.87,45.93,
8.05,46.03,8.10,46.25,8.32,46.38,8.62,46.13,8.87,46.17,9.03,46.15,9.25,46.50,9.48,46.35,
9.70,46.27,9.98,46.38,10.18,46.25,10.05,46.43,10.25,46.60,10.43,46.52,10.43,46.83,10.48,46.93,10.40,47.00,
11.25,46.97,11.37,46.97,11.65,46.97,12.27,46.80,12.58,46.70,13.25,46.50,13.40,46.27,13.47,46.22,
13.60,46.18,13.58,45.85,13.47,45.38,12.98,45.22,13.08,44.98,13.32,44.52,14.50,43.50,14.48,43.33,
14.78,43.30,15.28,42.98,15.73,42.70,
16.03,42.50,16.12,42.47,16.08,42.37,16.17,42.32,16.33,42.33,17.23,41.92,17.60,41.75,17.75,41.92,
18.18,41.92,18.58,41.85,18.68,41.47,18.55,41.28,18.87,41.12,18.95,40.88,19.00,40.75,19.00,36.50,
               );

               $lirr=array(
9.75,43.17,9.52,43.50,9.77,43.55,10.27,43.73,10.25,43.90,10.37,43.92,10.47,43.92,10.52,43.62,
10.78,43.67,11.00,44.02,11.18,43.80,11.63,43.67,11.87,43.50,12.38,43.22,12.67,43.05,13.12,42.87,
13.65,42.27,14.07,41.80,14.37,41.42,15.12,41.20,15.42,40.68,15.62,40.33,15.12,40.13,14.98,40.00,
14.75,39.80,14.27,39.30,14.35,38.82,14.97,37.93,14.95,37.45,14.98,36.50,14.52,36.82,14.38,36.85,
13.65,37.12,13.18,37.33,13.02,37.33,12.53,37.17,11.95,36.80,11.50,36.62,11.48,37.50,09.05,38.55,
08.97,38.47,08.80,38.58,08.85,38.63,08.00,39.20,08.00,39.98,07.62,40.15,07.38,40.47,07.37,40.73,
07.45,40.92,07.60,41.08,07.88,41.22,08.32,41.32,09.48,41.32,09.73,41.67,
               );

               $limm=array(
9.75,43.17,7.70,43.73,7.75,43.82,7.77,43.92,7.75,44.02,7.62,44.13,7.25,44.15,7.07,44.80,
7.15,44.97,6.95,45.18,7.30,45.73,7.33,45.78,7.38,45.90,7.45,45.92,7.53,45.97,7.87,45.93,
8.05,46.03,8.10,46.25,8.32,46.38,8.62,46.13,8.87,46.17,9.03,46.15,9.25,46.50,9.48,46.35,
9.70,46.27,9.98,46.38,10.18,46.25,10.05,46.43,10.25,46.60,10.43,46.52,10.43,46.83,10.48,46.93,
10.40,47.00,11.25,46.97,11.37,46.97,11.65,46.97,12.27,46.80,12.58,46.70,13.25,46.50,13.40,46.27,
13.47,46.22,13.60,46.18,13.58,45.85,13.47,45.38,12.98,45.22,13.08,44.98,13.32,44.52,14.50,43.50,
14.48,43.33,14.13,43.15,13.67,43.25,13.32,43.07,13.12,42.87,12.67,43.05,12.38,43.22,11.87,43.50,
11.63,43.67,11.18,43.80,11.00,44.02,10.78,43.67,10.52,43.62,10.47,43.92,10.37,43.92,10.25,43.90,
10.27,43.73,9.77,43.55,9.52,43.50,9.75,43.17,
);

               $libb=array(
13.12,42.87,13.32,43.07,13.67,43.25,14.13,43.15,14.48,43.33,14.78,43.30,15.28,42.98,15.73,42.70,
16.03,42.50,16.12,42.47,16.08,42.37,16.17,42.32,16.33,42.33,17.23,41.92,17.60,41.75,17.75,41.92,
18.18,41.92,18.58,41.85,18.68,41.47,18.55,41.28,18.87,41.12,18.95,40.88,19.00,40.75,19.00,36.50,
16.45,36.50,15.62,36.50,14.98,36.50,14.95,37.45,14.97,37.93,14.35,38.82,14.27,39.30,14.75,39.80,
14.98,40.00,15.12,40.13,15.62,40.33,15.42,40.68,15.12,41.20,14.37,41.42,14.07,41.80,13.65,42.27,
13.12,42.87,
       );

               $lipp=array(
11.00,44.02,10.00,45.27,9.98,45.47,10.10,45.55,10.62,45.55,10.62,45.73,10.42,45.80,10.12,46.03,
9.98,46.38,10.18,46.25,10.05,46.43,10.25,46.60,10.43,46.52,10.43,46.83,10.48,46.93,10.40,47.00,
11.25,46.97,11.37,46.97,11.65,46.97,12.27,46.80,12.58,46.70,13.25,46.50,13.40,46.27,13.47,46.22,
13.60,46.18,13.58,45.85,13.47,45.38,12.98,45.22,13.08,44.98,13.32,44.52,14.50,43.50,14.48,43.33,
14.13,43.15,13.67,43.25,13.32,43.07,13.12,42.87,12.67,43.05,12.38,43.22,11.87,43.50,11.63,43.67,
11.18,43.80,11.00,44.02,
               );

//ELENCO APP
$app['LIMM']=array(45.28,9.17);
$app['LIRR']=array(41.81,12.25);
$app['LIBA']=array(41.54,15.72);
$app['LIBC']=array(38.0,17.8);
$app['LIBD']=array(41.14,16.76);
$app['LIBF']=array(41.43,15.54);
$app['LIBG']=array(40.52,17.40);
$app['LIBP']=array(42.44,14.19);
$app['LIBR']=array(40.66,17.95);
$app['LIBV']=array(40.77,16.93);
$app['LICA']=array(38.91,16.24);
$app['LICC']=array(37.47,15.6);
$app['LICD']=array(35.50,12.62);
$app['LICG']=array(36.81,11.97);
$app['LICJ']=array(38.18,13.10);
$app['LICR']=array(38.7,15.65);
$app['LICT']=array(37.91,12.49);
$app['LICZ']=array(37.41,14.92);
$app['LIEA']=array(40.63,8.29);
$app['LIED']=array(39.35,8.97);
$app['LIEE']=array(39.25,9.6);
$app['LIEO']=array(40.90,9.52);
$app['LIET']=array(39.92,9.68);
$app['LIMC']=array(45.63,8.72);
$app['LIME']=array(45.67,9.70);
$app['LIMF']=array(45.20,7.65);
$app['LIMG']=array(44.4,8.13);
$app['LIMJ']=array(44.41,8.84);
$app['LIML']=array(45.45,9.28);
$app['LIMN']=array(45.53,8.67);
$app['LIMP']=array(44.82,10.29);
$app['LIMZ']=array(44.55,7.62);
$app['LIPA']=array(46.3,12.60);
$app['LIPB']=array(46.46,11.33);
$app['LIPC']=array(44.23,12.31);
$app['LIPE']=array(44.53,11.29);
$app['LIPH']=array(45.65,12.20);
$app['LIPI']=array(45.98,13.6);
$app['LIPK']=array(44.20,12.7);
$app['LIPL']=array(45.44,10.27);
$app['LIPO']=array(45.43,10.33);
$app['LIPQ']=array(45.83,13.47);
$app['LIPR']=array(44.2,12.61);
$app['LIPS']=array(45.69,12.8);
$app['LIPT']=array(45.57,11.53);
$app['LIPU']=array(45.40,11.85);
$app['LIPX']=array(45.40,10.89);
$app['LIPY']=array(43.62,13.36);
$app['LIPZ']=array(45.51,12.35);
$app['LIQS']=array(43.26,11.25);
$app['LIRA']=array(41.80,12.59);
$app['LIRF']=array(41.81,12.25);
$app['LIRM']=array(41.6,14.8);
$app['LIRN']=array(40.88,14.29);
$app['LIRP']=array(43.68,10.39);
$app['LIRQ']=array(43.81,11.20);
$app['LIRS']=array(42.76,11.7);
$app['LIRZ']=array(43.10,12.51);

//ELENCO TWR
/*
$twr['LIRA']=array(41.52,12.34);
$twr['LIMC']=array(45.39,8.44);
$twr['LIME']=array(45.40,9.42);
$twr['LIML']=array(45.28,9.17);
$twr['LIRF']=array(41.48,12.14);
$twr['LIEA']=array(40.42,8.20);
$twr['LIPY']=array(43.35,13.28);
$twr['LIPE']=array(44.32,11.17);
$twr['LIEE']=array(39.15,9.03);
$twr['LIMJ']=array(44,26,9.05);
$twr['LICJ']=array(38.02,13.11);
$twr['LIPZ']=array(45.27,12.17);
*/

$twr['LIBA']=array(41.54,15.72);
$twr['LIBC']=array(38.0,17.8);
$twr['LIBD']=array(41.14,16.76);
$twr['LIBF']=array(41.43,15.54);
$twr['LIBG']=array(40.52,17.40);
$twr['LIBP']=array(42.44,14.19);
$twr['LIBR']=array(40.66,17.95);
$twr['LIBV']=array(40.77,16.93);
$twr['LICA']=array(38.91,16.24);
$twr['LICC']=array(37.47,15.6);
$twr['LICD']=array(35.50,12.62);
$twr['LICG']=array(36.81,11.97);
$twr['LICJ']=array(38.18,13.10);
$twr['LICR']=array(38.7,15.65);
$twr['LICT']=array(37.91,12.49);
$twr['LICZ']=array(37.41,14.92);
$twr['LIEA']=array(40.63,8.29);
$twr['LIED']=array(39.35,8.97);
$twr['LIEE']=array(39.25,9.6);
$twr['LIEO']=array(40.90,9.52);
$twr['LIET']=array(39.92,9.68);
$twr['LIMC']=array(45.63,8.72);
$twr['LIME']=array(45.67,9.70);
$twr['LIMF']=array(45.20,7.65);
$twr['LIMG']=array(44.4,8.13);
$twr['LIMJ']=array(44.41,8.84);
$twr['LIML']=array(45.45,9.28);
$twr['LIMN']=array(45.53,8.67);
$twr['LIMP']=array(44.82,10.29);
$twr['LIMZ']=array(44.55,7.62);
$twr['LIPA']=array(46.3,12.60);
$twr['LIPB']=array(46.46,11.33);
$twr['LIPC']=array(44.23,12.31);
$twr['LIPE']=array(44.53,11.29);
$twr['LIPH']=array(45.65,12.20);
$twr['LIPI']=array(45.98,13.6);
$twr['LIPK']=array(44.20,12.7);
$twr['LIPL']=array(45.44,10.27);
$twr['LIPO']=array(45.43,10.33);
$twr['LIPQ']=array(45.83,13.47);
$twr['LIPR']=array(44.2,12.61);
$twr['LIPS']=array(45.69,12.8);
$twr['LIPT']=array(45.57,11.53);
$twr['LIPU']=array(45.40,11.85);
$twr['LIPX']=array(45.40,10.89);
$twr['LIPY']=array(43.62,13.36);
$twr['LIPZ']=array(45.51,12.35);
$twr['LIQS']=array(43.26,11.25);
$twr['LIRA']=array(41.80,12.59);
$twr['LIRF']=array(41.81,12.25);
$twr['LIRM']=array(41.6,14.8);
$twr['LIRN']=array(40.88,14.29);
$twr['LIRP']=array(43.68,10.39);
$twr['LIRQ']=array(43.81,11.20);
$twr['LIRS']=array(42.76,11.7);
$twr['LIRZ']=array(43.10,12.51);


//INITIALIZE IMAGE
//for each defind region set height width and coordinate range
$x['wd']=640;
$y['wd']=425;
$x1['wd']=-180;
$x2['wd']=180;
$y1['wd']=-90;
$y2['wd']=90;

$x['it']=548;
$y['it']=654;
$x1['it']=6.00; //6.48
$x2['it']=19.29;  //19.29
$y1['it']=35.76;  //35.76
$y2['it']=47.71;  //47.71

$x['i2']=150;
$y['i2']=179;
$x1['i2']=6.00;
$x2['i2']=19.29;
$y1['i2']=35.76;
$y2['i2']=47.71;

//set APP,TWR,GND marker sizes
if ($region=='it'){
       $apparc=50;
       $twrline1=10;
       $twrline2=5;
} elseif ($region=='i2'){
       $apparc=20;
       $twrline1=5;
       $twrline2=2;
}

//create image...
$image = imagecreatetruecolor($x[$region],$y[$region]);

$white  = ImageColorAllocate($image,255,255,255);
$green  = ImageColorAllocate($image,0,150,0);
$black  = ImageColorAllocate($image,0,0,0);
$red    = ImageColorAllocate($image,255,0,0);
$blue   = ImageColorAllocate($image,0,0,255);
$orange = ImageColorAllocate($image,255,114,0);
$grey   = ImageColorAllocate($image,127,127,127);

$image2 = imagecreatefromjpeg($region.".jpg");
imagecopy($image, $image2, 0,0,0,0,$x[$region],$y[$region]);
$dot = imagecreatefromjpeg("dot.jpg");
$dot2 = imagecreatefromjpeg("dot2.jpg");

$zero=0;


// READ THE DATA FILE
$file = fopen ("data.txt", "r");
if ($debug){
echo "data.txt: ".$file."<BR/>";
}
$riga = 0;

while (strlen($data = fgets($file, 1024)) != 0 ){
   $riga = explode(':', $data);
   if (($riga[3]=="PILOT")AND(($x1[$region]<$riga[6])AND($riga[6]<$x2[$region])AND($y1[$region]<$riga[5])AND($riga[5]<$y2[$region]))) {
               $hdg = $riga[38];
               $gs = $riga[8];
       $ydraw=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($riga[5]-$y1[$region])));
       $xdraw=((($x[$region])/($x2[$region]-$x1[$region]))*($riga[6]-$x1[$region]));
               imagecopy($image,$dot,($xdraw-2),($ydraw-2),0,0,4,4);

               //if ($region=='it'){
                       $xdev=((sin(deg2rad($hdg)))*$gs/100);
                       $ydev=((cos(deg2rad($hdg)))*$gs/100);
                       imagecopy($image,$dot2,($xdraw-$xdev),($ydraw+$ydev),0,0,1,1);
                       imagecopy($image,$dot2,($xdraw-$xdev*2),($ydraw+$ydev*2),0,0,1,1);
                       imagecopy($image,$dot2,($xdraw-$xdev*3),($ydraw+$ydev*3),0,0,1,1);
               //}
       if (($call)&&($gs>40)){
                       ImageString($image,1,$xdraw,($ydraw-7)," ".$riga[0],$white);
               }

//      } elseif  (($riga[3]=="ATC")&&($region=='it')){
       } elseif  (($riga[3]=="ATC")&&($region!='wd')){

               $findme = "LI";
               $findme2="CTR";
       $pos = strpos($riga[0],$findme);
       if (($pos===$zero) and (strpos($riga[0],$findme2))) {
                       $fir=substr($riga[0],0,4);
                       switch($fir){
                               case 'LIUP':
                                       $fir2=$liup;
                                       $i=0;
                                       while ($fir2[$i]!=0){
                                               $temp[$i]=((($x[$region])/($x2[$region]-$x1[$region]))*($fir2[$i]-$x1[$region]));
                                               $i++;
                                               $temp[$i]=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($fir2[$i]-$y1[$region])));
                                               $i++;
                                       }
                                       imagepolygon($image,$temp,($i/2),$orange);
                                       if ($region=='it'){
                                               ImageString($image,2,170,300,"LIUP CTR",$orange);
                                               ImageString($image,2,170,310,"above FL195",$orange);
                                       }
                                       break;
                               case 'LIRR':
                                       $fir2=$lirr;
                                       $i=0;
                                       while ($fir2[$i]!=0){
                                               $temp[$i]=((($x[$region])/($x2[$region]-$x1[$region]))*($fir2[$i]-$x1[$region]));
                                               $i++;
                                               $temp[$i]=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($fir2[$i]-$y1[$region])));
                                               $i++;
                                       }
                                       imagepolygon($image,$temp,($i/2),$red);
                                       if ($region=='it'){
                                               ImageString($image,2,285,438,"LIRR CTR",$red);
                                       }
                                       break;
                               case 'LIMM':
                                       $fir2=$limm;
                                       $i=0;
                                       while ($fir2[$i]!=0){
                                               $temp[$i]=((($x[$region])/($x2[$region]-$x1[$region]))*($fir2[$i]-$x1[$region]));
                                               $i++;
                                               $temp[$i]=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($fir2[$i]-$y1[$region])));
                                               $i++;
                                       }
                                       imagepolygon($image,$temp,($i/2),$red);
                                       if ($region=='it'){
                                               ImageString($image,2,105,159,"LIMM CTR",$red);
                                       }
                                       break;
                               case 'LIPP':
                                       $fir2=$lipp;
                                       $i=0;
                                       while ($fir2[$i]!=0){
                                               $temp[$i]=((($x[$region])/($x2[$region]-$x1[$region]))*($fir2[$i]-$x1[$region]));
                                               $i++;
                                               $temp[$i]=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($fir2[$i]-$y1[$region])));
                                               $i++;
                                       }
                                       imagepolygon($image,$temp,($i/2),$red);
                                       if ($region=='it'){
                                               ImageString($image,2,225,140,"LIPP CTR",$red);
                                       }
                                       break;
                               case 'LIBB':
                                       $fir2=$libb;
                                       $i=0;
                                       while ($fir2[$i]!=0){
                                               $temp[$i]=((($x[$region])/($x2[$region]-$x1[$region]))*($fir2[$i]-$x1[$region]));
                                               $i++;
                                               $temp[$i]=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($fir2[$i]-$y1[$region])));
                                               $i++;
                                       }
                                       imagepolygon($image,$temp,($i/2),$red);
                                       if ($region=='it'){
                                               ImageString($image,2,384,343,"LIBB CTR",$red);
                                       }

                               break;
                               }
                       }

                       $findme3="APP";
                       if (($pos===$zero) and (strpos($riga[0],$findme3))) {
                               $appname=substr($riga[0],0,4);
                               $ydraw=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($app[$appname][0]-$y1[$region])));
                               $xdraw=((($x[$region])/($x2[$region]-$x1[$region]))*($app[$appname][1]-$x1[$region]));
                               imagearc($image,$xdraw,$ydraw,$apparc,$apparc,0,360,$blue);
                               if ($region=='it'){
                                       ImageString($image,2,$xdraw-12,($ydraw-37),$appname,$blue);
                               }
                       }

                       $findme4="TWR";
                       if (($pos===$zero) and (strpos($riga[0],$findme4))) {
                               $twrname=substr($riga[0],0,4);
                               $ydraw=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($twr[$twrname][0]-$y1[$region])));
                               $xdraw=((($x[$region])/($x2[$region]-$x1[$region]))*($twr[$twrname][1]-$x1[$region]));
                               $temp=array($xdraw,$ydraw,$xdraw,$ydraw-$twrline1,$xdraw-$twrline2,$ydraw-$twrline1,$xdraw-$twrline2,$ydraw);
                               imagefilledpolygon($image,$temp,4,$orange);
                               if ($region=='it'){
                                       ImageString($image,1,$xdraw-9,($ydraw+5),$twrname,$white);
                               }
                       }

                       $findme5="GND";
                       if (($pos===$zero) and (strpos($riga[0],$findme5))) {
                               $gndname=substr($riga[0],0,4);
                               $ydraw=($y[$region]-((($y[$region])/($y2[$region]-$y1[$region]))*($twr[$gndname][0]-$y1[$region])));
                               $xdraw=((($x[$region])/($x2[$region]-$x1[$region]))*($twr[$gndname][1]-$x1[$region]));
                               $temp=array($xdraw,$ydraw,$xdraw,$ydraw-$twrline2,$xdraw+$twrline2,$ydraw-$twrline2,$xdraw+$twrline2,$ydraw);
                               imagefilledpolygon($image,$temp,4,$green);
                               if ($region=='it'){
                                       ImageString($image,1,$xdraw-9,($ydraw+5),$gndname,$white);
                               }
                       }

       }
       }

//copyleft info only on the bigger images... :-) 

if ($region!='i2') {
       $dataora=strftime("%Y %b %e %R",time());
       ImageString($image,2,5,($y[$region]-28),$dataora,$black);
       ImageString($image,2,5,($y[$region]-14),"http://www.vatita.net",$black);
       ImageString($image,2,($x[$region]-80),($y[$region]-14),"image by NASA",$grey);
       }

fclose($file);
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

?>

Luca Benelli - C3 - P2

Link to comment
Share on other sites

 Share