1 /* -*- Mode: C++ -*- *****************************************************
3 * Written by Durk Talsma. Started July 1999.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **************************************************************************/
21 /*************************************************************************
23 * This file defines a small and simple class to store geocentric
24 * coordinates. Basically, class GeoCoord is intended as a base class for
25 * any kind of of object, that can be categorized according to its
26 * location on earth, be it navaids, or aircraft. This class for originally
27 * written for FlightGear, in order to store Timezone control points.
29 ************************************************************************/
35 #include <simgear/compiler.h>
41 #include <simgear/constants.h>
50 SGGeoCoord() { lat = 0.0; lon = 0.0;};
51 SGGeoCoord(float la, float lo) { lat = la; lon = lo;};
52 SGGeoCoord(const SGGeoCoord& other);
53 virtual ~SGGeoCoord() {};
55 void set(float la, float lo) { lat = la; lon = lo; };
56 float getLat() const { return lat; };
57 float getLon() const { return lon; };
58 float getX() const { return cos(SGD_DEGREES_TO_RADIANS*lat) * cos(SGD_DEGREES_TO_RADIANS*lon); };
59 float getY() const { return cos(SGD_DEGREES_TO_RADIANS*lat) * sin(SGD_DEGREES_TO_RADIANS*lon); };
60 float getZ() const { return sin(SGD_DEGREES_TO_RADIANS*lat); };
63 virtual const char * getDescription() {return 0;};
66 typedef std::vector<SGGeoCoord*> SGGeoCoordVector;
67 typedef std::vector<SGGeoCoord*>::iterator SGGeoCoordVectorIterator;
68 typedef std::vector<SGGeoCoord*>::const_iterator SGGeoCoordVectorConstIterator;
70 /************************************************************************
71 * SGGeoCoordContainer is a simple container class, that stores objects
72 * derived from SGGeoCoord. Basically, it is a wrapper around an STL vector,
73 * with some added functionality
74 ***********************************************************************/
76 class SGGeoCoordContainer
79 SGGeoCoordVector data;
82 SGGeoCoordContainer() {};
83 virtual ~SGGeoCoordContainer();
85 const SGGeoCoordVector& getData() const { return data; };
86 SGGeoCoord* getNearest(const SGGeoCoord& ref) const;
90 #endif // _GEO_COORD_H_