📄 geopos.h
字号:
* <tt> x'x"x.x x'x"x.x x.x </tt>
*/
void parseXML(const char*);
/// XML post processing.
void convertXML() {}
public:
/** Construct a default LLA.
*/
LLA(): _lat(0.0), _lon(0.0), _alt(0.0) {}
/** Construct a new LLA.
*
* @param lat latitude in radians.
* @param lon longitude in radians.
* @param alt altitude in meters relative to the reference ellipsoid.
*/
LLA(double lat, double lon, double alt=0.0): _lat(lat), _lon(lon), _alt(alt) {}
/** Set latitude, longitude, and altitude in radians.
* @param lat,lon: the latitude and longitude unit is defined by unittype.
* @param unittype: 0,DD:MMSS; 1: DEG; 2: Radian; 3: Second.
*/
void Set(double lat, double lon, double alt ,char unittype);
void Set(double lat, double lon, double alt);
/** retrieve the latitude,longitude and altitude.
* @param unittype: 0,DD:MMSS; 1: DEG; 2: Radian; 3: Second
*/
void Get(double& lat, double& lon,double& alt,char unittype);
/** Set latitude, longitude, and altitude in degrees.
*/
void SetInDegrees(double lat, double lon, double alt=0.0);
/** Get latitude, longitude, and altitude in degree(m)
*/
void GetInDegrees(double& lat, double& lon, double& alt);
/** Get latitude in radians.
*/
inline double latitude() const { return _lat; }
/** Get longitude in radians.
*/
inline double longitude() const { return _lon; }
/** Get altitude in meters.
*/
inline double altitude() const { return _alt; }
/** Get the latitude in degrees.
*/
inline double latitudeInDegrees() const { return toDegrees(_lat); }
/** Get the longitude in degrees.
*/
inline double longitudeInDegrees() const { return toDegrees(_lon); }
/** Set the latitude in degrees.
*/
inline void setLatitudeInDegrees(double latitude) { _lat = toRadians(latitude); }
/** Set the longitude in degrees.
*/
inline void setLongitudeInDegrees(double longitude) { _lon = toRadians(longitude); }
/** Set the latitude in radians.
*/
inline void setLat(double latitude) { _lat = latitude; }
/** Set the longitude in radians.
*/
inline void setLon(double longitude) { _lon = longitude; }
/** Set the altitude in meters.
*/
inline void setAlt(double altitude) { _alt = altitude; }
};
/** Universal Transverse Mercator and altitude coordinates.
*
* A geospatial coordinate class using Universal Transverse Mercator (GRID)
* coordinates plus altitude.
*
* A sample XML tag for this type is @code <GRID>704300 3390210 13T 100.0</GRID> @endcode
* which represents 704300E 3390210N 13T, 100.0 m above the reference ellipsoid.
*
* @ingroup BaseTypes
*/
class GRID {
double _E, _N, _alt,_lon0;
char _zone, _designator;
char _NorS; //in UTMtoLLA,the latitude of the given point must be set before.
public: // BaseType
/// String representation.
std::string asString() const;
/// Type representation.
std::string typeString() const { return "type::GRID"; }
/// Serialize from a Reader.
void serialize(CArchive*);
/** Parse the character data from an XML \<GRID\> tag.
*
* GRID coordinate format (easting, northing, zone, alt): @n
* <tt>x.x x.x zone x.x</tt> @n
* where @c zone is an integer followed by a GRID latitude designator,
* such as @c 10T
*/
void parseXML(const char*);
/// XML post processing.
void convertXML() {}
public:
/** Get the designator character for a given latitude.
*/
static char GetDesignator(double latitude);
//Get zone character for a given longitude and latitude.
static void GetZoneAndCM(double lon, double lat,char& zone,double& lon0);
/** Construct a default (invalid) GRID
*/
GRID(): _E(0.0), _N(0.0), _alt(0.0), _zone(0), _designator('X') {}
/** Construct a GRID.
*/
GRID(double easting_, double northing_, char zone_, char designator_, double alt=0.0) {
set(easting_, northing_, zone_, designator_, alt);
}
/** Set the current position from GRID coordinates.
*
* @param easting_ GRID easting
* @param northing_ GRID northing
* @param zone_ GRID zone
* @param designator_ GRID zone letter
* @param alt altitude above the reference ellipse (in meters)
*/
void set(double easting_, double northing_,
char zone_, char designator_, double alt=0.0) {
_E = easting_;
_N = northing_;
_zone = zone_;
_designator = designator_;
_alt = alt;
// XXX check values
}
/** Set the current position from GRID coordinates.
*
* @param easting_ GRID easting
* @param northing_ GRID northing
* @param zone_ GRID zone (e.g. "10T")
* @param alt altitude above the reference ellipse (in meters)
*/
void Set(double easting_, double northing_, const double lon0, double alt = 0.0, const char NorS='N');
void Get(double& easting, double& northing,char& zone, double& alt);
/** Get the easting coordinate.
*/
inline double easting() const { return _E; }
/** Get the northing coordinate.
*/
inline double northing() const { return _N; }
/** Get the zone.
*/
inline char zone() const { return _zone; }
/** Get the latitude designator letter.
*/
inline char designator() const { return _designator; }
/** Get altitude in meters.
*/
inline double altitude() const { return _alt; }
inline double lon0() const {return _lon0;}
inline char NorS()const {return _NorS; }
/** Check that the GRID coordinates are valid.
*/
bool valid() const;
};
/** Earth-centered, earth-fixed coordinates.
*
* A geospatial coordinate class representing Earth Centered, Earth
* Fixed coordinates.
*
* The XML format for this type is @code <ECEF> X Y Z </ECEF> @endcode
*
* @ingroup BaseTypes
*/
class ECEF{//: public Vector3 {
public: // BaseType (most methods inherited from Vector3)
double _x, _y, _z;
/// Type representation.
std::string typeString() const { return "type::ECEF"; }
public:
/** Construct a default ECEF (at the center of the Earth).
*/
ECEF(): _x(0.0), _y(0.0), _z(0.0) {}
/** Construct a new ECEF
*/
ECEF(double x_, double y_, double z_): _x(x_), _y(y_), _z(z_) {}
/// Get the value of the x-component.
inline double x() const { return _x; }
/// Get the value of the y-component.
inline double y() const { return _y; }
/// Get the value of the z-component.
inline double z() const { return _z; }
ECEF const &operator = ( ECEF const & ecef) {
_x=ecef._x; _y=ecef._y; _z=ecef._z;
return *this;
}
inline void Get(double& x,double& y,double& z){
x=_x;y=_y;z=_z;
}
/**set ecef coordinates values
*/
void Set(double x_,double y_,double z_){
_x=x_;
_y=y_;
_z=z_;
}
};
std::ostream &operator <<(std::ostream &o, LLA const &q);
std::ostream &operator <<(std::ostream &o, GRID const &q);
std::ostream &operator <<(std::ostream &o, ECEF const &q);
#endif // __CSPLIB_DATA_GEOPOS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -