FGEagels patch and strict line code checks for all lines covered by the patch
Signed-off-by: merspieler <merspieler@alwaysdata.com>
This commit is contained in:
parent
43d8d23343
commit
31b7d422da
12 changed files with 88 additions and 27 deletions
|
@ -34,6 +34,11 @@ Helipad::Helipad(char* definition)
|
||||||
std::istringstream ss(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;
|
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);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Read helipad: (" << heli.lon << "," << heli.lat << ") heading: " << heli.heading << " length: " << heli.length << " width: " << heli.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,14 @@ public:
|
||||||
tgcontour_list& slivers,
|
tgcontour_list& slivers,
|
||||||
tgAccumulator& accum);
|
tgAccumulator& accum);
|
||||||
|
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TGRunway {
|
struct TGRunway {
|
||||||
// data for helipad
|
// data for helipad
|
||||||
std::string designator;
|
std::string designator;
|
||||||
double lat;
|
double lat {-9999};
|
||||||
double lon;
|
double lon {-9999};
|
||||||
double heading;
|
double heading;
|
||||||
double length;
|
double length;
|
||||||
double width;
|
double width;
|
||||||
|
|
|
@ -9,6 +9,11 @@ Windsock::Windsock(char* definition)
|
||||||
std::istringstream ss(definition);
|
std::istringstream ss(definition);
|
||||||
ss >> lat >> lon >> lit;
|
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);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Read Windsock: (" << lon << "," << lat << ") lit: " << lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +22,11 @@ Beacon::Beacon(char* definition)
|
||||||
std::istringstream ss(definition);
|
std::istringstream ss(definition);
|
||||||
ss >> lat >> lon >> code;
|
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);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Read Beacon: (" << lon << "," << lat << ") code: " << code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +38,11 @@ Sign::Sign(char* definition)
|
||||||
std::istringstream ss(definition);
|
std::istringstream ss(definition);
|
||||||
ss >> lat >> lon >> def_heading >> reserved >> size >> sgdef;
|
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
|
// 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
|
// Flightgear wants the heading to be the heading in which the sign is read
|
||||||
heading = -def_heading + 360.0;
|
heading = -def_heading + 360.0;
|
||||||
|
|
|
@ -10,9 +10,10 @@ class Windsock
|
||||||
public:
|
public:
|
||||||
explicit Windsock(char* def);
|
explicit Windsock(char* def);
|
||||||
|
|
||||||
double lat;
|
double lat {-9999};
|
||||||
double lon;
|
double lon {-9999};
|
||||||
int lit;
|
int lit;
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
SGGeod GetLoc() const
|
SGGeod GetLoc() const
|
||||||
{
|
{
|
||||||
|
@ -33,9 +34,10 @@ class Beacon
|
||||||
public:
|
public:
|
||||||
explicit Beacon(char* def);
|
explicit Beacon(char* def);
|
||||||
|
|
||||||
double lat;
|
double lat {-9999};
|
||||||
double lon;
|
double lon {-9999};
|
||||||
int code;
|
int code;
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
SGGeod GetLoc() const
|
SGGeod GetLoc() const
|
||||||
{
|
{
|
||||||
|
@ -55,12 +57,13 @@ class Sign
|
||||||
public:
|
public:
|
||||||
explicit Sign(char* def);
|
explicit Sign(char* def);
|
||||||
|
|
||||||
double lat;
|
double lat {-9999};
|
||||||
double lon;
|
double lon {-9999};
|
||||||
double heading;
|
double heading;
|
||||||
int reserved;
|
int reserved;
|
||||||
int size;
|
int size;
|
||||||
std::string sgn_def;
|
std::string sgn_def;
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
SGGeod GetLoc() const
|
SGGeod GetLoc() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,11 @@ LightingObj::LightingObj(char* definition)
|
||||||
std::istringstream ss(definition);
|
std::istringstream ss(definition);
|
||||||
ss >> lat >> lon >> type >> heading >> glideslope >> assoc_rw;
|
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);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Read lighting object: (" << lon << "," << lat << ") heading: " << heading << " type: " << type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,13 @@ class LightingObj
|
||||||
public:
|
public:
|
||||||
explicit LightingObj(char* def);
|
explicit LightingObj(char* def);
|
||||||
|
|
||||||
double lat;
|
double lat {-9999};
|
||||||
double lon;
|
double lon {-9999};
|
||||||
int type;
|
int type;
|
||||||
double heading;
|
double heading;
|
||||||
double glideslope;
|
double glideslope;
|
||||||
char assoc_rw;
|
char assoc_rw;
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
|
|
||||||
void BuildBtg(tglightcontour_list& lights);
|
void BuildBtg(tglightcontour_list& lights);
|
||||||
|
|
|
@ -492,7 +492,7 @@ int Parser::ParseLine(char* line)
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing runway: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing runway: " << line);
|
||||||
cur_runway = std::make_shared<Runway>(line);
|
cur_runway = std::make_shared<Runway>(line);
|
||||||
if (cur_airport) {
|
if (cur_airport && cur_runway->valid) {
|
||||||
cur_airport->AddRunway(cur_runway);
|
cur_airport->AddRunway(cur_runway);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -501,7 +501,7 @@ int Parser::ParseLine(char* line)
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing water runway: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing water runway: " << line);
|
||||||
cur_waterRunway = std::make_shared<WaterRunway>(line);
|
cur_waterRunway = std::make_shared<WaterRunway>(line);
|
||||||
if (cur_airport) {
|
if (cur_airport && cur_waterRunway->valid) {
|
||||||
cur_airport->AddWaterRunway(cur_waterRunway);
|
cur_airport->AddWaterRunway(cur_waterRunway);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -509,7 +509,7 @@ int Parser::ParseLine(char* line)
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing helipad: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing helipad: " << line);
|
||||||
cur_helipad = std::make_shared<Helipad>(line);
|
cur_helipad = std::make_shared<Helipad>(line);
|
||||||
if (cur_airport) {
|
if (cur_airport && cur_helipad->valid) {
|
||||||
cur_airport->AddHelipad(cur_helipad);
|
cur_airport->AddHelipad(cur_helipad);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -518,7 +518,7 @@ int Parser::ParseLine(char* line)
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway: " << line);
|
||||||
cur_taxiway = std::make_shared<Taxiway>(line);
|
cur_taxiway = std::make_shared<Taxiway>(line);
|
||||||
if (cur_airport) {
|
if (cur_airport && cur_taxiway->valid) {
|
||||||
cur_airport->AddTaxiway(cur_taxiway);
|
cur_airport->AddTaxiway(cur_taxiway);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -643,25 +643,33 @@ int Parser::ParseLine(char* line)
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing light beacon: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing light beacon: " << line);
|
||||||
cur_beacon = std::make_shared<Beacon>(line);
|
cur_beacon = std::make_shared<Beacon>(line);
|
||||||
|
if (cur_airport && cur_beacon->valid) {
|
||||||
cur_airport->AddBeacon(cur_beacon);
|
cur_airport->AddBeacon(cur_beacon);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WINDSOCK_CODE:
|
case WINDSOCK_CODE:
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing windsock: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing windsock: " << line);
|
||||||
cur_windsock = std::make_shared<Windsock>(line);
|
cur_windsock = std::make_shared<Windsock>(line);
|
||||||
|
if (cur_airport && cur_windsock->valid) {
|
||||||
cur_airport->AddWindsock(cur_windsock);
|
cur_airport->AddWindsock(cur_windsock);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TAXIWAY_SIGN:
|
case TAXIWAY_SIGN:
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway sign: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway sign: " << line);
|
||||||
cur_sign = std::make_shared<Sign>(line);
|
cur_sign = std::make_shared<Sign>(line);
|
||||||
|
if (cur_airport && cur_sign->valid) {
|
||||||
cur_airport->AddSign(cur_sign);
|
cur_airport->AddSign(cur_sign);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LIGHTING_OBJECT:
|
case LIGHTING_OBJECT:
|
||||||
SetState(STATE_PARSE_SIMPLE);
|
SetState(STATE_PARSE_SIMPLE);
|
||||||
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing lighting object: " << line);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing lighting object: " << line);
|
||||||
cur_object = std::make_shared<LightingObj>(line);
|
cur_object = std::make_shared<LightingObj>(line);
|
||||||
|
if (cur_airport && cur_object->valid) {
|
||||||
cur_airport->AddObj(cur_object);
|
cur_airport->AddObj(cur_object);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMM_FREQ1_CODE:
|
case COMM_FREQ1_CODE:
|
||||||
|
|
|
@ -65,6 +65,11 @@ Runway::Runway(char* definition)
|
||||||
>> rwy.tz_lights[1]
|
>> rwy.tz_lights[1]
|
||||||
>> rwy.reil[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)
|
// calculate runway heading and length (used a lot)
|
||||||
SGGeodesy::inverse(GetStart(), GetEnd(), rwy.heading, az2, rwy.length);
|
SGGeodesy::inverse(GetStart(), GetEnd(), rwy.heading, az2, rwy.length);
|
||||||
|
|
||||||
|
@ -88,6 +93,11 @@ WaterRunway::WaterRunway(char* definition)
|
||||||
>> lat[1]
|
>> lat[1]
|
||||||
>> lon[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] <<
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Read water runway: (" << lon[0] << "," << lat[0] <<
|
||||||
") to (" << lon[1] << "," << lat[1] <<
|
") to (" << lon[1] << "," << lat[1] <<
|
||||||
") width: " << width <<
|
") width: " << width <<
|
||||||
|
|
|
@ -52,6 +52,8 @@ public:
|
||||||
tgcontour_list& slivers,
|
tgcontour_list& slivers,
|
||||||
tgAccumulator& accum);
|
tgAccumulator& accum);
|
||||||
|
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TGRunway {
|
struct TGRunway {
|
||||||
// data for the whole runway
|
// data for the whole runway
|
||||||
|
@ -61,15 +63,15 @@ private:
|
||||||
int edge_lights;
|
int edge_lights;
|
||||||
int dist_remain_signs;
|
int dist_remain_signs;
|
||||||
|
|
||||||
double width;
|
double width {-9999};
|
||||||
double length;
|
double length;
|
||||||
double heading;
|
double heading;
|
||||||
double smoothness;
|
double smoothness;
|
||||||
|
|
||||||
// data for each end
|
// data for each end
|
||||||
char rwnum[2][16];
|
char rwnum[2][16];
|
||||||
double lat[2];
|
double lat[2] {-9999, -9999};
|
||||||
double lon[2];
|
double lon[2] {-9999, -9999};
|
||||||
double threshold[2];
|
double threshold[2];
|
||||||
double overrun[2];
|
double overrun[2];
|
||||||
|
|
||||||
|
@ -197,12 +199,14 @@ public:
|
||||||
return SGGeod::fromDeg(lon[1], lat[1]);
|
return SGGeod::fromDeg(lon[1], lat[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double width;
|
double width {-9999};
|
||||||
int buoys;
|
int buoys;
|
||||||
char rwnum[2][16];
|
char rwnum[2][16];
|
||||||
double lat[2];
|
double lat[2] {-9999, -9999};
|
||||||
double lon[2];
|
double lon[2] {-9999, -9999};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<std::shared_ptr<WaterRunway>> WaterRunwayList;
|
typedef std::vector<std::shared_ptr<WaterRunway>> WaterRunwayList;
|
||||||
|
|
|
@ -16,7 +16,7 @@ extern int nudge;
|
||||||
Taxiway::Taxiway(char* definition)
|
Taxiway::Taxiway(char* definition)
|
||||||
{
|
{
|
||||||
// variables for adjusting 810 rwy format to 850 rwy format
|
// 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
|
// variables to store unused parameters
|
||||||
char designation[16];
|
char designation[16];
|
||||||
|
@ -50,6 +50,11 @@ Taxiway::Taxiway(char* definition)
|
||||||
smoothness >>
|
smoothness >>
|
||||||
signs;
|
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);
|
TG_LOG(SG_GENERAL, SG_DEBUG, "Read taxiway: (" << lon << "," << lat << ") heading: " << heading << " length: " << length << " width: " << width);
|
||||||
|
|
||||||
// adjust length and width from feet to meters
|
// adjust length and width from feet to meters
|
||||||
|
|
|
@ -28,11 +28,13 @@ public:
|
||||||
tgAccumulator& accum,
|
tgAccumulator& accum,
|
||||||
std::string& shapefile_name);
|
std::string& shapefile_name);
|
||||||
|
|
||||||
|
bool valid {true};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SGGeod origin;
|
SGGeod origin;
|
||||||
double heading;
|
double heading;
|
||||||
double length;
|
double length {-9999};
|
||||||
double width;
|
double width {-9999};
|
||||||
int surface;
|
int surface;
|
||||||
char lighting[6];
|
char lighting[6];
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,7 @@ tgSurface::tgSurface( const std::string& path,
|
||||||
// Build the extra res input grid (shifted SW by half (dlon,dlat)
|
// Build the extra res input grid (shifted SW by half (dlon,dlat)
|
||||||
// with an added major row column on the NE sides.)
|
// with an added major row column on the NE sides.)
|
||||||
int mult = 10;
|
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 );
|
tgMatrix dPts( (xdivs + 1) * mult + 1, (ydivs + 1) * mult + 1 );
|
||||||
for ( int j = 0; j < dPts.rows(); ++j ) {
|
for ( int j = 0; j < dPts.rows(); ++j ) {
|
||||||
for ( int i = 0; i < dPts.cols(); ++i ) {
|
for ( int i = 0; i < dPts.cols(); ++i ) {
|
||||||
|
|
Loading…
Reference in a new issue