Skip to content

Instantly share code, notes, and snippets.

@tkanmae
Last active August 29, 2015 14:25
Show Gist options
  • Save tkanmae/4f06e9dfd8288aa22077 to your computer and use it in GitHub Desktop.
Save tkanmae/4f06e9dfd8288aa22077 to your computer and use it in GitHub Desktop.
Test data for transformation between geodetic coordinates and local horizontal ones.
//
// This program produces test data for transformation between geodetic
// coordinates and local horizontal coordinates.
//
// $ cland geodetic_horizontal.cpp -o geodetic_horizontal -lGeographic
//
#include <iostream>
#include <exception>
#include <cmath>
#include <stdio.h>
#include <GeographicLib/Geocentric.hpp>
#include <GeographicLib/LocalCartesian.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
const Geocentric& earth = Geocentric::WGS84();
// Fairbanks, AK
LocalCartesian proj(64.844, -147.723, 136.0, earth);
{
// Everest
double lat = 27.988, lon = 86.925, h = 8848.0;
double x, y, z;
proj.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;
proj.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;
proj.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;
proj.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;
proj.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;
proj.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;
proj.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 = -4.603447e+06, y = 4.238965e+06, z = -5.052065e+06;
double lat, lon, h;
proj.Reverse(x, y, z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", x, y, z, lat, lon, h);
}
{
// Aconcagua
double x = 5.257915e+06, y = -2.476234e+06, z = -8.974420e+06;
double lat, lon, h;
proj.Reverse(x, y, z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", x, y, z, lat, lon, h);
}
{
// Denali
double x = -1.660801e+05, y = -1.936096e+05, z = 9.441103e+02;
double lat, lon, h;
proj.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.640312e+05, y = 5.908744e+06, z = -8.751986e+06;
double lat, lon, h;
proj.Reverse(x, y, z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", x, y, z, lat, lon, h);
}
{
// Elbrus
double x = -8.201288e+05, y = 6.011161e+06, z = -4.359695e+06;
double lat, lon, h;
proj.Reverse(x, y, z, lat, lon, h);
printf("(%e, %e, %e) ==> (%e, %e, %e)\n", x, y, z, lat, lon, h);
}
{
// Vinson
double x = 1.125928e+06, y = -3.172824e+06, z = -1.174982e+07;
double lat, lon, h;
proj.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.618373e+06, y = -3.623843e+06, z = -8.816771e+06;
double lat, lon, h;
proj.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