]> git.mxchange.org Git - flightgear.git/commitdiff
Thomas Foerster: Made FGParking a subclass of FGTaxiNode
authordurk <durk>
Thu, 5 Jul 2007 19:00:59 +0000 (19:00 +0000)
committerdurk <durk>
Thu, 5 Jul 2007 19:00:59 +0000 (19:00 +0000)
                 Fixed bug due to longstanding inconsistency in FGAirport
                 getter functions return types.
Durk Talsma:     Fixed traffic record initialization bug that occured
                 when taxiing traffic was waiting for traffic on runway

15 files changed:
src/Airports/Makefile.am
src/Airports/dynamicloader.cxx
src/Airports/dynamicloader.hxx
src/Airports/gnnode.hxx [new file with mode: 0644]
src/Airports/groundnetwork.cxx
src/Airports/groundnetwork.hxx
src/Airports/parking.cxx
src/Airports/parking.hxx
src/Airports/runwayprefloader.cxx
src/Airports/runwayprefloader.hxx
src/Airports/simple.hxx
src/Airports/trafficcontrol.cxx
src/Airports/trafficcontrol.hxx
src/Airports/xmlloader.cxx
src/Airports/xmlloader.hxx

index 7449c24cb2a2aa44d7743dd62f838ac32a1f1615..7f067295adcaacf4dd9006892b316f41f6abd1fc 100644 (file)
@@ -10,11 +10,11 @@ libAirports_a_SOURCES = \
        parking.cxx parking.hxx \
        groundnetwork.cxx groundnetwork.hxx \
        dynamics.cxx dynamics.hxx \
-       trafficcontrol.hxx trafficcontrol.cxx \
-       dynamicloader.hxx dynamicloader.cxx \
-       runwayprefloader.hxx runwayprefloader.cxx \
-       xmlloader.hxx xmlloader.cxx 
-
+       trafficcontrol.cxx trafficcontrol.hxx \
+       dynamicloader.cxx dynamicloader.hxx \
+       runwayprefloader.cxx runwayprefloader.hxx \
+       xmlloader.cxx xmlloader.hxx \
+       gnnode.hxx 
 
 calc_loc_SOURCES = calc_loc.cxx
 calc_loc_LDADD = -lsgmath -lsgdebug -lsgmisc -lz $(base_LIBS)
index 456acc83597288492d2837e51c510658709a7e49..5f111d1d826ce7b94d1e1f2376fc0693e5058228 100644 (file)
@@ -1,3 +1,18 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
 #include "dynamicloader.hxx"
 
 FGAirportDynamicsXMLLoader::FGAirportDynamicsXMLLoader(FGAirportDynamics* dyn):
index 95f05aa0720b575d524dba3facfafe3cc6d23f98..8f86cf6abca508a699a1d226c770a7b7f25901d0 100644 (file)
@@ -1,3 +1,18 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
 #ifndef _DYNAMIC_LOADER_HXX_
 #define _DYNAMIC_LOADER_HXX_
 
diff --git a/src/Airports/gnnode.hxx b/src/Airports/gnnode.hxx
new file mode 100644 (file)
index 0000000..703f1e4
--- /dev/null
@@ -0,0 +1,72 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
+#ifndef _GN_NODE_HXX_
+#define _GN_NODE_HXX_
+
+#include <vector>
+#include <string>
+#include <simgear/compiler.h>
+
+SG_USING_STD(string);
+SG_USING_STD(vector);
+
+class FGTaxiSegment;
+typedef vector<FGTaxiSegment*>  FGTaxiSegmentVector;
+typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
+
+double processPosition(const string& pos);
+
+class FGTaxiNode 
+{
+private:
+  double lat;
+  double lon;
+  int index;
+  FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
+  
+public:
+  FGTaxiNode();
+  FGTaxiNode(double, double, int);
+
+  void setIndex(int idx)                  { index = idx;};
+  void setLatitude (double val)           { lat = val;};
+  void setLongitude(double val)           { lon = val;};
+  void setLatitude (const string& val)           { lat = processPosition(val);  };
+  void setLongitude(const string& val)           { lon = processPosition(val);  };
+  void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
+  
+  double getLatitude() { return lat;};
+  double getLongitude(){ return lon;};
+
+  int getIndex() { return index; };
+  FGTaxiNode *getAddress() { return this;};
+  FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
+  FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
+  bool operator<(const FGTaxiNode &other) const { return index < other.index; };
+
+  void sortEndSegments(bool);
+
+  // used in way finding
+  double pathscore;
+  FGTaxiNode* previousnode;
+  FGTaxiSegment* previousseg;
+  
+};
+
+typedef vector<FGTaxiNode*> FGTaxiNodeVector;
+typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
+
+#endif
index d6cdc68ac6ad0faf6f1dccede458183d8dc78005..32a51692a3f7125ba9b50b0ec7389eea7ed26137 100644 (file)
@@ -41,7 +41,6 @@
 //#include <Main/fg_props.hxx>
 //#include <Airports/runways.hxx>
 
-
 #include <AIModel/AIFlightPlan.hxx>
 
 //#include STL_STRING
 
 SG_USING_STD(sort);
 
-
+/*****************************************************************************
+ * Helper function for parsing position string
+ ****************************************************************************/
+double processPosition(const string &pos)
+{
+  string prefix;
+  string subs;
+  string degree;
+  string decimal;
+  int sign = 1;
+  double value;
+  subs = pos;
+  prefix= subs.substr(0,1);
+  if (prefix == string("S") || (prefix == string("W")))
+    sign = -1;
+  subs    = subs.substr(1, subs.length());
+  degree  = subs.substr(0, subs.find(" ",0));
+  decimal = subs.substr(subs.find(" ",0), subs.length());
+  
+             
+  //cerr << sign << " "<< degree << " " << decimal << endl;
+  value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
+  //cerr << value <<endl;
+  //exit(1);
+  return value;
+}
 
 /**************************************************************************
  * FGTaxiNode
index 425b2d559fa4283ba3f9364ca2d5192031466255..b9370fa21d788beaab92d6ed6fcfb83cfbf6660e 100644 (file)
 #include <simgear/compiler.h>
 #include <simgear/route/waypoint.hxx>
 
-
 #include STL_STRING
 #include <vector>
 
 SG_USING_STD(string);
 SG_USING_STD(vector);
 
+#include "gnnode.hxx"
 #include "parking.hxx"
 #include "trafficcontrol.hxx"
 
-
-
 class FGTaxiSegment; // forward reference
 class FGAIFlightPlan; // forward reference
 class FGAirport;      // forward reference
@@ -49,49 +47,6 @@ typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentVectorIterator;
 //typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
 //typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
 
-/**************************************************************************************
- * class FGTaxiNode
- *************************************************************************************/
-class FGTaxiNode 
-{
-private:
-  double lat;
-  double lon;
-  int index;
-  FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
-  
-public:
-  FGTaxiNode();
-  FGTaxiNode(double, double, int);
-
-  void setIndex(int idx)                  { index = idx;};
-  void setLatitude (double val)           { lat = val;};
-  void setLongitude(double val)           { lon = val;};
-  void setLatitude (const string& val)           { lat = processPosition(val);  };
-  void setLongitude(const string& val)           { lon = processPosition(val);  };
-  void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
-  
-  double getLatitude() { return lat;};
-  double getLongitude(){ return lon;};
-
-  int getIndex() { return index; };
-  FGTaxiNode *getAddress() { return this;};
-  FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
-  FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
-  bool operator<(const FGTaxiNode &other) const { return index < other.index; };
-
-  void sortEndSegments(bool);
-
-  // used in way finding
-  double pathscore;
-  FGTaxiNode* previousnode;
-  FGTaxiSegment* previousseg;
-  
-};
-
-typedef vector<FGTaxiNode*> FGTaxiNodeVector;
-typedef vector<FGTaxiNode*>::iterator FGTaxiNodeVectorIterator;
-
 /***************************************************************************************
  * class FGTaxiSegment
  **************************************************************************************/
index e9a25cfdb835b93b8060d24ed1086f4c547f6919..ebc06210fb4f8c5121c721a7af13adae7d92ba89 100644 (file)
 
 #include "parking.hxx"
 
-
-/*****************************************************************************
- * Helper function for parsing position string
- ****************************************************************************/
-double processPosition(const string &pos)
-{
-  string prefix;
-  string subs;
-  string degree;
-  string decimal;
-  int sign = 1;
-  double value;
-  subs = pos;
-  prefix= subs.substr(0,1);
-  if (prefix == string("S") || (prefix == string("W")))
-    sign = -1;
-  subs    = subs.substr(1, subs.length());
-  degree  = subs.substr(0, subs.find(" ",0));
-  decimal = subs.substr(subs.find(" ",0), subs.length());
-  
-             
-  //cerr << sign << " "<< degree << " " << decimal << endl;
-  value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
-  //cerr << value <<endl;
-  //exit(1);
-  return value;
-}
-
-
 /*********************************************************************************
  * FGParking
  ********************************************************************************/
@@ -87,12 +58,10 @@ FGParking::FGParking(double lat,
                     const string &name,
                     const string &tpe,
                     const string &codes)
+  : FGTaxiNode(lat,lon,idx)
 {
-  latitude     = lat;
-  longitude    = lon;
   heading      = hdg;
   parkingName  = name;
-  index        = idx;
   type         = tpe;
   airlineCodes = codes;
 }
index a64d5509b40a5ef0a760df2a4f7b3921192c9d4d..c96ab1d241248ae2a34c3d030da027dd1ee441c5 100644 (file)
 #include STL_STRING
 #include <vector>
 
+#include "gnnode.hxx"
 
 SG_USING_STD(string);
 SG_USING_STD(vector);
 
-double processPosition(const string& pos);
-
-class FGParking {
+class FGParking : public FGTaxiNode {
 private:
-  double latitude;
-  double longitude;
   double heading;
   double radius;
-  int index;
   string parkingName;
   string type;
   string airlineCodes;
@@ -66,11 +62,10 @@ public:
            const string& name,
            const string& tpe,
            const string& codes);
-  void setLatitude (const string& lat)  { latitude    = processPosition(lat);  };
-  void setLongitude(const string& lon)  { longitude   = processPosition(lon);  };
+
   void setHeading  (double hdg)  { heading     = hdg;  };
   void setRadius   (double rad)  { radius      = rad;  };
-  void setIndex    (int    idx)  { index       = idx;  };
+
   void setName     (const string& name) { parkingName = name; };
   void setType     (const string& tpe)  { type        = tpe;  };
   void setCodes    (const string& codes){ airlineCodes= codes;};
@@ -78,16 +73,15 @@ public:
   bool isAvailable ()         { return available;};
   void setAvailable(bool val) { available = val; };
   
-  double getLatitude () { return latitude;    };
-  double getLongitude() { return longitude;   };
   double getHeading  () { return heading;     };
   double getRadius   () { return radius;      };
-  int    getIndex    () { return index;       };
+
   string getType     () { return type;        };
   string getCodes    () { return airlineCodes;};
   string getName     () { return parkingName; };
 
-  bool operator< (const FGParking &other) const {return radius < other.radius; };
+  bool operator< (const FGParking &other) const {
+    return radius < other.radius; };
 };
 
 typedef vector<FGParking> FGParkingVec;
index b31bc60616449679d239bd7a8486409f545ad0c0..05a54dacaf7d42d40287bf640aa8d34642e89c9e 100644 (file)
@@ -1,3 +1,18 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
 #include <simgear/debug/logstream.hxx>
 
 #include "runwayprefloader.hxx"
index 9ee489b10f47cc367f7e44b739573595461b1494..56a62eed3f049de5d77031779f088c8e17061ea2 100644 (file)
@@ -1,3 +1,18 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
 #ifndef _RUNWAY_PREF_LOADER_HXX_
 #define _RUNWAY_PREF_LOADER_HXX_
 
index 72256bf5f56098da67b1e27228d4438c3d334556..0e79c8675ee36212f7c4320d5cfc376f369876ab 100644 (file)
@@ -78,8 +78,8 @@ public:
     FGAirport(const string& id, double lon, double lat, double elev, const string& name, bool has_metar);
     ~FGAirport();
 
-    string getId() const { return _id; }
-    const string &getName() const { return _name; }
+    const string& getId() const { return _id; }
+    const stringgetName() const { return _name; }
     double getLongitude() const { return _longitude; }
     // Returns degrees
     double getLatitude()  const { return _latitude; }
index 423a7c961c6c17e153d0e61c12f0cb476d33afc5..7489b2c016d5ac058b31fe83f3195f97e36f100c 100644 (file)
 /***************************************************************************
  * FGTrafficRecord
  **************************************************************************/
+FGTrafficRecord::FGTrafficRecord() :
+  id(0), waitsForId(0),
+  currentPos(0),
+  leg(0),
+  latitude(0),
+  longitude(0), 
+   heading(0), 
+   speed(0), 
+   altitude(0), 
+   radius(0) {
+}
+
 void FGTrafficRecord::setPositionAndIntentions(int pos, FGAIFlightPlan *route)
 {
  
@@ -346,6 +358,7 @@ void FGTowerController::announcePosition(int id, FGAIFlightPlan *intendedRoute,
   if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
     FGTrafficRecord rec;
     rec.setId(id);
+
     rec.setPositionAndHeading(lat, lon, heading, speed, alt);
     rec.setRunway(intendedRoute->getRunway());
     rec.setLeg(leg);
index 1ab622ebe90ee522ab0f2d1ee8360bd43d421f45..be687d16da9eb4711ea577aee519aa4685517dd2 100644 (file)
@@ -136,7 +136,7 @@ private:
   
   
 public:
-  FGTrafficRecord() {};
+  FGTrafficRecord();
   
   void setId(int val)  { id = val; };
   void setRadius(double rad) { radius = rad;};
index 1448c84f9e6fc473e3a2323b4c2ed0cd7aafc747..205defa8207c2d9fb68c96a67aad9139d5ad7dd1 100644 (file)
@@ -1,3 +1,18 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
 #include <simgear/misc/sg_path.hxx>
 #include <Main/globals.hxx>
 
index a423eac2f84d5c7f350be4e62faf9af93544a40d..fd07636c39d7d1179edc431dffe00f1a9e2ccdb5 100644 (file)
@@ -1,3 +1,18 @@
+// 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
 #ifndef _XML_LOADER_HXX_
 #define _XML_LOADER_HXX_