From fdb37b36c701f313281fb9b6e2374d3f17e8887a Mon Sep 17 00:00:00 2001 From: PSadrozinski <psadrozinski@bellsouth.net> Date: Wed, 5 Oct 2011 22:58:44 -0400 Subject: [PATCH] added linked objects for beacon and windsock support. taxiway signs pending... --- src/Airports/GenAirports850/CMakeLists.txt | 1 + src/Airports/GenAirports850/airport.cxx | 77 ++++++++++++------- src/Airports/GenAirports850/airport.hxx | 13 ++++ .../GenAirports850/linked_objects.cxx | 18 +++++ .../GenAirports850/linked_objects.hxx | 61 +++++++++++++++ src/Airports/GenAirports850/parser.cxx | 6 +- src/Airports/GenAirports850/parser.hxx | 2 + 7 files changed, 148 insertions(+), 30 deletions(-) create mode 100644 src/Airports/GenAirports850/linked_objects.cxx create mode 100644 src/Airports/GenAirports850/linked_objects.hxx diff --git a/src/Airports/GenAirports850/CMakeLists.txt b/src/Airports/GenAirports850/CMakeLists.txt index 8f0e6b9c..824fc570 100644 --- a/src/Airports/GenAirports850/CMakeLists.txt +++ b/src/Airports/GenAirports850/CMakeLists.txt @@ -8,6 +8,7 @@ add_executable(genapts850 global.hxx lights.cxx linearfeature.hxx linearfeature.cxx + linked_objects.hxx linked_objects.cxx main.cxx object.hxx object.cxx parser.hxx parser.cxx diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index 0e65617e..c06031d4 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -949,14 +949,32 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()"); #if 0 // TODO : along with taxiway sign elevations - SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations"); - point_list beacon_nodes = calc_elevations( apt_surf, beacons, 0.0 ); SG_LOG(SG_GENERAL, SG_INFO, "Computing tower node elevations"); point_list tower_nodes = calc_elevations( apt_surf, towers, 0.0 ); - SG_LOG(SG_GENERAL, SG_INFO, "Computing windsock node elevations"); - point_list windsock_nodes = calc_elevations( apt_surf, windsocks, 0.0 ); #endif + // calc windsock elevations: + SG_LOG(SG_GENERAL, SG_INFO, "Computing windsock node elevations"); + point_list ws_nodes; + ws_nodes.clear(); + for ( i = 0; i < (int)windsocks.size(); ++i ) + { + p = windsocks[i]->GetLoc(); + ws_nodes.push_back( p ); + } + point_list windsock_nodes = calc_elevations( apt_surf, ws_nodes, 0.0 ); + + + SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations"); + point_list b_nodes; + b_nodes.clear(); + for ( i = 0; i < (int)beacons.size(); ++i ) + { + p = beacons[i]->GetLoc(); + b_nodes.push_back( p ); + } + point_list beacon_nodes = calc_elevations( apt_surf, b_nodes, 0.0 ); + // add base skirt (to hide potential cracks) // // this has to happen after we've calculated the node elevations @@ -1233,6 +1251,32 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) write_index( objpath, b, name ); #if 0 // TODO : along with taxiway signs + // write out tower references + for ( i = 0; i < (int)tower_nodes.size(); ++i ) + { + write_index_shared( objpath, b, tower_nodes[i], + "Models/Airport/tower.xml", + 0.0 ); + } +#endif + + // write out windsock references : TODO - save elevation data in the windsock object + for ( i = 0; i < (int)windsock_nodes.size(); ++i ) + { + if ( windsocks[i]->IsLit() ) + { + write_index_shared( objpath, b, windsock_nodes[i], + "Models/Airport/windsock_lit.xml", + 0.0 ); + } + else + { + write_index_shared( objpath, b, windsock_nodes[i], + "Models/Airport/windsock.xml", + 0.0 ); + } + } + // write out beacon references for ( i = 0; i < (int)beacon_nodes.size(); ++i ) { @@ -1241,31 +1285,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) 0.0 ); } - // write out tower references - for ( i = 0; i < (int)tower_nodes.size(); ++i ) - { - write_index_shared( objpath, b, tower_nodes[i], - "Models/Airport/tower.xml", - 0.0 ); - } - - // write out windsock references - for ( i = 0; i < (int)windsock_nodes.size(); ++i ) - { - if ( windsock_types[i] == 0 ) - { - write_index_shared( objpath, b, windsock_nodes[i], - "Models/Airport/windsock.xml", - 0.0 ); - } - else - { - write_index_shared( objpath, b, windsock_nodes[i], - "Models/Airport/windsock_lit.xml", - 0.0 ); - } - } -#endif string holepath = root + "/AirportArea"; // long int poly_index = poly_index_next(); diff --git a/src/Airports/GenAirports850/airport.hxx b/src/Airports/GenAirports850/airport.hxx index 157b0195..ec3d920f 100644 --- a/src/Airports/GenAirports850/airport.hxx +++ b/src/Airports/GenAirports850/airport.hxx @@ -8,6 +8,7 @@ #include "object.hxx" #include "closedpoly.hxx" #include "linearfeature.hxx" +#include "linked_objects.hxx" using std::string; @@ -45,6 +46,16 @@ public: } } + void AddWindsock( Windsock* windsock ) + { + windsocks.push_back( windsock ); + } + + void AddBeacon( Beacon* beacon ) + { + beacons.push_back( beacon ); + } + void BuildOsg( osg::Group* airport ); void BuildBtg( const string& root, const string_list& elev_src ); @@ -58,6 +69,8 @@ private: FeatureList features; RunwayList runways; LightingObjList lightobjects; + WindsockList windsocks; + BeaconList beacons; }; typedef std::vector <Airport *> AirportList; diff --git a/src/Airports/GenAirports850/linked_objects.cxx b/src/Airports/GenAirports850/linked_objects.cxx new file mode 100644 index 00000000..468ea40c --- /dev/null +++ b/src/Airports/GenAirports850/linked_objects.cxx @@ -0,0 +1,18 @@ +#include <simgear/math/sg_geodesy.hxx> +#include <simgear/debug/logstream.hxx> +#include "linked_objects.hxx" + +Windsock::Windsock( char* definition ) +{ + sscanf(definition, "%lf %lf %d", &lat, &lon, &lit); + + SG_LOG(SG_GENERAL, SG_DEBUG, "Read Windsock: (" << lon << "," << lat << ") lit: " << lit ); +} + +Beacon::Beacon( char* definition ) +{ + sscanf(definition, "%lf %lf %d", &lat, &lon, &code); + + SG_LOG(SG_GENERAL, SG_DEBUG, "Read Beacon: (" << lon << "," << lat << ") code: " << code ); +} + diff --git a/src/Airports/GenAirports850/linked_objects.hxx b/src/Airports/GenAirports850/linked_objects.hxx new file mode 100644 index 00000000..6a9cff1b --- /dev/null +++ b/src/Airports/GenAirports850/linked_objects.hxx @@ -0,0 +1,61 @@ +#ifndef _LINKED_OBJECTS_H_ +#define _LINKED_OBJECTS_H_ + +#include <stdio.h> +#include <stdlib.h> + +#include <Polygon/polygon.hxx> +#include <Polygon/superpoly.hxx> +#include <Geometry/point3d.hxx> + +#include "texparams.hxx" + +using std::string; + +class Windsock +{ +public: + Windsock(char* def); + + double lat; + double lon; + int lit; + + Point3D GetLoc() + { + return Point3D( lon, lat, 0.0f ); + } + + bool IsLit() + { + return (lit == 1) ? true : false; + } +}; + +typedef std::vector <Windsock *> WindsockList; + + +class Beacon +{ +public: + Beacon(char* def); + + double lat; + double lon; + int code; + + Point3D GetLoc() + { + return Point3D( lon, lat, 0.0f ); + } + + int GetCode() + { + return code; + } +}; + +typedef std::vector <Beacon *> BeaconList; + + +#endif diff --git a/src/Airports/GenAirports850/parser.cxx b/src/Airports/GenAirports850/parser.cxx index d6a09e42..5906363f 100644 --- a/src/Airports/GenAirports850/parser.cxx +++ b/src/Airports/GenAirports850/parser.cxx @@ -390,10 +390,14 @@ int Parser::ParseLine(char* line) case LIGHT_BEACON_CODE: SetState( STATE_PARSE_SIMPLE ); SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing light beacon: " << line); + cur_beacon = new Beacon(line); + cur_airport->AddBeacon( cur_beacon ); break; case WINDSOCK_CODE: SetState( STATE_PARSE_SIMPLE ); - SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing windsock: " << line); + SG_LOG(SG_GENERAL, SG_ALERT, "Parsing windsock: " << line); + cur_windsock = new Windsock(line); + cur_airport->AddWindsock( cur_windsock ); break; case TAXIWAY_SIGN: SetState( STATE_PARSE_SIMPLE ); diff --git a/src/Airports/GenAirports850/parser.hxx b/src/Airports/GenAirports850/parser.hxx index 11e8b4e4..cc892b71 100644 --- a/src/Airports/GenAirports850/parser.hxx +++ b/src/Airports/GenAirports850/parser.hxx @@ -90,6 +90,8 @@ private: LinearFeature* cur_feat; BezNode* prev_node; LightingObj* cur_object; + Windsock* cur_windsock; + Beacon* cur_beacon; AirportList airports;