コード例 #1
0
ファイル: d8.cpp プロジェクト: bpass/cegis
void main(int argc,char **argv)
{
  char demfile[MAXLN], pointfile[MAXLN], slopefile[MAXLN], flowfile[MAXLN];
  int err,nmain;
    short useflowfile=0;

   if(argc < 2)
    {  
       printf("Usage:\n %s filename [fdrfile]\n",argv[0]);
       printf("The following are appended BEFORE\n");
       printf("the files are opened:\n");
       printf("fel    Flooded Elevation data\n");
       printf("p      D8 flow directions\n");
       printf("sd8    D8 slope data\n");
	   printf("optional fdr file of existing stream directions\n");
       exit(0);  
    }
    nmain=nameadd(pointfile,argv[1],"p");
	nmain=nameadd(slopefile,argv[1],"sd8");
    nmain=nameadd(demfile,argv[1],"fel");
	if(argc > 2)
	{
		useflowfile=1;
		nmain=nameadd(flowfile,argv[2],"n");
	}

    if(err=setdird8(demfile, pointfile, slopefile,flowfile,useflowfile) != 0)
        printf("setdird8 error %d\n",err);
}    
コード例 #2
0
int main(int argc,char **argv)
{
  char demfile[MAXLN], pointfile[MAXLN], slopefile[MAXLN], flowfile[MAXLN];
  int err, i, prow = 0, pcol = 0;
    short useflowfile=0;

   if(argc < 2)
    {  
       printf("Error: To run this program, use either the Simple Usage option or\n");
	   printf("the Usage with Specific file names option\n");
	   goto errexit; 
    }
   else if(argc > 2)
	{
		i = 1;
//		printf("You are running %s with the Specific File Names Usage option.\n", argv[0]);
	}
	else {
		i = 2;
//		printf("You are running %s with the Simple Usage option.\n", argv[0]);
	}
	while(argc > i)
	{
		if(strcmp(argv[i],"-fel")==0)
		{
			i++;
			if(argc > i)
			{
				strcpy(demfile,argv[i]);
				i++;
			}
			else goto errexit;
		}
                else if(strcmp(argv[i],"-mf")==0)
                {
                        i++;
                        if(argc > i)
                        {
                                prow = atoi(argv[i]);
                                i++;
                                if(argc > i)
                                {
                                        pcol = atoi(argv[i]);
                                        i++;
                                }
                                else goto errexit;
                        }
                        else goto errexit;
                        if(prow <=0 || pcol <=0)
                                goto errexit;
                }
		else if(strcmp(argv[i],"-sd8")==0)
		{
			i++;
			if(argc > i)
			{
				strcpy(slopefile,argv[i]);
				i++;
			}
			else goto errexit;
		}
		else if(strcmp(argv[i],"-p")==0)
		{
			i++;
			if(argc > i)
			{
				strcpy(pointfile,argv[i]);
				i++;
			}
			else goto errexit;
		}
		else if(strcmp(argv[i],"-sfdr")==0)
		{
			i++;
			if(argc > i)
			{
				strcpy(flowfile,argv[i]);
				i++;
				useflowfile=1;
			}
			else goto errexit;
		}

		else 
		{
			goto errexit;
		}
	}
	if( argc == 2) {
		nameadd(demfile,argv[1],"fel");
		nameadd(pointfile,argv[1],"p");
		nameadd(slopefile,argv[1],"sd8");		
	}

    if((err=setdird8(demfile, pointfile, slopefile,flowfile,useflowfile, prow, pcol)) != 0)
        printf("setdird8 error %d\n",err);

	return 0;

	errexit:
	   printf("Simple Usage:\n %s <basefilename>\n",argv[0]);
	   printf("Usage with specific file names:\n %s -fel <demfile>\n",argv[0]);
       printf("-sd8 <slopefile> -p <angfile> [-sfdr <flowfile>]\n");
	   printf("<basefilename> is the name of the raw digital elevation model\n");
	   printf("<demfile> is the pit filled or carved DEM input file.\n");
	   printf("<slopefile> is the slope output file.\n");
	   printf("<pointfile> is the output d8 flow direction file.\n");
       printf("[-sfdr <flowfile>] is the optional user imposed stream flow direction file.\n");
       printf("The following are appended to the file names\n");
       printf("before the files are opened:\n");
       printf("fel    carved or pit filled input elevation file\n");
       printf("sd8    D8 slope file (output)\n");
	   printf("p   D8 flow direction output file\n");
       exit(0);
}