1
0
Fork 0

FGEagels patch and strict line code checks for all lines covered by the patch

Signed-off-by: Fabian Lucke <fabian.lucke@uniki.de>
This commit is contained in:
Fabian Lucke 2023-09-16 22:32:23 +02:00
parent 43d8d23343
commit d42a5d6d0d
12 changed files with 88 additions and 27 deletions

View file

@ -34,6 +34,11 @@ Helipad::Helipad(char* definition)
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;
if (heli.length <= 0 || heli.width <= 0 || heli.lat < -90 || heli.lat > 90 || heli.lon < -180 || heli.lon > 180 || heli.surface < 1 || heli.surface > 57 || heli.shoulder < 0 || heli.shoulder > 2 || heli.smoothness < 0 || heli.smoothness > 1 || !(heli.edge_lights == 0 || heli.edge_lights == 1)) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid helipad line: " << definition);
}
TG_LOG(SG_GENERAL, SG_DEBUG, "Read helipad: (" << heli.lon << "," << heli.lat << ") heading: " << heli.heading << " length: " << heli.length << " width: " << heli.width);
}

View file

@ -54,12 +54,14 @@ public:
tgcontour_list& slivers,
tgAccumulator& accum);
bool valid {true};
private:
struct TGRunway {
// data for helipad
std::string designator;
double lat;
double lon;
double lat {-9999};
double lon {-9999};
double heading;
double length;
double width;

View file

@ -9,6 +9,11 @@ Windsock::Windsock(char* definition)
std::istringstream ss(definition);
ss >> lat >> lon >> lit;
if (lat < -90 || lat > 90 || lon < -180 || lon > 180) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid windsock line: " << definition);
}
TG_LOG(SG_GENERAL, SG_DEBUG, "Read Windsock: (" << lon << "," << lat << ") lit: " << lit);
}
@ -17,6 +22,11 @@ Beacon::Beacon(char* definition)
std::istringstream ss(definition);
ss >> lat >> lon >> code;
if (lat < -90 || lat > 90 || lon < -180 || lon > 180) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid beacon line: " << definition);
}
TG_LOG(SG_GENERAL, SG_DEBUG, "Read Beacon: (" << lon << "," << lat << ") code: " << code);
}
@ -28,6 +38,11 @@ Sign::Sign(char* definition)
std::istringstream ss(definition);
ss >> lat >> lon >> def_heading >> reserved >> size >> sgdef;
if (lat < -90 || lat > 90 || lon < -180 || lon > 180 || size < 1 || size > 5) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid sign line: " << definition);
}
// 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;

View file

@ -10,9 +10,10 @@ class Windsock
public:
explicit Windsock(char* def);
double lat;
double lon;
double lat {-9999};
double lon {-9999};
int lit;
bool valid {true};
SGGeod GetLoc() const
{
@ -33,9 +34,10 @@ class Beacon
public:
explicit Beacon(char* def);
double lat;
double lon;
double lat {-9999};
double lon {-9999};
int code;
bool valid {true};
SGGeod GetLoc() const
{
@ -55,12 +57,13 @@ class Sign
public:
explicit Sign(char* def);
double lat;
double lon;
double lat {-9999};
double lon {-9999};
double heading;
int reserved;
int size;
std::string sgn_def;
bool valid {true};
SGGeod GetLoc() const
{

View file

@ -10,6 +10,11 @@ LightingObj::LightingObj(char* definition)
std::istringstream ss(definition);
ss >> lat >> lon >> type >> heading >> glideslope >> assoc_rw;
if (lat < -90 || lat > 90 || lon < -180 || lon > 180 || type < 1 || type > 6 || heading < 0 || heading > 360) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid lighting object line: " << definition);
}
TG_LOG(SG_GENERAL, SG_DEBUG, "Read lighting object: (" << lon << "," << lat << ") heading: " << heading << " type: " << type);
}

View file

@ -11,12 +11,13 @@ class LightingObj
public:
explicit LightingObj(char* def);
double lat;
double lon;
double lat {-9999};
double lon {-9999};
int type;
double heading;
double glideslope;
char assoc_rw;
bool valid {true};
void BuildBtg(tglightcontour_list& lights);

View file

@ -492,7 +492,7 @@ int Parser::ParseLine(char* line)
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing runway: " << line);
cur_runway = std::make_shared<Runway>(line);
if (cur_airport) {
if (cur_airport && cur_runway->valid) {
cur_airport->AddRunway(cur_runway);
}
break;
@ -501,7 +501,7 @@ int Parser::ParseLine(char* line)
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing water runway: " << line);
cur_waterRunway = std::make_shared<WaterRunway>(line);
if (cur_airport) {
if (cur_airport && cur_waterRunway->valid) {
cur_airport->AddWaterRunway(cur_waterRunway);
}
break;
@ -509,7 +509,7 @@ int Parser::ParseLine(char* line)
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing helipad: " << line);
cur_helipad = std::make_shared<Helipad>(line);
if (cur_airport) {
if (cur_airport && cur_helipad->valid) {
cur_airport->AddHelipad(cur_helipad);
}
break;
@ -518,7 +518,7 @@ int Parser::ParseLine(char* line)
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway: " << line);
cur_taxiway = std::make_shared<Taxiway>(line);
if (cur_airport) {
if (cur_airport && cur_taxiway->valid) {
cur_airport->AddTaxiway(cur_taxiway);
}
break;
@ -643,25 +643,33 @@ int Parser::ParseLine(char* line)
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing light beacon: " << line);
cur_beacon = std::make_shared<Beacon>(line);
cur_airport->AddBeacon(cur_beacon);
if (cur_airport && cur_beacon->valid) {
cur_airport->AddBeacon(cur_beacon);
}
break;
case WINDSOCK_CODE:
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing windsock: " << line);
cur_windsock = std::make_shared<Windsock>(line);
cur_airport->AddWindsock(cur_windsock);
if (cur_airport && cur_windsock->valid) {
cur_airport->AddWindsock(cur_windsock);
}
break;
case TAXIWAY_SIGN:
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway sign: " << line);
cur_sign = std::make_shared<Sign>(line);
cur_airport->AddSign(cur_sign);
if (cur_airport && cur_sign->valid) {
cur_airport->AddSign(cur_sign);
}
break;
case LIGHTING_OBJECT:
SetState(STATE_PARSE_SIMPLE);
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing lighting object: " << line);
cur_object = std::make_shared<LightingObj>(line);
cur_airport->AddObj(cur_object);
if (cur_airport && cur_object->valid) {
cur_airport->AddObj(cur_object);
}
break;
case COMM_FREQ1_CODE:

View file

@ -65,6 +65,11 @@ Runway::Runway(char* definition)
>> rwy.tz_lights[1]
>> rwy.reil[1];
if (rwy.width == -9999 || rwy.lat[0] < -90 || rwy.lat[0] > 90 || rwy.lon[0] < -180 || rwy.lon[0] > 180 || rwy.lat[1] < -90 || rwy.lat[1] > 90 || rwy.lon[1] < -180 || rwy.lon[1] > 180 || rwy.smoothness > 1 || rwy.smoothness < 0 || !(rwy.centerline_lights == 0 || rwy.centerline_lights == 1) || rwy.edge_lights < 0 || rwy.edge_lights > 3 || !(rwy.dist_remain_signs == 0 || rwy.dist_remain_signs == 1) || rwy.marking[0] < 0 || rwy.marking[0] > 7 || rwy.marking[1] < 0 || rwy.marking[1] > 7 || rwy.approach_lights[0] < 0 || rwy.approach_lights[0] > 12 || rwy.approach_lights[1] < 0 || rwy.approach_lights[1] > 12 || !(rwy.tz_lights[0] == 0 || rwy.tz_lights[0] == 1) || !(rwy.tz_lights[1] == 0 || rwy.tz_lights[1] == 1) || rwy.reil[0] < 0 || rwy.reil[0] > 2 || rwy.reil[1] < 0 || rwy.reil[1] > 2 || rwy.surface < 1 || rwy.surface > 57) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid runway line: " << definition);
}
// calculate runway heading and length (used a lot)
SGGeodesy::inverse(GetStart(), GetEnd(), rwy.heading, az2, rwy.length);
@ -88,6 +93,11 @@ WaterRunway::WaterRunway(char* definition)
>> lat[1]
>> lon[1];
if (width == -9999 || lat[0] < -90 || lat[0] > 90 || lon[0] < -180 || lon[0] > 180 || lat[1] < -90 || lat[1] > 90 || lon[1] < -180 || lon[1] > 180 || !(buoys == 0 || buoys == 1)) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid water runway line: " << definition);
}
TG_LOG(SG_GENERAL, SG_DEBUG, "Read water runway: (" << lon[0] << "," << lat[0] <<
") to (" << lon[1] << "," << lat[1] <<
") width: " << width <<

View file

@ -52,6 +52,8 @@ public:
tgcontour_list& slivers,
tgAccumulator& accum);
bool valid {true};
private:
struct TGRunway {
// data for the whole runway
@ -61,15 +63,15 @@ private:
int edge_lights;
int dist_remain_signs;
double width;
double width {-9999};
double length;
double heading;
double smoothness;
// data for each end
char rwnum[2][16];
double lat[2];
double lon[2];
double lat[2] {-9999, -9999};
double lon[2] {-9999, -9999};
double threshold[2];
double overrun[2];
@ -197,12 +199,14 @@ public:
return SGGeod::fromDeg(lon[1], lat[1]);
}
bool valid {true};
private:
double width;
double width {-9999};
int buoys;
char rwnum[2][16];
double lat[2];
double lon[2];
double lat[2] {-9999, -9999};
double lon[2] {-9999, -9999};
};
typedef std::vector<std::shared_ptr<WaterRunway>> WaterRunwayList;

View file

@ -16,7 +16,7 @@ extern int nudge;
Taxiway::Taxiway(char* definition)
{
// variables for adjusting 810 rwy format to 850 rwy format
double lon = 0, lat = 0;
double lon = -9999, lat = -9999;
// variables to store unused parameters
char designation[16];
@ -50,6 +50,11 @@ Taxiway::Taxiway(char* definition)
smoothness >>
signs;
if (width == -9999 || length == -9999 || lat < -90 || lat > 90 || lon < -180 || lon > 180) {
valid = false;
TG_LOG(SG_GENERAL, SG_ALERT, "Invalid taxiway line: " << definition);
}
TG_LOG(SG_GENERAL, SG_DEBUG, "Read taxiway: (" << lon << "," << lat << ") heading: " << heading << " length: " << length << " width: " << width);
// adjust length and width from feet to meters

View file

@ -28,11 +28,13 @@ public:
tgAccumulator& accum,
std::string& shapefile_name);
bool valid {true};
private:
SGGeod origin;
double heading;
double length;
double width;
double length {-9999};
double width {-9999};
int surface;
char lighting[6];

View file

@ -269,6 +269,7 @@ tgSurface::tgSurface( const std::string& path,
// Build the extra res input grid (shifted SW by half (dlon,dlat)
// with an added major row column on the NE sides.)
int mult = 10;
SG_LOG(SG_GENERAL, SG_ALERT, "creating tgMatrix with nPts x=" << ((xdivs + 1) * mult + 1) << " y=" << ((ydivs + 1) * mult + 1));
tgMatrix dPts( (xdivs + 1) * mult + 1, (ydivs + 1) * mult + 1 );
for ( int j = 0; j < dPts.rows(); ++j ) {
for ( int i = 0; i < dPts.cols(); ++i ) {