/* ptest.c pt1.bat = cl /AL ptest.c proj2 */ #include #include #define R 6367.65 #define PI 3.1415927 #define PI2 1.5707963 #define PI4 0.7853981 #define DEG_RAD 0.01745329251 /* converts degrees to radians */ #define KM_MILE 0.621371192 /* converts km to miles */ #define BLACK 0 #define D_GREY 1 #define L_GREY 2 #define WHITE 3 #define RED 4 #define ORANGE 5 #define YELLOW 6 #define GREEN 7 #define CYAN 8 #define BLUE 9 #define MAGENTA 10 #define TAN 11 #define BROWN 12 #define L_BLUE 13 #define BUFF 14 #define D_BLUE 15 #define MAX_PTS 30 int Mouse=0; int ScreenXs=640,ScreenYs=480; double Lat[MAX_PTS],Lon[MAX_PTS],X[MAX_PTS],Y[MAX_PTS]; double Tx[MAX_PTS],Ty[MAX_PTS]; struct control { char proj; int pnum; double lon_0,lon_1,lon_2,lon_p; double lat_0,lat_1,lat_2,lat_p; double pixsize,scale; double x0,y0; double c,C,F,H,k,k0,k1,k2,n,P,rho_0; double omega; /* elevation (tilt of surface plane) */ double gamma; /* azimuth (east of north) */ double horiz; /* radius of horizon arc */ }Constant; char String[10][80]; struct projection { char name[80]; char id; }; unsigned char Buffer[12][640]; extern struct projection *Proj; char P[100]; char C[20][80]; int translate(); double get_dist(); double set_scale(); double rotate(); double strech(); int auto_set_constants(struct control *cc); int xy2ll(double x,double y,double *lat,double *lon,struct control cc); int ll2xy(double lat,double lon,double *x,double *y,struct control cc); int get_constants(struct control *cc,char string[][80],int *nums); int choose_projection(struct control *cc,char *string); main() { int i,j,k,n; char ans,string[100]; int pnum,ret,num; double lat,lon,x,y; int xc=0,yc=0,xs=640,ys=480,speed=8; double clat,clon,cx,cy; FILE *fp,*fpin; do { printf("\n p -- set projection\n"); printf(" c -- check lat/lon to x/y and back again\n"); printf("\n x -- exit program\n\n"); ans=getch(); if(ans=='p') { do { pnum=choose_projection(&Constant,string); }while(pnum<0); printf("Constant.proj = %c\n",Constant.proj); get_constants(&Constant,C,&num); for(i=0;i=0) { printf("x = %lf y = %lf\n",x,y); ret=xy2ll(x,y,&lat,&lon,Constant); if(ret>=0) printf("lat = %lf lon = %lf\n",lat,lon); else printf("Error in function 'xy2ll()'.\n"); } else printf("Error in function 'll2xy()'.\n"); } }while(ans!='x'); }