]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATCutils.cxx
If it's a struct, it's not a class
[flightgear.git] / src / ATC / ATCutils.cxx
index 0b51b550fac36aae6e5afb4f090a82a05e774af8..c5a229fee1cf04b97c631a4d111b86e723eb4993 100644 (file)
@@ -16,7 +16,7 @@
 //
 // 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
@@ -187,7 +187,7 @@ string GetCompassDirection(double h) {
 //================================================================================================================
 
 // Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D pos1, const Point3D pos2) {
+double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2) {
        double x;       //East-West separation
        double y;       //North-South separation
        double z;       //Horizontal separation - z = sqrt(x^2 + y^2)
@@ -226,7 +226,7 @@ double dclGetLinePointSeparation(double px, double py, double x1, double y1, dou
 // Given a position (lat/lon/elev), heading and vertical angle (degrees), and distance (meters), calculate the new position.
 // This function assumes the world is spherical.  If geodetic accuracy is required use the functions is sg_geodesy instead!
 // Assumes that the ground is not hit!!!  Expects heading and angle in degrees, distance in meters. 
-Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, double distance) {
+Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance) {
        //cout << setprecision(10) << pos.lon() << ' ' << pos.lat() << '\n';
        heading *= DCL_DEGREES_TO_RADIANS;
        angle *= DCL_DEGREES_TO_RADIANS;
@@ -259,7 +259,7 @@ Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, doubl
 // Get a heading in degrees from one lat/lon to another.
 // This function assumes the world is spherical.  If geodetic accuracy is required use the functions is sg_geodesy instead!
 // Warning - at the moment we are not checking for identical points - currently it returns 0 in this instance.
-double GetHeadingFromTo(const Point3D A, const Point3D B) {
+double GetHeadingFromTo(const Point3D& A, const Point3D& B) {
        double latA = A.lat() * DCL_DEGREES_TO_RADIANS;
        double lonA = A.lon() * DCL_DEGREES_TO_RADIANS;
        double latB = B.lat() * DCL_DEGREES_TO_RADIANS;
@@ -291,70 +291,9 @@ double GetAngleDiff_deg( const double &a1, const double &a2) {
   return a3;
 }
 
-//================================================================================================================
-
-// Airport stuff.  The next two functions are straight copies of their fg.... equivalents
-// in fg_init.cxx, and are just here temporarily until some rationalisation occurs.
-// find basic airport location info from airport database
-bool dclFindAirportID( const string& id, FGAirport *a ) {
-    const FGAirport* result;
-
-    if ( id.length() ) {
-        SG_LOG( SG_GENERAL, SG_INFO, "Searching for airport code = " << id );
-
-        result = globals->get_airports()->search(id);
-        if ( result == NULL ) {
-            SG_LOG( SG_GENERAL, SG_WARN,
-                    "Failed to find " << id << " in apt.dat.gz" );
-            return false;
-        }
-    } else {
-        return false;
-    }
-
-    *a = *result;
-
-    SG_LOG( SG_GENERAL, SG_INFO,
-            "Position for " << id << " is ("
-            << a->getLongitude() << ", "
-            << a->getLatitude() << ")" );
-
-    return true;
-}
-
-// get airport elevation
-double dclGetAirportElev( const string& id ) {
-    FGAirport a;
-    // double lon, lat;
-
-    SG_LOG( SG_ATC, SG_INFO,
-            "Finding elevation for airport: " << id );
-
-    if ( dclFindAirportID( id, &a ) ) {
-        return a.getElevation() * SG_FEET_TO_METER;
-    } else {
-        return -9999.0;
-    }
-}
-
-// get airport position
-Point3D dclGetAirportPos( const string& id ) {
-    FGAirport a;
-    // double lon, lat;
-
-    SG_LOG( SG_ATC, SG_INFO,
-            "Finding position for airport: " << id );
-
-    if ( dclFindAirportID( id, &a ) ) {
-        return Point3D(a.getLongitude(), a.getLatitude(), a.getElevation());
-    } else {
-        return Point3D(0.0, 0.0, -9999.0);
-    }
-}      
-
 // Runway stuff
 // Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D pt, const FGRunway& rwy) {
+bool OnRunway(const Point3D& pt, const FGRunway& rwy) {
        FGATCAlignedProjection ortho;
        Point3D centre(rwy._lon, rwy._lat, 0.0);        // We don't need the elev
        ortho.Init(centre, rwy._heading);