head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.38; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.53; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.00; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.56; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# geocoord.h

    00001 /* -*- Mode: C++ -*- *****************************************************
    00002  * geocoord.h
    00003  * Written by Durk Talsma. Started July 1999.
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Library General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  * Library General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Library General Public
    00016  * License along with this library; if not, write to the
    00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  * Boston, MA  02111-1307, USA.
    00019  *
    00020  **************************************************************************/
    00021
    00022 /*************************************************************************
    00023  *
    00024  * This file defines a small and simple class to store geocentric
    00025  * coordinates. Basically, class GeoCoord is intended as a base class for
    00026  * any kind of of object, that can be categorized according to its
    00027  * location on earth, be it navaids, or aircraft. This class for originally
    00028  * written for FlightGear, in order to store Timezone control points.
    00029  *
    00030  ************************************************************************/
    00031
    00032
    00033 #ifndef _GEOCOORD_H_
    00034 #define _GEOCOORD_H_
    00035
    00036 #include <simgear/compiler.h>
    00037
    00038
    00039 #include <math.h>
    00040 #include <string>
    00041 #include STL_IOSTREAM
    00042 //#include <streambuf> // looks like streambuf does not exist on linux.
    00043 // But it looks like it isn't used anyways -:)
    00044 #include <vector>
    00045
    00046 SG_USING_NAMESPACE(std);
    00047
    00048 #include <simgear/constants.h>
    00049
    00050 class GeoCoord
    00051 {
    00052 protected:
    00053   float lat;
    00054   float lon;
    00055
    00056 public:
    00057   GeoCoord() { lat = 0.0; lon = 0.0;};
    00058   GeoCoord(float la, float lo) { lat = la; lon = lo;};
    00059   GeoCoord(const GeoCoord& other);
    00060   virtual ~GeoCoord() {};
    00061
    00062   void set(float la, float lo) { lat = la; lon = lo; };
    00063   float getLat() const { return lat; };
    00064   float getLon() const { return lon; };
    00065   float getX()   const { return cos(SGD_DEGREES_TO_RADIANS*lat) * cos(SGD_DEGREES_TO_RADIANS*lon); };
    00066   float getY()   const { return cos(SGD_DEGREES_TO_RADIANS*lat) * sin(SGD_DEGREES_TO_RADIANS*lon); };
    00067   float getZ()   const { return sin(SGD_DEGREES_TO_RADIANS*lat); };
    00068
    00069
    00070   //double getAngle(const GeoCoord& other) const;
    00071   virtual void print() {} ;
    00072   virtual char *getDescription() {return 0;};
    00073 };
    00074
    00075 typedef vector<GeoCoord*> GeoCoordVector;
    00076 typedef vector<GeoCoord*>::iterator GeoCoordVectorIterator;
    00077 typedef vector<GeoCoord*>::const_iterator GeoCoordVectorConstIterator;
    00078
    00079 /************************************************************************
    00080  * GeoCoordContainer is a simple container class, that stores objects
    00081  * derived from GeoCoord. Basically, it is a wrapper around an STL vector,
    00082  * with some added functionality
    00083  ***********************************************************************/
    00084
    00085 class GeoCoordContainer
    00086 {
    00087 protected:
    00088   GeoCoordVector data;
    00089
    00090 public:
    00091   GeoCoordContainer() {};
    00092   virtual ~GeoCoordContainer();
    00093
    00094   const GeoCoordVector& getData() const { return data; };
    00095   GeoCoord* getNearest(const GeoCoord& ref) const;
    00096 };
    00097
    00098
    00099 #endif // _GEO_COORD_H_

@ 1.3 log @Oops, try again. @ text @d108 1 a108 1