From: durk Date: Thu, 5 Jul 2007 19:00:59 +0000 (+0000) Subject: Thomas Foerster: Made FGParking a subclass of FGTaxiNode X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4238a46faa8fc8e9ac9174fe960eb7c5df188a4c;p=flightgear.git Thomas Foerster: Made FGParking a subclass of FGTaxiNode 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 --- diff --git a/src/Airports/Makefile.am b/src/Airports/Makefile.am index 7449c24cb..7f067295a 100644 --- a/src/Airports/Makefile.am +++ b/src/Airports/Makefile.am @@ -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) diff --git a/src/Airports/dynamicloader.cxx b/src/Airports/dynamicloader.cxx index 456acc835..5f111d1d8 100644 --- a/src/Airports/dynamicloader.cxx +++ b/src/Airports/dynamicloader.cxx @@ -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): diff --git a/src/Airports/dynamicloader.hxx b/src/Airports/dynamicloader.hxx index 95f05aa07..8f86cf6ab 100644 --- a/src/Airports/dynamicloader.hxx +++ b/src/Airports/dynamicloader.hxx @@ -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 index 000000000..703f1e46d --- /dev/null +++ b/src/Airports/gnnode.hxx @@ -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 +#include +#include + +SG_USING_STD(string); +SG_USING_STD(vector); + +class FGTaxiSegment; +typedef vector 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 FGTaxiNodeVector; +typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator; + +#endif diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index d6cdc68ac..32a51692a 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -41,7 +41,6 @@ //#include
//#include - #include //#include STL_STRING @@ -50,7 +49,32 @@ 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 < #include - #include STL_STRING #include 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::iterator FGTaxiSegmentVectorIterator; //typedef vector FGTaxiSegmentPointerVector; //typedef vector::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 FGTaxiNodeVector; -typedef vector::iterator FGTaxiNodeVectorIterator; - /*************************************************************************************** * class FGTaxiSegment **************************************************************************************/ diff --git a/src/Airports/parking.cxx b/src/Airports/parking.cxx index e9a25cfdb..ebc06210f 100644 --- a/src/Airports/parking.cxx +++ b/src/Airports/parking.cxx @@ -47,35 +47,6 @@ #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 < +#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 FGParkingVec; diff --git a/src/Airports/runwayprefloader.cxx b/src/Airports/runwayprefloader.cxx index b31bc6061..05a54daca 100644 --- a/src/Airports/runwayprefloader.cxx +++ b/src/Airports/runwayprefloader.cxx @@ -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 #include "runwayprefloader.hxx" diff --git a/src/Airports/runwayprefloader.hxx b/src/Airports/runwayprefloader.hxx index 9ee489b10..56a62eed3 100644 --- a/src/Airports/runwayprefloader.hxx +++ b/src/Airports/runwayprefloader.hxx @@ -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_ diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index 72256bf5f..0e79c8675 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -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 string& getName() const { return _name; } double getLongitude() const { return _longitude; } // Returns degrees double getLatitude() const { return _latitude; } diff --git a/src/Airports/trafficcontrol.cxx b/src/Airports/trafficcontrol.cxx index 423a7c961..7489b2c01 100644 --- a/src/Airports/trafficcontrol.cxx +++ b/src/Airports/trafficcontrol.cxx @@ -31,6 +31,18 @@ /*************************************************************************** * 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); diff --git a/src/Airports/trafficcontrol.hxx b/src/Airports/trafficcontrol.hxx index 1ab622ebe..be687d16d 100644 --- a/src/Airports/trafficcontrol.hxx +++ b/src/Airports/trafficcontrol.hxx @@ -136,7 +136,7 @@ private: public: - FGTrafficRecord() {}; + FGTrafficRecord(); void setId(int val) { id = val; }; void setRadius(double rad) { radius = rad;}; diff --git a/src/Airports/xmlloader.cxx b/src/Airports/xmlloader.cxx index 1448c84f9..205defa82 100644 --- a/src/Airports/xmlloader.cxx +++ b/src/Airports/xmlloader.cxx @@ -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 #include
diff --git a/src/Airports/xmlloader.hxx b/src/Airports/xmlloader.hxx index a423eac2f..fd07636c3 100644 --- a/src/Airports/xmlloader.hxx +++ b/src/Airports/xmlloader.hxx @@ -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_