1
0
Fork 0

David Luf:

The attached patches significantly quieten the output from genapts, which in it's current form resembles the universe flying by on a bad hair day   Remember chaps, console output on Windows is slooowwwwww...  Normal service may be resumed using --verbose or -v.  I've also added a short help, obtainable with --help or -h.  I've also added a couple of extra options, --airport=abcd for just generating a particular airport, and --tile=<[we]xxx[ns]xx> for generating a 1x1 degree tile.  We currently have --chunk=<[we]xxx[ns]xx> for generating a 10x10 degree chunk, and I'd like to eventually add --tile as an option to all tools that take --chunk.

This one adds the tile option to
tgvpf.

Erik Hofman:

Some small code changes for IRIX.
This commit is contained in:
ehofman 2004-02-26 15:33:32 +00:00
parent 0ec77c12c5
commit a71d62c859
15 changed files with 231 additions and 135 deletions

View file

@ -28,6 +28,7 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <simgear/debug/logstream.hxx>
#include <Array/array.hxx> #include <Array/array.hxx>
@ -89,7 +90,7 @@ static void calc_elevations( const string &root, const string_list elev_src,
+ "/" + b.gen_index_str(); + "/" + b.gen_index_str();
if ( array.open(array_path) ) { if ( array.open(array_path) ) {
found_file = true; found_file = true;
cout << "Using array_path = " << array_path << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Using array_path = " << array_path);
} }
j++; j++;
} }
@ -141,7 +142,7 @@ static void calc_elevations( const string &root, const string_list elev_src,
} }
} }
double average = total / (double) count; double average = total / (double) count;
cout << "Average surface height = " << average << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Average surface height = " << average);
// now go through the elevations and clamp them all to within // now go through the elevations and clamp them all to within
// +/-10m (33') of the average. // +/-10m (33') of the average.
@ -186,7 +187,7 @@ TGAptSurface::TGAptSurface( const string& path,
double x_nm = x_rad * SG_RAD_TO_NM * xfact; double x_nm = x_rad * SG_RAD_TO_NM * xfact;
double x_m = x_nm * SG_NM_TO_METER; double x_m = x_nm * SG_NM_TO_METER;
cout << "Area size = " << x_m << " x " << y_m << " (m)" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Area size = " << x_m << " x " << y_m << " (m)");
int xdivs = (int)(x_m / 600.0) + 1; int xdivs = (int)(x_m / 600.0) + 1;
int ydivs = (int)(y_m / 600.0) + 1; int ydivs = (int)(y_m / 600.0) + 1;
@ -194,7 +195,7 @@ TGAptSurface::TGAptSurface( const string& path,
if ( xdivs < 3 ) { xdivs = 3; } if ( xdivs < 3 ) { xdivs = 3; }
if ( ydivs < 3 ) { ydivs = 3; } if ( ydivs < 3 ) { ydivs = 3; }
cout << " M(" << xdivs << "," << ydivs << ")" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " M(" << xdivs << "," << ydivs << ")");
double dlon = x_deg / xdivs; double dlon = x_deg / xdivs;
double dlat = y_deg / ydivs; double dlat = y_deg / ydivs;
@ -216,7 +217,7 @@ TGAptSurface::TGAptSurface( const string& path,
Matrix_Point3Df Pts(xdivs + 1, ydivs + 1); Matrix_Point3Df Pts(xdivs + 1, ydivs + 1);
for ( int i = 0; i < xdivs + 1; ++i ) { for ( int i = 0; i < xdivs + 1; ++i ) {
for ( int j = 0; j < ydivs + 1; ++j ) { for ( int j = 0; j < ydivs + 1; ++j ) {
cout << i << "," << j << endl; SG_LOG(SG_GENERAL, SG_DEBUG, i << "," << j);
double accum = 0.0; double accum = 0.0;
for ( int ii = 0; ii < mult; ++ii ) { for ( int ii = 0; ii < mult; ++ii ) {
for ( int jj = 0; jj < mult; ++jj ) { for ( int jj = 0; jj < mult; ++jj ) {
@ -232,10 +233,10 @@ TGAptSurface::TGAptSurface( const string& path,
// Create the nurbs surface // Create the nurbs surface
cout << "ready to create nurbs surface" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "ready to create nurbs surface");
apt_surf = new PlNurbsSurfacef; apt_surf = new PlNurbsSurfacef;
apt_surf->globalInterp( Pts, 3, 3); apt_surf->globalInterp( Pts, 3, 3);
cout << " successful." << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " successful.");
} }
@ -250,7 +251,7 @@ double TGAptSurface::query( double lon_deg, double lat_deg ) {
if ( lon_deg < min_deg.lon() || lon_deg > max_deg.lon() || if ( lon_deg < min_deg.lon() || lon_deg > max_deg.lon() ||
lat_deg < min_deg.lat() || lat_deg > max_deg.lat() ) lat_deg < min_deg.lat() || lat_deg > max_deg.lat() )
{ {
cout << "Warning: query out of bounds for NURBS surface!" << endl; SG_LOG(SG_GENERAL, SG_WARN, "Warning: query out of bounds for NURBS surface!");
return -9999.0; return -9999.0;
} }
@ -258,9 +259,8 @@ double TGAptSurface::query( double lon_deg, double lat_deg ) {
double x = (lon_deg - min_deg.lon()) / (max_deg.lon() - min_deg.lon()); double x = (lon_deg - min_deg.lon()) / (max_deg.lon() - min_deg.lon());
double y = (lat_deg - min_deg.lat()) / (max_deg.lat() - min_deg.lat()); double y = (lat_deg - min_deg.lat()) / (max_deg.lat() - min_deg.lat());
cout << " querying for " << x << ", " << y << " = ";
Point3Df p = apt_surf->pointAt( x, y ); Point3Df p = apt_surf->pointAt( x, y );
cout << p.z() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " querying for " << x << ", " << y << " = " << p.z());
return p.z(); return p.z();
} }

View file

@ -99,10 +99,10 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly,
double maxu = tp.get_maxu(); double maxu = tp.get_maxu();
double minv = tp.get_minv(); double minv = tp.get_minv();
double maxv = tp.get_maxv(); double maxv = tp.get_maxv();
SG_LOG( SG_GENERAL, SG_INFO, "section ref = " << ref ); SG_LOG( SG_GENERAL, SG_DEBUG, "section ref = " << ref );
SG_LOG( SG_GENERAL, SG_INFO, " width = " << width ); SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << width );
SG_LOG( SG_GENERAL, SG_INFO, " length = " << length ); SG_LOG( SG_GENERAL, SG_DEBUG, " length = " << length );
SG_LOG( SG_GENERAL, SG_INFO, " heading = " << heading ); SG_LOG( SG_GENERAL, SG_DEBUG, " heading = " << heading );
Point3D p, t; Point3D p, t;
double x, y, tx, ty; double x, y, tx, ty;
@ -122,7 +122,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly,
double az1, az2, dist; double az1, az2, dist;
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(),
&az1, &az2, &dist ); &az1, &az2, &dist );
SG_LOG(SG_GENERAL, SG_INFO, "basic course = " << az2); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course = " << az2);
// //
// 2. Rotate this back into a coordinate system where Y // 2. Rotate this back into a coordinate system where Y
@ -132,7 +132,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly,
double course = az2 - heading; double course = az2 - heading;
while ( course < -360 ) { course += 360; } while ( course < -360 ) { course += 360; }
while ( course > 360 ) { course -= 360; } while ( course > 360 ) { course -= 360; }
SG_LOG( SG_GENERAL, SG_INFO, SG_LOG( SG_GENERAL, SG_DEBUG,
" course = " << course << " dist = " << dist ); " course = " << course << " dist = " << dist );
// //
@ -141,7 +141,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly,
x = sin( course * SGD_DEGREES_TO_RADIANS ) * dist; x = sin( course * SGD_DEGREES_TO_RADIANS ) * dist;
y = cos( course * SGD_DEGREES_TO_RADIANS ) * dist; y = cos( course * SGD_DEGREES_TO_RADIANS ) * dist;
SG_LOG(SG_GENERAL, SG_INFO, " x = " << x << " y = " << y); SG_LOG(SG_GENERAL, SG_DEBUG, " x = " << x << " y = " << y);
// //
// 4. Map x, y point into texture coordinates // 4. Map x, y point into texture coordinates
@ -151,7 +151,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly,
tmp = x / width; tmp = x / width;
tx = tmp * (maxu - minu) + minu; tx = tmp * (maxu - minu) + minu;
// tx = ((int)(tx * 100)) / 100.0; // tx = ((int)(tx * 100)) / 100.0;
SG_LOG(SG_GENERAL, SG_INFO, " (" << tx << ")"); 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; }
@ -163,7 +163,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly,
tmp = y / length; tmp = y / length;
ty = tmp * (maxv - minv) + minv; ty = tmp * (maxv - minv) + minv;
// ty = ((int)(ty * 100)) / 100.0; // ty = ((int)(ty * 100)) / 100.0;
SG_LOG(SG_GENERAL, SG_INFO, " (" << ty << ")"); 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; }
@ -411,25 +411,25 @@ void build_airport( string airport_id, float alt_m,
string rwy_stopway2 = rwy_str.substr(83, 4); string rwy_stopway2 = rwy_str.substr(83, 4);
rwy.stopway2 = atoi( rwy_stopway2.c_str() ); rwy.stopway2 = atoi( rwy_stopway2.c_str() );
SG_LOG( SG_GENERAL, SG_INFO, " no = " << rwy.rwy_no); SG_LOG( SG_GENERAL, SG_DEBUG, " no = " << rwy.rwy_no);
SG_LOG( SG_GENERAL, SG_INFO, " lat = " << rwy_lat << " " << rwy.lat); SG_LOG( SG_GENERAL, SG_DEBUG, " lat = " << rwy_lat << " " << rwy.lat);
SG_LOG( SG_GENERAL, SG_INFO, " lon = " << rwy_lon << " " << rwy.lon); SG_LOG( SG_GENERAL, SG_DEBUG, " lon = " << rwy_lon << " " << rwy.lon);
SG_LOG( SG_GENERAL, SG_INFO, " hdg = " << rwy_hdg << " " SG_LOG( SG_GENERAL, SG_DEBUG, " hdg = " << rwy_hdg << " "
<< rwy.heading); << rwy.heading);
SG_LOG( SG_GENERAL, SG_INFO, " len = " << rwy_len << " " SG_LOG( SG_GENERAL, SG_DEBUG, " len = " << rwy_len << " "
<< rwy.length); << rwy.length);
SG_LOG( SG_GENERAL, SG_INFO, " width = " << rwy_width << " " SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << rwy_width << " "
<< rwy.width); << rwy.width);
SG_LOG( SG_GENERAL, SG_INFO, " sfc = " << rwy.surface_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_flags);
SG_LOG( SG_GENERAL, SG_INFO, " end1 = " << rwy.end1_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " end1 = " << rwy.end1_flags);
SG_LOG( SG_GENERAL, SG_INFO, " dspth1= " << rwy_disp_threshold1 SG_LOG( SG_GENERAL, SG_DEBUG, " dspth1= " << rwy_disp_threshold1
<< " " << rwy.disp_thresh1); << " " << rwy.disp_thresh1);
SG_LOG( SG_GENERAL, SG_INFO, " stop1 = " << rwy_stopway1 << " " SG_LOG( SG_GENERAL, SG_DEBUG, " stop1 = " << rwy_stopway1 << " "
<< rwy.stopway1); << rwy.stopway1);
SG_LOG( SG_GENERAL, SG_INFO, " end2 = " << rwy.end2_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " end2 = " << rwy.end2_flags);
SG_LOG( SG_GENERAL, SG_INFO, " dspth2= " << rwy_disp_threshold2 SG_LOG( SG_GENERAL, SG_DEBUG, " dspth2= " << rwy_disp_threshold2
<< " " << rwy.disp_thresh2); << " " << rwy.disp_thresh2);
SG_LOG( SG_GENERAL, SG_INFO, " stop2 = " << rwy_stopway2 << " " SG_LOG( SG_GENERAL, SG_DEBUG, " stop2 = " << rwy_stopway2 << " "
<< rwy.stopway2); << rwy.stopway2);
runways.push_back( rwy ); runways.push_back( rwy );
@ -472,17 +472,17 @@ void build_airport( string airport_id, float alt_m,
taxi.surface_flags = taxi_str.substr(53, 5); taxi.surface_flags = taxi_str.substr(53, 5);
SG_LOG( SG_GENERAL, SG_INFO, " lat = " << taxi_lat << " " SG_LOG( SG_GENERAL, SG_DEBUG, " lat = " << taxi_lat << " "
<< taxi.lat); << taxi.lat);
SG_LOG( SG_GENERAL, SG_INFO, " lon = " << taxi_lon << " " SG_LOG( SG_GENERAL, SG_DEBUG, " lon = " << taxi_lon << " "
<< taxi.lon); << taxi.lon);
SG_LOG( SG_GENERAL, SG_INFO, " hdg = " << taxi_hdg << " " SG_LOG( SG_GENERAL, SG_DEBUG, " hdg = " << taxi_hdg << " "
<< taxi.heading); << taxi.heading);
SG_LOG( SG_GENERAL, SG_INFO, " len = " << taxi_len << " " SG_LOG( SG_GENERAL, SG_DEBUG, " len = " << taxi_len << " "
<< taxi.length); << taxi.length);
SG_LOG( SG_GENERAL, SG_INFO, " width = " << taxi_width << " " SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << taxi_width << " "
<< taxi.width); << taxi.width);
SG_LOG( SG_GENERAL, SG_INFO, " sfc = " << taxi.surface_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << taxi.surface_flags);
taxiways.push_back( taxi ); taxiways.push_back( taxi );
} }
@ -549,7 +549,7 @@ void build_airport( string airport_id, float alt_m,
} }
if ( largest_idx >= 0 ) { if ( largest_idx >= 0 ) {
SG_LOG( SG_GENERAL, SG_INFO, "generating " << largest_idx ); SG_LOG( SG_GENERAL, SG_DEBUG, "generating " << largest_idx );
build_runway( taxiways[largest_idx], alt_m, build_runway( taxiways[largest_idx], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
@ -586,6 +586,7 @@ void build_airport( string airport_id, float alt_m,
TGPolygon base_poly = polygon_diff( divided_base, accum ); TGPolygon base_poly = polygon_diff( divided_base, accum );
// write_polygon( base_poly, "base-raw" ); // write_polygon( base_poly, "base-raw" );
char buf[120]; // For debugging output
// 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 ) {
SG_LOG(SG_GENERAL, SG_DEBUG, "add nodes/remove dups section = " << k SG_LOG(SG_GENERAL, SG_DEBUG, "add nodes/remove dups section = " << k
@ -595,7 +596,8 @@ void build_airport( string airport_id, float alt_m,
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);
printf(" %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() ); snprintf(buf, 119, " %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() );
SG_LOG(SG_GENERAL, SG_DEBUG, buf);
} }
} }
@ -606,7 +608,8 @@ void build_airport( string airport_id, float alt_m,
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);
printf(" %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() ); snprintf(buf, 119, " %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() );
SG_LOG(SG_GENERAL, SG_DEBUG, buf);
} }
} }
@ -617,7 +620,8 @@ void build_airport( string airport_id, float alt_m,
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);
printf(" %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() ); snprintf(buf, 119, " %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() );
SG_LOG(SG_GENERAL, SG_DEBUG, buf);
} }
} }
@ -649,7 +653,7 @@ void build_airport( string airport_id, float alt_m,
tmp_nodes.unique_add( divided_base.get_pt(i, j) ); tmp_nodes.unique_add( divided_base.get_pt(i, j) );
} }
} }
#if 0 #if 0
// dump info for debugging purposes // dump info for debugging purposes
point_list ttt = tmp_nodes.get_node_list(); point_list ttt = tmp_nodes.get_node_list();
@ -704,12 +708,12 @@ void build_airport( string airport_id, float alt_m,
rwy_polys[k].set_poly( poly ); rwy_polys[k].set_poly( poly );
} }
SG_LOG(SG_GENERAL, SG_INFO, "add nodes base "); SG_LOG(SG_GENERAL, SG_DEBUG, "add nodes base ");
cout << " before: " << base_poly << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " before: " << base_poly);
cout << " tmp_nodes size = " << tmp_nodes.get_node_list().size() << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " tmp_nodes size = " << tmp_nodes.get_node_list().size());
base_poly = add_nodes_to_poly( base_poly, tmp_nodes ); base_poly = add_nodes_to_poly( base_poly, tmp_nodes );
cout << " after adding tmp_nodes: " << base_poly << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " after adding tmp_nodes: " << base_poly);
// write_polygon( base_poly, "base-add" ); // write_polygon( base_poly, "base-add" );
SG_LOG(SG_GENERAL, SG_DEBUG, "remove dups base "); SG_LOG(SG_GENERAL, SG_DEBUG, "remove dups base ");
@ -717,12 +721,12 @@ void build_airport( string airport_id, float alt_m,
SG_LOG(SG_GENERAL, SG_DEBUG, "remove bad contours base"); 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" );
cout << " after clean up: " << base_poly << endl; SG_LOG(SG_GENERAL, SG_DEBUG, " after clean up: " << base_poly);
// 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 ) {
SG_LOG(SG_GENERAL, SG_INFO, "Tesselating section = " << i); SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating section = " << i);
TGPolygon poly = rwy_polys[i].get_poly(); TGPolygon poly = rwy_polys[i].get_poly();
SG_LOG(SG_GENERAL, SG_DEBUG, "total size before = " << poly.total_size()); SG_LOG(SG_GENERAL, SG_DEBUG, "total size before = " << poly.total_size());
@ -933,14 +937,14 @@ void build_airport( string airport_id, float alt_m,
max_deg.setlat( max_deg.lat() + 0.1 * dlat ); max_deg.setlat( max_deg.lat() + 0.1 * dlat );
TGAptSurface apt_surf( root, elev_src, min_deg, max_deg ); TGAptSurface apt_surf( root, elev_src, min_deg, max_deg );
cout << "Surface created" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "Surface created");
// calculate node elevations // calculate node elevations
point_list geod_nodes = calc_elevations( apt_surf, nodes.get_node_list(), point_list geod_nodes = calc_elevations( apt_surf, nodes.get_node_list(),
0.0 ); 0.0 );
divided_base = calc_elevations( apt_surf, divided_base, 0.0 ); divided_base = calc_elevations( apt_surf, divided_base, 0.0 );
cout << "DIVIDED" << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "DIVIDED");
cout << divided_base << endl; SG_LOG(SG_GENERAL, SG_DEBUG, divided_base);
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()"); SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()");
@ -1078,7 +1082,7 @@ void build_airport( string airport_id, float alt_m,
} }
} }
elevation_map[flag] = max; elevation_map[flag] = max;
SG_LOG( SG_GENERAL, SG_INFO, flag << " max = " << max ); SG_LOG( SG_GENERAL, SG_DEBUG, flag << " max = " << max );
} }
} }
@ -1199,4 +1203,6 @@ void build_airport( string airport_id, float alt_m,
// write_boundary( holepath, b, hull, poly_index ); // write_boundary( holepath, b, hull, poly_index );
tgSplitPolygon( holepath, HoleArea, divided_base, true ); tgSplitPolygon( holepath, HoleArea, divided_base, true );
tgSplitPolygon( holepath, AirportArea, apt_clearing, false ); tgSplitPolygon( holepath, AirportArea, apt_clearing, false );
} }

View file

@ -26,6 +26,7 @@
#include <plib/sg.h> #include <plib/sg.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include "lights.hxx" #include "lights.hxx"
@ -59,14 +60,14 @@ static Point3D gen_runway_light_vector( const TGRunway& rwy_info,
} }
Point3D cart1 = sgGeodToCart( end1 * SG_DEGREES_TO_RADIANS ); Point3D cart1 = sgGeodToCart( end1 * SG_DEGREES_TO_RADIANS );
Point3D cart2 = sgGeodToCart( end2 * SG_DEGREES_TO_RADIANS ); Point3D cart2 = sgGeodToCart( end2 * SG_DEGREES_TO_RADIANS );
cout << "cart1 = " << cart1 << " cart2 = " << cart2 << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "cart1 = " << cart1 << " cart2 = " << cart2);
Point3D up = cart1; Point3D up = cart1;
length = up.distance3D( Point3D(0.0) ); length = up.distance3D( Point3D(0.0) );
up = up / length; up = up / length;
Point3D rwy_vec = cart2 - cart1; Point3D rwy_vec = cart2 - cart1;
cout << "rwy_vec = " << rwy_vec << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "rwy_vec = " << rwy_vec);
// angle up specified amount // angle up specified amount
length = rwy_vec.distance3D( Point3D(0.0) ); length = rwy_vec.distance3D( Point3D(0.0) );
@ -2567,8 +2568,8 @@ static superpoly_list gen_malsx( const TGRunway& rwy_info,
void gen_runway_lights( const TGRunway& rwy_info, float alt_m, void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
superpoly_list &lights ) { superpoly_list &lights ) {
cout << "gen runway lights " << rwy_info.rwy_no << " " SG_LOG(SG_GENERAL, SG_DEBUG, "gen runway lights " << rwy_info.rwy_no << " "
<< rwy_info.end1_flags << " " << rwy_info.end2_flags << endl;; << rwy_info.end1_flags << " " << rwy_info.end2_flags);
unsigned int i; unsigned int i;
@ -2895,8 +2896,8 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
void gen_taxiway_lights( const TGRunway& taxiway_info, float alt_m, void gen_taxiway_lights( const TGRunway& taxiway_info, float alt_m,
superpoly_list &lights ) { superpoly_list &lights ) {
cout << "gen taxiway lights " << taxiway_info.rwy_no << " " SG_LOG(SG_GENERAL, SG_DEBUG, "gen taxiway lights " << taxiway_info.rwy_no << " "
<< taxiway_info.end1_flags << " " << taxiway_info.end2_flags << endl;; << taxiway_info.end1_flags << " " << taxiway_info.end2_flags);
unsigned int i; unsigned int i;

View file

@ -61,9 +61,47 @@ int nudge = 10;
static void usage( int argc, char **argv ) { static void usage( int argc, char **argv ) {
SG_LOG(SG_GENERAL, SG_ALERT, SG_LOG(SG_GENERAL, SG_ALERT,
"Usage " << argv[0] << " --input=<apt_file> " "Usage " << argv[0] << " --input=<apt_file> "
<< "--work=<work_dir> [ --start-id=abcd ] [ --nudge=n ]" << "--work=<work_dir> [ --start-id=abcd ] [ --nudge=n ] "
<< "[--min-lon=<deg>] [--max-lon=<deg>] [--min-lat=<deg>] [--max-lat=<deg>]" << "[--min-lon=<deg>] [--max-lon=<deg>] [--min-lat=<deg>] [--max-lat=<deg>] "
<< "[--chunk=<chunk>]"); << "[ --airport=abcd ] [--tile=<tile>] [--chunk=<chunk>] [--verbose] [--help]");
}
// Display help and usage
static void help( int argc, char **argv ) {
cout << "genapts generates airports for use in generating scenery for the FlightGear flight simulator. ";
cout << "Airport, runway, and taxiway vector data and attributes are input, and generated 3D airports ";
cout << "are output for further processing by the TerraGear scenery creation tools. ";
cout << "\n\n";
cout << "The standard input file is runways.dat.gz which is found in $FG_ROOT/Airports. ";
cout << "This file is periodically generated for the FlightGear project by Robin Peel, who ";
cout << "maintains an airport database for both the X-Plane and FlightGear simulators. ";
cout << "The format of this file is documented on the FlightGear web site. ";
cout << "Any other input file corresponding to this format may be used as input to genapts. ";
cout << "Input files may be gzipped or left as plain text as required. ";
cout << "\n\n";
cout << "Processing all the world's airports takes a *long* time. To cut down processing time ";
cout << "when only some airports are required, you may refine the input selection either by airport ";
cout << "or by area. By airport, either one airport can be specified using --airport=abcd, where abcd is ";
cout << "a valid airport code eg. --airport-id=KORD, or a starting airport can be specified using --start-id=abcd ";
cout << "where once again abcd is a valid airport code. In this case, all airports in the file subsequent to the ";
cout << "start-id are done. This is convienient when re-starting after a previous error. ";
cout << "\nAn input area may be specified by lat and lon extent using min and max lat and lon. ";
cout << "Alternatively, you may specify a chunk (10 x 10 degrees) or tile (1 x 1 degree) using a string ";
cout << "such as eg. w080n40, e000s27. ";
cout << "\nAn input file containing only a subset of the world's ";
cout << "airports may of course be used.";
cout << "\n\n";
cout << "It is necessary to generate the elevation data for the area of interest PRIOR TO GENERATING THE AIRPORTS. ";
cout << "Failure to do this will result in airports being generated with an elevation of zero. ";
cout << "The following subdirectories of the work-dir will be searched for elevation files:\n\n";
cout << "SRTM-United_States-1\n";
cout << "SRTM-North_America-3\n";
cout << "SRTM-South_America-3\n";
cout << "SRTM-Eurasia-3\n";
cout << "DEM-USGS-3\n";
cout << "SRTM-30";
cout << "\n\n";
usage( argc, argv );
} }
@ -85,6 +123,7 @@ int main( int argc, char **argv ) {
string work_dir = ""; string work_dir = "";
string input_file = ""; string input_file = "";
string start_id = ""; string start_id = "";
string airport_id = "";
int arg_pos; int arg_pos;
for (arg_pos = 1; arg_pos < argc; arg_pos++) { for (arg_pos = 1; arg_pos < argc; arg_pos++) {
string arg = argv[arg_pos]; string arg = argv[arg_pos];
@ -113,12 +152,27 @@ int main( int argc, char **argv ) {
min_lat = rectangle.getMin().y(); min_lat = rectangle.getMin().y();
max_lon = rectangle.getMax().x(); max_lon = rectangle.getMax().x();
max_lat = rectangle.getMax().y(); max_lat = rectangle.getMax().y();
} else if ( arg.find("--tile=") == 0 ) {
tg::Rectangle rectangle = tg::parseTile(arg.substr(7).c_str());
min_lon = rectangle.getMin().x();
min_lat = rectangle.getMin().y();
max_lon = rectangle.getMax().x();
max_lat = rectangle.getMax().y();
} else if ( arg.find("--airport=") == 0 ) {
airport_id = arg.substr(10).c_str();
ready_to_go = false;
} else if ( (arg.find("--verbose") == 0) || (arg.find("-v") == 0) ) {
sglog().setLogLevels( SG_GENERAL, SG_BULK );
} else if ( (arg.find("--help") == 0) || (arg.find("-h") == 0) ) {
help( argc, argv );
exit(-1);
} else { } else {
usage( argc, argv ); usage( argc, argv );
exit(-1); exit(-1);
} }
} }
// Please update the help near the top of this file if you update this list.
elev_src.push_back( "SRTM-United_States-1" ); elev_src.push_back( "SRTM-United_States-1" );
elev_src.push_back( "SRTM-North_America-3" ); elev_src.push_back( "SRTM-North_America-3" );
elev_src.push_back( "SRTM-South_America-3" ); elev_src.push_back( "SRTM-South_America-3" );
@ -183,7 +237,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;
SG_LOG( SG_GENERAL, SG_INFO, "-> " << line ); SG_LOG( SG_GENERAL, SG_DEBUG, "-> " << line );
if ( line.length() == 0 ) { if ( line.length() == 0 ) {
// empty, skip // empty, skip
@ -199,7 +253,7 @@ int main( int argc, char **argv ) {
sscanf( line.c_str(), "%c %s %d", sscanf( line.c_str(), "%c %s %d",
&ctmp, tmpid, &elev ); &ctmp, tmpid, &elev );
id = tmpid; id = tmpid;
SG_LOG( SG_GENERAL, SG_INFO, "Airport = " << id << " " SG_LOG( SG_GENERAL, SG_DEBUG, "Next airport = " << id << " "
<< elev ); << elev );
if ( !last_apt_id.empty()) { if ( !last_apt_id.empty()) {
@ -211,7 +265,9 @@ int main( int argc, char **argv ) {
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 )
{ {
if ( start_id.length() && start_id == last_apt_id ) { if ( airport_id.length() && airport_id == last_apt_id ) {
ready_to_go = true;
} else if ( start_id.length() && start_id == last_apt_id ) {
ready_to_go = true; ready_to_go = true;
} }
@ -237,9 +293,12 @@ int main( int argc, char **argv ) {
<< e.getMessage() ); << e.getMessage() );
exit(-1); exit(-1);
} }
if(airport_id.length()) ready_to_go = false;
} }
} else { } else {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id); if(!airport_id.length()) {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id);
}
} }
} }
last_apt_id = id; last_apt_id = id;

View file

@ -41,8 +41,10 @@ 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();
// SG_LOG(SG_GENERAL, SG_DEBUG, " add_intermediate_nodes()"); // SG_LOG(SG_GENERAL, SG_DEBUG, " add_intermediate_nodes()");
printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n", char buf[200];
snprintf(buf, 199, " %.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() );
SG_LOG(SG_GENERAL, SG_BULK, buf);
Point3D new_pt; Point3D new_pt;
@ -56,7 +58,7 @@ void add_intermediate_nodes( int contour, const Point3D& start,
result ); result );
result->add_node( contour, new_pt ); result->add_node( contour, new_pt );
cout << " adding = " << new_pt << endl; SG_LOG(SG_GENERAL, SG_BULK, " adding = " << new_pt);
add_intermediate_nodes( contour, new_pt, end, tmp_nodes, add_intermediate_nodes( contour, new_pt, end, tmp_nodes,
result ); result );

View file

@ -385,7 +385,7 @@ void gen_visual_rwy( const TGRunway& rwy_info,
while ( end1_pct < 1.0 ) { while ( end1_pct < 1.0 ) {
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + rest1_inc; end1_pct = start1_pct + rest1_inc;
cout << "start1 = " << start1_pct << " end1 = " << end1_pct << endl; SG_LOG(SG_GENERAL, SG_DEBUG, "start1 = " << start1_pct << " end1 = " << end1_pct);
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct, start1_pct, end1_pct,

View file

@ -19,10 +19,14 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <iostream.h> #include <simgear/compiler.h>
#include STL_IOSTREAM
#include <math.h> #include <math.h>
#include <simgear/math/point3d.hxx> #include <simgear/math/point3d.hxx>
SG_USING_STD(cout);
SG_USING_STD(endl);
//******************************************************************* //*******************************************************************
// //

View file

@ -5,6 +5,11 @@
#include <config.h> #include <config.h>
#endif #endif
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include STL_STRING
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> // FD_ISSET(), etc. #include <sys/time.h> // FD_ISSET(), etc.
@ -18,11 +23,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include STL_STRING
#include <simgear/bucket/newbucket.hxx> #include <simgear/bucket/newbucket.hxx>
SG_USING_STD( cout ); SG_USING_STD( cout );

View file

@ -29,6 +29,7 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/math/point3d.hxx> #include <simgear/math/point3d.hxx>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <simgear/debug/logstream.hxx>
#include <Polygon/polygon.hxx> #include <Polygon/polygon.hxx>
#include <Triangulate/trieles.hxx> #include <Triangulate/trieles.hxx>
@ -140,10 +141,10 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
} }
} }
cout << "min node index = " << min_node_index << endl; //cout << "min node index = " << min_node_index << endl;
cout << "min index = " << min_index //cout << "min index = " << min_index
<< " value = " << trinodes.get_node( min_index ) //<< " value = " << trinodes.get_node( min_index )
<< " == " << min << endl; //<< " == " << min << endl;
// 2. take midpoint, m, of min with neighbor having lowest // 2. take midpoint, m, of min with neighbor having lowest
// fabs(slope) // fabs(slope)
@ -175,7 +176,7 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
m.setx( (min.x() + ln.x()) / 2.0 ); m.setx( (min.x() + ln.x()) / 2.0 );
m.sety( (min.y() + ln.y()) / 2.0 ); m.sety( (min.y() + ln.y()) / 2.0 );
cout << "low mid point = " << m << endl; //cout << "low mid point = " << m << endl;
// 3. intersect vertical line through m and all other segments of // 3. intersect vertical line through m and all other segments of
// all other contours of this polygon. save point, p3, with // all other contours of this polygon. save point, p3, with
@ -184,7 +185,7 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
p3.sety(100); p3.sety(100);
for ( i = 0; i < (int)p.contours(); ++i ) { for ( i = 0; i < (int)p.contours(); ++i ) {
cout << "contour = " << i << " size = " << p.contour_size( i ) << endl; //cout << "contour = " << i << " size = " << p.contour_size( i ) << endl;
for ( int j = 0; j < (int)(p.contour_size( i ) - 1); ++j ) { for ( int j = 0; j < (int)(p.contour_size( i ) - 1); ++j ) {
// cout << " p1 = " << poly[i][j] << " p2 = " // cout << " p1 = " << poly[i][j] << " p2 = "
// << poly[i][j+1] << endl; // << poly[i][j+1] << endl;
@ -194,7 +195,7 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
p2_index = trinodes.find( p2 ); p2_index = trinodes.find( p2 );
if ( intersects(p1, p2, m.x(), &result) ) { if ( intersects(p1, p2, m.x(), &result) ) {
cout << "intersection = " << result << endl; //cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) && if ( ( result.y() < p3.y() ) &&
( result.y() > m.y() ) && ( result.y() > m.y() ) &&
!( base_leg == TGTriSeg(p1_index, p2_index, 0) ) ) { !( base_leg == TGTriSeg(p1_index, p2_index, 0) ) ) {
@ -209,7 +210,7 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
p1_index = trinodes.find( p1 ); p1_index = trinodes.find( p1 );
p2_index = trinodes.find( p2 ); p2_index = trinodes.find( p2 );
if ( intersects(p1, p2, m.x(), &result) ) { if ( intersects(p1, p2, m.x(), &result) ) {
cout << "intersection = " << result << endl; //cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) && if ( ( result.y() < p3.y() ) &&
( result.y() > m.y() ) && ( result.y() > m.y() ) &&
!( base_leg == TGTriSeg(p1_index, p2_index, 0) ) ) { !( base_leg == TGTriSeg(p1_index, p2_index, 0) ) ) {
@ -218,7 +219,7 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
} }
} }
if ( p3.y() < 100 ) { if ( p3.y() < 100 ) {
cout << "low intersection of other segment = " << p3 << endl; //cout << "low intersection of other segment = " << p3 << endl;
inside_pt = Point3D( (m.x() + p3.x()) / 2.0, inside_pt = Point3D( (m.x() + p3.x()) / 2.0,
(m.y() + p3.y()) / 2.0, (m.y() + p3.y()) / 2.0,
0.0 ); 0.0 );
@ -229,7 +230,7 @@ Point3D calc_point_inside_old( const TGPolygon& p, const int contour,
// 4. take midpoint of p2 && m as an arbitrary point inside polygon // 4. take midpoint of p2 && m as an arbitrary point inside polygon
cout << "inside point = " << inside_pt << endl; //cout << "inside point = " << inside_pt << endl;
return inside_pt; return inside_pt;
} }
@ -375,7 +376,7 @@ void polygon_tesselate( const TGPolygon &p,
string tri_options; string tri_options;
tri_options = "pzYYenQ"; // add multiple "V" entries for verbosity tri_options = "pzYYenQ"; // add multiple "V" entries for verbosity
cout << "Triangulation with options = " << tri_options << endl; //cout << "Triangulation with options = " << tri_options << endl;
triangulate( (char *)tri_options.c_str(), &in, &out, &vorout ); triangulate( (char *)tri_options.c_str(), &in, &out, &vorout );
@ -456,8 +457,8 @@ TGPolygon polygon_tesselate_alt( TGPolygon &p ) {
// inside any other contour // inside any other contour
calc_points_inside( p ); calc_points_inside( p );
for ( i = 0; i < p.contours(); ++i ) { for ( i = 0; i < p.contours(); ++i ) {
cout << "final point inside =" << p.get_point_inside( i ) //cout << "final point inside =" << p.get_point_inside( i )
<< endl; // << endl;
} }
// 2. Do a final triangulation of the entire polygon // 2. Do a final triangulation of the entire polygon
@ -501,13 +502,13 @@ static void contour_tesselate( TGContourNode *node, const TGPolygon &p,
// list of points // list of points
int contour_num = node->get_contour_num(); int contour_num = node->get_contour_num();
cout << "Tesselating contour = " << contour_num << endl; //cout << "Tesselating contour = " << contour_num << endl;
point_list contour = p.get_contour( contour_num ); point_list contour = p.get_contour( contour_num );
double max_x = contour[0].x(); double max_x = contour[0].x();
int total_pts = contour.size(); int total_pts = contour.size();
cout << "contour = " << contour_num << " nodes = " << total_pts << endl; //cout << "contour = " << contour_num << " nodes = " << total_pts << endl;
#if 0 #if 0
// testing ... don't enable this if not testing // testing ... don't enable this if not testing
@ -654,7 +655,7 @@ static void contour_tesselate( TGContourNode *node, const TGPolygon &p,
string tri_options; string tri_options;
tri_options = "pzYYenQ"; // add multiple "V" entries for verbosity tri_options = "pzYYenQ"; // add multiple "V" entries for verbosity
cout << "Triangulation with options = " << tri_options << endl; //cout << "Triangulation with options = " << tri_options << endl;
triangulate( (char *)tri_options.c_str(), &in, &out, &vorout ); triangulate( (char *)tri_options.c_str(), &in, &out, &vorout );
@ -790,13 +791,13 @@ static Point3D point_inside_contour( TGContourNode *node, const TGPolygon &p ) {
} }
// find center point of largest triangle // find center point of largest triangle
cout << "biggest = " << biggest + 1 << " out of " << elelist.size() << endl; //cout << "biggest = " << biggest + 1 << " out of " << elelist.size() << endl;
TGTriEle t = elelist[biggest]; TGTriEle t = elelist[biggest];
contour_num = node->get_contour_num(); contour_num = node->get_contour_num();
Point3D p1 = out_pts[ t.get_n1() ]; Point3D p1 = out_pts[ t.get_n1() ];
Point3D p2 = out_pts[ t.get_n2() ]; Point3D p2 = out_pts[ t.get_n2() ];
Point3D p3 = out_pts[ t.get_n3() ]; Point3D p3 = out_pts[ t.get_n3() ];
cout << "hole tri = " << p1 << endl << " " << p2 << endl << " " << p3 << endl; //cout << "hole tri = " << p1 << endl << " " << p2 << endl << " " << p3 << endl;
// new // new
Point3D center = ( p1 + p2 + p3 ) / 3; Point3D center = ( p1 + p2 + p3 ) / 3;
@ -818,8 +819,8 @@ static void calc_point_inside( TGContourNode *node, TGPolygon &p ) {
int contour_num = node->get_contour_num(); int contour_num = node->get_contour_num();
if ( contour_num >= 0 ) { if ( contour_num >= 0 ) {
Point3D pi = point_inside_contour( node, p ); Point3D pi = point_inside_contour( node, p );
cout << endl << "point inside(" << contour_num << ") = " << pi //cout << endl << "point inside(" << contour_num << ") = " << pi
<< endl << endl; // << endl << endl;
p.set_point_inside( contour_num, pi ); p.set_point_inside( contour_num, pi );
} }
} }
@ -842,8 +843,8 @@ static void build_contour_tree( TGContourNode *node,
const TGPolygon &p, const TGPolygon &p,
int_list &avail ) int_list &avail )
{ {
cout << "working on contour = " << node->get_contour_num() << endl; //cout << "working on contour = " << node->get_contour_num() << endl;
cout << " total contours = " << p.contours() << endl; //cout << " total contours = " << p.contours() << endl;
TGContourNode *tmp; TGContourNode *tmp;
int i; int i;
@ -854,12 +855,12 @@ static void build_contour_tree( TGContourNode *node,
} else { } else {
flag = true; flag = true;
} }
cout << " hole flag = " << flag << endl; //cout << " hole flag = " << flag << endl;
// add all remaining hole/non-hole contours as children of the // add all remaining hole/non-hole contours as children of the
// current node if they are inside of it. // current node if they are inside of it.
for ( i = 0; i < p.contours(); ++i ) { for ( i = 0; i < p.contours(); ++i ) {
cout << " testing contour = " << i << endl; //cout << " testing contour = " << i << endl;
if ( p.get_hole_flag( i ) != flag ) { if ( p.get_hole_flag( i ) != flag ) {
// only holes can be children of non-holes and visa versa // only holes can be children of non-holes and visa versa
if ( avail[i] ) { if ( avail[i] ) {
@ -868,24 +869,24 @@ static void build_contour_tree( TGContourNode *node,
if ( (cur_contour < 0 ) || p.is_inside( i, cur_contour ) ) { if ( (cur_contour < 0 ) || p.is_inside( i, cur_contour ) ) {
// must be inside the parent (or if the parent is // must be inside the parent (or if the parent is
// the root, add all available non-holes. // the root, add all available non-holes.
cout << " adding contour = " << i << endl; //cout << " adding contour = " << i << endl;
avail[i] = 0; avail[i] = 0;
tmp = new TGContourNode( i ); tmp = new TGContourNode( i );
node->add_kid( tmp ); node->add_kid( tmp );
} else { } else {
cout << " not inside" << endl; //cout << " not inside" << endl;
} }
} else { } else {
cout << " not available" << endl; //cout << " not available" << endl;
} }
} else { } else {
cout << " wrong hole/non-hole type" << endl; //cout << " wrong hole/non-hole type" << endl;
} }
} }
// if any of the children are inside of another child, remove the // if any of the children are inside of another child, remove the
// inside one // inside one
cout << "node now has num kids = " << node->get_num_kids() << endl; //cout << "node now has num kids = " << node->get_num_kids() << endl;
for ( i = 0; i < node->get_num_kids(); ++i ) { for ( i = 0; i < node->get_num_kids(); ++i ) {
for ( int j = 0; j < node->get_num_kids(); ++j ) { for ( int j = 0; j < node->get_num_kids(); ++j ) {
@ -901,8 +902,8 @@ static void build_contour_tree( TGContourNode *node,
// need to remove contour j from the kid list // need to remove contour j from the kid list
avail[ node->get_kid( i ) -> get_contour_num() ] = 1; avail[ node->get_kid( i ) -> get_contour_num() ] = 1;
node->remove_kid( i ); node->remove_kid( i );
cout << "removing contour " << A //cout << "removing contour " << A
<< " which is inside of contour " << B << endl; // << " which is inside of contour " << B << endl;
continue; continue;
} }
} else { } else {
@ -940,7 +941,7 @@ void calc_points_inside( TGPolygon& p ) {
// recursively build the tree // recursively build the tree
build_contour_tree( ct, p, avail ); build_contour_tree( ct, p, avail );
print_contour_tree( ct, "" ); //print_contour_tree( ct, "" );
// recurse the tree and build up the point inside list for each // recurse the tree and build up the point inside list for each
// contour/hole // contour/hole
@ -1011,7 +1012,7 @@ snap (const Point3D &p, double grid_size)
result.setx(snap(p.x(), grid_size)); result.setx(snap(p.x(), grid_size));
result.sety(snap(p.y(), grid_size)); result.sety(snap(p.y(), grid_size));
result.setz(snap(p.z(), grid_size)); result.setz(snap(p.z(), grid_size));
cout << result << endl; //cout << result << endl;
return result; return result;
} }
@ -1167,7 +1168,7 @@ static point_list reduce_contour_degeneracy( const point_list& contour ) {
while ( !done ) { while ( !done ) {
// traverse the contour until we find the first bad node or // traverse the contour until we find the first bad node or
// hit the end of the contour // hit the end of the contour
cout << " ... not done ... " << endl; //cout << " ... not done ... " << endl;
bool bad = false; bool bad = false;
int i = 0; int i = 0;
@ -1231,10 +1232,10 @@ static point_list remove_contour_cycles( const point_list& contour ) {
result.push_back( contour[i] ); result.push_back( contour[i] );
for ( unsigned int j = i + 1; j < contour.size(); ++j ) { for ( unsigned int j = i + 1; j < contour.size(); ++j ) {
if ( contour[i] == contour[j] && i + 2 > j ) { if ( contour[i] == contour[j] && i + 2 > j ) {
cout << "detected a small cycle: i = " //cout << "detected a small cycle: i = "
<< i << " j = " << j << endl; // << i << " j = " << j << endl;
for ( unsigned int k = i; k <= j; ++k ) { for ( unsigned int k = i; k <= j; ++k ) {
cout << " " << contour[k] << endl; //cout << " " << contour[k] << endl;
} }
// i = j; // i = j;
} }
@ -1275,7 +1276,7 @@ TGPolygon remove_bad_contours( const TGPolygon &poly ) {
int flag = poly.get_hole_flag( i ); int flag = poly.get_hole_flag( i );
result.add_contour( contour, flag ); result.add_contour( contour, flag );
} else { } else {
cout << "tossing a bad contour" << endl; //cout << "tossing a bad contour" << endl;
} }
} }

View file

@ -19,7 +19,7 @@
namespace tg { namespace tg {
/** /**
* A simple rectangle class for bounding rectanglees. * A simple rectangle class for bounding rectangles.
* *
* The class defines a rectangle in by the vertices of its minimum and * The class defines a rectangle in by the vertices of its minimum and
* maximum corners, ignoring any z coordinates. There are methods to * maximum corners, ignoring any z coordinates. There are methods to

View file

@ -175,7 +175,7 @@ makeBounds (const TGPolygon &polygon)
Rectangle Rectangle
parseChunk (const string &s) parseChunk (const string &s, double delta)
{ {
Rectangle bounds; Rectangle bounds;
int x_factor; int x_factor;
@ -203,11 +203,17 @@ parseChunk (const string &s)
double x = atoi(s.substr(1,3).c_str()) * x_factor; double x = atoi(s.substr(1,3).c_str()) * x_factor;
double y = atoi(s.substr(5).c_str()) * y_factor; double y = atoi(s.substr(5).c_str()) * y_factor;
bounds.setMin(Point3D(x, y, 0)); bounds.setMin(Point3D(x, y, 0));
bounds.setMax(Point3D(x + 10, y + 10, 0)); bounds.setMax(Point3D(x + delta, y + delta, 0));
return bounds; return bounds;
} }
Rectangle
parseTile (const string &s)
{
return( parseChunk(s, 1.0) );
}
}; };
// end of util.cxx // end of util.cxx

View file

@ -104,12 +104,23 @@ Rectangle makeBounds (const TGPolygon &polygon);
/** /**
* Parse a chunk string (like "w080n40") into a rectangle. * Parse a chunk string (like "w080n40") into a rectangle.
* Defaults to 10 x 10 degrees.
* *
* @param s The string. * @param s The string.
* @return A rectangle containing the bounds. * @return A rectangle containing the bounds.
*/ */
Rectangle parseChunk (const string &s); Rectangle parseChunk (const string &s, double delta = 10.0);
};
/**
* Parse a tile string (like "w080n41") into a 1x1 degree rectangle.
*
* @param s The string.
* @return A rectangle containing the bounds.
*/
Rectangle parseTile (const string &s);
}; // namespace tg
#endif // __UTIL_HXX #endif // __UTIL_HXX

View file

@ -176,15 +176,15 @@ void tgSplitPolygon( const string& path, AreaType area,
// get next polygon index // get next polygon index
index = poly_index_next(); index = poly_index_next();
SG_LOG( SG_GENERAL, SG_INFO, " min = " << min << " max = " << max ); SG_LOG( SG_GENERAL, SG_DEBUG, " min = " << min << " max = " << max );
// find buckets for min, and max points of convex hull. // find buckets for min, and max points of convex hull.
// note to self: self, you should think about checking for // note to self: self, you should think about checking for
// polygons that span the date line // polygons that span the date line
SGBucket b_min( min.x(), min.y() ); SGBucket b_min( min.x(), min.y() );
SGBucket b_max( max.x(), max.y() ); SGBucket b_max( max.x(), max.y() );
SG_LOG( SG_GENERAL, SG_INFO, " Bucket min = " << b_min ); SG_LOG( SG_GENERAL, SG_DEBUG, " Bucket min = " << b_min );
SG_LOG( SG_GENERAL, SG_INFO, " Bucket max = " << b_max ); SG_LOG( SG_GENERAL, SG_DEBUG, " Bucket max = " << b_max );
if ( b_min == b_max ) { if ( b_min == b_max ) {
// shape entirely contained in a single bucket, write and bail // shape entirely contained in a single bucket, write and bail
@ -198,7 +198,7 @@ void tgSplitPolygon( const string& path, AreaType area,
sgBucketDiff(b_min, b_max, &dx, &dy); sgBucketDiff(b_min, b_max, &dx, &dy);
SG_LOG( SG_GENERAL, SG_INFO, SG_LOG( SG_GENERAL, SG_INFO,
" polygon spans tile boundaries" ); " polygon spans tile boundaries" );
SG_LOG( SG_GENERAL, SG_INFO, " dx = " << dx SG_LOG( SG_GENERAL, SG_DEBUG, " dx = " << dx
<< " dy = " << dy ); << " dy = " << dy );
if ( (dx > 2880) || (dy > 1440) ) if ( (dx > 2880) || (dy > 1440) )
@ -245,7 +245,7 @@ void tgSplitPolygon( const string& path, AreaType area,
// structures to reduce memory use) // structures to reduce memory use)
// //
SG_LOG ( SG_GENERAL, SG_INFO, SG_LOG ( SG_GENERAL, SG_DEBUG,
"Generating bottom half (" << min.y() << "-" << "Generating bottom half (" << min.y() << "-" <<
clip_line << ")" ); clip_line << ")" );
@ -274,7 +274,7 @@ void tgSplitPolygon( const string& path, AreaType area,
// structures to reduce memory use) // structures to reduce memory use)
// //
SG_LOG ( SG_GENERAL, SG_INFO, SG_LOG ( SG_GENERAL, SG_DEBUG,
"Generating top half (" << clip_line << "-" << "Generating top half (" << clip_line << "-" <<
max.y() << ")" ); max.y() << ")" );

View file

@ -42,7 +42,7 @@ int main( int argc, char **argv ) {
int dx = xrwy2 - xrwy1; int dx = xrwy2 - xrwy1;
int dy = yrwy2 - yrwy1; int dy = yrwy2 - yrwy1;
cout << "dx = " << dx << " dy = " << dy << endl; cout << "dx = " << dx << " dy = " << dy << endl;
double distp = sqrt( dx*dx + dy*dy ); double distp = sqrt( double(dx*dx + dy*dy) );
cout << "runway distance (pixels) = " << distp << endl; cout << "runway distance (pixels) = " << distp << endl;
// find pixel resolution // find pixel resolution
@ -52,7 +52,7 @@ int main( int argc, char **argv ) {
cout << "pixel per feet = " << feet_to_pixel << endl; cout << "pixel per feet = " << feet_to_pixel << endl;
// find runway angle in image space // find runway angle in image space
double img_angle = atan2( dy, dx ); double img_angle = atan2( double(dy), double(dx) );
cout << "runway angle in image space = " cout << "runway angle in image space = "
<< img_angle * SGD_RADIANS_TO_DEGREES << endl; << img_angle * SGD_RADIANS_TO_DEGREES << endl;
// angle offset // angle offset

View file

@ -218,17 +218,18 @@ usage ()
<< " [opts] <db> <library> <coverage> <feature>" << " [opts] <db> <library> <coverage> <feature>"
<< endl; << endl;
cerr << "Options:" << endl; cerr << "Options:" << endl;
cerr << "--chunk=<chunk> (default: none)" << endl; cerr << "--tile=<tile> (default: none)" << endl;
cerr << "--chunk=<chunk> (default: none)" << endl;
cerr << "--min-lon=<longitude> (default: -180.0)" << endl; cerr << "--min-lon=<longitude> (default: -180.0)" << endl;
cerr << "--min-lat=<latitude> (default: -90.0)" << endl; cerr << "--min-lat=<latitude> (default: -90.0)" << endl;
cerr << "--max-lon=<longitude> (default: 180.0)" << endl; cerr << "--max-lon=<longitude> (default: 180.0)" << endl;
cerr << "--max-lat=<latitude> (default: 90.0)" << endl; cerr << "--max-lat=<latitude> (default: 90.0)" << endl;
cerr << "--min-area=<area> (default: none)" << endl; cerr << "--min-area=<area> (default: none)" << endl;
cerr << "--max-area=<area> (default: none)" << endl; cerr << "--max-area=<area> (default: none)" << endl;
cerr << "--material=<material_type> (default: Default)" << endl; cerr << "--material=<material_type> (default: Default)" << endl;
cerr << "--width=<meters> (default: 50 line, 500 point)" << endl; cerr << "--width=<meters> (default: 50 line, 500 point)" << endl;
cerr << "--work-dir=<dir> (default: .)" << endl; cerr << "--work-dir=<dir> (default: .)" << endl;
cerr << "--att=<item>:<value> (may be repeated)" << endl; cerr << "--att=<item>:<value> (may be repeated)" << endl;
cerr << "--att=!<item>:<value> (may be repeated)" << endl; cerr << "--att=!<item>:<value> (may be repeated)" << endl;
exit(2); exit(2);
} }
@ -294,8 +295,13 @@ main (int argc, const char **argv)
int argPos = 1; int argPos = 1;
while (argPos < argc) { while (argPos < argc) {
string arg = argv[argPos]; string arg = argv[argPos];
if (arg.find("--tile=") == 0) {
bounds = tg::parseTile(arg.substr(7));
argPos++;
}
if (arg.find("--chunk=") == 0) { else if (arg.find("--chunk=") == 0) {
bounds = tg::parseChunk(arg.substr(8)); bounds = tg::parseChunk(arg.substr(8));
argPos++; argPos++;
} }