initial upload
This commit is contained in:
62
archive/xyz2gpx/main.cpp
Normal file
62
archive/xyz2gpx/main.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "func.h"
|
||||
|
||||
void disp_help()
|
||||
{
|
||||
cout<<"xyz2gpx 1.0 - convet a xyz table file into .gpx file for portable GPX device"<<endl<<endl
|
||||
<<"syntax: xyz2gpx <xyz_file> [-o<outfile>]"<<endl
|
||||
<<" -o specify output file's name, the input name will be used if -o is absent"<<endl;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
XyzGpx XG;
|
||||
char command_type[1024] = {0};
|
||||
char inname[1024] = {0};
|
||||
char nametype[1024] = {0};
|
||||
char outname[1024] = {0};
|
||||
if (argc==1)
|
||||
{
|
||||
disp_help();
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(argv[1],"%s",inname);//按格式读入文件名与扩展名
|
||||
if(!strcmp(inname,""))//检查文件名是否为空
|
||||
{
|
||||
cout<<BOLDRED<<"==> "<<RESET<<"bad syntax: "<<argv[1]<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc>2)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
sscanf(argv[i],"%2s",command_type);
|
||||
if(!strcmp(command_type,OUTFILE))//命令为文件名设置符
|
||||
{
|
||||
sscanf(argv[i],"%*2s%s",outname);//按格式读入文件名与扩展名
|
||||
if(!strcmp(outname,""))//检查文件名是否为空
|
||||
{
|
||||
cout<<BOLDRED<<"==> "<<RESET<<"bad syntax: "<<argv[i]<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(outname,""))
|
||||
{
|
||||
char temp[1024] = {0};
|
||||
char temp2[1024] = {0};
|
||||
sscanf(inname,"%[^.]%s",temp,temp2);
|
||||
strcpy(outname,temp);
|
||||
strcat(outname,".gpx");
|
||||
}
|
||||
|
||||
if (!XG.readxyz(inname))
|
||||
{
|
||||
XG.outgpx(outname);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user