diff --git a/src/Airports/GenAirports/build.cxx b/src/Airports/GenAirports/build.cxx index 904e0352..db669301 100644 --- a/src/Airports/GenAirports/build.cxx +++ b/src/Airports/GenAirports/build.cxx @@ -796,6 +796,8 @@ void build_airport( string airport_id, float alt_m, for ( k = 0; k < (int)rwy_polys.size(); ++k ) { TGPolygon poly = rwy_polys[k].get_poly(); + SG_LOG(SG_GENERAL, SG_DEBUG, "total size of section " << k << " before =" << poly.total_size()); + poly = remove_dups( poly ); SG_LOG(SG_GENERAL, SG_DEBUG, "total size after remove_dups() = " << poly.total_size()); poly = remove_bad_contours( poly ); @@ -822,7 +824,7 @@ void build_airport( string airport_id, float alt_m, // tesselate the polygons and prepair them for final output for ( i = 0; i < (int)rwy_polys.size(); ++i ) { - SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating section = " << i); + SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating section = " << i << " flag = " << rwy_polys[i].get_flag()); TGPolygon poly = rwy_polys[i].get_poly(); SG_LOG(SG_GENERAL, SG_DEBUG, "total size before = " << poly.total_size()); diff --git a/src/Lib/Geometry/poly_support.cxx b/src/Lib/Geometry/poly_support.cxx index 9583d07d..1ad927cc 100644 --- a/src/Lib/Geometry/poly_support.cxx +++ b/src/Lib/Geometry/poly_support.cxx @@ -395,25 +395,11 @@ static void intersect_yline_with_contour( double yline, TGContourNode *node, TGP // cout << "intersect_yline_with_contour() p0=(" << p0.x() << ", " << p0.y() << ") p1=(" << p1.x() << ", " << p1.y() << ") ymin=" << ymin << " ymax=" << ymax << " yline=" << yline << endl; - if ((yline+SG_EPSILON)(cout, " ")); + cout << endl; + + cout << "calc_point_inside() maxdiff=" << maxdiff << " yline=" << yline << endl; vector < double > xcuts; @@ -512,9 +500,9 @@ static void calc_point_inside( TGContourNode *node, TGPolygon &p ) { sort( xcuts.begin(), xcuts.end() ); - // cout << "calc_point_inside() " << xcuts.size() << " intersections "; - // copy(xcuts.begin(), xcuts.end(), ostream_iterator(cout, " ")); - // cout << endl; + cout << "calc_point_inside() " << xcuts.size() << " intersections "; + copy(xcuts.begin(), xcuts.end(), ostream_iterator(cout, " ")); + cout << endl; if ( xcuts.size() < 2 || (xcuts.size() % 2) != 0 ) { throw sg_exception("Geometric inconsistency in calc_point_inside()"); @@ -1026,13 +1014,26 @@ TGPolygon remove_bad_contours( const TGPolygon &poly ) { for ( int i = 0; i < poly.contours(); ++i ) { point_list contour = poly.get_contour( i ); - if ( contour.size() >= 3 ) { - // good - int flag = poly.get_hole_flag( i ); - result.add_contour( contour, flag ); - } else { + if ( contour.size() < 3) { //cout << "tossing a bad contour" << endl; + continue; } + double xmin,xmax,ymin,ymax; + xmin=xmax=contour[0].x(); + ymin=ymax=contour[0].y(); + for ( int j = 1; j < contour.size(); ++j ) { + xmin = SGMisc::min(xmin,contour[j].x()); + ymin = SGMisc::min(ymin,contour[j].y()); + xmax = SGMisc::max(xmax,contour[j].x()); + ymax = SGMisc::max(ymax,contour[j].y()); + } + if ( xmax-xmin < SG_EPSILON || ymax-ymin < SG_EPSILON ) { + //cout << "tossing a bad contour (too small)" << endl; + continue; + } + /* keeping the contour */ + int flag = poly.get_hole_flag( i ); + result.add_contour( contour, flag ); } return result;