From 3911a656b52174cf2f788f9857ad0c30d64e2ebc Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 14 Apr 2006 16:09:10 +0000 Subject: [PATCH] Version 0.2 of airspace program. Note the CHANGES file. --- src/Airspace/CHANGES | 17 + src/Airspace/airspace.cxx | 5036 +++++++++++++---- src/Airspace/support_files/.fgfsrc | 28 + src/Airspace/support_files/airspace.xml | 197 + .../support_files/glide-slope-1nm-by-3d.ac | 25 + src/Airspace/support_files/glide-slope.xml | 11 + src/Airspace/support_files/menubar.xml | 487 ++ src/Airspace/support_files/readme | 34 + 8 files changed, 4754 insertions(+), 1081 deletions(-) create mode 100644 src/Airspace/CHANGES create mode 100644 src/Airspace/support_files/.fgfsrc create mode 100755 src/Airspace/support_files/airspace.xml create mode 100644 src/Airspace/support_files/glide-slope-1nm-by-3d.ac create mode 100644 src/Airspace/support_files/glide-slope.xml create mode 100644 src/Airspace/support_files/menubar.xml create mode 100644 src/Airspace/support_files/readme diff --git a/src/Airspace/CHANGES b/src/Airspace/CHANGES new file mode 100644 index 00000000..05a54857 --- /dev/null +++ b/src/Airspace/CHANGES @@ -0,0 +1,17 @@ + +0.2 is an extensive rewrite featuring + +(1) Texturing on airspace with useful information such as call signs and frequencies for controlling agencies for special use airspace. +(2) Terminal waypoints associated with airports are displayable as well as glide slopes (black for three degree vfr, red for ILS glideslopes with +the glideslope angle as specified in the database. The outer upper boundary onthe glide slope is one degree above the glideslope. +(3) circles, arcs, and lines have been dissected into lists of lines and distributed accross the various tiles. By dividing the graphics files +among the tiles large arcs for Class B airspace for example become visable as soon as the tile comes into view. T he first version would not display until +the center of the circle come into view.... +(4) Added signage for (a) airports, (b) navaids, (c) waypoints (d) terminal waypoints (e) special use airspace. The signage system(s) take advantage of the +billboard feature in flightgear so the signs always turn to face the view. +(5) added a menu system to toggle everything on or off to suit the situational requirements. Turning everything on for display in the Los Angelus area is +an excercise in visually getting buried. + +The program can output Class A and E airspace boundaries but they seem to be more of a nuisance visually. The default setup in the code is to omit A and E +airspace. + diff --git a/src/Airspace/airspace.cxx b/src/Airspace/airspace.cxx index 376492bc..3f0e75d7 100644 --- a/src/Airspace/airspace.cxx +++ b/src/Airspace/airspace.cxx @@ -4,27 +4,27 @@ ////// ////// ////// airspace: generates files for 3d depiction of airspace ////// ////// for flighgear ////// -////// version 0.1 released 2005-12-12 Merry Christmas! ////// +////// version 0.2 released 2006-04-12 ////// ////// by Philip Cobbin ////// ////// ////// -////// running: ./airspace US >airspace.txt ////// -////// to generate files for United States ////// -////// with the formatted report info on airspace ////// -////// piped to the text file airspace.txt (5+mb) ////// -////// running: ./airspace US clean >airspace.txt ////// -////// to clean out all the auto generated files. ////// -////// (Technically anything after the first auto generated ////// -////// line is wiped out of tile file ////// +////// running: ./airspace US ////// +////// report files are generated for the various types of ////// +////// data processed: ////// ////// ////// -////// required directories for "Airspace" ////// +////// summary-airport.txt ////// +////// summary-airspace.txt ////// +////// summary-ils.txt ////// +////// summary-navaid.txt ////// +////// summary-suas.txt ////// +////// summary-waypoint.txt ////// +////// tile_pathlist.txt ////// ////// ////// -////// create: /usr/local/share/FlightGear/data/Models/Airspace/ ////// -////// then create the following subdirectories ////// -////// Class_A Class_C Class_E Class_SD Class_SP Class_ST ////// -////// Class_B Class_D Class_SA Class_SM Class_SR Class_SW ////// +////// see the readme file in the support files folder for where to put ////// +////// the extra files for adding menu support and default configuration ////// +////// values. ////// ////// ////// ////// compiling: ////// -// g++ airspace.cxx /usr/local/lib/libsgmagvar.a /usr/local/lib/libsgmath.a -o airspace // +// g++ airspace.cxx /usr/local/lib/libsgmagvar.a /usr/local/lib/libsgmath.a /usr/local/lib/libsgmisc.a /usr/local/lib/libsgdebug.a -o airspace // ////// ////// ////// ////// ////// ---- NOTICE ---- ////// @@ -94,18 +94,20 @@ using std::string; /******************* simgear ********************************/ #include -//#include #include #include /************************************************************/ // Configure the following for your particular directory structure ... -const string dafift_base = "/stage/fgfs05/curt/RawData/Airports"; -// const string output_base = "/usr/local/share/FlightGear/Scenery-Airspace"; -const string output_base = "./Scenery-Airspace"; -const string airspace_path = "/home/curt/Projects/FlightGear/data/Models/Airspace"; +const string dafift_base = "/usr/local/share/DAFIFT"; +const string output_base = "/usr/local/share/FlightGear/data/Scenery-Airspace"; +const string short_output_base = "Scenery-Airspace"; +//const string output_base = "/usr/local/share/FlightGear/data/Scenery-9.10"; +const string airspace_path = "/usr/local/share/FlightGear/data/Models/Airspace"; + +const string airspace_texture_path = "/usr/local/share/FlightGear/data/Textures/Airspace"; /**************** simgear hybred of newbucket ***************/ @@ -119,17 +121,6 @@ const string airspace_path = "/home/curt/Projects/FlightGear/data/Models/Airspac int y; // y subdivision (0 to 7) -/** For divide by zero avoidance, this will be close enough to zero */ -//#define SG_EPSILON 0.0000001 - -//#define SG_BUCKET_SPAN 0.125 - -/** - * half of a standard SG_BUCKET_SPAN - */ -//#define SG_HALF_BUCKET_SPAN ( 0.5 * SG_BUCKET_SPAN ) - - // return the horizontal tile span factor based on latitude double sg_bucket_span( double l ) { if ( l >= 89.0 ) { @@ -235,18 +226,78 @@ void set_bucket( double dlon, double dlat ) { long int gen_index() { return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x; } +// ptc addition 2006-03-01 +// gen_tilenum is derived from set_bucket and gen_index... +// ptc 2006-03-01 +long int gen_tilenum( double dlon, double dlat ) { + // + // latitude first + // + double span = sg_bucket_span( dlat ); + double diff = dlon - (double)(int)dlon; + + int lon; + int lat; + int x; + int y; + + // cout << "diff = " << diff << " span = " << span << endl; + + if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) { + lon = (int)dlon; + } else { + lon = (int)dlon - 1; + } + + // find subdivision or super lon if needed + if ( span < SG_EPSILON ) { + // polar cap + lon = 0; + x = 0; + } else if ( span <= 1.0 ) { + x = (int)((dlon - lon) / span); + } else { + if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) { + lon = (int)( (int)(lon / span) * span); + } else { + // cout << " lon = " << lon + // << " tmp = " << (int)((lon-1) / span) << endl; + lon = (int)( (int)((lon + 1) / span) * span - span); + if ( lon < -180 ) { + lon = -180; + } + } + x = 0; + } + + // + // then latitude + // + diff = dlat - (double)(int)dlat; + + if ( (dlat >= 0) || (fabs(diff) < SG_EPSILON) ) { + lat = (int)dlat; + } else { + lat = (int)dlat - 1; + } + y = (int)((dlat - lat) * 8); +// printf("x[%d]y[%d]",x,y); + return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x; + +} + /********************************************************************* globals ********************************************************/ -/*************************************************** what can I say...an ol FORTRAN'r ************************************************/ - // ------------------------------------------------DAFIF fields----------------------------------------------------------- char tc = '\t'; + char tc2= '\n'; char header[1000]; // to read header into to skip over .... /** boundary (country) record **/ char bdry_ident[13]; + char bdry_ident_safe[13]; //safe as a filename with '-' replacing ' ' characters char bdry_ident_last[13]; char seg_nbr[6]; char ctry_1[5]; @@ -256,12 +307,25 @@ void set_bucket( double dlon, double dlat ) { char ctry_5[5]; char cycle_date[8]; +// procedure to make a "safe" version of the bdry identifier for use as a string in a filename... +void set_safe_bdry() +{ + int i=0; + for (i=0; i=MAX_CLASSES)) return false; @@ -469,130 +731,100 @@ bool process_class(int i) } double class_height[MAX_CLASSES] = { - 0.0, - 10000.0, - 4000.0, - 2500.0, - 14500.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 + 0.0, + 10000.0, + 4000.0, + 2500.0, + 14500.0, + UPPER_ALTITUDE_LIMIT, + UPPER_ALTITUDE_LIMIT, + UPPER_ALTITUDE_LIMIT, + UPPER_ALTITUDE_LIMIT, + UPPER_ALTITUDE_LIMIT, + UPPER_ALTITUDE_LIMIT, + UPPER_ALTITUDE_LIMIT }; -//idiot proof lower boundary so the depiction goes to the surface... -#define CLASS_FLOOR_ADD 500.0 +//idiot proof lower boundary so the depiction goes to the surface... 150 meters +#define CLASS_FLOOR_ADD 150.0 +//********************************* color/texture parameters *************************************** +//************* Note can use either transparency color method or a transparent texturing method for airspace boundairies +bool use_texture[MAX_CLASSES] = { + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true +}; -float rgb_colors[MAX_CLASSES][3]= { - {1.0, 1.0, 1.0}, // Class A not used until I own the 777! (white) - {0.0, 0.0, 1.0}, // class B // hmm...need some texturing? (blue) - {1.0, 0.0, 1.0}, // class C (magenta) - {0.0, 0.0, 1.0}, // class D (blue...dashing used) - {1.0, 0.0, 1.0}, // class E (magenta) - {0.5, 0.5, 0.0}, // class S A Alert (1/2 yellow) - {1.0, 0.0, 0.0}, // class S D Danger (red) - {1.0, 1.0, 0.0}, // class S M MOA (yellow) - {0.0, 0.0, 0.0}, // class S P Prohibited (black) - {0.25, 0.25, 0.25}, // class S R Restricted (3/4 black) - {0.0, 0.0, 0.0}, // class S T Temporary (black) - {1.0, 0.5, 0.0} // class S W Warning (red/yellow) +double rgb_colors[MAX_CLASSES][3]= { + {1.0, 1.0, 1.0}, // Class A (white) + {0.0, 0.0, 1.0}, // class B (blue) + {1.0, 0.0, 1.0}, // class C (magenta) + {0.5, 0.5, 1.0}, // class D (blue...dashing used) + {1.0, 0.5, 1.0}, // class E (magenta) + {0.5, 0.5, 0.0}, // class S A Alert (1/2 yellow) + {1.0, 0.0, 0.0}, // class S D Danger (red) + {1.0, 1.0, 0.0}, // class S M MOA (yellow) + {0.0, 0.0, 0.0}, // class S P Prohibited (black) + {0.25, 0.25, 0.25}, // class S R Restricted (3/4 black) + {0.0, 0.0, 0.0}, // class S T Temporary (black) + {1.0, 0.5, 0.0} // class S W Warning (red/yellow) }; -float rgb_transparency[MAX_CLASSES]= { // transparency used as a que as to whether you should enter lower number is f16 bait... - 0.5, - 0.5, //B - 0.5, //C - 0.7, //D - 0.7, //E - 0.4, //S A - 0.4, //S D - 0.4, //S M - 0.4, //S P - 0.4, //S R - 0.4, //S T - 0.4, //S W +double rgb_transparency[MAX_CLASSES]= { // transparency used as a que as to whether you should enter lower number is f16 bait... + 0.8, + 0.8, //B + 0.8, //C + 0.8, //D + 0.8, //E + 0.8, //S A + 0.8, //S D + 0.8, //S M + 0.8, //S P + 0.8, //S R + 0.8, //S T + 0.8, //S W }; +/** Note: rgb's are generated for each individual airspace boundary to sign the wall +const string airspace_texture[MAX_CLASSES] = { + "class_a.rgb", + "class_b.rgb", + "class_c.rgb", + "class_d.rgb", + "class_e.rgb", + "class_s_alert.rgb", + "class_s_danger.rgb", + "class_s_moa.rgb", + "class_s_prohibited.rgb", + "class_s_restricted.rgb", + "class_s_temporary.rgb", + "class_s_warning.rgb" + }; +**/ +const string airspace_enabled_flag[MAX_CLASSES] = { + "airspace_a", + "airspace_b", + "airspace_c", + "airspace_d", + "airspace_e", + "airspace_alert", + "airspace_danger", + "airspace_moa", + "airspace_prohibited", + "airspace_restricted", + "airspace_temporary", + "airspace_warning" + }; - char * class_arc[MAX_CLASSES] = { - "class_a_arc_r", - "class_b_arc_r", - "class_c_arc_r", - "class_d_arc_r", - "class_e_arc_r", - "class_sa_arc_r", - "class_sd_arc_r", - "class_sm_arc_r", - "class_sp_arc_r", - "class_sr_arc_r", - "class_st_arc_r", - "class_sw_arc_r" -}; - char * class_circle[MAX_CLASSES] = { - "class_a_circle_r", - "class_b_circle_r", - "class_c_circle_r", - "class_d_circle_r", - "class_e_circle_r", - "class_sa_circle_r", - "class_sd_circle_r", - "class_sm_circle_r", - "class_sp_circle_r", - "class_sr_circle_r", - "class_st_circle_r", - "class_sw_circle_r" -}; - char * class_line[MAX_CLASSES] = { - "class_a_line_d", - "class_b_line_d", - "class_c_line_d", - "class_d_line_d", - "class_e_line_d", - "class_sa_line_d", - "class_sd_line_d", - "class_sm_line_d", - "class_sp_line_d", - "class_sr_line_d", - "class_st_line_d", - "class_sw_line_d" -}; - bool class_dash[MAX_CLASSES] = { // solid versus dashing of boundary, - // Class D is typically blue dashed lines on sectionals. - // may add a secondary color to dashing for further queing of airspace type as the - // variations of blue and magenta on sectionals is very heavily overloaded visually. - false, - false, - false, - true, - false, - false, - false, - false, - false, - false, - false, - false - }; - - - - char * class_path[MAX_CLASSES] = { - "Class_A/", - "Class_B/", - "Class_C/", - "Class_D/", - "Class_E/", - "Class_SA/", - "Class_SD/", - "Class_SM/", - "Class_SP/", - "Class_SR/", - "Class_ST/", - "Class_SW/" - }; //-----------------statistics....although iclass has heavy use otherwise ---------------------- @@ -608,10 +840,46 @@ float rgb_transparency[MAX_CLASSES]= { // transparency used as a que as to whet double ave_r =0.0; + double sum_long=0.0; // compute an average to place sign over special use airspace + double sum_lat=0.0; + int num_pts=0; + + +void init_boundary_ave() +{ + sum_long=0.0; + sum_lat=0.0; + num_pts=0; +} + +void sum_boundary_pt(double xlat, double xlong) +{ + + sum_long = sum_long + xlong; + sum_lat = sum_lat + xlat; + num_pts++; + // printf("sum_boundary pts: added [%f] [%f] sums are [%f] [%f] n is [%d] ave is [%f] [%f] [%f] \n",xlat, xlong, sum_lat, sum_long, num_pts,sum_lat/(double)num_pts, sum_long/(double)num_pts); + +} +double ave_boundary_long() +{ + if (num_pts > 0 ) return sum_long/((double)(num_pts)); else { + fprintf(fp_rep,"WARNING: bad average calculations (ave_boundary_long)\n"); + return -1.0; + } +} +double ave_boundary_lat() +{ + if (num_pts > 0 ) return sum_lat/((double)(num_pts)); else { + fprintf(fp_rep,"WARNING: bad average calculations (ave_boundary_lat)\n"); + return -1.0; + } +} + //------------------- DAFIF conversions i.e. string latitude to the actual number...--------------------------- - float r; // my wonderful collection of kludges... - float rr; // first you make em work then you make em elegant... + double r; // my wonderful collection of kludges... + double rr; // first you make em work then you make em elegant... int ir;// int irr;// int ilatxx;// @@ -619,47 +887,46 @@ float rgb_transparency[MAX_CLASSES]= { // transparency used as a que as to whet int ilatxxx;// int ilongxxx;// - float dlat; // longitude - float dlong; // latitude - float dlatc; // longitude center - float dlongc; // latitude center - float dlatp1; // longitude p1 - float dlongp1; // latitude p1 - float dlatp2; // longitude p2 - float dlongp2; // latitude p2 - float flatxx;// - float flongxx;// - float flatxxx;// - float flongxxx;// + double dlat; // longitude + double dlong; // latitude + double dlat2; // longitude 2nd pt + double dlong2; // latitude 2nd pt + double dlatc; // longitude center + double dlongc; // latitude center + double dlatp1; // longitude p1 + double dlongp1; // latitude p1 + double dlatp2; // longitude p2 + double dlongp2; // latitude p2 - float fremlatxxx;// - float fremlongxxx;// + double fremlatxxx;// + double fremlongxxx;// char ns; // n or s char ew; // e or w - float floor_alt,ceiling_alt; + double floor_alt,ceiling_alt; - float altitude_high; - float altitude_low; + double altitude_high; + double altitude_low; char alt_low_type[10]; char alt_high_type[10]; // --------------------------------------misc-------------------------------------------- - bool cleanfiles=false; // backup current .stg file and then clean out anything from the first automatically added line to eof - bool floor_is = true; - - char class_x_filename[200]; - - float altitude; - char alt_digits[10]; - char type_digits[10]; + double altitude; + char alt_digits[12]; + char type_digits[11]; char tile_filename[1000]; char tile_filename_bak[1000]; char tile_addline[1000]; + char airspace_filename[1000]; + char airspace_filename_xml[1000]; + char airspace_filename_xml_bak[1000]; + char airspace_texture_filename[1000]; + char airspace_filename_bak[1000]; + int counter=0; double az1 =0.0; @@ -676,324 +943,111 @@ float rgb_transparency[MAX_CLASSES]= { // transparency used as a que as to whet char subpath[1000]; // i.e. w080n40/w073n43 -//---------------------------------- .ac file generators for circles arcs and lines ----------------------------------- -void do_circle(const string &fn, float radnm, float lalt, float halt, int cl_clr,bool dash) +//----------------------------------------- icao list for setting terminal waypoint heights... + +struct icao_list { + struct icao_list * next; + struct icao_list * last; + char _icao[9]; + double elevation; +}; + + struct icao_list * head_icao = NULL; + struct icao_list * current_icao = NULL; + struct icao_list * tail_icao = NULL; + struct icao_list * t_icao = NULL; + + +void erase_icao_list() { + current_icao=head_icao; + while (current_icao!=NULL) { + current_icao = current_icao->next; + delete head_icao; + head_icao = current_icao; + } +} + +void init_icao_list() { -// NUM_SEGMENTS should be even number for dashing to work... -#define NUM_SEGMENTS 72 - int i; - float vertices[NUM_SEGMENTS*2][3]; - double delta_d = 360.0 / ((double)(NUM_SEGMENTS)); - double xx; - double yy; - for (i=0; i_icao,strncmp(current_icao->_icao,icao,9)); + if (strncmp(current_icao->_icao,icao,9) == 0 ) return current_icao; + if (strncmp(current_icao->_icao,icao,9) < 0 ) return NULL; + current_icao = current_icao->next; + if (current_icao==NULL) { + return NULL; } - else { - fout.width(5); - fout << NUM_SEGMENTS << " 0.0 0.0 " << endl; - fout.width(5); - fout << 0 << " 0.0 0.0 " << endl; - fout.width(5); - fout << NUM_SEGMENTS-1 << " 0.0 0.0 " << endl; - fout.width(5); - fout << NUM_SEGMENTS*2-1 << " 0.0 0.0 " << endl; - } } - fout << "kids 0\n"; - fout.close(); } -void do_arc(const string &fn, float starta, float enda, float radnm, float lalt, float halt, int cl_clr,bool dash) + +void add_icao(char * icao, double elev ) { -// NUM_SEGMENTS should be even number for dashing to work... -#define NUM_ARC_SEGMENTS 72 - float sa; - float ea; - float ca; - sa=starta; - ea=enda; - if (sa>ea) sa-=360.0; - sa+=180.0;//get ac to flighgear bearings aligned - ea+=180.0; - float span = ea-sa; - int i; - float vertices[NUM_ARC_SEGMENTS*2][3]; - double delta_d = span / ((double)(NUM_ARC_SEGMENTS-1)); - double xx; - double yy; - ca=sa; - for (i=0; ilast=NULL; + new_icao->next=NULL; + strncpy((char *) new_icao->_icao, icao,5); + new_icao->elevation=elev; + + if (head_icao!=NULL) { + current_icao = head_icao; + while (!done) { + if (strncmp(current_icao->_icao,icao,9)>0) { + if (current_icao->next!=NULL) { + current_icao = current_icao->next; + } + else {//new tail + current_icao->next=new_icao; + new_icao->last=current_icao; + done=true; + } + } + else { // < assuming no double insert attempts...i.e. call lookup first... + if (current_icao->last!=NULL) { + new_icao->last = current_icao->last; + current_icao->last->next=new_icao; + new_icao->next = current_icao; + current_icao->last = new_icao; + done = true; + } + else {//new head + current_icao->last=new_icao; + new_icao->next=current_icao; + head_icao=new_icao; + done=true; + } + } + } // !done } - ca=sa; - for (i=0; i=0.0) { ew='e'; ilongxxx = (int) dlong; //truncate - fremlongxxx = dlong - truncf(dlong); //(float) ilongxxx; + fremlongxxx = dlong - trunc(dlong); //(double) ilongxxx; ilongxxx = (int) (dlong+0.999999); ilongxx = (int) (ilongxxx+9.999999)/10; } else { ew ='w'; ilongxxx = (int) (0.9999999-dlong); - fremlongxxx = fabsf((float) dlong) - trunc(fabsf(dlong)); + fremlongxxx = fabs((double) dlong) - trunc(fabs(dlong)); ilongxx = (int)(ilongxxx+9.999999)/10; ilongxxx = -ilongxxx; ilongxx = -ilongxx; @@ -1001,14 +1055,14 @@ void set_subpath() if (dlat>=0) { ns='n'; ilatxxx = (int)dlat; //truncate - fremlatxxx = dlat - truncf(dlat); + fremlatxxx = dlat - trunc(dlat); ilatxxx = (int)dlat; //round down ilatxx = (ilatxxx)/10; } else { ns='s'; ilatxxx = (int)(-dlat); //truncate - fremlatxxx = fabsf(dlat) - trunc(fabsf(dlat));// - (float) ilatxxx; + fremlatxxx = fabs(dlat) - trunc(fabs(dlat));// - (double) ilatxxx; ilatxxx = (int)(-dlat); //round down ilatxx = (ilatxxx)/10; ilatxxx = -ilatxxx; @@ -1031,36 +1085,1476 @@ void set_subpath() else sprintf(subpath,"%s%d/",subpath,abs(ilatxxx)); } -float decode_altitude(char *a) +//----------------------------------------- line management and generation to keep lines within tile boundaries-------- + + +//**************Line division work... +//NOTE! bucket span changes as a function of latitude. +// +double divisor; + +struct pt { + double xp; + double yp; + char seg_nbr[6]; + struct pt * next; + struct pt * last; +}; + + struct pt * head_pt=NULL; + struct pt * current_pt=NULL; + struct pt * end_pt=NULL; + struct pt * t_pt=NULL; + + struct pt * head_pt_m=NULL; + struct pt * current_pt_m=NULL; + struct pt * tail_pt_m=NULL; + struct pt * t_pt_m=NULL; + + + int good_lists=0; + int bad_lists=0; + + +// tile node for processing line lists for an airspace identifier.... + +struct tile_list { + struct tile_list * next; + struct tile_list * last; + struct pt * start; + struct pt * end; + long int tile_nbr; +}; + + struct tile_list * head_tile = NULL; + struct tile_list * current_tile = NULL; + struct tile_list * tail_tile = NULL; + struct tile_list * t_tile = NULL; + + +void erase_tile_list() { + current_tile=head_tile; + while (current_tile!=NULL) { + current_tile = current_tile->next; + delete head_tile; + head_tile = current_tile; + } +} + +void init_tile_list() { + if (head_tile!=NULL) erase_tile_list(); +} + +void add_tile(long int tn, pt * sp, pt * ep) +{ + bool done=false; + + struct tile_list * new_tile = new struct tile_list; + + new_tile->last=NULL; + new_tile->next=NULL; + new_tile->start=sp; + new_tile->end=ep; + new_tile->tile_nbr = tn; + + if (head_tile!=NULL) { + current_tile = head_tile; + while (!done) { + if (tn <= current_tile->tile_nbr) { //insert before + done=true; + if (current_tile->last!=NULL) { // in list insert + new_tile->last = current_tile->last; + new_tile->next = current_tile; + current_tile->last=new_tile; + new_tile->last->next=new_tile; + } + else { //new head + current_tile->last=new_tile; + new_tile->next=current_tile; + head_tile = new_tile; + } + } + else { // insert after ? + if (current_tile->next != NULL) current_tile = current_tile->next; + else { + done=true; + current_tile->next = new_tile; + new_tile->last = current_tile; + } + } + } // !done + } + else head_tile=new_tile; +} + + + FILE * ac_fp=NULL; + + + int nkids; + int ikid; + + +void write_xml_file() +{ +// airspace_filename_xml + FILE * x_fp; + int ik; + string command = "mkdir -p "; command += SGPath(airspace_filename_xml).dir(); + // cout << command << endl; + system(command.c_str()); + x_fp = fopen(airspace_filename_xml,"w+"); + if (x_fp!=NULL) { + fprintf(x_fp,"\n\n"); + fprintf(x_fp," %s-%d.ac\n",bdry_ident_safe,current_tile->tile_nbr); + fprintf(x_fp," \n select\n"); + for (ik=0; ikairspace-%d\n",ik+1); + } + fprintf(x_fp," \n /sim/airspace/enabled\n"); + fprintf(x_fp," /sim/%s/enabled\n \n \n\n",airspace_enabled_flag[iclass].c_str()); + fclose(x_fp); + } + else { + fprintf(fp_rep,"WARNING! COULD WRITE TO FILE [%s]\n",airspace_filename_xml); + } +} +// who's the leader of the pack that's ........ M I C K E Y M O U S E....but I'll clean them up later, but individual texture generators allow +// for tweaking. For example, Restricted airpsace is usually a tower as to an MOA's more fence like configuration, so the texturing can be tuned.... +void write_airspace_texture() +{ + char command_str[1000]; + + string command = ""; + sprintf(command_str,""); + switch (iclass) { + case CLASS_A : { + command = "convert -size 256x128 xc:lightblue -encoding None -font Helvetica-Bold -fill white \\\n"; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text 33,-33 'Class A\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text -99,-33 'Class A\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_B : { + command = "convert -size 256x128 xc:blue -encoding None -font Helvetica-Bold -fill white \\\n"; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text 33,-33 'Class B\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text -99,-33 'Class B\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_C : { + command = "convert -size 256x128 xc:magenta -encoding None -font Helvetica-Bold -fill white \\\n"; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text 33,-33 'Class C\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text -99,-33 'Class C\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_D : { + command = "convert -size 256x128 xc:blue -encoding None -font Helvetica-Bold -fill white \\\n"; + + command+="-draw \"rectangle 0,0,64,128\" \\\n"; + command+="-draw \"rectangle 128,0,192,128\" \\\n"; + command+="xc:white -fill black \\\n"; + + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text 33,-33 'Class D\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text -99,-33 'Class D\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_E : { + command = "convert -size 256x128 xc:magenta -encoding None -font Helvetica-Bold -fill white \\\n"; + + command+="-draw \"rectangle 0,0,64,128\" \\\n"; + command+="-draw \"rectangle 128,0,192,128\" \\\n"; + command+="xc:white -fill black \\\n"; + + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text 33,-33 'Class E\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + sprintf(command_str,"-pointsize 15 -gravity Center -draw \"text -99,-33 'Class E\\n%s\\n%s %s'\" \\\n",picao,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + +//************************************** special use airspace ***********************************************8 + + case CLASS_SA : { + command ="convert -size 256x128 xc:orange -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n";// 'Class B\\n%s\ v \n%s %s'\" \\\n" + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -45,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_SD : { + command ="convert -size 256x128 xc:red -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_SM : { + command ="convert -size 256x128 xc:yellow -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; +/* + +convert -size 256x128 xc:yellow -encoding None -font Helvetica-Bold -fill black \ +-gravity west \ +-pointsize 12 -gravity Center -draw "text -65,8 'YANKEE 1 MOA, NH\n \ +BOSTON CENTER\n \ +135.7 M 282.2 M\n \ +YANKEE 1 MOA, NH\n \ +BOSTON CENTER\n \ +135.7 M 282.2 M\n" \ +-gravity west \ +-pointsize 12 -gravity Center -draw "text 65,8 'YANKEE 1 MOA, NH\n \ +BOSTON CENTER\n \ +135.7 M 282.2 M\n \ +YANKEE 1 MOA, NH\n \ +BOSTON CENTER\n \ +135.7 M 282.2 M\n" \ +-rotate 90 \ +-compress RLE SGI:/usr/local/share/FlightGear/data/Scenery-Airspace/Objects/w080n40/w073n43/MOA-US-02350-1761659.rgb +*/ + + + break; + } + case CLASS_SP : { + command ="convert -size 256x128 xc:grey -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_SR : { + command ="convert -size 256x128 xc:grey -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_ST : { + command ="convert -size 256x128 xc:grey -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\n%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + case CLASS_SW : { + command ="convert -size 256x128 xc:red -encoding None -font Helvetica-Bold -fill black \\\n"; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text 65,-7 '%s\\n \\\n%s\\n \\\n%s %s\\nWarning:%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command+="-gravity west \\\n"; + sprintf(command_str,"-pointsize 12 -gravity Center -draw \"text -65,-7 'Warning:%s\\n \\\n%s\\n \\\n%s %s\\nWarning:%s\\n \\\n%s\\n \\\n%s %s'\" \\\n", + pname,pcomm_name,pcomm_freq1,pcomm_freq2, + pname,pcomm_name,pcomm_freq1,pcomm_freq2); + command += command_str; + command += "-rotate 90 \\\n"; + sprintf(command_str,"-compress RLE SGI:%s\n",airspace_texture_filename); + command += command_str; + break; + } + } + //string + // command = command_str; +// I put the string in the report file for debugging and tweaking experiments... + fprintf(fp_rep,"Create rgb file with command: [%s]\n",command.c_str()); +// printf("Create rgb file with command: [%s]\n",command.c_str()); + system(command.c_str()); +} + + +void write_ac_header() +{ + nkids=0; + tile_list * t_tile=current_tile; + long int ttn = current_tile->tile_nbr; + bool done=false; + while (!done) { + if (t_tile->tile_nbr==ttn) { + nkids++; + t_tile=t_tile->next; + } + else done=true; + if (t_tile==NULL) done=true; + } + if (use_texture[iclass]) { + fprintf(ac_fp,"AC3Db\nMATERIAL \"Material.001\" rgb 1 1 1 amb 0.5 0.5 0.5 emis 0 0 0 spec 1 1 1 shi 80 trans 0.7\nOBJECT world\nkids %d\n",nkids); + write_airspace_texture(); + } + else { + fprintf(ac_fp,"AC3Db\nMATERIAL \"Material.001\" rgb %f %f %f amb 0.5 0.5 0.5 emis 0 0 0 spec 1 1 1 shi 80 trans %f\nOBJECT world\nkids %d\n", + rgb_colors[iclass][0], rgb_colors[iclass][1], rgb_colors[iclass][2],rgb_transparency[iclass], nkids); + } + if (nkids==0) printf(" WARNING, no kids for ac file! "); + ikid=1; +} +void ac_from_wgs_84(double dlatc, double dlongc, double dlatp, double dlongp,double *ac_x, double *ac_y) +{ + double start_az; + double az2; + double r; + + geo_inverse_wgs_84(0.0, dlatc, dlongc, dlatp,dlongp, &start_az, &az2,&r); + + start_az+=180.0; //get ac to flightgear bearings aligned + + *ac_x = r * cos(start_az*SGD_DEGREES_TO_RADIANS); + + *ac_y = r * sin(start_az*SGD_DEGREES_TO_RADIANS); + +} + + +void write_kid(double dlatc, double dlongc, double zlow, double zhigh) +{ + double ac_x; + double ac_y; + struct pt * sp; + struct pt * cp; + struct pt * ep; + + int npts=0; + int numvert=0; + int numsurf=0; + int isurf; + int ix; + bool done; + + fprintf(ac_fp,"OBJECT poly\nname\"airspace-%d\"\n",ikid); + + + if (use_texture[iclass]) { +// sprintf(airspace_texture_filename,"%s/%s",airspace_texture_path.c_str(),airspace_texture[iclass].c_str()); + fprintf(ac_fp,"texture \"%s\"\n",airspace_texture_filename); +/* symbolic link design abandoned in favor of signed textures + string command = "ln -s "; + command += airspace_texture_filename; // SGPath(airspace_texture_filename).dir(); + command += " "; + command += SGPath(airspace_filename).dir(); + command += "/"; + command += airspace_texture[iclass].c_str(); +// cout << command << endl; + system(command.c_str()); +*/ + } +//**/ + ikid++; + +// numvert matrix + sp = current_tile->start; + ep = current_tile->end; + cp = sp; + npts=1; + while (cp!=ep) { + npts++; + cp = cp->next; + } + if (npts<2) { + printf("Warning npts is only %d\n",npts); + return; + } + numvert = 2*npts; // this design has redundant pts...used now for gator management while draining and cleaning the swimming pool... + numsurf = npts-1; + fprintf(ac_fp,"numvert %d #origin at [%11.6f] - [%11.6f] npts %d low alt [%f] high alt [%f]\n",numvert,dlatc, dlongc,npts,zlow,zhigh); + if (numvert!=0) { + cp = sp; + +// need to translate the x, y pts into their metric units with the origin at the center of the tile... + ix=0; + done=false; + while (!done) { + ac_from_wgs_84(dlatc, dlongc, cp->yp, cp->xp,&ac_x, &ac_y); + fprintf(ac_fp," %12.2f %12.2f %12.2f # pt(%4d) %11.6f %11.6f %11.6f\n", ac_x, zlow, ac_y, ix, cp->xp, zlow, cp->yp); + ix++; + if (cp!=ep) cp = cp->next; + else done=true; + } + cp = sp; + done=false; + while (!done) { + ac_from_wgs_84(dlatc, dlongc, cp->yp, cp->xp,&ac_x, &ac_y); + fprintf(ac_fp," %12.2f %12.2f %12.2f # pt(%4d) %11.6f %11.6f %11.6f\n", ac_x, zhigh, ac_y, ix, cp->xp, zhigh, cp->yp); + ix++; + if (cp!=ep) cp = cp->next; + else done=true; + } + fprintf(ac_fp,"numsurf %d\n",numsurf); + for (isurf=0; isurf %s",picao,tile_filename, tile_addline); + string command = "mkdir -p "; command += SGPath(tile_filename).dir(); + // cout << command << endl; + system(command.c_str()); + t_fp = fopen(tile_filename,"a"); + if (t_fp!=NULL) { + fprintf(t_fp,"%s\n",tile_addline); + fclose(t_fp); + } + else { + fprintf(fp_rep,"WARNING! COULD NOT APPEND TO FILE [%s]\n",tile_filename); + } +} + +bool close_airspace_file() +{ + if (ac_fp!=NULL) { + if (fclose(ac_fp) != EOF) return true; else return false; + } +} + +void set_tile_info(double * dlatc, double * dlongc) +{ + double x, y, xn, yn; + double ax, ay; + double divisor; + divisor = 1.0/sg_bucket_span(current_tile->start->next->yp); + x = (current_tile->start->xp + 1000.0)*divisor; // arbitrary transform to keep math positive and "indexed" + y = (current_tile->start->yp + 1000.0)*8.0; + xn= (current_tile->start->next->xp + 1000.0)*divisor; // arbitrary transform to keep math positive and "indexed" + yn= (current_tile->start->next->yp + 1000.0)*8.0; + + ax= (x+xn)/2.0; + ay= (y+yn)/2.0; + ax = (trunc(ax)/divisor-1000.0+trunc(ax+1.0)/divisor-1000.0)/2.0; + ay = (trunc(ay)/8.0-1000.0+trunc(ay+1.0)/8.0-1000.0)/2.0; + + *dlatc =ay; + *dlongc =ax; + + set_subpath_for(ay,ax); //current_tile->start->next->yp, current_tile->start->next->xp); + sprintf(airspace_filename, "%s/Objects/%s%s-%d.ac", output_base.c_str(), subpath, bdry_ident_safe,current_tile->tile_nbr); + if (use_texture[iclass]) sprintf(airspace_texture_filename, "%s/Objects/%s%s-%d.rgb", output_base.c_str(), subpath, bdry_ident_safe,current_tile->tile_nbr); + sprintf(airspace_filename_xml, "%s/Objects/%s%s-%d.xml", output_base.c_str(), subpath, bdry_ident_safe,current_tile->tile_nbr); + sprintf(tile_addline,"OBJECT_STATIC %s-%d.xml %f %f %f 0.00\n",bdry_ident_safe,current_tile->tile_nbr, ax, ay, altitude_high*SG_FEET_TO_METER); + sprintf( tile_filename, "%s/Objects/%s%d.stg", output_base.c_str(), subpath, current_tile->tile_nbr); + process_tile_file(); + open_airspace_file(); +} + +void process_tile_list() +{ + double dlongc; + double dlatc; + struct pt * sp; + struct pt * cp; + struct pt * ep; + + int ix; + + long int ctn; + + int nk; + + current_tile = head_tile; + ctn = current_tile->tile_nbr; + set_tile_info(&dlatc, &dlongc); + ctn = current_tile->tile_nbr; + while (current_tile !=NULL) { + if (current_tile->tile_nbr !=ctn) { + close_airspace_file(); + set_tile_info(&dlatc, &dlongc); + ctn = current_tile->tile_nbr; + } + write_kid(dlatc, dlongc, floor_alt, 0.0); //altitude_low,altitude_high); + sp = current_tile->start; + ep = current_tile->end; + cp = sp; + ix=1; + while (cp!=ep) { + ix++; + cp = cp->next; + } + if (cp->next== NULL) { + cp = cp->last; //cross over line between tile boundaries for lines 1 - (n-1) with the last tile ending with ep->next being NULL + } + current_tile=current_tile->next; + } + close_airspace_file(); +} + +void create_tile_list() +{ + int ix; + struct pt * hp = head_pt_m; + struct pt * cp = hp; + struct pt * sp = hp; + ix=1; + double txp; + double typ; + double txp2; + double typ2; + + init_tile_list(); + cp=hp; + ix=1; + + long int last_tile; + long int tile_n; + int tile_changes=0; + + struct pt * startpt=head_pt_m; + struct pt * endpt; + struct pt * lastpt = NULL; + if (hp==NULL) { + printf("create_tile_list call with NULL ptr!\n"); + return; + } + txp = cp->xp; + typ = cp->yp; + txp2 = cp->next->xp; + typ2 = cp->next->yp; + + last_tile = gen_tilenum( (txp+txp2)/2.0, (typ+typ2)/2.0); + + while ( cp->next!=NULL) { + + txp = cp->xp; + typ = cp->yp; + txp2 = cp->next->xp; + typ2 = cp->next->yp; + + tile_n = gen_tilenum( (txp+txp2)/2.0, (typ+typ2)/2.0); + + if (tile_n != last_tile) { + tile_changes++; + endpt=cp; + add_tile(last_tile,startpt,endpt); + startpt=cp; + last_tile = tile_n; + } + + cp = cp->next; + } + endpt=cp; + //printf("end tile...add_tile ( %d ... ...)\n",tile_n); + add_tile(tile_n,startpt,endpt); //cp->last); + + hp=sp; + cp=sp; + if (head_tile!=NULL) process_tile_list(); + else printf("NO TILES?\n"); +} + + + +void list_line( struct pt * hp) +{ + int ix; + struct pt * cp = hp; + struct pt * sp = hp; + ix=1; + double txp; + double typ; + double txp2; + double typ2; + cp=hp; + ix=1; + + long int last_tile=-1; + long int tile_n; + int tile_changes=-1; + + struct pt * startpt; + struct pt * endpt; + + if (hp==NULL) { + printf("list_line call with NULL ptr!\n"); + return; + } + while ( cp->next!=NULL) { + txp = cp->xp; + typ = cp->yp; + txp2 = cp->next->xp; + typ2 = cp->next->yp; + + tile_n = gen_tilenum( (txp+txp2)/2.0, (typ+typ2)/2.0); + if (last_tile<0) startpt=cp; + if (tile_n != last_tile) { + tile_changes++; + if (tile_changes>0) { + endpt=cp; + } + } + + last_tile = tile_n; + + fprintf(fp_rep,"Line [%4d] seg [%s-%s]: %11.6f , %11.6f | %11.6f , %11.6f Tile: %d", + ix, cp->seg_nbr, cp->next->seg_nbr,typ, txp, typ2, txp2, + gen_tilenum( (txp+txp2)/2.0, (typ+typ2)/2.0) + ); + // double check for zero length line segments. if the following line shows up in the output it's an oops somewhere... + if ((txp==txp2) && (typ==typ2)) fprintf(fp_rep," zero length line segment?"); + fprintf(fp_rep,"\n"); + ix++; + cp = cp->next; + } + endpt=cp; + fprintf(fp_rep,"add_tile ( %d ... ...)\n",tile_n); + txp = cp->xp; + typ = cp->yp; + txp2 = hp->xp; + typ2 = hp->yp; +#define TOLERANCE 0.0001 + if ( (fabs(txp-txp2) < TOLERANCE) && fabs(typ-typ2)xp; + typ = tail_pt_m->yp; + txp2 = head_pt->xp; + typ2 = head_pt->yp; + if ((txp==txp2) && (typ==typ2)) { + t_pt = head_pt; + delete t_pt; + head_pt = head_pt->next; + } + current_pt_m->next = head_pt; + head_pt->last=current_pt_m; + while (head_pt->next !=NULL) head_pt=head_pt->next; + tail_pt_m=head_pt; + } + } + else { + head_pt_m=head_pt; + current_pt_m=head_pt_m; + tail_pt_m=head_pt_m; + } + current_pt_m=head_pt_m; + head_pt=NULL; +} + +void erase_pt_list() { + current_pt=head_pt; + while (current_pt!=NULL) { + current_pt = current_pt->next; + delete head_pt; + head_pt = current_pt; + } +} + +void erase_master_list() { + current_pt_m=head_pt_m; + while (current_pt_m!=NULL) { + sum_boundary_pt(current_pt_m->yp, current_pt_m->xp); //track average for sign posting... + current_pt_m = current_pt_m->next; + delete head_pt_m; + head_pt_m = current_pt_m; + } +} + +void init_pt_list() +{ + if (head_pt!=NULL) add_pts_to_master(); +} + +void add_pt(double x, double y) +{ + bool done=false; + struct pt * new_pt = new struct pt; + new_pt->xp=x; + new_pt->yp=y; + strcpy(new_pt->seg_nbr,sseg_nbr); + new_pt->last=new_pt->next=NULL; + if (head_pt!=NULL) { + current_pt = head_pt; + while (!done) { + if (x < current_pt->xp) { //insert before + done=true; + if (current_pt->last!=NULL) { // in list insert + new_pt->last = current_pt->last; + new_pt->next = current_pt; + current_pt->last=new_pt; + new_pt->last->next=new_pt; + } + else { //new head + current_pt->last=new_pt; + new_pt->next=current_pt; + head_pt = new_pt; + } + } + else { + if (x!=current_pt->xp) { + if (current_pt->next!=NULL) current_pt = current_pt->next; + else { //insert after + done=true; + if (x!=current_pt->xp) { //possible fence post error where coordinate is on boundary...not a trivial chance... + current_pt->next = new_pt; + new_pt->last = current_pt; + } + else { + if (y!=current_pt->yp) { //fence post error if x and y already in list... + current_pt->next = new_pt; + new_pt->last = current_pt; + } + // else printf("point already exists. not added to list\n"); + delete new_pt; + } + } + } + else {// n/s running lines x is fixed... + if (yyp) { //insert before + done=true; + if (current_pt->last!=NULL) { // in list insert + new_pt->last = current_pt->last; + new_pt->next = current_pt; + current_pt->last=new_pt; + new_pt->last->next=new_pt; + } + else { //new head + current_pt->last=new_pt; + new_pt->next=current_pt; + head_pt = new_pt; + } + } + else { //insert after ? + if (y!=current_pt->yp) { + if (current_pt->next!=NULL) current_pt = current_pt->next; + else { + done=true; + current_pt->next = new_pt; + new_pt->last = current_pt; + } + } + else { + done=true; + // printf("n/s point already exists. not added to list\n"); + delete new_pt; + } + } + } + } + } + } + else head_pt=new_pt; +} + +int maxtilespan=-1; + +void create_line(double dlong, double dlat, double dlong2, double dlat2) +{ + double delta_long; + double delta_lat; + double delta_max; + int ntilespan; + + double x; // x and y are in "indexed" coordinates as tiles are 0-7 by 0-7... + double y; + + double xn; + double yn; + + double sx; // x and y are in "indexed" coordinates as tiles are 0-7 by 0-7... + double sy; + + double sxn; + double syn; + + + int ix; + int iy; + + double lastx; + double lasty; + + double m; + double b; + + bool swap_flag=false; + +//******* note: line needs further splitting if begining and ending lattitudes have different bucket spans + set_bucket(dlong,dlat); + double check_divisor = 1.0/sg_bucket_span(dlat2); + divisor = 1.0/sg_bucket_span(dlat); + if ( fabs(divisor - check_divisor) > SG_EPSILON ) { + fprintf(fp_rep,"WARNING: Bucket span divisor ranges from %f to %f, using larger divisor to divide lines\n",divisor, check_divisor); + //use larger divisor or first vertically chop line up... + //use larger divisor and you get say two panes in the tile instead one when the line drawing goes to one pane per line segment... + if (divisor < check_divisor) divisor = check_divisor; + } + if (gen_tilenum(dlong,dlat)!=gen_tilenum(dlong2,dlat2)) { + // printf("Line crosses tile boundaries\n"); + + delta_long = dlong-dlong2; //strtod((const char *)&swgs_dlong2,NULL); + delta_lat = dlat -dlat2; //strtod((const char *)&swgs_dlat2,NULL); + if (fabs(delta_long)>fabs(delta_lat)) delta_max= delta_long; else delta_max=delta_lat; + + ntilespan = (int) ((fabs(delta_max)/0.125)+1.0); + + if (ntilespan>maxtilespan) maxtilespan=ntilespan; +//********* a few words on why the arbitrary tranform: +//********* you then have numbers on the scalar 0, 1, 2, .... which are then the tile boundaries +//********* so.... between the end points are a sequence of intercepts for the x axis and the y axis +//********* so.... compute the various x/y intercepts and sort em.... +//********* then.. generate the line segments from p ....p.....p +//********* 0 i n +//********* there will be n-1 of them... + x = (dlong + 1000.0)*divisor; // arbitrary transform to keep math positive and "indexed" + y = (dlat + 1000.0)*8.0; + xn= (dlong2 + 1000.0)*divisor; // arbitrary transform to keep math positive and "indexed" + yn= (dlat2 + 1000.0)*8.0; + + sx=x; + sy=y; + sxn=xn; + syn=yn; + +// printf("original coordinates are %f , %f transformed coordinates %f , %f\n",dlong,dlat,x,y); +// printf(" %f , %f %f , %f\n",dlong2,dlat2,xn,yn); +// printf("inverted transforms %f , %f\n",x/divisor-1000.0, y/8.0-1000.0); +// printf(" %f , %f\n",xn/divisor-1000.0, yn/8.0-1000.0); + + init_pt_list(); + + // start list with end points... + + add_pt( x, y); + add_pt( xn, yn); + + if (x>xn) { //swap pt order... + lastx=x; + lasty=y; + x=xn; + y=yn; + xn=lastx; + yn=lasty; + lastx=xn; + lasty=yn; + } + if (fabs(delta_long) < SG_EPSILON) { //n-s line + // i.e. x is fixed + if (y>yn) { //swap y order + lasty=y; + y=yn; + yn=lasty; + lasty=y; + } + if ((int) y==(int) yn) { + ; // printf("ns1) y range is singular for %f to %f\n",y,yn); + } + else { + if ((int)y+1 < (int)yn) { + for (iy=(int)y+1; iy<(int)yn; iy++){ + add_pt( x, (double) iy); + } + } + else { + iy=(int) yn; + add_pt( x, (double) iy); + } + } + } + else { + if (fabs(delta_lat) < SG_EPSILON) { //e-w line + // printf("east west running line...\n"); + // i.e. y is fixed + if ((int) x==(int) xn) { + ; // printf("ew1) x range is singular for %f to %f\n",x,xn); + } + else { + if ((int)x+1 < (int)xn) { + for (ix=(int)x+1; ix<(int)xn; ix++){ + add_pt( (double) ix, y); + } + } + else { + ix=(int) xn; + add_pt( (double) ix, y); + } + } + } + else { // y=mx+b geometry... + + m = (yn-y)/(xn-x); + b = y-m*x; + + // check order + if (x>xn) { //swap pt order... + lastx=x; + lasty=y; + x=xn; + y=yn; + xn=lastx; + yn=lasty; + lastx=xn; + lasty=yn; + } + lasty = y; + lastx = x; + //y=mx+b + //m=(yn-y)/(xn-x) + //b= y-mx + //x=(y-b)/m + if ((int) x==(int) xn) { + // y range then... + if (yxn) { //swap pt order... + // printf("swap pt order...\n"); + // if (swap_flag) swap_flag=false else swap_flag=true; + } + } + current_pt=head_pt; + ix=1; + double txp; + double typ; + double txp2; + double typ2; + + current_pt=head_pt; + end_pt=head_pt; + ix=1; + if (current_pt!=NULL) { + while (current_pt!=NULL) { + current_pt->xp = (current_pt->xp/divisor)-1000.0; + current_pt->yp = (current_pt->yp/8.0)-1000.0; + ix++; + current_pt = current_pt->next; + } + } + else { + fprintf(fp_rep,"Warning: create_line:current_pt is null\n"); + } + current_pt=head_pt; + if (fabs(dlong-current_pt->xp) < SG_EPSILON ) { + if (fabs(dlat-current_pt->yp) < SG_EPSILON ) { + ; //printf("and y checks\n"); + } + else { + if (fabs(dlat2-current_pt->yp) < SG_EPSILON ) { + // printf("but y looks like yn, swap\n"); + swap_flag=true; + } + else { + fprintf(fp_rep,"(1) WARNING first point is neither x,y or xn, yn\n"); + } + } + } + else { + if (fabs(dlong2-current_pt->xp) < SG_EPSILON ) { + //printf("first point looks like xn swap the order\n"); + swap_flag=true; + } + else { + fprintf(fp_rep,"(2) WARNING first point is neither x,y or xn, yn\n"); + } + } + if (swap_flag) { + current_pt=head_pt; + while (current_pt!=NULL) { + t_pt=current_pt; + end_pt=current_pt; + current_pt = current_pt->next; + t_pt->next = t_pt->last; + t_pt->last = current_pt; + } + t_pt=head_pt; + head_pt=end_pt; + end_pt=t_pt; + } +} + + +void create_cw_arc(double starta, double enda, double radnm, double clong, double clat, double dlongs, double dlats, double dlonge, double dlate) +{ +//72 +//setup for clockwise arc +#define NUM_ARC_SEGMENTS 72 + double sa; + double ea; + double ca; + double ca_norm; + + double az1; + double az2; + double s; + + + sa=starta; + ea=enda; + if (sa>ea) sa-=360.0; +// sa+=180.0;//get ac to flighgear bearings aligned +// ea+=180.0; + double span = ea-sa; + + int i; + double coordinates[NUM_ARC_SEGMENTS+1][2]; + double delta_d = span / ((double)(NUM_ARC_SEGMENTS)); + + double xx; + double yy; + // double az2; +//unit circle + ca=sa+delta_d; + coordinates[0][0]=dlongs; + coordinates[0][1]=dlats; + coordinates[NUM_ARC_SEGMENTS][0]=dlonge; + coordinates[NUM_ARC_SEGMENTS][1]=dlate; + + for (i=1; i360.0) ca_norm-=360.0; + ca+=delta_d; + } + + ca=sa; + for (i=0; i360.0) ca_norm-=360.0; + ca+=delta_d; + } + for (i=0; isa) sa+=360.0; +// sa+=180.0;//get ac to flighgear bearings aligned +// ea+=180.0; + double span = sa-ea; + + int i; + double coordinates[NUM_ARC_SEGMENTS+1][2]; + double delta_d = span / ((double)(NUM_ARC_SEGMENTS)); + + double xx; + double yy; + // double az2; +//unit circle + ca=sa-delta_d; + coordinates[0][0]=dlongs; + coordinates[0][1]=dlats; + coordinates[NUM_ARC_SEGMENTS][0]=dlonge; + coordinates[NUM_ARC_SEGMENTS][1]=dlate; + + + for (i=1; i360.0) ca_norm-=360.0; + ca-=delta_d; + } + for (i=0; i=0.0) { + ew='e'; + ilongxxx = (int) dlong; //truncate + fremlongxxx = dlong - trunc(dlong); //(double) ilongxxx; + ilongxxx = (int) (dlong+0.999999); + ilongxx = (int) (ilongxxx+9.999999)/10; + } + else { + ew ='w'; + ilongxxx = (int) (0.9999999-dlong); + fremlongxxx = fabs((double) dlong) - trunc(fabs(dlong)); + ilongxx = (int)(ilongxxx+9.999999)/10; + ilongxxx = -ilongxxx; + ilongxx = -ilongxx; + } + if (dlat>=0) { + ns='n'; + ilatxxx = (int)dlat; //truncate + fremlatxxx = dlat - trunc(dlat); + ilatxxx = (int)dlat; //round down + ilatxx = (ilatxxx)/10; + } + else { + ns='s'; + ilatxxx = (int)(-dlat); //truncate + fremlatxxx = fabs(dlat) - trunc(fabs(dlat));// - (double) ilatxxx; + ilatxxx = (int)(-dlat); //round down + ilatxx = (ilatxxx)/10; + ilatxxx = -ilatxxx; + ilatxx = -ilatxx; + } + fremlatxxx = fremlatxxx*8.0; + fremlongxxx = fremlongxxx*8.0; + x = (int)fremlongxxx; //+0.999999; + y = (int)fremlatxxx; //+0.999999; + sprintf(subpath,"%c",ew); // [e] + if (abs(ilongxx)<10) sprintf(subpath,"%s0%d",subpath,abs(ilongxx)); // [e0x] + else sprintf(subpath,"%s%d",subpath,abs(ilongxx)); // [exx] + sprintf(subpath,"%s0%c",subpath,ns); // [e0x0n] or [exx0xn] + sprintf(subpath,"%s%d",subpath,abs(ilatxx)); // [e0xxnxx] + sprintf(subpath,"%s0/%c",subpath,ew); // [e0xxnxx0 + if (abs(ilongxxx)<100) sprintf(subpath,"%s0%d",subpath,abs(ilongxxx)); + else sprintf(subpath,"%s%d",subpath,abs(ilongxxx)); + sprintf(subpath,"%s%c",subpath,ns); + if (abs(ilatxxx)<10) sprintf(subpath,"%s0%d/",subpath,abs(ilatxxx)); + else sprintf(subpath,"%s%d/",subpath,abs(ilatxxx)); +} + +double decode_altitude(char *a) +{ + float small_alt; + bool fl=false; int i=0; + int i2=0; int j=0; altitude=0.0; alt_digits[i]=type_digits[j]=0; + if (a[0]=='U') { //"UNLTD" for some warning and prohibited areas...like off the east coast of Cont. US + return UPPER_ALTITUDE_LIMIT; //for unlimited upper altitudes set altitude to 14,000 feet + } if (a[0]=='F') { - fl=true; - i=2; + fl=true; + i2=2; } - while (isdigit(a[i])) { - alt_digits[i]=a[i]; - i++; - alt_digits[i]=0; - } - while (isupper(a[i])) { - type_digits[j]=a[i]; + while (isdigit(a[i2])) { + alt_digits[i]=a[i2]; i++; + i2++; + alt_digits[i]=0; + } + while (isupper(a[i2])) { + type_digits[j]=a[i2]; + i2++; j++; type_digits[j]=0; } - if (alt_digits[0]==0) altitude=0.0; else { - sscanf(alt_digits,"%f",&altitude); - if (fl) altitude*=100.0; + if (alt_digits[0]==0) { + altitude=0.0; + } + else { + sscanf(alt_digits,"%f",&small_alt); + altitude = (double) small_alt; + if (fl) { + altitude*=100.0; + } } return altitude; } -void set_floor_alt() // sets agl's artificially to zero +void set_floor_alt() // sets agl's artificially to zero when alt_low_type is "AGL" { floor_alt = altitude_low-altitude_high; if (strncmp(alt_low_type,"AGL",3) ==0 ) floor_alt = -altitude_high; @@ -1072,6 +2566,31 @@ void do_decode_altitudes() sprintf(alt_low_type,"%s",type_digits); altitude_high = decode_altitude((char *)&pupper_alt); sprintf(alt_high_type,"%s",type_digits); + if (strncmp(plower_alt,"SURFACE",7)==0) { + floor_alt = -(class_height[iclass]+CLASS_FLOOR_ADD); + } + else { // does not start at surface need to calculate floor and generate a file.. + set_floor_alt(); + } +//bug hunting...set all lower altitudes to surface.... +// floor_alt = -(class_height[iclass]+CLASS_FLOOR_ADD); + + if (strncmp(alt_high_type,"AGL",3) !=0 ){ + high_agl_flag = false; + } + else { + high_agl_flag = true; + } + if (altitude_low>= UPPER_ALTITUDE_LIMIT) high_altitude_flag=true; else high_altitude_flag=false; + + if (high_agl_flag) fprintf(fp_rep,"upper level is AGL, no output \n"); + if (high_altitude_flag) fprintf(fp_rep," lower level is at or above altitude limit [%f]\n",UPPER_ALTITUDE_LIMIT); + if ((!high_agl_flag) && (!high_altitude_flag)) { + if (altitude_high>UPPER_ALTITUDE_LIMIT) { + fprintf(fp_rep, "upper altitude limit clipped from [%f] to [%f]\n",altitude_high,UPPER_ALTITUDE_LIMIT); + altitude_high=UPPER_ALTITUDE_LIMIT; + } + } } void do_decode_radius() { @@ -1090,10 +2609,10 @@ void do_decode_radius_from_start_r() void decode_line_parameters() { - dlongp1 = strtof((const char *)&swgs_dlong1,NULL); - dlatp1 = strtof((const char *)&swgs_dlat1,NULL); - dlongp2 = strtof((const char *)&swgs_dlong2,NULL); - dlatp2 = strtof((const char *)&swgs_dlat2,NULL); + dlongp1 = strtod((const char *)&swgs_dlong1,NULL); + dlatp1 = strtod((const char *)&swgs_dlat1,NULL); + dlongp2 = strtod((const char *)&swgs_dlong2,NULL); + dlatp2 = strtod((const char *)&swgs_dlat2,NULL); geo_inverse_wgs_84(0.0, dlatp1, dlongp1, dlatp2,dlongp2, &start_az, &az2,&start_r); start_r*=SG_METER_TO_NM; @@ -1102,21 +2621,20 @@ void decode_line_parameters() void decode_arc_parameters() { - dlongc = strtof((const char *)&swgs_dlong0,NULL); - dlatc = strtof((const char *)&swgs_dlat0,NULL); + dlongc = strtod((const char *)&swgs_dlong0,NULL); + dlatc = strtod((const char *)&swgs_dlat0,NULL); if (strncmp(sshap,"R",1)==0) { // R - CLOCKWISE ARC - dlongp1 = strtof((const char *)&swgs_dlong1,NULL); - dlatp1 = strtof((const char *)&swgs_dlat1,NULL); - dlongp2 = strtof((const char *)&swgs_dlong2,NULL); - dlatp2 = strtof((const char *)&swgs_dlat2,NULL); + dlongp1 = strtod((const char *)&swgs_dlong1,NULL); + dlatp1 = strtod((const char *)&swgs_dlat1,NULL); + dlongp2 = strtod((const char *)&swgs_dlong2,NULL); + dlatp2 = strtod((const char *)&swgs_dlat2,NULL); } - if (strncmp(sshap,"L",1)==0) { // R - CLOCKWISE ARC - dlongp2 = strtof((const char *)&swgs_dlong1,NULL); - dlatp2 = strtof((const char *)&swgs_dlat1,NULL); - dlongp1 = strtof((const char *)&swgs_dlong2,NULL); - dlatp1 = strtof((const char *)&swgs_dlat2,NULL); + if (strncmp(sshap,"L",1)==0) { // R - COUNTERCLOCKWISE ARC + dlongp2 = strtod((const char *)&swgs_dlong1,NULL); + dlatp2 = strtod((const char *)&swgs_dlat1,NULL); + dlongp1 = strtod((const char *)&swgs_dlong2,NULL); + dlatp1 = strtod((const char *)&swgs_dlat2,NULL); } - geo_inverse_wgs_84(0.0, dlatc, dlongc, dlatp1,dlongp1, &start_az, &az2,&start_r); geo_inverse_wgs_84(0.0, dlatc, dlongc, dlatp2,dlongp2, &end_az, &az2,&end_r); @@ -1131,7 +2649,7 @@ void decode_arc_parameters() } //-----------------------------------do routines...main translation of DAFIF information into formatted output and generated .ac and tile files... - +/// void do_tile_list() { fprintf(fp_tiles,"(%4s) %85s <-> %s",picao,tile_filename, tile_addline); @@ -1141,233 +2659,569 @@ void do_tile_update() { if (process_class(iclass)) { do_tile_list(); - if (!cleanfiles) { - string command = "mkdir -p "; command += SGPath(tile_filename).dir(); - cout << command << endl; - system(command.c_str()); - FILE * ft = fopen(tile_filename,"a"); - if (ft!=NULL) { - printf("open for append: [%s]\n",tile_filename); - fprintf(ft,"\n##### THE FOLLOWING LINE WAS AUTOMATICALLY ADDED TO THIS FILE #####\n%s\n",tile_addline); - fclose(ft); - } - else { - cout << "WARNING! COULD NOT APPEND TO FILE [" << tile_filename << "]\n"; - } - } - else { - string command = "mkdir -p "; command += SGPath(tile_filename).dir(); - cout << command << endl; - system(command.c_str()); - FILE * ft = fopen(tile_filename,"r"); - if (ft!=NULL) { - struct stat stbuf; - stat(tile_filename,&stbuf); - char * ts; - long tsl = stbuf.st_size; - ts = (char *) calloc(tsl,sizeof(char)); - long numread =fread((void*)ts,sizeof(char),tsl,ft); - tsl=numread; - fclose(ft); - sprintf(tile_filename_bak,"%s.bak",tile_filename); - FILE * ft = fopen(tile_filename_bak,"w"); - if (ft!=NULL) { - fwrite(ts,sizeof(char),tsl,ft); - fclose(ft); - } - char * al = strstr((const char *) ts,"##### THE FOLLOWING LINE WAS AUTOMATICALLY ADDED TO THIS FILE #####"); - if (al != NULL) { - *al= '0'; - long tsrl =0; - while (&ts[tsrl]!=al) tsrl++; - FILE * ft = fopen(tile_filename,"w"); - if (ft!=NULL) { - fwrite(ts,sizeof(char),tsrl,ft); - fclose(ft); - } - } - } + string command = "mkdir -p "; command += SGPath(tile_filename).dir(); + system(command.c_str()); + FILE * ft = fopen(tile_filename,"a"); + if (ft!=NULL) { + fprintf(ft,"%s\n",tile_addline); + fclose(ft); + fprintf(fp_rep,"added line: [%s]\nto file: [%s]\n",tile_addline,tile_filename); + } + else { + fprintf(fp_rep,"WARNING! COULD NOT APPEND TO FILE [%s]\n",tile_filename); } } } -void do_floor_circle_segment() + +#define SIGN_HEIGHT_ABOVE_FIELD 6000.00 +#define SIGN_HEIGHT_ABOVE_NAVAID 10300.00 +#define SIGN_HEIGHT_ABOVE_WAYPOINT -2200.00 +#define SIGN_HEIGHT_ABOVE_T_WAYPOINT 100.0 + + +void safe_line(char * tl) { - if (process_class(iclass)) { - floor_alt = -(class_height[iclass]+CLASS_FLOOR_ADD); - sprintf(class_x_filename,"%s%s%d-%d.ac",class_path[iclass],class_circle[iclass],ir,irr); - do_circle(class_x_filename,r,floor_alt,0.0,iclass,class_dash[iclass]); - fprintf(fp_tiles_b,"%80s %5s(r)%8.0f (%s) - %8.0f (%s)\n",tile_filename,sradius1,altitude_low, alt_low_type, altitude_high, alt_high_type); - sprintf(tile_addline,"OBJECT_SHARED Models/Airspace/%s %s %s %f 0.00\n",class_x_filename,swgs_dlong0,swgs_dlat0, altitude_high*SG_FEET_TO_METER); - do_tile_update(); + int i=0; + while (tl[i]!='\0') { + if (tl[i]=='\'') tl[i]=' '; + i++; } } -void do_circle_segment() + +void write_sign_files() { - cout << " C - CIRCLE: " << swgs_dlat0 << " / " << swgs_dlong0 << " radius: " << sradius1 << " Nautical Miles\n"; - dlong = strtof((const char *)&swgs_dlong0,NULL); - dlat = strtof((const char *)&swgs_dlat0,NULL); + FILE * s_fp; + char filename[1000]; +// do tile update + dlong = strtod((const char *)&wgs_dlong,NULL); + dlat = strtod((const char *)&wgs_dlat,NULL); + + double d_elev = strtod((const char *)&elev,NULL); + set_subpath(); set_bucket(dlong,dlat); tilenum = gen_index(); - sprintf( tile_filename, "%s/Objects/%s%d.stg", - output_base.c_str(), subpath, tilenum ); - do_decode_altitudes(); - r=strtof((const char *)&sradius1,NULL); + sprintf( tile_filename, "%s/Objects/%s%d.stg",output_base.c_str(), subpath, tilenum ); + sprintf(tile_addline,"OBJECT_STATIC %s.xml %s %s %6.1f 0.0\n",airport_icao,wgs_dlong,wgs_dlat, (d_elev+SIGN_HEIGHT_ABOVE_FIELD)*SG_FEET_TO_METER); + fprintf(fp_rep,"update tile file [%s]\nwith line [%s]\n",tile_filename,tile_addline); + string command = "mkdir -p "; + command += SGPath(tile_filename).dir(); + // cout << command << endl; + system(command.c_str()); + FILE * ft = fopen(tile_filename,"a"); + if (ft!=NULL) { + fprintf(ft,"%s\n",tile_addline); + fclose(ft); + } + else { + fprintf(fp_rep,"WARNING! COULD NOT APPEND TO FILE [%s]\n",tile_filename); + } +// write xml file + sprintf( filename, "%s/Objects/%s%s.xml",output_base.c_str(), subpath,airport_icao); + fprintf(fp_rep,"write xml file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp, + "\n\n %s.ac\n \n billboard\n \n \n select\n %s\n", + airport_icao, airport_icao); + fprintf(s_fp, + " \n /sim/airspace_signs/enabled\n /sim/airspace_signs_airport/enabled\n \n \n\n"); + fclose(s_fp); + } +// write ac file + sprintf( filename, "%s/Objects/%s%s.ac",output_base.c_str(), subpath,airport_icao); + fprintf(fp_rep,"write ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp, + "AC3Db\nMATERIAL \"sign\" rgb 1 1 1 amb 1 1 1 emis 1 1 1 spec 0 0 0 shi 0 trans 0\nOBJECT poly\nname \"%s\"\ntexture \"%s.rgb\"",airport_icao, airport_icao); + fprintf(s_fp,"\nnumvert 4\n-2048 400 0\n-2048 1424 0\n 2048 1424 0\n 2048 400 0\nnumsurf 2\nSURF 0x00\nmat 0\nrefs 3\n1 0 1\n0 0 0\n2 1 1\nSURF 0x00\nmat 0\nrefs 3\n2 1 1\n0 0 0\n3 1 0\nkids 0\n"); + fclose(s_fp); + } +//create rgb file + + + char command_str[1000]; + + char * st = lookup_state((char *)&state_prov); + if (strlen(st)!=2) + sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill black -pointsize 100 -gravity Center -draw \"text 0,-30 '%s'\" -pointsize 20 -draw \"text 0,40 '%s'\" -compress RLE SGI:", + airport_icao,name); + else + sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill black -pointsize 100 -gravity Center -draw \"text 0,-30 '%s'\" -pointsize 20 -draw \"text 0,40 '%s, %s'\" -compress RLE SGI:", + airport_icao,name,st); + + //string + command = command_str; + command += output_base.c_str(); + command += "/Objects/"; + command += subpath; + command += airport_icao; + command += ".rgb"; + //cout << "create rgb file: ]" <\n\n %s.ac\n \n billboard\n \n \n select\n %s\n", + bdry_ident_safe, bdry_ident_safe); + fprintf(s_fp, + " \n /sim/airspace_signs/enabled\n /sim/airspace_signs_suas/enabled\n \n \n\n"); + fclose(s_fp); + } +// write ac file + sprintf( filename, "%s/Objects/%s%s.ac",output_base.c_str(), subpath, bdry_ident_safe); + fprintf(fp_rep,"write ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp, + "AC3Db\nMATERIAL \"sign\" rgb 1 1 1 amb 1 1 1 emis 1 1 1 spec 0 0 0 shi 0 trans 0\nOBJECT poly\nname \"%s\"\ntexture \"%s.rgb\"", bdry_ident_safe, bdry_ident_safe); + fprintf(s_fp,"\nnumvert 4\n-2048 400 0\n-2048 1424 0\n 2048 1424 0\n 2048 400 0\nnumsurf 2\nSURF 0x00\nmat 0\nrefs 3\n1 0 1\n0 0 0\n2 1 1\nSURF 0x00\nmat 0\nrefs 3\n2 1 1\n0 0 0\n3 1 0\nkids 0\n"); + fclose(s_fp); + } +//create rgb file + char command_str[1000]; + sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill black -pointsize 55 -gravity Center -draw \"text 0,-30 '%s'\" -pointsize 20 -draw \"text 0,40 '%s'\" -compress RLE SGI:", + bdry_ident_safe,pname); + + // string + command = command_str; + command += output_base.c_str(); + command += "/Objects/"; + command += subpath; + command += bdry_ident_safe; + command += ".rgb"; +// cout << "create rgb file: ]" <\n\n %s.ac\n \n billboard\n \n \n select\n %s\n", + nav_ident, nav_ident); + fprintf(s_fp, + " \n /sim/airspace_signs/enabled\n /sim/airspace_signs_navaid/enabled\n \n \n\n"); + fclose(s_fp); + } +// write ac file + sprintf( filename, "%s/Objects/%s%s.ac",output_base.c_str(), subpath, nav_ident); + fprintf(fp_rep,"write ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp, + "AC3Db\nMATERIAL \"sign\" rgb 1 1 1 amb 1 1 1 emis 1 1 1 spec 0 0 0 shi 0 trans 0\nOBJECT poly\nname \"%s\"\ntexture \"%s.rgb\"", nav_ident, nav_ident); + fprintf(s_fp,"\nnumvert 4\n-2048 400 0\n-2048 1424 0\n 2048 1424 0\n 2048 400 0\nnumsurf 2\nSURF 0x00\nmat 0\nrefs 3\n1 0 1\n0 0 0\n2 1 1\nSURF 0x00\nmat 0\nrefs 3\n2 1 1\n0 0 0\n3 1 0\nkids 0\n"); + fclose(s_fp); + } + +// write na-pillar.xml file redundant writes on n>1 per tile...thems the way it goes for now... + sprintf( filename, "%s/Objects/%sna-pillar.xml",output_base.c_str(), subpath); + fprintf(fp_rep,"write xml file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp,"\n\n na-pillar.ac\n \n select\n na-pillar\n \n"); + fprintf(s_fp," /sim/airspace_signs/enabled\n /sim/airspace_signs_navaid/enabled\n \n \n\n"); + fclose(s_fp); + } +// write wp-pillar.ac file redundant writes on n>1 per tile...thems the way it goes for now... + sprintf( filename, "%s/Objects/%sna-pillar.ac",output_base.c_str(), subpath); + + fprintf(fp_rep,"write na-pillar.ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp,"AC3Db\nMATERIAL \"Material.003\" rgb 0 0 0 amb 1 1 1 emis 0 0 0 spec 1 1 1 shi 72 trans 0.7\nOBJECT poly\nname \"na-pillar\"\nnumvert 16\n"); + fprintf(s_fp," -25 0 -25\n -25 4000 -25\n 25 4000 -25\n 25 0 -25\n -25 0 -25\n -25 4000 -25\n -25 4000 25\n -25 0 25\n"); + fprintf(s_fp," 25 0 -25\n 25 4000 -25\n 25 4000 25\n 25 0 25\n -25 0 25\n -25 4000 25\n 25 4000 25\n 25 0 25\n"); + fprintf(s_fp,"numsurf 4\nSURF 0x30\nmat 0\nrefs 4\n0 0 0\n1 0 0\n2 0 0\n3 0 0\nSURF 0x30\nmat 0\nrefs 4\n4 0 0\n5 0 0\n6 0 0\n7 0 0\nSURF 0x30\nmat 0\nrefs 4\n"); + fprintf(s_fp,"8 0 0\n9 0 0\n10 0 0\n11 0 0\nSURF 0x30\nmat 0\nrefs 4\n12 0 0\n13 0 0\n14 0 0\n15 0 0\nkids 0\n"); + fclose(s_fp); + } +//create rgb file + safe_line((char *) &nav_line_2); + char command_str[1000]; + sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill darkblue -pointsize 55 -gravity Center -draw \"text 0,-30 '%s'\" -pointsize 20 -draw \"text 0,40 '%s'\" -compress RLE SGI:", + nav_line_1,nav_line_2); + //string + command = command_str; + command += output_base.c_str(); + command += "/Objects/"; + command += subpath; + command += nav_ident; + command += ".rgb"; +// cout << "create rgb file: ]" <\n\n %s-wp.ac\n \n billboard\n \n \n select\n %s\n", + wpt_ident, wpt_ident); + + fprintf(s_fp, + " \n /sim/airspace_signs/enabled\n /sim/airspace_signs_wp/enabled\n \n \n\n"); + fclose(s_fp); + } +// write wp-pillar.xml file redundant writes on n>1 per tile...thems the way it goes for now... + sprintf( filename, "%s/Objects/%swp-pillar.xml",output_base.c_str(), subpath); + + fprintf(fp_rep,"write xml file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp,"\n\n wp-pillar.ac\n \n select\n wp-pillar\n \n"); + fprintf(s_fp," /sim/airspace_signs/enabled\n /sim/airspace_signs_wp/enabled\n \n \n\n"); + fclose(s_fp); + } + +// write ac file + sprintf( filename, "%s/Objects/%s%s-wp.ac",output_base.c_str(), subpath, wpt_ident); + fprintf(fp_rep,"write ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp, + "AC3Db\nMATERIAL \"sign\" rgb 1 1 1 amb 1 1 1 emis 1 1 1 spec 0 0 0 shi 0 trans 0\nOBJECT poly\nname \"%s\"\ntexture \"%s-wp.rgb\"", wpt_ident, wpt_ident); + fprintf(s_fp,"\nnumvert 4\n-512 400 0\n-512 912 0\n 512 912 0\n 512 400 0\nnumsurf 2\nSURF 0x00\nmat 0\nrefs 3\n1 0 1\n0 0 0\n2 1 1\nSURF 0x00\nmat 0\nrefs 3\n2 1 1\n0 0 0\n3 1 0\nkids 0\n"); + fclose(s_fp); + } +// write wp-pillar.ac file redundant writes on n>1 per tile...thems the way it goes for now... + sprintf( filename, "%s/Objects/%swp-pillar.ac",output_base.c_str(), subpath); + fprintf(fp_rep,"write wp-pillar.ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp,"AC3Db\nMATERIAL \"Material.003\" rgb 0 0 0 amb 1 1 1 emis 0 0 0 spec 1 1 1 shi 72 trans 0.7\nOBJECT poly\nname \"wp-pillar\"\nnumvert 16\n"); + fprintf(s_fp," -25 0 -25\n -25 4000 -25\n 25 4000 -25\n 25 0 -25\n -25 0 -25\n -25 4000 -25\n -25 4000 25\n -25 0 25\n"); + fprintf(s_fp," 25 0 -25\n 25 4000 -25\n 25 4000 25\n 25 0 25\n -25 0 25\n -25 4000 25\n 25 4000 25\n 25 0 25\n"); + fprintf(s_fp,"numsurf 4\nSURF 0x30\nmat 0\nrefs 4\n0 0 0\n1 0 0\n2 0 0\n3 0 0\nSURF 0x30\nmat 0\nrefs 4\n4 0 0\n5 0 0\n6 0 0\n7 0 0\nSURF 0x30\nmat 0\nrefs 4\n"); + fprintf(s_fp,"8 0 0\n9 0 0\n10 0 0\n11 0 0\nSURF 0x30\nmat 0\nrefs 4\n12 0 0\n13 0 0\n14 0 0\n15 0 0\nkids 0\n"); + fclose(s_fp); + } + + +//create rgb file + safe_line((char *) &desc); + char command_str[1000]; +// sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill blue -pointsize 55 -gravity Center -draw \"text 0,-30 '%s'\" -pointsize 27 -draw \"text 0,40 '%s'\" -compress RLE SGI:", +// wpt_ident,desc); + sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill darkblue -pointsize 120 -gravity Center -draw \"text 0,-15 '%s'\" -compress RLE SGI:", + wpt_ident); + + //string + command = command_str; + command += output_base.c_str(); + command += "/Objects/"; + command += subpath; + command += wpt_ident; +// if (s_fp != NULL) { + command += "-wp.rgb"; + +// cout << "create rgb file: ]" <\n\n %s-twp.ac\n \n billboard\n \n \n select\n %s\n", + wpt_ident, wpt_ident); + + fprintf(s_fp, + " \n /sim/airspace_signs/enabled\n /sim/airspace_signs_term_wp/enabled\n \n \n\n"); + fclose(s_fp); + } +// write wp-pillar.xml file redundant writes on n>1 per tile...thems the way it goes for now... + sprintf( filename, "%s/Objects/%stwp-pillar.xml",output_base.c_str(), subpath); + fprintf(fp_rep,"write xml file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp,"\n\n twp-pillar.ac\n \n select\n twp-pillar\n \n"); + fprintf(s_fp," /sim/airspace_signs/enabled\n /sim/airspace_signs_term_wp/enabled\n \n \n\n"); + fclose(s_fp); + } + +// write ac file + sprintf( filename, "%s/Objects/%s%s-twp.ac",output_base.c_str(), subpath, wpt_ident); + fprintf(fp_rep,"write ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp, + "AC3Db\nMATERIAL \"sign\" rgb 1 1 1 amb 1 1 1 emis 1 1 1 spec 0 0 0 shi 0 trans 0\nOBJECT poly\nname \"%s\"\ntexture \"%s-twp.rgb\"", wpt_ident, wpt_ident); + fprintf(s_fp,"\nnumvert 4\n-256 400 0\n-256 656 0\n 256 656 0\n 256 400 0\nnumsurf 2\nSURF 0x00\nmat 0\nrefs 3\n1 0 1\n0 0 0\n2 1 1\nSURF 0x00\nmat 0\nrefs 3\n2 1 1\n0 0 0\n3 1 0\nkids 0\n"); + fclose(s_fp); + } +// write wp-pillar.ac file redundant writes on n>1 per tile...thems the way it goes for now... + sprintf( filename, "%s/Objects/%stwp-pillar.ac",output_base.c_str(), subpath); + fprintf(fp_rep,"write twp-pillar.ac file [%s]\n",filename); + s_fp = fopen(filename,"w+"); + if (s_fp != NULL) { + fprintf(s_fp,"AC3Db\nMATERIAL \"Material.003\" rgb 0 0 0 amb 1 1 1 emis 0 0 0 spec 1 1 1 shi 72 trans 0.7\nOBJECT poly\nname \"twp-pillar\"\nnumvert 16\n"); + fprintf(s_fp," -25 0 -25\n -25 4000 -25\n 25 4000 -25\n 25 0 -25\n -25 0 -25\n -25 4000 -25\n -25 4000 25\n -25 0 25\n"); + fprintf(s_fp," 25 0 -25\n 25 4000 -25\n 25 4000 25\n 25 0 25\n -25 0 25\n -25 4000 25\n 25 4000 25\n 25 0 25\n"); + fprintf(s_fp,"numsurf 4\nSURF 0x30\nmat 0\nrefs 4\n0 0 0\n1 0 0\n2 0 0\n3 0 0\nSURF 0x30\nmat 0\nrefs 4\n4 0 0\n5 0 0\n6 0 0\n7 0 0\nSURF 0x30\nmat 0\nrefs 4\n"); + fprintf(s_fp,"8 0 0\n9 0 0\n10 0 0\n11 0 0\nSURF 0x30\nmat 0\nrefs 4\n12 0 0\n13 0 0\n14 0 0\n15 0 0\nkids 0\n"); + fclose(s_fp); + } + + +//create rgb file + safe_line((char *) &desc); + char command_str[1000]; + sprintf(command_str,"convert -size 256x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill darkred -pointsize 60 -gravity Center -draw \"text 0,-40 '%s'\" -pointsize 40 -draw \"text 0,30 '%s'\" -compress RLE SGI:", + wpt_ident,icao); +// sprintf(command_str,"convert -size 512x128 xc:none -gravity center -encoding None -font Helvetica-Bold -fill darkred -pointsize 40 -gravity Center -draw \"text 0,-15 '%s'\" -compress RLE SGI:", +// wpt_ident); + + //string + command = command_str; + command += output_base.c_str(); + command += "/Objects/"; + command += subpath; + command += wpt_ident; +// if (s_fp != NULL) { + command += "-twp.rgb"; + + fprintf(fp_rep,"Create rgb file: [%s]\n",command.c_str()); + +// cout << "create rgb file: ]" <=sizeof(pname)) done=true; + } + if (nx!=0) { + ix=0; + // printf("use pname [%s] up to the %d'th character\n",pname,nx+1); + for (ix=0; ixelevation+1000.0); + } + else fprintf(fp_rep,"terminal waypoint [%s] not associated with airport...skipped\n",icao); + } + } + } + } + } +// else { +// printf("skip country code [%s]\n",ctry); +// } + +} + + +void read_navaid() +{ + read_field(fp_navaid,(char *)&nav_ident,sizeof(nav_ident),tc); + read_field(fp_navaid,(char *)&type,sizeof(type),tc); + read_field(fp_navaid,(char *)&ctry,sizeof(ctry),tc); + read_field(fp_navaid,(char *)&nav_key_cd,sizeof(nav_key_cd),tc); + read_field(fp_navaid,(char *)&state_prov,sizeof(state_prov),tc); + read_field(fp_navaid,(char *)&name,sizeof(name),tc); + read_field(fp_navaid,(char *)&icao,sizeof(icao),tc); + read_field(fp_navaid,(char *)&wac,sizeof(wac),tc); + read_field(fp_navaid,(char *)&freq,sizeof(freq),tc); + read_field(fp_navaid,(char *)&usage_cd,sizeof(usage_cd),tc); + read_field(fp_navaid,(char *)&chan,sizeof(chan),tc); + read_field(fp_navaid,(char *)&rcc,sizeof(rcc),tc); + read_field(fp_navaid,(char *)&freq_prot,sizeof(freq_prot),tc); + read_field(fp_navaid,(char *)&power,sizeof(power),tc); + read_field(fp_navaid,(char *)&nav_range,sizeof(nav_range),tc); + read_field(fp_navaid,(char *)&loc_hdatum,sizeof(loc_hdatum),tc); + read_field(fp_navaid,(char *)&wgs_datum,sizeof(wgs_datum),tc); + read_field(fp_navaid,(char *)&wgs_lat,sizeof(wgs_lat),tc); + read_field(fp_navaid,(char *)&wgs_dlat,sizeof(wgs_dlat),tc); + read_field(fp_navaid,(char *)&wgs_long,sizeof(wgs_long),tc); + read_field(fp_navaid,(char *)&wgs_dlong,sizeof(wgs_dlong),tc); + read_field(fp_navaid,(char *)&slaved_var,sizeof(slaved_var),tc); + read_field(fp_navaid,(char *)&mag_var,sizeof(mag_var),tc); + read_field(fp_navaid,(char *)&elev,sizeof(elev),tc); + read_field(fp_navaid,(char *)&dme_wgs_lat,sizeof(dme_wgs_lat),tc); + read_field(fp_navaid,(char *)&dme_wgs_dlat,sizeof(dme_wgs_dlat),tc); + read_field(fp_navaid,(char *)&dme_wgs_long,sizeof(dme_wgs_long),tc); + read_field(fp_navaid,(char *)&dme_wgs_dlong,sizeof(dme_wgs_dlong),tc); + read_field(fp_navaid,(char *)&dme_elev,sizeof(dme_elev),tc); + read_field(fp_navaid,(char *)&arpt_icao,sizeof(arpt_icao),tc); + read_field(fp_navaid,(char *)&os,sizeof(os),tc); + read_field(fp_navaid,(char *)&cycle_date,sizeof(cycle_date),tc2); + + if (strncmp(ctry,country,2)==0) { + + + +/** + + 1 - VOR + 2 - VORTAC + 3 - TACAN + 4 - VOR-DME + 5 - NDB + 7 - NDB-DME + 9 - DME (EXCLUDING ILS-DME) + + +**/ + if (strncmp(elev,"U",1)!=0) { +/* +xxxx --------yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -------- ---- ---- [-------------] - [-------------] 55555 +*/ + + fprintf(fp_rep,"%4s ",nav_ident); + if (strncmp(type,"1",1)==0) + fprintf(fp_rep," VOR "); + else + if (strncmp(type,"2",1)==0) + fprintf(fp_rep," VORTAC "); + else + if (strncmp(type,"3",1)==0) + fprintf(fp_rep," TACAN "); + else + if (strncmp(type,"4",1)==0) + fprintf(fp_rep," VOR-DME"); + else + if (strncmp(type,"5",1)==0) + fprintf(fp_rep," NDB "); + else + if (strncmp(type,"7",1)==0) + fprintf(fp_rep," NDB-DME"); + else + if (strncmp(type,"9",1)==0) + fprintf(fp_rep," DME "); + else + fprintf(fp_rep," UNKOWN "); + +//xx printf(" key [%2s] ",nav_key_cd); +// printf("%38s ",name); +//xx printf(" icao [%4s] ",icao); +//xx printf(" icao (airport) [%4s] ",arpt_icao); +// printf("%8s ",freq); +/** + H - HIGH LEVEL + L - LOW LEVEL + B - BOTH + R - RNAV + T - TERMINAL + +**/ + + if (strncmp(usage_cd,"H",1)==0) + fprintf(fp_rep," HIGH LEVEL "); + else + if (strncmp(usage_cd,"L",1)==0) + fprintf(fp_rep," LOW LEVEL "); + else + if (strncmp(usage_cd,"B",1)==0) + fprintf(fp_rep," BOTH "); + else + if (strncmp(usage_cd,"H",1)==0) + fprintf(fp_rep," RNAV "); + else + if (strncmp(usage_cd,"H",1)==0) + fprintf(fp_rep," TERMINAL "); + else + fprintf(fp_rep," unknwn use "); + +// printf("%4s ",chan); + + fprintf(fp_rep," rcc [%5s] ",rcc); + if (strncmp(rcc," H",2)==0) + fprintf(fp_rep," NON-DIRECTIONAL RADIO BEACON (HOMING), POWER 50 WATTS TO LESS THAN 2000 WATTS."); + else + if (strncmp(rcc," L",2)==0) + fprintf(fp_rep," NORMAL ANTICIPATED INTERFERENCE-FREE SERVICE 40 NM UP TO 18,000 FEET."); + else + if (strncmp(rcc," T",2)==0) + fprintf(fp_rep," NORMAL ANTICIPATED INTERFERENCE-FREE SERVICE 25 NM UP TO 12,000 FEET."); + else + if (strncmp(rcc,"MH",2)==0) + fprintf(fp_rep," NON-DIRECTIONAL RADIO BEACON (HOMING) POWERLESS THAN 50 WATTS."); + else + if (strncmp(rcc,"HH",2)==0) + fprintf(fp_rep," NON-DIRECTIONAL RADIO BEACON (HOMING), POWER 2000 WATTS OR MORE."); + else + if (strncmp(rcc,"HA",2)==0) + fprintf(fp_rep," NORMAL ANTICIPATED INTERFERENCE - FREE SERVICE BELOW 18,000 FEET - 40 NM; 14,500 - 17,999 FEET - 100 NM (CONTIGUOUS 48 STATES ONLY); 18,000 FEET TO FL 450 - 130 NM; ABOVE FL 450 - 100"); + else + if (strncmp(rcc,"HH",2)==0) + fprintf(fp_rep," UNKNOWN."); + + +/** + H - NON-DIRECTIONAL RADIO BEACON (HOMING), POWER 50 WATTS TO LESS THAN 2000 WATTS. + + L - NORMAL ANTICIPATED INTERFERENCE-FREE SERVICE 40 NM UP TO 18,000 FEET. + + T - NORMAL ANTICIPATED INTERFERENCE-FREE SERVICE 25 NM UP TO 12,000 FEET. + + MH - NON-DIRECTIONAL RADIO BEACON (HOMING) POWERLESS THAN 50 WATTS.- + + HH - NON-DIRECTIONAL RADIO BEACON (HOMING), POWER 2000 WATTS OR MORE. + + HA - NORMAL ANTICIPATED INTERFERENCE - FREE SERVICE BELOW 18,000 FEET - 40 NM; 14,500 - 17,999 FEET - 100 NM (CONTIGUOUS 48 STATES ONLY); 18,000 FEET TO FL 450 - 130 NM; ABOVE FL 450 - 100 + NM. + + U - UNKNOWN + + +**/ + + +//xx printf(" freq_prot [%9s] ",freq_prot); +//xx printf(" power [%4s] ",power); +//xx printf(" nav_range [%3s] ",nav_range); +//xx printf(" dme_elev [%5s] ",dme_elev); +//xx printf(" os [%s] ",os); + + +// printf("[%13s] - [%13s] ",wgs_dlat, wgs_dlong); +// printf("%5s",elev); + + +// printf("\n"); + fprintf(fp_rep,"["); + fprintf(fp_rep,"%s",nav_ident); + sprintf(nav_line_1,"%s",nav_ident); + + if (strncmp(type,"1",1)==0) { + fprintf(fp_rep," VOR "); + sprintf(nav_line_1,"%s VOR",nav_line_1); + } + else + if (strncmp(type,"2",1)==0) { + fprintf(fp_rep," VORTAC "); + sprintf(nav_line_1,"%s VORTAC",nav_line_1); + } + else + if (strncmp(type,"3",1)==0) { + fprintf(fp_rep," TACAN "); + sprintf(nav_line_1,"%s TACAN",nav_line_1); + } + else + if (strncmp(type,"4",1)==0) { + fprintf(fp_rep," VOR-DME"); + sprintf(nav_line_1,"%s VOR-DME",nav_line_1); + } + else + if (strncmp(type,"5",1)==0) { + fprintf(fp_rep," NDB "); + sprintf(nav_line_1,"%s NDB",nav_line_1); + } + else + if (strncmp(type,"7",1)==0) { + fprintf(fp_rep," NDB-DME"); + sprintf(nav_line_1,"%s NDB-DME",nav_line_1); + } + else + if (strncmp(type,"9",1)==0) { + fprintf(fp_rep," DME "); + sprintf(nav_line_1,"%s DME",nav_line_1); + } + else { + fprintf(fp_rep," UNKOWN "); + sprintf(nav_line_1,"%s UNKNOWN",nav_line_1); + } + + fprintf(fp_rep,"][%s ",name); + sprintf(nav_line_2,"%s",name); + + // if (frequency()>0.0) { + // printf("[%f]",strtod((const char *) &freq,NULL)/1000.0); + if (freq[6]=='K') { + fprintf(fp_rep,"%3.0fK",strtod((const char *) &freq,NULL)/1000.0); + sprintf(nav_line_2,"%s %3.0fK",nav_line_2, strtod((const char *) &freq,NULL)/1000.0); + } + else { + fprintf(fp_rep,"%5.1fM",strtod((const char *) &freq,NULL)/1000.0); + sprintf(nav_line_2,"%s %5.1fM",nav_line_2, strtod((const char *) &freq,NULL)/1000.0); + } +// } + if (chan[0]!='\0') { + chan[3]='\0'; + fprintf(fp_rep," %s",chan); + sprintf(nav_line_2,"%s %s",nav_line_2, chan); + } + fprintf(fp_rep," coordinates [%f] - [%f] [%f]",strtod((const char *) wgs_dlat,NULL), strtod((const char *) wgs_dlong,NULL), strtod((const char *) elev, NULL)); + write_sign_files_navaid( strtod((const char *) wgs_dlat,NULL), strtod((const char *) wgs_dlong,NULL), strtod((const char *) elev, NULL)); + +// printf("[%13s] - [%13s] ",wgs_dlat, wgs_dlong); +// printf("%5s",elev); + + fprintf(fp_rep,"]\n"); + + } + } //not country... +// else printf("skipped navaid\n"); +} + +void find_airport ( char *f, int fs) +{ + // char tc='\t'; + // char tc2='\n'; + bool found=false; + int i=0; + // int n; + char ch; + while (!found) { + if (!putbackflag) { + fairport[0]=i=0; + while (peek(fp_airport)!= '\t') { + fairport[i]=fgetc(fp_airport); + i++; + if (i\n\n %s\n \n select\n ils-glideslope\n \n /sim/airspace_ils_glideslope/enabled\n \n \n\n" + ,ils_glideslope_filename_ac); + fclose(ils_gs_fp); + } +// write ac file + ils_gs_fp = fopen(ils_glideslope_filename_ac_long,"w+"); + if (ils_gs_fp != NULL) { + fprintf(ils_gs_fp, + "AC3Db\nMATERIAL \"Material.003\" rgb 1 0 0 amb 0.5 0.5 0.5 emis 0 0 0 spec 1 1 1 shi 72 trans 0\nOBJECT world\nname \"ils-glideslope\"\nnumvert 6\n"); + + double gs_data[3][3]; + double ils_gs_length_nm=5.0; + double ils_gs_angle_plus=1.0; + double ils_gs_width_ft=strtod((const char *)&_rwy_width[i_rwy],NULL); //150.0; + double ils_gs_length=ils_gs_length_nm*SG_NM_TO_METER; + gs_data[0][0]=0.0; + gs_data[0][1]=0.0; + gs_data[0][2]=15.2; + + gs_data[1][0]=ils_gs_length; + + gs_data[1][1]=sin(ils_gs_angle*SGD_DEGREES_TO_RADIANS)*ils_gs_length; + gs_data[1][2]=SG_FEET_TO_METER*ils_gs_width_ft/2.0; + + gs_data[2][0]=ils_gs_length; + gs_data[2][1]=sin((ils_gs_angle+ils_gs_angle_plus)*SGD_DEGREES_TO_RADIANS)*ils_gs_length; + gs_data[2][2]=SG_FEET_TO_METER*ils_gs_width_ft/2.0;; + + int gsi; + for (gsi=0; gsi<3; gsi++) { + fprintf(ils_gs_fp,"%f %f %f\n",gs_data[gsi][0],gs_data[gsi][1],-gs_data[gsi][2]); + } + for (gsi=0; gsi<3; gsi++) { + fprintf(ils_gs_fp,"%f %f %f\n",gs_data[gsi][0],gs_data[gsi][1],gs_data[gsi][2]); + } + fprintf(ils_gs_fp, + "numsurf 2\nSURF 0x01\nmat 0\nrefs 3\n0 0 0\n1 0 0\n2 0 0\nSURF 0x01\nmat 0\nrefs 3\n3 0 0\n4 0 0\n5 0 0\nkids 0\n"); + fclose(ils_gs_fp); + } +} +void generate_glideslope() +{ + i_rwy = lookup_rwy_index((char *)&rwy_ident_ref); //_last); + if (i_rwy >=0) { + if (ils_thd_crossing_hgt<=BAD_ELEVATION) { + ils_thd_crossing_hgt=50.0; + fprintf(fp_rep,"Threshold crossing height set to [%f]\n",ils_thd_crossing_hgt); + } + if (ils_gs_angle<=BAD_GS_ANGLE) { + ils_gs_angle=3.0; + fprintf(fp_rep,"Glide slope angle not specified, set to [%f] degrees\n",ils_gs_angle); + } + + ils_elev = strtod((const char *)_rwy_elev,NULL) + ils_thd_crossing_hgt; + + fprintf(fp_rep,"Set glideslope visual for runway [%s] at lat [%s] long [%s] at elevation [%f] (thd_x_hgt) [%f] with angle [%f]\n",_rwy_ident[i_rwy],_rwy_lat[i_rwy],_rwy_long[i_rwy],ils_elev,ils_thd_crossing_hgt,ils_gs_angle); + if (ils_inner_lat!=BAD_LAT_LONG) { + fprintf(fp_rep,"Set inner marker at lat [%f] long [%f] for marker [%s]\n",ils_inner_lat,ils_inner_long,ils_inner_name); + } + if (ils_middle_lat!=BAD_LAT_LONG) { + fprintf(fp_rep,"Set middle marker at lat [%f] long [%f] for marker [%s]\n",ils_middle_lat,ils_middle_long,ils_middle_name); + } + if (ils_outer_lat!=BAD_LAT_LONG) { + fprintf(fp_rep,"Set outer marker at lat [%f] long [%f] for marker [%s]\n",ils_outer_lat,ils_outer_long,ils_outer_name); + } + write_ils_glideslope(); + } + else { + fprintf(fp_rep,"Warning: no runway record for ILS runway [%s] [%s]\n",rwy_ident_last, rwy_ident); + } +} void open_files() { - fp_class_e = fopen("circle_radiu_class_e.txt","w+"); - fp_class_d = fopen("circle_radiu_class_d.txt","w+"); - fp_class_b = fopen("circle_radiu_class_b.txt","w+"); - fp_class_c = fopen("circle_radiu_class_c.txt","w+"); - - fp_arcs = fopen("arcs.txt","w+"); - fp_arcs_surface = fopen("arcs_surface.txt","w+"); - fp_arcs_amsl = fopen("arcs_amsl.txt","w+"); - - fp_lines = fopen("lines.txt","w+"); - fp_lines_surface = fopen("lines_surface.txt","w+"); - fp_lines_amsl = fopen("lines_amsl.txt","w+"); - - fp_tile_numbers=fopen("tile_numbers.txt","w+"); fp_tiles = fopen("tile_pathlist.txt","w+"); - fp_tiles_b = fopen("tile_pathlist_b.txt","w+"); - fp_tiles_c = fopen("tile_pathlist_c.txt","w+"); - fp_tiles_d = fopen("tile_pathlist_d.txt","w+"); - fp_tiles_e = fopen("tile_pathlist_e.txt","w+"); } void close_files() { - fclose(fp_class_e); - fclose(fp_class_d); - fclose(fp_class_b); - fclose(fp_class_c); - fclose(fp_arcs); - fclose(fp_arcs_surface); - fclose(fp_arcs_amsl); - - fclose(fp_lines); - fclose(fp_lines_surface); - fclose(fp_lines_amsl); - - fclose(fp_tile_numbers); fclose(fp_tiles); - fclose(fp_tiles_b); - fclose(fp_tiles_c); - fclose(fp_tiles_d); - fclose(fp_tiles_e); - +// fclose(fp_icao); } + int main(int argc, char **argv) { int narg; int jarg; unsigned int i; - char country[2]; + bool no_special=false; bool no_class_bcd=false; + bool no_airport=false; + bool no_navaid=false; + bool no_waypoint=false; + bool no_ils=false; if (argc<2) { cout << "form: airspace code options \nwhere code is a two character mnemomic\n"; cout << "or\n"; - cout << " airspace code clean\nwhere code is a two character mnemomic and clean (case sensitive) requests to clean auto generated lines from tile files\n"; - cout << " options are --no-special --no-class-bcd \n"; + cout << " airspace code\nwhere code is a two character mnemomic\n"; + cout << " options are --no-special --no-class-bcd --no-airport --no-navaid --no-waypoint --no-ils\n"; return 1; } - if (argc==3) { - if (strncmp("clean",argv[2],5)==0) { - cleanfiles=true; - } - } - if (argc>=3){ + // printf("okay 1 argc is %d\n",argc); + if (argc>2){ narg=argc-2; for (jarg=0; jarg2) ) { + if (strncmp(icao,"PH",2) !=0) { ///hawai + if (strncmp(icao,"PA",2) !=0) { ///ALASKA + strncpy((char *)&airport_icao,(char *)&icao,sizeof(airport_icao)); + } + else { + sprintf(airport_icao,"%s",faa_host_id); + } + } + else { + sprintf(airport_icao,"%s",faa_host_id); + } + } else { + sprintf(airport_icao,"%s",faa_host_id); + if (isdigit(airport_icao[1])) { + int ai; + for (ai=0; ai < (strlen(airport_icao)); ai++) { + airport_icao[ai]=airport_icao[ai+1]; + } + } + } + fprintf(fp_rep,"airport_icao [%s] icao [%s] faa_host_id [%s] name [%s]\n",airport_icao,icao, faa_host_id,name); + if (get_icao((char *)&airport_icao)==NULL) add_icao((char *)&airport_icao,strtod((char *)&elev,NULL)); + + write_sign_files(); + find_runways((char *) &arpt_ident,sizeof(arpt_ident)); + } + } + fprintf(fp_rep,"\nNumber of Airports %d\n",nairports); + fclose(fp_airport); + fclose(fp_runway); } + + current_icao=head_icao; + int n_icao=1; + while (current_icao!=NULL) { + fprintf(fp_rep,"%d [%s] [%f]\n",n_icao, current_icao->_icao,current_icao->elevation); + n_icao++; + current_icao = current_icao->next; + } + + + fclose(fp_rep); //close the summary report... + + +//**************************************************************************** Navaid signage *********************************************************** +// no_navaid=true; + fp_rep = fopen("summary-navaid.txt","w+"); //navaid processing + if (!no_navaid) { + SGPath d_navaid(dafift_base); + d_navaid.append("./DAFIFT/NAV/NAV.TXT"); + fp_navaid = fopen( d_navaid.c_str(), "r" ); + read_field(fp_navaid,(char *)&header,sizeof(header),'\n'); + fprintf(fp_rep," id type name freq chan lat long elev \n"); + fprintf(fp_rep,"xxxx --------yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -------- ---- [-------------] - [-------------] -----\n"); + while (nextok(fp_navaid)) { + read_navaid(); + } + fclose(fp_navaid); + } + fclose(fp_rep); //close the summary report... +//**************************************************************************** Waypoint signage *********************************************************** +// no_waypoint=true; + fp_rep = fopen("summary-waypoint.txt","w+"); //waypoint processing + if (!no_waypoint) { + SGPath d_waypoint(dafift_base); + d_waypoint.append("./DAFIFT/WPT/WPT.TXT"); + fp_waypoint = fopen( d_waypoint.c_str(), "r" ); + if (fp_waypoint !=NULL) { + read_field(fp_waypoint,(char *)&header,sizeof(header),'\n'); + fprintf(fp_rep," id type name freq chan lat long elev \n"); + fprintf(fp_rep,"xxxx --------yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -------- ---- [-------------] - [-------------] -----\n"); + while (nextok(fp_waypoint)) { + read_waypoint(); + } + } + fclose(fp_waypoint); + fprintf(fp_rep," Waypoints by type: unnamed [%d] ndb [%d] named [%d] off [%d] vfr [%d]\n",type_unnamed,type_ndb,type_named,type_off,type_vfr); + fprintf(fp_rep," Usage: high [%d] low [%d] both [%d] rnav [%d] term [%d]\n",high_usage,low_usage,both_usage, rnav_usage,term_usage); + fprintf(fp_rep," processed %d total %d skips %d\n",nwp-nwpskip,nwp, nwpskip); + } + else { + fprintf(fp_rep,"could not open waypoint file\n"); + } + fclose(fp_rep); //close the summary report... + + +//**************************************************************************** ILS *********************************************************** +//snooping stage... +// fp_rep = fopen("stdout","w+"); //ils processing; +// no_ils=true; +// ILS records + int nils=0; + fp_rep = fopen("summary-ils.txt","w+"); //ils processing; + + if (!no_ils) { + do_vfr_glideslope=false; //suppress double vfr glideslope generation... +// ILS.TXT leads the show with runways by airport code so you then look up the airport... + SGPath d_ils(dafift_base); + d_ils.append("./DAFIFT/ARPT/ILS.TXT"); + SGPath d_airport(dafift_base); + d_airport.append("./DAFIFT/ARPT/ARPT.TXT"); + fp_ils = fopen( d_ils.c_str(), "r" ); + fp_airport = fopen( d_airport.c_str(), "r" ); + + SGPath d_runway(dafift_base); + d_runway.append("./DAFIFT/ARPT/RWY.TXT"); + fp_runway = fopen( d_runway.c_str(), "r" ); + read_field(fp_runway,(char *)&header,sizeof(header),'\n'); + + read_field(fp_ils,(char *)&header,sizeof(header),'\n'); + read_field(fp_airport,(char *)&header,sizeof(header),'\n'); + bdry_ident_last[0]=0; + putbackflag=false; //segment carry over + char ref_arpt_ident[8]; + read_field(fp_ils,(char *)&arpt_ident,sizeof(arpt_ident),tc); + bool done =false; + while (!done) { //nextok(fp_ils)) { + if (strncmp(arpt_ident,country,2)==0) { + strncpy((char *)&ref_arpt_ident,(char *)&arpt_ident,sizeof(arpt_ident)); +// printf("find airport: [%s]\n",arpt_ident); + find_airport((char *) &arpt_ident,sizeof(arpt_ident)); + +// fprintf(fp_rep, "\nAirport Identifier: [" << arpt_ident << "] name: [" << name << "] ICAO: ["<< icao << "] faa host id: [" << faa_host_id +// << "] type: [" << type << "] lat [" << wgs_dlat << "] long [" << wgs_dlong << "]\n"; //cycle date: [" << acycle_date << "]\n"; + fprintf(fp_rep,"\nAirport Identifier: [%s] name: [%s] ICAO: [%s] faa host id: [%s] type: [%s] lat [%s] long [%s]\n", + arpt_ident, name, icao, faa_host_id, type, wgs_dlat, wgs_dlong); + + find_runways((char *) &arpt_ident,sizeof(arpt_ident)); + + + rwy_ident_ref[0]='\0'; + rwy_ident_changed=false; + + ils_elev = BAD_ELEVATION; + ils_thd_crossing_hgt = BAD_ELEVATION; + ils_gs_angle = BAD_GS_ANGLE; + ils_inner_long = BAD_LAT_LONG; + ils_middle_long = BAD_LAT_LONG; + ils_outer_long = BAD_LAT_LONG; + ils_inner_lat = BAD_LAT_LONG; + ils_middle_lat = BAD_LAT_LONG; + ils_outer_lat = BAD_LAT_LONG; + + while (strncmp(ref_arpt_ident,arpt_ident,sizeof(arpt_ident))==0) { + read_ils(); + nils++; + read_field(fp_ils,(char *)&arpt_ident,sizeof(arpt_ident),tc); + } + generate_glideslope(); + + if (ils_elev <= BAD_ELEVATION) fprintf(fp_rep,"WARNING no elevation referenced for ILS Glideslope!\n"); +// fprintf(fp_rep,"\nGlide slope located at lat [%f] long [%f] at elevation [%f]\n",ils_lat, ils_long, ils_elev); + + } + else { + // printf("[%s] not country [%s] so skip_record\n",arpt_ident,country); + skip_record(fp_ils); + if ((nextok(fp_ils))) + read_field(fp_ils,(char *)&arpt_ident,sizeof(arpt_ident),tc); + else { + done=true; + // printf("end of file!\n"); + } + } + } + // printf("number of records for country %s with unique boundary identifiers is %d\n",country,ncountry); - cout << "\nNumber of Airports " << nairports << "\n"; - fclose(fp_airport); - fclose(fp_runway); + fprintf(fp_rep, "\nNumber of ILS runways %d\n", nils); + fclose(fp_airport); + fclose(fp_ils); + } + fclose(fp_rep); //close the summary report... close_files(); - +// printf("maxtilespan was %d\n",maxtilespan); +// printf("good lists were %d, bad lists were %d\n",good_lists, bad_lists); return 0; - -} + } diff --git a/src/Airspace/support_files/.fgfsrc b/src/Airspace/support_files/.fgfsrc new file mode 100644 index 00000000..a16bd398 --- /dev/null +++ b/src/Airspace/support_files/.fgfsrc @@ -0,0 +1,28 @@ + +--fg-scenery=/usr/local/share/FlightGear/data/Scenery-Airspace:/usr/local/share/FlightGear/data/Scenery +--timeofday=noon +--disable-skyblend +--fog-disable +--disable-clouds +--visibility-miles=50 +--disable-clouds3d +--disable-random-objects +--enable-fullscreen +--fov=75.0 + +--prop:/sim/airspace_signs/enabled=1.0 +--prop:/sim/airspace_signs_airport/enabled=1.0 +--prop:/sim/airspace_signs_suas/enabled=1.0 + +--prop:/sim/airspace/enabled=1.0 +--prop:/sim/airspace_b/enabled=1.0 +--prop:/sim/airspace_c/enabled=1.0 +--prop:/sim/airspace_d/enabled=1.0 + +--prop:/sim/airspace_alert/enabled=1.0 +--prop:/sim/airspace_danger/enabled=1.0 +--prop:/sim/airspace_moa/enabled=1.0 +--prop:/sim/airspace_prohibited/enabled=1.0 +--prop:/sim/airspace_restricted/enabled=1.0 +--prop:/sim/airspace_temporary/enabled=1.0 +--prop:/sim/airspace_warning/enabled=1.0 diff --git a/src/Airspace/support_files/airspace.xml b/src/Airspace/support_files/airspace.xml new file mode 100755 index 00000000..ee076c7b --- /dev/null +++ b/src/Airspace/support_files/airspace.xml @@ -0,0 +1,197 @@ + + + + + + airspace + false + vbox + + + + + + + + + + hbox + + + 10 + + + + vbox + + + + vbox + + left + + /sim/airspace_vfr_glideslope/enabled + + + left + + /sim/airspace_ils_glideslope/enabled + + + + + left + + /sim/airspace_signs/enabled + + + + + left + + /sim/airspace_signs_airport/enabled + + + left + + /sim/airspace_signs_navaid/enabled + + + left + + /sim/airspace_signs_suas/enabled + + + left + + /sim/airspace_signs_term_wp/enabled + + + left + + /sim/airspace_signs_wp/enabled + + + + + + + left + + /sim/airspace/enabled + + + + + + left + + /sim/airspace_a/enabled + + + left + + /sim/airspace_b/enabled + + + left + + /sim/airspace_c/enabled + + + left + + /sim/airspace_d/enabled + + + left + + /sim/airspace_e/enabled + + + left + + /sim/airspace_alert/enabled + + + left + + /sim/airspace_danger/enabled + + + left + + /sim/airspace_moa/enabled + + + left + + /sim/airspace_prohibited/enabled + + + left + + /sim/airspace_restricted/enabled + + + left + + /sim/airspace_temporary/enabled + + + left + + /sim/airspace_warning/enabled + + + + true + + + + + + hbox + 6 + true + + + + + + + + + + true + + diff --git a/src/Airspace/support_files/glide-slope-1nm-by-3d.ac b/src/Airspace/support_files/glide-slope-1nm-by-3d.ac new file mode 100644 index 00000000..e5fd0eec --- /dev/null +++ b/src/Airspace/support_files/glide-slope-1nm-by-3d.ac @@ -0,0 +1,25 @@ +AC3Db +MATERIAL "Material.003" rgb 0 0 0 amb 0.5 0.5 0.5 emis 0 0 0 spec 1 1 1 shi 72 trans 0 +OBJECT world +name "glideslope" +numvert 6 + 0.0 0.0 -15.2 + 1852.0 96.9 -15.2 + 1852.0 129.2 -15.2 + 0.0 0.0 15.2 + 1852.0 96.9 15.2 + 1852.0 129.2 15.2 +numsurf 2 +SURF 0x01 +mat 0 +refs 3 +0 0 0 +1 0 0 +2 0 0 +SURF 0x01 +mat 0 +refs 3 +3 0 0 +4 0 0 +5 0 0 +kids 0 diff --git a/src/Airspace/support_files/glide-slope.xml b/src/Airspace/support_files/glide-slope.xml new file mode 100644 index 00000000..b35b0db1 --- /dev/null +++ b/src/Airspace/support_files/glide-slope.xml @@ -0,0 +1,11 @@ + + + glide-slope-1nm-by-3d.ac + + select + glideslope + + /sim/airspace_vfr_glideslope/enabled + + + diff --git a/src/Airspace/support_files/menubar.xml b/src/Airspace/support_files/menubar.xml new file mode 100644 index 00000000..15e81837 --- /dev/null +++ b/src/Airspace/support_files/menubar.xml @@ -0,0 +1,487 @@ + + + + + + + + + dialog-show + save_flight + + + + + + + dialog-show + load_flight + + + + + + + + + old-reinit-dialog + + + + + + + hires-screen-capture + + + + + + + screen-capture + + + + + + + old-print-dialog + + + + + + + dialog-show + sound-dialog + + + + + + + old-properties-dialog + + + + + + + dialog-show + logging + + + + + + + dialog-show + exit + + + + + + + + + + + + dialog-show + airspace + + + + + + + + property-toggle + /sim/panel/visibility + + + + + + + dialog-show + rendering + + + + + + + dialog-show + pilot_offset + + + + + + + dialog-show + hud + + + + + + + dialog-show + replay + + + + + + + dialog-show + static-lod + + + + + + + + + + + + dialog-show + location-on-ground + + + + + + + dialog-show + location-in-air + + + + + + + dialog-show + airports + + + + + + + property-assign + /sim/presets/trim + false + + + property-randomize + /orientation/pitch-deg + 0 + 360 + + + property-randomize + /orientation/roll-deg + 0 + 360 + + + property-randomize + /orientation/heading-deg + 0 + 360 + + + + + + + dialog-show + location-of-tower + + + + + + + + autopilot + + + + + dialog-show + autopilot + + + + + + + old-ap-add-waypoint-dialog + + + + + + + old-ap-pop-waypoint-dialog + + + + + + + old-ap-clear-route-dialog + + + + + + + + + old-lat-lon-format-dialog + + + + + + + + + + + + dialog-show + weather_scenario + + + + + + + dialog-show + weather + + + + + + + dialog-show + clouds + + + + + + + dialog-show + timeofday + + + + + + + + + + + fuel-and-payload + + nasal + + + + + + + + dialog-show + radios + + + + + + + dialog-show + gps + + + + + + + dialog-show + instruments + + + + + + + dialog-show + system-failures + + + + + + + dialog-show + instrument-failures + + + + + + + + + + + + ATC-freq-search + + + + + + + dialog-show + atc-ai + + + + + + + + + + + + reinit + gui + + + + + + + reinit + input + + + + + + + panel-load + + + + + + + reinit + xml-autopilot + + + + + + + dialog-show + nasal-console + + + + + + + nasal + + + + + + + + + + + + + old-help-dialog + + + + + + + nasal + + + + + + + + nasal + + + + + + + + nasal + + + + + + + tutorial-start + + nasal + + + + + + + tutorial-stop + false + + nasal + + + + + + diff --git a/src/Airspace/support_files/readme b/src/Airspace/support_files/readme new file mode 100644 index 00000000..d6889f95 --- /dev/null +++ b/src/Airspace/support_files/readme @@ -0,0 +1,34 @@ +This folder includes a sample .fgfsrc file which is normally +in the home directory on linux systems as a hidden file. + +airspace.xml is a menu to control toggling on and off various +airspace features such as signage, which types of airspace to +display etc. + +menubar.xml is the tweaked version of the flighgear menubar to +add in the airspace.xml menu system. + +glide-slope-1nm-by-3d.ac and glide-slope.xml are for displaying +3 degree glideslopes for runways with known altitudes for the +runway ends. + +Where to put em... + +.fgfsrc into your home directory, typically + +/home/user/.fgfsrc + +menubar.xml into +/usr/local/share/FlightGear/data/gui/menubar.xml +airspace.xml into +/usr/local/share/FlightGear/data/gui/airspace.xml + +and the glide slope files into +/usr/local/share/FlightGear/data/Models/Airport/glide-slope-1nm-by-3d.ac +/usr/local/share/FlightGear/data/Models/Airport/glide-slope.xml + +Where to put the DAFIF files: unpack the dafif file so the +folders for ARPT etc are in +/usr/local/share/DAFIFT/DAFIFT/ +i.e put the DAFIFT.zip file in: +/usr/local/share/DAFIFT