解释说明:
Geocentric coordinates
Convert between geodetic coordinates latitude = lat, longitude = lon, height = h (measured vertically from the surface of the ellipsoid) to geocentric coordinates (X, Y, Z). The origin of geocentric coordinates is at the center of the earth. The Z axis goes thru the north pole, lat = 90°. The X axis goes thru lat = 0, lon = 0. Geocentric coordinates are also known as earth centered, earth fixed (ECEF) coordinates.
(地心坐标
将大地坐标纬度=纬度,经度=经度,高度= h(从椭球表面垂直测量)转换为地心坐标(X, Y, Z)。地心坐标的原点在地球的中心。Z轴穿过北极,纬度为90度。X轴经纬度为0,经度为0。地心坐标也被称为地球中心,地球固定(ECEF)坐标。)
引用方式
#include <GeographicLib/Geocentric.hpp>
Public Member Functions
Geocentric (real a, real f)
Geocentric ()
void Forward (real lat, real lon, real h, real &X, real &Y, real &Z) const
void Forward (real lat, real lon, real h, real &X, real &Y, real &Z, std::vector< real > &M) const
void Reverse (real X, real Y, real Z, real &lat, real &lon, real &h) const
void Reverse (real X, real Y, real Z, real &lat, real &lon, real &h, std::vector< real > &M) const
Static Public Member Functions
static const Geocentric & WGS84 ()
Example of use:
// Example of using the GeographicLib::Geocentric class
#include <iostream>
#include <exception>
#include <cmath>
#include <GeographicLib/Geocentric.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
Geocentric earth(Constants::WGS84_a(), Constants::WGS84_f());
// Alternatively: const Geocentric& earth = Geocentric::WGS84();
{
// Sample forward calculation
double lat = 27.99, lon = 86.93, h = 8820; // Mt Everest
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
cout << floor(X / 1000 + 0.5) << " "
<< floor(Y / 1000 + 0.5) << " "
<< floor(Z / 1000 + 0.5) << "\n";
}
{
// Sample reverse calculation
double X = 302e3, Y = 5636e3, Z = 2980e3;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
cout << lat << " " << lon << " " << h << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}