#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sgstream.hxx>
#include <simgear/misc/strutils.hxx>
+#include <simgear/structure/exception.hxx>
#include <string>
#include "apt_loader.hxx"
+static FGPositioned::Type fptypeFromRobinType(int aType)
+{
+ switch (aType) {
+ case 1: return FGPositioned::AIRPORT;
+ case 16: return FGPositioned::SEAPORT;
+ case 17: return FGPositioned::HELIPORT;
+ default:
+ SG_LOG(SG_GENERAL, SG_ALERT, "unsupported type:" << aType);
+ throw sg_range_exception("Unsupported airport type", "fptypeFromRobinType");
+ }
+}
+
FGAirport* addAirport(FGAirportList *airports, const string& apt_id, const string& apt_name,
int rwy_count, double rwy_lat_accum, double rwy_lon_accum, double last_rwy_heading,
double apt_elev, SGGeod& tower, bool got_tower, int type)
tower = SGGeod::fromDegFt(lon + fudge_lon, lat + fudge_lat, apt_elev + tower_height);
}
+
+
return airports->add(apt_id, SGGeod::fromDegFt(lon, lat, apt_elev), tower, apt_name, false,
- type == 1/*airport*/, type == 16/*seaport*/, type == 17/*heliport*/);
+ fptypeFromRobinType(type));
}
// Load the airport data base from the specified aptdb file. The
int surface_code = atoi( token[10].c_str() );
FGRunway* rwy = new FGRunway(NULL, rwy_no, lon, lat, heading, length,
- width, displ_thresh1, stopway1, surface_code, false);
+ width, displ_thresh1, stopway1, surface_code, false);
FGRunway* reciprocal = new FGRunway(NULL, FGRunway::reverseIdent(rwy_no),
lon, lat, heading + 180.0, length, width,
displ_thresh2, stopway2, surface_code, true);
-
runways.push_back(rwy);
runways.push_back(reciprocal);
+
} else if ( line_id == 18 ) {
// beacon entry (ignore)
} else if ( line_id == 14 ) {
// add the last airport being processed if any
addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
- last_rwy_heading, last_apt_elev, last_tower, got_tower, 0);
+ last_rwy_heading, last_apt_elev, last_tower, got_tower, last_apt_type);
//
#include <simgear/compiler.h>
-#include <plib/sg.h>
-#include <plib/ul.h>
-
#include <Environment/environment_mgr.hxx>
#include <Environment/environment.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
-//#include <simgear/route/waypoint.hxx>
#include <simgear/debug/logstream.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Airports/runways.hxx>
#include <Airports/dynamics.hxx>
-#include <Airports/runways.hxx>
#include <string>
/***************************************************************************
* FGAirport
***************************************************************************/
-FGAirport::FGAirport() : _dynamics(0)
-{
-}
FGAirport::FGAirport(const string &id, const SGGeod& location, const SGGeod& tower_location,
- const string &name, bool has_metar, bool is_airport, bool is_seaport,
- bool is_heliport) :
- _id(id),
- _location(location),
+ const string &name, bool has_metar, Type aType) :
+ FGPositioned(aType, id, location),
_tower_location(tower_location),
_name(name),
_has_metar(has_metar),
- _is_airport(is_airport),
- _is_seaport(is_seaport),
- _is_heliport(is_heliport),
_dynamics(0)
{
}
delete _dynamics;
}
+bool FGAirport::isAirport() const
+{
+ return type() == AIRPORT;
+}
+
+bool FGAirport::isSeaport() const
+{
+ return type() == SEAPORT;
+}
+
+bool FGAirport::isHeliport() const
+{
+ return type() == HELIPORT;
+}
FGAirportDynamics * FGAirport::getDynamics()
{
{
Runway_iterator it = getIteratorForRunwayIdent(aIdent);
if (it == mRunways.end()) {
- SG_LOG(SG_GENERAL, SG_ALERT, "no such runway '" << aIdent << "' at airport " << _id);
- throw sg_range_exception("unknown runway " + aIdent + " at airport:" + _id, "FGAirport::getRunwayByIdent");
+ SG_LOG(SG_GENERAL, SG_ALERT, "no such runway '" << aIdent << "' at airport " << ident());
+ throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
}
return *it;
envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
}
- FGEnvironment stationWeather(envMgr->getEnvironment(_location));
+ FGEnvironment stationWeather(envMgr->getEnvironment(mPosition));
double windSpeed = stationWeather.get_wind_speed_kt();
double hdg = stationWeather.get_wind_from_heading_deg();
// add an entry to the list
FGAirport* FGAirportList::add( const string &id, const SGGeod& location, const SGGeod& tower_location,
- const string &name, bool has_metar, bool is_airport, bool is_seaport,
- bool is_heliport)
+ const string &name, bool has_metar, FGPositioned::Type aType)
{
- FGAirport* a = new FGAirport(id, location, tower_location, name, has_metar,
- is_airport, is_seaport, is_heliport);
-
+ FGAirport* a = new FGAirport(id, location, tower_location, name, has_metar, aType);
airports_by_id[a->getId()] = a;
// try and read in an auxilary file
#include <vector>
#include <simgear/math/point3d.hxx>
-
#include "Navaids/positioned.hxx"
// forward decls
/***************************************************************************************
*
**************************************************************************************/
-class FGAirport {
+class FGAirport : public FGPositioned
+{
private:
- std::string _id;
- SGGeod _location;
SGGeod _tower_location;
std::string _name;
bool _has_metar;
- bool _is_airport;
- bool _is_seaport;
- bool _is_heliport;
FGAirportDynamics *_dynamics;
public:
- FGAirport();
- // FGAirport(const FGAirport &other);
FGAirport(const std::string& id, const SGGeod& location, const SGGeod& tower,
- const std::string& name,
- bool has_metar, bool is_airport, bool is_seaport, bool is_heliport);
+ const std::string& name, bool has_metar, Type aType);
~FGAirport();
- const std::string& getId() const { return _id; }
+ const std::string& getId() const { return ident(); }
const std::string& getName() const { return _name; }
- double getLongitude() const { return _location.getLongitudeDeg(); }
+ double getLongitude() const { return longitude(); }
// Returns degrees
- double getLatitude() const { return _location.getLatitudeDeg(); }
+ double getLatitude() const { return latitude(); }
// Returns ft
- double getElevation() const { return _location.getElevationFt(); }
+ double getElevation() const { return elevation(); }
bool getMetar() const { return _has_metar; }
- bool isAirport() const { return _is_airport; }
- bool isSeaport() const { return _is_seaport; }
- bool isHeliport() const { return _is_heliport; }
+ bool isAirport() const;
+ bool isSeaport() const;
+ bool isHeliport() const;
const SGGeod& getTowerLocation() const { return _tower_location; }
- void setId(const std::string& id) { _id = id; }
void setMetar(bool value) { _has_metar = value; }
FGRunway* getActiveRunwayForUsage() const;
void addRunway(FGRunway* aRunway);
private:
typedef std::vector<FGRunwayPtr>::const_iterator Runway_iterator;
-
/**
* Helper to locate a runway by ident
*/
// add an entry to the list
FGAirport* add( const std::string& id, const SGGeod& location, const SGGeod& tower,
- const std::string& name, bool has_metar, bool is_airport,
- bool is_seaport, bool is_heliport );
+ const std::string& name, bool has_metar, FGPositioned::Type aType);
// search for the specified id.
// Returns NULL if unsucessfull.