本文整理汇总了C++中DBObjTableField::String方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTableField::String方法的具体用法?C++ DBObjTableField::String怎么用?C++ DBObjTableField::String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTableField
的用法示例。
在下文中一共展示了DBObjTableField::String方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void UIAttribView::Draw (DBObjRecord *record)
{
DBObjTableField *field;
DBObjectLIST<DBObjTableField> *fields;
UIXYGraphShell *graphCLS;
if (record == (DBObjRecord *) NULL)
{
Cardinal i, numChildren;
WidgetList rowCols;
UIAuxSetLabelString (ItemNameWGT,(char *) "");
XtVaGetValues (FieldsRowCol,XmNchildren, &rowCols, XmNnumChildren, &numChildren,NULL);
for (i = 0;i < numChildren; ++i)
XmTextFieldSetString (XtNameToWidget (rowCols [i],"UIAttribViewTextField"),(char *) "");
return;
}
UIAuxSetLabelString (ItemNameWGT,record->Name ());
switch (DataPTR->Type ())
{
case DBTypeVectorPoint:
case DBTypeVectorLine:
case DBTypeVectorPolygon:
case DBTypeGridDiscrete:
fields = ItemTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record));
break;
case DBTypeGridContinuous:
{
DBCoordinate coord = *((DBCoordinate *) (record->Data ()));
DBGridIF *gridIF = new DBGridIF (DataPTR);
for (record = ItemTable->First ();record != (DBObjRecord *) NULL;record = ItemTable->Next ())
DrawField (record->Name (),gridIF->ValueString (record,coord));
delete gridIF;
} break;
case DBTypeNetwork:
{
DBObjTable *cellTable = DataPTR->Table (DBrNCells);
DBObjTableField *basinFLD = cellTable->Field (DBrNBasin);
DBObjRecord *basinRec;
if ((basinRec = ItemTable->Item (basinFLD->Int (record) - 1)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "BasinID Error in:%s %d",__FILE__,__LINE__); return; }
DrawField ((char *) "Basin Name",basinRec->Name ());
fields = ItemTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (basinRec));
fields = cellTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record));
} break;
default: break;
}
if ((graphCLS = (UIXYGraphShell *) DataPTR->Display (UIXYGraphShellStr)) != (UIXYGraphShell *) NULL)
graphCLS->Configure (record);
}
示例2: _DBObjTableListSort
static int _DBObjTableListSort(const DBObjRecord **obj0, const DBObjRecord **obj1) {
DBInt ret = 0;
DBObjTableField *field;
DBDate date0, date1;
for (field = _DBObjTableSortFields->First();
field != (DBObjTableField *) NULL;
field = _DBObjTableSortFields->Next()) {
switch (field->Type()) {
case DBTableFieldString:
ret = strcmp(field->String(*obj0), field->String(*obj1));
break;
case DBTableFieldInt:
ret = field->Int(*obj0) - field->Int(*obj1);
break;
case DBTableFieldFloat:
if (field->Float(*obj0) - field->Float(*obj1) > 0.0) ret = 1;
else if (field->Float(*obj0) - field->Float(*obj1) < 0.0) ret = -1;
else ret = 0;
break;
case DBTableFieldDate:
date0 = field->Date(*obj0);
date1 = field->Date(*obj1);
if (date0 > date1) ret = 1;
else if (date0 < date1) ret = -1;
else ret = 0;
break;
case DBTableFieldTableRec:
ret = strcmp((*obj0)->Name(), (*obj1)->Name());
break;
case DBTableFieldDataRec:
ret = (*obj0)->RowID() - (*obj1)->RowID();
break;
}
if ((field->Flags() & DBObjectFlagSortReversed) == DBObjectFlagSortReversed) ret *= -1;
if (ret != 0) return (ret);
}
if (ret == 0) ret = (*obj0)->ListPos() - (*obj1)->ListPos();
return (ret);
}
示例3: 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);
}
示例4: RGISAnalysePointInterStationTSCBK
void RGISAnalysePointInterStationTSCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
DBDataset *dataset = UIDataset ();
DBObjMetaEntry *metaEntry;
DBObjData *pntData = dataset->Data (), *tsData;
DBObjTable *relateTBL = pntData->Table (DBrNRelations);
DBObjRecord *relateRec;
DBObjTableField *relDataFLD;
DBObjTableField *relateFLD;
DBObjTableField *joinFLD;
static Widget selectWidget = (Widget) NULL;
if (selectWidget == (Widget) NULL) selectWidget = UISelectionCreate ((char *) "Select Time Series");
if ((selection = UISelectObject (selectWidget,(DBObjectLIST<DBObject> *) relateTBL)) == (char *) NULL) return;
if ((relateRec = relateTBL->Item (selection)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Relate Record Error in: %s %d",__FILE__,__LINE__); return; }
relDataFLD = relateTBL->Field (DBrNRelateData);
relateFLD = relateTBL->Field (DBrNRelateField);
joinFLD = relateTBL->Field (DBrNRelateJoinField);
if ((tsData = dataset->Data (relDataFLD->String (relateRec))) == (DBObjData *) NULL)
{
if ((metaEntry = dataset->Meta (relDataFLD->String (relateRec))) == (DBObjMetaEntry *) NULL)
{ CMmsgPrint (CMmsgAppError, "Meta Enrty Finding Error in: %s %d",__FILE__,__LINE__); return; }
tsData = new DBObjData ();
if (tsData->Read (metaEntry->FileName ()) != DBSuccess) return;
}
workspace->CurrentData (tsData);
UIPauseDialogOpen ((char *) "Calculating");
RGlibPointInterStationTS (pntData,tsData,relateFLD->String (relateRec),joinFLD->String (relateRec));
UIPauseDialogClose ();
}
示例5: RGISAnalyseLineMSampleGridCBK
void RGISAnalyseLineMSampleGridCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt layerID, layerNum;
DBCoordinate coord;
DBFloat realValue;
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjData *grdData = dbData->LinkedData ();
DBObjData *tblData;
DBObjTable *table, *itemTable = dbData->Table (DBrNItems);
DBObjTableField *lineIDFLD;
DBObjTableField *layerIDFLD;
DBObjTableField *layerNameFLD;
DBObjTableField *fromValueFLD = (DBObjTableField *) NULL;
DBObjTableField *toValueFLD = (DBObjTableField *) NULL;
DBVLineIF *lineIF = (DBVLineIF *) NULL;
DBGridIF *gridIF;
DBObjRecord *record, *layerRec, *tblRec;
DBObjectLIST<DBObjTableField> *fields;
widget = widget; callData = callData;
gridIF = new DBGridIF (grdData);
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
if ((layerRec->Flags () & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
}
if (layerNum < 1)
{ CMmsgPrint (CMmsgAppError, "No Layer to Process in: %s %d",__FILE__,__LINE__); delete gridIF; return; }
tblData = new DBObjData ("",DBTypeTable);
tblData->Document (DBDocGeoDomain,dbData->Document (DBDocGeoDomain));
tblData->Document (DBDocSubject,grdData->Document (DBDocSubject));
if (UIDataHeaderForm (tblData) == false) { delete gridIF; delete tblData; return; }
table = tblData->Table (DBrNItems);
lineIF = new DBVLineIF (dbData);
table->AddField (lineIDFLD = 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 (fromValueFLD = new DBObjTableField (RGISLineFromNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4)));
table->AddField (toValueFLD = new DBObjTableField (RGISLineToNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4)));
grdData->Flags (DBObjectFlagProcessed,DBSet);
UIPauseDialogOpen ((char *) "Sampling Grid(s)");
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
if ((layerRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ())
{
if (UIPause ((layerRec->RowID () * itemTable->ItemNum () + record->RowID ()) * 100 / (itemTable->ItemNum () * gridIF->LayerNum ()))) goto Stop;
if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
tblRec = table->Add (record->Name ());
lineIDFLD->Int (tblRec,record->RowID () + 1);
layerIDFLD->Int (tblRec,layerRec->RowID ());
layerNameFLD->String (tblRec,layerRec->Name ());
coord = lineIF->FromCoord (record);
if (gridIF->Value (layerRec,coord,&realValue))
fromValueFLD->Float (tblRec,realValue);
coord = lineIF->ToCoord (record);
if (gridIF->Value (layerRec,coord,&realValue))
toValueFLD->Float (tblRec,realValue);
}
}
Stop:
UIPauseDialogClose ();
delete gridIF;
delete lineIF;
fields = new DBObjectLIST<DBObjTableField> ("Field List");
fields->Add (new DBObjTableField (*lineIDFLD));
fields->Add (new DBObjTableField (*layerIDFLD));
table->ListSort (fields);
workspace->CurrentData (tblData);
delete fields;
}
示例6: main
int main (int argc,char *argv [])
{
int argPos, argNum = argc, ret, verbose = false;
DBInt recID;
bool padding = false;
char *tableName = (char *) NULL;
char *fieldName = (char *) NULL;
char *yearFieldName = (char *) NULL;
char *monthFieldName = (char *) NULL;
char *dayFieldName = (char *) NULL;
char *hourFieldName = (char *) NULL;
char *minFieldName = (char *) NULL;
char *tmp = (char *) NULL;
DBObjData *data;
DBObjTable *table;
DBObjTableField *srcField;
DBObjTableField *yearField = (DBObjTableField *) NULL;
DBObjTableField *monthField= (DBObjTableField *) NULL;
DBObjTableField *dayField = (DBObjTableField *) NULL;
DBObjTableField *hourField = (DBObjTableField *) NULL;
DBObjTableField *minField = (DBObjTableField *) NULL;
DBInt dbInputType = DBTableFieldInt;
DBInt dbInputSize = sizeof(DBShort);
DBDate date;
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],"-f","--field"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing field name!"); return (CMfailed); }
fieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-y","--year"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing year field name!"); return (CMfailed); }
yearFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-m","--month"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing month field name!"); return (CMfailed); }
monthFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-d","--day"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing day field name!"); return (CMfailed); }
dayFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-o","--hour"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing hour field name!"); return (CMfailed); }
hourFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-i","--minute"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing minute field name!"); return (CMfailed); }
minFieldName = argv [argPos];
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-p","--padding"))
{
padding = true;
dbInputType = DBTableFieldString;
dbInputSize = sizeof(DBByte) * 3;
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"))
//.........这里部分代码省略.........
示例7: DBImportARCVector
int DBImportARCVector (DBObjData *vecData,const char *arcCov,const char *nameFieldStr,const char *symbolFieldStr)
{
char symbolName [DBStringLength + 1];
DBObjTable *items = vecData->Table (DBrNItems);
DBObjTable *symbols = vecData->Table (DBrNSymbols);
DBObjTableField *nameFLD = NULL, *symbolResFLD, *symbolFLD = NULL;
DBObjTableField *symbolIDFLD = symbols->Field (DBrNSymbolID);
DBObjTableField *foregroundFLD = symbols->Field (DBrNForeground);
DBObjTableField *backgroundFLD = symbols->Field (DBrNBackground);
DBObjTableField *styleFLD = symbols->Field (DBrNStyle);
DBObjRecord *record;
DBObjRecord *symbolRec;
if (DBInfoGetFields (items,DBInfoFileName (arcCov,vecData->Type ())) == DBSuccess)
if (DBInfoGetTable (items,DBInfoFileName (arcCov,vecData->Type ())) == DBFault) return (DBFault);
switch (vecData->Type ())
{
case DBTypeVectorPoint:
if (DBImportARCPoint (vecData,arcCov) == DBFault) return (DBFault); else break;
case DBTypeVectorLine:
if (DBImportARCLine (vecData,arcCov) == DBFault) return (DBFault); else break;
case DBTypeVectorPolygon:
if (DBImportARCPoly (vecData,arcCov) == DBFault) return (DBFault); else break;
default: return (DBFault);
}
nameFLD = nameFieldStr != NULL ? items->Field (nameFieldStr) : (DBObjTableField *) NULL;
symbolFLD = symbolFieldStr != NULL ? items->Field (symbolFieldStr) : (DBObjTableField *) NULL;
symbolResFLD = items->Field (DBrNSymbol);
if (symbolFLD != NULL)
{
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
{
switch (symbolFLD->Type ())
{
case DBTableFieldString:
if ((symbolRec = (DBObjRecord *) symbols->Item (symbolFLD->String (record))) == NULL)
{
if ((symbolRec = symbols->Add (symbolFLD->String (record))) == NULL)
{ CMmsgPrint (CMmsgAppError,"Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,symbolRec->RowID ());
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
}
break;
case DBTableFieldInt:
sprintf (symbolName,"Symbol:%5d",symbolFLD->Int (record));
if ((symbolRec = (DBObjRecord *) symbols->Item (symbolName)) == NULL)
{
if ((symbolRec = symbols->Add (symbolName)) == NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,symbolFLD->Int (record));
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
}
break;
default:
CMmsgPrint (CMmsgAppError, "Invalid Field Type in: %s %d",__FILE__,__LINE__);
break;
}
symbolResFLD->Record (record,symbolRec);
}
}
else
{
symbols->Add ("Default Symbol");
if ((symbolRec = (DBObjRecord *) symbols->Item ()) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,0);
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
symbolResFLD->Record (record,symbolRec);
}
if (nameFLD != NULL)
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
record->Name (nameFLD->String (record));
return (DBSuccess);
}
示例8: RGlibPointSTNCharacteristics
DBInt RGlibPointSTNCharacteristics(DBObjData *dbData) {
DBInt i, pointID, dPointID, cellID, mouthID, basinID, color, ret = DBFault, dir;
DBVPointIF *pntIF;
DBObjTable *pointTable, *cellTable;
DBObjTableField *cellIDFLD;
DBObjTableField *basinFLD;
DBObjTableField *basinNameFLD;
DBObjTableField *orderFLD;
DBObjTableField *colorFLD;
DBObjTableField *basinCellsFLD;
DBObjTableField *basinLengthFLD;
DBObjTableField *basinAreaFLD;
DBObjTableField *interAreaFLD;
DBObjTableField *nextStationFLD;
DBObjData *netData;
DBNetworkIF *netIF;
DBObjRecord *pointRec, *dPointRec, *cellRec, *fromCell, *basinRec;
if ((netData = dbData->LinkedData()) == (DBObjData *) NULL) return (DBFault);
pointTable = dbData->Table(DBrNItems);
pntIF = new DBVPointIF(dbData);
netIF = new DBNetworkIF(netData);
cellTable = netData->Table(DBrNCells);
if ((cellIDFLD = pointTable->Field(RGlibCellID)) == NULL) {
cellIDFLD = new DBObjTableField(RGlibCellID, DBTableFieldInt, "%8d", sizeof(DBInt));
pointTable->AddField(cellIDFLD);
DBPause(1);
}
if ((basinFLD = pointTable->Field(DBrNBasin)) == NULL) {
basinFLD = new DBObjTableField(DBrNBasin, DBTableFieldInt, "%8d", sizeof(DBInt));
pointTable->AddField(basinFLD);
DBPause(2);
}
if ((basinNameFLD = pointTable->Field(RGlibBasinName)) == NULL) {
basinNameFLD = new DBObjTableField(RGlibBasinName, DBTableFieldString, "%32s", DBStringLength);
pointTable->AddField(basinNameFLD);
DBPause(3);
}
if ((orderFLD = pointTable->Field(DBrNOrder)) == NULL) {
orderFLD = new DBObjTableField(DBrNOrder, DBTableFieldInt, "%3d", sizeof(DBByte));
pointTable->AddField(orderFLD);
DBPause(4);
}
if ((colorFLD = pointTable->Field(RGlibColor)) == NULL) {
colorFLD = new DBObjTableField(RGlibColor, DBTableFieldInt, "%2d", sizeof(DBShort));
pointTable->AddField(colorFLD);
DBPause(5);
}
if ((basinCellsFLD = pointTable->Field(RGlibCellNum)) == NULL) {
basinCellsFLD = new DBObjTableField(RGlibCellNum, DBTableFieldInt, "%8d", sizeof(DBInt));
pointTable->AddField(basinCellsFLD);
DBPause(6);
}
if ((basinLengthFLD = pointTable->Field(RGlibLength)) == NULL) {
basinLengthFLD = new DBObjTableField(RGlibLength, DBTableFieldFloat, "%10.1f", sizeof(DBFloat4));
pointTable->AddField(basinLengthFLD);
DBPause(7);
}
if ((basinAreaFLD = pointTable->Field(RGlibArea)) == NULL) {
basinAreaFLD = new DBObjTableField(RGlibArea, DBTableFieldFloat, "%10.1f", sizeof(DBFloat4));
pointTable->AddField(basinAreaFLD);
DBPause(8);
}
if ((interAreaFLD = pointTable->Field(RGlibInterStation)) == NULL) {
interAreaFLD = new DBObjTableField(RGlibInterStation, DBTableFieldFloat, "%10.1f", sizeof(DBFloat4));
pointTable->AddField(interAreaFLD);
DBPause(9);
}
if ((nextStationFLD = pointTable->Field(RGlibNextStation)) == NULL) {
nextStationFLD = new DBObjTableField(RGlibNextStation, DBTableFieldInt, "%8d", sizeof(DBInt));
pointTable->AddField(nextStationFLD);
DBPause(10);
}
if ((_RGlibTEMPPointIDFLD = cellTable->Field(RGlibTEMPPointID)) == NULL) {
_RGlibTEMPPointIDFLD = new DBObjTableField(RGlibTEMPPointID, DBTableFieldInt, "%8d", sizeof(DBInt));
cellTable->AddField(_RGlibTEMPPointIDFLD);
}
for (pointID = 0; pointID < pointTable->ItemNum(); pointID++) {
pointRec = pointTable->Item(pointID);
if (DBPause(10 + pointID * 10 / pointTable->ItemNum())) goto Stop;
if ((pointRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) {
cellIDFLD->Int(pointRec, cellIDFLD->IntNoData());
basinFLD->Int(pointRec, basinFLD->IntNoData());
basinNameFLD->String(pointRec, "");
orderFLD->Int(pointRec, orderFLD->IntNoData());
colorFLD->Int(pointRec, colorFLD->IntNoData());
basinCellsFLD->Int(pointRec, basinCellsFLD->IntNoData());
basinAreaFLD->Float(pointRec, basinAreaFLD->FloatNoData());
interAreaFLD->Float(pointRec, interAreaFLD->FloatNoData());
continue;
}
if ((cellRec = netIF->Cell(pntIF->Coordinate(pointRec))) == (DBObjRecord *) NULL) {
cellIDFLD->Int(pointRec, 0);
basinFLD->Int(pointRec, 0);
basinNameFLD->String(pointRec, "Water");
orderFLD->Int(pointRec, colorFLD->IntNoData());
colorFLD->Int(pointRec, colorFLD->IntNoData());
basinCellsFLD->Int(pointRec, 0);
basinAreaFLD->Float(pointRec, 0.0);
interAreaFLD->Float(pointRec, 0.0);
//.........这里部分代码省略.........
示例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: RGlibPointSubbasinStats
DBInt RGlibPointSubbasinStats(DBObjData *pntData, DBObjData *netData, DBObjData *grdData, DBObjData *tblData) {
DBInt layerID, layerNum = 0, progress = 0, maxProgress;
DBObjTable *table;
DBObjTableField *pointIDFLD;
DBObjTableField *layerIDFLD;
DBObjTableField *layerNameFLD;
DBObjTableField *minimumFLD;
DBObjTableField *maximumFLD;
DBObjTableField *averageFLD;
DBObjTableField *stdDevFLD;
DBObjTableField *areaFLD;
DBVPointIF *pntIF;
DBNetworkIF *netIF;
DBObjRecord *pntRec, *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);
}
table = tblData->Table(DBrNItems);
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(averageFLD = new DBObjTableField(RGlibPointMean, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(minimumFLD = new DBObjTableField(RGlibPointMin, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(maximumFLD = new DBObjTableField(RGlibPointMax, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(
stdDevFLD = new DBObjTableField(RGlibPointStdDev, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(areaFLD = new DBObjTableField(RGlibPointArea, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
grdData->Flags(DBObjectFlagProcessed, DBSet);
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;
tblRec = table->Add(pntRec->Name());
pointIDFLD->Int(tblRec, pntRec->RowID() + 1);
layerIDFLD->Int(tblRec, _RGlibPointGrdLayerRec->RowID());
layerNameFLD->String(tblRec, _RGlibPointGrdLayerRec->Name());
_RGlibSubbasinArea = 0.0;
_RGlibSubbasinMin = DBHugeVal;
_RGlibSubbasinMax = -DBHugeVal;
_RGlibSubbasinMean = 0.0;
_RGlibSubbasinStdDev = 0.0;
netIF->UpStreamSearch(netIF->Cell(pntIF->Coordinate(pntRec)), (DBNetworkACTION) _RGlibSubbasinStatistics);
_RGlibSubbasinMean = _RGlibSubbasinMean / _RGlibSubbasinArea;
_RGlibSubbasinStdDev = _RGlibSubbasinStdDev / _RGlibSubbasinArea;
_RGlibSubbasinStdDev = _RGlibSubbasinStdDev - _RGlibSubbasinMean * _RGlibSubbasinMean;
_RGlibSubbasinStdDev = sqrt(_RGlibSubbasinStdDev);
minimumFLD->Float(tblRec, _RGlibSubbasinMin);
maximumFLD->Float(tblRec, _RGlibSubbasinMax);
averageFLD->Float(tblRec, _RGlibSubbasinMean);
stdDevFLD->Float(tblRec, _RGlibSubbasinStdDev);
areaFLD->Float(tblRec, _RGlibSubbasinArea);
}
}
Stop:
delete _RGlibPointGrdIF;
delete netIF;
delete pntIF;
if (progress == maxProgress) {
fields = new DBObjectLIST<DBObjTableField>("Field List");
fields->Add(new DBObjTableField(*pointIDFLD));
fields->Add(new DBObjTableField(*layerIDFLD));
table->ListSort(fields);
delete fields;
return (DBSuccess);
}
return (DBFault);
}