# include <config.h>
#endif
-#include <cmath> // fabs()
#include <cstdio> // sprintf()
#include <cstdlib> // atoi()
+#include <cassert>
#include <simgear/compiler.h>
-#include <simgear/debug/logstream.hxx>
-#include <Main/fg_props.hxx>
+
+#include <simgear/props/props.hxx>
#include <string>
-#include <map>
#include "runways.hxx"
-using std::istream;
-using std::multimap;
-using std::string;
+#include <Airports/simple.hxx>
+#include <Navaids/procedure.hxx>
+#include <Navaids/navrecord.hxx>
+#include <Navaids/PositionedBinding.hxx>
-/*
- * surface codes
- * 1 - asphalt
- * 2 - concrete
- * 3 - turf
- * 4 - dirt
- * 5 - gravel
- * 6 - asphalt helipad
- * 7 - concrete helipad
- * 8 - turf helipad
- * 9 - dirt helipad
- * 12 - lakebed
- */
-
-static FGPositioned::Type runwayTypeFromNumber(const std::string& aRwyNo)
-{
- return (aRwyNo[0] == 'x') ? FGPositioned::TAXIWAY : FGPositioned::RUNWAY;
-}
+using std::string;
static std::string cleanRunwayNo(const std::string& aRwyNo)
{
return result;
}
-FGRunway::FGRunway(FGAirport* aAirport, const string& rwy_no,
+FGRunway::FGRunway(FGAirport* aAirport, const string& aIdent,
const SGGeod& aGeod,
const double heading, const double length,
const double width,
const double stopway,
const int surface_code,
bool reciprocal) :
- FGPositioned(runwayTypeFromNumber(rwy_no), cleanRunwayNo(rwy_no), aGeod,
- (runwayTypeFromNumber(rwy_no) == FGPositioned::RUNWAY)),
+ FGRunwayBase(RUNWAY, cleanRunwayNo(aIdent), aGeod, heading, length, width, surface_code, true),
_airport(aAirport),
- _reciprocal(reciprocal)
+ _isReciprocal(reciprocal),
+ _reciprocal(NULL),
+ _displ_thresh(displ_thresh),
+ _stopway(stopway),
+ _ils(NULL)
{
- _heading = heading;
- _length = length;
- _width = width;
- _displ_thresh = displ_thresh;
- _stopway = stopway;
-
- _surface_code = surface_code;
}
string FGRunway::reverseIdent(const string& aRunwayIdent)
return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + 1e-20;
}
-bool FGRunway::isTaxiway() const
+SGGeod FGRunway::begin() const
{
- return (type() == TAXIWAY);
+ return pointOnCenterline(0.0);
+}
+
+SGGeod FGRunway::end() const
+{
+ return pointOnCenterline(lengthM());
}
SGGeod FGRunway::threshold() const
{
- return pointOnCenterline(0.0);
+ return pointOnCenterline(_displ_thresh * SG_FEET_TO_METER);
}
-SGGeod FGRunway::reverseThreshold() const
+void FGRunway::processThreshold(SGPropertyNode* aThreshold)
{
- return pointOnCenterline(lengthM());
+ assert(ident() == aThreshold->getStringValue("rwy"));
+
+ double lon = aThreshold->getDoubleValue("lon"),
+ lat = aThreshold->getDoubleValue("lat");
+ SGGeod newThreshold(SGGeod::fromDegM(lon, lat, mPosition.getElevationM()));
+
+ _heading = aThreshold->getDoubleValue("hdg-deg");
+ _displ_thresh = aThreshold->getDoubleValue("displ-m") * SG_METER_TO_FEET;
+ _stopway = aThreshold->getDoubleValue("stopw-m") * SG_METER_TO_FEET;
+
+ // compute the new runway center, based on the threshold lat/lon and length,
+ double offsetFt = (0.5 * _length);
+ SGGeod newCenter;
+ double dummy;
+ SGGeodesy::direct(newThreshold, _heading, offsetFt * SG_FEET_TO_METER, newCenter, dummy);
+ mPosition = newCenter;
+}
+
+void FGRunway::setReciprocalRunway(FGRunway* other)
+{
+ assert(_reciprocal==NULL);
+ assert((other->_reciprocal == NULL) || (other->_reciprocal == this));
+
+ _reciprocal = other;
}
-SGGeod FGRunway::displacedThreshold() const
+std::vector<flightgear::SID*> FGRunway::getSIDs()
{
- return pointOnCenterline(_displ_thresh * SG_FEET_TO_METER);
+ std::vector<flightgear::SID*> result;
+ for (unsigned int i=0; i<_airport->numSIDs(); ++i) {
+ flightgear::SID* s = _airport->getSIDByIndex(i);
+ if (s->isForRunway(this)) {
+ result.push_back(s);
+ }
+ } // of SIDs at the airport iteration
+
+ return result;
}
-SGGeod FGRunway::pointOnCenterline(double aOffset) const
+std::vector<flightgear::STAR*> FGRunway::getSTARs()
{
- SGGeod result;
- double dummyAz2;
- double halfLengthMetres = lengthM() * 0.5;
+ std::vector<flightgear::STAR*> result;
+ for (unsigned int i=0; i<_airport->numSTARs(); ++i) {
+ flightgear::STAR* s = _airport->getSTARByIndex(i);
+ if (s->isForRunway(this)) {
+ result.push_back(s);
+ }
+ } // of STARs at the airport iteration
- SGGeodesy::direct(mPosition, _heading,
- aOffset - halfLengthMetres,
- result, dummyAz2);
return result;
}
-bool FGRunway::isHardSurface() const
+flightgear::PositionedBinding*
+FGRunway::createBinding(SGPropertyNode* nd) const
{
- return ((_surface_code == 1) || (_surface_code == 2));
+ return new flightgear::RunwayBinding(this, nd);
}