From e9a266fdf1cdb9d4baa1fad653058f579307625b Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Thu, 6 Oct 2011 15:18:00 +0200 Subject: [PATCH] Helipads are also back, including some light --- src/Airports/GenAirports850/CMakeLists.txt | 1 + src/Airports/GenAirports850/airport.cxx | 9 ++ src/Airports/GenAirports850/airport.hxx | 7 ++ src/Airports/GenAirports850/heli_gen.cxx | 70 ----------- src/Airports/GenAirports850/heli_gen.hxx | 49 -------- src/Airports/GenAirports850/helipad.cxx | 134 +++++++++++++++++++++ src/Airports/GenAirports850/helipad.hxx | 68 +++++++++++ src/Airports/GenAirports850/lights.cxx | 44 ------- src/Airports/GenAirports850/parser.cxx | 5 + src/Airports/GenAirports850/parser.hxx | 1 + src/Airports/GenAirports850/rwy_gen.hxx | 49 -------- 11 files changed, 225 insertions(+), 212 deletions(-) delete mode 100644 src/Airports/GenAirports850/heli_gen.cxx delete mode 100644 src/Airports/GenAirports850/heli_gen.hxx create mode 100644 src/Airports/GenAirports850/helipad.cxx create mode 100644 src/Airports/GenAirports850/helipad.hxx delete mode 100644 src/Airports/GenAirports850/rwy_gen.hxx diff --git a/src/Airports/GenAirports850/CMakeLists.txt b/src/Airports/GenAirports850/CMakeLists.txt index 5564688a..64cc6e41 100644 --- a/src/Airports/GenAirports850/CMakeLists.txt +++ b/src/Airports/GenAirports850/CMakeLists.txt @@ -7,6 +7,7 @@ add_executable(genapts850 convex_hull.hxx convex_hull.cxx elevations.cxx elevations.hxx global.hxx + helipad.hxx helipad.cxx lights.cxx linearfeature.hxx linearfeature.cxx linked_objects.hxx linked_objects.cxx diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index c06031d4..73f1b71e 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -1,5 +1,6 @@ #include "beznode.hxx" #include "runway.hxx" +#include "helipad.hxx" #include "airport.hxx" #include @@ -391,6 +392,14 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) } } + // Build helipads (use runway poly- and texture list for this) + if (helipads.size()) + { + for (i=0; iBuildBtg( altitude, &rwy_polys, &rwy_tps, &rwy_lights, &accum, &apt_base, &apt_clearing ); + } + } // Build the pavements if (pavements.size()) { diff --git a/src/Airports/GenAirports850/airport.hxx b/src/Airports/GenAirports850/airport.hxx index ec3d920f..5dbaa4d1 100644 --- a/src/Airports/GenAirports850/airport.hxx +++ b/src/Airports/GenAirports850/airport.hxx @@ -6,6 +6,7 @@ #include "runway.hxx" #include "object.hxx" +#include "helipad.hxx" #include "closedpoly.hxx" #include "linearfeature.hxx" #include "linked_objects.hxx" @@ -27,6 +28,11 @@ public: lightobjects.push_back( lightobj ); } + void AddHelipad( Helipad* helipad ) + { + helipads.push_back( helipad ); + } + void AddPavement( ClosedPoly* pavement ) { pavements.push_back( pavement ); @@ -71,6 +77,7 @@ private: LightingObjList lightobjects; WindsockList windsocks; BeaconList beacons; + HelipadList helipads; }; typedef std::vector AirportList; diff --git a/src/Airports/GenAirports850/heli_gen.cxx b/src/Airports/GenAirports850/heli_gen.cxx deleted file mode 100644 index 0902b4d0..00000000 --- a/src/Airports/GenAirports850/heli_gen.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// rwy_gen.cxx -- Build a runway -// -// Written by Curtis Olson, started February 2002. -// -// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// - -#include -#include -#include - -#include "rwy_common.hxx" - -#include - -using std::string; - - -void gen_heli( const TGRunway& rwy_info, - double alt_m, - const string& material, - superpoly_list *rwy_polys, - texparams_list *texparams, - TGPolygon *accum ) -{ - SG_LOG( SG_GENERAL, SG_INFO, "Building helipad = " << rwy_info.rwy_no1 ); - - // - // Generate the basic helipad outlines - // - Point3D helicenter = Point3D( rwy_info.lon, rwy_info.lat, 0.0); - - TGPolygon helipad = gen_wgs84_area( helicenter, rwy_info.length, 0, 0, rwy_info.width, rwy_info.heading, - alt_m, false); - - double start1_pct = 0.0; - double end1_pct = 0.0; - double maxsize = rwy_info.width - rwy_info.length; - - if (maxsize <= 0) - maxsize = rwy_info.width; - else if (maxsize > 0) - maxsize = rwy_info.length; - - double percent = (maxsize / rwy_info.length) /2; - - start1_pct = 0.5 - percent; - end1_pct = 0.5 + percent; - gen_runway_section( rwy_info, helipad, - start1_pct, end1_pct, - 0.0, 1.0, - 0.0, 1.0, 0.0, 1.0, - rwy_info.heading, - material, "heli", - rwy_polys, texparams, accum ); -} diff --git a/src/Airports/GenAirports850/heli_gen.hxx b/src/Airports/GenAirports850/heli_gen.hxx deleted file mode 100644 index b2c770f4..00000000 --- a/src/Airports/GenAirports850/heli_gen.hxx +++ /dev/null @@ -1,49 +0,0 @@ -// rwy_gen.hxx -- Build a runway -// -// Written by Curtis Olson, started February 2002. -// -// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// $Id: rwy_prec.hxx,v 1.5 2004-11-19 22:25:49 curt Exp $ -// - - -#ifndef _HELI_GEN_HXX -#define _HELI_GEN_HXX - - -#include -#include - -#include "runway.hxx" -#include "texparams.hxx" - - -// generate a runway. The routine modifies -// rwy_polys, texparams, and accum. For specific details and -// dimensions of precision runway markings, please refer to FAA -// document AC 150/5340-1H - -void gen_heli( const TGRunway& rwy_info, - double alt_m, - const std::string& material, - superpoly_list *rwy_polys, - texparams_list *texparams, - TGPolygon *accum ); - - -#endif // _RWY_PREC_HXX diff --git a/src/Airports/GenAirports850/helipad.cxx b/src/Airports/GenAirports850/helipad.cxx new file mode 100644 index 00000000..28b094a7 --- /dev/null +++ b/src/Airports/GenAirports850/helipad.cxx @@ -0,0 +1,134 @@ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include +#include +#include +#include + +#include "apt_math.hxx" +#include "helipad.hxx" +#include "runway.hxx" + +#include + +Helipad::Helipad(char* definition) +{ + + // format: + // helipad designator lat lon heading length width surface markings shoulder smoothness edge lighting + + // int fscanf(FILE *stream, const char *format, ...); + sscanf(definition, "%s %lf %lf %lf %lf %lf %d %d %d %lf %d", + &heli.designator, &heli.lat, &heli.lon, &heli.heading, &heli.length, &heli.width, &heli.surface, + &heli.marking, &heli.shoulder, &heli.smoothness, &heli.edge_lights); + + SG_LOG(SG_GENERAL, SG_DEBUG, "Read helipad: (" << heli.lon << "," << heli.lat << ") heading: " << heli.heading << " length: " << heli.length << " width: " << heli.width ); +} + +superpoly_list Helipad::gen_helipad_lights(void){ + + point_list c_lights; c_lights.clear(); + point_list c_normals; c_normals.clear(); + double lat2, lon2, az2; + + // Create a circle of lights approx. where the white circle is + for (int deg=0; deg<360; deg+=10){ + geo_direct_wgs_84(0, heli.lat, heli.lon, deg , + heli.width * 0.46 , &lat2, &lon2, &az2 ); + + c_lights.push_back( Point3D( lon2, lat2, 0.0 ) ); + + Point3D tmp = Point3D( lon2, lat2, 0.0 ); + Point3D vec = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS ); + double length = vec.distance3D( Point3D(0.0) ); + vec = vec / length; + c_normals.push_back( vec ); + } + + TGPolygon lights_poly; lights_poly.erase(); + TGPolygon normals_poly; normals_poly.erase(); + lights_poly.add_contour( c_lights, false ); + normals_poly.add_contour( c_normals, false ); + + TGSuperPoly green; + green.set_poly( lights_poly ); + green.set_normals( normals_poly ); + green.set_material( "RWY_GREEN_LIGHTS" ); + + superpoly_list result; result.clear(); + + result.push_back( green ); + + return result; +} + +void Helipad::BuildBtg( float alt_m, + superpoly_list *rwy_polys, + texparams_list *texparams, + superpoly_list *rwy_lights, + TGPolygon *accum, TGPolygon* apt_base, TGPolygon* apt_clearing ) +{ + SG_LOG( SG_GENERAL, SG_INFO, "Building helipad = " << heli.designator ); + + // + // Generate the basic helipad outlines + // + Point3D helicenter = Point3D( heli.lon, heli.lat, 0.0); + + + TGPolygon helipad = gen_wgs84_area( helicenter, heli.length, 0, 0, heli.width, heli.heading, alt_m, false); + + double start1_pct = 0.0; + double end1_pct = 0.0; + double maxsize = heli.width - heli.length; + + if (maxsize <= 0) + maxsize = heli.width; + else if (maxsize > 0) + maxsize = heli.length; + + double percent = (maxsize / heli.length) /2; + + start1_pct = 0.5 - percent; + end1_pct = 0.5 + percent; + gen_tex_section( helipad, + start1_pct, end1_pct, + 0.0, 1.0, + 0.0, 1.0, 0.0, 1.0, + heli.heading, heli.width, heli.length, + "pc_", "heli", + rwy_polys, texparams, accum ); + + + // generate area around helipad + TGPolygon base, safe_base; + base = gen_runway_area_w_extend( 0.0, maxsize * 0.25 , 0.0, 0.0, maxsize * 0.25 ); + + // also clear a safe area around the pad + safe_base = gen_runway_area_w_extend( 0.0, maxsize * 0.5, 0.0, 0.0, maxsize * 0.5 ); + + // add this to the airport clearing + *apt_clearing = tgPolygonUnion(safe_base, *apt_clearing); + + // and add the clearing to the base + *apt_base = tgPolygonUnion( base, *apt_base ); + + // Now generate the helipad lights + superpoly_list s = gen_helipad_lights(); + for ( int i = 0; i < s.size(); ++i ) { + rwy_lights->push_back( s[i] ); + } +} diff --git a/src/Airports/GenAirports850/helipad.hxx b/src/Airports/GenAirports850/helipad.hxx new file mode 100644 index 00000000..8edf67c8 --- /dev/null +++ b/src/Airports/GenAirports850/helipad.hxx @@ -0,0 +1,68 @@ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + +#ifndef _HELIPAD_HXX +#define _HELIPAD_HXX + +#include +#include + +#include +#include + +#include "texparams.hxx" + +class Helipad +{ +public: + Helipad(char* def); + void BuildBtg( float alt_m, superpoly_list* heli_polys, texparams_list* texparams, superpoly_list* heli_lights, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ); + +private: + struct TGRunway { + // data for whole runway + int surface; + int shoulder; + int edge_lights; + + double width; + double length; + double heading; + double smoothness; + + // data for each end + char designator[16]; + double lat; + double lon; + + int marking; + }; + + TGRunway heli; + + // generate an area for a runway with expansion specified in meters + // (return result points in degrees) + TGPolygon gen_runway_area_w_extend( double alt_m, double length_extend, double displ1, double displ2, double width_extend ) + { + return ( gen_wgs84_area(Point3D(heli.lon, heli.lat, 0.0f), heli.length + 2.0*length_extend, displ1, displ2, heli.width + 2.0*width_extend, heli.heading, alt_m, false) ); + } + + superpoly_list gen_helipad_lights(void); + +}; + +typedef std::vector HelipadList; + +#endif diff --git a/src/Airports/GenAirports850/lights.cxx b/src/Airports/GenAirports850/lights.cxx index ec421631..ff38c137 100644 --- a/src/Airports/GenAirports850/lights.cxx +++ b/src/Airports/GenAirports850/lights.cxx @@ -83,44 +83,6 @@ Point3D Runway::gen_runway_light_vector( double angle, bool recip ) { return light_vec; } -/*static superpoly_list gen_helipad_lights(const TGRunway& rwy_info){ - - point_list c_lights; c_lights.clear(); - point_list c_normals; c_normals.clear(); - double lat2, lon2, az2; - - // Create a circle of lights approx. where the white circle is - for (int deg=0; deg<360; deg+=30){ - geo_direct_wgs_84(0, rwy_info.lat, rwy_info.lon, deg , - rwy_info.width * 0.46 , &lat2, &lon2, &az2 ); - - c_lights->push_back( Point3D( lon2, lat2, 0.0 ) ); - - Point3D tmp = Point3D( lon2, lat2, 0.0 ); - Point3D vec = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS ); - double length = vec.distance3D( Point3D(0.0) ); - vec = vec / length; - c_normals.push_back( vec ); - } - - TGPolygon lights_poly; lights_poly.erase(); - TGPolygon normals_poly; normals_poly.erase(); - lights_poly.add_contour( c_lights, false ); - normals_poly.add_contour( c_normals, false ); - - TGSuperPoly green; - green.set_poly( lights_poly ); - green.set_normals( normals_poly ); - green.set_material( "RWY_GREEN_LIGHTS" ); - - superpoly_list result; result.clear(); - - result.push_back( green ); - - return result; -}*/ - - // generate runway edge lighting // 60 meters spacing or the next number down that divides evenly. superpoly_list Runway::gen_runway_edge_lights( bool recip ) @@ -2634,12 +2596,6 @@ void Runway::gen_runway_lights( float alt_m, superpoly_list *lights, TGPolygon * lights->push_back( s[i] ); } } -/* if ( rwy_info.type == 102){ - superpoly_list s = gen_helipad_lights( rwy_info ); - for ( i = 0; i < s.size(); ++i ) { - lights->push_back( s[i] ); - } - }*/ // Centerline lighting if ( rwy.centerline_lights == 1 /* Has centerline lighting */ ) { diff --git a/src/Airports/GenAirports850/parser.cxx b/src/Airports/GenAirports850/parser.cxx index 5906363f..2a6bfa2b 100644 --- a/src/Airports/GenAirports850/parser.cxx +++ b/src/Airports/GenAirports850/parser.cxx @@ -273,6 +273,11 @@ int Parser::ParseLine(char* line) case HELIPAD_CODE: SetState( STATE_PARSE_SIMPLE ); SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing helipad: " << line); + cur_helipad = new Helipad(line); + if (cur_airport) + { + cur_airport->AddHelipad( cur_helipad ); + } break; case PAVEMENT_CODE: diff --git a/src/Airports/GenAirports850/parser.hxx b/src/Airports/GenAirports850/parser.hxx index cc892b71..c3579168 100644 --- a/src/Airports/GenAirports850/parser.hxx +++ b/src/Airports/GenAirports850/parser.hxx @@ -86,6 +86,7 @@ private: // (first is outside boundry, remaining are holes) Airport* cur_airport; Runway* cur_runway; + Helipad* cur_helipad; ClosedPoly* cur_pavement; LinearFeature* cur_feat; BezNode* prev_node; diff --git a/src/Airports/GenAirports850/rwy_gen.hxx b/src/Airports/GenAirports850/rwy_gen.hxx deleted file mode 100644 index 6cd28927..00000000 --- a/src/Airports/GenAirports850/rwy_gen.hxx +++ /dev/null @@ -1,49 +0,0 @@ -// rwy_gen.hxx -- Build a runway -// -// Written by Curtis Olson, started February 2002. -// -// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// $Id: rwy_prec.hxx,v 1.5 2004-11-19 22:25:49 curt Exp $ -// - - -#ifndef _RWY_PREC_HXX -#define _RWY_PREC_HXX - - -#include -#include - -#include "runway.hxx" -#include "texparams.hxx" - - -// generate a runway. The routine modifies -// rwy_polys, texparams, and accum. For specific details and -// dimensions of precision runway markings, please refer to FAA -// document AC 150/5340-1H - -void gen_rwy( const TGRunway& rwy_info, - double alt_m, - const std::string& material, - superpoly_list *rwy_polys, - texparams_list *texparams, - TGPolygon *accum ); - - -#endif // _RWY_PREC_HXX