1999-02-26 22:08:34 +00:00
|
|
|
// simple.hxx -- a really simplistic class to manage airport ID,
|
2006-07-10 11:36:38 +00:00
|
|
|
// lat, lon of the center of one of it's runways, and
|
1998-08-25 17:19:13 +00:00
|
|
|
// elevation in feet.
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started April 1998.
|
2005-02-10 09:01:51 +00:00
|
|
|
// Updated by Durk Talsma, started December 2004.
|
1998-08-25 17:19:13 +00:00
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
|
1998-08-25 17:19:13 +00:00
|
|
|
//
|
|
|
|
// 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
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1998-08-25 17:19:13 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
2003-08-28 20:53:08 +00:00
|
|
|
#ifndef _FG_SIMPLE_HXX
|
|
|
|
#define _FG_SIMPLE_HXX
|
1998-08-25 17:19:13 +00:00
|
|
|
|
2000-02-15 03:30:01 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2008-07-25 18:38:29 +00:00
|
|
|
#include <string>
|
2003-11-27 23:37:03 +00:00
|
|
|
#include <vector>
|
2000-05-27 05:54:02 +00:00
|
|
|
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
#include "Navaids/positioned.hxx"
|
2005-10-18 18:44:37 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
// forward decls
|
|
|
|
class FGAirportDynamics;
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
class FGRunway;
|
2008-12-29 22:23:22 +00:00
|
|
|
class FGTaxiway;
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
|
|
|
|
typedef SGSharedPtr<FGRunway> FGRunwayPtr;
|
2008-12-29 22:23:22 +00:00
|
|
|
typedef SGSharedPtr<FGTaxiway> FGTaxiwayPtr;
|
2005-10-18 18:44:37 +00:00
|
|
|
|
|
|
|
/***************************************************************************************
|
|
|
|
*
|
|
|
|
**************************************************************************************/
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
class FGAirport : public FGPositioned
|
|
|
|
{
|
2005-02-10 09:01:51 +00:00
|
|
|
private:
|
2007-09-09 23:21:48 +00:00
|
|
|
SGGeod _tower_location;
|
2008-08-14 18:13:39 +00:00
|
|
|
std::string _name;
|
2006-07-10 11:36:38 +00:00
|
|
|
bool _has_metar;
|
2007-10-05 12:59:43 +00:00
|
|
|
FGAirportDynamics *_dynamics;
|
2005-10-25 13:49:55 +00:00
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
public:
|
2008-08-14 18:13:39 +00:00
|
|
|
FGAirport(const std::string& id, const SGGeod& location, const SGGeod& tower,
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
const std::string& name, bool has_metar, Type aType);
|
2006-07-10 11:36:38 +00:00
|
|
|
~FGAirport();
|
|
|
|
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
const std::string& getId() const { return ident(); }
|
2008-08-14 18:13:39 +00:00
|
|
|
const std::string& getName() const { return _name; }
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
double getLongitude() const { return longitude(); }
|
2006-07-10 11:36:38 +00:00
|
|
|
// Returns degrees
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
double getLatitude() const { return latitude(); }
|
2006-07-10 11:36:38 +00:00
|
|
|
// Returns ft
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
double getElevation() const { return elevation(); }
|
2006-07-10 11:36:38 +00:00
|
|
|
bool getMetar() const { return _has_metar; }
|
James Turner:
Trivial patch, but an important milestone:
Convert FGAirport to inherit FGPositioned. This concludes the first phase of the FGPositioned changes, and hopefully the most intrusive ones - adding in the base class. There's lots (and lots) of further work to do on the indexing and querying side, as well as cleaning up the accessors, but that will happen in single source files, or a group of related files at a time.
As a trivial note, this patch does fix a bug where the very last airport in apt.dat would get an invalid type. So for all you people who just love to fly to EHYB (Ypenburg, The Hague), things may work a little more sanely.
I'll intentionally let the dust settle after this patch, so any weird behaviour I may potentially have introduced shows up. Just to re-iterate, so far there should be absolutely no user-visible change in the behaviour of anything - navaids, position init, the route manager, AI flight plans, etc. If there is, please let me know and I'll fix it ASAP.
2008-09-13 08:07:22 +00:00
|
|
|
bool isAirport() const;
|
|
|
|
bool isSeaport() const;
|
|
|
|
bool isHeliport() const;
|
2006-07-10 11:36:38 +00:00
|
|
|
|
2008-12-25 23:11:43 +00:00
|
|
|
virtual const std::string& name() const
|
|
|
|
{ return _name; }
|
|
|
|
|
2007-09-09 23:21:48 +00:00
|
|
|
const SGGeod& getTowerLocation() const { return _tower_location; }
|
|
|
|
|
2006-07-10 11:36:38 +00:00
|
|
|
void setMetar(bool value) { _has_metar = value; }
|
|
|
|
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
FGRunway* getActiveRunwayForUsage() const;
|
2006-07-10 11:36:38 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
FGAirportDynamics *getDynamics();
|
|
|
|
|
|
|
|
unsigned int numRunways() const;
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
FGRunway* getRunwayByIndex(unsigned int aIndex) const;
|
2008-08-14 18:13:39 +00:00
|
|
|
|
|
|
|
bool hasRunwayWithIdent(const std::string& aIdent) const;
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
FGRunway* getRunwayByIdent(const std::string& aIdent) const;
|
|
|
|
FGRunway* findBestRunwayForHeading(double aHeading) const;
|
2008-08-14 18:13:39 +00:00
|
|
|
|
2008-12-23 12:37:59 +00:00
|
|
|
/**
|
|
|
|
* Useful predicate for FMS/GPS/NAV displays and similar - check if this
|
|
|
|
* aiport has a hard-surfaced runway of at least the specified length.
|
|
|
|
*/
|
|
|
|
bool hasHardRunwayOfLengthFt(double aLengthFt) const;
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
unsigned int numTaxiways() const;
|
2008-12-29 22:23:22 +00:00
|
|
|
FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
|
2008-08-14 18:13:39 +00:00
|
|
|
|
2008-12-29 22:23:22 +00:00
|
|
|
void setRunwaysAndTaxiways(std::vector<FGRunwayPtr>& rwys,
|
|
|
|
std::vector<FGTaxiwayPtr>& txwys);
|
2008-12-23 12:37:59 +00:00
|
|
|
|
|
|
|
class AirportFilter : public Filter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool pass(FGPositioned* aPos) const {
|
|
|
|
Type ty(aPos->type());
|
|
|
|
return (ty >= AIRPORT) && (ty <= SEAPORT);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class HardSurfaceFilter : public Filter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HardSurfaceFilter(double minLengthFt);
|
|
|
|
|
|
|
|
virtual bool pass(FGPositioned* aPos) const;
|
|
|
|
private:
|
|
|
|
double mMinLengthFt;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Syntactic wrapper around FGPositioned::findClosest - find the closest
|
|
|
|
* match for filter, and return it cast to FGAirport. The default filter
|
|
|
|
* passes all airports, including seaports and heliports.
|
|
|
|
*/
|
|
|
|
static FGAirport* findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter = NULL);
|
2008-12-26 15:26:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to look up an FGAirport instance by unique ident. Throws an
|
|
|
|
* exception if the airport could not be found - so callers can assume
|
|
|
|
* the result is non-NULL.
|
|
|
|
*/
|
|
|
|
static FGAirport* getByIdent(const std::string& aIdent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to look up an FGAirport instance by unique ident. Returns NULL
|
|
|
|
* if the airport could not be found.
|
|
|
|
*/
|
|
|
|
static FGAirport* findByIdent(const std::string& aIdent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specialised helper to implement the AirportList dialog. Performs a
|
|
|
|
* case-insensitive search on airport names and ICAO codes, and returns
|
|
|
|
* matches in a format suitable for use by a puaList.
|
|
|
|
*/
|
|
|
|
static char** searchNamesAndIdents(const std::string& aFilter);
|
2005-12-29 13:58:21 +00:00
|
|
|
private:
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
typedef std::vector<FGRunwayPtr>::const_iterator Runway_iterator;
|
2008-08-14 18:13:39 +00:00
|
|
|
/**
|
|
|
|
* Helper to locate a runway by ident
|
|
|
|
*/
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
Runway_iterator getIteratorForRunwayIdent(const std::string& aIdent) const;
|
2008-08-14 18:13:39 +00:00
|
|
|
|
2006-07-10 11:36:38 +00:00
|
|
|
FGAirport operator=(FGAirport &other);
|
|
|
|
FGAirport(const FGAirport&);
|
2008-08-14 18:13:39 +00:00
|
|
|
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
std::vector<FGRunwayPtr> mRunways;
|
2008-12-29 22:23:22 +00:00
|
|
|
std::vector<FGTaxiwayPtr> mTaxiways;
|
1998-09-01 19:02:53 +00:00
|
|
|
};
|
1998-08-25 17:19:13 +00:00
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
// find basic airport location info from airport database
|
2008-08-14 18:13:39 +00:00
|
|
|
const FGAirport *fgFindAirportID( const std::string& id);
|
2005-12-29 13:58:21 +00:00
|
|
|
|
|
|
|
// get airport elevation
|
2008-08-14 18:13:39 +00:00
|
|
|
double fgGetAirportElev( const std::string& id );
|
2005-12-29 13:58:21 +00:00
|
|
|
|
2003-08-28 20:53:08 +00:00
|
|
|
#endif // _FG_SIMPLE_HXX
|
1998-08-25 17:19:13 +00:00
|
|
|
|
|
|
|
|