本文整理汇总了C++中DBObjTable::ItemNum方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTable::ItemNum方法的具体用法?C++ DBObjTable::ItemNum怎么用?C++ DBObjTable::ItemNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTable
的用法示例。
在下文中一共展示了DBObjTable::ItemNum方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RGlibGenFuncSymbolField
int RGlibGenFuncSymbolField (DBObjData *data, const char *fieldName)
{
DBInt recID;
char symbolName [DBStringLength + 1];
DBObjTable *table = data->Table (DBrNItems);
DBObjTable *symbols = data->Table (DBrNSymbols);
DBObjRecord *record, *symbolRec;
DBObjTableField *field;
DBObjTableField *symbolFLD;
DBObjTableField *symbolIDFLD;
DBObjTableField *foregroundFLD;
DBObjTableField *backgroundFLD;
DBObjTableField *styleFLD;
if (table == (DBObjTable *) NULL) return (DBFault);
if ((field = table->Field (fieldName)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Invalid field name in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((symbolFLD = table->Field (DBrNSymbol)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing symbol field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (symbols == (DBObjTable *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing symbol table in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((symbolIDFLD = symbols->Field (DBrNSymbolID)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing symbolID field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((foregroundFLD = symbols->Field (DBrNForeground)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing foreground field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((backgroundFLD = symbols->Field (DBrNBackground)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing background field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((styleFLD = symbols->Field (DBrNStyle)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing style field in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbols->DeleteAll ();
for (recID = 0;recID < table->ItemNum (); ++recID)
{
record = table->Item (recID);
DBPause (record->RowID () * 100 / table->ItemNum ());
if (field->Type () == DBTableFieldString) sprintf (symbolName,"%s",field->String (record));
else sprintf (symbolName,"Symbol:%03d",field->Int (record));
if ((symbolRec = (DBObjRecord *) symbols->Item (symbolName)) == (DBObjRecord *) NULL)
{
if ((symbolRec = symbols->Add (symbolName)) == NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,field->Type () == DBTableFieldString ? symbolRec->RowID () : field->Int (record));
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
}
symbolFLD->Record (record,symbolRec);
}
return (DBSuccess);
}
示例2: _RGISGrpPanelSaveCBK
static void _RGISGrpPanelSaveCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)
{
DBInt rowID;
DBDataset *dataset= UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *itemTable = dbData->Table (DBrNItems);
DBObjTable *groupTable = dbData->Table (DBrNGroups);
DBObjTableField *group;
DBObjRecord *itemRec, *groupRec;
UITable *tableCLS;
if (groupTable == (DBObjTable *) NULL) return;
group = grpPanel->Current ();
for (rowID = 0;rowID < groupTable->ItemNum ();++rowID)
{
groupRec = groupTable->Item (rowID);
itemRec = itemTable->Item (rowID);
group->Int (groupRec,(itemRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected ? true : false);
}
if ((tableCLS = (UITable *) dbData->Display (UITableName (dbData,groupTable))) != (UITable *) NULL)
tableCLS->Draw ();
}
示例3: RGISAnalyseLineSSampleGridCBK
//.........这里部分代码省略.........
XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameLabel",xmLabelWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, button,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, toNameTextF,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNlabelString, string,
NULL);
XmStringFree (string);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&sample);
}
sample = false;
UIDialogFormPopup (dShell);
while (UILoop ())
{
allowOk = false;
fText = XmTextFieldGetString (fromNameTextF);
if (strlen (fText) > 0) allowOk = true;
XtFree (fText);
fText = XmTextFieldGetString (toNameTextF);
if (strlen (fText) > 0) allowOk = true;
XtFree (fText);
XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
}
UIDialogFormPopdown (dShell);
if (sample)
{
DBInt ret;
DBFloat value;
DBCoordinate coord;
DBGridIF *gridIF = new DBGridIF (grdData);
DBVLineIF *lineIF = new DBVLineIF (dbData);
DBObjTableField *fromField;
DBObjTableField *toField;
DBObjRecord *record;
fText = XmTextFieldGetString (fromNameTextF);
if (strlen (fText) > 0)
{
if ((fromField = itemTable->Field (fText)) == (DBObjTableField *) NULL)
itemTable->AddField (fromField = new DBObjTableField (fText,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4)));
}
else fromField = (DBObjTableField *) NULL;
XtFree (fText);
fText = XmTextFieldGetString (toNameTextF);
if (strlen (fText) > 0)
{
if ((toField = itemTable->Field (fText)) == (DBObjTableField *) NULL)
itemTable->AddField (toField = new DBObjTableField (fText,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4)));
}
else toField = (DBObjTableField *) NULL;
XtFree (fText);
UIPauseDialogOpen ((char *) "Sampling Grid");
for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ())
{
if (UIPause (record->RowID () * 100 / itemTable->ItemNum ())) goto Stop;
if (fromField != (DBObjTableField *) NULL)
{
coord = lineIF->FromCoord (record);
ret = gridIF->Value (coord,&value);
if (fromField->Type () == DBTableFieldFloat)
{
if (ret) fromField->Float (record,value);
else fromField->Float (record,fromField->FloatNoData ());
}
else
{
if (ret) fromField->Int (record,(DBInt) value);
else fromField->Int (record,fromField->IntNoData ());
}
}
if (toField != (DBObjTableField *) NULL)
{
coord = lineIF->ToCoord (record);
ret = gridIF->Value (coord,&value);
if (toField->Type () == DBTableFieldFloat)
{
if (ret) toField->Float (record,value);
else toField->Float (record,toField->FloatNoData ());
}
else
{
if (ret) toField->Int (record,(DBInt) value);
else toField->Int (record,toField->IntNoData ());
}
}
}
Stop:
UIPauseDialogClose ();
delete lineIF;
delete gridIF;
}
}
示例4: main
//.........这里部分代码省略.........
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));
fieldY = new DBObjTableField (fieldYName, DBTableFieldFloat, (char *) "%10.3f", sizeof (DBFloat4));
table->AddField(fieldID);
table->AddField(fieldX);
table->AddField(fieldY);
if (strcmp(fieldIDName, "CellID") == 0) {
for (recID = 0; recID < table->ItemNum(); ++recID) {
record = netIF->Cell(recID);
coord = netIF->Center(record);
fieldID->Int(record, recID+1);
fieldX->Float(record, coord.X);
fieldY->Float(record, coord.Y);
}
} else if (strcmp(fieldIDName, "BasinID") == 0) {
for (recID = 0; recID < netIF->BasinNum(); ++recID) {
record = netIF->Basin(recID);
coord = netIF->Center(netIF->MouthCell(record));
fieldID->Int(record, recID+1);
fieldX->Float(record,coord.X);
fieldY->Float(record,coord.Y);
}
} else {
CMmsgPrint(CMmsgUsrError, "Invalid field name: %s!", fieldIDName);
delete data;
return (CMfailed);
}
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);
delete data;
if (verbose) RGlibPauseClose();
return (ret);
}
示例5: main
//.........这里部分代码省略.........
if (tableName == (char *) NULL) tableName = DBrNItems;
if ((table = data->Table (tableName)) == (DBObjTable *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Invalid table!"); delete data; return (CMfailed); }
if (fieldName == (char *) NULL) fieldName = (char *) "Date";
if ((srcField = table->Field (fieldName)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Missing date field!"); delete data; return (CMfailed); }
if ((srcField->Type () != DBTableFieldString) &&
(srcField->Type () != DBTableFieldDate))
{ CMmsgPrint (CMmsgUsrError,"Invalid date field!"); delete data; return (CMfailed); }
if (yearFieldName != (char *) NULL)
{
if ((yearField = table->Field (yearFieldName)) == (DBObjTableField *) NULL)
{
yearField = new DBObjTableField (yearFieldName,DBTableFieldInt,"%4d",sizeof(DBShort),false);
table->AddField (yearField);
}
}
if (monthFieldName != (char *) NULL)
{
if ((monthField = table->Field (monthFieldName)) == (DBObjTableField *) NULL)
{
monthField = new DBObjTableField (monthFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (monthField);
}
}
if (dayFieldName != (char *) NULL)
{
if (monthField == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Month field is not set!"); delete data; return (CMfailed); }
if ((dayField = table->Field (dayFieldName)) == (DBObjTableField *) NULL)
{
dayField = new DBObjTableField (dayFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (dayField);
}
}
if (hourFieldName != (char *) NULL)
{
if (dayField == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Day field is not set!"); delete data; return (CMfailed); }
if ((hourField = table->Field (hourFieldName)) == (DBObjTableField *) NULL)
{
hourField = new DBObjTableField (hourFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (hourField);
}
}
if (minFieldName != (char *) NULL)
{
if (hourField == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Hour field is not set!"); delete data; return (CMfailed); }
if ((minField = table->Field (minFieldName)) == (DBObjTableField *) NULL)
{
minField = new DBObjTableField (minFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (minField);
}
}
for (recID = 0;recID < table->ItemNum ();++recID)
{
record = table->Item (recID);
if (srcField->Type () == DBTableFieldString)
date.Set (srcField->String (record));
else date = srcField->Date (record);
if (yearField != (DBObjTableField *) NULL) yearField->Int(record,date.Year ());
if(padding)
{
if (monthField != (DBObjTableField *) NULL)
{
if (date.Month() != DBDefaultMissingIntVal) monthField->String (record,tmp = _CMDpadit(date.Month() + 1,false));
else monthField->String (record,tmp = _CMDpadit(date.Month(),false));
free(tmp);
}
if (dayField != (DBObjTableField *) NULL) { dayField->String (record,tmp = _CMDpadit(date.Day(),false)); free(tmp); }
if (hourField != (DBObjTableField *) NULL) { hourField->String (record,tmp = _CMDpadit(date.Hour(),false)); free(tmp); }
if (minField != (DBObjTableField *) NULL) { minField->String (record,tmp = _CMDpadit(date.Minute(),false)); free(tmp); }
}
else
{
if (monthField != (DBObjTableField *) NULL)
{
if (date.Month() != DBDefaultMissingIntVal) monthField->Int(record,date.Month () + 1);
else monthField->Int (record,DBDefaultMissingIntVal);
}
if (dayField != (DBObjTableField *) NULL) dayField->Int (record,date.Day ());
if (hourField != (DBObjTableField *) NULL) hourField->Int(record,date.Hour ());
if (minField != (DBObjTableField *) NULL) minField->Int (record,date.Minute ());
}
}
ret = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? data->Write (argv [2]) : data->Write (stdout);
delete data;
if (verbose) RGlibPauseClose ();
return (ret);
}
示例6: DBImportARCLine
int DBImportARCLine (DBObjData *vecData,const char *arcCov)
{
FILE *inFile;
DBInt arcNum, vertex, swap = DBByteOrder (DBByteOrderLITTLE), floatCov;
char fileName [DBDataFileNameLen], objName [DBStringLength];
short infoHeader [50];
DBARCRecord arcRecord;
DBObjTable *lines;
DBObjTable *nodes;
DBObjectLIST<DBObjRecord> *data;
DBObjRecord *lineRec, *nodeRec, *dataRec;
DBRegion dataExtent = vecData->Extent (), itemExtent;
DBObjTableField *fromNodeFLD;
DBObjTableField *toNodeFLD;
DBObjTableField *leftPolyFLD;
DBObjTableField *rightPolyFLD;
DBObjTableField *vertexesFLD;
DBObjTableField *vertexNumFLD;
DBObjTableField *extentFLD;
DBObjTableField *coordFLD;
DBObjTableField *linkNumFLD;
DBCoordinate *vertexes, nodeCoord;
DBFloat4 floatVAR [2];
switch (vecData->Type ())
{
case DBTypeVectorLine: lines = vecData->Table (DBrNItems); break;
case DBTypeVectorPolygon: lines = vecData->Table (DBrNContours); break;
default: CMmsgPrint (CMmsgAppError, "Invalide Vector Data Type in: %s %d",__FILE__,__LINE__); return (DBFault);
}
fromNodeFLD = lines->Field (DBrNFromNode);
toNodeFLD = lines->Field (DBrNToNode);
leftPolyFLD = lines->Field (DBrNLeftPoly);
rightPolyFLD= lines->Field (DBrNRightPoly);
vertexesFLD = lines->Field (DBrNVertexes);
vertexNumFLD= lines->Field (DBrNVertexNum);
extentFLD = lines->Field (DBrNRegion);
nodes = vecData->Table (DBrNNodes);
coordFLD = nodes->Field (DBrNCoord);
linkNumFLD = nodes->Field (DBrNLinkNum);
data = vecData->Arrays ();
sprintf (fileName,"%s/arc",arcCov);
if (access (fileName,R_OK) == DBFault) sprintf (fileName,"%s/arc.adf",arcCov);
if ((inFile = fopen (fileName,"r")) == NULL)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (fread (infoHeader,sizeof (short),50,inFile) != 50)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
arcNum = 0;
for (lineRec = lines->First ();arcRecord.Read (inFile,swap) != DBFault;lineRec = lines->Next ())
{
if (lineRec == NULL)
{
sprintf (objName,"Line: %5d",arcRecord.ID () + 1);
if ((lineRec = lines->Add (objName)) == (DBObjRecord *) NULL) return (DBFault);
}
else DBPause ((++arcNum * 100) / lines->ItemNum ());
floatCov = arcRecord.RecordLength () - 12 == arcRecord.NumOfPnts () * (DBInt) sizeof (float) ? true : false;
while (arcRecord.FromNode () > nodes->ItemNum ())
{
sprintf (objName,"Node: %5d",nodes->ItemNum () + 1);
nodes->Add (objName);
if ((nodeRec = nodes->Item ()) == NULL) return (DBFault);
linkNumFLD->Int (nodeRec,0);
}
if ((nodeRec = nodes->Item (arcRecord.FromNode () - 1)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Node Not Found in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (floatCov)
{
if (fread (floatVAR,sizeof (floatVAR),1,inFile) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (swap) { DBByteOrderSwapWord (floatVAR); DBByteOrderSwapWord (floatVAR + 1); }
nodeCoord.X = (DBFloat) floatVAR [0];
nodeCoord.Y = (DBFloat) floatVAR [1];
}
else
{
if (fread (&nodeCoord,sizeof (DBCoordinate),1,inFile) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (swap) nodeCoord.Swap ();
}
coordFLD->Coordinate (nodeRec,nodeCoord);
fromNodeFLD->Record (lineRec,nodeRec);
if (leftPolyFLD != (DBObjTableField *) NULL) leftPolyFLD->Record (lineRec,arcRecord.LeftPoly ());
if (rightPolyFLD != (DBObjTableField *) NULL) rightPolyFLD->Record (lineRec,arcRecord.RightPoly ());
itemExtent.LowerLeft = nodeCoord;
itemExtent.UpperRight = nodeCoord;
linkNumFLD->Int (nodeRec,linkNumFLD->Int (nodeRec) + 1);
if (arcRecord.NumOfPnts () > 2)
{
if ((dataRec = data->Item (lineRec->RowID ())) == (DBObjRecord *) NULL)
{
//.........这里部分代码省略.........
示例7: DBImportARCPoly
int DBImportARCPoly (DBObjData *vecData,const char *arcCov)
{
DBInt polyNum = 0, line, lineNum, vertexNum, polyDir;
DBObjTable *items = vecData->Table (DBrNItems);
DBObjTable *lines = vecData->Table (DBrNContours);
DBObjTableField *firstLineFLD = items->Field (DBrNFirstLine);
DBObjTableField *lineNumFLD = items->Field (DBrNLineNum);
DBObjTableField *polyVertexNumFLD = items->Field (DBrNVertexNum);
DBObjTableField *polyExtentFLD = items->Field (DBrNRegion);
DBObjTableField *leftPolyFLD = lines->Field (DBrNLeftPoly);
DBObjTableField *rightPolyFLD = lines->Field (DBrNRightPoly);
DBObjTableField *nextLineFLD = lines->Field (DBrNNextLine);
DBObjTableField *prevLineFLD = lines->Field (DBrNPrevLine);
DBObjTableField *fromNodeFLD = lines->Field (DBrNFromNode);
DBObjTableField *toNodeFLD = lines->Field (DBrNToNode);
DBObjTableField *lineVertextNumFLD = lines->Field (DBrNVertexNum);
DBObjTableField *lineExtentFLD = lines->Field (DBrNRegion);
DBObjRecord *polyRec, *lineRec, *firstNodeRec, *nodeRec, **lineRecArray;
DBRegion extent, initRegion;
if (DBImportARCLine (vecData,arcCov) == DBFault) return (DBFault);
items->Delete (0);
for (polyRec = items->First ();polyRec != (DBObjRecord *) NULL;polyRec = items->Next ())
lineNumFLD->Int (polyRec,0);
for (lineRec = lines->First ();lineRec != (DBObjRecord *) NULL;lineRec = lines->Next ())
{
rightPolyFLD->Record (lineRec,items->Item ((DBInt) (rightPolyFLD->Record(lineRec) - (DBObjRecord *) NULL)));
leftPolyFLD->Record (lineRec,items->Item ((DBInt) (leftPolyFLD->Record (lineRec) - (DBObjRecord *) NULL)));
nextLineFLD->Record (lineRec,(DBObjRecord *) NULL);
prevLineFLD->Record (lineRec,(DBObjRecord *) NULL);
}
if ((lineRecArray = (DBObjRecord **) calloc (lines->ItemNum (),sizeof (DBObjRecord *))) == (DBObjRecord **) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
for (polyRec = items->First ();polyRec != (DBObjRecord *) NULL;polyRec = items->Next ())
{
DBPause ((++polyNum * 100) / items->ItemNum ());
lineNum = vertexNum = 0;
extent = initRegion;
for (lineRec = lines->First ();lineRec != (DBObjRecord *) NULL;lineRec = lines->Next ())
if ((rightPolyFLD->Record (lineRec) == polyRec) || (leftPolyFLD->Record (lineRec) == polyRec))
{
lineRecArray [lineNum++] = lineRec;
vertexNum += lineVertextNumFLD->Int (lineRec);
extent.Expand (lineExtentFLD->Region (lineRec));
}
lineNumFLD->Int (polyRec,lineNum);
polyExtentFLD->Region (polyRec,extent);
firstLineFLD->Record (polyRec,lineRecArray [0]);
firstNodeRec = (rightPolyFLD->Record (lineRecArray [0]) == polyRec) ?
fromNodeFLD->Record (lineRecArray [0]) : toNodeFLD->Record(lineRecArray [0]);
for (lineNum = 1;lineNum < lineNumFLD->Int (polyRec);++lineNum)
{
polyDir = (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec);
nodeRec = polyDir ? toNodeFLD->Record (lineRecArray [lineNum - 1]) :
fromNodeFLD->Record(lineRecArray [lineNum - 1]);
for (line = lineNum;line < lineNumFLD->Int (polyRec); ++line)
if ((nodeRec == fromNodeFLD->Record (lineRecArray [line])) ||
(nodeRec == toNodeFLD->Record (lineRecArray [line]))) break;
if (line < lineNumFLD->Int (polyRec))
{
lineRec = lineRecArray [lineNum];
lineRecArray [lineNum] = lineRecArray [line];
lineRecArray [line] = lineRec;
}
else
{
vertexNum += 1;
if (nodeRec != firstNodeRec) vertexNum += 1;
}
}
polyDir = (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec);
nodeRec = polyDir ? toNodeFLD->Record (lineRecArray [lineNum - 1]) :
fromNodeFLD->Record(lineRecArray [lineNum - 1]);
polyVertexNumFLD->Int (polyRec,vertexNum + lineNum + 1 + (nodeRec != firstNodeRec ? 1 : 0));
for (lineNum = 1;lineNum < lineNumFLD->Int (polyRec);++lineNum)
{
if (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec)
nextLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [lineNum]);
else prevLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [lineNum]);
}
if (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec)
nextLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [0]);
else prevLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [0]);
}
free (lineRecArray);
return (DBSuccess);
}
示例8: 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);
}
示例9: RGlibPointSubbasinHist
DBInt RGlibPointSubbasinHist(DBObjData *pntData, DBObjData *netData, DBObjData *grdData, DBObjData *tblData) {
DBInt layerID, layerNum = 0, progress = 0, maxProgress;
DBObjTable *itemTable = grdData->Table(DBrNItems);
DBObjTable *table = tblData->Table(DBrNItems);
DBObjTableField *pointIDFLD;
DBObjTableField *layerIDFLD;
DBObjTableField *layerNameFLD;
DBObjTableField *categoryIDFLD;
DBObjTableField *categoryFLD;
DBObjTableField *percentFLD;
DBObjTableField *areaFLD;
DBObjTableField *cellNumFLD;
DBVPointIF *pntIF;
DBNetworkIF *netIF;
DBObjRecord *pntRec, *itemRec, *tblRec;
DBObjectLIST<DBObjTableField> *fields;
_RGlibPointGrdIF = new DBGridIF(grdData);
for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
_RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
}
if (layerNum < 1) {
CMmsgPrint(CMmsgUsrError, "No Layer to Process!");
delete _RGlibPointGrdIF;
return (DBFault);
}
pntIF = new DBVPointIF(pntData);
netIF = new DBNetworkIF(netData);
table->AddField(pointIDFLD = new DBObjTableField("GHAASPointID", DBTableFieldInt, "%8d", sizeof(DBInt)));
table->AddField(layerIDFLD = new DBObjTableField("LayerID", DBTableFieldInt, "%4d", sizeof(DBShort)));
table->AddField(layerNameFLD = new DBObjTableField("LayerName", DBTableFieldString, "%s", DBStringLength));
table->AddField(categoryIDFLD = new DBObjTableField(DBrNCategoryID, DBTableFieldInt, "%2d", sizeof(DBShort)));
table->AddField(categoryFLD = new DBObjTableField(DBrNCategory, DBTableFieldString, _RGlibPointGrdIF->ValueFormat(),
DBStringLength));
table->AddField(cellNumFLD = new DBObjTableField("CellNum", DBTableFieldInt, "%8d", sizeof(DBInt)));
table->AddField(areaFLD = new DBObjTableField(DBrNArea, DBTableFieldFloat, "%10.1f", sizeof(DBFloat4)));
table->AddField(percentFLD = new DBObjTableField(DBrNPercent, DBTableFieldFloat, "%6.2f", sizeof(DBFloat4)));
_RGlibHistogram = (Histogram *) malloc(itemTable->ItemNum() * sizeof(Histogram));
if (_RGlibHistogram == (Histogram *) NULL) {
CMmsgPrint(CMmsgAppError, "Memory Allocation Error in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
maxProgress = pntIF->ItemNum() * _RGlibPointGrdIF->LayerNum();
for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
_RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (pntRec = pntIF->FirstItem(); pntRec != (DBObjRecord *) NULL; pntRec = pntIF->NextItem()) {
if (DBPause(progress * 100 / maxProgress)) goto Stop;
progress++;
if ((pntRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (itemRec = itemTable->First(); itemRec != (DBObjRecord *) NULL; itemRec = itemTable->Next())
_RGlibHistogram[itemRec->RowID()].Initialize();
netIF->UpStreamSearch(netIF->Cell(pntIF->Coordinate(pntRec)), (DBNetworkACTION) _RGlibSubbasinCategories);
for (itemRec = itemTable->First(); itemRec != (DBObjRecord *) NULL; itemRec = itemTable->Next())
if (_RGlibHistogram[itemRec->RowID()].cellNum > 0) {
tblRec = table->Add(pntRec->Name());
pointIDFLD->Int(tblRec, pntRec->RowID() + 1);
layerIDFLD->Int(tblRec, _RGlibPointGrdLayerRec->RowID());
layerNameFLD->String(tblRec, _RGlibPointGrdLayerRec->Name());
categoryIDFLD->Int(tblRec, itemRec->RowID() + 1);
categoryFLD->String(tblRec, itemRec->Name());
areaFLD->Float(tblRec, _RGlibHistogram[itemRec->RowID()].area);
percentFLD->Float(tblRec, _RGlibHistogram[itemRec->RowID()].area /
netIF->CellBasinArea(netIF->Cell(pntIF->Coordinate(pntRec))) * 100.0);
cellNumFLD->Int(tblRec, _RGlibHistogram[itemRec->RowID()].cellNum);
}
}
}
Stop:
delete _RGlibPointGrdIF;
delete netIF;
delete pntIF;
free(_RGlibHistogram);
if (progress == maxProgress) {
fields = new DBObjectLIST<DBObjTableField>("Field List");
fields->Add(new DBObjTableField(*pointIDFLD));
fields->Add(new DBObjTableField(*layerIDFLD));
fields->Add(areaFLD = new DBObjTableField(*areaFLD));
areaFLD->Flags(DBObjectFlagSortReversed, DBSet);
table->ListSort(fields);
delete fields;
return (DBSuccess);
}
return (DBFault);
}
示例10: RGISAnGNUXYPlotCBK
//.........这里部分代码省略.........
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNlabelString, string,
NULL);
XmStringFree (string);
string = XmStringCreate ((char *) "Logarithmic Scale",UICharSetBold);
toggle = XtVaCreateManagedWidget ("RGISEditCompLogScaleToggle",xmToggleButtonWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, button,
XmNtopOffset, 10,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_FORM,
XmNbottomOffset, 10,
XmNlabelString, string,
XmNhighlightThickness, 0,
XmNshadowThickness, 0,
XmNmarginWidth, 5,
XmNset, False,
NULL);
XmStringFree (string);
XtAddCallback (toggle,XmNvalueChangedCallback,(XtCallbackProc) UIAuxSetToggleCBK, (XtPointer) &logScale);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&plot);
}
plot = false;
XtVaSetValues (field0TextF,XmNuserData, itemTable->Fields (), NULL);
XtVaSetValues (field1TextF,XmNuserData, itemTable->Fields (), NULL);
UIDialogFormPopup (dShell);
while (UILoop ())
{
f0Text = XmTextFieldGetString (field0TextF);
f1Text = XmTextFieldGetString (field1TextF);
allowOk = (strlen (f0Text) > 0) && (strlen (f1Text) > 0);
XtFree (f0Text); XtFree (f1Text);
XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
}
UIDialogFormPopdown (dShell);
if (plot)
{
char buffer [256];
DBInt intVal, rowID;
DBFloat val;
DBObjTableField *field0 = itemTable->Field (f0Text = XmTextFieldGetString (field0TextF));
DBObjTableField *field1 = itemTable->Field (f1Text = XmTextFieldGetString (field1TextF));
DBObjRecord *record;
XtFree (f0Text); XtFree (f1Text);
if ((field0 == (DBObjTableField *) NULL) || (field1 == (DBObjTableField *) NULL))
{ CMmsgPrint (CMmsgAppError, "Invalid Compare Fields in: %s %d",__FILE__,__LINE__); return; }
strcpy (fileName,"ghaasXXXXXX");
if ((fd = mkstemp (fileName)) == DBFault)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }
if ((file = fdopen (fd,"w")) == (FILE *) NULL)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }
fprintf (file,"\"GHAASId\"\t\"RecordName\"\t\"Selected\"\t\"%s\"\t\"%s\"\n",field0->Name (),field1->Name ());
for (rowID = 0;rowID < itemTable->ItemNum ();++rowID)
{
record = itemTable->Item (rowID);
if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
sprintf (buffer,"%d\t\"%s\"\t%d",record->RowID () + 1,record->Name (),
(record->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected ? true : false);
if (field0->Type () == DBTableFieldInt)
{
intVal = field0->Int (record);
if (intVal == field0->IntNoData ()) continue;
sprintf (buffer + strlen (buffer),"\t%d",intVal);
}
else
{
val = field0->Float (record);
if (CMmathEqualValues (val,field0->FloatNoData ())) continue;
sprintf (buffer + strlen (buffer),"\t%f",val);
}
if (field1->Type () == DBTableFieldInt)
{
intVal = field1->Int (record);
if (intVal == field1->IntNoData ()) continue;
sprintf (buffer + strlen (buffer),"\t%d",intVal);
}
else
{
val = field1->Float (record);
if (CMmathEqualValues (val,field1->FloatNoData ())) continue;
sprintf (buffer + strlen (buffer),"\t%f",val);
}
fprintf (file,"%s\n",buffer);
}
fclose (file);
ghaasDir = getenv ("GHAAS_DIR");
sprintf (command,"%s/Scripts/xy-plot.sh %s %s",ghaasDir != (const char *) NULL ? ghaasDir : ".",fileName,logScale ? "log" : "normal");
system (command);
unlink (fileName);
}
}
示例11: DBGridCont2Network
//.........这里部分代码省略.........
if (((0x01 << dir) == DBNetDirNE) || ((0x01 << dir) == DBNetDirE) || ((0x01 << dir) == DBNetDirSE)) col++;
if (((0x01 << dir) == DBNetDirNW) || ((0x01 << dir) == DBNetDirW) || ((0x01 << dir) == DBNetDirSW)) col--;
if (row < 0) continue;
if (col < 0) continue;
if (row >= gridIF->RowNum ()) continue;
if (col >= gridIF->ColNum ()) continue;
auxPos.Row = row;
auxPos.Col = col;
gridIF->Pos2Coord (auxPos,coord1);
switch (zGridData->Type ())
{
case DBTypeGridDiscrete: basinID = zGridIF->GridValue (layerRec,coord1); break;
case DBTypeGridContinuous: zGridIF->Value (layerRec,coord1,&basinID); break;
}
zones [zLayerID * 9 + dir] = basinID;
}
switch (zGridData->Type ())
{
case DBTypeGridDiscrete: basinID = zGridIF->GridValue (layerRec,coord0); break;
case DBTypeGridContinuous: zGridIF->Value (layerRec,coord0,&basinID); break;
}
zones [zLayerID * 9 + 8] = basinID;
}
for (dir = 0;dir < 9;++dir) zones [zLayerID * 9 + dir] = 0;
maxDir = DBFault;
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
if ((layerRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
if (gridIF->Value (layerRec,pos,&elev0))
{
maxDelta = (DBFloat) 0.0;
maxDir = 0;
for (zLayerID = 0;zLayerID < zLayerNum;++zLayerID)
{
for (dir = 0;dir < 8;++dir)
{
row = pos.Row;
col = pos.Col;
if (((0x01 << dir) == DBNetDirNW) || ((0x01 << dir) == DBNetDirN) || ((0x01 << dir) == DBNetDirNE)) row++;
if (((0x01 << dir) == DBNetDirSE) || ((0x01 << dir) == DBNetDirS) || ((0x01 << dir) == DBNetDirSW)) row--;
if (((0x01 << dir) == DBNetDirNE) || ((0x01 << dir) == DBNetDirE) || ((0x01 << dir) == DBNetDirSE)) col++;
if (((0x01 << dir) == DBNetDirNW) || ((0x01 << dir) == DBNetDirW) || ((0x01 << dir) == DBNetDirSW)) col--;
if (col < 0) continue;
if (row < 0) continue;
if (col >= gridIF->ColNum ()) continue;
if (row >= gridIF->RowNum ()) continue;
auxPos.Row = row;
auxPos.Col = col;
gridIF->Pos2Coord (auxPos,coord1);
distance = DBMathCoordinateDistance (projection,coord0,coord1);
if ((zones [zLayerID * 9 + dir] == zones [zLayerID * 9 + 8]) && (gridIF->Value (layerRec,auxPos,&elev1)))
{
delta = (downhill ? (elev1 - elev0) : (elev0 - elev1)) / distance;
if (maxDelta > delta) { maxDelta = delta; maxDir = (0x01 << dir); }
}
}
if (maxDir != 0) goto SlopeStop;
}
}
}
SlopeStop:
if (maxDir != DBFault)
{
sprintf (nameSTR,"GHAASCell:%d",cellTable->ItemNum ());
cellRec = cellTable->Add (nameSTR);
positionFLD->Position(cellRec,pos);
toCellFLD->Int (cellRec,(DBInt) maxDir);
fromCellFLD->Int (cellRec,(DBInt) 0);
orderFLD->Int (cellRec,(DBInt) 0);
basinFLD->Int (cellRec,(DBInt) 0);
basinCellsFLD->Int (cellRec,(DBInt) 0);
travelFLD->Int (cellRec,(DBInt) 0);
upCellPosFLD->Position (cellRec,pos);
cellAreaFLD->Float (cellRec,(DBFloat) 0.0);
subbasinLengthFLD->Float(cellRec,(DBFloat) 0.0);
subbasinAreaFLD->Float (cellRec,(DBFloat) 0.0);
((DBInt *) dataRec->Data ()) [pos.Row * gridIF->ColNum () + pos.Col] = cellRec->RowID ();
}
}
}
PauseStop:
if (pos.Row < gridIF->RowNum ()) return (DBFault);
sprintf (nameSTR,"GHAASBasin%d",(DBInt) 0);
basinRec = basinTable->Add (nameSTR);
mouthPosFLD->Position (basinRec,positionFLD->Position (cellTable->Item (0)));
colorFLD->Int (basinRec,0);
free (zones);
delete gridIF;
if (zGridIF != (DBGridIF *) NULL) delete zGridIF;
netData->Precision (DBMathMin (gridIF->CellWidth (),gridIF->CellHeight ()) / 25.0);
netIF = new DBNetworkIF (netData);
netIF->Build ();
delete netIF;
return (DBSuccess);
}