diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index 9df251a0..d6938899 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -194,6 +194,16 @@ static tgContour calc_elevations( TGAptSurface &surf, return result; } +static double calc_elevation( TGAptSurface &surf, + const SGGeod& node, + double offset ) +{ + double elev = surf.query( node.getLongitudeDeg(), node.getLatitudeDeg() ); + elev += offset; + + return elev; +} + // Determine node elevations of each node of a TGPolygon based on the // provided TGAptSurface. Offset is added to the final elevation @@ -992,51 +1002,6 @@ 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 - SG_LOG(SG_GENERAL, SG_INFO, "Computing tower node elevations"); - point_list tower_nodes = calc_elevations( apt_surf, towers, 0.0 ); -#endif - - // calc windsock elevations: - SG_LOG(SG_GENERAL, SG_DEBUG, "Computing windsock node elevations"); - point_list ws_nodes; - ws_nodes.clear(); - for ( unsigned int i = 0; i < 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_DEBUG, "Computing beacon node elevations"); - point_list b_nodes; - b_nodes.clear(); - for ( unsigned int i = 0; i < beacons.size(); ++i ) - { - p = beacons[i]->GetLoc(); - b_nodes.push_back( p ); - } - point_list beacon_nodes = calc_elevations( apt_surf, b_nodes, 0.0 ); - - // calc taxiway sign elevations: - SG_LOG(SG_GENERAL, SG_DEBUG, "Computing taxiway sign node elevations"); - point_list ts_nodes; - ts_nodes.clear(); - for ( unsigned int i = 0; i < signs.size(); ++i ) - { - p = signs[i]->GetLoc(); - ts_nodes.push_back( p ); - } - point_list taxisigns_nodes = calc_elevations( apt_surf, ts_nodes, 0.0 ); - - // calc water runway buoys elevations: - SG_LOG(SG_GENERAL, SG_DEBUG, "Computing water buoy elevations"); - point_list buoy_nodes; - for ( unsigned int i = 0; i < waterrunways.size(); ++i ) - { - buoy_nodes = waterrunways[i]->TempGetAsPointList(); - } - point_list water_buoys_nodes = calc_elevations( apt_surf, buoy_nodes, 0.0 ); // add base skirt (to hide potential cracks) // this has to happen after we've calculated the node elevations @@ -1318,46 +1283,62 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) } #endif - // write out windsock references : TODO - save elevation data in the windsock object - for ( unsigned int i = 0; i < windsock_nodes.size(); ++i ) + SGGeod ref_geod; + // calc elevations and write out windsock references + SG_LOG(SG_GENERAL, SG_DEBUG, "Computing windsock node elevations"); + + for ( unsigned int i = 0; i < windsocks.size(); ++i ) { - if ( windsocks[i]->IsLit() ) + SGGeod ref_geod = windsocks[i]->GetLoc(); + ref_geod.setElevationM( calc_elevation( apt_surf, ref_geod, 0.0 ) ); + + if ( windsocks[i]->IsLit() ) { - write_index_shared( objpath, b, windsock_nodes[i], - "Models/Airport/windsock_lit.xml", - 0.0 ); + write_index_shared( objpath, b, ref_geod, + "Models/Airport/windsock_lit.xml", 0.0 ); } else { - write_index_shared( objpath, b, windsock_nodes[i], - "Models/Airport/windsock.xml", - 0.0 ); - } + write_index_shared( objpath, b, ref_geod, + "Models/Airport/windsock.xml", 0.0 ); + } } // write out beacon references - for ( unsigned int i = 0; i < beacon_nodes.size(); ++i ) + for ( unsigned int i = 0; i < beacons.size(); ++i ) { - write_index_shared( objpath, b, beacon_nodes[i], + ref_geod = beacons[i]->GetLoc(); + ref_geod.setElevationM( calc_elevation( apt_surf, ref_geod, 0.0 ) ); + + write_index_shared( objpath, b, ref_geod, "Models/Airport/beacon.xml", 0.0 ); } // write out taxiway signs references - for ( unsigned int i = 0; i < taxisigns_nodes.size(); ++i ) + for ( unsigned int i = 0; i < signs.size(); ++i ) { - write_object_sign( objpath, b, taxisigns_nodes[i], + ref_geod = signs[i]->GetLoc(); + ref_geod.setElevationM( calc_elevation( apt_surf, ref_geod, 0.0 ) ); + write_object_sign( objpath, b, ref_geod, signs[i]->GetDefinition(), signs[i]->GetHeading(), signs[i]->GetSize() ); } // write out water buoys - for ( unsigned int i = 0; i < water_buoys_nodes.size(); ++i ) + for ( unsigned int i = 0; i < waterrunways.size(); ++i ) { - write_index_shared( objpath, b, water_buoys_nodes[i], - "Models/Airport/water_rw_buoy.xml", - 0.0 ); + tgContour buoys = waterrunways[i]->GetBuoys(); + + for ( unsigned int j = 0; j < buoys.GetSize(); ++j ) + { + ref_geod = buoys.GetNode(j); + ref_geod.setElevationM( calc_elevation( apt_surf, ref_geod, 0.0 ) ); + write_index_shared( objpath, b, ref_geod, + "Models/Airport/water_rw_buoy.xml", + 0.0 ); + } } string holepath = root + "/AirportArea"; diff --git a/src/Airports/GenAirports850/linked_objects.hxx b/src/Airports/GenAirports850/linked_objects.hxx index 13dd9f1c..938122cd 100644 --- a/src/Airports/GenAirports850/linked_objects.hxx +++ b/src/Airports/GenAirports850/linked_objects.hxx @@ -5,10 +5,6 @@ #include <stdlib.h> #include <Polygon/polygon.hxx> -#include <Polygon/superpoly.hxx> -#include <Polygon/texparams.hxx> - -#include <Geometry/point3d.hxx> using std::string; @@ -21,9 +17,9 @@ public: double lon; int lit; - Point3D GetLoc() + SGGeod GetLoc() { - return Point3D( lon, lat, 0.0f ); + return SGGeod::fromDeg(lon, lat); } bool IsLit() @@ -44,9 +40,9 @@ public: double lon; int code; - Point3D GetLoc() + SGGeod GetLoc() { - return Point3D( lon, lat, 0.0f ); + return SGGeod::fromDeg(lon, lat); } int GetCode() @@ -69,9 +65,9 @@ public: int size; string sgn_def; - Point3D GetLoc() + SGGeod GetLoc() { - return Point3D( lon, lat, 0.0f ); + return SGGeod::fromDeg(lon, lat); } double GetHeading() diff --git a/src/Airports/GenAirports850/runway.cxx b/src/Airports/GenAirports850/runway.cxx index 32a1e318..0050cf44 100644 --- a/src/Airports/GenAirports850/runway.cxx +++ b/src/Airports/GenAirports850/runway.cxx @@ -60,7 +60,7 @@ WaterRunway::WaterRunway(char* definition) SG_LOG(SG_GENERAL, SG_DEBUG, "Read water runway: (" << lon[0] << "," << lat[0] << ") to (" << lon[1] << "," << lat[1] << ") width: " << width << " buoys = " << buoys ); } -tgContour WaterRunway::GetNodes() +tgContour WaterRunway::GetBuoys() { tgContour buoys_nodes; @@ -69,48 +69,18 @@ tgContour WaterRunway::GetNodes() // calculate runway heading and length SGGeodesy::inverse(GetStart(), GetEnd(), heading, az2, length); - // create a polygon for the outline and use it to calculate the point list - int divs = (int)(length / 100.0); + // create a contour with points every 100m tgContour area = gen_wgs84_area(GetStart(), GetEnd(), 0, 0, 0, width, heading, false); - Point3D pt, inc; - for ( unsigned int i = 0; i < area.GetSize(); ++i ) { - pt = Point3D::fromSGGeod( area.GetNode(i) ); - inc = ( Point3D::fromSGGeod( area.GetNode(i==3 ? 0 : i+1) ) - - Point3D::fromSGGeod( area.GetNode(i)) ) / divs; - - for ( int j = 0; j < divs; ++j) { - buoys_nodes.AddNode( pt.toSGGeod() ); - pt += inc; - } - } - } - return buoys_nodes; -} - -point_list WaterRunway::TempGetAsPointList() -{ - point_list buoys_nodes; - - if (buoys){ - double heading, az2, length; - // calculate runway heading and length - SGGeodesy::inverse(GetStart(), GetEnd(), heading, az2, length); - - // create a polygon for the outline and use it to calculate the point list - int divs = (int)(length / 100.0); - tgContour area = gen_wgs84_area(GetStart(), GetEnd(), - 0, 0, 0, width, heading, false); - Point3D pt, inc; - - for ( unsigned int i = 0; i < area.GetSize(); ++i ) { - pt = Point3D::fromSGGeod( area.GetNode( i ) ); - inc = ( Point3D::fromSGGeod( area.GetNode(i==3 ? 0 : i+1) ) - - Point3D::fromSGGeod( area.GetNode(i)) ) / divs; - for ( int j = 0; j < divs; ++j) { - buoys_nodes.push_back( pt ); - pt += inc; + double dist, course, cs; + SGGeodesy::inverse(area.GetNode(i), area.GetNode(i==3 ? 0 : i+1), course, cs, dist ); + int divs = (int)(dist / 100.0); + double step = dist/divs; + SGGeod pt = area.GetNode(i); + for (int j = 0; j < divs; ++j) { + pt = SGGeodesy::direct(pt, course, step ); + buoys_nodes.AddNode( pt ); } } } diff --git a/src/Airports/GenAirports850/runway.hxx b/src/Airports/GenAirports850/runway.hxx index 92d5b67c..4acf3330 100644 --- a/src/Airports/GenAirports850/runway.hxx +++ b/src/Airports/GenAirports850/runway.hxx @@ -5,9 +5,6 @@ #include <stdlib.h> #include <Polygon/polygon.hxx> -#include <Polygon/superpoly.hxx> -#include <Polygon/texparams.hxx> -#include <Geometry/point3d.hxx> #include "apt_math.hxx" @@ -188,8 +185,7 @@ class WaterRunway public: WaterRunway(char* def); - tgContour GetNodes(); - point_list TempGetAsPointList(); + tgContour GetBuoys(); SGGeod GetStart(void) { diff --git a/src/Lib/Output/output.cxx b/src/Lib/Output/output.cxx index 3fff04a3..47acb8cb 100644 --- a/src/Lib/Output/output.cxx +++ b/src/Lib/Output/output.cxx @@ -92,7 +92,7 @@ void write_index( const string& base, const SGBucket& b, const string& name ) // update index file (list of shared objects to be included in final // scenery build) void write_index_shared( const string &base, const SGBucket &b, - const Point3D &p, const string& name, + const SGGeod &p, const string& name, const double &heading ) { string dir = base + "/" + b.gen_base_path(); @@ -111,12 +111,12 @@ void write_index_shared( const string &base, const SGBucket &b, } fprintf( fp, "OBJECT_SHARED %s %.6f %.6f %.1f %.2f\n", name.c_str(), - p.lon(), p.lat(), p.elev(), heading ); + p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading ); fclose( fp ); } void write_object_sign( const string &base, const SGBucket &b, - const Point3D &p, const string& sign, + const SGGeod &p, const string& sign, const double &heading, const int &size) { string dir = base + "/" + b.gen_base_path(); @@ -135,7 +135,7 @@ void write_object_sign( const string &base, const SGBucket &b, } fprintf( fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %u\n", sign.c_str(), - p.lon(), p.lat(), p.elev(), heading, size ); + p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size ); fclose( fp ); } diff --git a/src/Lib/Output/output.hxx b/src/Lib/Output/output.hxx index 474a4335..1c34d663 100644 --- a/src/Lib/Output/output.hxx +++ b/src/Lib/Output/output.hxx @@ -50,13 +50,13 @@ void write_index( const std::string& base, const SGBucket& b, const std::string& // update index file (list of shared objects to be included in final // scenery build) void write_index_shared( const std::string &base, const SGBucket &b, - const Point3D &p, const std::string& name, + const SGGeod &p, const std::string& name, const double &heading ); // update index file (list of shared objects to be included in final // scenery build) void write_object_sign( const std::string &base, const SGBucket &b, - const Point3D &p, const std::string& sign, + const SGGeod &p, const std::string& sign, const double &heading, const int &size ); void write_boundary( const std::string& base, const SGBucket& b,