我找到了一个将Latitude / Langitude转换为UTM坐标的C ++代码。
代码为here。
我想使用.NET GUI(Windows窗体)而不是控制台屏幕。
现在我不是在控制台中输入值22.2 33.3
,而是从textBox
读取它。然后调用转换函数。
我遇到的问题是我不知道应该将哪些参数传递给函数
`CvtLine(int C, char**V, char*p)`
从控制台应用程序的主要功能调用:
int main(int argc, char**argv){ //2010-08-11: was void main(...
char buf[256]; char*p; int L,ac; char*av[129]; //vars for reading stdin
cout<<setiosflags(ios::fixed); //decided against including ios::showpoint
Fmt=fUT4|fLLD|fLLDM; //default for Fmt, if not specified by input
--argc; ++argv; //remove spurious first element of argv array
while(argc && memcmp(argv[0],"--",2)==0){ //handle leading options: --Outputformat, --test, --help
if (isdigit(argv[0][2])) Fmt=atoi(argv[0]+2); //for --<DIGIT>, parse Outputformat into Fmt
else if(strcmp(argv[0],"--test")==0) {Testcases(); return 0;} //for --test, run testcases & exit
else {Usage(); return 0;} //for --help, show Usage & exit
--argc; ++argv;
}
if(argc==0) while(cin.getline(buf,256), cin.good()){ //0 args, read stdin converting each line
p=buf; ac=0;
while(1){ while(*p&&strchr(" \t",*p))++p; if(*p==0||*p=='#')break; av[ac++]=p; while(*p&&!strchr(" \t#",*p))++p;} //break line into whitespace-separated words
if(ac>=2&&ac<=4) CvtLine(ac,av,p); //line with 2|3|4 words, convert and print
else if(ac==0) cout<<buf<<"\n"; //line with no words, echo the line (comments)
else cout<<"==invalid number-of-words: "<<buf<<"\n"; //anything else is invalid, produce errmsg
}
else if(argc>=2&&argc<=4) CvtLine(argc,argv,""); //2|3|4 args, convert and print
else Usage(); //argc other than 0|2|3 is invalid, show Usage
return 0; //2010-08-11: added when void became illegal
}
答案 0 :(得分:1)
查看.NET Spatial Reference和Projection Engine库。 http://projnet.codeplex.com/
.NET空间参考和投影引擎
Proj.NET在大地测量之间执行点对点坐标转换 用于fx的坐标系。地理信息系统(GIS) 或GPS应用程序。
它们的FAQ,有一个关于系统之间转换的代码示例。 Projecting points from one coordinate system to another