//#! g++ modelsg.cxx -lm -lsgmath -lsgstructure -o modelsg #include #include #include #include //#include #include //void toCartesian(double *x, double *y, double *z, double lat, double lon, double alt); int main(int argc, char *argv[]) { double lon,lat,alt; double x,y,z; SGGeod geod; SGVec3 cart; cart.x()=0.; cart.y()=0.; cart.z()=0.; if (argc != 4) { fprintf(stderr,"USAGE:\n %s lon lat alt\n", argv[0]); return(0); } lon=atof(argv[1]); lat=atof(argv[2]); alt=atof(argv[3]); // std::cout << lat << lon << alt << std::endl; // std::cout << geod << std::endl << cart << std::endl; geod.setLatitudeDeg(lat); geod.setLongitudeDeg(lon); geod.setElevationM(alt); // toCartesian(&x,&y,&z,lat, lon, alt); SGGeodesy::SGGeodToCart(geod,cart); printf("%0.6f %0.6f %0.6f\n", cart.x(), cart.z(), -cart.y()); // std::cout << geod << std::endl << cart << std::endl; } /* void toCartesian(double *x, double *y, double *z, double lat, double lon, double alt) { const double equatorRadius=6378137.0, polarRadius=6356752.3; *z = sin(lon)*cos(lat)*(equatorRadius+alt); *y = cos(lon)*cos(lat)*(equatorRadius+alt); *x = sin(lat)*(polarRadius+alt); } */