From c04eab31019d802bba09d8fd609fc79f7664ec9e Mon Sep 17 00:00:00 2001 From: scttgs0 Date: Sun, 14 May 2023 12:04:42 -0500 Subject: [PATCH] [linearfeature] Maintenance --- src/Airports/GenAirports/linearfeature.cxx | 1131 +++++++++----------- src/Airports/GenAirports/linearfeature.hxx | 14 +- 2 files changed, 531 insertions(+), 614 deletions(-) diff --git a/src/Airports/GenAirports/linearfeature.cxx b/src/Airports/GenAirports/linearfeature.cxx index 41d0f67b..04141452 100644 --- a/src/Airports/GenAirports/linearfeature.cxx +++ b/src/Airports/GenAirports/linearfeature.cxx @@ -1,26 +1,25 @@ -#include - -#include "global.hxx" -#include "beznode.hxx" #include "linearfeature.hxx" +#include "beznode.hxx" +#include "global.hxx" -void LinearFeature::ConvertContour( const BezContour& src, bool closed ) + +void LinearFeature::ConvertContour(const BezContour& src, bool closed) { - std::shared_ptr curNode; - std::shared_ptr nextNode; + std::shared_ptr curNode; + std::shared_ptr nextNode; - SGGeod curLoc; - SGGeod nextLoc; - SGGeod cp1; - SGGeod cp2; + SGGeod curLoc; + SGGeod nextLoc; + SGGeod cp1; + SGGeod cp2; - int curve_type; - double total_dist; - double theta1, theta2; - int num_segs; + int curve_type; + double total_dist; + double theta1, theta2; + int num_segs; - Marking* cur_mark = NULL; - Lighting* cur_light = NULL; + std::shared_ptr cur_mark = nullptr; + std::shared_ptr cur_light = nullptr; TG_LOG(SG_GENERAL, SG_DEBUG, " LinearFeature::ConvertContour - Creating a contour with " << src.size() << " nodes"); @@ -28,16 +27,12 @@ void LinearFeature::ConvertContour( const BezContour& src, bool closed ) points.Erase(); // iterate through each bezier node in the contour - for (unsigned int i = 0; i < src.size(); ++i) - { + for (unsigned int i = 0; i < src.size(); ++i) { curNode = src.at(i); - if (i < src.size() - 1) - { + if (i < src.size() - 1) { nextNode = src.at(i + 1); - } - else - { + } else { // for the last node, next is the first node, as all contours are closed nextNode = src.at(0); } @@ -46,32 +41,31 @@ void LinearFeature::ConvertContour( const BezContour& src, bool closed ) // remember the index for the starting stopping of marks on the converted contour // are we watching a mark for the end? - if (cur_mark) - { - if (curNode->GetMarking() != cur_mark->type) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking has changed from " << cur_mark->type << " to " << curNode->GetMarking() << " save mark from " << cur_mark->start_idx << " to " << points.GetSize() ); + if (cur_mark) { + if (curNode->GetMarking() != cur_mark->type) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking has changed from " << cur_mark->type << + " to " << curNode->GetMarking() << + " save mark from " << cur_mark->start_idx << + " to " << points.GetSize()); // marking has ended, or changed cur_mark->end_idx = points.GetSize(); marks.push_back(cur_mark); - cur_mark = NULL; - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Continue Marking from " << cur_mark->start_idx << " with type " << cur_mark->type ); + cur_mark = nullptr; + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Continue Marking from " << cur_mark->start_idx << + " with type " << cur_mark->type); } } // should we start a new mark? - if (cur_mark == NULL) - { - if (curNode->GetMarking()) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Marking from " << points.GetSize() << " with type " << curNode->GetMarking() ); + if (cur_mark == nullptr) { + if (curNode->GetMarking()) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Marking from " << points.GetSize() << + " with type " << curNode->GetMarking()); // we aren't watching a mark, and this node has one - cur_mark = new Marking; + cur_mark = std::make_shared(); cur_mark->type = curNode->GetMarking(); cur_mark->start_idx = points.GetSize(); } @@ -83,632 +77,576 @@ void LinearFeature::ConvertContour( const BezContour& src, bool closed ) // remember the index for the starting stopping of lights on the converted contour // are we watching a mark for the end? - if (cur_light) - { - if (curNode->GetLighting() != cur_light->type) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting has changed from " << cur_light->type << " to " << curNode->GetLighting() << " save light from " << cur_light->start_idx << " to " << points.GetSize() ); + if (cur_light) { + if (curNode->GetLighting() != cur_light->type) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting has changed from " << cur_light->type << + " to " << curNode->GetLighting() << + " save light from " << cur_light->start_idx << + " to " << points.GetSize()); // lighting has ended, or changed : add final light cur_light->end_idx = points.GetSize(); lights.push_back(cur_light); - cur_light = NULL; - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Continue Lighting from " << cur_light->start_idx << " with type " << cur_light->type ); + cur_light = nullptr; + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Continue Lighting from " << cur_light->start_idx << + " with type " << cur_light->type); } } // should we start a new light? - if (cur_light == NULL) - { - if (curNode->GetLighting()) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Lighting from " << points.GetSize() << " with type " << curNode->GetLighting() ); + if (cur_light == nullptr) { + if (curNode->GetLighting()) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Lighting from " << points.GetSize() << + " with type " << curNode->GetLighting()); // we aren't watching a mark, and this node has one - cur_light = new Lighting; + cur_light = std::make_shared(); cur_light->type = curNode->GetLighting(); cur_light->start_idx = points.GetSize(); } } + //////////////////////////////////////////////////////////////////////////////////// // now determine how we will iterate from current node to next node - if( curNode->HasNextCp() ) - { + if (curNode->HasNextCp()) { // next curve is cubic or quadratic - if( nextNode->HasPrevCp() ) - { + if (nextNode->HasPrevCp()) { // curve is cubic : need both control points curve_type = CURVE_CUBIC; cp1 = curNode->GetNextCp(); cp2 = nextNode->GetPrevCp(); - total_dist = CubicDistance( curNode->GetLoc(), cp1, cp2, nextNode->GetLoc() ); - theta1 = SGMiscd::rad2deg( CalculateTheta( curNode->GetLoc(), cp1, nextNode->GetLoc()) ); - theta2 = SGMiscd::rad2deg( CalculateTheta( curNode->GetLoc(), cp2, nextNode->GetLoc()) ); - } - else - { + total_dist = CubicDistance(curNode->GetLoc(), cp1, cp2, nextNode->GetLoc()); + theta1 = SGMiscd::rad2deg(CalculateTheta(curNode->GetLoc(), cp1, nextNode->GetLoc())); + theta2 = SGMiscd::rad2deg(CalculateTheta(curNode->GetLoc(), cp2, nextNode->GetLoc())); + } else { // curve is quadratic using current nodes cp as the cp curve_type = CURVE_QUADRATIC; cp1 = curNode->GetNextCp(); - total_dist = QuadraticDistance( curNode->GetLoc(), cp1, nextNode->GetLoc() ); - theta1 = SGMiscd::rad2deg( CalculateTheta( curNode->GetLoc(), cp1, nextNode->GetLoc()) ); + total_dist = QuadraticDistance(curNode->GetLoc(), cp1, nextNode->GetLoc()); + theta1 = SGMiscd::rad2deg(CalculateTheta(curNode->GetLoc(), cp1, nextNode->GetLoc())); } - } - else - { + } else { // next curve is quadratic or linear - if( nextNode->HasPrevCp() ) - { + if (nextNode->HasPrevCp()) { // curve is quadratic using next nodes cp as the cp curve_type = CURVE_QUADRATIC; cp1 = nextNode->GetPrevCp(); - total_dist = QuadraticDistance( curNode->GetLoc(), cp1, nextNode->GetLoc() ); - theta1 = SGMiscd::rad2deg( CalculateTheta( curNode->GetLoc(), cp1, nextNode->GetLoc()) ); - } - else - { + total_dist = QuadraticDistance(curNode->GetLoc(), cp1, nextNode->GetLoc()); + theta1 = SGMiscd::rad2deg(CalculateTheta(curNode->GetLoc(), cp1, nextNode->GetLoc())); + } else { // curve is linear curve_type = CURVE_LINEAR; - total_dist = LinearDistance( curNode->GetLoc(), nextNode->GetLoc() ); + total_dist = LinearDistance(curNode->GetLoc(), nextNode->GetLoc()); } } // One more test - some people are using bezier curves to draw straight lines - this can cause a bit of havoc... // Sometimes, the control point lies just beyond the final point. We try to make a 'hook' at the end, which makes some really bad polys // Just convert the entire segment to linear - // this can be detected in quadratic curves (current issue in LFKJ) when the contol point lies within the line generated from point 1 to point 2 - // at close to 180 at the control point to the cur node and next node - if ( curve_type == CURVE_QUADRATIC ) - { - if ( (std::abs(theta1 - 180.0) < 5.0 ) || (std::abs(theta1) < 5.0 ) || (std::isnan(theta1)) ) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Quadtratic curve with cp in line : convert to linear: " << description << ": theta is " << theta1 ); + // this can be detected in quadratic curves (current issue in LFKJ) when the control point lies within the line generated from point 1 to + // point 2 at close to 180 at the control point to the cur node and next node + if (curve_type == CURVE_QUADRATIC) { + if ((std::abs(theta1 - 180.0) < 5.0) || (std::abs(theta1) < 5.0) || (std::isnan(theta1))) { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Quadratic curve with cp in line : convert to linear: " << + description << ": theta is " << theta1); curve_type = CURVE_LINEAR; - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Quadtratic curve withOUT cp in line : keep quadtratic: " << description << ": theta is " << theta1 ); + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Quadratic curve withOUT cp in line : keep quadratic: " << + description << ": theta is " << theta1); } } - if ( curve_type == CURVE_CUBIC ) - { - if ( (std::abs(theta1 - 180.0) < 5.0 ) || (std::abs(theta1) < 5.0 ) || (std::isnan(theta1)) ) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Cubic curve with cp1 in line : " << description << ": theta is " << theta1 ); + if (curve_type == CURVE_CUBIC) { + if ((std::abs(theta1 - 180.0) < 5.0) || (std::abs(theta1) < 5.0) || (std::isnan(theta1))) { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Cubic curve with cp1 in line : " << + description << ": theta is " << theta1); - if ( (std::abs(theta2 - 180.0) < 5.0 ) || (std::abs(theta2) < 5.0 ) || (std::isnan(theta2)) ) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\n and cp2 in line : " << description << ": theta is " << theta2 << " CONVERTING TO LINEAR" ); + if ((std::abs(theta2 - 180.0) < 5.0) || (std::abs(theta2) < 5.0) || (std::isnan(theta2))) { + TG_LOG(SG_GENERAL, SG_DEBUG, "\n and cp2 in line : " << + description << ": theta is " << theta2 << " CONVERTING TO LINEAR"); curve_type = CURVE_LINEAR; + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "\n BUT cp2 NOT in line : " << + description << ": theta is " << theta2); } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\n BUT cp2 NOT in line : " << description << ": theta is " << theta2 ); - } - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Cubic curve withOUT cp1 in line : keep quadtratic: " << description << ": theta is " << theta1 ); + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature: Cubic curve withOUT cp1 in line : keep quadratic: " << + description << ": theta is " << theta1); - if ( (std::abs(theta2 - 180.0) < 5.0 ) || (std::abs(theta2) < 5.0 ) || (std::isnan(theta2)) ) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\n BUT cp2 IS in line : " << description << ": theta is " << theta2 ); - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\n AND cp2 NOT in line : " << description << ": theta is " << theta2 ); + if ((std::abs(theta2 - 180.0) < 5.0) || (std::abs(theta2) < 5.0) || (std::isnan(theta2))) { + TG_LOG(SG_GENERAL, SG_DEBUG, "\n BUT cp2 IS in line : " << + description << ": theta is " << theta2); + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "\n AND cp2 NOT in line : " << + description << ": theta is " << theta2); } } } - if (total_dist < 4.0f) - { - if (curve_type != CURVE_LINEAR) - { + if (total_dist < 4.0f) { + if (curve_type != CURVE_LINEAR) { // If total distance is < 4 meters, then we need to modify num Segments so that each segment >= 1/2 meter num_segs = ((int)total_dist + 1) * 2; - TG_LOG(SG_GENERAL, SG_DEBUG, "Segment from " << curNode->GetLoc() << " to " << nextNode->GetLoc() ); - TG_LOG(SG_GENERAL, SG_DEBUG, " Distance is " << total_dist << " ( < 4.0) so num_segs is " << num_segs ); - } - else - { + TG_LOG(SG_GENERAL, SG_DEBUG, "Segment from " << curNode->GetLoc() << " to " << nextNode->GetLoc()); + TG_LOG(SG_GENERAL, SG_DEBUG, " Distance is " << total_dist << " ( < 4.0) so num_segs is " << num_segs); + } else { num_segs = 1; } - } - else if (total_dist > 800.0f) - { + } else if (total_dist > 800.0f) { // If total distance is > 800 meters, then we need to modify num Segments so that each segment <= 100 meters num_segs = total_dist / 100.0f + 1; - TG_LOG(SG_GENERAL, SG_DEBUG, "Segment from " << curNode->GetLoc() << " to " << nextNode->GetLoc() ); - TG_LOG(SG_GENERAL, SG_DEBUG, " Distance is " << total_dist << " ( > 100.0) so num_segs is " << num_segs ); - } - else - { - if (curve_type != CURVE_LINEAR) - { + TG_LOG(SG_GENERAL, SG_DEBUG, "Segment from " << curNode->GetLoc() << " to " << nextNode->GetLoc()); + TG_LOG(SG_GENERAL, SG_DEBUG, " Distance is " << total_dist << " ( > 100.0) so num_segs is " << num_segs); + } else { + if (curve_type != CURVE_LINEAR) { num_segs = 8; - TG_LOG(SG_GENERAL, SG_DEBUG, "Segment from " << curNode->GetLoc() << " to " << nextNode->GetLoc() ); - TG_LOG(SG_GENERAL, SG_DEBUG, " Distance is " << total_dist << " (OK) so num_segs is " << num_segs ); - } - else - { + TG_LOG(SG_GENERAL, SG_DEBUG, "Segment from " << curNode->GetLoc() << " to " << nextNode->GetLoc()); + TG_LOG(SG_GENERAL, SG_DEBUG, " Distance is " << total_dist << " (OK) so num_segs is " << num_segs); + } else { num_segs = 1; } } // if only one segment, revert to linear - if (num_segs == 1) - { + if (num_segs == 1) { curve_type = CURVE_LINEAR; } // initialize current location curLoc = curNode->GetLoc(); - if (curve_type != CURVE_LINEAR) - { - for (int p=0; pGetLoc(), cp1, nextNode->GetLoc(), (1.0f/num_segs) * (p+1) ); - } - else - { - nextLoc = CalculateCubicLocation( curNode->GetLoc(), cp1, cp2, nextNode->GetLoc(), (1.0f/num_segs) * (p+1) ); + if (curve_type == CURVE_QUADRATIC) { + nextLoc = CalculateQuadraticLocation(curNode->GetLoc(), cp1, nextNode->GetLoc(), (1.0f / num_segs) * (p + 1)); + } else { + nextLoc = CalculateCubicLocation(curNode->GetLoc(), cp1, cp2, nextNode->GetLoc(), (1.0f / num_segs) * (p + 1)); } // add the feature vertex points.AddNode(curLoc); - if (p==0) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "adding Curve Anchor node (type " << curve_type << ") at " << curLoc ); - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, " add bezier node (type " << curve_type << ") at " << curLoc ); + if (p == 0) { + TG_LOG(SG_GENERAL, SG_DEBUG, "adding Curve Anchor node (type " << curve_type << ") at " << curLoc); + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, " add bezier node (type " << curve_type << ") at " << curLoc); } // now set set prev and cur locations for the next iteration curLoc = nextLoc; } - } - else - { + } else { // calculate linear distance to determine how many segments we want - if (num_segs > 1) - { - for (int p=0; p 1) { + for (int p = 0; p < num_segs; p++) { // calculate next location - nextLoc = CalculateLinearLocation( curNode->GetLoc(), nextNode->GetLoc(), (1.0f/num_segs) * (p+1) ); + nextLoc = CalculateLinearLocation(curNode->GetLoc(), nextNode->GetLoc(), (1.0f / num_segs) * (p + 1)); // add the feature vertex points.AddNode(curLoc); - if (p==0) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "adding Linear anchor node at " << curLoc ); - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, " add linear node at " << curLoc ); + if (p == 0) { + TG_LOG(SG_GENERAL, SG_DEBUG, "adding Linear anchor node at " << curLoc); + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, " add linear node at " << curLoc); } // now set set prev and cur locations for the next iteration curLoc = nextLoc; } - } - else - { + } else { nextLoc = nextNode->GetLoc(); // just add the one vertex - dist is small points.AddNode(curLoc); - TG_LOG(SG_GENERAL, SG_DEBUG, "adding Linear Anchor node at " << curLoc ); + TG_LOG(SG_GENERAL, SG_DEBUG, "adding Linear Anchor node at " << curLoc); curLoc = nextLoc; } } } - if (closed) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "Closed COntour : adding last node at " << curLoc ); + if (closed) { + TG_LOG(SG_GENERAL, SG_DEBUG, "Closed COntour : adding last node at " << curLoc); // need to add the markings for last segment points.AddNode(curLoc); } // check for marking that goes all the way to the end... - if (cur_mark) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking from " << cur_mark->start_idx << " with type " << cur_mark->type << " ends at the end of the contour: " << points.GetSize() ); + if (cur_mark) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking from " << cur_mark->start_idx << + " with type " << cur_mark->type << + " ends at the end of the contour: " << points.GetSize()); - cur_mark->end_idx = points.GetSize()-1; - marks.push_back(cur_mark); - cur_mark = NULL; + cur_mark->end_idx = points.GetSize() - 1; + marks.push_back(cur_mark); + cur_mark = nullptr; } // check for lighting that goes all the way to the end... - if (cur_light) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting from " << cur_light->start_idx << " with type " << cur_light->type << " ends at the end of the contour: " << points.GetSize() ); + if (cur_light) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting from " << cur_light->start_idx << + " with type " << cur_light->type << + " ends at the end of the contour: " << points.GetSize()); - cur_light->end_idx = points.GetSize()-1; - lights.push_back(cur_light); - cur_light = NULL; + cur_light->end_idx = points.GetSize() - 1; + lights.push_back(cur_light); + cur_light = nullptr; } } LinearFeature::~LinearFeature() { - for (unsigned int i=0; itype ) - { - case LF_NONE: - break; + switch (marks[i]->type) { + case LF_NONE: + break; - case LF_SOLID_RED: - material = "lf_sng_solid_red"; - width = 0.25f; - break; - - case LF_BROKEN_RED: - material = "lf_sng_broken_red"; - width = 0.25f; - break; - - case LF_SOLID_RED_WIDE: - material = "lf_sng_solid_red"; - width = 0.5f; - break; + case LF_SOLID_RED: + material = "lf_sng_solid_red"s; + width = 0.25f; + break; - case LF_SOLID_ORANGE: - material = "lf_sng_solid_orange"; - width = 0.25f; - break; + case LF_BROKEN_RED: + material = "lf_sng_broken_red"s; + width = 0.25f; + break; - case LF_SOLID_BLUE: - material = "lf_sng_solid_blue"; - width = 0.25f; - break; + case LF_SOLID_RED_WIDE: + material = "lf_sng_solid_red"s; + width = 0.5f; + break; - case LF_SOLID_GREEN: - material = "lf_sng_solid_green"; - width = 0.25f; - break; + case LF_SOLID_ORANGE: + material = "lf_sng_solid_orange"s; + width = 0.25f; + break; - case LF_SOLID_YELLOW: - material = "lf_sng_solid_yellow"; - width = 0.25f; - break; + case LF_SOLID_BLUE: + material = "lf_sng_solid_blue"s; + width = 0.25f; + break; - case LF_SOLID_YELLOW_WIDE: - material = "lf_sng_solid_yellow"; - width = 0.5f; - break; + case LF_SOLID_GREEN: + material = "lf_sng_solid_green"s; + width = 0.25f; + break; - case LF_SOLID_YELLOW_HATCH: - material = "lf_sng_solid_yellow"; - width = 1.0f; - break; + case LF_SOLID_YELLOW: + material = "lf_sng_solid_yellow"s; + width = 0.25f; + break; - case LF_BROKEN_YELLOW: - material = "lf_sng_broken_yellow"; - width = 0.25f; - break; + case LF_SOLID_YELLOW_WIDE: + material = "lf_sng_solid_yellow"s; + width = 0.5f; + break; - case LF_SOLID_DBL_YELLOW: - material = "lf_dbl_solid_yellow"; - width = 0.5f; - break; + case LF_SOLID_YELLOW_HATCH: + material = "lf_sng_solid_yellow"s; + width = 1.0f; + break; - case LF_RUNWAY_HOLD: - material = "lf_runway_hold"; - width = 1.0f; - break; + case LF_BROKEN_YELLOW: + material = "lf_sng_broken_yellow"s; + width = 0.25f; + break; - case LF_DOUBLE_HOLD_WIDE: - material = "lf_runway_hold"; - width = 2.0f; - break; + case LF_SOLID_DBL_YELLOW: + material = "lf_dbl_solid_yellow"s; + width = 0.5f; + break; - case LF_OTHER_HOLD: - material = "lf_other_hold"; - width = 0.5f; - break; + case LF_RUNWAY_HOLD: + material = "lf_runway_hold"s; + width = 1.0f; + break; - case LF_OTHER_HOLD_WIDE: - material = "lf_other_hold"; - width = 1.0f; - break; + case LF_DOUBLE_HOLD_WIDE: + material = "lf_runway_hold"s; + width = 2.0f; + break; - case LF_ILS_HOLD: - material = "lf_ils_hold"; - width = 1.0f; - break; + case LF_OTHER_HOLD: + material = "lf_other_hold"s; + width = 0.5f; + break; - case LF_ILS_HOLD_WIDE: - material = "lf_ils_hold"; - width = 2.0f; - break; + case LF_OTHER_HOLD_WIDE: + material = "lf_other_hold"s; + width = 1.0f; + break; - case LF_SAFETYZONE_CENTERLINE: - material = "lf_safetyzone_centerline"; - width = 0.75f; - break; + case LF_ILS_HOLD: + material = "lf_ils_hold"s; + width = 1.0f; + break; - case LF_TAXI_HOLD_WIDE: - material = "lf_safetyzone_centerline"; - width = 1.5f; - break; + case LF_ILS_HOLD_WIDE: + material = "lf_ils_hold"s; + width = 2.0f; + break; - case LF_SINGLE_LANE_QUEUE: - material = "lf_sng_lane_queue"; - width = 0.25f; - break; + case LF_SAFETYZONE_CENTERLINE: + material = "lf_safetyzone_centerline"s; + width = 0.75f; + break; - case LF_DOUBLE_LANE_QUEUE: - material = "lf_dbl_lane_queue"; - width = 0.5f; - break; + case LF_TAXI_HOLD_WIDE: + material = "lf_safetyzone_centerline"s; + width = 1.5f; + break; - case LF_B_SOLID_YELLOW: - material = "lf_sng_solid_yellow_border"; - width = 0.25f; - break; + case LF_SINGLE_LANE_QUEUE: + material = "lf_sng_lane_queue"s; + width = 0.25f; + break; - case LF_B_SOLID_YELLOW_WIDE: - material = "lf_sng_solid_yellow_border"; - width = 0.5f; - break; + case LF_DOUBLE_LANE_QUEUE: + material = "lf_dbl_lane_queue"s; + width = 0.5f; + break; - case LF_B_BROKEN_YELLOW: - material = "lf_sng_broken_yellow_border"; - width = 0.25f; - break; + case LF_B_SOLID_YELLOW: + material = "lf_sng_solid_yellow_border"s; + width = 0.25f; + break; - case LF_B_SOLID_DBL_YELLOW: - material = "lf_dbl_solid_yellow_border"; - width = 0.5f; - break; + case LF_B_SOLID_YELLOW_WIDE: + material = "lf_sng_solid_yellow_border"s; + width = 0.5f; + break; - case LF_B_RUNWAY_HOLD: - material = "lf_runway_hold_border"; - width = 1.0f; - break; + case LF_B_BROKEN_YELLOW: + material = "lf_sng_broken_yellow_border"s; + width = 0.25f; + break; - case LF_B_RUNWAY_HOLD_WIDE: - material = "lf_runway_hold_border"; - width = 2.0f; - break; + case LF_B_SOLID_DBL_YELLOW: + material = "lf_dbl_solid_yellow_border"s; + width = 0.5f; + break; - case LF_B_OTHER_HOLD: - material = "lf_other_hold_border"; - width = 0.5f; - break; + case LF_B_RUNWAY_HOLD: + material = "lf_runway_hold_border"s; + width = 1.0f; + break; - case LF_B_OTHER_HOLD_WIDE: - material = "lf_other_hold_border"; - width = 1.0f; - break; + case LF_B_RUNWAY_HOLD_WIDE: + material = "lf_runway_hold_border"s; + width = 2.0f; + break; - case LF_B_ILS_HOLD: - material = "lf_ils_hold_border"; - width = 1.0f; - break; + case LF_B_OTHER_HOLD: + material = "lf_other_hold_border"s; + width = 0.5f; + break; - case LF_B_ILS_HOLD_WIDE: - material = "lf_ils_hold_border"; - width = 2.0f; - break; + case LF_B_OTHER_HOLD_WIDE: + material = "lf_other_hold_border"s; + width = 1.0f; + break; - case LF_B_SAFETYZONE_CENTERLINE: - material = "lf_safetyzone_centerline_border"; - width = 0.75f; - break; + case LF_B_ILS_HOLD: + material = "lf_ils_hold_border"s; + width = 1.0f; + break; - case LF_B_TAXI_HOLD_WIDE: - material = "lf_safetyzone_centerline_border"; - width = 1.5f; - break; + case LF_B_ILS_HOLD_WIDE: + material = "lf_ils_hold_border"s; + width = 2.0f; + break; - case LF_B_SINGLE_LANE_QUEUE: - material = "lf_sng_lane_queue_border"; - width = 0.25f; - break; + case LF_B_SAFETYZONE_CENTERLINE: + material = "lf_safetyzone_centerline_border"s; + width = 0.75f; + break; - case LF_B_DOUBLE_LANE_QUEUE: - material = "lf_dbl_lane_queue_border"; - width = 0.5f; - break; + case LF_B_TAXI_HOLD_WIDE: + material = "lf_safetyzone_centerline_border"s; + width = 1.5f; + break; - case LF_SOLID_WHITE: - material = "lf_sng_solid_white"; - width = 0.25f; - break; + case LF_B_SINGLE_LANE_QUEUE: + material = "lf_sng_lane_queue_border"s; + width = 0.25f; + break; - case LF_SOLID_ROAD_WIDE: - material = "lf_sng_solid_white"; - width = 0.5f; - break; + case LF_B_DOUBLE_LANE_QUEUE: + material = "lf_dbl_lane_queue_border"s; + width = 0.5f; + break; - case LF_CHECKERBOARD_WHITE: - material = "lf_checkerboard_white"; - width = 0.5f; - break; + case LF_SOLID_WHITE: + material = "lf_sng_solid_white"s; + width = 0.25f; + break; - case LF_BROKEN_WHITE: - material = "lf_broken_white"; - width = 0.25f; - break; + case LF_SOLID_ROAD_WIDE: + material = "lf_sng_solid_white"s; + width = 0.5f; + break; - case LF_BROKEN_ROAD: - material = "lf_broken_white"; - width = 0.25f; - break; + case LF_CHECKERBOARD_WHITE: + material = "lf_checkerboard_white"s; + width = 0.5f; + break; - case LF_BROKEN_ROAD_WIDE: - material = "lf_broken_white"; - width = 0.5f; - break; + case LF_BROKEN_WHITE: + material = "lf_broken_white"s; + width = 0.25f; + break; - case LF_B_ROAD_EDGE_SOLID: - material = "lf_solid_white_border"; - width = 0.25f; - break; - - case LF_B_ROAD_EDGE_ZIPPER: - material = "lf_broken_white_border"; //TODO - width = 0.5f; - break; - - case LF_B_ROAD_EDGE_DASH: - material = "lf_broken_white_border"; - width = 0.25f; - break; - - case LF_B_ROAD_DASH: - material = "lf_broken_white_border"; - width = 0.25f; - break; - - case LF_B_ROAD_DASH_WIDE: - material = "lf_broken_white_border"; - width = 0.5f; - break; - - case LF_B_ROAD_EDGE_WIDE: - material = "lf_solid_white_border"; - width = 0.5f; - break; - - case LF_B_SOLID_RED: - material = "lf_solid_red_border"; - width = 0.25f; - break; - - case LF_B_BROKEN_RED: - material = "lf_broken_red_border"; - width = 0.25f; - break; - - case LF_B_SOLID_RED_WIDE: - material = "lf_solid_red_border"; - width = 0.5f; - break; - - case LF_B_SOLID_ORANGE: - material = "lf_solid_orange_border"; - width = 0.25f; - break; - - case LF_B_SOLID_BLUE: - material = "lf_solid_blue_border"; - width = 0.25f; - break; - - case LF_B_SOLID_GREEN: - material = "lf_solid_green_border"; - width = 0.25f; - break; + case LF_BROKEN_ROAD: + material = "lf_broken_white"s; + width = 0.25f; + break; - default: - TG_LOG(SG_GENERAL, SG_ALERT, "LinearFeature::Finish: unknown marking " << marks[i]->type ); - exit(1); + case LF_BROKEN_ROAD_WIDE: + material = "lf_broken_white"s; + width = 0.5f; + break; + + case LF_B_ROAD_EDGE_SOLID: + material = "lf_solid_white_border"s; + width = 0.25f; + break; + + case LF_B_ROAD_EDGE_ZIPPER: + material = "lf_broken_white_border"s; //TODO + width = 0.5f; + break; + + case LF_B_ROAD_EDGE_DASH: + material = "lf_broken_white_border"s; + width = 0.25f; + break; + + case LF_B_ROAD_DASH: + material = "lf_broken_white_border"s; + width = 0.25f; + break; + + case LF_B_ROAD_DASH_WIDE: + material = "lf_broken_white_border"s; + width = 0.5f; + break; + + case LF_B_ROAD_EDGE_WIDE: + material = "lf_solid_white_border"s; + width = 0.5f; + break; + + case LF_B_SOLID_RED: + material = "lf_solid_red_border"s; + width = 0.25f; + break; + + case LF_B_BROKEN_RED: + material = "lf_broken_red_border"s; + width = 0.25f; + break; + + case LF_B_SOLID_RED_WIDE: + material = "lf_solid_red_border"s; + width = 0.5f; + break; + + case LF_B_SOLID_ORANGE: + material = "lf_solid_orange_border"s; + width = 0.25f; + break; + + case LF_B_SOLID_BLUE: + material = "lf_solid_blue_border"s; + width = 0.25f; + break; + + case LF_B_SOLID_GREEN: + material = "lf_solid_green_border"s; + width = 0.25f; + break; + + default: + TG_LOG(SG_GENERAL, SG_ALERT, "LinearFeature::Finish: unknown marking " << marks[i]->type); + exit(1); } - for (unsigned int j = marks[i]->start_idx; j <= marks[i]->end_idx; j++) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::Finish: calculating offsets for mark " << i << " whose start idx is " << marks[i]->start_idx << " and end idx is " << marks[i]->end_idx << " cur idx is " << j ); + for (unsigned int j = marks[i]->start_idx; j <= marks[i]->end_idx; j++) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::Finish: calculating offsets for mark " << i << + " whose start idx is " << marks[i]->start_idx << + " and end idx is " << marks[i]->end_idx << + " cur idx is " << j); + // for each point on the PointsList, generate a quad from - // start to next, offset by 2 distnaces from the edge + // start to next, offset by 2 distances from the edge - if (j == marks[i]->start_idx) - { + if (j == marks[i]->start_idx) { // first point on the mark - offset heading is 90deg - cur_outer = OffsetPointFirst( points.GetNode(j), points.GetNode(j+1), offset-width/2.0f ); - cur_inner = OffsetPointFirst( points.GetNode(j), points.GetNode(j+1), offset+width/2.0f ); - // OffsetPointsFirst( points.GetNode(j), points.GetNode(j+1), offset, width, cur_inner, cur_outer ); - } - else if (j == marks[i]->end_idx) - { + cur_outer = OffsetPointFirst(points.GetNode(j), points.GetNode(j + 1), offset - width / 2.0f); + cur_inner = OffsetPointFirst(points.GetNode(j), points.GetNode(j + 1), offset + width / 2.0f); + } else if (j == marks[i]->end_idx) { // last point on the mark - offset heading is 90deg - cur_outer = OffsetPointLast( points.GetNode(j-1), points.GetNode(j), offset-width/2.0f ); - cur_inner = OffsetPointLast( points.GetNode(j-1), points.GetNode(j), offset+width/2.0f ); - // OffsetPointsLast( points.GetNode(j-1), points.GetNode(j), offset, width, cur_inner, cur_outer ); - } - else - { - cur_outer = OffsetPointMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset-width/2.0f ); - cur_inner = OffsetPointMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset+width/2.0f ); - // OffsetPointsMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset, width, cur_inner, cur_outer ); + cur_outer = OffsetPointLast(points.GetNode(j - 1), points.GetNode(j), offset - width / 2.0f); + cur_inner = OffsetPointLast(points.GetNode(j - 1), points.GetNode(j), offset + width / 2.0f); + } else { + cur_outer = OffsetPointMiddle(points.GetNode(j - 1), points.GetNode(j), points.GetNode(j + 1), offset - width / 2.0f); + cur_inner = OffsetPointMiddle(points.GetNode(j - 1), points.GetNode(j), points.GetNode(j + 1), offset + width / 2.0f); } - if ( markStarted ) - { - SGGeod prev_mp = midpoint( prev_outer, prev_inner ); - SGGeod cur_mp = midpoint( cur_outer, cur_inner ); - SGGeodesy::inverse( prev_mp, cur_mp, heading, az2, dist ); + if (markStarted) { + SGGeod prev_mp = midpoint(prev_outer, prev_inner); + SGGeod cur_mp = midpoint(cur_outer, cur_inner); + SGGeodesy::inverse(prev_mp, cur_mp, heading, az2, dist); poly.Erase(); - poly.AddNode( 0, prev_inner ); - poly.AddNode( 0, prev_outer ); - poly.AddNode( 0, cur_outer ); - poly.AddNode( 0, cur_inner ); - poly = tgPolygon::Snap( poly, gSnap ); + poly.AddNode(0, prev_inner); + poly.AddNode(0, prev_outer); + poly.AddNode(0, cur_outer); + poly.AddNode(0, cur_inner); + poly = tgPolygon::Snap(poly, gSnap); - poly.SetMaterial( material ); - poly.SetTexParams( prev_inner, width, 1.0f, heading ); - poly.SetTexLimits( 0, last_end_v, 1, 1 ); - poly.SetTexMethod( TG_TEX_BY_TPS_CLIPU, -1.0, 0.0, 1.0, 0.0 ); + poly.SetMaterial(material); + poly.SetTexParams(prev_inner, width, 1.0f, heading); + poly.SetTexLimits(0, last_end_v, 1, 1); + poly.SetTexMethod(TG_TEX_BY_TPS_CLIPU, -1.0, 0.0, 1.0, 0.0); marking_polys.push_back(poly); - last_end_v = (double)1.0f - (fmod( (double)(dist - last_end_v), (double)1.0f )); + last_end_v = (double)1.0f - (fmod((double)(dist - last_end_v), (double)1.0f)); } else { markStarted = true; } @@ -718,156 +656,136 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) } } - // now generate the superpoly list for lights with constant distance between lights (depending on feature type) + // now generate the super-poly list for lights with constant distance between lights (depending on feature type) tglightcontour_list light_contours; - tgLightContour cur_light_contour; - tgLightContour alt_light_contour; + tgLightContour cur_light_contour; + tgLightContour alt_light_contour; - for (unsigned int i=0; iLightDirection(); bool alternate = false; // which material for this light - switch( lights[i]->type ) - { - case LF_BIDIR_GREEN: - cur_light_contour.SetType( "RWY_GREEN_TAXIWAY_LIGHTS" ); - light_delta = 10.0f; - break; + switch (lights[i]->type) { + case LF_BIDIR_GREEN: + cur_light_contour.SetType("RWY_GREEN_TAXIWAY_LIGHTS"); + light_delta = 10.0f; + break; - case LF_OMNIDIR_BLUE: - cur_light_contour.SetType( "RWY_BLUE_TAXIWAY_LIGHTS" ); - light_delta = 10.0f; - break; + case LF_OMNIDIR_BLUE: + cur_light_contour.SetType("RWY_BLUE_TAXIWAY_LIGHTS"); + light_delta = 10.0f; + break; - case LF_UNIDIR_CLOSE_AMBER: - cur_light_contour.SetType( "RWY_YELLOW_LIGHTS" ); - light_delta = 2.0f; - break; + case LF_UNIDIR_CLOSE_AMBER: + cur_light_contour.SetType("RWY_YELLOW_LIGHTS"); + light_delta = 2.0f; + break; - case LF_UNIDIR_CLOSE_AMBER_PULSE: - cur_light_contour.SetType( "RWY_YELLOW_PULSE_LIGHTS" ); - light_delta = 2.0f; - break; + case LF_UNIDIR_CLOSE_AMBER_PULSE: + cur_light_contour.SetType("RWY_YELLOW_PULSE_LIGHTS"); + light_delta = 2.0f; + break; - case LF_BIDIR_GREEN_AMBER: - cur_light_contour.SetType( "RWY_GREEN_TAXIWAY_LIGHTS" ); - alt_light_contour.SetType( "RWY_YELLOW_LIGHTS" ); - light_delta = 10.0f; - alternate = true; - break; + case LF_BIDIR_GREEN_AMBER: + cur_light_contour.SetType("RWY_GREEN_TAXIWAY_LIGHTS"); + alt_light_contour.SetType("RWY_YELLOW_LIGHTS"); + light_delta = 10.0f; + alternate = true; + break; - case LF_OMNIDIR_RED: - cur_light_contour.SetType( "RWY_RED_LIGHTS" ); - light_delta = 10.0f; - break; + case LF_OMNIDIR_RED: + cur_light_contour.SetType("RWY_RED_LIGHTS"); + light_delta = 10.0f; + break; - case LF_UNIDIR_GREEN: - cur_light_contour.SetType( "RWY_GREEN_LIGHTS" ); - light_delta = 10.0f; - break; + case LF_UNIDIR_GREEN: + cur_light_contour.SetType("RWY_GREEN_LIGHTS"); + light_delta = 10.0f; + break; - case LF_UNIDIR_GREEN_AMBER: - cur_light_contour.SetType( "RWY_GREEN_LIGHTS" ); - alt_light_contour.SetType( "RWY_YELLOW_LIGHTS" ); - light_delta = 10.0f; - alternate = true; - break; + case LF_UNIDIR_GREEN_AMBER: + cur_light_contour.SetType("RWY_GREEN_LIGHTS"); + alt_light_contour.SetType("RWY_YELLOW_LIGHTS"); + light_delta = 10.0f; + alternate = true; + break; - default: - // catch unknown lighting type. Allows TerraGear to exit cleanly when it comes across new light features 107 and 108 - TG_LOG(SG_GENERAL, SG_ALERT, "LinearFeature::Finish: unknown lighting feature " << lights[i]->type ); - exit(1); + default: + // catch unknown lighting type. Allows TerraGear to exit cleanly when it comes across new light features 107 and 108 + TG_LOG(SG_GENERAL, SG_ALERT, "LinearFeature::Finish: unknown lighting feature " << lights[i]->type); + exit(1); } - for (unsigned int j = lights[i]->start_idx; j <= lights[i]->end_idx; j++) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::Finish: calculating offsets for light " << i << " whose start idx is " << lights[i]->start_idx << " and end idx is " << lights[i]->end_idx << " cur idx is " << j ); - // for each point on the PointsList, offset by 2 distnaces from the edge, and add a point to the superpoly contour - if (j == lights[i]->start_idx) - { + for (unsigned int j = lights[i]->start_idx; j <= lights[i]->end_idx; j++) { + TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::Finish: calculating offsets for light " << i << + " whose start idx is " << lights[i]->start_idx << + " and end idx is " << lights[i]->end_idx << + " cur idx is " << j); + + // for each point on the PointsList, offset by 2 distances from the edge, and add a point to the super-poly contour + if (j == lights[i]->start_idx) { // first point on the light - offset heading is 90deg - cur_outer = OffsetPointFirst( points.GetNode(j), points.GetNode(j+1), offset ); - } - else if (j == lights[i]->end_idx) - { + cur_outer = OffsetPointFirst(points.GetNode(j), points.GetNode(j + 1), offset); + } else if (j == lights[i]->end_idx) { // last point on the mark - offset heading is 90deg - cur_outer = OffsetPointLast( points.GetNode(j-1), points.GetNode(j), offset ); - } - else - { - cur_outer = OffsetPointMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset ); + cur_outer = OffsetPointLast(points.GetNode(j - 1), points.GetNode(j), offset); + } else { + cur_outer = OffsetPointMiddle(points.GetNode(j - 1), points.GetNode(j), points.GetNode(j + 1), offset); } - if ( markStarted ) - { + if (markStarted) { SGGeod tmp; - bool switch_poly = true; + bool switch_poly = true; // calculate the heading and distance from prev to cur - SGGeodesy::inverse( prev_outer, cur_outer, heading, az2, dist ); + SGGeodesy::inverse(prev_outer, cur_outer, heading, az2, dist); - while (cur_light_dist < dist) - { - if (cur_light_dist == 0.0) - { + while (cur_light_dist < dist) { + if (cur_light_dist == 0.0) { tmp = prev_outer; - } - else - { + } else { // calculate the position of the next light - tmp = SGGeodesy::direct( prev_outer, heading, cur_light_dist ); + tmp = SGGeodesy::direct(prev_outer, heading, cur_light_dist); } SGVec3f vec1, vec2; - if ( light_direction == 0) - { + if (light_direction == 0) { // calculate the omnidirectional normal vec1 = normalize(SGVec3f::fromGeod(tmp)); - } else if ( light_direction == 1) - { + } else if (light_direction == 1) { // calculate the directional normal. These lights all face to the right - double heading_vec = SGMiscd::normalizePeriodic( 0, 360, heading + 90.0 ); + double heading_vec = SGMiscd::normalizePeriodic(0, 360, heading + 90.0); SGVec3f cart1 = SGVec3f::fromGeod(tmp); - SGVec3f cart2 = SGVec3f::fromGeod( SGGeodesy::direct( tmp, heading_vec, 10 ) ); + SGVec3f cart2 = SGVec3f::fromGeod(SGGeodesy::direct(tmp, heading_vec, 10)); vec1 = normalize(cart2 - cart1); } else //( light_direction == 2) { // calculate the directional normals for bidirectional lights SGVec3f cart1 = SGVec3f::fromGeod(tmp); - SGVec3f cart2 = SGVec3f::fromGeod( SGGeodesy::direct( tmp, heading, 10 ) ); + SGVec3f cart2 = SGVec3f::fromGeod(SGGeodesy::direct(tmp, heading, 10)); vec1 = normalize(cart2 - cart1); - cart2 = SGVec3f::fromGeod( SGGeodesy::direct( tmp, heading, -10 ) ); + cart2 = SGVec3f::fromGeod(SGGeodesy::direct(tmp, heading, -10)); vec2 = normalize(cart2 - cart1); } - if (!alternate) - { - cur_light_contour.AddLight( tmp, vec1 ); - if ( light_direction == 2) - { - cur_light_contour.AddLight( tmp, vec2 ); + if (!alternate) { + cur_light_contour.AddLight(tmp, vec1); + if (light_direction == 2) { + cur_light_contour.AddLight(tmp, vec2); } - } - else - { - if (switch_poly) - { - cur_light_contour.AddLight( tmp, vec1 ); - if ( light_direction == 2) - { - cur_light_contour.AddLight( tmp, vec2 ); + } else { + if (switch_poly) { + cur_light_contour.AddLight(tmp, vec1); + if (light_direction == 2) { + cur_light_contour.AddLight(tmp, vec2); } - } - else - { - alt_light_contour.AddLight( tmp, vec1 ); - if ( light_direction == 2) - { - alt_light_contour.AddLight( tmp, vec2 ); + } else { + alt_light_contour.AddLight(tmp, vec1); + if (light_direction == 2) { + alt_light_contour.AddLight(tmp, vec2); } } switch_poly = !switch_poly; @@ -886,49 +804,46 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) prev_outer = cur_outer; } - // if there were lights generated - create the superpoly - if (cur_light_contour.ContourSize()) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::Finish: Adding light contour with " << cur_light_contour.ContourSize() << " lights" ); + // if there were lights generated - create the super-poly + if (cur_light_contour.ContourSize()) { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::Finish: Adding light contour with " << + cur_light_contour.ContourSize() << " lights"); cur_light_contour.SetFlag(""); lighting_polys.push_back(cur_light_contour); } - // create the superpoly for the alternating light color - if (alt_light_contour.ContourSize()) - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::Finish: Adding light contour with " << cur_light_contour.ContourSize() << " lights" ); + // create the super-poly for the alternating light color + if (alt_light_contour.ContourSize()) { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::Finish: Adding light contour with " << + cur_light_contour.ContourSize() << " lights"); alt_light_contour.SetFlag(""); lighting_polys.push_back(cur_light_contour); - } - else - { - TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::Finish: No points for linear feature " << description << " light index " << i ); + } else { + TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::Finish: No points for linear feature " << + description << " light index " << i); } } return 1; } -int LinearFeature::BuildBtg(tgpolygon_list& line_polys, tglightcontour_list& lights, tgAccumulator& accum, bool make_shapefiles ) +int LinearFeature::BuildBtg(tgpolygon_list& line_polys, tglightcontour_list& lights, tgAccumulator& accum, bool make_shapefiles) { tgPolygon poly; - SGGeod min, max, minp, maxp; + SGGeod min, max, minp, maxp; TG_LOG(SG_GENERAL, SG_DEBUG, "\nLinearFeature::BuildBtg: " << description); - for ( unsigned int i = 0; i < marking_polys.size(); i++) - { + for (unsigned int i = 0; i < marking_polys.size(); i++) { // Clipping and triangulation need to copy texparams, and material info... - marking_polys[i] = accum.Diff( marking_polys[i] ); - line_polys.push_back( marking_polys[i] ); + marking_polys[i] = accum.Diff(marking_polys[i]); + line_polys.push_back(marking_polys[i]); - accum.Add( marking_polys[i] ); + accum.Add(marking_polys[i]); } TG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::BuildBtg: add " << lighting_polys.size() << " light defs"); - for ( unsigned i = 0; i < lighting_polys.size(); i++) - { - lights.push_back( lighting_polys[i] ); + for (unsigned i = 0; i < lighting_polys.size(); i++) { + lights.push_back(lighting_polys[i]); } return 1; diff --git a/src/Airports/GenAirports/linearfeature.hxx b/src/Airports/GenAirports/linearfeature.hxx index a9be6b4f..dfd089d1 100644 --- a/src/Airports/GenAirports/linearfeature.hxx +++ b/src/Airports/GenAirports/linearfeature.hxx @@ -81,13 +81,14 @@ #define LF_UNIDIR_GREEN (107) #define LF_UNIDIR_GREEN_AMBER (108) + struct Marking { public: unsigned int type; unsigned int start_idx; unsigned int end_idx; }; -typedef std::vector MarkingList; +typedef std::vector> MarkingList; struct Lighting { public: @@ -98,16 +99,17 @@ public: // 1 for unidirectional // 2 for bidirectional // 0 for omnidirectional - int LightDirection() + int LightDirection() const { if (type == 103 || type == 104) return 1; else if (type == 101 || type == 105) return 2; + return 0; } }; -typedef std::vector LightingList; +typedef std::vector> LightingList; class LinearFeature { @@ -126,7 +128,7 @@ public: ~LinearFeature(); - inline std::string GetDescription() { return description; } + inline std::string GetDescription() const { return description; } void AddNode(std::shared_ptr b) { @@ -141,10 +143,10 @@ private: double width; MarkingList marks; - Marking* cur_mark; + std::shared_ptr cur_mark = nullptr; LightingList lights; - Lighting* cur_light; + std::shared_ptr cur_light = nullptr; void ConvertContour(const BezContour& src, bool closed);