1 /* -*- Mode: C++ -*- *****************************************************
3 * Written by Durk Talsma. Started March 1998.
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 SGGeoCoord 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 ************************************************************************/
30 #include <simgear/math/SGMath.hxx>
33 SGGeoCoord::SGGeoCoord(const SGGeoCoord& other)
39 SGGeoCoord* SGGeoCoordContainer::getNearest(const SGGeoCoord& ref) const
45 SGVec3f refVec(ref.getX(), ref.getY(), ref.getZ());
46 SGGeoCoordVectorConstIterator i, nearest;
47 for (i = data.begin(); i != data.end(); ++i)
49 float cosAng = dot(refVec, SGVec3f((*i)->getX(), (*i)->getY(), (*i)->getZ()));
50 if (maxCosAng < cosAng)
60 SGGeoCoordContainer::~SGGeoCoordContainer()
62 SGGeoCoordVectorIterator i = data.begin();
63 while (i != data.end())