From fb50bb46814f011597af36e1d1d9f48c7cc25056 Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Sun, 27 Jan 2019 18:59:01 -0600 Subject: [PATCH] [Genapts] Reduce technical debt. Migrate away from usage of . --- src/Airports/GenAirports850/airport.cxx | 20 ++--- src/Airports/GenAirports850/beznode.hxx | 2 +- src/Airports/GenAirports850/closedpoly.cxx | 47 ++++-------- src/Airports/GenAirports850/closedpoly.hxx | 2 +- src/Airports/GenAirports850/elevations.cxx | 2 +- src/Airports/GenAirports850/elevations.hxx | 2 +- src/Airports/GenAirports850/helipad.cxx | 25 +++--- src/Airports/GenAirports850/helipad.hxx | 2 +- src/Airports/GenAirports850/linearfeature.hxx | 21 ++--- .../GenAirports850/linked_objects.cxx | 33 +++++--- .../GenAirports850/linked_objects.hxx | 6 +- src/Airports/GenAirports850/object.cxx | 10 ++- src/Airports/GenAirports850/object.hxx | 2 +- src/Airports/GenAirports850/output.cxx | 1 - src/Airports/GenAirports850/runway.cxx | 76 +++++++++++++------ src/Airports/GenAirports850/runway.hxx | 4 +- src/Airports/GenAirports850/taxiway.cxx | 33 +++++--- src/Airports/GenAirports850/taxiway.hxx | 2 +- 18 files changed, 168 insertions(+), 122 deletions(-) diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index 6b87c6f4..6582a7d7 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -243,7 +243,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src ) // runway lights tglightcontour_list rwy_lights; - bool make_shapefiles = false; char debug_root[32]; sprintf(debug_root, "./airport_dbg/%s/", icao.c_str() ); @@ -305,6 +304,7 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src ) { TG_LOG(SG_GENERAL, SG_DEBUG, "Build Feature Poly " << i + 1 << " of " << features.size() << " : " << features[i]->GetDescription() ); + bool make_shapefiles = false; features[i]->BuildBtg( line_polys, rwy_lights, lf_accum, make_shapefiles ); } @@ -327,7 +327,7 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src ) //slivers.clear(); if ( isDebugRunway(i) ) { - sprintf( shapefile_name, "runway_%d", i ); + sprintf( shapefile_name, "runway_%u", i ); } else { strcpy( shapefile_name, "" ); } @@ -393,7 +393,7 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src ) //slivers.clear(); if ( isDebugPavement(i) ) { - sprintf( shapefile_name, "pvmnt_%d", i ); + sprintf( shapefile_name, "pvmnt_%u", i ); } else { strcpy( shapefile_name, "" ); } @@ -427,7 +427,7 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src ) //slivers.clear(); if ( isDebugTaxiway(i) ) { - sprintf( shapefile_name, "taxiway_%d", i ); + sprintf( shapefile_name, "taxiway_%u", i ); } else { strcpy( shapefile_name, "" ); } @@ -1106,10 +1106,10 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src ) } SGVec3d gbs_center = SGVec3d::fromGeod( b.get_center() ); - double dist_squared, radius_squared = 0; + double radius_squared = 0; for ( unsigned int i = 0; i < wgs84_nodes.size(); ++i ) { - dist_squared = distSqr(gbs_center, wgs84_nodes[i]); + double dist_squared = distSqr(gbs_center, wgs84_nodes[i]); if ( dist_squared > radius_squared ) { radius_squared = dist_squared; } @@ -1258,7 +1258,7 @@ bool Airport::CheckZFightingTriangles( const char* prefix, const char* debug_roo tgContour intContour = intersection.GetContour( m ); if ( (intContour.GetSize() > 2) && (intContour.GetArea() > min_area_thresh) ) { TG_LOG( SG_GENERAL, SG_ALERT, prefix << "Z-FIGHTING between runway poly " << i << " and pavement poly " << k << " contour has " << intContour.GetSize() << " nodes " << " area is " << intContour.GetArea() ); - sprintf( desc, "rwy_%06d_pvmt_%06d", i, j ); + sprintf( desc, "rwy_%06u_pvmt_%06u", i, j ); tgShapefile::FromContour( intContour, debug_root, layer, desc ); zfighting = true; } @@ -1292,7 +1292,7 @@ bool Airport::CheckZFightingTriangles( const char* prefix, const char* debug_roo tgContour intContour = intersection.GetContour( m ); if ( (intContour.GetSize() > 2) && (intContour.GetArea() > min_area_thresh) ) { TG_LOG( SG_GENERAL, SG_ALERT, prefix << "Z-FIGHTING between pavement poly " << i << " and runway poly " << k << " contour has " << intContour.GetSize() << " nodes " << " area is " << intContour.GetArea() ); - sprintf( desc, "pvmt_%06d_rwy_%06d", i, j ); + sprintf( desc, "pvmt_%06u_rwy_%06u", i, j ); tgShapefile::FromContour( intContour, debug_root, layer, desc ); zfighting = true; } @@ -1325,7 +1325,7 @@ bool Airport::CheckZFightingTriangles( const char* prefix, const char* debug_roo tgContour intContour = intersection.GetContour( m ); if ( (intContour.GetSize() > 2) && (intContour.GetArea() > min_area_thresh) ) { TG_LOG( SG_GENERAL, SG_ALERT, prefix << "Z-FIGHTING between base poly and runway poly " << j << " contour has " << intContour.GetSize() << " nodes " << " area is " << intContour.GetArea() ); - sprintf( desc, "base_rwy_%06d", j ); + sprintf( desc, "base_rwy_%06u", j ); tgShapefile::FromContour( intContour, debug_root, layer, desc ); zfighting = true; } @@ -1353,7 +1353,7 @@ bool Airport::CheckZFightingTriangles( const char* prefix, const char* debug_roo tgContour intContour = intersection.GetContour( m ); if ( (intContour.GetSize() > 2) && (intContour.GetArea() > min_area_thresh) ) { TG_LOG( SG_GENERAL, SG_ALERT, prefix << "Z-FIGHTING between base poly and pavement poly " << j << " contour has " << intContour.GetSize() << " nodes " << " area is " << intContour.GetArea() ); - sprintf( desc, "base_pvmt_%06d", j ); + sprintf( desc, "base_pvmt_%06u", j ); tgShapefile::FromContour( intContour, debug_root, layer, desc ); zfighting = true; } diff --git a/src/Airports/GenAirports850/beznode.hxx b/src/Airports/GenAirports850/beznode.hxx index 7fc5524b..26f6d2e7 100644 --- a/src/Airports/GenAirports850/beznode.hxx +++ b/src/Airports/GenAirports850/beznode.hxx @@ -120,7 +120,7 @@ inline double CalculateTheta( const SGVec3d& dirCur, const SGVec3d& dirNext, con class BezNode { public: - BezNode( SGGeod l ) + explicit BezNode( SGGeod l ) { loc = l; diff --git a/src/Airports/GenAirports850/closedpoly.cxx b/src/Airports/GenAirports850/closedpoly.cxx index a0313f02..c3df2504 100644 --- a/src/Airports/GenAirports850/closedpoly.cxx +++ b/src/Airports/GenAirports850/closedpoly.cxx @@ -21,48 +21,33 @@ static void stringPurifier( std::string& s ) } } -ClosedPoly::ClosedPoly( char* desc ) +ClosedPoly::ClosedPoly( char* desc ) : + is_pavement(false), + is_border(false), + has_feature(false), + surface_type(0), + smoothness(0.0), + texture_heading(0.0), + description(std::string(desc ? desc : "none")) { - is_pavement = false; - is_border = true; - has_feature = false; - - if ( desc ) - { - description = desc; - stringPurifier(description); - } - else - { - description = "none"; - } + is_border = true; + + stringPurifier(description); boundary.clear(); cur_contour.clear(); } -ClosedPoly::ClosedPoly( int st, float s, float th, char* desc ) +ClosedPoly::ClosedPoly( int st, float s, float th, char* desc ) : + ClosedPoly( desc ) { surface_type = st; smoothness = s; texture_heading = th; is_pavement = (surface_type != 15) ? true : false; // wrong?? - is_border = false; + is_border = false; has_feature = true; - - if ( desc ) - { - description = desc; - stringPurifier(description); - } - else - { - description = "none"; - } - - boundary.clear(); - cur_contour.clear(); } ClosedPoly::~ClosedPoly() @@ -438,10 +423,10 @@ int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tg int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tgAccumulator& accum, std::string& shapefile_name ) { - char layer[128]; - if ( is_pavement && pre_tess.Contours() ) { + char layer[128]; + if( shapefile_name.size() ) { sprintf( layer, "%s_preclip", shapefile_name.c_str() ); tgShapefile::FromPolygon( pre_tess, "./airport_dbg", layer, std::string("preclip") ); diff --git a/src/Airports/GenAirports850/closedpoly.hxx b/src/Airports/GenAirports850/closedpoly.hxx index a400d57c..f75783bf 100644 --- a/src/Airports/GenAirports850/closedpoly.hxx +++ b/src/Airports/GenAirports850/closedpoly.hxx @@ -11,7 +11,7 @@ class ClosedPoly { public: - ClosedPoly( char* desc ); + explicit ClosedPoly( char* desc ); ClosedPoly( int st, float s, float th, char* desc ); ~ClosedPoly(); diff --git a/src/Airports/GenAirports850/elevations.cxx b/src/Airports/GenAirports850/elevations.cxx index 3e017beb..05a0a9b8 100644 --- a/src/Airports/GenAirports850/elevations.cxx +++ b/src/Airports/GenAirports850/elevations.cxx @@ -37,7 +37,7 @@ // lookup node elevations for each point in the SGGeod list. Returns // average of all points. Doesn't modify the original list. double tgAverageElevation( const std::string &root, const string_list elev_src, - const std::vector points_source ) + const std::vector& points_source ) { bool done = false; unsigned int i; diff --git a/src/Airports/GenAirports850/elevations.hxx b/src/Airports/GenAirports850/elevations.hxx index 1da27119..9851298a 100644 --- a/src/Airports/GenAirports850/elevations.hxx +++ b/src/Airports/GenAirports850/elevations.hxx @@ -25,7 +25,7 @@ // lookup node elevations for each point in the SGGeod list. Returns // average of all points. Doesn't modify the original list. double tgAverageElevation( const std::string &root, const string_list elev_src, - const std::vector points_source ); + const std::vector& points_source ); // lookup node elevations for each point in the specified nurbs++ // matrix. diff --git a/src/Airports/GenAirports850/helipad.cxx b/src/Airports/GenAirports850/helipad.cxx index 6c26c925..dd27495e 100644 --- a/src/Airports/GenAirports850/helipad.cxx +++ b/src/Airports/GenAirports850/helipad.cxx @@ -23,19 +23,26 @@ #include "runway.hxx" #include "debug.hxx" -#include -#include Helipad::Helipad(char* definition) { + // helipad format: + // designator lat lon heading length width surface markings shoulder smoothness edge-lighting + // example: + // "H1 21.30433555 -157.85586778 0.00 10.70 10.70 2 0 0 0.25 0\r" - // format: - // helipad designator lat lon heading length width surface markings shoulder smoothness edge lighting - - // int fscanf(FILE *stream, const char *format, ...); - sscanf(definition, "%s %lf %lf %lf %lf %lf %d %d %d %lf %d", - heli.designator, &heli.lat, &heli.lon, &heli.heading, &heli.length, &heli.width, &heli.surface, - &heli.marking, &heli.shoulder, &heli.smoothness, &heli.edge_lights); + std::istringstream ss(definition); + ss >> heli.designator + >> heli.lat + >> heli.lon + >> heli.heading + >> heli.length + >> heli.width + >> heli.surface + >> heli.marking + >> heli.shoulder + >> heli.smoothness + >> heli.edge_lights; TG_LOG(SG_GENERAL, SG_DEBUG, "Read helipad: (" << heli.lon << "," << heli.lat << ") heading: " << heli.heading << " length: " << heli.length << " width: " << heli.width ); } diff --git a/src/Airports/GenAirports850/helipad.hxx b/src/Airports/GenAirports850/helipad.hxx index 5127f24e..0dc3cc1a 100644 --- a/src/Airports/GenAirports850/helipad.hxx +++ b/src/Airports/GenAirports850/helipad.hxx @@ -25,7 +25,7 @@ class Helipad { public: - Helipad(char* def); + explicit Helipad(char* def); void BuildBtg( tgpolygon_list& heli_polys, tglightcontour_list& heli_lights, diff --git a/src/Airports/GenAirports850/linearfeature.hxx b/src/Airports/GenAirports850/linearfeature.hxx index 1d417ac3..74054be8 100644 --- a/src/Airports/GenAirports850/linearfeature.hxx +++ b/src/Airports/GenAirports850/linearfeature.hxx @@ -72,23 +72,18 @@ typedef std::vector LightingList; class LinearFeature { public: - LinearFeature( char* desc, double o ) + LinearFeature( char* desc, double o ) : + LinearFeature(std::string(desc ? desc : "none"), o) { - if ( desc ) - { - description = desc; - } - else - { - description = "none"; - } - offset = o; } - LinearFeature( std::string desc, double o ) + LinearFeature( const std::string& desc, double o ) : + offset(o), + width(0), + cur_mark(nullptr), + cur_light(nullptr), + description(desc) { - description = desc; - offset = o; } ~LinearFeature(); diff --git a/src/Airports/GenAirports850/linked_objects.cxx b/src/Airports/GenAirports850/linked_objects.cxx index 3eb82729..52c809e6 100644 --- a/src/Airports/GenAirports850/linked_objects.cxx +++ b/src/Airports/GenAirports850/linked_objects.cxx @@ -1,35 +1,50 @@ #include + #include "linked_objects.hxx" #include "debug.hxx" -#include -Windsock::Windsock( char* definition ) +Windsock::Windsock(char* definition) { - sscanf(definition, "%lf %lf %d", &lat, &lon, &lit); + std::istringstream ss(definition); + ss >> lat + >> lon + >> lit; TG_LOG(SG_GENERAL, SG_DEBUG, "Read Windsock: (" << lon << "," << lat << ") lit: " << lit ); } -Beacon::Beacon( char* definition ) +Beacon::Beacon(char* definition) { - sscanf(definition, "%lf %lf %d", &lat, &lon, &code); + std::istringstream ss(definition); + ss >> lat + >> lon + >> code; TG_LOG(SG_GENERAL, SG_DEBUG, "Read Beacon: (" << lon << "," << lat << ") code: " << code ); } -Sign::Sign( char* definition ) +Sign::Sign(char* definition) { char sgdef[256]; double def_heading; - sscanf(definition, "%lf %lf %lf %d %d %s", &lat, &lon, &def_heading, &reserved, &size, sgdef ); + std::istringstream ss(definition); + ss >> lat + >> lon + >> def_heading + >> reserved + >> size + >> sgdef; // 850 format sign heading is the heading which points away from the visible numbers // Flightgear wants the heading to be the heading in which the sign is read heading = -def_heading + 360.0; - TG_LOG(SG_GENERAL, SG_DEBUG, "Read Sign: (" << lon << "," << lat << ") heading " << def_heading << " size " << size << " definition: " << sgdef << " calc view heading: " << heading ); + TG_LOG(SG_GENERAL, SG_DEBUG, "Read Sign: (" << lon << "," << lat << + ") heading " << def_heading << + " size " << size << + " definition: " << sgdef << + " calc view heading: " << heading ); sgn_def = sgdef; } - diff --git a/src/Airports/GenAirports850/linked_objects.hxx b/src/Airports/GenAirports850/linked_objects.hxx index b50f4205..da4b2cf5 100644 --- a/src/Airports/GenAirports850/linked_objects.hxx +++ b/src/Airports/GenAirports850/linked_objects.hxx @@ -8,7 +8,7 @@ class Windsock { public: - Windsock(char* def); + explicit Windsock(char* def); double lat; double lon; @@ -31,7 +31,7 @@ typedef std::vector> WindsockList; class Beacon { public: - Beacon(char* def); + explicit Beacon(char* def); double lat; double lon; @@ -53,7 +53,7 @@ typedef std::vector> BeaconList; class Sign { public: - Sign(char* def); + explicit Sign(char* def); double lat; double lon; diff --git a/src/Airports/GenAirports850/object.cxx b/src/Airports/GenAirports850/object.cxx index 5565a9ee..e830504f 100644 --- a/src/Airports/GenAirports850/object.cxx +++ b/src/Airports/GenAirports850/object.cxx @@ -1,12 +1,18 @@ #include #include + #include "object.hxx" #include "debug.hxx" -#include LightingObj::LightingObj( char* definition ) { - sscanf(definition, "%lf %lf %d %lf %lf %s", &lat, &lon, &type, &heading, &glideslope, &assoc_rw); + std::istringstream ss(definition); + ss >> lat + >> lon + >> type + >> heading + >> glideslope + >> assoc_rw; TG_LOG(SG_GENERAL, SG_DEBUG, "Read lighting object: (" << lon << "," << lat << ") heading: " << heading << " type: " << type ); } diff --git a/src/Airports/GenAirports850/object.hxx b/src/Airports/GenAirports850/object.hxx index d819a574..f97aa530 100644 --- a/src/Airports/GenAirports850/object.hxx +++ b/src/Airports/GenAirports850/object.hxx @@ -9,7 +9,7 @@ class LightingObj { public: - LightingObj(char* def); + explicit LightingObj(char* def); double lat; double lon; diff --git a/src/Airports/GenAirports850/output.cxx b/src/Airports/GenAirports850/output.cxx index f7581e1c..898d1682 100644 --- a/src/Airports/GenAirports850/output.cxx +++ b/src/Airports/GenAirports850/output.cxx @@ -24,7 +24,6 @@ #include #endif -#include #include #include #include diff --git a/src/Airports/GenAirports850/runway.cxx b/src/Airports/GenAirports850/runway.cxx index 55873737..99556f2f 100644 --- a/src/Airports/GenAirports850/runway.cxx +++ b/src/Airports/GenAirports850/runway.cxx @@ -7,8 +7,6 @@ #include -#include - #include "global.hxx" #include "apt_math.hxx" #include "beznode.hxx" @@ -20,43 +18,74 @@ Runway::Runway(char* definition) { double az2; - // format: - // runway width surface shoulder smoothness centerline lights edge lighting distance remaining signs - // 100 46.02 2 1 0.00 1 2 1 + // runway format: + // width surface shoulder smoothness centerline lights edge lighting distance remaining signs + // 46.02 2 1 0.00 1 2 1 // - // runway number runway end lat runway end long threshold overrun markings approach lighting - // 09L 33.63470475 -084.44798671 0.00 120.09 3 7 + // runway number runway end lat runway end long threshold overrun markings approach lighting + // 09L 33.63470475 -084.44798671 0.00 120.09 3 7 // - // touchdown zone lighting runway end identifier lights - // 0 1 + // touchdown zone lighting runway end identifier lights + // 0 1 // - // runway number runway end lat runway end long threshold overrun markings approach lighting - // 27R 33.63469907 -084.40893004 0.00 120.09 3 6 + // runway number runway end lat runway end long threshold overrun markings approach lighting + // 27R 33.63469907 -084.40893004 0.00 120.09 3 6 // - // touchdown zone lighting runway end identifier lights - // 0 1 + // touchdown zone lighting runway end identifier lights + // 0 1 // Parse the line - // 46.02 2 1 0.00 1 2 1 09L 33.63470475 -084.44798671 0.00 120.09 3 7 0 1 27R 33.63469907 -084.40893004 0.00 120.09 3 6 0 1 + // 46.02 2 1 0.00 1 2 1 09L 33.63470475 -084.44798671 0.00 120.09 3 7 0 1 27R 33.63469907 -084.40893004 0.00 120.09 3 6 0 1 - // int fscanf(FILE *stream, const char *format, ...); - sscanf(definition, "%lf %d %d %lf %d %d %d %s %lf %lf %lf %lf %d %d %d %d %s %lf %lf %lf %lf %d %d %d %d", - &rwy.width, &rwy.surface, &rwy.shoulder, &rwy.smoothness, &rwy.centerline_lights, &rwy.edge_lights, &rwy.dist_remain_signs, - rwy.rwnum[0], &rwy.lat[0], &rwy.lon[0], &rwy.threshold[0], &rwy.overrun[0], &rwy.marking[0], &rwy.approach_lights[0], &rwy.tz_lights[0], &rwy.reil[0], - rwy.rwnum[1], &rwy.lat[1], &rwy.lon[1], &rwy.threshold[1], &rwy.overrun[1], &rwy.marking[1], &rwy.approach_lights[1], &rwy.tz_lights[1], &rwy.reil[1] - ); + std::istringstream ss(definition); + ss >> rwy.width + >> rwy.surface + >> rwy.shoulder + >> rwy.smoothness + >> rwy.centerline_lights + >> rwy.edge_lights + >> rwy.dist_remain_signs + >> rwy.rwnum[0] + >> rwy.lat[0] + >> rwy.lon[0] + >> rwy.threshold[0] + >> rwy.overrun[0] + >> rwy.marking[0] + >> rwy.approach_lights[0] + >> rwy.tz_lights[0] + >> rwy.reil[0] + >> rwy.rwnum[1] + >> rwy.lat[1] + >> rwy.lon[1] + >> rwy.threshold[1] + >> rwy.overrun[1] + >> rwy.marking[1] + >> rwy.approach_lights[1] + >> rwy.tz_lights[1] + >> rwy.reil[1]; // calculate runway heading and length (used a lot) SGGeodesy::inverse( GetStart(), GetEnd(), rwy.heading, az2, rwy.length ); - TG_LOG(SG_GENERAL, SG_DEBUG, "Read runway: (" << rwy.lon[0] << "," << rwy.lat[0] << ") to (" << rwy.lon[1] << "," << rwy.lat[1] << ") heading: " << rwy.heading << " length: " << rwy.length << " width: " << rwy.width ); - + TG_LOG(SG_GENERAL, SG_DEBUG, "Read runway: (" << rwy.lon[0] << "," << rwy.lat[0] << + ") to (" << rwy.lon[1] << "," << rwy.lat[1] << + ") heading: " << rwy.heading << + " length: " << rwy.length << + " width: " << rwy.width ); } WaterRunway::WaterRunway(char* definition) { - sscanf(definition, "%lf %d %s %lf %lf %s %lf %lf", &width, &buoys, rwnum[0], &lat[0], &lon[0], rwnum[1], &lat[1], &lon[1]); + std::istringstream ss(definition); + ss >> width + >> buoys + >> rwnum[0] + >> lat[0] + >> lon[0] + >> rwnum[1] + >> lat[1] + >> lon[1]; TG_LOG(SG_GENERAL, SG_DEBUG, "Read water runway: (" << lon[0] << "," << lat[0] << ") to (" << lon[1] << "," << lat[1] << ") width: " << width << " buoys = " << buoys ); } @@ -85,6 +114,7 @@ tgContour WaterRunway::GetBuoys() } } } + return buoys_nodes; } diff --git a/src/Airports/GenAirports850/runway.hxx b/src/Airports/GenAirports850/runway.hxx index b36a7e64..51ebece8 100644 --- a/src/Airports/GenAirports850/runway.hxx +++ b/src/Airports/GenAirports850/runway.hxx @@ -13,7 +13,7 @@ class Runway { public: - Runway(char* def); + explicit Runway(char* def); SGGeod GetStart() { @@ -184,7 +184,7 @@ typedef std::vector > RunwayList; class WaterRunway { public: - WaterRunway(char* def); + explicit WaterRunway(char* def); tgContour GetBuoys(); diff --git a/src/Airports/GenAirports850/taxiway.cxx b/src/Airports/GenAirports850/taxiway.cxx index 10be3956..ec397338 100644 --- a/src/Airports/GenAirports850/taxiway.cxx +++ b/src/Airports/GenAirports850/taxiway.cxx @@ -6,8 +6,6 @@ #include -#include - #include "global.hxx" #include "apt_math.hxx" #include "beznode.hxx" @@ -29,20 +27,31 @@ Taxiway::Taxiway(char* definition) double smoothness; int signs; - // format: - // taxiway lat lon designation heading length threshold overrun - // 10 44.38085600 -074.20606200 xxx 79.29 3384 0.0 0.0 + // taxiway format: + // lat lon designation heading length threshold overrun + // 44.38085600 -074.20606200 xxx 79.29 3384 0.0 0.0 // - // width lighting surface shoulder markings smoothness dist remain - // 60 161161 1 0 0 0.35 0 + // width lighting surface shoulder markings smoothness dist remain + // 60 161161 1 0 0 0.35 0 // Parse the line - // 44.38085600 -074.20606200 xxx 79.29 3384 0.0 0.0 60 161161 1 0 0 0.35 0 + // 44.38085600 -074.20606200 xxx 79.29 3384 0.0 0.0 60 161161 1 0 0 0.35 0 - // int fscanf(FILE *stream, const char *format, ...); - sscanf(definition, "%lf %lf %s %lf %lf %lf %lf %lf %s %d %d %d %lf %d", - &lat, &lon, designation, &heading, &length, &threshold, &overrun, - &width, lighting, &surface, &shoulder, &markings, &smoothness, &signs); + std::istringstream ss(definition); + ss >> lat + >> lon + >> designation + >> heading + >> length + >> threshold + >> overrun + >> width + >> lighting + >> surface + >> shoulder + >> markings + >> smoothness + >> signs; TG_LOG(SG_GENERAL, SG_DEBUG, "Read taxiway: (" << lon << "," << lat << ") heading: " << heading << " length: " << length << " width: " << width ); diff --git a/src/Airports/GenAirports850/taxiway.hxx b/src/Airports/GenAirports850/taxiway.hxx index 3ec00aef..bb439dda 100644 --- a/src/Airports/GenAirports850/taxiway.hxx +++ b/src/Airports/GenAirports850/taxiway.hxx @@ -13,7 +13,7 @@ class Taxiway { public: - Taxiway(char* def); + explicit Taxiway(char* def); int BuildBtg( tgpolygon_list& taxi_polys, tglightcontour_list& taxi_lights,