]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/runways.cxx
httpd: provide more airport information in geojson
[flightgear.git] / src / Airports / runways.cxx
index 72fb1609d47cf2044473bd50600126cb9644ef7d..9f2291f7ba90f31f10f31da246a4a978975572d4 100644 (file)
@@ -51,12 +51,10 @@ FGRunway::FGRunway(PositionedID aGuid,
                         const double width,
                         const double displ_thresh,
                         const double stopway,
-                        const int surface_code,
-                        bool reciprocal) :
+                        const int surface_code) :
   FGRunwayBase(aGuid, RUNWAY, aIdent, aGeod,
                heading, length, width, surface_code),
   _airport(aAirport),
-  _isReciprocal(reciprocal),
   _reciprocal(0),
   _displ_thresh(displ_thresh),
   _stopway(stopway),
@@ -98,15 +96,17 @@ string FGRunway::reverseIdent(const string& aRunwayIdent)
   return buf;
 }
 
-double FGRunway::score(double aLengthWt, double aWidthWt, double aSurfaceWt) const
+double FGRunway::score(double aLengthWt, double aWidthWt, double aSurfaceWt, double aIlsWt) const
 {
   int surface = 1;
   if (_surface_code == 12 || _surface_code == 5) // dry lakebed & gravel
     surface = 2;
   else if (_surface_code == 1 || _surface_code == 2) // asphalt & concrete
     surface = 3;
+
+  int ils = (_ils != 0);
     
-  return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + 1e-20;
+  return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + ils * aIlsWt + 1e-20;
 }
 
 SGGeod FGRunway::begin() const
@@ -121,7 +121,7 @@ SGGeod FGRunway::end() const
 
 SGGeod FGRunway::threshold() const
 {
-  return pointOnCenterline(_displ_thresh * SG_FEET_TO_METER);
+  return pointOnCenterline(_displ_thresh);
 }
 
 void FGRunway::setReciprocalRunway(PositionedID other)
@@ -132,12 +132,12 @@ void FGRunway::setReciprocalRunway(PositionedID other)
 
 FGAirport* FGRunway::airport() const
 {
-  return (FGAirport*) flightgear::NavDataCache::instance()->loadById(_airport);
+  return loadById<FGAirport>(_airport);
 }
 
 FGRunway* FGRunway::reciprocalRunway() const
 {
-  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(_reciprocal);
+  return loadById<FGRunway>(_reciprocal);
 }
 
 FGNavRecord* FGRunway::ILS() const
@@ -146,7 +146,7 @@ FGNavRecord* FGRunway::ILS() const
     return NULL;
   }
   
-  return (FGNavRecord*) flightgear::NavDataCache::instance()->loadById(_ils);
+  return loadById<FGNavRecord>(_ils);
 }
 
 FGNavRecord* FGRunway::glideslope() const
@@ -157,13 +157,13 @@ FGNavRecord* FGRunway::glideslope() const
     return NULL;
   }
   
-  return (FGNavRecord*) cache->loadById(gsId);
+  return loadById<FGNavRecord>(gsId);
 }
 
-std::vector<flightgear::SID*> FGRunway::getSIDs() const
+flightgear::SIDList FGRunway::getSIDs() const
 {
   FGAirport* apt = airport();
-  std::vector<flightgear::SID*> result;
+  flightgear::SIDList result;
   for (unsigned int i=0; i<apt->numSIDs(); ++i) {
     flightgear::SID* s = apt->getSIDByIndex(i);
     if (s->isForRunway(this)) {
@@ -174,10 +174,10 @@ std::vector<flightgear::SID*> FGRunway::getSIDs() const
   return result;
 }
 
-std::vector<flightgear::STAR*> FGRunway::getSTARs() const
+flightgear::STARList FGRunway::getSTARs() const
 {
   FGAirport* apt = airport();
-  std::vector<flightgear::STAR*> result;
+  flightgear::STARList result;
   for (unsigned int i=0; i<apt->numSTARs(); ++i) {
     flightgear::STAR* s = apt->getSTARByIndex(i);
     if (s->isForRunway(this)) {
@@ -188,13 +188,17 @@ std::vector<flightgear::STAR*> FGRunway::getSTARs() const
   return result;
 }
 
-std::vector<flightgear::Approach*> FGRunway::getApproaches() const
+flightgear::ApproachList
+FGRunway::getApproaches(flightgear::ProcedureType type) const
 {
   FGAirport* apt = airport();
-  std::vector<flightgear::Approach*> result;
-  for (unsigned int i=0; i<apt->numApproaches(); ++i) {
+  flightgear::ApproachList result;
+  for (unsigned int i=0; i<apt->numApproaches(); ++i)
+  {
     flightgear::Approach* s = apt->getApproachByIndex(i);
-    if (s->runway() == this) {
+    if(    s->runway() == this
+        && (type == flightgear::PROCEDURE_INVALID || type == s->type()) )
+    {
       result.push_back(s);
     }
   } // of approaches at the airport iteration
@@ -202,6 +206,16 @@ std::vector<flightgear::Approach*> FGRunway::getApproaches() const
   return result;
 }
 
+void FGRunway::updateThreshold(const SGGeod& newThreshold, double newHeading,
+                     double newDisplacedThreshold,
+                     double newStopway)
+{
+    modifyPosition(newThreshold);
+    _heading = newHeading;
+    _stopway = newStopway;
+    _displ_thresh = newDisplacedThreshold;
+}
+
 FGHelipad::FGHelipad(PositionedID aGuid,
                         PositionedID aAirport, const string& aIdent,
                         const SGGeod& aGeod,
@@ -209,7 +223,6 @@ FGHelipad::FGHelipad(PositionedID aGuid,
                         const double width,
                         const int surface_code) :
   FGRunwayBase(aGuid, RUNWAY, aIdent, aGeod,
-               heading, length, width, surface_code),
-  _airport(aAirport)
+               heading, length, width, surface_code)
 {
 }