diff --git a/src/Airports/GenAirports850/linearfeature.cxx b/src/Airports/GenAirports850/linearfeature.cxx index 82d804a6..720cdd16 100644 --- a/src/Airports/GenAirports850/linearfeature.cxx +++ b/src/Airports/GenAirports850/linearfeature.cxx @@ -1,14 +1,9 @@ #include #include -#include -#include -#include -#include -#include -#include #include +#include // for debugging clipping errors #include @@ -931,7 +926,7 @@ int LinearFeature::BuildBtg(superpoly_list* line_polys, texparams_list* line_tps TGPolygon poly, tmp; void* ds_id = NULL; // If we are going to build shapefiles void* l_id = NULL; // datasource and layer IDs - SGVec3d min, max, minp, maxp; + SGGeod min, max, minp, maxp; if ( make_shapefiles ) { char ds_name[128]; @@ -944,16 +939,16 @@ int LinearFeature::BuildBtg(superpoly_list* line_polys, texparams_list* line_tps { poly = marking_polys[i].get_poly(); poly.get_bounding_box(minp, maxp); - SGBoxd box1(minp, maxp); + tg::Rectangle box1(minp, maxp); for (int j= 0; j < lines->contours(); ++j) { tmp.erase(); tmp.add_contour(lines->get_contour(j), 0); tmp.get_bounding_box(min, max); - SGBoxd box2(min, max); + tg::Rectangle box2(min, max); - if ( intersects(box2, box1 ) ) + if ( box2.intersects(box1) ) { poly = tgPolygonDiffClipper( poly, tmp ); } diff --git a/src/BuildTiles/Main/tgconstruct_tesselate.cxx b/src/BuildTiles/Main/tgconstruct_tesselate.cxx index 18b08a75..3218564c 100644 --- a/src/BuildTiles/Main/tgconstruct_tesselate.cxx +++ b/src/BuildTiles/Main/tgconstruct_tesselate.cxx @@ -39,7 +39,7 @@ void TGConstruct::TesselatePolys( void ) { // tesselate the polygons and prepair them for final output point_list poly_extra; - SGVec3d min, max; + SGGeod min, max; for (unsigned int area = 0; area < TG_MAX_AREA_TYPES; area++) { for (unsigned int shape = 0; shape < polys_clipped.area_size(area); shape++ ) { @@ -53,7 +53,7 @@ void TGConstruct::TesselatePolys( void ) TGPolygon poly = polys_clipped.get_poly(area, shape, segment); poly.get_bounding_box(min, max); - poly_extra = nodes.get_geod_inside( Point3D::fromSGVec3(min), Point3D::fromSGVec3(max) ); + poly_extra = nodes.get_geod_inside( Point3D::fromSGGeod(min), Point3D::fromSGGeod(max) ); SG_LOG( SG_CLIPPER, SG_INFO, "Tesselating " << get_area_name( (AreaType)area ) << "(" << area << "): " << shape+1 << "-" << segment << " of " << (int)polys_clipped.area_size(area) << diff --git a/src/Lib/Geometry/poly_extra.cxx b/src/Lib/Geometry/poly_extra.cxx index fb44925e..eb09bcdf 100644 --- a/src/Lib/Geometry/poly_extra.cxx +++ b/src/Lib/Geometry/poly_extra.cxx @@ -111,14 +111,14 @@ TGPolygon add_nodes_to_poly( const TGPolygon& poly, TGPolygon add_tgnodes_to_poly( const TGPolygon& poly, const TGNodes* nodes ) { TGPolygon result; result.erase(); - SGVec3d min, max; + SGGeod min, max; Point3D p0, p1; point_list poly_points; poly.get_bounding_box(min, max); SG_LOG(SG_GENERAL, SG_DEBUG, "add_tgnodes_to_poly : min " << min << " max " << max ); - poly_points = nodes->get_geod_inside( Point3D::fromSGVec3(min), Point3D::fromSGVec3(max) ); + poly_points = nodes->get_geod_inside( Point3D::fromSGGeod(min), Point3D::fromSGGeod(max) ); for ( int i = 0; i < poly.contours(); ++i ) { SG_LOG(SG_GENERAL, SG_DEBUG, "contour = " << i); diff --git a/src/Lib/Geometry/rectangle.cxx b/src/Lib/Geometry/rectangle.cxx index 75a1d1ed..af3ce1bf 100644 --- a/src/Lib/Geometry/rectangle.cxx +++ b/src/Lib/Geometry/rectangle.cxx @@ -64,7 +64,7 @@ Rectangle::isInside (const SGGeod &p) const } bool -Rectangle::isOverlapping (const Rectangle &r) const +Rectangle::intersects (const Rectangle &r) const { const SGGeod &min = r.getMin(); const SGGeod &max = r.getMax(); diff --git a/src/Lib/Geometry/rectangle.hxx b/src/Lib/Geometry/rectangle.hxx index daa66a23..84bfa786 100644 --- a/src/Lib/Geometry/rectangle.hxx +++ b/src/Lib/Geometry/rectangle.hxx @@ -118,7 +118,7 @@ public: * @return true if the rectangle is touching or overlapping, false * otherwise. */ - virtual bool isOverlapping (const Rectangle &r) const; + virtual bool intersects (const Rectangle &r) const; /** * Create a polygon representation of this rectangle. diff --git a/src/Lib/Polygon/polygon.cxx b/src/Lib/Polygon/polygon.cxx index a322bf24..e9b1c794 100644 --- a/src/Lib/Polygon/polygon.cxx +++ b/src/Lib/Polygon/polygon.cxx @@ -18,13 +18,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // -// $Id: polygon.cxx,v 1.30 2007-11-05 14:02:21 curt Exp $ - - -// include Generic Polygon Clipping Library -// -// http://www.cs.man.ac.uk/aig/staff/alan/software/ -// #include #include @@ -35,13 +28,8 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include +#include #include @@ -60,7 +48,7 @@ TGPolygon::TGPolygon( void ) TGPolygon::~TGPolygon( void ) { } -void TGPolygon::get_bounding_box( SGVec3d& min, SGVec3d& max ) const +void TGPolygon::get_bounding_box( SGGeod& min, SGGeod& max ) const { double minx = std::numeric_limits::infinity(); double miny = std::numeric_limits::infinity(); @@ -69,16 +57,16 @@ void TGPolygon::get_bounding_box( SGVec3d& min, SGVec3d& max ) const for ( int i = 0; i < contours(); i++ ) { for (unsigned int j = 0; j < poly[i].size(); j++) { - SGVec3d pt = poly[i][j].toSGVec3d(); - if ( pt.x() < minx ) { minx = pt.x(); } - if ( pt.x() > maxx ) { maxx = pt.x(); } - if ( pt.y() < miny ) { miny = pt.y(); } - if ( pt.y() > maxy ) { maxy = pt.y(); } + SGGeod pt = poly[i][j].toSGGeod(); + if ( pt.getLongitudeDeg() < minx ) { minx = pt.getLongitudeDeg(); } + if ( pt.getLongitudeDeg() > maxx ) { maxx = pt.getLongitudeDeg(); } + if ( pt.getLatitudeDeg() < miny ) { miny = pt.getLatitudeDeg(); } + if ( pt.getLatitudeDeg() > maxy ) { maxy = pt.getLatitudeDeg(); } } } - min = SGVec3d( minx, miny, 0.0 ); - max = SGVec3d( maxx, maxy, 0.0 ); + min = SGGeod::fromDeg( minx, miny ); + max = SGGeod::fromDeg( maxx, maxy ); } @@ -420,17 +408,13 @@ static Point3D MakeTGPoint( ClipperLib::IntPoint pt ) return tg_pt; } -static SGVec3d MakeSGVec3D( ClipperLib::IntPoint pt ) +static SGGeod MakeSGGeod( ClipperLib::IntPoint pt ) { - SGVec3d sgvec; double x, y; - x = (double)( ((double)pt.X) / (double)FIXEDPT ); y = (double)( ((double)pt.Y) / (double)FIXEDPT ); - sgvec = SGVec3d( x, y, 0.0f); - - return sgvec; + return SGGeod::fromDeg(x, y); } double MakeClipperDelta( double mDelta ) @@ -502,7 +486,7 @@ void make_tg_poly_from_clipper( const ClipperLib::Polygons& in, TGPolygon *out ) } -void get_Clipper_bounding_box( const ClipperLib::Polygons& in, SGVec3d& min, SGVec3d& max ) +void get_Clipper_bounding_box( const ClipperLib::Polygons& in, SGGeod& min, SGGeod& max ) { ClipperLib::IntPoint min_pt, max_pt; @@ -530,8 +514,8 @@ void get_Clipper_bounding_box( const ClipperLib::Polygons& in, SGVec3d& min, SGV } } - min = MakeSGVec3D( min_pt ); - max = MakeSGVec3D( max_pt ); + min = MakeSGGeod( min_pt ); + max = MakeSGGeod( max_pt ); } void clipper_to_shapefile( ClipperLib::Polygons polys, char* ds ) @@ -666,7 +650,7 @@ void tgPolygonAddToClipperAccumulator( const TGPolygon& subject, bool dump ) TGPolygon tgPolygonDiffClipperWithAccumulator( const TGPolygon& subject ) { TGPolygon result; - SGVec3d min, max, minp, maxp; + SGGeod min, max, minp, maxp; unsigned int num_hits = 0; ClipperLib::Polygons clipper_subject; @@ -675,7 +659,7 @@ TGPolygon tgPolygonDiffClipperWithAccumulator( const TGPolygon& subject ) // Start with full poly result = subject; result.get_bounding_box(minp, maxp); - SGBoxd box1(minp, maxp); + tg::Rectangle box1(minp, maxp); ClipperLib::Clipper c; c.Clear(); @@ -685,9 +669,9 @@ TGPolygon tgPolygonDiffClipperWithAccumulator( const TGPolygon& subject ) // clip result against all polygons in the accum that intersect our bb for (unsigned int i=0; i < clipper_accumulator.size(); i++) { get_Clipper_bounding_box( clipper_accumulator[i], min, max); - SGBoxd box2(min, max); + tg::Rectangle box2(min, max); - if ( intersects( box2, box1 ) ) + if ( box2.intersects(box1) ) { c.AddPolygons(clipper_accumulator[i], ClipperLib::ptClip); num_hits++; diff --git a/src/Lib/Polygon/polygon.hxx b/src/Lib/Polygon/polygon.hxx index f77a7af5..c3ca5a2f 100644 --- a/src/Lib/Polygon/polygon.hxx +++ b/src/Lib/Polygon/polygon.hxx @@ -138,7 +138,7 @@ public: poly[contour][i] = p; } - void get_bounding_box( SGVec3d& min, SGVec3d& max ) const; + void get_bounding_box( SGGeod& min, SGGeod& max ) const; // get and set an arbitrary point inside the specified polygon contour inline Point3D get_point_inside( const int contour ) const