From 8698ab4e69878b8d0c9e8349bcf71ab563639e81 Mon Sep 17 00:00:00 2001 From: Peter Sadrozinski Date: Fri, 19 Oct 2012 17:55:01 -0400 Subject: [PATCH] Use SGGeod as reference point in TGTexParams --- src/Airports/GenAirports850/airport.cxx | 12 +++---- src/Airports/GenAirports850/closedpoly.cxx | 2 +- src/Airports/GenAirports850/helipad.cxx | 6 ++-- src/Airports/GenAirports850/linearfeature.cxx | 2 +- src/Airports/GenAirports850/rwy_gen.cxx | 6 ++-- src/Airports/GenAirports850/taxiway.cxx | 2 +- src/BuildTiles/Main/tgconstruct_poly.cxx | 2 +- src/BuildTiles/Main/tgconstruct_texture.cxx | 4 +-- src/BuildTiles/Main/tglandclass.cxx | 20 ----------- src/BuildTiles/Main/tglandclass.hxx | 3 +- src/BuildTiles/Main/tgshape.cxx | 33 ------------------- src/BuildTiles/Main/tgshape.hxx | 3 +- src/Lib/Geometry/util.cxx | 2 +- src/Lib/Polygon/chop-bin.cxx | 6 ++-- src/Lib/Polygon/texparams.cxx | 23 +++---------- src/Lib/Polygon/texparams.hxx | 21 ++++++------ 16 files changed, 40 insertions(+), 107 deletions(-) diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index de695d7e..5135a4ff 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -175,7 +175,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly, const TGTexPa TGPolygon result; result.erase(); - Point3D ref = tp.get_ref(); + SGGeod ref = tp.get_ref(); double width = tp.get_width(); double length = tp.get_length(); double heading = tp.get_heading(); @@ -204,7 +204,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly, const TGTexPa // and ending az1, az2 and distance (s). Lat, lon, and // azimuth are in degrees. distance in meters double az1, az2, dist; - geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), + geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(), &az1, &az2, &dist ); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course = " << az2); @@ -267,7 +267,7 @@ static TGPolygon shoulder_tex_coords( const TGPolygon& in_poly, const TGTexParam TGPolygon result; result.erase(); - Point3D ref = tp.get_ref(); + SGGeod ref = tp.get_ref(); double width = tp.get_width(); double length = tp.get_length(); double heading = tp.get_heading(); @@ -302,7 +302,7 @@ static TGPolygon shoulder_tex_coords( const TGPolygon& in_poly, const TGTexParam // and ending az1, az2 and distance (s). Lat, lon, and // azimuth are in degrees. distance in meters double az1, az2, dist; - geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), + geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(), &az1, &az2, &dist ); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2); @@ -358,7 +358,7 @@ static TGPolygon linear_feature_tex_coords( const TGPolygon& in_poly, const TGTe TGPolygon result; result.erase(); - Point3D ref = tp.get_ref(); + SGGeod ref = tp.get_ref(); double width = tp.get_width(); double length = tp.get_length(); double heading = tp.get_heading(); @@ -393,7 +393,7 @@ static TGPolygon linear_feature_tex_coords( const TGPolygon& in_poly, const TGTe // and ending az1, az2 and distance (s). Lat, lon, and // azimuth are in degrees. distance in meters double az1, az2, dist; - geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), + geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(), &az1, &az2, &dist ); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2); diff --git a/src/Airports/GenAirports850/closedpoly.cxx b/src/Airports/GenAirports850/closedpoly.cxx index 6118b0fe..de4d1914 100644 --- a/src/Airports/GenAirports850/closedpoly.cxx +++ b/src/Airports/GenAirports850/closedpoly.cxx @@ -492,7 +492,7 @@ int ClosedPoly::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams, SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct"); - tp = TGTexParams( pre_tess.get_pt(0,0), 5.0, 5.0, texture_heading ); + tp = TGTexParams( pre_tess.get_pt(0,0).toSGGeod(), 5.0, 5.0, texture_heading ); texparams->push_back( tp ); if ( apt_base ) diff --git a/src/Airports/GenAirports850/helipad.cxx b/src/Airports/GenAirports850/helipad.cxx index 8f832c27..7516c1e6 100644 --- a/src/Airports/GenAirports850/helipad.cxx +++ b/src/Airports/GenAirports850/helipad.cxx @@ -146,7 +146,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys, WriteGeom( helipad, material + "heli", rwy_polys, accum, slivers); TGTexParams tp; - tp = TGTexParams( helipad.get_pt(0,0), maxsize, maxsize, heli.heading ); + tp = TGTexParams( helipad.get_pt(0,0).toSGGeod(), maxsize, maxsize, heli.heading ); tp.set_minu( 1 ); tp.set_maxu( 0 ); tp.set_minv( 1 ); @@ -187,7 +187,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys, area_geom.add_contour(area_poly.get_contour(i), false); WriteGeom( area_geom, material + "tiedown", rwy_polys, accum, slivers); - tp = TGTexParams( area_poly.get_pt(i,0), maxsize, areahight, heading ); + tp = TGTexParams( area_poly.get_pt(i,0).toSGGeod(), maxsize, areahight, heading ); tp.set_minu( 1 ); tp.set_maxu( 0 ); tp.set_minv( 1 ); @@ -239,7 +239,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys, sp.set_flag( "heli-shoulder" ); shoulder_polys.push_back( sp ); - tp = TGTexParams( area_poly.get_pt(0,1), areahight, shoulder_width, heading ); + tp = TGTexParams( area_poly.get_pt(0,1).toSGGeod(), areahight, shoulder_width, heading ); tp.set_minu( 1 ); tp.set_maxu( 0 ); tp.set_minv( 1 ); diff --git a/src/Airports/GenAirports850/linearfeature.cxx b/src/Airports/GenAirports850/linearfeature.cxx index 720cdd16..0904ea79 100644 --- a/src/Airports/GenAirports850/linearfeature.cxx +++ b/src/Airports/GenAirports850/linearfeature.cxx @@ -741,7 +741,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) sp.set_flag("lf"); marking_polys.push_back(sp); - tp = TGTexParams( prev_inner, width, 1.0f, heading ); + tp = TGTexParams( prev_inner.toSGGeod(), width, 1.0f, heading ); tp.set_minv(last_end_v); marking_tps.push_back(tp); diff --git a/src/Airports/GenAirports850/rwy_gen.cxx b/src/Airports/GenAirports850/rwy_gen.cxx index 046b1305..e8aaa349 100644 --- a/src/Airports/GenAirports850/rwy_gen.cxx +++ b/src/Airports/GenAirports850/rwy_gen.cxx @@ -132,11 +132,11 @@ void Runway::gen_shoulder_section( Point3D p0, Point3D p1, Point3D t0, Point3D t sp.set_flag( "shoulder" ); if (side == 0) { - tp = TGTexParams( poly.get_pt(0,2), width, dist, heading ); + tp = TGTexParams( poly.get_pt(0,2).toSGGeod(), width, dist, heading ); tp.set_minu(0); tp.set_maxu(1); } else { - tp = TGTexParams( poly.get_pt(0,1), width, dist, heading ); + tp = TGTexParams( poly.get_pt(0,1).toSGGeod(), width, dist, heading ); tp.set_minu(1); tp.set_maxu(0); } @@ -391,7 +391,7 @@ void Runway::gen_runway_section( const TGPolygon& runway, double sect_wid = width * ( endw_pct - startw_pct ); TGTexParams tp; - tp = TGTexParams( p0, + tp = TGTexParams( p0.toSGGeod(), sect_wid, sect_len, heading ); diff --git a/src/Airports/GenAirports850/taxiway.cxx b/src/Airports/GenAirports850/taxiway.cxx index 2dca5f9b..3a134fde 100644 --- a/src/Airports/GenAirports850/taxiway.cxx +++ b/src/Airports/GenAirports850/taxiway.cxx @@ -174,7 +174,7 @@ int Taxiway::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams, sup SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct"); - tp = TGTexParams( taxi.get_pt(0,0), width, 250*SG_FEET_TO_METER, heading ); + tp = TGTexParams( taxi.get_pt(0,0).toSGGeod(), width, 250*SG_FEET_TO_METER, heading ); texparams->push_back( tp ); if ( apt_base ) diff --git a/src/BuildTiles/Main/tgconstruct_poly.cxx b/src/BuildTiles/Main/tgconstruct_poly.cxx index 887462e0..d1a98dbc 100644 --- a/src/BuildTiles/Main/tgconstruct_poly.cxx +++ b/src/BuildTiles/Main/tgconstruct_poly.cxx @@ -140,7 +140,7 @@ bool TGConstruct::load_poly(const string& path) { in >> minv; in >> maxv; - tp.set_ref( Point3D(x, y, 0.0f) ); + tp.set_ref( SGGeod::fromDeg(x,y) ); tp.set_width( width ); tp.set_length( length ); tp.set_heading( heading ); diff --git a/src/BuildTiles/Main/tgconstruct_texture.cxx b/src/BuildTiles/Main/tgconstruct_texture.cxx index e58db5ce..1f20fd59 100644 --- a/src/BuildTiles/Main/tgconstruct_texture.cxx +++ b/src/BuildTiles/Main/tgconstruct_texture.cxx @@ -77,7 +77,7 @@ TGPolygon TGConstruct::linear_tex_coords( const TGPolygon& tri, const TGTexParam result.erase(); - Point3D ref = tp.get_ref(); + SGGeod ref = tp.get_ref(); double width = tp.get_width(); double length = tp.get_length(); double heading = tp.get_heading(); @@ -112,7 +112,7 @@ TGPolygon TGConstruct::linear_tex_coords( const TGPolygon& tri, const TGTexParam // and ending az1, az2 and distance (s). Lat, lon, and // azimuth are in degrees. distance in meters double az1, az2, dist; - geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), + geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(), &az1, &az2, &dist ); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2); diff --git a/src/BuildTiles/Main/tglandclass.cxx b/src/BuildTiles/Main/tglandclass.cxx index 1bc58149..cac0a1ec 100644 --- a/src/BuildTiles/Main/tglandclass.cxx +++ b/src/BuildTiles/Main/tglandclass.cxx @@ -42,26 +42,6 @@ void TGLandclass::clear(void) } } -// input from stream -std::istream& operator >> ( std::istream& in, TGLandclass& lc) -{ - int i, j, count; - - // Load all landclass shapes - for (i=0; i> count; - - for (j=0; j> shape; - lc.shapes[i].push_back( shape ); - } - } - - return in; -} - void TGLandclass::LoadFromGzFile(gzFile& fp) { int i, j, count; diff --git a/src/BuildTiles/Main/tglandclass.hxx b/src/BuildTiles/Main/tglandclass.hxx index 4bcc3284..01f9c118 100644 --- a/src/BuildTiles/Main/tglandclass.hxx +++ b/src/BuildTiles/Main/tglandclass.hxx @@ -152,8 +152,7 @@ public: void SaveToGzFile( gzFile& fp ); void LoadFromGzFile( gzFile& fp ); - // Friends for serialization - friend std::istream& operator>> ( std::istream&, TGLandclass& ); + // Friend for output to stream friend std::ostream& operator<< ( std::ostream&, const TGLandclass& ); private: diff --git a/src/BuildTiles/Main/tgshape.cxx b/src/BuildTiles/Main/tgshape.cxx index c5d11664..1555f884 100644 --- a/src/BuildTiles/Main/tgshape.cxx +++ b/src/BuildTiles/Main/tgshape.cxx @@ -70,39 +70,6 @@ void TGShape::IntersectPolys( void ) } } -// Serialization -// input from stream -std::istream& operator >> ( std::istream& in, TGShape& p) -{ - int i, count; - - // First, load the clipmask - in >> p.clip_mask; - - // Then load superpolys - in >> count; - for (i=0; i> sp; - p.sps.push_back( sp ); - } - - // Then load texparams - in >> count; - for (i=0; i> tp; - p.tps.push_back( tp ); - } - - // Load the id, area type and textured flag - in >> p.id; - in >> p.area; - in >> p.textured; - - return in; -} - void TGShape::LoadFromGzFile(gzFile& fp) { int i, count; diff --git a/src/BuildTiles/Main/tgshape.hxx b/src/BuildTiles/Main/tgshape.hxx index 3a8cbbdb..17e6f0cc 100644 --- a/src/BuildTiles/Main/tgshape.hxx +++ b/src/BuildTiles/Main/tgshape.hxx @@ -59,8 +59,7 @@ public: void SaveToGzFile( gzFile& fp ); void LoadFromGzFile( gzFile& fp ); - // Friends for serialization - friend std::istream& operator>> ( std::istream&, TGShape& ); + // Friend for output to stream friend std::ostream& operator<< ( std::ostream&, const TGShape& ); }; diff --git a/src/Lib/Geometry/util.cxx b/src/Lib/Geometry/util.cxx index 5e770c23..c2050943 100644 --- a/src/Lib/Geometry/util.cxx +++ b/src/Lib/Geometry/util.cxx @@ -767,7 +767,7 @@ makePolygonsTP (const Line &line, double width, poly_list& polys, texparams_list polys.push_back(poly); - tp = TGTexParams( prev_inner, width, 20.0f, heading ); + tp = TGTexParams( prev_inner.Point3D::toSGGeod(), width, 20.0f, heading ); tp.set_minv(last_end_v); tps.push_back(tp); diff --git a/src/Lib/Polygon/chop-bin.cxx b/src/Lib/Polygon/chop-bin.cxx index c993cd54..ff868af4 100644 --- a/src/Lib/Polygon/chop-bin.cxx +++ b/src/Lib/Polygon/chop-bin.cxx @@ -371,7 +371,8 @@ static void clip_and_write_polys_with_tps( string root, long int p_index, tp = clipped_tps[s]; fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n", - tp.get_ref().x(), tp.get_ref().y(), tp.get_width(), tp.get_length(), + tp.get_ref().getLongitudeDeg(), tp.get_ref().getLatitudeDeg(), + tp.get_width(), tp.get_length(), tp.get_heading(), tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu()); @@ -474,7 +475,8 @@ static void clip_and_write_poly_tp( string root, long int p_index, fprintf( rfp, "%s\n", poly_type.c_str() ); fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n", - tp.get_ref().x(), tp.get_ref().y(), tp.get_width(), tp.get_length(), + tp.get_ref().getLongitudeDeg(), tp.get_ref().getLatitudeDeg(), + tp.get_width(), tp.get_length(), tp.get_heading(), tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu()); diff --git a/src/Lib/Polygon/texparams.cxx b/src/Lib/Polygon/texparams.cxx index d3ed98c0..62fc72e5 100644 --- a/src/Lib/Polygon/texparams.cxx +++ b/src/Lib/Polygon/texparams.cxx @@ -1,3 +1,5 @@ +#include + #include "texparams.hxx" // Send a TexParam to standard output. @@ -19,7 +21,7 @@ std::ostream& operator << (std::ostream &output, const TGTexParams &tp) void TGTexParams::SaveToGzFile(gzFile& fp) { - sgWritePoint3D( fp, ref ); + sgWriteSGGeod( fp, ref ); sgWriteDouble( fp, width ); sgWriteDouble( fp, length ); sgWriteDouble( fp, heading ); @@ -30,26 +32,9 @@ void TGTexParams::SaveToGzFile(gzFile& fp) sgWriteDouble( fp, maxv ); } -// Read a polygon from input buffer. -std::istream& operator >> (std::istream &input, TGTexParams &tp) -{ - // Load the data - input >> tp.ref; - input >> tp.width; - input >> tp.length; - input >> tp.heading; - - input >> tp.minu; - input >> tp.maxu; - input >> tp.minv; - input >> tp.maxv; - - return input; -} - void TGTexParams::LoadFromGzFile(gzFile& fp) { - sgReadPoint3D( fp, ref ); + sgReadSGGeod( fp, ref ); sgReadDouble( fp, &width ); sgReadDouble( fp, &length ); sgReadDouble( fp, &heading ); diff --git a/src/Lib/Polygon/texparams.hxx b/src/Lib/Polygon/texparams.hxx index c8e7af15..29aa2135 100644 --- a/src/Lib/Polygon/texparams.hxx +++ b/src/Lib/Polygon/texparams.hxx @@ -30,19 +30,21 @@ # error This library requires C++ #endif +#include +#include +#include #include -#include +#include -#include +#include /* for gzFile */ -#include class TGTexParams { private: - Point3D ref; + SGGeod ref; double width; double length; double heading; @@ -58,7 +60,7 @@ public: inline TGTexParams( void ) { } - inline TGTexParams( const Point3D &r, const double w, const double l, const double h ) + inline TGTexParams( const SGGeod &r, const double w, const double l, const double h ) { ref = r; width = w; @@ -72,11 +74,11 @@ public: { } - inline Point3D get_ref() const + inline SGGeod get_ref() const { return ref; } - inline void set_ref( const Point3D &r ) + inline void set_ref( const SGGeod &r ) { ref = r; } @@ -146,9 +148,8 @@ public: void SaveToGzFile( gzFile& fp ); void LoadFromGzFile( gzFile& fp ); - - // Friends for serialization - friend std::istream& operator>> ( std::istream&, TGTexParams& ); + + // Friend for output friend std::ostream& operator<< ( std::ostream&, const TGTexParams& ); };