* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * 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 _TIMEZONE_H_
#define _TIMEZONE_H_
-#include <stdio.h>
+#include <string>
+#include <vector>
-#include <simgear/timing/geocoord.h>
+#include <simgear/math/SGMath.hxx>
+#include <simgear/math/SGGeod.hxx>
/**
- * SGTimeZone is derived from geocoord, and stores the timezone centerpoint,
+ * SGTimeZone stores the timezone centerpoint,
* as well as the countrycode and the timezone descriptor. The latter is
* used in order to get the local time.
*
*/
-class SGTimeZone : public SGGeoCoord
+class SGTimeZone
{
private:
- string countryCode;
- string descriptor;
+ SGVec3d centerpoint; // centre of timezone, in cartesian coordinates
+ std::string countryCode;
+ std::string descriptor;
public:
- /**
- * Default constructor.
- */
- SGTimeZone() : SGGeoCoord()
- {
- countryCode.erase();
- descriptor.erase();
- };
-
/**
* Build a timezone object with a specifed latitude, longitude, country
* code, and descriptor
- * @param la latitude
- * @param lo longitude
+ * @param pt centerpoint
* @param cc country code
* @param desc descriptor
*/
- SGTimeZone(float la, float lo, char* cc, char* desc);
+ SGTimeZone(const SGGeod& pt, char* cc, char* desc);
/**
* Build a timezone object from a textline in zone.tab
* @param other the source object
*/
SGTimeZone(const SGTimeZone &other);
-
- /**
- * Virutal destructor
- */
- virtual ~SGTimeZone() { };
- /**
- * Print the descriptor string
- */
- virtual void print() { printf("%s", descriptor.c_str()); }
-
/**
* Return the descriptor string
* @return descriptor string (char array)
*/
- virtual const char * getDescription() { return descriptor.c_str(); };
+ const char * getDescription() { return descriptor.c_str(); };
+
+ const SGVec3d& cartCenterpoint() const
+ {
+ return centerpoint;
+ }
};
/**
- * SGTimeZoneContainer is derived from SGGeoCoordContainer, and has some
- * added functionality.
+ * SGTimeZoneContainer
*/
-class SGTimeZoneContainer : public SGGeoCoordContainer
+class SGTimeZoneContainer
{
- public:
+public:
SGTimeZoneContainer(const char *filename);
- virtual ~SGTimeZoneContainer();
+ ~SGTimeZoneContainer();
+
+ SGTimeZone* getNearest(const SGGeod& ref) const;
+
+private:
+ typedef std::vector<SGTimeZone*> TZVec;
+ TZVec zones;
};