-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_sphere.cpp
More file actions
61 lines (52 loc) · 1.44 KB
/
test_sphere.cpp
File metadata and controls
61 lines (52 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Sample code: test_sphere.cpp
// Compile: g++ -o test_sphere test_sphere.cpp datum.cpp utm.cpp
// Reporoduce tables 2-11 AND 3-7 of DMA TM 8358.2
#include<iostream>
#include<iomanip>
#include<cmath>
#include"datum.h"
#include"utm.h"
// Test of the exact spherical TM conversion. Reproduce Table 10 from
// "MAP PROJECTIONS; A WORKING MANUAL", John Snyder, USGS Professional
// Paper 1395, 1987. Page 59-60.
#include<iostream>
#include<sstream>
#include<iomanip>
#define RAD(x) ((x)/180.0*M_PI)
int main()
{
for(unsigned ilat=0;ilat<10;ilat++)
{
if(ilat!=0)std::cout << std::endl;
double lat_rad=double(9-ilat)*RAD(10);
double x[10];
double y[10];
for(unsigned ilon=0;ilon<10;ilon++)
{
double lon_rad=double(ilon)*RAD(10);
geographic_to_tm_sphere(1.0, 1.0, 0.0, 0.0, 0.0,
lat_rad, lon_rad, &y[ilon], &x[ilon]);
#if 0
// Test FORWARD followed by BACKWARD conversion
tm_to_geographic_sphere(1.0, 1.0, 0.0, 0.0, 0.0,
y[ilon], x[ilon], &y[ilon], &x[ilon]);
y[ilon] *= 180/M_PI;
x[ilon] *= 180/M_PI;
#endif
}
for(unsigned ilon=0;ilon<10;ilon++)
{
if(ilon)std::cout << ' ';
std::cout << std::fixed << std::setw(7) << std::setprecision(5)
<< x[ilon];
}
std::cout << std::endl;
for(unsigned ilon=0;ilon<10;ilon++)
{
if(ilon)std::cout << ' ';
std::cout << std::fixed << std::setw(7) << std::setprecision(5)
<< y[ilon];
}
std::cout << std::endl;
}
}