本文整理汇总了C++中RGlibPauseOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ RGlibPauseOpen函数的具体用法?C++ RGlibPauseOpen怎么用?C++ RGlibPauseOpen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RGlibPauseOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
int argPos, argNum = argc, ret, verbose = false;
char *title = (char *) NULL, *subject = (char *) NULL;
char *domain = (char *) NULL, *version = (char *) NULL;
DBObjData *netData, *pntData;
for (argPos = 1; argPos < argNum;) {
if (CMargTest (argv[argPos], "-t", "--title")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing title!");
return (CMfailed);
}
title = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-u", "--subject")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing subject!");
return (CMfailed);
}
subject = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-d", "--domain")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing domain!");
return (CMfailed);
}
domain = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-v", "--version")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing version!");
return (CMfailed);
}
version = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input network> <output point>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -t,--title [dataset title]");
CMmsgPrint(CMmsgInfo, " -u,--subject [subject]");
CMmsgPrint(CMmsgInfo, " -d,--domain [domain]");
CMmsgPrint(CMmsgInfo, " -v,--version [version]");
CMmsgPrint(CMmsgInfo, " -V,--verbose");
CMmsgPrint(CMmsgInfo, " -h,--help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
netData = new DBObjData();
ret = (argNum > 1) && (strcmp(argv[1], "-") != 0) ? netData->Read(argv[1]) : netData->Read(stdin);
if ((ret == DBFault) || (netData->Type() != DBTypeNetwork)) {
delete netData;
return (CMfailed);
}
if (title == (char *) NULL) title = (char *) "River Confluences";
if (subject == (char *) NULL) subject = netData->Document(DBDocSubject);
if (domain == (char *) NULL) domain = (char *) netData->Document(DBDocGeoDomain);
if (version == (char *) NULL) version = (char *) "0.01pre";
pntData = new DBObjData(title, DBTypeVectorPoint);
pntData->Document(DBDocSubject, subject);
pntData->Document(DBDocGeoDomain, domain);
pntData->Document(DBDocVersion, version);
if ((ret = RGlibNetworkConfluences(netData, pntData)) == DBSuccess)
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? pntData->Write(argv[2]) : pntData->Write(stdout);
delete netData;
delete pntData;
if (verbose) RGlibPauseClose();
return (ret);
}
示例2: main
//.........这里部分代码省略.........
if (CMargTest (argv[argPos], "-v", "--version")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing version!");
return (CMfailed);
}
version = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-s", "--shadeset")) {
int codes[] = {DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation};
const char *options[] = {"standard", "grey", "blue", "blue-to-red", "elevation", (char *) NULL};
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing shadeset!");
return (CMfailed);
}
if ((shadeSet = CMoptLookup(options, argv[argPos], true)) == DBFault) {
CMmsgPrint(CMmsgUsrError, "Invalid shadeset!");
return (CMfailed);
}
shadeSet = codes[shadeSet];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input grid> <output grid>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -n,--network [network coverage]");
CMmsgPrint(CMmsgInfo, " -t,--title [dataset title]");
CMmsgPrint(CMmsgInfo, " -u,--subject [subject]");
CMmsgPrint(CMmsgInfo, " -d,--domain [domain]");
CMmsgPrint(CMmsgInfo, " -s,--shadeset [standard|grey|blue|blue-to-red|elevation]");
CMmsgPrint(CMmsgInfo, " -v,--version [version]");
CMmsgPrint(CMmsgInfo, " -V,--verbose");
CMmsgPrint(CMmsgInfo, " -h,--help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
if (networkName == (char *) NULL) {
CMmsgPrint(CMmsgUsrError, "Network is not specified");
return (CMfailed);
}
netData = new DBObjData();
if ((netData->Read(networkName) == DBFault) || (netData->Type() != DBTypeNetwork)) {
delete netData;
return (CMfailed);
}
grdData = new DBObjData();
ret = (argNum > 1) && (strcmp(argv[1], "-") != 0) ? grdData->Read(argv[1]) : grdData->Read(stdin);
if ((ret == DBFault) || (grdData->Type() != DBTypeGridContinuous)) {
delete netData;
delete grdData;
return (CMfailed);
}
if (title == (char *) NULL) title = (char *) "Cell Slopes";
if (subject == (char *) NULL) subject = grdData->Document(DBDocSubject);
if (domain == (char *) NULL) domain = (char *) netData->Document(DBDocGeoDomain);
if (version == (char *) NULL) version = (char *) "0.01pre";
data = DBNetworkToGrid(netData, DBTypeGridContinuous);
data->Name(title);
data->Document(DBDocSubject, subject);
data->Document(DBDocGeoDomain, domain);
data->Document(DBDocVersion, version);
grdData->Flags(DBDataFlagDispModeContShadeSets, DBClear);
grdData->Flags(shadeSet, DBSet);
if ((ret = RGlibNetworkCellSlopes(netData, grdData, data)) == DBSuccess)
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);
delete data;
delete netData;
delete grdData;
if (verbose) RGlibPauseClose();
return (ret);
}
示例3: main
//.........这里部分代码省略.........
else
{
CMmsgPrint (CMmsgUsrError,"No data file, reading from stdin!");
if (header.Read(stdin) == DBFault) { delete dbData; return(DBFault); }
if (dbData->Read(stdin) == DBFault) { delete dbData; return(DBFault); }
}
if(All_Fields)
{
title = dbData->Name();
domain = dbData->Document(DBDocGeoDomain);
subject = dbData->Document(DBDocSubject);
version = dbData->Document(DBDocVersion);
type = DBDataTypeString(header.Type ());
institute = dbData->Document(DBDocCitationInst);
person = dbData->Document(DBDocOwnerPerson);
citation = dbData->Document(DBDocCitationRef);
comment = dbData->Document(DBDocComment);
source = dbData->Document(DBDocSourcePerson);
}
else
{
for (argPos = 1;argPos < argNum; ) {
if (CMargTest (argv [argPos],"-t","--title")) {
title = dbData->Name();
if(title == (char *) NULL) title = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--domain")) {
domain = dbData->Document(DBDocGeoDomain);
if(domain == (char *) NULL) domain = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-s","--subject")) {
subject = dbData->Document(DBDocSubject);
if(subject == (char *) NULL) subject = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version")) {
version = dbData->Document(DBDocVersion);
if(version == (char *) NULL) version = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-n","--institute")) {
institute = dbData->Document(DBDocCitationInst);
if(institute == (char *) NULL) institute = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-p","--person")) {
person = dbData->Document(DBDocOwnerPerson);
if(person == (char *) NULL) person = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-i","--citation")) {
citation = dbData->Document(DBDocCitationRef);
if(citation == (char *) NULL) citation = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-c","--comment")) {
comment = dbData->Document(DBDocComment);
if(comment == (char *) NULL) comment = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-S","--source")) {
source = dbData->Document(DBDocSourcePerson);
if(source == (char *) NULL) source = &ch;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if ((argv[argPos][0] == '-') && (strlen (argv[argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv[argPos]); return (CMfailed); }
argPos++;
}
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
if (title == &ch) printf("Title: N/A\n"); else if (title != (char *) NULL) printf("Title: %s\n", title);
if (domain == &ch) printf("Domain: N/A\n"); else if (domain != (char *) NULL) printf("Domain: %s\n", domain);
if (subject == &ch) printf("Subject: N/A\n"); else if (subject != (char *) NULL) printf("Subject: %s\n", subject);
if (version == &ch) printf("Version: N/A\n"); else if (version != (char *) NULL) printf("Version: %s\n", version);
if (type == &ch) printf("Data Type: N/A\n"); else if (type != (char *) NULL) printf("Data Type: %s\n", type);
if (institute == &ch) printf("Citation Institute: N/A\n"); else if (institute != (char *) NULL) printf("Citation Institute: %s\n",institute);
if (citation == &ch) printf("Citation Reference: N/A\n"); else if (citation != (char *) NULL) printf("Citation Reference: %s\n",citation);
if (person == &ch) printf("Person: N/A\n"); else if (person != (char *) NULL) printf("Person: %s\n", person);
if (source == &ch) printf("Source: N/A\n"); else if (source != (char *) NULL) printf("Source: %s\n", source);
if (comment == &ch) printf("Comment: N/A\n"); else if (comment != (char *) NULL) printf("Comment: %s\n", comment);
if (verbose) RGlibPauseClose ();
return (0);
}
示例4: main
int main (int argc,char *argv [])
{
int argPos, argNum = argc, ret, verbose = false;
char *title = (char *) NULL, *subject = (char *) NULL;
char *domain = (char *) NULL, *version = (char *) NULL;
char *networkName = (char *) NULL;
DBObjData *data, *netData, *grdData;
for (argPos = 1;argPos < argNum; )
{
if (CMargTest (argv [argPos],"-n","--network"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing network!"); return (CMfailed); }
networkName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-t","--title"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing title!"); return (CMfailed); }
title = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-u","--subject"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing subject!"); return (CMfailed); }
subject = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--domain"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing domain!"); return (CMfailed); }
domain = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing version!"); return (CMfailed); }
version = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input grid> <output grid>",CMfileName(argv[0]));
CMmsgPrint (CMmsgInfo," -n,--network [network]");
CMmsgPrint (CMmsgInfo," -t,--title [dataset title]");
CMmsgPrint (CMmsgInfo," -u,--subject [subject]");
CMmsgPrint (CMmsgInfo," -d,--domain [domain]");
CMmsgPrint (CMmsgInfo," -v,--version [version]");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
if (networkName == (char *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Network is not specified"); return (CMfailed); }
netData = new DBObjData ();
if ((netData->Read (networkName) == DBFault) || (netData->Type () != DBTypeNetwork))
{ delete netData; return (CMfailed); }
grdData = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? grdData->Read (argv [1]) : grdData->Read (stdin);
if ((ret == DBFault) || (grdData->Type () != DBTypeGridContinuous))
{ delete netData; delete grdData; return (CMfailed); }
if (title == (char *) NULL) title = (char *) "Basin Histogram";
if (subject == (char *) NULL) subject = grdData->Document (DBDocSubject);
if (domain == (char *) NULL) domain = netData->Document (DBDocGeoDomain);
if (version == (char *) NULL) version = (char *) "0.01pre";
data = new DBObjData (title,DBTypeTable);
data->Document (DBDocSubject,subject);
data->Document (DBDocGeoDomain,domain);
data->Document (DBDocVersion,version);
if ((ret = RGlibNetworkHistogram (netData,grdData,data)) == DBSuccess)
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
int shadeCodes [] = { DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation };
const char *shadeSets [] = { "standard","grey","blue","blue-to-red","elevation", (char *) NULL };
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing shadeset!"); return (CMfailed); }
if ((shadeSet = CMoptLookup (shadeSets,argv [argPos],true)) == CMfailed)
{ CMmsgPrint (CMmsgUsrError,"Invalid shadeset!"); return (CMfailed); }
shadeSet = shadeCodes [shadeSet];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input grid> <output grid>",CMfileName(argv[0]));
CMmsgPrint (CMmsgInfo," -k,--kernelsize");
CMmsgPrint (CMmsgInfo," -f,--kerneloffset");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
{
CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3)
{
CMmsgPrint (CMmsgUsrError,"Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen (argv[0]);
inData = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? inData->Read (argv [1]) : inData->Read (stdin);
if ((ret == DBFault) || ((inData->Type () != DBTypeGridContinuous) && (inData->Type () != DBTypeGridDiscrete)))
{
delete inData;
return (CMfailed);
}
inGridIF = new DBGridIF (inData);
if ((outData = DBGridToGrid (inData,DBTypeGridContinuous)) == (DBObjData *) NULL) return (CMfailed);
if (title != (char *) NULL) outData->Name (title);
if (subject != (char *) NULL) outData->Document (DBDocSubject, subject);
if (domain != (char *) NULL) outData->Document (DBDocGeoDomain, domain);
if (version != (char *) NULL) outData->Document (DBDocVersion, version);
outGridIF = new DBGridIF (outData);
layerNum = inGridIF->LayerNum ();
for (layerID = 0;layerID < layerNum;++layerID)
{
inLayerRec = inGridIF->Layer (layerID);;
if (layerID == 0)
{
outLayerRec = outGridIF->Layer (layerID);
outGridIF->RenameLayer (outLayerRec, inLayerRec->Name ());
}
else outLayerRec = outGridIF->AddLayer (inLayerRec->Name ());
beginLayerID = layerID >= offset ? layerID - offset : 0;
endLayerID = (layerID - offset + kernel) < layerNum ? (layerID - offset + kernel) : layerNum;
// CMmsgPrint (CMmsgDebug, "LayerID: %d Kernel: %d Offset: %d Begin: %d End: %d", layerID, kernel, offset, beginLayerID, endLayerID);
for (pos.Row = 0; pos.Row < inGridIF->RowNum (); pos.Row++)
{
for (pos.Col = 0; pos.Col < inGridIF->ColNum (); pos.Col++)
{
num = 0;
sum = 0.0;
for (i = beginLayerID; i < endLayerID; ++i)
{
if (inGridIF->Value (i, pos, &value) == false) continue;
sum = sum + value;
num++;
}
outGridIF->Value (outLayerRec,pos,num > 0 ? sum / (DBFloat) num : outGridIF->MissingValue ());
}
}
outGridIF->RecalcStats (outLayerRec);
}
ret = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? outData->Write (argv [2]) : outData->Write (stdout);
delete inGridIF;
delete outGridIF;
delete inData;
delete outData;
if (verbose) RGlibPauseClose ();
return (ret);
}
示例6: main
//.........这里部分代码省略.........
{ CMmsgPrint (CMmsgUsrError,"Missing subject!"); return (CMfailed); }
subject = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--domain"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing domain!"); return (CMfailed); }
domain = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing version!"); return (CMfailed); }
version = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-s","--shadeset"))
{
int shadeCodes [] = { DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation };
const char *shadeSets [] = { "standard","grey","blue","blue-to-red",
"elevation", (char *) NULL };
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing shadeset!"); return (CMfailed); }
if ((shadeSet = CMoptLookup (shadeSets,argv [argPos],true)) == DBFault)
{ CMmsgPrint (CMmsgUsrError,"Invalid shadeset!"); return (CMfailed); }
shadeSet = shadeCodes [shadeSet];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <continuous grid>",CMfileName(argv[0]));
CMmsgPrint (CMmsgInfo," -o,--operation [+|-|*|/|^]");
CMmsgPrint (CMmsgInfo," -g,--grid [grid name]");
CMmsgPrint (CMmsgInfo," -c,--constant [constant value]");
CMmsgPrint (CMmsgInfo," -m,--merge [true|false]");
CMmsgPrint (CMmsgInfo," -t,--title [dataset title]");
CMmsgPrint (CMmsgInfo," -u,--subject [subject]");
CMmsgPrint (CMmsgInfo," -d,--domain [domain]");
CMmsgPrint (CMmsgInfo," -v,--version [version]");
CMmsgPrint (CMmsgInfo," -s,--shadeset [standard|grey|blue|blue-to-red|elevation]");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
data = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? data->Read (argv [1]) : data->Read (stdin);
if ((ret == DBFault) || (data->Type () != DBTypeGridContinuous))
{ delete data; return (CMfailed); }
if (constSet) DBGridOperation (data,constant,operation);
if (gridName != (char *) NULL)
{
gridData = new DBObjData ();
if ((gridData->Read (gridName) != DBSuccess) || (gridData->Type () != DBTypeGridContinuous))
{ delete data; delete gridData; return (CMfailed); }
DBGridOperation (data,gridData,operation,merge);
delete gridData;
}
if (title != (char *) NULL) data->Name (title);
if (subject != (char *) NULL) data->Document (DBDocSubject,subject);
if (domain != (char *) NULL) data->Document (DBDocGeoDomain,domain);
if (version != (char *) NULL) data->Document (DBDocVersion,version);
if (shadeSet != DBFault)
{
data->Flags (DBDataFlagDispModeContShadeSets,DBClear);
data->Flags (shadeSet,DBSet);
}
ret = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? data->Write (argv [2]) : data->Write (stdout);
delete data;
if (verbose) RGlibPauseClose ();
return (ret);
}
示例7: main
int main(int argc, char *argv[]) {
int argPos, argNum = argc, ret, verbose = false;
DBInt recID;
DBObjData *data;
char *tableName = (char *) NULL;
char *fieldIDName = (char *) NULL;
char *fieldXName = (char *) NULL;
char *fieldYName = (char *) NULL;
DBObjTable *table;
DBObjTableField *fieldID, *fieldX, *fieldY;
DBObjRecord *record;
DBNetworkIF *netIF;
DBCoordinate coord;
for (argPos = 1; argPos < argNum;) {
if (CMargTest (argv[argPos], "-a", "--table")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing table name!");
return (CMfailed);
}
tableName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-f", "--IDfield")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing field name!");
return (CMfailed);
}
fieldIDName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-x", "--Xfield")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing field name!");
return (CMfailed);
}
fieldXName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-y", "--Yfield")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing field name!");
return (CMfailed);
}
fieldYName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input file> <output file>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -a, --table [ [DBCells] | DBItems ]");
CMmsgPrint(CMmsgInfo, " -f, --IDfield [ [CellID] | BasinID ]");
CMmsgPrint(CMmsgInfo, " -x, --Xfield [ [CellXCoord] | MouthXCoord ]");
CMmsgPrint(CMmsgInfo, " -y, --Yfield [ [CellYCoord] | MouthYCoord ]");
CMmsgPrint(CMmsgInfo, " -V, --verbose");
CMmsgPrint(CMmsgInfo, " -h, --help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
if (tableName == (char *) NULL) tableName = (char *) "DBCells";
if (fieldIDName == (char *) NULL) fieldIDName = (char *) "CellID";
if (fieldXName == (char *) NULL) fieldXName = (char *) "CellXCoord";
if (fieldYName == (char *) NULL) fieldYName = (char *) "CellYCoord";
data = new DBObjData();
if (((argNum > 1) && (strcmp(argv[1], "-") != 0) ? data->Read(argv[1]) : data->Read(stdin)) == DBFault) {
delete data;
return (CMfailed);
}
if ((table = data->Table(tableName)) == (DBObjTable *) NULL) {
CMmsgPrint(CMmsgUsrError, "Invalid table: %s!", tableName);
delete data;
return (CMfailed);
}
netIF = new DBNetworkIF(data);
fieldID = new DBObjTableField(fieldIDName, DBTableFieldInt, (char *) "%8d", sizeof (DBInt));
fieldX = new DBObjTableField (fieldXName, DBTableFieldFloat, (char *) "%10.3f", sizeof (DBFloat4));
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
CMmsgPrint(CMmsgUsrError, "Missing domain!");
return (CMfailed);
}
domain = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-v", "--version")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing version!");
return (CMfailed);
}
version = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-s", "--shadeset")) {
int shadeCodes[] = {DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation
};
const char *shadeSets[] = {"standard", "grey", "blue", "blue-to-red", "elevation", (char *) NULL};
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing shadeset!");
return (CMfailed);
}
if ((shadeSet = CMoptLookup(shadeSets, argv[argPos], true)) == CMfailed) {
CMmsgPrint(CMmsgUsrError, "Invalid shadeset!");
return (CMfailed);
}
shadeSet = shadeCodes[shadeSet];
changeShadeSet = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input grid> <output grid>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -m,--mode [min|max]");
CMmsgPrint(CMmsgInfo, " -r,--report [value|layer]");
CMmsgPrint(CMmsgInfo, " -t,--title [dataset title]");
CMmsgPrint(CMmsgInfo, " -u,--subject [subject]");
CMmsgPrint(CMmsgInfo, " -d,--domain [domain]");
CMmsgPrint(CMmsgInfo, " -v,--version [version]");
CMmsgPrint(CMmsgInfo, " -s,--shadeset [standard|grey|blue|blue-to-red|elevation]");
CMmsgPrint(CMmsgInfo, " -V,--verbose");
CMmsgPrint(CMmsgInfo, " -h,--help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
tsData = new DBObjData();
ret = (argNum > 1) && (strcmp(argv[1], "-") != 0) ? tsData->Read(argv[1]) : tsData->Read(stdin);
if ((ret == DBFault) || (tsData->Type() != DBTypeGridContinuous)) {
delete tsData;
return (CMfailed);
}
if (title == (char *) NULL) title = tsData->Name();
if (subject == (char *) NULL) subject = tsData->Document(DBDocSubject);
if (domain == (char *) NULL) domain = tsData->Document(DBDocGeoDomain);
if (version == (char *) NULL) version = tsData->Document(DBDocVersion);
data = reportValue ? DBGridToGrid(tsData, DBTypeGridContinuous, DBTableFieldFloat, sizeof(DBFloat)) :
DBGridToGrid(tsData, DBTypeGridContinuous, DBTableFieldInt, sizeof(DBInt));
data->Name(title);
data->Document(DBDocSubject, subject);
data->Document(DBDocGeoDomain, domain);
data->Document(DBDocVersion, version);
if (changeShadeSet && (data->Type() == DBTypeGridContinuous)) {
data->Flags(DBDataFlagDispModeContShadeSets, DBClear);
data->Flags(shadeSet, DBSet);
}
if ((ret = RGlibMinMax(tsData, data, doMin,reportValue)) == DBSuccess)
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);
delete tsData;
delete data;
if (verbose) RGlibPauseClose();
return (ret);
}
示例9: main
int main(int argc, char *argv[]) {
int argPos, argNum = argc, ret, verbose = false;
char *title = (char *) NULL, *subject = (char *) NULL;
char *domain = (char *) NULL, *version = (char *) NULL;
DBObjData *srcData, *dstData;
for (argPos = 1; argPos < argNum;) {
if (CMargTest (argv[argPos], "-t", "--title")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing title!");
return (CMfailed);
}
title = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-u", "--subject")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing subject!");
return (CMfailed);
}
subject = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-d", "--domain")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing domain!");
return (CMfailed);
}
domain = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-v", "--version")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing version!");
return (CMfailed);
}
version = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input grid> <output grid>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -t,--title [dataset title]");
CMmsgPrint(CMmsgInfo, " -u,--subject [subject]");
CMmsgPrint(CMmsgInfo, " -d,--domain [domain]");
CMmsgPrint(CMmsgInfo, " -v,--version [version]");
CMmsgPrint(CMmsgInfo, " -V,--verbose");
CMmsgPrint(CMmsgInfo, " -h,--help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
srcData = new DBObjData();
ret = (argNum > 1) && (strcmp(argv[1], "-") != 0) ? srcData->Read(argv[1]) : srcData->Read(stdin);
if ((ret == DBFault) || (srcData->Type() != DBTypeGridContinuous)) {
delete srcData;
return (CMfailed);
}
if ((dstData = DBGridToGrid(srcData)) == (DBObjData *) NULL) {
delete srcData;
return (CMfailed);
}
if (title == (char *) NULL) title = (char *) "Cell Statistics";
if (subject == (char *) NULL) subject = srcData->Document(DBDocSubject);
if (domain == (char *) NULL) domain = srcData->Document(DBDocGeoDomain);
if (version == (char *) NULL) version = (char *) "0.01pre";
dstData->Name(title);
dstData->Document(DBDocSubject, subject);
dstData->Document(DBDocGeoDomain, domain);
srcData->Document(DBDocVersion, version);
if ((ret = RGlibGridCellStats(srcData, dstData)) == DBSuccess)
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ?
dstData->Write(argv[2]) : dstData->Write(stdout);
delete srcData;
delete dstData;
if (verbose) RGlibPauseClose();
//.........这里部分代码省略.........
示例10: main
//.........这里部分代码省略.........
title = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-u","--subject"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing subject!"); return (CMfailed); }
subject = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--domain"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing domain!"); return (CMfailed); }
domain = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing version!"); return (CMfailed); }
version = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-s","--shadeset"))
{
int shadeCodes [] = { DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation };
const char *shadeSets [] = { "standard","grey", "blue","blue-to-red", "elevation", (char *) NULL };
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing shadeset!"); return (CMfailed); }
if ((shadeSet = CMoptLookup (shadeSets,argv [argPos],true)) == DBFault)
{ CMmsgPrint (CMmsgUsrError,"Invalid shadeset!"); return (CMfailed); }
shadeSet = shadeCodes [shadeSet];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input grid> <output grid>",CMfileName(argv[0]));
CMmsgPrint (CMmsgInfo," -a,--aggregate [avg|max|min|sum]");
CMmsgPrint (CMmsgInfo," -e,--step [year|month|day|hour]");
CMmsgPrint (CMmsgInfo," -t,--title [dataset title]");
CMmsgPrint (CMmsgInfo," -u,--subject [subject]");
CMmsgPrint (CMmsgInfo," -d,--domain [domain]");
CMmsgPrint (CMmsgInfo," -v,--version [version]");
CMmsgPrint (CMmsgInfo," -s,--shadeset [standard|grey|blue|blue-to-red|elevation]");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
tsData = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? tsData->Read (argv [1]) : tsData->Read (stdin);
if ((ret == DBFault) || (tsData->Type () != DBTypeGridContinuous))
{ delete tsData; return (CMfailed); }
if (title == (char *) NULL) title = tsData->Name ();
if (subject == (char *) NULL) subject = tsData->Document (DBDocSubject);
if (domain == (char *) NULL) domain = tsData->Document (DBDocGeoDomain);
if (version == (char *) NULL) version = tsData->Document (DBDocVersion);
if (shadeSet == DBFault) shadeSet = DBDataFlagDispModeContGreyScale;
data = DBGridToGrid (tsData);
data->Name (title);
data->Document (DBDocSubject,subject);
data->Document (DBDocGeoDomain,domain);
data->Document (DBDocVersion,version);
data->Flags (DBDataFlagDispModeContShadeSets,DBClear);
data->Flags (shadeSet,DBSet);
if ((ret = RGlibTSAggregate (tsData, data, timeStep, aggregate)) == DBSuccess)
ret = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? data->Write (argv [2]) : data->Write (stdout);
delete tsData;
delete data;
if (verbose) RGlibPauseClose ();
return (ret);
}
示例11: main
int main (int argc,char *argv [])
{
int argPos, argNum = argc, ret, verbose = false;
DBInt oper = DBMathOperatorAdd;
char *tableName = (char *) NULL;
char *srcFieldName = (char *) NULL;
char *dstFieldName = (char *) NULL;
char *nextFieldName = (char *) NULL;
DBObjData *data;
DBObjTable *table;
for (argPos = 1;argPos < argNum; )
{
if (CMargTest (argv [argPos],"-a","--table"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing table name!"); return (CMfailed); }
tableName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-o","--operation"))
{
int operCodes [] = { DBMathOperatorAdd, DBMathOperatorSub };
const char *operations [] = { "add", "subtract", (char *) NULL };
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing operation!"); return (CMfailed); }
if ((oper = CMoptLookup (operations,argv [argPos],true)) == DBFault)
{ CMmsgPrint (CMmsgUsrError,"Invalid operation!"); return (CMfailed); }
oper = operCodes [oper];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-n","--next"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing next field name!"); return (CMfailed); }
nextFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-s","--source"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing source field name!"); return (CMfailed); }
srcFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-t","--target"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing target field name!"); return (CMfailed); }
dstFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <=argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input file> <output file>",CMprgName(argv[0]));
CMmsgPrint (CMmsgInfo," -a,--table [table name]");
CMmsgPrint (CMmsgInfo," -o,--operation [add|subtract]");
CMmsgPrint (CMmsgInfo," -n,--next [next fieldname]");
CMmsgPrint (CMmsgInfo," -s,--source [source fieldname]");
CMmsgPrint (CMmsgInfo," -t,--target [target fieldname]");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && ((int) strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (srcFieldName == (char *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Missing source field!"); return (CMfailed); }
if (dstFieldName == (char *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Missing target field!"); return (CMfailed); }
if (nextFieldName == (char *) NULL) nextFieldName = RGlibNextStation;
if (tableName == (char *) NULL) tableName = DBrNItems;
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
data = new DBObjData ();
if (((argNum > 1) && (strcmp (argv [1],"-") != 0) ? data->Read (argv [1]) : data->Read (stdin)) == DBFault)
{ delete data; if (argNum > 1) printf ("File error in: %s", argv[1]); return(DBFault); }
if ((table = data->Table (tableName)) == (DBObjTable *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Invalid table!"); delete data; return (CMfailed); }
switch (oper)
//.........这里部分代码省略.........
示例12: main
int main (int argc,char *argv [])
{
int argPos, argNum = argc, ret, verbose = false;
bool downhill = true;
char *title = (char *) NULL;
char *domain = (char *) NULL, *version = (char *) NULL;
DBObjData *outData, *inData, *basinData = (DBObjData *) NULL;
DBInt DBGridCont2Network (DBObjData *,DBObjData *, bool);
for (argPos = 1;argPos < argNum; )
{
if (CMargTest(argv[argPos],"-b","--basin_pack")) {
if ((argNum = CMargShiftLeft(argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError, "Missing basin pack filename!"); return (CMfailed); }
else {
if (basinData != (DBObjData *) NULL)
CMmsgPrint (CMmsgWarning,"Ignoring redefined basin pack");
else {
basinData = new DBObjData ();
if (basinData->Read (argv [argPos]) == DBFault) {
CMmsgPrint (CMmsgUsrError, "Basin data reading error");
delete basinData;
basinData = (DBObjData *) NULL;
return (CMfailed);
}
}
}
if ((argNum = CMargShiftLeft(argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest(argv[argPos],"-g","--gradient")) {
if ((argNum = CMargShiftLeft(argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError, "Missing gradient method!"); return (CMfailed); }
else {
const char *options [] = { "down", "up", (char *) NULL };
bool methods [] = { true, false };
DBInt code;
if ((code = CMoptLookup (options,argv [argPos],false)) == CMfailed) {
CMmsgPrint (CMmsgWarning,"Ignoring illformed gradient method [%s]!",argv [argPos]);
}
else downhill = methods [code];
}
if ((argNum = CMargShiftLeft(argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-t","--title"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing title!"); return (CMfailed); }
title = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--domain"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing domain!"); return (CMfailed); }
domain = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing version!"); return (CMfailed); }
version = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input file> <output file>",CMprgName(argv[0]));
CMmsgPrint (CMmsgInfo," -b,--basin_pack [basin pack file]");
CMmsgPrint (CMmsgInfo," -g,--gradient [down|up]");
CMmsgPrint (CMmsgInfo," -t,--title [dataset title]");
CMmsgPrint (CMmsgInfo," -d,--domain [domain]");
CMmsgPrint (CMmsgInfo," -v,--version [version]");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && ((int) strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
inData = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? inData->Read (argv [1]) : inData->Read (stdin);
//.........这里部分代码省略.........
示例13: main
//.........这里部分代码省略.........
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing domain!"); return (CMfailed); }
domain = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing version!"); return (CMfailed); }
version = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-s","--shadeset"))
{
int shadeCodes [] = { DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation };
const char *shadeSets [] = { "standard","grey","blue","blue-to-red","elevation", (char *) NULL };
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing shadeset!"); return (CMfailed); }
if ((shadeSet = CMoptLookup (shadeSets,argv [argPos],true)) == DBFault)
{ CMmsgPrint (CMmsgUsrError,"Invalid shadeset!"); return (CMfailed); }
shadeSet = shadeCodes [shadeSet];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input table> <output grid>",CMfileName(argv[0]));
CMmsgPrint (CMmsgInfo," -g,--grid [discrete grid coverage]");
CMmsgPrint (CMmsgInfo," -r,--relate [relate field]");
CMmsgPrint (CMmsgInfo," -j,--join [join field]");
CMmsgPrint (CMmsgInfo," -i,--variable [variable field]");
CMmsgPrint (CMmsgInfo," -a,--date [date field]");
CMmsgPrint (CMmsgInfo," -u,--subject [subject]");
CMmsgPrint (CMmsgInfo," -d,--domain [domain]");
CMmsgPrint (CMmsgInfo," -v,--version [version]");
CMmsgPrint (CMmsgInfo," -s,--shadeset [standard|grey|blue|blue-to-red|elevation]");
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
if (gridName == (char *) NULL) { CMmsgPrint (CMmsgUsrError,"Discrete grid is mandatory"); return (CMfailed); }
if (relateName == (char *) NULL) { CMmsgPrint (CMmsgUsrError,"Relate field is mandatory"); return (CMfailed); }
if (joinName == (char *) NULL) { CMmsgPrint (CMmsgUsrError,"Join field is mandatory"); return (CMfailed); }
if (varName == (char *) NULL) { CMmsgPrint (CMmsgUsrError,"Variable field is mandatory"); return (CMfailed); }
grdData = new DBObjData ();
if ((grdData->Read (gridName) != DBSuccess) || (grdData->Type () != DBTypeGridDiscrete))
{ delete grdData; CMmsgPrint (CMmsgUsrError,"Grid File Reading Error!"); return (CMfailed); }
tabData = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? tabData->Read (argv [1]) : tabData->Read (stdin);
if ((ret == DBFault) || (tabData->Type () != DBTypeTable))
{ delete grdData; delete tabData; return (CMfailed); }
if (title == (char *) NULL) title = (char *) "Time Series";
if (subject == (char *) NULL) subject = tabData->Document (DBDocSubject);
if (domain == (char *) NULL) domain = grdData->Document (DBDocGeoDomain);
if (version == (char *) NULL) version = (char *) "0.01pre";
if ((outData = DBGridToGrid (grdData,DBTypeGridContinuous)) == (DBObjData *) NULL) return (CMfailed);
outData->Name (title);
outData->Document (DBDocSubject,subject);
outData->Document (DBDocGeoDomain,domain);
outData->Document (DBDocVersion,version);
if (shadeSet != DBFault)
{
outData->Flags (DBDataFlagDispModeContShadeSets,DBClear);
outData->Flags (shadeSet,DBSet);
}
if ((ret = RGlibGridUniformGrid (grdData,tabData,relateName,joinName,varName,dateName,outData)) == DBSuccess)
ret = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? outData->Write (argv [2]) : outData->Write (stdout);
delete grdData; delete tabData; delete outData;
if (verbose) RGlibPauseClose ();
return (DBSuccess);
}
示例14: main
//.........这里部分代码省略.........
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing offset!"); return (CMfailed); }
if (sscanf (argv [argPos],"%d",&offset) != 1)
{ CMmsgPrint (CMmsgUsrError,"Invalid number of steps!"); return (CMfailed); }
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-e","--step"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing number of steps!"); return (CMfailed); }
if (sscanf (argv [argPos],"%d",&stepNum) != 1)
{ CMmsgPrint (CMmsgUsrError,"Invalid number of steps!"); return (CMfailed); }
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-t","--title"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing title!"); return (CMfailed); }
title = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-u","--subject"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing subject!"); return (CMfailed); }
subject = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--domain"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing domain!"); return (CMfailed); }
domain = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-v","--version"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing version!"); return (CMfailed); }
version = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-V","--verbose"))
{
verbose = true;
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgSysError,"%s [options] <input grid> <output grid>",CMprgName(argv[0]));
CMmsgPrint (CMmsgSysError," -a,--aggregate [avg|sum]");
CMmsgPrint (CMmsgSysError," -o,--offset [offset]");
CMmsgPrint (CMmsgSysError," -e,--step [number of steps]");
CMmsgPrint (CMmsgSysError," -t,--title [dataset title]");
CMmsgPrint (CMmsgSysError," -u,--subject [subject]");
CMmsgPrint (CMmsgSysError," -d,--domain [domain]");
CMmsgPrint (CMmsgSysError," -v,--version [version]");
CMmsgPrint (CMmsgSysError," -V,--verbose");
CMmsgPrint (CMmsgSysError," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
{ CMmsgPrint (CMmsgUsrError,"Unknown option: %s!",argv [argPos]); return (CMfailed); }
argPos++;
}
if (argNum > 3) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
if (verbose) RGlibPauseOpen (argv[0]);
tsData = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? tsData->Read (argv [1]) : tsData->Read (stdin);
if ((ret == DBFault) || (tsData->Type () != DBTypeGridContinuous))
{ delete tsData; return (CMfailed); }
if (title == (char *) NULL) title = tsData->Name ();
if (subject == (char *) NULL) subject = tsData->Document (DBDocSubject);
if (domain == (char *) NULL) domain = tsData->Document (DBDocGeoDomain);
if (version == (char *) NULL) version = tsData->Document (DBDocVersion);
data = DBGridToGrid (tsData);
data->Name (title);
data->Document (DBDocSubject,subject);
data->Document (DBDocGeoDomain,domain);
data->Document (DBDocVersion,version);
if ((ret = RGlibSeasonMean (tsData, data, stepNum, offset, doSum)) == DBSuccess)
ret = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? data->Write (argv [2]) : data->Write (stdout);
delete tsData;
delete data;
if (verbose) RGlibPauseClose ();
return (ret);
}
示例15: main
int main(int argc, char *argv[]) {
int argPos, argNum = argc, ret, idleMode, verbose = false;
char *tableName = (char *) NULL;
DBInt recID;
DBObjData *data;
DBObjTable *table;
DBObjRecord *record;
for (argPos = 1; argPos < argNum;) {
if (CMargTest (argv[argPos], "-a", "--table")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing table name!");
return (CMfailed);
}
tableName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-m", "--mode")) {
int modeCodes[] = {true, false};
const char *modes[] = {"set", "clear"};
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing selection mode!");
return (CMfailed);
}
if ((idleMode = CMoptLookup(modes, argv[argPos], true)) == DBFault) {
CMmsgPrint(CMmsgUsrError, "Invalid selection mode!");
return (CMfailed);
}
idleMode = modeCodes[idleMode];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input file> <output file>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -a,--table [table name]");
CMmsgPrint(CMmsgInfo, " -m,--mode [set|clear]");
CMmsgPrint(CMmsgInfo, " -V,--verbose");
CMmsgPrint(CMmsgInfo, " -h,--help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
data = new DBObjData();
if (((argNum > 1) && (strcmp(argv[1], "-") != 0) ? data->Read(argv[1]) : data->Read(stdin)) == DBFault) {
delete data;
return (CMfailed);
}
if (tableName == (char *) NULL) tableName = DBrNItems;
if ((table = data->Table(tableName)) == (DBObjTable *) NULL) {
CMmsgPrint(CMmsgUsrError, "Invalid table!");
delete data;
return (CMfailed);
}
if (idleMode)
for (recID = 0; recID < table->ItemNum(); ++recID) {
record = table->Item(recID);
if ((record->Flags() & DBObjectFlagSelected) == DBObjectFlagSelected)
record->Flags(DBObjectFlagIdle, DBSet);
else
record->Flags(DBObjectFlagIdle, DBClear);
}
else
for (recID = 0; recID < table->ItemNum(); ++recID) {
record = table->Item(recID);
record->Flags(DBObjectFlagIdle, DBClear);
}
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);
delete data;
if (verbose) RGlibPauseClose();
return (ret);
}