// marker.hpp -- Calibration markers for map fragments // // Written by Frederic Bouvier, started October 2001. // OSGB36 functions written by David Luff, started December 2000. // // Copyright (C) 2001 Frederic Bouvier - fredb@users.sourceforge.net // Copyright (C) 2000 David C. Luff - david.luff@nottingham.ac.uk // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // 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. // // $Id: marker.hpp,v 1.5 2005/05/09 07:02:10 fredb Exp $ #ifndef _marker_hpp_ #define _marker_hpp_ #include "sdutil.hpp" class SGPropertyNode; class Point3D; class FGSD_Marker { public: enum CoordSyst { UNKNOWN, WGS84, LAMBERT1, LAMBERT2, LAMBERT2E, LAMBERT3, LAMBERT4, OSGB36, UTM }; FGSD_Marker(); FGSD_Marker( double __x, double __y, CoordSyst __syst, double __lon, double __lat, double __h, int __z = 0, FGSD_Util::Datum __d = FGSD_Util::D_UNKNOWN ); FGSD_Marker( const FGSD_Marker &right ); FGSD_Marker &operator=( const FGSD_Marker &right ); bool hittest( double __x, double __y, double __r ) const; bool getWGS84Position( double &__lon, double &__lat ) const; static void lambert2GeoNTF( double x, double y, double xs, double ys, double n, double c, double &lonNTF, double &latNTF ); static void geoNTF2Cart( double lonNTF, double latNTF, double h, double &xNTF, double &yNTF, double &zNTF ); static void cart2GeoWGS84( double xWGS84, double yWGS84, double zWGS84, double &lonWGS84, double &latWGS84 ); //******************************************************************* // // NOTE All functions which take or return Latitude and Longitude // take and return degrees. Conversion to and from radians // is performed internaly. XYZ coordinates and ellipsoid // heights are returned and required in meters. // //******************************************************************* //Convert OSGB36 Lat and Lon to OSGB36 Eastings and Northings (Grid Reference) static Point3D ConvertLatLonToEastingsNorthings(Point3D LatLon); //Convert OSGB36 Eastings and Northings to OSGB36 Lat and Lon static Point3D ConvertEastingsNorthingsToLatLon(Point3D GridRef); //Convert OSGB36 coordinates from polar to cartesian (x,y,z) form static Point3D ConvertAiry1830PolarToCartesian(Point3D LatLon); //Convert WGS84 coordinates from polar to cartesian (x,y,z) form static Point3D ConvertGRS80PolarToCartesian(Point3D LatLon); //Convert OSGB36 coordinates from cartesian (x,y,z) to polar form static Point3D ConvertAiry1830CartesianToPolar(Point3D XYZCoord); //Convert WGS84 coordinates from cartesian (x,y,z) to polar form static Point3D ConvertGRS80CartesianToPolar(Point3D XYZCoord); //Transform a point in WGS84 cartesian coordinates to OSGB36 cartesian coordinates //Uses the Helmert Transformation with coefficients from www.gps.gov.org //Only accurate to around 5m since OSGB36 is an inhomogenous TRF static Point3D ConvertWGS84ToOSGB36(Point3D WGS84); //Transform a point in OSGB36 cartesian coordinates to WGS84 cartesian coordinates //Uses the Helmert Transformation with coefficients from www.gps.gov.org //Only accurate to around 5m since OSGB36 is an inhomogenous TRF static Point3D ConvertOSGB36ToWGS84(Point3D OSGB36); // Persistence void restoreFrom( SGPropertyNode * ); void saveAs( SGPropertyNode * ); // Accessors double x() const; double y() const; private: double _x; double _y; CoordSyst _syst; double _lon; double _lat; double _h; int _zone; // for UTM FGSD_Util::Datum _datum; // for UTM }; inline FGSD_Marker::FGSD_Marker() : _x( 0 ) , _y( 0 ) , _syst( FGSD_Marker::UNKNOWN ) , _lon( 0 ) , _lat( 0 ) , _h( 0 ) , _zone( 0 ) , _datum( FGSD_Util::D_UNKNOWN ) { } inline FGSD_Marker::FGSD_Marker( double __x, double __y, FGSD_Marker::CoordSyst __syst, double __lon, double __lat, double __h, int __z, FGSD_Util::Datum __d ) : _x( __x ) , _y( __y ) , _syst( __syst ) , _lon( __lon ) , _lat( __lat ) , _h( __h ) , _zone( __z ) , _datum( __d ) { } inline FGSD_Marker::FGSD_Marker( const FGSD_Marker &right ) : _x( right._x ) , _y( right._y ) , _syst( right._syst ) , _lon( right._lon ) , _lat( right._lat ) , _h( right._h ) , _zone( right._zone ) , _datum( right._datum ) { } inline bool FGSD_Marker::hittest( double __x, double __y, double __r ) const { return __x > _x - __r && __x < _x + __r && __y > _y - __r && __y < _y + __r; } inline double FGSD_Marker::x() const { return _x; } inline double FGSD_Marker::y() const { return _y; } inline FGSD_Marker &FGSD_Marker::operator=( const FGSD_Marker &right ) { _x = right._x; _y = right._y; _syst = right._syst; _lon = right._lon; _lat = right._lat; _h = right._h; _zone = right._zone; _datum = right._datum; return *this; } #endif