]> git.mxchange.org Git - flightgear.git/blobdiff - GenAirports/main.cxx
Use long int for index instead of just int.
[flightgear.git] / GenAirports / main.cxx
index 77b9607c3dcb7154e5abc8747b9fd924b2b8c5c2..7ad07f6db0b57a750c5152438dd8c450b9dc7393 100644 (file)
 
 
 // write out airport data
-void write_airport( int p_index, list_container hull_list, FGBucket b, 
+void write_airport( long int p_index, list_container hull_list, FGBucket b, 
                    const string& root, const bool cut_and_keep ) {
     char tile_name[256], poly_index[256];
 
-    long int b_index = b.gen_index();
     string base = b.gen_base_path();
     string path = root + "/Scenery/" + base;
     string command = "mkdir -p " + path;
     system( command.c_str() );
 
+    long int b_index = b.gen_index();
     sprintf(tile_name, "%ld", b_index);
     string aptfile = path + "/" + tile_name;
 
-    sprintf( poly_index, "%d", p_index );
+    sprintf( poly_index, "%ld", p_index );
     aptfile += ".";
     aptfile += poly_index;
     cout << "apt file = " << aptfile << endl;
@@ -73,13 +73,20 @@ void write_airport( int p_index, list_container hull_list, FGBucket b,
         exit(-1);
     }
 
+    // polygon type
     if ( cut_and_keep ) {
        fprintf( fd, "AirportKeep\n" );
     } else {
        fprintf( fd, "AirportIgnore\n" );
     }
+
+    // number of contours
+    fprintf( fd, "1\n" );
+
+    // size of first contour
     fprintf( fd, "%d\n", hull_list.size() );
-    // write perimeter polygon
+
+    // write contour (polygon) points
     list_iterator current = hull_list.begin();
     list_iterator last = hull_list.end();
     for ( ; current != last ; ++current ) {
@@ -146,8 +153,8 @@ void process_airport( string airport, list < string > & runway_list,
        string rwy_width = rwy_str.substr(43, 4);
        sscanf( rwy_width.c_str(), "%d", &width);
        string rwy_sfc = rwy_str.substr(47, 4);
-       string rwy_end1 = rwy_str.substr(52, 6);
-       string rwy_end2 = rwy_str.substr(59, 6);
+       string rwy_end1 = rwy_str.substr(52, 8);
+       string rwy_end2 = rwy_str.substr(61, 8);
 
        /*
        cout << "  no    = " << rwy_no << endl;
@@ -160,7 +167,7 @@ void process_airport( string airport, list < string > & runway_list,
        cout << "  end1  = " << rwy_end1 << endl;
        cout << "  end2  = " << rwy_end2 << endl;
        */
-       
+
        rwy_list = gen_runway_area( lon, lat, hdg * DEG_TO_RAD, 
                                    (double)len * FEET_TO_METER,
                                    (double)width * FEET_TO_METER );
@@ -190,7 +197,7 @@ void process_airport( string airport, list < string > & runway_list,
     hull_list = convex_hull(apt_list);
 
     // get next polygon index
-    int index = poly_index_next();
+    long int index = poly_index_next();
 
     // find average center, min, and max point of convex hull
     point2d average, min, max;
@@ -234,7 +241,7 @@ void process_airport( string airport, list < string > & runway_list,
        cout << "airport spans tile boundaries" << endl;
        cout << "  dx = " << dx << "  dy = " << dy << endl;
 
-       if ( (dx > 1) || (dy > 1) ) {
+       if ( (dx > 2) || (dy > 2) ) {
            cout << "somethings really wrong!!!!" << endl;
            exit(-1);
        }
@@ -276,7 +283,7 @@ int main( int argc, char **argv ) {
     system( command.c_str() );
 
     // initialize persistant polygon counter
-    string counter_file = work_dir + "/polygon.counter";
+    string counter_file = work_dir + "/../work.counter";
     poly_index_init( counter_file );
 
     fg_gzifstream in( argv[1] );
@@ -317,7 +324,7 @@ int main( int argc, char **argv ) {
        } else if ( line[0] == 'R' ) {
            // runway entry
            runway_list.push_back(line);
-       } else if ( line == "99" ) {
+       } else if ( line == "[End]" ) {
            // end of file
            break;
        } else {
@@ -337,6 +344,18 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.11  1999/03/19 00:27:38  curt
+// Use long int for index instead of just int.
+//
+// Revision 1.10  1999/03/17 23:51:25  curt
+// Changed polygon index counter file.
+//
+// Revision 1.9  1999/03/12 22:54:19  curt
+// Rearrange a bit of code ...
+//
+// Revision 1.8  1999/03/01 15:35:26  curt
+// Fixed bug in output format generated.
+//
 // Revision 1.7  1999/02/25 21:32:49  curt
 // Modified to adhere to new polygon naming convention, and also to read the
 // new Robin Peel aiport format.