⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geopos.h

📁 GPS坐标转换软件与源程序 支持世界上大多数坐标框架下
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Combat Simulator Project
 * Copyright 2002-2005 Mark Rose <mkrose@users.sourceforge.net>
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

/**
 * @file GeoPos.h
 * @brief Geodetic coordinate class and conversions.
 */


#ifndef __CSPLIB_DATA_GEOPOS_H__
#define __CSPLIB_DATA_GEOPOS_H__

//#include "Vector3.h"
#include "selfdefine.h"
#include <string>


class CArchive;

double toRadians (double de);
double toDegrees (double ra);


/** Reference ellipsoid parameters.semi-major axis,semi-minor axis
 */
class CReferenceEllipsoid {
public:
	double A;    ///< equatorial radius
	double B;    ///< polar radius
	double R;    ///< volumetric mean radius (6371010 meters)
	double f;    ///< flattening @f$((A-B)/A)@f$
	double e;    ///< first eccentricity @f$ (\sqrt{2f-f^2}) @f$
	double A_B;  ///< equatorial to polar radius ratio @f$(A/B)@f$
	double B_A;  ///< polar to equatorial radius ratio @f$(B/A)@f$
	double B2_A2;///< square of polar to equatorial radius ratio @f$(B^2/A^2)@f$
	double A2_B2;///< square of equatorial to polar radius ratio @f$(A^2/B^2)@f$
	double e2;   ///< eccentricity squared @f$ (e^2) @f$
	double e1;   ///< eccentricity one @f$ ((A-B)/(A+B)) @f$
	double ep;   ///< eccentricity prime @f$ (\sqrt{A^2-B^2}/B) @f$ (second eccentricity)
	double ep2;  ///< eccentricity prime squared @f$ ({e^{\prime}}^2) @f$
	
	double m_0;  ///< utm to lat,lon conversion constant m0
	double m_1;  ///< utm to lat,lon conversion constant m1
	double m_2;  ///< utm to lat,lon conversion constant m2
	double m_3;  ///< utm to lat,lon conversion constant m3
	
	double m_f;  ///< lat,lon to utm conversion constant f
	double m_a;  ///< lat,lon to utm conversion constant a
	double m_b;  ///< lat,lon to utm conversion constant b
	double m_c;  ///< lat,lon to utm conversion constant c

public:
	CReferenceEllipsoid(){};
	~CReferenceEllipsoid(){};
	CReferenceEllipsoid(double semi_major, double flattening_inv);

	void setPara(double semi_major, double flattening_inv);
	CReferenceEllipsoid operator =(CReferenceEllipsoid right);
	bool operator == (CReferenceEllipsoid right);
};

/**temperate reference ellipsoid. used to 
*/
struct _refellipsoid 
{
	char name_coor[30];
	char name_ellip[30];
	double semimajor;
	double invflattening;
	_refellipsoid(){memset(this,0,sizeof(_refellipsoid));}
};


/** Reference ellipsoids for geospacial coordinate transforms.
 *
 *  See for example:
 *      http://www.colorado.edu/geography/gcraft/notes/datum/datum.html
 *  or
 *      http://www.nima.mil/GandG/tm83581/toc.htm
 */
namespace GeoRef {
	/** Airy 1830
	 */
	extern  const CReferenceEllipsoid Airy1830;
	/** Australian National
	 */
	extern  const CReferenceEllipsoid AustralianNational;
	/**Clarke1880 ellipsoid,used in algeria
	*/
	extern  const CReferenceEllipsoid Clarke1880;
	/**bj54 Krassolvsky1990 ellipsoid,used in bj54.
	*/
	extern  const CReferenceEllipsoid Krassolvsky1990;
	/** World Geodetic System 1984
	 */
	extern  const CReferenceEllipsoid WGS84;
	/** World Geodetic System 1980
	 */
	extern  const CReferenceEllipsoid GRS80;
	/** World Geodetic System 1972
	 */
	extern  const CReferenceEllipsoid WGS72;
	/** Clarke 1866
	 */
	extern  const CReferenceEllipsoid Clarke1866;
	/**CLARKE 1880
	*/
	extern  const CReferenceEllipsoid clarke1880;
	/** North American Datum 1927
	 */
	extern  const CReferenceEllipsoid NAD27;
}


class GRID;
class LLA;
class ECEF;

/** Convert from Earth centered, Earth fixed (ECEF) coondinates
 *  to latitude, longitude, and altitude (LLA).
 *	@refer大地测量学基础 孔祥元等p38
 *  @param ecef the source coordinates in ECEF
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 *  @return the coordinates in LLA
 */
LLA  ECEFtoLLA(ECEF const &ecef, CReferenceEllipsoid const &_ref = GeoRef::WGS84);

/** Convert from Earth centered, Earth fixed (ECEF) coondinates
 *  to Universal Transverse Mercator (GRID) coordinates.
 *
 *  @param ecef the source coordinates in ECEF
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 *  @return the coordinates in GRID
 */
GRID  ECEFtoGRID(ECEF const &ecef,const double k0=0.9996, CReferenceEllipsoid const &_ref = GeoRef::WGS84);

/** Convert from latitude, longitude, and altitude (LLA) to
 *  Earth centered, Earth fixed (ECEF) coondinates.
 *
 *  @ref:<GPS survey and Data processing> LiZhengHang,HuangJS,p163
 *  @param lla the source coordinates in LLA
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 *  @return the coordinates in ECEF
 */
ECEF  LLAtoECEF(LLA const &lla, CReferenceEllipsoid const &_ref = GeoRef::WGS84);

/** Convert from Universal Transverse Mercator (GRID) coordinates to
 *  Earth centered, Earth fixed (ECEF) coondinates.
 *
 *  @param utm the source coordinates in GRID
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 *  @return the coordinates in ECEF
 */
ECEF  GRIDtoECEF(GRID const &grid, const double k0=0.9996, CReferenceEllipsoid const &_ref = GeoRef::WGS84);

/** Convert from Universal Transverse Mercator (GRID) coordinates to
 *  latitude, longitude, and altitude (LLA).
 *
 *  @ref:
 *  @param utm the source coordinates in GRID
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 *  @return the coordinates in LLA
 */
LLA  GRIDtoLLA(GRID const &grid, const double k0=0.9996, CReferenceEllipsoid const &_ref = GeoRef::WGS84);

/** Convert from latitude, longitude, and altitude (LLA) to GRID coordinates.
 *	k0=1: gauss projection
 *	k0=0.9996 utm projection
 *  @ref   <大地测量学基础>孔祥元 郭际明 刘宗泉等p120,p146
 *  @param lla the source coordinates in LLA
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 *  @param _zone for a specific zone, independent of longitude
 *  @return the coordinates in GRID
 */
GRID  LLAtoGRID(LLA const &lla,const double k0=0.9996, CReferenceEllipsoid const &_ref = GeoRef::WGS84);
//GRID  LLAtoGRID(LLA const &lla,char _zone=-1,const double k0=0.9996,CReferenceEllipsoid const &_ref = GeoRef::WGS84);
//void LLAtoGRID(double lon,double lat,double alt,double* utm,char _zone=-1,const double k0=0.9996);
/** Get the distance between two points along the surface of the
 *  reference ellipsoid.
 *
 *  Both points are projected to altitude = 0, and the distance
 *  calculated along a geodesic path of the reference ellipsoid.
 *
 *  @param p point 1
 *  @param q point 2
 *  @param distance Output: the geodesic distance
 *  @param bearing Output: the bearing to the specified point (in radians relative to true north)
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 */
void  SurfaceDistance(LLA const &p, LLA const &q, double &distance, double &bearing, CReferenceEllipsoid const &_ref = GeoRef::WGS84);


/** Get the distance between two points along the surface of the
 *  reference ellipsoid, including altitude.
 *
 *  This method is very similar to SurfaceDistance, but includes the altitude
 *  difference between the two points in an approximate way that can be used both
 *  at close range and globally.
 *
 *  @param p point 1
 *  @param q point 2
 *  @param distance Output: a combined geodesic and altitude distance
 *  @param bearing Output: the bearing to the specified point (in radians relative to true north)
 *  @param _ref the reference ellipsoid (the default is WGS-84)
 */
void  ShellDistance(LLA const &p, LLA const &q, double &distance, double &bearing, CReferenceEllipsoid const &_ref = GeoRef::WGS84);


/** Latitude, longitude, and altitude coordinates.
 *
 *  A geospatial coordinate class representing latitude, longitude, and
 *  altitude.
 *
 *  There are two distinct XML formats for this type.  The first lists
 *  latitude and longitude in degrees, followed by altitude in meters.
 *  The second uses a degree-minute-second notation for the latitude and
 *  longitude.  The notation for the second format is slighly non-standard
 *  to avoid using the degree symbol.  Examples:
 *
 *      @code <LLA>37.1 -122.43 100.0</LLA> @endcode
 *  and
 *      @code <LLA>37'6"0.0 -122'25"48.0 100.0</LLA> @endcode
 *
 *  @ingroup BaseTypes
 */
class  LLA {

public: // BaseType
	double _lat, _lon, _alt;

	/// String representation.
	std::string asString() const;

	/// Type representation.
	std::string typeString() const { return "type::LLA"; }

	/// Serialize from a Reader.
	void serialize(CArchive*);



	/** Parse the character data from an XML \<LLA\> tag.
	 *
	 *  LLA coordinate format (lat, lon, alt): @n
	 *   <tt> x.x x.x x.x </tt>
	 *
	 *  LLA coordinate format 2 (lat, lon, alt): @n

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -