void RGISAnNetworkCellSlopesCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjData *inGridData, *outGridData; widget = widget; callData = callData; if ((inGridData = netData->LinkedData ()) == (DBObjData *) NULL) { CMmsgPrint (CMmsgAppError,"Null Linked Data in: %s %d",__FILE__,__LINE__); return; } outGridData = DBNetworkToGrid (netData,DBTypeGridContinuous); outGridData->Document (DBDocGeoDomain,inGridData->Document (DBDocGeoDomain)); outGridData->Document (DBDocSubject,"Slope"); if (UIDataHeaderForm (outGridData)) { UIPauseDialogOpen ((char *) "Calculating Slopes"); if (RGlibNetworkCellSlopes (netData,inGridData,outGridData) == DBSuccess) workspace->CurrentData (outGridData); else delete outGridData; UIPauseDialogClose (); } else delete outGridData; }
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; DBInt shadeSet = DBDataFlagDispModeContGreyScale; 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], "-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); }