Skip to content

Instantly share code, notes, and snippets.

@tkanmae
Created July 15, 2015 11:23
Show Gist options
  • Save tkanmae/6379571d40c033780328 to your computer and use it in GitHub Desktop.
Save tkanmae/6379571d40c033780328 to your computer and use it in GitHub Desktop.
Test data for transformation between geodetic coordinates to geocentric ones
//
// This program produces test data for tranformation between geodetic
// coordinates to geocentric ones.
//
// $ clang++ geodetic_geocentric.cpp -o geodetic_geocentric -lGeographic
//
#include <iostream>
#include <exception>
#include <cmath>
#include <GeographicLib/Geocentric.hpp>
#include <stdio.h>
using namespace std;
using namespace GeographicLib;
int main() {
const Geocentric& earth = Geocentric::WGS84();
try {
{
// Everest
double lat = 27.988, lon = 86.925, h = 8848.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
{
// Aconcagua
double lat = -32.653, lon = -70.011, h = 6961.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
{
// Denali
double lat = 63.070, lon = -151.007, h = 6168.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
{
// Kilimanjaro
double lat = 3.076, lon = 37.353, h = 5885.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
{
// Elbrus
double lat = 43.355, lon = 42.439, h = 4741.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
{
// Vinson
double lat = -78.525, lon = -85.617, h = 4892.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
{
// Kosciuszko
double lat = -36.458, lon = 148.262, h = 2228.0;
double X, Y, Z;
earth.Forward(lat, lon, h, X, Y, Z);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", lat, lon, h, X, Y, Z);
}
printf("\n");
{
// Everest
double X = 3.027702e+05, Y = 5.636031e+06, Z = 2.979483e+06;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
{
// Aconcagua
double X = 1.839507e+06, Y = -5.057024e+06, Z = -3.425377e+06;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
{
// McKinley
double X = -2.535850e+06, Y = -1.405240e+06, Z = 5.669015e+06;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
{
// Kilimanjaro
double X = 5.067477e+06, Y = 3.867796e+06, Z = 3.402822e+05;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
{
// Elbrus
double X = 3.430512e+06, Y = 3.136772e+06, Z = 4.359517e+06;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
{
// Vinson
double X = 9.735862e+04, Y = -1.270215e+06, Z = -6.233655e+06;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
{
// Kosciuszko
double X = -4.369467e+06, Y = 2.702643e+06, Z = -3.770511e+06;
double lat, lon, h;
earth.Reverse(X, Y, Z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", X, Y, Z, lat, lon, h);
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment