Geoscience Reference
In-Depth Information
./addct -h
usage: ./addct -ct <ascii_filename> <inputFilename>
14.3.6.2 CreateCopy Mode
In a second version of our utility to add a color table to a raster dataset, we
illustrate how to create a new raster file using the CreateCopy method. In addi-
tion to the update mode in the previous utility, the user can now provide a new
dataset on the command line. We declare a new string from the standard template
library stlsDestImageFilename and add a new condition to the command line
parsing.
string stlsSrcImageFilename;//source raster dataset filename
string stlsCtFilename;//ASCII color table filename
string stlsDestImageFilename;//destination raster dataset filename
try {
//define error stream in case wrong arguments
ostringstream stlosError;
stlosError <<"usage: "<< argv[0] <<" -ct <asciiFilename>
<inputFilename> [<outputFilename>]";
//loop over all command line arguments
for ( int i=1;i<argc;i++){
string stlsOption=argv[i];//convert to std::string
if (stlsOption=="-h"||stlsOption=="--help")
throw (stlosError.str());
else if (stlsOption=="-ct"||stlsOption=="--color table"){
stlsCtFilename=argv[++i];
}
else if (stlsOption.find('-')==0){
cerr <<"Error: unknown option "<< stlsOption << endl;
throw (stlosError.str());
}
else if (stlsSrcImageFilename.empty()){
stlsSrcImageFilename=argv[i];
}
else if (stlsDestImageFilename.empty()){
stlsDestImageFilename=argv[i];
}
else {
cerr <<"Error: multiple input raster files are not supported"<<
endl;
throw (stlosError.str());
}
}
if (stlsSrcImageFilename.empty()){
cerr <<"Error: no raster file provided"<< endl;
throw (stlosError.str());
}
}
catch (string stlsError){
cout << stlsError << endl;
exit(1);
}
 
Search WWH ::




Custom Search