39
39
using namespace std;
41
void get_lldepth(double x, double y, double z, double &longitude, double &latitude, double &depth){
41
void get_ll(double x, double y, double z, double &longitude, double &latitude){
43
43
const double pi=4.0*atanl(1.0);
44
const double earth_radius=6378100.0;
45
44
const double rad_to_deg=180.0/pi;
47
46
double r = sqrt(x*x+y*y+z*z);
48
47
longitude = atan2(y, x);
49
48
latitude = acos(z/r);
50
depth = earth_radius - r;
51
49
longitude*=rad_to_deg;
52
50
latitude = 90.0 - latitude*rad_to_deg;
78
double longitude, latitude, depth_tmp;
79
get_lldepth(x[i], y[i], z[i], longitude, latitude, depth_tmp);
76
double longitude, latitude;
77
get_ll(x[i], y[i], z[i], longitude, latitude);
80
78
if(map.HasPoint(longitude, latitude)){
81
79
height[i]=map.GetValue(longitude, latitude);
130
#ifdef DEPTH_UNITTEST
131
// This is a simple test program to check the depth returned for three given lon,lat locations
132
int main(int argc, char **argv){
134
double pi=4.0*atanl(1.0);
135
double deg_to_rad=pi/180.0;
139
string data_file="/data/maps/gridone.grd";
141
double xloc[3], yloc[3], zloc[3], longitude[3], latitude[3];
143
double r=6378100.0; // Approx. radius of Earth
146
longitude[0]=5.974731;
147
latitude[0]=38.387311;
149
xloc[0]=r*cos(latitude[0]*deg_to_rad)*cos(longitude[0]*deg_to_rad);
150
yloc[0]=r*cos(latitude[0]*deg_to_rad)*sin(longitude[0]*deg_to_rad);
151
zloc[0]=r*sin(latitude[0]*deg_to_rad);
154
longitude[1]=6.974731;
155
latitude[1]=39.387311;
157
xloc[1]=r*cos(latitude[1]*deg_to_rad)*cos(longitude[1]*deg_to_rad);
158
yloc[1]=r*cos(latitude[1]*deg_to_rad)*sin(longitude[1]*deg_to_rad);
159
zloc[1]=r*sin(latitude[1]*deg_to_rad);
162
longitude[2]=5.974731;
163
latitude[2]=40.387311;
165
xloc[2]=r*cos(latitude[2]*deg_to_rad)*cos(longitude[2]*deg_to_rad);
166
yloc[2]=r*cos(latitude[2]*deg_to_rad)*sin(longitude[2]*deg_to_rad);
167
zloc[2]=r*sin(latitude[2]*deg_to_rad);
169
cout << "Retrieving bathymetry data.\n";
170
set_from_map_fc(data_file.c_str(), xloc, yloc, zloc, depth, &columns);
172
for (int i = 0; i < columns; i++) {
173
cout << "The depth at ( " << longitude[i] << " , " << latitude[i] << " ) is " << depth[i] << endl;
175
cout << "End of unit test.\n";
180
#ifdef DEPTH_UNITTEST2
181
// This is a simple test program to check the depth returned for three given x,y beta plane locations
182
int main(int argc, char **argv){
187
string data_file="/data/myfluidity/tests/MonaiValley/outfileMonaiValley.grd";
189
double xloc[3], yloc[3];
191
// The Monaia Valley data bounds are
192
// x:actual_range = 0., 5.4916666667
193
// y:actual_range = 0., 3.4083333333
207
cout << "Retrieving bathymetry data.\n";
208
set_from_map_beta_fc(data_file.c_str(), xloc, yloc, depth, &columns);
210
for (int i = 0; i < columns; i++) {
211
cout << "The depth at ( " << xloc[i] << " , " << yloc[i] << " ) is " << depth[i] << endl;
213
cout << "End of unit test.\n";