diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index a7b64556..30b4ab91 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -353,65 +353,60 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) SGBucket b( apt_lon, apt_lat ); SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str()); - // Build precision runways first - for (i=0; iIsPrecision() ) - { - runways[i]->BuildBtg( altitude, &rwy_polys, &rwy_tps, &accum, &apt_base, &apt_clearing ); - } - } - - // Now generate pavements, and gather the linear features and lights from them - SG_LOG(SG_GENERAL, SG_ALERT, "Features before pavement add " << features.size() ); + superpoly_list rwy_lights; + rwy_lights.clear(); + // If we are cutting in the linear features, add them first if (pavements.size()) { for ( i=0; iGetMarkings() ); + AddFeatures( pavements[i]->GetFeatures() ); } } - SG_LOG(SG_GENERAL, SG_ALERT, "Features after pavement add " << features.size() ); - - // Then the linear features + // Add the linear features if (features.size()) { for ( i=0; iGetDescription() ); + SG_LOG(SG_GENERAL, SG_ALERT, "Build Feature Poly " << i << ": " << features[i]->GetDescription() ); // cut the linear feature in until we get the geometry right... // features[i]->BuildBtg( altitude, &line_polys, &line_tps, &line_accum ); - features[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum ); + features[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum, &rwy_lights ); } } else { - SG_LOG(SG_GENERAL, SG_ALERT, "no pavements"); + SG_LOG(SG_GENERAL, SG_ALERT, "no markings"); } - // wipe out the pavements to save memory - features.clear(); - // Now generate pavements, and gather the linear features and lights from them + // Build runways next + for (i=0; iIsPrecision() ) + { + runways[i]->BuildBtg( altitude, &rwy_polys, &rwy_tps, &rwy_lights, &accum, &apt_base, &apt_clearing ); + } + } + + // Build the pavements if (pavements.size()) { for ( i=0; iGetDescription()); pavements[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum, &apt_base, &apt_clearing ); - AddFeatures( pavements[i]->GetMarkings() ); + // AddFeatures( pavements[i]->GetMarkings() ); } } else { SG_LOG(SG_GENERAL, SG_ALERT, "no pavements"); } - // wipe out the pavements to save memory - pavements.clear(); - if ( apt_base.total_size() == 0 ) + if ( apt_base.total_size() == 0 ) { SG_LOG(SG_GENERAL, SG_ALERT, "no airport points generated"); return; @@ -894,14 +889,11 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) } } -#if 0 // extend the min/max coordinates of airport area to cover all // lights as well for ( i = 0; i < (int)rwy_lights.size(); ++i ) { - for ( j = 0; - j < (int)rwy_lights[i].get_poly().get_contour(0).size(); - ++j ) + for ( j = 0; j < (int)rwy_lights[i].get_poly().get_contour(0).size(); ++j ) { Point3D p = rwy_lights[i].get_poly().get_contour(0)[j]; if ( p.lon() < min_deg.lon() ) @@ -922,7 +914,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) } } } -#endif // need newmat.... @@ -1070,11 +1061,9 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) strips_tc.push_back( base_tc ); } - -#if 0 // add light points - - superpoly_list tmp_light_list; tmp_light_list.clear(); + superpoly_list tmp_light_list; + tmp_light_list.clear(); typedef map < string, double, less > elev_map_type; typedef elev_map_type::const_iterator const_elev_map_iterator; elev_map_type elevation_map; @@ -1082,7 +1071,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) SG_LOG(SG_GENERAL, SG_INFO, "Computing runway/approach lighting elevations"); // pass one, calculate raw elevations from Array - for ( i = 0; i < (int)rwy_lights.size(); ++i ) { TGTriNodes light_nodes; @@ -1095,7 +1083,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) } // calculate light node elevations - point_list geod_light_nodes = calc_elevations( apt_surf, light_nodes.get_node_list(), 0.5 ); TGPolygon p; p.add_contour( geod_light_nodes, 0 ); @@ -1155,7 +1142,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) pts_n.push_back( pt_n ); pt_materials.push_back( rwy_lights[i].get_material() ); } -#endif // calculate wgs84 mapping of nodes std::vector< SGVec3d > wgs84_nodes; diff --git a/src/Airports/GenAirports850/closedpoly.cxx b/src/Airports/GenAirports850/closedpoly.cxx index 30894c55..73b7c2a4 100644 --- a/src/Airports/GenAirports850/closedpoly.cxx +++ b/src/Airports/GenAirports850/closedpoly.cxx @@ -31,7 +31,7 @@ ClosedPoly::ClosedPoly( int st, float s, float th, char* desc ) boundary = NULL; cur_contour = NULL; - cur_marking = NULL; + cur_feature = NULL; } void ClosedPoly::AddNode( BezNode* node ) @@ -52,22 +52,22 @@ void ClosedPoly::AddNode( BezNode* node ) // if recording a linear feature on the pavement, add this node // to it as well // TODO: just doing marking now, need lighting as well - if (!cur_marking) + if (!cur_feature) { - string marking_desc = description + ":"; + string feature_desc = description + ":"; if (boundary) { - marking_desc += "hole"; + feature_desc += "hole"; } else { - marking_desc += "boundary"; + feature_desc += "boundary"; } - SG_LOG(SG_GENERAL, SG_DEBUG, " Adding node (" << node->GetLoc().x() << "," << node->GetLoc().y() << ") to current linear feature " << cur_marking); - cur_marking = new LinearFeature(marking_desc, 1.0f ); + SG_LOG(SG_GENERAL, SG_DEBUG, " Adding node (" << node->GetLoc().x() << "," << node->GetLoc().y() << ") to current linear feature " << cur_feature); + cur_feature = new LinearFeature(feature_desc, 1.0f ); } - cur_marking->AddNode( node ); + cur_feature->AddNode( node ); } void ClosedPoly::CreateConvexHull( void ) @@ -93,14 +93,13 @@ int ClosedPoly::CloseCurContour() // if we are recording a pavement marking - it must be closed - // add the first node of the poly - if (cur_marking) + if (cur_feature) { SG_LOG(SG_GENERAL, SG_DEBUG, "We still have an active linear feature - add the first node to close it"); - // cur_marking->Close(); - cur_marking->Finish(); + cur_feature->Finish(); - markings.push_back(cur_marking); - cur_marking = NULL; + features.push_back(cur_feature); + cur_feature = NULL; } // add the contour to the poly - first one is the outer boundary @@ -596,7 +595,7 @@ int ClosedPoly::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list break; default: - SG_LOG(SG_GENERAL, SG_ALERT, "ClosedPoly::BuildBtg: unknown material " << surface_type ); + SG_LOG(SG_GENERAL, SG_ALERT, "ClosedPoly::BuildBtg: unknown surface type " << surface_type ); exit(1); } diff --git a/src/Airports/GenAirports850/closedpoly.hxx b/src/Airports/GenAirports850/closedpoly.hxx index ec98dd19..368ce0d8 100644 --- a/src/Airports/GenAirports850/closedpoly.hxx +++ b/src/Airports/GenAirports850/closedpoly.hxx @@ -27,10 +27,10 @@ public: int BuildOsg( osg::Group* airport ); int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ); - FeatureList* GetMarkings() + FeatureList* GetFeatures() { - return &markings; - } + return &features; + } private: //osg::DrawArrays* CreatePrimitive( BezContour* contour, osg::Vec3Array* v_pave ); @@ -61,8 +61,8 @@ private: TGPolygon pre_tess; // pavement definitions have multiple linear features (markings and lights for each contour) - LinearFeature* cur_marking; - FeatureList markings; + LinearFeature* cur_feature; + FeatureList features; }; typedef std::vector PavementList; diff --git a/src/Airports/GenAirports850/linearfeature.cxx b/src/Airports/GenAirports850/linearfeature.cxx index d9fed865..d86ab035 100644 --- a/src/Airports/GenAirports850/linearfeature.cxx +++ b/src/Airports/GenAirports850/linearfeature.cxx @@ -405,10 +405,10 @@ int LinearFeature::Finish() // create the inner and outer boundaries to generate polys // this generates 2 point lists for the contours, and remembers - // the start stop points for markings + // the start stop points for markings and lights ConvertContour( &contour ); - // now generate the supoerpoly and texparams list + // now generate the supoerpoly and texparams lists for markings for (i=0; itype ); + SG_LOG(SG_GENERAL, SG_ALERT, "LinearFeature::Finish: unknown marking " << marks[i]->type ); exit(1); } @@ -580,11 +571,11 @@ int LinearFeature::Finish() sp.set_poly( poly ); sp.set_material( material ); sp.set_flag("lf"); - feature_polys.push_back(sp); + marking_polys.push_back(sp); tp = TGTexParams( prev_inner, width, 1.0f, heading ); tp.set_minv(last_end_v); - feature_tps.push_back(tp); + marking_tps.push_back(tp); last_end_v = 1.0f - (fmod( (dist - last_end_v), 1.0f )); } @@ -593,18 +584,44 @@ int LinearFeature::Finish() prev_inner = cur_inner; } } + + // now generate the supoerpoly list for lights + for (i=0; itype ) + { + case LF_BIDIR_GREEN: + break; + + case LF_OMNIDIR_BLUE: + break; + + case LF_UNIDIR_CLOSE_AMBER: + break; + + case LF_UNIDIR_CLOSE_AMBER_PULSE: + break; + + case LF_BIDIR_GREEN_AMBER: + break; + + case LF_OMNIDIR_RED: + break; + } + } } -int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum ) +int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum, superpoly_list* lights ) { TGPolygon poly; TGPolygon clipped; TGPolygon split; int i; - for (i=0; ipush_back( feature_polys[i] ); + marking_polys[i].set_poly( split ); + line_polys->push_back( marking_polys[i] ); *line_accum = tgPolygonUnion( poly, *line_accum ); - line_tps->push_back( feature_tps[i] ); + line_tps->push_back( marking_tps[i] ); } return 1; diff --git a/src/Airports/GenAirports850/linearfeature.hxx b/src/Airports/GenAirports850/linearfeature.hxx index fa989bd4..775a9890 100644 --- a/src/Airports/GenAirports850/linearfeature.hxx +++ b/src/Airports/GenAirports850/linearfeature.hxx @@ -53,6 +53,14 @@ public: }; typedef std::vector MarkingList; +struct Lighting +{ +public: + int type; + int start_idx; + int end_idx; +}; +typedef std::vector LightingList; class LinearFeature { @@ -85,7 +93,7 @@ public: int Finish(); int BuildOsg( osg::Group* airport ); - int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum ); + int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum, superpoly_list* lights ); private: Point3D OffsetPointFirst( Point3D *cur, Point3D *next, double offset_by ); @@ -94,8 +102,12 @@ private: double offset; double width; - MarkingList marks; - Marking* cur_mark; + + MarkingList marks; + Marking* cur_mark; + + LightingList lights; + Lighting* cur_light; void ConvertContour( BezContour* src ); @@ -108,8 +120,10 @@ private: // contour definition after bezier interpolation point_list points; - superpoly_list feature_polys; - texparams_list feature_tps; + superpoly_list marking_polys; + texparams_list marking_tps; + + superpoly_list lighting_polys; }; typedef std::vector FeatureList; diff --git a/src/Airports/GenAirports850/main.cxx b/src/Airports/GenAirports850/main.cxx index 305b7332..c081dae2 100644 --- a/src/Airports/GenAirports850/main.cxx +++ b/src/Airports/GenAirports850/main.cxx @@ -293,7 +293,7 @@ int main(int argc, char **argv) Parser* parser = new Parser(input_file); SG_LOG(SG_GENERAL, SG_INFO, "Parse katl"); - parser->Parse((char*)"katl"); + parser->Parse((char*)"edfe"); if (view_osg) { diff --git a/src/Airports/GenAirports850/parser.cxx b/src/Airports/GenAirports850/parser.cxx index b7ab8efe..62411b41 100644 --- a/src/Airports/GenAirports850/parser.cxx +++ b/src/Airports/GenAirports850/parser.cxx @@ -38,14 +38,14 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode ) { double lat, lon; double ctrl_lat, ctrl_lon; - int mark_type, light_type; + int feat_type1, feat_type2; BezNode *curNode = NULL; bool hasCtrl; bool close; bool term; - bool hasMarking = false; - bool hasLighting = false; + bool hasFeat1 = false; + bool hasFeat2 = false; int numParams; switch(type) @@ -90,26 +90,26 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode ) // parse the line if (hasCtrl) { - numParams = sscanf(line, "%lf %lf %lf %lf %d %d", &lat, &lon, &ctrl_lat, &ctrl_lon, &mark_type, &light_type); + numParams = sscanf(line, "%lf %lf %lf %lf %d %d", &lat, &lon, &ctrl_lat, &ctrl_lon, &feat_type1, &feat_type2); if (numParams > 4) { - hasMarking = true; + hasFeat1 = true; } if (numParams > 5) { - hasLighting = true; + hasFeat2 = true; } } else { - numParams = sscanf(line, "%lf %lf %d %d", &lat, &lon, &mark_type, &light_type); + numParams = sscanf(line, "%lf %lf %d %d", &lat, &lon, &feat_type1, &feat_type2); if (numParams > 2) { - hasMarking = true; + hasFeat1 = true; } if (numParams > 3) { - hasLighting = true; + hasFeat2 = true; } } @@ -143,14 +143,28 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode ) } } - if (hasMarking) + if (hasFeat1) { - curNode->SetMarking( mark_type ); + if (feat_type1 < 100) + { + curNode->SetMarking( feat_type1 ); + } + else + { + curNode->SetLighting( feat_type1 ); + } } - if (hasLighting) + if (hasFeat2) { - curNode->SetLighting( light_type ); + if (feat_type2 < 100) + { + curNode->SetMarking( feat_type2 ); + } + else + { + curNode->SetLighting( feat_type2 ); + } } return curNode; diff --git a/src/Airports/GenAirports850/runway.cxx b/src/Airports/GenAirports850/runway.cxx index 546ecab1..994a7ec2 100644 --- a/src/Airports/GenAirports850/runway.cxx +++ b/src/Airports/GenAirports850/runway.cxx @@ -370,7 +370,7 @@ void Runway::gen_marked_rwy( double alt_m, const string& material, superpoly_lis } #endif -int Runway::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ) +int Runway::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, superpoly_list* rwy_lights, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ) { TGPolygon base, safe_base; string material; diff --git a/src/Airports/GenAirports850/runway.hxx b/src/Airports/GenAirports850/runway.hxx index 39242501..13f23903 100644 --- a/src/Airports/GenAirports850/runway.hxx +++ b/src/Airports/GenAirports850/runway.hxx @@ -69,7 +69,7 @@ TGRunway rwy; } int BuildOsg( osg::Group* airport ); - int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ); + int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, superpoly_list* rwy_lights, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ); private: