1
0
Fork 0

- use SG_LOG throughout instead of cout/cerr

- in main.cxx, make the default log level SG_INFO rather than SG_DEBUG
  (developers can easily change it back during testing)

- replace all instances of exit() with an exception throw, caught in
  main.cxx, so that the program can go on processing the rest of the
  airports; to restore the old behaviour, just add an exit() to the
  catch clause

(Unfortunately, this still does not guarantee a full processing run,
because triangle.c in the library can invoke exit() when it gets
hopelessly confused.)
This commit is contained in:
david 2002-03-22 15:05:54 +00:00
parent f42cdc4578
commit 58634b2dfc
11 changed files with 235 additions and 282 deletions

View file

@ -28,6 +28,8 @@
#endif #endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/exception.hxx>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> // for atoi() atof() #include <stdlib.h> // for atoi() atof()
@ -36,11 +38,6 @@
#include <list> #include <list>
#include STL_STRING #include STL_STRING
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <plib/sg.h> // plib include #include <plib/sg.h> // plib include
#include <simgear/constants.h> #include <simgear/constants.h>
@ -92,17 +89,17 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
Point3D min = tp.get_min(); Point3D min = tp.get_min();
Point3D max = tp.get_max(); Point3D max = tp.get_max();
double angle = tp.get_angle(); double angle = tp.get_angle();
cout << "section heading = " << angle << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "section heading = " << angle);
cout << "center = " << center << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "center = " << center);
cout << "min = " << min << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "min = " << min);
cout << "max = " << max << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "max = " << max);
Point3D p, t; Point3D p, t;
double x, y, tx, ty; double x, y, tx, ty;
for ( i = 0; i < in_poly.contours(); ++i ) { for ( i = 0; i < in_poly.contours(); ++i ) {
for ( j = 0; j < in_poly.contour_size( i ); ++j ) { for ( j = 0; j < in_poly.contour_size( i ); ++j ) {
p = in_poly.get_pt( i, j ); p = in_poly.get_pt( i, j );
cout << "point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "point = " << p);
// //
// 1. Calculate distance and bearing from the center of // 1. Calculate distance and bearing from the center of
@ -115,7 +112,7 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
double az1, az2, dist; double az1, az2, dist;
geo_inverse_wgs_84( 0, center.y(), center.x(), p.y(), p.x(), geo_inverse_wgs_84( 0, center.y(), center.x(), p.y(), p.x(),
&az1, &az2, &dist ); &az1, &az2, &dist );
// cout << "basic course = " << az1 << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "basic course = " << az1);
// //
// 2. Rotate this back into a coordinate system where Y // 2. Rotate this back into a coordinate system where Y
@ -123,11 +120,11 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
// //
double course = az1 - angle + 90; double course = az1 - angle + 90;
// cout << "course = " << course << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "course = " << course);
while ( course < -360 ) { course += 360; } while ( course < -360 ) { course += 360; }
while ( course > 360 ) { course -= 360; } while ( course > 360 ) { course -= 360; }
// cout << "Dist = " << dist << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Dist = " << dist);
// cout << " Course = " << course * 180.0 / SGD_PI << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " Course = " << course * 180.0 / SGD_PI);
// //
// 3. Convert from polar to cartesian coordinates // 3. Convert from polar to cartesian coordinates
@ -135,16 +132,16 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
x = cos( course * SGD_DEGREES_TO_RADIANS ) * dist; x = cos( course * SGD_DEGREES_TO_RADIANS ) * dist;
y = sin( course * SGD_DEGREES_TO_RADIANS ) * dist; y = sin( course * SGD_DEGREES_TO_RADIANS ) * dist;
cout << " x = " << x << " y = " << y << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " x = " << x << " y = " << y);
cout << " min = " << min << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " min = " << min);
cout << " max = " << max << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " max = " << max);
// //
// 4. Map x, y point into texture coordinates // 4. Map x, y point into texture coordinates
// //
tx = (x - min.x()) / (max.x() - min.x()); tx = (x - min.x()) / (max.x() - min.x());
tx = ((int)(tx * 100)) / 100.0; tx = ((int)(tx * 100)) / 100.0;
cout << " (" << tx << ")" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " (" << tx << ")");
if ( clip_result ) { if ( clip_result ) {
if ( tx < 0.0 ) { tx = 0.0; } if ( tx < 0.0 ) { tx = 0.0; }
@ -154,7 +151,7 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
// ty = (y - min.y()) / (max.y() - min.y()); // ty = (y - min.y()) / (max.y() - min.y());
ty = (max.y() - y) / (max.y() - min.y()); ty = (max.y() - y) / (max.y() - min.y());
ty = ((int)(ty * 100)) / 100.0; ty = ((int)(ty * 100)) / 100.0;
cout << " (" << ty << ")" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " (" << ty << ")");
if ( clip_result ) { if ( clip_result ) {
if ( ty < 0.0 ) { ty = 0.0; } if ( ty < 0.0 ) { ty = 0.0; }
@ -162,7 +159,7 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
} }
t = Point3D( tx, ty, 0 ); t = Point3D( tx, ty, 0 );
cout << " (" << tx << ", " << ty << ")" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " (" << tx << ", " << ty << ")");
result.add_node( i, t ); result.add_node( i, t );
} }
@ -198,19 +195,19 @@ point_list calc_elevations( const string& root, const point_list& geod_nodes ) {
// try 3 arcsec dems first // try 3 arcsec dems first
string dem_path = root + "/DEM-3/" + base string dem_path = root + "/DEM-3/" + base
+ "/" + b.gen_index_str() + ".dem"; + "/" + b.gen_index_str() + ".dem";
cout << "dem_path = " << dem_path << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "dem_path = " << dem_path);
if ( ! array.open(dem_path) ) { if ( ! array.open(dem_path) ) {
cout << "ERROR: cannot open 3 arcsec file " << dem_path << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "ERROR: cannot open 3 arcsec file " << dem_path);
cout << "trying 30 arcsec file" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "trying 30 arcsec file");
// try 30 arcsec dem // try 30 arcsec dem
dem_path = root + "/DEM-30/" + base dem_path = root + "/DEM-30/" + base
+ "/" + b.gen_index_str() + ".dem"; + "/" + b.gen_index_str() + ".dem";
cout << "dem_path = " << dem_path << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "dem_path = " << dem_path);
if ( ! array.open(dem_path) ) { if ( ! array.open(dem_path) ) {
cout << "ERROR: cannot open 3 arcsec file " SG_LOG(SG_GENERAL, SG_ALERT,
<< dem_path << endl; "ERROR: cannot open 30 arcsec file " << dem_path);
} }
} }
array.parse( b ); array.parse( b );
@ -222,7 +219,7 @@ point_list calc_elevations( const string& root, const point_list& geod_nodes ) {
for ( j = 0; j < (int)result.size(); ++j ) { for ( j = 0; j < (int)result.size(); ++j ) {
if ( result[j].z() < -9000 ) { if ( result[j].z() < -9000 ) {
done = false; done = false;
cout << "interpolating for " << result[j] << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "interpolating for " << result[j]);
elev = array.interpolate_altitude( result[j].x() * 3600.0, elev = array.interpolate_altitude( result[j].x() * 3600.0,
result[j].y() * 3600.0 ); result[j].y() * 3600.0 );
if ( elev > -9000 ) { if ( elev > -9000 ) {
@ -243,11 +240,11 @@ point_list calc_elevations( const string& root, const point_list& geod_nodes ) {
// strip trailing spaces // strip trailing spaces
static void my_chomp( string& str ) { static void my_chomp( string& str ) {
cout << "my_chomp()" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "my_chomp()");
cout << "'" << str.substr( str.length() - 1, 1 ) << "'" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "'" << str.substr( str.length() - 1, 1 ) << "'");
while ( str.substr( str.length() - 1, 1 ) == " " ) { while ( str.substr( str.length() - 1, 1 ) == " " ) {
str = str.substr( 0, str.length() - 1 ); str = str.substr( 0, str.length() - 1 );
cout << "'" << str.substr( str.length() - 1, 1 ) << "'" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "'" << str.substr( str.length() - 1, 1 ) << "'");
} }
} }
@ -259,9 +256,9 @@ void build_runway( const FGRunway& rwy_info,
FGPolygon *accum, FGPolygon *accum,
FGPolygon *apt_base ) FGPolygon *apt_base )
{ {
cout << "surface flags = " << rwy_info.surface_flags << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "surface flags = " << rwy_info.surface_flags);
string surface_flag = rwy_info.surface_flags.substr(1, 1); string surface_flag = rwy_info.surface_flags.substr(1, 1);
cout << "surface flag = " << surface_flag << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "surface flag = " << surface_flag);
string material; string material;
if ( surface_flag == "A" ) { if ( surface_flag == "A" ) {
@ -295,13 +292,12 @@ void build_runway( const FGRunway& rwy_info,
} else if ( surface_flag == "W" ) { } else if ( surface_flag == "W" ) {
// water ??? // water ???
} else { } else {
cout << "unknown runway type!" << endl; throw sg_exception("unknown runway type!");
exit(-1);
} }
string type_flag = rwy_info.surface_flags.substr(2, 1); string type_flag = rwy_info.surface_flags.substr(2, 1);
cout << "type flag = " << type_flag << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "type flag = " << type_flag);
if ( rwy_info.really_taxiway ) { if ( rwy_info.really_taxiway ) {
gen_taxiway( rwy_info, material, gen_taxiway( rwy_info, material,
@ -330,9 +326,7 @@ void build_runway( const FGRunway& rwy_info,
// unknown runway code ... hehe, I know, let's just die // unknown runway code ... hehe, I know, let's just die
// right here so the programmer has to fix his code if a // right here so the programmer has to fix his code if a
// new code ever gets introduced. :-) // new code ever gets introduced. :-)
cout << "Unknown runway code in build.cxx:build_airport()" << endl; throw sg_exception("Unknown runway code in build.cxx:build_airport()");
cout << "dying ..." << endl;
exit(-1);
} }
FGPolygon base; FGPolygon base;
@ -369,7 +363,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
double apt_lon, apt_lat; double apt_lon, apt_lat;
int elev; int elev;
cerr << airport_raw << endl; SG_LOG(SG_GENERAL, SG_INFO, airport_raw);
string apt_type = airport_raw.substr(0, 1); string apt_type = airport_raw.substr(0, 1);
string apt_code = airport_raw.substr(2, 4); my_chomp( apt_code ); string apt_code = airport_raw.substr(2, 4); my_chomp( apt_code );
string apt_lat_str = airport_raw.substr(7, 10); string apt_lat_str = airport_raw.substr(7, 10);
@ -384,22 +378,22 @@ void build_airport( string airport_raw, string_list& runways_raw,
string apt_name = airport_raw.substr(40); string apt_name = airport_raw.substr(40);
/* /*
cout << " type = " << apt_type << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " type = " << apt_type);
cout << " code = " << apt_code << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " code = " << apt_code);
cout << " lat = " << apt_lat << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " lat = " << apt_lat);
cout << " lon = " << apt_lon << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " lon = " << apt_lon);
cout << " elev = " << apt_elev << " " << elev << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " elev = " << apt_elev << " " << elev);
cout << " use = " << apt_use << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " use = " << apt_use);
cout << " twr = " << apt_twr << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " twr = " << apt_twr);
cout << " bldg = " << apt_bldg << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " bldg = " << apt_bldg);
cout << " name = " << apt_name << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " name = " << apt_name);
*/ */
SGBucket b( apt_lon, apt_lat ); SGBucket b( apt_lon, apt_lat );
Point3D center_geod( b.get_center_lon() * SGD_DEGREES_TO_RADIANS, Point3D center_geod( b.get_center_lon() * SGD_DEGREES_TO_RADIANS,
b.get_center_lat() * SGD_DEGREES_TO_RADIANS, 0 ); b.get_center_lat() * SGD_DEGREES_TO_RADIANS, 0 );
Point3D gbs_center = sgGeodToCart( center_geod ); Point3D gbs_center = sgGeodToCart( center_geod );
cout << b.gen_base_path() << "/" << b.gen_index_str() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, b.gen_base_path() << "/" << b.gen_index_str());
// Ignore any seaplane bases // Ignore any seaplane bases
if ( apt_type == "S" ) { if ( apt_type == "S" ) {
@ -418,7 +412,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
rwy.really_taxiway = false; rwy.really_taxiway = false;
cout << rwy_str << endl; SG_LOG(SG_GENERAL, SG_DEBUG, rwy_str);
rwy.rwy_no = rwy_str.substr(2, 4); rwy.rwy_no = rwy_str.substr(2, 4);
string rwy_lat = rwy_str.substr(6, 10); string rwy_lat = rwy_str.substr(6, 10);
@ -454,19 +448,19 @@ void build_airport( string airport_raw, string_list& runways_raw,
string rwy_stopway2 = rwy_str.substr(84, 6); string rwy_stopway2 = rwy_str.substr(84, 6);
rwy.stopway2 = atoi( rwy_stopway2.c_str() ); rwy.stopway2 = atoi( rwy_stopway2.c_str() );
cout << " no = " << rwy.rwy_no << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " no = " << rwy.rwy_no);
cout << " lat = " << rwy_lat << " " << rwy.lat << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " lat = " << rwy_lat << " " << rwy.lat);
cout << " lon = " << rwy_lon << " " << rwy.lon << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " lon = " << rwy_lon << " " << rwy.lon);
cout << " hdg = " << rwy_hdg << " " << rwy.heading << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " hdg = " << rwy_hdg << " " << rwy.heading);
cout << " len = " << rwy_len << " " << rwy.length << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " len = " << rwy_len << " " << rwy.length);
cout << " width = " << rwy_width << " " << rwy.width << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " width = " << rwy_width << " " << rwy.width);
cout << " sfc = " << rwy.surface_flags << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_flags);
cout << " end1 = " << rwy.end1_flags << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " end1 = " << rwy.end1_flags);
cout << " dspth1= " << rwy_disp_threshold1 << " " << rwy.disp_thresh1 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " dspth1= " << rwy_disp_threshold1 << " " << rwy.disp_thresh1);
cout << " stop1 = " << rwy_stopway1 << " " << rwy.stopway1 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " stop1 = " << rwy_stopway1 << " " << rwy.stopway1);
cout << " end2 = " << rwy.end2_flags << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " end2 = " << rwy.end2_flags);
cout << " dspth2= " << rwy_disp_threshold2 << " " << rwy.disp_thresh2 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " dspth2= " << rwy_disp_threshold2 << " " << rwy.disp_thresh2);
cout << " stop2 = " << rwy_stopway2 << " " << rwy.stopway2 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " stop2 = " << rwy_stopway2 << " " << rwy.stopway2);
runways.push_back( rwy ); runways.push_back( rwy );
} }
@ -482,7 +476,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
taxi.really_taxiway = true; taxi.really_taxiway = true;
cout << rwy_str << endl; SG_LOG(SG_GENERAL, SG_DEBUG, rwy_str);
taxi.rwy_no = rwy_str.substr(2, 4); taxi.rwy_no = rwy_str.substr(2, 4);
string rwy_lat = rwy_str.substr(6, 10); string rwy_lat = rwy_str.substr(6, 10);
@ -503,15 +497,15 @@ void build_airport( string airport_raw, string_list& runways_raw,
taxi.surface_flags = rwy_str.substr(48, 3); taxi.surface_flags = rwy_str.substr(48, 3);
/* /*
cout << " no = " << rwy_no << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " no = " << rwy_no);
cout << " lat = " << rwy_lat << " " << lat << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " lat = " << rwy_lat << " " << lat);
cout << " lon = " << rwy_lon << " " << lon << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " lon = " << rwy_lon << " " << lon);
cout << " hdg = " << rwy_hdg << " " << hdg << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " hdg = " << rwy_hdg << " " << hdg);
cout << " len = " << rwy_len << " " << len << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " len = " << rwy_len << " " << len);
cout << " width = " << rwy_width << " " << width << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " width = " << rwy_width << " " << width);
cout << " sfc = " << rwy_sfc << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " sfc = " << rwy_sfc);
cout << " end1 = " << rwy_end1 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " end1 = " << rwy_end1);
cout << " end2 = " << rwy_end2 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " end2 = " << rwy_end2);
*/ */
taxiways.push_back( taxi ); taxiways.push_back( taxi );
@ -555,7 +549,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
// write_polygon( accum, "accum" ); // write_polygon( accum, "accum" );
if ( apt_base.total_size() == 0 ) { if ( apt_base.total_size() == 0 ) {
cout << "no airport points generated" << endl; SG_LOG(SG_GENERAL, SG_ALERT, "no airport points generated");
return; return;
} }
@ -578,10 +572,10 @@ void build_airport( string airport_raw, string_list& runways_raw,
// Try to remove duplicated nodes and other degeneracies // Try to remove duplicated nodes and other degeneracies
for ( k = 0; k < (int)rwy_polys.size(); ++k ) { for ( k = 0; k < (int)rwy_polys.size(); ++k ) {
cout << "add nodes/remove dups section = " << k SG_LOG(SG_GENERAL, SG_DEBUG, "add nodes/remove dups section = " << k
<< " " << rwy_polys[k].get_material() << endl; << " " << rwy_polys[k].get_material());
FGPolygon poly = rwy_polys[k].get_poly(); FGPolygon poly = rwy_polys[k].get_poly();
cout << "total size before = " << poly.total_size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "total size before = " << poly.total_size());
for ( i = 0; i < poly.contours(); ++i ) { for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size(i); ++j ) { for ( j = 0; j < poly.contour_size(i); ++j ) {
Point3D tmp = poly.get_pt(i, j); Point3D tmp = poly.get_pt(i, j);
@ -590,8 +584,8 @@ void build_airport( string airport_raw, string_list& runways_raw,
} }
poly = remove_dups( poly ); poly = remove_dups( poly );
cout << "total size after remove_dups() = " SG_LOG(SG_GENERAL, SG_DEBUG, "total size after remove_dups() = "
<< poly.total_size() << endl; << poly.total_size());
for ( i = 0; i < poly.contours(); ++i ) { for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size(i); ++j ) { for ( j = 0; j < poly.contour_size(i); ++j ) {
@ -601,8 +595,8 @@ void build_airport( string airport_raw, string_list& runways_raw,
} }
poly = reduce_degeneracy( poly ); poly = reduce_degeneracy( poly );
cout << "total size after reduce_degeneracy() = " SG_LOG(SG_GENERAL, SG_DEBUG, "total size after reduce_degeneracy() = "
<< poly.total_size() << endl; << poly.total_size());
for ( i = 0; i < poly.contours(); ++i ) { for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size(i); ++j ) { for ( j = 0; j < poly.contour_size(i); ++j ) {
@ -664,7 +658,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
for ( k = 0; k < (int)rwy_polys.size(); ++k ) { for ( k = 0; k < (int)rwy_polys.size(); ++k ) {
FGPolygon poly = rwy_polys[k].get_poly(); FGPolygon poly = rwy_polys[k].get_poly();
poly = add_nodes_to_poly( poly, tmp_nodes ); poly = add_nodes_to_poly( poly, tmp_nodes );
cout << "total size after add nodes = " << poly.total_size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "total size after add nodes = " << poly.total_size());
#if 0 #if 0
char tmp[256]; char tmp[256];
@ -680,35 +674,35 @@ void build_airport( string airport_raw, string_list& runways_raw,
FGPolygon poly = rwy_polys[k].get_poly(); FGPolygon poly = rwy_polys[k].get_poly();
poly = remove_dups( poly ); poly = remove_dups( poly );
cout << "total size after remove_dups() = " << poly.total_size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "total size after remove_dups() = " << poly.total_size());
poly = remove_bad_contours( poly ); poly = remove_bad_contours( poly );
cout << "total size after remove_bad() = " << poly.total_size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "total size after remove_bad() = " << poly.total_size());
rwy_polys[k].set_poly( poly ); rwy_polys[k].set_poly( poly );
} }
cout << "add nodes base " << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "add nodes base ");
base_poly = add_nodes_to_poly( base_poly, tmp_nodes ); base_poly = add_nodes_to_poly( base_poly, tmp_nodes );
// write_polygon( base_poly, "base-add" ); // write_polygon( base_poly, "base-add" );
cout << "remove dups base " << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "remove dups base ");
base_poly = remove_dups( base_poly ); base_poly = remove_dups( base_poly );
cout << "remove bad contours base" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "remove bad contours base");
base_poly = remove_bad_contours( base_poly ); base_poly = remove_bad_contours( base_poly );
// write_polygon( base_poly, "base-fin" ); // write_polygon( base_poly, "base-fin" );
// tesselate the polygons and prepair them for final output // tesselate the polygons and prepair them for final output
for ( i = 0; i < (int)rwy_polys.size(); ++i ) { for ( i = 0; i < (int)rwy_polys.size(); ++i ) {
cout << "Tesselating section = " << i << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating section = " << i);
FGPolygon poly = rwy_polys[i].get_poly(); FGPolygon poly = rwy_polys[i].get_poly();
cout << "total size before = " << poly.total_size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "total size before = " << poly.total_size());
FGPolygon tri = polygon_tesselate_alt( poly ); FGPolygon tri = polygon_tesselate_alt( poly );
cout << "total size after = " << tri.total_size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "total size after = " << tri.total_size());
FGPolygon tc; FGPolygon tc;
if ( rwy_polys[i].get_flag() ) { if ( rwy_polys[i].get_flag() ) {
cout << "no clip" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "no clip");
tc = rwy_section_tex_coords( tri, texparams[i], false ); tc = rwy_section_tex_coords( tri, texparams[i], false );
} else { } else {
tc = rwy_section_tex_coords( tri, texparams[i], true ); tc = rwy_section_tex_coords( tri, texparams[i], true );
@ -719,7 +713,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
rwy_polys[i].set_tri_mode( GL_TRIANGLES ); rwy_polys[i].set_tri_mode( GL_TRIANGLES );
} }
cout << "Tesselating base" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating base");
FGPolygon base_tris = polygon_tesselate_alt( base_poly ); FGPolygon base_tris = polygon_tesselate_alt( base_poly );
#if 0 #if 0
@ -785,25 +779,25 @@ void build_airport( string airport_raw, string_list& runways_raw,
p.sety( base_tris.get_pt(0, 0).y() * SGD_DEGREES_TO_RADIANS ); p.sety( base_tris.get_pt(0, 0).y() * SGD_DEGREES_TO_RADIANS );
p.setz( 0 ); p.setz( 0 );
Point3D vnt = sgGeodToCart( p ); Point3D vnt = sgGeodToCart( p );
// cout << "geod = " << p << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "geod = " << p);
// cout << "cart = " << tmp << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "cart = " << tmp);
sgdVec3 tmp; sgdVec3 tmp;
sgdSetVec3( tmp, vnt.x(), vnt.y(), vnt.z() ); sgdSetVec3( tmp, vnt.x(), vnt.y(), vnt.z() );
sgdNormalizeVec3( tmp ); sgdNormalizeVec3( tmp );
Point3D vn( tmp[0], tmp[1], tmp[2] ); Point3D vn( tmp[0], tmp[1], tmp[2] );
cout << "found normal for this airport = " << tmp << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "found normal for this airport = " << tmp);
for ( k = 0; k < (int)rwy_polys.size(); ++k ) { for ( k = 0; k < (int)rwy_polys.size(); ++k ) {
cout << "tri " << k << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "tri " << k);
// FGPolygon tri_poly = rwy_tris[k]; // FGPolygon tri_poly = rwy_tris[k];
FGPolygon tri_poly = rwy_polys[k].get_tris(); FGPolygon tri_poly = rwy_polys[k].get_tris();
FGPolygon tri_txs = rwy_polys[k].get_texcoords(); FGPolygon tri_txs = rwy_polys[k].get_texcoords();
string material = rwy_polys[k].get_material(); string material = rwy_polys[k].get_material();
cout << "material = " << material << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "material = " << material);
cout << "poly size = " << tri_poly.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "poly size = " << tri_poly.contours());
cout << "texs size = " << tri_txs.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "texs size = " << tri_txs.contours());
for ( i = 0; i < tri_poly.contours(); ++i ) { for ( i = 0; i < tri_poly.contours(); ++i ) {
tri_v.clear(); tri_v.clear();
tri_n.clear(); tri_n.clear();
@ -853,7 +847,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
base_tc.clear(); base_tc.clear();
for ( j = 0; j < (int)base_txs.size(); ++j ) { for ( j = 0; j < (int)base_txs.size(); ++j ) {
tc = base_txs[j]; tc = base_txs[j];
// cout << "base_tc = " << tc << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "base_tc = " << tc);
index = texcoords.simple_add( tc ); index = texcoords.simple_add( tc );
base_tc.push_back( index ); base_tc.push_back( index );
} }
@ -862,7 +856,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
// calculate node elevations // calculate node elevations
point_list geod_nodes = calc_elevations( root, nodes.get_node_list() ); point_list geod_nodes = calc_elevations( root, nodes.get_node_list() );
cout << "Done with calc_elevations()" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Done with calc_elevations()");
// add base skirt (to hide potential cracks) // add base skirt (to hide potential cracks)
// //
@ -880,7 +874,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
uindex = nodes.find( p ); uindex = nodes.find( p );
if ( uindex >= 0 ) { if ( uindex >= 0 ) {
Point3D lower = geod_nodes[uindex] - Point3D(0, 0, 20); Point3D lower = geod_nodes[uindex] - Point3D(0, 0, 20);
cout << geod_nodes[uindex] << " <-> " << lower << endl; SG_LOG(SG_GENERAL, SG_DEBUG, geod_nodes[uindex] << " <-> " << lower);
lindex = nodes.simple_add( lower ); lindex = nodes.simple_add( lower );
geod_nodes.push_back( lower ); geod_nodes.push_back( lower );
strip_v.push_back( uindex ); strip_v.push_back( uindex );
@ -892,9 +886,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
strip_n.push_back( index ); strip_n.push_back( index );
strip_n.push_back( index ); strip_n.push_back( index );
} else { } else {
cout << "Ooops missing node when building skirt ... dying!" throw sg_exception("Ooops missing node when building skirt");
<< endl;
exit(-1);
} }
// loop through the list // loop through the list
@ -903,7 +895,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
uindex = nodes.find( p ); uindex = nodes.find( p );
if ( uindex >= 0 ) { if ( uindex >= 0 ) {
Point3D lower = geod_nodes[uindex] - Point3D(0, 0, 20); Point3D lower = geod_nodes[uindex] - Point3D(0, 0, 20);
cout << geod_nodes[uindex] << " <-> " << lower << endl; SG_LOG(SG_GENERAL, SG_DEBUG, geod_nodes[uindex] << " <-> " << lower);
lindex = nodes.simple_add( lower ); lindex = nodes.simple_add( lower );
geod_nodes.push_back( lower ); geod_nodes.push_back( lower );
strip_v.push_back( lindex ); strip_v.push_back( lindex );
@ -913,9 +905,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
strip_n.push_back( index ); strip_n.push_back( index );
strip_n.push_back( index ); strip_n.push_back( index );
} else { } else {
cout << "Ooops missing node when building skirt ... dying!" throw sg_exception("Ooops missing node when building skirt");
<< endl;
exit(-1);
} }
} }
@ -924,7 +914,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
uindex = nodes.find( p ); uindex = nodes.find( p );
if ( uindex >= 0 ) { if ( uindex >= 0 ) {
Point3D lower = geod_nodes[uindex] - Point3D(0, 0, 20); Point3D lower = geod_nodes[uindex] - Point3D(0, 0, 20);
cout << geod_nodes[uindex] << " <-> " << lower << endl; SG_LOG(SG_GENERAL, SG_DEBUG, geod_nodes[uindex] << " <-> " << lower);
lindex = nodes.simple_add( lower ); lindex = nodes.simple_add( lower );
geod_nodes.push_back( lower ); geod_nodes.push_back( lower );
strip_v.push_back( lindex ); strip_v.push_back( lindex );
@ -934,9 +924,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
strip_n.push_back( index ); strip_n.push_back( index );
strip_n.push_back( index ); strip_n.push_back( index );
} else { } else {
cout << "Ooops missing node when building skirt ... dying!" throw("Ooops missing node when building skirt");
<< endl;
exit(-1);
} }
strips_v.push_back( strip_v ); strips_v.push_back( strip_v );
@ -949,7 +937,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
base_tc.clear(); base_tc.clear();
for ( j = 0; j < (int)base_txs.size(); ++j ) { for ( j = 0; j < (int)base_txs.size(); ++j ) {
tc = base_txs[j]; tc = base_txs[j];
// cout << "base_tc = " << tc << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "base_tc = " << tc);
index = texcoords.simple_add( tc ); index = texcoords.simple_add( tc );
base_tc.push_back( index ); base_tc.push_back( index );
} }
@ -967,7 +955,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
// calculate light node elevations // calculate light node elevations
point_list geod_light_nodes point_list geod_light_nodes
= calc_elevations( root, light_nodes.get_node_list() ); = calc_elevations( root, light_nodes.get_node_list() );
cout << "Done with (light) calc_elevations()" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Done with (light) calc_elevations()");
// this is a little round about, but what we want to calculate the // this is a little round about, but what we want to calculate the
// light node elevations as ground + an offset so we do them // light node elevations as ground + an offset so we do them
@ -998,7 +986,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
wgs84_nodes.push_back( sgGeodToCart( p ) ); wgs84_nodes.push_back( sgGeodToCart( p ) );
} }
float gbs_radius = sgCalcBoundingRadius( gbs_center, wgs84_nodes ); float gbs_radius = sgCalcBoundingRadius( gbs_center, wgs84_nodes );
cout << "Done with wgs84 node mapping" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Done with wgs84 node mapping");
// null structures // null structures
group_list fans_v; fans_v.clear(); group_list fans_v; fans_v.clear();
@ -1036,8 +1024,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
/* result = obj.write_ascii( objpath, name, b ); */ /* result = obj.write_ascii( objpath, name, b ); */
result = obj.write_bin( objpath, name, b ); result = obj.write_bin( objpath, name, b );
if ( !result ) { if ( !result ) {
cout << "error writing file. :-(" << endl; throw sg_exception("error writing file. :-(");
exit(-1);
} }
#if 0 #if 0

View file

@ -26,16 +26,13 @@
#include <stdio.h> #include <stdio.h>
#include <map> #include <map>
#include <iostream>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/misc/exception.hxx>
SG_USING_STD(less); SG_USING_STD(less);
SG_USING_STD(map); SG_USING_STD(map);
SG_USING_STD(cerr);
SG_USING_STD(cout);
SG_USING_STD(endl);
#include <simgear/constants.h> #include <simgear/constants.h>
@ -176,8 +173,7 @@ FGPolygon convex_hull( const point_list& input_list ) {
// double check list size ... this should never fail because a // double check list size ... this should never fail because a
// single runway will always generate four points. // single runway will always generate four points.
if ( radians_map.size() < 3 ) { if ( radians_map.size() < 3 ) {
cout << "convex hull not possible with < 3 points" << endl; throw sg_exception("convex hull not possible with < 3 points");
exit(-1);
} }
// ensure that we run the while loop at least once // ensure that we run the while loop at least once

View file

@ -27,16 +27,13 @@
#endif #endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/misc/exception.hxx>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#include <list> #include <list>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -81,7 +78,7 @@ int main( int argc, char **argv ) {
char tmp[2048]; char tmp[2048];
bool ready_to_go = true; bool ready_to_go = true;
sglog().setLogLevels( SG_ALL, SG_DEBUG ); sglog().setLogLevels( SG_GENERAL, SG_INFO );
// parse arguments // parse arguments
string work_dir = ""; string work_dir = "";
@ -113,11 +110,11 @@ int main( int argc, char **argv ) {
} }
} }
cout << "Input file = " << input_file << endl; SG_LOG(SG_GENERAL, SG_INFO, "Input file = " << input_file);
cout << "Work directory = " << work_dir << endl; SG_LOG(SG_GENERAL, SG_INFO, "Work directory = " << work_dir);
cout << "Nudge = " << nudge << endl; SG_LOG(SG_GENERAL, SG_INFO, "Nudge = " << nudge);
cout << "Longitude = " << min_lon << ':' << max_lon << endl; SG_LOG(SG_GENERAL, SG_INFO, "Longitude = " << min_lon << ':' << max_lon);
cout << "Latitude = " << min_lat << ':' << max_lat << endl; SG_LOG(SG_GENERAL, SG_INFO, "Latitude = " << min_lat << ':' << max_lat);
if (max_lon < min_lon || max_lat < min_lat || if (max_lon < min_lon || max_lat < min_lat ||
min_lat < -90 || max_lat > 90 || min_lat < -90 || max_lat > 90 ||
@ -165,7 +162,7 @@ int main( int argc, char **argv ) {
while ( ! in.eof() ) { while ( ! in.eof() ) {
in.getline(tmp, 2048); in.getline(tmp, 2048);
line = tmp; line = tmp;
cout << line << endl; SG_LOG(SG_GENERAL, SG_DEBUG, line);
if ( line.length() == 0 ) { if ( line.length() == 0 ) {
// empty, skip // empty, skip
@ -180,8 +177,9 @@ int main( int argc, char **argv ) {
float lat, lon; float lat, lon;
sscanf( last_airport.c_str(), "%c %s %f %f", sscanf( last_airport.c_str(), "%c %s %f %f",
&ctmp, id, &lat, &lon); &ctmp, id, &lat, &lon);
cout << "Airport lat/lon = " << lat << ',' << lon << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Airport lat/lon = "
cout << "Id portion = " << id << endl; << lat << ',' << lon);
SG_LOG(SG_GENERAL, SG_DEBUG, "Id portion = " << id);
if (lon >= min_lon && lon <= max_lon && if (lon >= min_lon && lon <= max_lon &&
lat >= min_lat && lat <= max_lat) { lat >= min_lat && lat <= max_lat) {
@ -198,8 +196,15 @@ int main( int argc, char **argv ) {
// process previous record // process previous record
// process_airport(last_airport, runways_list, argv[2]); // process_airport(last_airport, runways_list, argv[2]);
try {
build_airport( last_airport, runways_list, taxiways_list, build_airport( last_airport, runways_list, taxiways_list,
work_dir ); work_dir );
} catch (sg_exception &e) {
SG_LOG(SG_GENERAL, SG_ALERT, "Failed to build airport "
<< id);
SG_LOG(SG_GENERAL, SG_ALERT, "Exception: "
<< e.getMessage());
}
} }
} else { } else {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id); SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id);
@ -222,7 +227,7 @@ int main( int argc, char **argv ) {
break; break;
} else { } else {
SG_LOG( SG_GENERAL, SG_ALERT, SG_LOG( SG_GENERAL, SG_ALERT,
"Unknown line in file" << endl << line ); "Unknown line in file: " << line );
exit(-1); exit(-1);
} }
} }
@ -230,7 +235,7 @@ int main( int argc, char **argv ) {
if ( last_airport.length() ) { if ( last_airport.length() ) {
char ctmp, id[32]; char ctmp, id[32];
sscanf( last_airport.c_str(), "%c %s", &ctmp, id ); sscanf( last_airport.c_str(), "%c %s", &ctmp, id );
cout << "Id portion = " << id << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Id portion = " << id);
if ( start_id.length() && start_id == id ) { if ( start_id.length() && start_id == id ) {
ready_to_go = true; ready_to_go = true;
@ -243,9 +248,7 @@ int main( int argc, char **argv ) {
} }
} }
cout << "[FINISHED CORRECTLY]" << endl; SG_LOG(SG_GENERAL, SG_INFO, "[FINISHED CORRECTLY]");
return 0; return 0;
} }

View file

@ -21,16 +21,10 @@
// $Id$ // $Id$
// //
#include <simgear/compiler.h>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <stdio.h> #include <stdio.h>
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
#include <Geometry/poly_support.hxx> #include <Geometry/poly_support.hxx>
@ -46,7 +40,7 @@ void add_intermediate_nodes( int contour, const Point3D& start,
{ {
point_list nodes = tmp_nodes.get_node_list(); point_list nodes = tmp_nodes.get_node_list();
// cout << " add_intermediate_nodes()" << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " add_intermediate_nodes()");
printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n", printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n",
start.x(), start.y(), start.z(), end.x(), end.y(), end.z() ); start.x(), start.y(), start.z(), end.x(), end.y(), end.z() );
@ -56,8 +50,8 @@ void add_intermediate_nodes( int contour, const Point3D& start,
if ( found_extra ) { if ( found_extra ) {
// recurse with two sub segments // recurse with two sub segments
// cout << "dividing " << p0 << " " << nodes[extra_index] // SG_LOG(SG_GENERAL, SG_DEBUG, "dividing " << p0 << " " << nodes[extra_index]
// << " " << p1 << endl; // << " " << p1);
add_intermediate_nodes( contour, start, new_pt, tmp_nodes, add_intermediate_nodes( contour, start, new_pt, tmp_nodes,
result ); result );
@ -81,10 +75,10 @@ FGPolygon add_nodes_to_poly( const FGPolygon& poly,
FGPolygon result; result.erase(); FGPolygon result; result.erase();
Point3D p0, p1; Point3D p0, p1;
// cout << "add_nodes_to_poly" << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "add_nodes_to_poly");
for ( i = 0; i < poly.contours(); ++i ) { for ( i = 0; i < poly.contours(); ++i ) {
// cout << "contour = " << i << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "contour = " << i);
for ( j = 0; j < poly.contour_size(i) - 1; ++j ) { for ( j = 0; j < poly.contour_size(i) - 1; ++j ) {
p0 = poly.get_pt( i, j ); p0 = poly.get_pt( i, j );
p1 = poly.get_pt( i, j + 1 ); p1 = poly.get_pt( i, j + 1 );
@ -126,10 +120,10 @@ FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
Point3D p0, p1; Point3D p0, p1;
int i, j, k; int i, j, k;
cout << "split_long_edges()" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "split_long_edges()");
for ( i = 0; i < poly.contours(); ++i ) { for ( i = 0; i < poly.contours(); ++i ) {
// cout << "contour = " << i << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "contour = " << i);
for ( j = 0; j < poly.contour_size(i) - 1; ++j ) { for ( j = 0; j < poly.contour_size(i) - 1; ++j ) {
p0 = poly.get_pt( i, j ); p0 = poly.get_pt( i, j );
p1 = poly.get_pt( i, j + 1 ); p1 = poly.get_pt( i, j + 1 );
@ -138,22 +132,22 @@ FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
geo_inverse_wgs_84( 0.0, geo_inverse_wgs_84( 0.0,
p0.y(), p0.x(), p1.y(), p1.x(), p0.y(), p0.x(), p1.y(), p1.x(),
&az1, &az2, &s ); &az1, &az2, &s );
cout << "distance = " << s << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "distance = " << s);
if ( s > max_len ) { if ( s > max_len ) {
int segments = (int)(s / max_len) + 1; int segments = (int)(s / max_len) + 1;
cout << "segments = " << segments << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "segments = " << segments);
double dx = (p1.x() - p0.x()) / segments; double dx = (p1.x() - p0.x()) / segments;
double dy = (p1.y() - p0.y()) / segments; double dy = (p1.y() - p0.y()) / segments;
for ( k = 0; k < segments; ++k ) { for ( k = 0; k < segments; ++k ) {
Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 ); Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 );
cout << tmp << endl; SG_LOG(SG_GENERAL, SG_DEBUG, tmp);
result.add_node( i, tmp ); result.add_node( i, tmp );
} }
} else { } else {
cout << p0 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, p0);
result.add_node( i, p0 ); result.add_node( i, p0 );
} }
@ -166,22 +160,22 @@ FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
geo_inverse_wgs_84( 0.0, geo_inverse_wgs_84( 0.0,
p0.y(), p0.x(), p1.y(), p1.x(), p0.y(), p0.x(), p1.y(), p1.x(),
&az1, &az2, &s ); &az1, &az2, &s );
cout << "distance = " << s << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "distance = " << s);
if ( s > max_len ) { if ( s > max_len ) {
int segments = (int)(s / max_len) + 1; int segments = (int)(s / max_len) + 1;
cout << "segments = " << segments << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "segments = " << segments);
double dx = (p1.x() - p0.x()) / segments; double dx = (p1.x() - p0.x()) / segments;
double dy = (p1.y() - p0.y()) / segments; double dy = (p1.y() - p0.y()) / segments;
for ( k = 0; k < segments; ++k ) { for ( k = 0; k < segments; ++k ) {
Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 ); Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 );
cout << tmp << endl; SG_LOG(SG_GENERAL, SG_DEBUG, tmp);
result.add_node( i, tmp ); result.add_node( i, tmp );
} }
} else { } else {
cout << p0 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, p0);
result.add_node( i, p0 ); result.add_node( i, p0 );
} }
@ -197,10 +191,10 @@ FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
FGPolygon strip_out_holes( const FGPolygon &poly ) { FGPolygon strip_out_holes( const FGPolygon &poly ) {
FGPolygon result; result.erase(); FGPolygon result; result.erase();
cout << "strip_out_holes()" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "strip_out_holes()");
for ( int i = 0; i < poly.contours(); ++i ) { for ( int i = 0; i < poly.contours(); ++i ) {
// cout << "contour = " << i << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "contour = " << i);
point_list contour = poly.get_contour( i ); point_list contour = poly.get_contour( i );
if ( ! poly.get_hole_flag(i) ) { if ( ! poly.get_hole_flag(i) ) {
result.add_contour( contour, poly.get_hole_flag(i) ); result.add_contour( contour, poly.get_hole_flag(i) );

View file

@ -26,6 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
@ -73,13 +74,13 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
rad_list = batch_cart_to_polar_2d(cart_list); rad_list = batch_cart_to_polar_2d(cart_list);
// display points // display points
// cout << "converted to polar" << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "converted to polar");
// for ( i = 0; i < rad_list.contour_size( 0 ); ++i ) { // for ( i = 0; i < rad_list.contour_size( 0 ); ++i ) {
// cout << " " << rad_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << rad_list.get_pt(0, i));
// } // }
// rotate by specified angle // rotate by specified angle
// cout << "Rotating points by " << angle << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Rotating points by " << angle);
for ( i = 0; i < rad_list.contour_size( 0 ); ++i) { for ( i = 0; i < rad_list.contour_size( 0 ); ++i) {
p = rad_list.get_pt( 0, i ); p = rad_list.get_pt( 0, i );
double theta = p.y() + angle; double theta = p.y() + angle;
@ -88,11 +89,11 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
} }
p.sety( theta ); p.sety( theta );
rad_list.set_pt( 0, i, p ); rad_list.set_pt( 0, i, p );
// cout << " " << p << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << p);
} }
// find actual lon,lat of coordinates // find actual lon,lat of coordinates
// cout << "convert to lon, lat relative to " << origin << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "convert to lon, lat relative to " << origin);
for ( i = 0; i < (int)rad_list.contour_size( 0 ); ++i ) { for ( i = 0; i < (int)rad_list.contour_size( 0 ); ++i ) {
// p = calc_lon_lat(origin_rad, rad_list.get_pt(0, i) ); // p = calc_lon_lat(origin_rad, rad_list.get_pt(0, i) );
@ -105,7 +106,7 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
// convert from radians to degress // convert from radians to degress
p.setx( lon2 ); p.setx( lon2 );
p.sety( lat2 ); p.sety( lat2 );
// cout << " " << p << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << p);
result_list.add_node( 0, p ); result_list.add_node( 0, p );
} }
@ -140,18 +141,18 @@ FGPolygon gen_runway_area_w_scale( const FGRunway& runway,
tmp_list.add_node( 0, Point3D( -l, w, 0 ) ); tmp_list.add_node( 0, Point3D( -l, w, 0 ) );
// display points // display points
// cout << "Untransformed, unrotated runway" << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Untransformed, unrotated runway");
// for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) { // for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) {
// cout << " " << tmp_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << tmp_list.get_pt(0, i));
// } // }
// rotate, transform, and convert points to lon, lat in degrees // rotate, transform, and convert points to lon, lat in degrees
result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list); result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list);
// display points // display points
// cout << "Results in radians." << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Results in radians.");
// for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) { // for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
// cout << " " << result_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
// } // }
return result_list; return result_list;
@ -185,18 +186,18 @@ FGPolygon gen_runway_area_w_expand( const FGRunway& runway,
tmp_list.add_node( 0, Point3D( -l, w, 0 ) ); tmp_list.add_node( 0, Point3D( -l, w, 0 ) );
// display points // display points
// cout << "Untransformed, unrotated runway" << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Untransformed, unrotated runway");
// for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) { // for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) {
// cout << " " << tmp_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << tmp_list.get_pt(0, i));
// } // }
// rotate, transform, and convert points to lon, lat in degrees // rotate, transform, and convert points to lon, lat in degrees
result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list); result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list);
// display points // display points
// cout << "Results in radians." << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Results in radians.");
// for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) { // for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
// cout << " " << result_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
// } // }
return result_list; return result_list;
@ -230,18 +231,18 @@ FGPolygon gen_runway_w_mid( const FGRunway& runway,
tmp_list.add_node( 0, Point3D( 0, w, 0 ) ); tmp_list.add_node( 0, Point3D( 0, w, 0 ) );
// display points // display points
// cout << "Untransformed, unrotated runway" << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Untransformed, unrotated runway");
// for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) { // for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) {
// cout << " " << tmp_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << tmp_list.get_pt(0, i));
// } // }
// rotate, transform, and convert points to lon, lat in degrees // rotate, transform, and convert points to lon, lat in degrees
result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list); result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list);
// display points // display points
// cout << "Results in radians." << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, "Results in radians.");
// for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) { // for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
// cout << " " << result_list.get_pt(0, i) << endl; // SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
// } // }
return result_list; return result_list;

View file

@ -22,13 +22,8 @@
// //
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include "global.hxx" #include "global.hxx"
#include "poly_extra.hxx" #include "poly_extra.hxx"
@ -46,7 +41,7 @@ void gen_number_block( const FGRunway& rwy_info,
char tex1[32]; tex1[0] = '\0'; char tex1[32]; tex1[0] = '\0';
char tex2[32]; tex2[0] = '\0'; char tex2[32]; tex2[0] = '\0';
cout << "Runway num = " << num << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = " << num);
if ( num == 11 ) { if ( num == 11 ) {
sprintf( tex1, "11" ); sprintf( tex1, "11" );
@ -134,8 +129,8 @@ void gen_runway_section( const FGRunway& rwy_info,
} }
} }
cout << "start len % = " << startl_pct SG_LOG(SG_GENERAL, SG_DEBUG, "start len % = " << startl_pct
<< " end len % = " << endl_pct << endl; << " end len % = " << endl_pct);
double dlx, dly; double dlx, dly;
@ -156,8 +151,8 @@ void gen_runway_section( const FGRunway& rwy_info,
Point3D t3 = Point3D( a2.x() + dlx * endl_pct, Point3D t3 = Point3D( a2.x() + dlx * endl_pct,
a2.y() + dly * endl_pct, 0); a2.y() + dly * endl_pct, 0);
cout << "start wid % = " << startw_pct SG_LOG(SG_GENERAL, SG_DEBUG, "start wid % = " << startw_pct
<< " end wid % = " << endw_pct << endl; << " end wid % = " << endw_pct);
double dwx, dwy; double dwx, dwy;
@ -188,11 +183,11 @@ void gen_runway_section( const FGRunway& rwy_info,
section.add_node( 0, p3 ); section.add_node( 0, p3 );
// print runway points // print runway points
cout << "pre clipped runway pts " << prefix << material << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "pre clipped runway pts " << prefix << material);
for ( j = 0; j < section.contours(); ++j ) { for ( j = 0; j < section.contours(); ++j ) {
for ( k = 0; k < section.contour_size( j ); ++k ) { for ( k = 0; k < section.contour_size( j ); ++k ) {
Point3D p = section.get_pt(j, k); Point3D p = section.get_pt(j, k);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
} }
@ -203,7 +198,7 @@ void gen_runway_section( const FGRunway& rwy_info,
sp.set_poly( split ); sp.set_poly( split );
sp.set_material( prefix + material ); sp.set_material( prefix + material );
rwy_polys->push_back( sp ); rwy_polys->push_back( sp );
cout << "section = " << clipped.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "section = " << clipped.contours());
*accum = polygon_union( section, *accum ); *accum = polygon_union( section, *accum );
double len = rwy_info.length / 2.0; double len = rwy_info.length / 2.0;
@ -226,11 +221,11 @@ void gen_runway_section( const FGRunway& rwy_info,
texparams->push_back( tp ); texparams->push_back( tp );
// print runway points // print runway points
cout << "clipped runway pts " << prefix + material << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped runway pts " << prefix + material);
for ( j = 0; j < clipped.contours(); ++j ) { for ( j = 0; j < clipped.contours(); ++j ) {
for ( k = 0; k < clipped.contour_size( j ); ++k ) { for ( k = 0; k < clipped.contour_size( j ); ++k ) {
Point3D p = clipped.get_pt(j, k); Point3D p = clipped.get_pt(j, k);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
} }
} }

View file

@ -22,12 +22,7 @@
// //
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include "rwy_common.hxx" #include "rwy_common.hxx"
#include "rwy_nonprec.hxx" #include "rwy_nonprec.hxx"
@ -69,15 +64,15 @@ void gen_non_precision_rwy( const FGRunway& rwy_info,
runway_b.add_node( 0, runway.get_pt(0, 2) ); runway_b.add_node( 0, runway.get_pt(0, 2) );
Point3D p; Point3D p;
cout << "raw runway pts (a half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (a half)");
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j); p = runway_a.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
cout << "raw runway pts (b half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (b half)");
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j); p = runway_b.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
// //
@ -90,8 +85,8 @@ void gen_non_precision_rwy( const FGRunway& rwy_info,
double length = rwy_info.length / 2.0; double length = rwy_info.length / 2.0;
if ( length < 1150 ) { if ( length < 1150 ) {
cout << "This runway is not long enough for non-precision markings!" SG_LOG(SG_GENERAL, SG_ALERT,
<< endl; "This runway is not long enough for non-precision markings!");
} }
double start_pct = 0; double start_pct = 0;
@ -137,8 +132,8 @@ void gen_non_precision_rwy( const FGRunway& rwy_info,
} }
} }
cout << "Runway designation = " << rwy_info.rwy_no << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation = " << rwy_info.rwy_no);
cout << "Runway designation letter = " << letter << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter = " << letter);
if ( letter != "" ) { if ( letter != "" ) {
start_pct = end_pct; start_pct = end_pct;
@ -173,7 +168,7 @@ void gen_non_precision_rwy( const FGRunway& rwy_info,
snum = rwy_info.rwy_no.substr(0, i); snum = rwy_info.rwy_no.substr(0, i);
} }
} }
cout << "Runway num = '" << snum << "'" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = '" << snum << "'");
int num = atoi( snum.c_str() ); int num = atoi( snum.c_str() );
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0, gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,

View file

@ -22,11 +22,7 @@
// //
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include "rwy_common.hxx" #include "rwy_common.hxx"
#include "rwy_nonprec.hxx" #include "rwy_nonprec.hxx"
@ -70,15 +66,15 @@ void gen_precision_rwy( const FGRunway& rwy_info,
runway_b.add_node( 0, runway.get_pt(0, 2) ); runway_b.add_node( 0, runway.get_pt(0, 2) );
Point3D p; Point3D p;
cout << "raw runway pts (a half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (a half)");
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j); p = runway_a.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
cout << "raw runway pts (b half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (b half)");
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j); p = runway_b.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
// //
@ -91,8 +87,8 @@ void gen_precision_rwy( const FGRunway& rwy_info,
double length = rwy_info.length / 2.0; double length = rwy_info.length / 2.0;
if ( length < 3075 ) { if ( length < 3075 ) {
cout << "This runway is not long enough for precision markings!" SG_LOG(SG_GENERAL, SG_ALERT,
<< endl; "This runway is not long enough for precision markings!");
} }
double start_pct = 0; double start_pct = 0;
@ -138,8 +134,8 @@ void gen_precision_rwy( const FGRunway& rwy_info,
} }
} }
cout << "Runway designation = " << rwy_info.rwy_no << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation = " << rwy_info.rwy_no);
cout << "Runway designation letter = " << letter << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter = " << letter);
if ( letter != "" ) { if ( letter != "" ) {
start_pct = end_pct; start_pct = end_pct;
@ -174,7 +170,7 @@ void gen_precision_rwy( const FGRunway& rwy_info,
snum = rwy_info.rwy_no.substr(0, i); snum = rwy_info.rwy_no.substr(0, i);
} }
} }
cout << "Runway num = '" << snum << "'" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = '" << snum << "'");
int num = atoi( snum.c_str() ); int num = atoi( snum.c_str() );
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0, gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,

View file

@ -23,13 +23,8 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include "poly_extra.hxx" #include "poly_extra.hxx"
#include "rwy_common.hxx" #include "rwy_common.hxx"
@ -64,15 +59,15 @@ void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
runway_b.add_node( 0, runway.get_pt(0, 4) ); runway_b.add_node( 0, runway.get_pt(0, 4) );
Point3D p; Point3D p;
cout << "raw runway pts (a half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (a half)");
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j); p = runway_a.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
cout << "raw runway pts (b half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (b half)");
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j); p = runway_b.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
FGSuperPoly sp; FGSuperPoly sp;
@ -84,7 +79,7 @@ void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
sp.set_poly( split_a ); sp.set_poly( split_a );
sp.set_material( material ); sp.set_material( material );
rwy_polys->push_back( sp ); rwy_polys->push_back( sp );
cout << "clipped_a = " << clipped_a.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_a = " << clipped_a.contours());
*accum = polygon_union( runway_a, *accum ); *accum = polygon_union( runway_a, *accum );
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ), tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
Point3D( (-rwy_info.width / 2.0) * SG_FEET_TO_METER, Point3D( (-rwy_info.width / 2.0) * SG_FEET_TO_METER,
@ -102,7 +97,7 @@ void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
sp.set_poly( split_b ); sp.set_poly( split_b );
sp.set_material( material ); sp.set_material( material );
rwy_polys->push_back( sp ); rwy_polys->push_back( sp );
cout << "clipped_b = " << clipped_b.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_b = " << clipped_b.contours());
*accum = polygon_union( runway_b, *accum ); *accum = polygon_union( runway_b, *accum );
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ), tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
Point3D( (-rwy_info.width / 2.0) * SG_FEET_TO_METER, Point3D( (-rwy_info.width / 2.0) * SG_FEET_TO_METER,
@ -124,20 +119,20 @@ void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
#endif #endif
// print runway points // print runway points
cout << "clipped runway pts (a)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped runway pts (a)");
for ( j = 0; j < clipped_a.contours(); ++j ) { for ( j = 0; j < clipped_a.contours(); ++j ) {
for ( k = 0; k < clipped_a.contour_size( j ); ++k ) { for ( k = 0; k < clipped_a.contour_size( j ); ++k ) {
p = clipped_a.get_pt(j, k); p = clipped_a.get_pt(j, k);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
} }
// print runway points // print runway points
cout << "clipped runway pts (b)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped runway pts (b)");
for ( j = 0; j < clipped_b.contours(); ++j ) { for ( j = 0; j < clipped_b.contours(); ++j ) {
for ( k = 0; k < clipped_b.contour_size( j ); ++k ) { for ( k = 0; k < clipped_b.contour_size( j ); ++k ) {
p = clipped_b.get_pt(j, k); p = clipped_b.get_pt(j, k);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
} }

View file

@ -23,11 +23,7 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include "rwy_common.hxx" #include "rwy_common.hxx"
#include "rwy_visual.hxx" #include "rwy_visual.hxx"
@ -69,15 +65,15 @@ void gen_visual_rwy( const FGRunway& rwy_info,
runway_b.add_node( 0, runway.get_pt(0, 2) ); runway_b.add_node( 0, runway.get_pt(0, 2) );
Point3D p; Point3D p;
cout << "raw runway pts (a half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (a half)");
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j); p = runway_a.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
cout << "raw runway pts (b half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (b half)");
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j); p = runway_b.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
// //
@ -90,8 +86,8 @@ void gen_visual_rwy( const FGRunway& rwy_info,
double length = rwy_info.length / 2.0; double length = rwy_info.length / 2.0;
if ( length < 1150 ) { if ( length < 1150 ) {
cout << "This runway is not long enough for visual markings!" SG_LOG(SG_GENERAL, SG_ALERT,
<< endl; "This runway is not long enough for visual markings!");
} }
double start_pct = 0; double start_pct = 0;
@ -119,8 +115,8 @@ void gen_visual_rwy( const FGRunway& rwy_info,
} }
} }
cout << "Runway designation = " << rwy_info.rwy_no << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation = " << rwy_info.rwy_no);
cout << "Runway designation letter = " << letter << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter = " << letter);
if ( letter != "" ) { if ( letter != "" ) {
start_pct = end_pct; start_pct = end_pct;
@ -155,7 +151,7 @@ void gen_visual_rwy( const FGRunway& rwy_info,
snum = rwy_info.rwy_no.substr(0, i); snum = rwy_info.rwy_no.substr(0, i);
} }
} }
cout << "Runway num = '" << snum << "'" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = '" << snum << "'");
int num = atoi( snum.c_str() ); int num = atoi( snum.c_str() );
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0, gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,

View file

@ -23,13 +23,8 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <iostream>
SG_USING_STD(cout);
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include "poly_extra.hxx" #include "poly_extra.hxx"
#include "rwy_common.hxx" #include "rwy_common.hxx"
@ -64,15 +59,15 @@ void gen_taxiway( const FGRunway& rwy_info, const string& material,
runway_b.add_node( 0, runway.get_pt(0, 4) ); runway_b.add_node( 0, runway.get_pt(0, 4) );
Point3D p; Point3D p;
cout << "raw runway pts (a half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (a half)");
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j); p = runway_a.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
cout << "raw runway pts (b half)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (b half)");
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) { for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j); p = runway_b.get_pt(0, j);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
FGSuperPoly sp; FGSuperPoly sp;
@ -82,15 +77,15 @@ void gen_taxiway( const FGRunway& rwy_info, const string& material,
double yfactor = 1.0; double yfactor = 1.0;
if ( fabs(rwy_info.width) > SG_EPSILON ) { if ( fabs(rwy_info.width) > SG_EPSILON ) {
xfactor = 150.0 / rwy_info.width; xfactor = 150.0 / rwy_info.width;
cout << "xfactor = " << xfactor << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "xfactor = " << xfactor);
} }
if ( fabs(rwy_info.length) > SG_EPSILON ) { if ( fabs(rwy_info.length) > SG_EPSILON ) {
yfactor = 150.0 / rwy_info.length; yfactor = 150.0 / rwy_info.length;
cout << "yfactor = " << yfactor << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "yfactor = " << yfactor);
} }
cout << "len = " << rwy_info.length << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "len = " << rwy_info.length);
cout << "width = " << rwy_info.width << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "width = " << rwy_info.width);
FGPolygon clipped_a = polygon_diff( runway_a, *accum ); FGPolygon clipped_a = polygon_diff( runway_a, *accum );
FGPolygon split_a = split_long_edges( clipped_a, 400.0 ); FGPolygon split_a = split_long_edges( clipped_a, 400.0 );
@ -99,7 +94,7 @@ void gen_taxiway( const FGRunway& rwy_info, const string& material,
sp.set_material( material ); sp.set_material( material );
sp.set_flag( 1 ); // mark as a taxiway sp.set_flag( 1 ); // mark as a taxiway
rwy_polys->push_back( sp ); rwy_polys->push_back( sp );
cout << "clipped_a = " << clipped_a.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_a = " << clipped_a.contours());
*accum = polygon_union( runway_a, *accum ); *accum = polygon_union( runway_a, *accum );
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ), tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
Point3D( (-250 / 2.0) * SG_FEET_TO_METER, Point3D( (-250 / 2.0) * SG_FEET_TO_METER,
@ -117,7 +112,7 @@ void gen_taxiway( const FGRunway& rwy_info, const string& material,
sp.set_poly( split_b ); sp.set_poly( split_b );
sp.set_material( material ); sp.set_material( material );
rwy_polys->push_back( sp ); rwy_polys->push_back( sp );
cout << "clipped_b = " << clipped_b.contours() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_b = " << clipped_b.contours());
*accum = polygon_union( runway_b, *accum ); *accum = polygon_union( runway_b, *accum );
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ), tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
Point3D( (-250 / 2.0) * SG_FEET_TO_METER, Point3D( (-250 / 2.0) * SG_FEET_TO_METER,
@ -139,20 +134,20 @@ void gen_taxiway( const FGRunway& rwy_info, const string& material,
#endif #endif
// print runway points // print runway points
cout << "clipped runway pts (a)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped runway pts (a)");
for ( j = 0; j < clipped_a.contours(); ++j ) { for ( j = 0; j < clipped_a.contours(); ++j ) {
for ( k = 0; k < clipped_a.contour_size( j ); ++k ) { for ( k = 0; k < clipped_a.contour_size( j ); ++k ) {
p = clipped_a.get_pt(j, k); p = clipped_a.get_pt(j, k);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
} }
// print runway points // print runway points
cout << "clipped runway pts (b)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "clipped runway pts (b)");
for ( j = 0; j < clipped_b.contours(); ++j ) { for ( j = 0; j < clipped_b.contours(); ++j ) {
for ( k = 0; k < clipped_b.contour_size( j ); ++k ) { for ( k = 0; k < clipped_b.contour_size( j ); ++k ) {
p = clipped_b.get_pt(j, k); p = clipped_b.get_pt(j, k);
cout << " point = " << p << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
} }