C++ proj.4 地心坐标系转wgs84坐标系


#include 
#include 
#include "proj_api.h"
#include

using namespace std;

int main_g()
{
    projPJ pj_geocent, pj_longlat;
    double x, y, z;

    if (!(pj_geocent = pj_init_plus("+proj=geocent +datum=WGS84 +units=m +no_defs")))
        return 1;
    if (!(pj_longlat = pj_init_plus("+proj=longlat +datum=WGS84 +no_defs")))
        return 1;


    x = -2253241.8393135895;
    y = 5016470.230646026;
    z = 3220061.2176725552;
    int p = pj_transform(pj_geocent, pj_longlat, 1, 1, &x, &y, &z);
    cout << p << endl;
    printf("%.15f\t%.15f\t%.15f\n", x / DEG_TO_RAD, y / DEG_TO_RAD, z);


    pj_free(pj_longlat);
    pj_free(pj_geocent);

    return 0;
}

你可能感兴趣的:(C++ proj.4 地心坐标系转wgs84坐标系)