Mapper
get_lat_lon.c
Go to the documentation of this file.
1 #include "prototypes.h"
2 
3 void get_lat_lon(int newx,int newy,float *lat,float *lon)
4 
5 {
6 
7 extern struct dval dval;
8 double conv=.0174,c,lonf;
9 double t1,t2,t3,t4,t5,lat1,lat2;
10 
11 t1=.0001;
12 
13 lonf= atan(((double)newy-dval.yo)/(t1))/conv-90.;
14 
15 t1=(double)newx-dval.xo;
16 
17 *lon= atan(((double)newy-dval.yo)/(t1))/conv;
18 
19 if(*lon > 0)
20  *lon=-180+*lon-2*lonf;
21 
22 *lon=*lon+90+dval.lo;
23 
24 c=dval.a*cos((*lon-dval.lo-90)*conv)/((double)newx-dval.xo);
25 c=pow(c,2);
26 
27 t1=1/(1+c);
28 t2=1-c;
29 t3=pow(2*t1,2);
30 t4=4*t2*t1;
31 t5=pow(t3-t4,.5)/2;
32 
33 if(fabs(-t1+t5) > 1.0)
34  lat1=-9999;
35 else
36  lat1=asin(-t1+t5)/conv;
37 
38 if(fabs(-t1-t5) > 1.0)
39  lat2=-9999;
40 else
41  lat2=asin(-t1-t5)/conv;
42 
43 if(lat1 > 0 && lat1 < 90)
44  *lat=lat1;
45 
46 else
47  *lat=lat2;
48 
49 return;
50 
51 }
52 
53 
54 
55 
56 
57 
58 
void get_lat_lon(int newx, int newy, float *lat, float *lon)
Definition: get_lat_lon.c:3
double lat
Definition: mapp2h.h:41
double lon
Definition: mapp2h.h:41
Definition: misc.h:470
double lo
Definition: misc.h:475
double a
Definition: misc.h:472
double yo
Definition: misc.h:474
double xo
Definition: misc.h:473