本文整理汇总了C++中DBObjTable::Field方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTable::Field方法的具体用法?C++ DBObjTable::Field怎么用?C++ DBObjTable::Field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTable
的用法示例。
在下文中一共展示了DBObjTable::Field方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _RGISGrpPanelNewCBK
static void _RGISGrpPanelNewCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)
{
char *groupName;
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *groupTable = dbData->Table (DBrNGroups);
DBObjTableField *group;
DBObjRecord *record;
if ((groupName = UIGetString ((char *) "Group Name",16)) == (char *) NULL) return;
if (groupTable == (DBObjTable *) NULL)
{
DBObjTable *items = dbData->Table (DBrNItems);
DBObjectLIST<DBObjTable> *tables = dbData->Tables ();
DBTableFieldDefinition fieldDefs [] = {
DBTableFieldDefinition (groupName, DBTableFieldInt,(char *) "%1d",sizeof (DBByte)),
DBTableFieldDefinition () };
tables->Add (groupTable = new DBObjTable (DBrNGroups,fieldDefs));
grpPanel->Groups (groupTable->Fields ());
group = groupTable->Field (groupName);
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
group->Int (groupTable->Add (record->Name ()),true);
}
else
{
groupTable->AddField (group = new DBObjTableField (groupName,DBTableFieldInt,"%1d",sizeof (DBByte)));
for (record = groupTable->First ();record != (DBObjRecord *) NULL;record = groupTable->Next ())
group->Int (record,true);
}
grpPanel->Add (group);
}
示例2: 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);
}
示例3: RGISAnNetworkToGridCBK
void RGISAnNetworkToGridCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
DBInt dataType;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTableField *field;
DBObjData *grdData;
static Widget select = NULL;
if (select == NULL) select = UISelectionCreate ((char *) "Field Selection");
selection = UISelectObject (select,(DBObjectLIST<DBObject> *) (cellTable->Fields ()),DBTableFieldIsSimple);
if (selection == (char *) NULL) return;
if ((field = cellTable->Field (selection)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError,"Corrupt Network Dataset in: %s %d",__FILE__,__LINE__); return; }
if (DBTableFieldIsCategory (field) && DBTableFieldIsNumeric (field))
{
DBObjData *tmpData;
tmpData = new DBObjData ("",DBTypeGrid);
tmpData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain));
tmpData->Document (DBDocSubject,field->Name ());
if (UIDataHeaderForm (tmpData))
{
grdData = DBNetworkToGrid (netData,tmpData->Type ());
grdData->Name (tmpData->Name ());
grdData->Document (DBDocGeoDomain,tmpData->Document (DBDocGeoDomain));
grdData->Document (DBDocSubject,tmpData->Document (DBDocSubject));
grdData->Document (DBDocVersion,tmpData->Document (DBDocVersion));
grdData->Document (DBDocCitationRef,tmpData->Document (DBDocCitationRef));
grdData->Document (DBDocCitationInst,tmpData->Document (DBDocCitationInst));
grdData->Document (DBDocSourceInst,tmpData->Document (DBDocSourceInst));
grdData->Document (DBDocSourcePerson,tmpData->Document (DBDocSourcePerson));
grdData->Document (DBDocOwnerPerson,tmpData->Document (DBDocOwnerPerson));
grdData->Document (DBDocComment,tmpData->Document (DBDocComment));
delete tmpData;
}
else { return; }
}
else
{
if (DBTableFieldIsCategory (field)) dataType = DBTypeGridDiscrete;
else if (DBTableFieldIsNumeric (field)) dataType = DBTypeGridContinuous;
else
{
CMmsgPrint (CMmsgAppError,"Invalid field type in: %s %d",__FILE__,__LINE__);
return;
}
grdData = DBNetworkToGrid (netData,dataType);
if (UIDataHeaderForm (grdData) == false) { delete grdData; return; }
}
UIPauseDialogOpen ((char *) "Converting Network to Grid");
if (RGlibNetworkToGrid (netData,field,grdData) == DBSuccess) workspace->CurrentData (grdData);
else delete grdData;
UIPauseDialogClose ();
}
示例4: Extent
DBRegion DBObjData::Extent(DBObjRecord *record) {
DBRegion extent;
DBCoordinate coord;
DBFloat delta;
DBObjTable *items;
DBObjTableField *field;
if (record == (DBObjRecord *) NULL) return (Extent());
switch (Type()) {
case DBTypeVectorPoint:
delta = pow((double) 10.0, (double) Precision());
items = TablesPTR->Item(DBrNItems);
field = items->Field(DBrNCoord);
coord = field->Coordinate(record);
extent.Expand(coord + delta);
extent.Expand(coord - delta);
return (extent);
case DBTypeVectorLine:
case DBTypeVectorPolygon:
items = TablesPTR->Item(DBrNItems);
field = items->Field(DBrNRegion);
return (field->Region(record));
case DBTypeGridDiscrete:
case DBTypeGridContinuous:
return (Extent());
case DBTypeNetwork: {
DBInt cellID, cellNum;
DBObjRecord *cellRec;
DBNetworkIF *netIF = new DBNetworkIF(this);
cellRec = netIF->MouthCell(record);
cellNum = netIF->CellBasinCells(cellRec) + cellRec->RowID();
for (cellID = cellRec->RowID(); cellID < cellNum; ++cellID) {
cellRec = netIF->Cell(cellID);
extent.Expand(netIF->Center(cellRec) + (netIF->CellSize() / 2.0));
extent.Expand(netIF->Center(cellRec) - (netIF->CellSize() / 2.0));
}
delete netIF;
}
return (extent);
case DBTypeTable:
default:
return (extent);
}
}
示例5: RGISAnalysePointSubbasinCenterCBK
void RGISAnalysePointSubbasinCenterCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *pntData =dataset->Data ();
DBObjTable *pointTable = pntData->Table (DBrNItems);
DBObjTableField *massCoordXFLD = pointTable->Field (RGlibMassCoordX);
DBObjTableField *massCoordYFLD = pointTable->Field (RGlibMassCoordY);
DBObjData *netData = pntData->LinkedData ();
UITable *tableCLS = (UITable *) pntData->Display (UITableName (pntData,pointTable));
UIPauseDialogOpen ((char *) "Subbasin Centers");
if ((RGlibPointSubbasinCenter (pntData, netData) == DBSuccess) && (tableCLS != (UITable *) NULL))
{
if (massCoordXFLD == NULL) tableCLS->AddField (pointTable->Field (RGlibMassCoordX));
if (massCoordYFLD == NULL) tableCLS->AddField (pointTable->Field (RGlibMassCoordY));
tableCLS->Draw ();
}
UIPauseDialogClose ();
}
示例6: 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 ();
}
示例7: RGlibPointSubbasinCenter
DBInt RGlibPointSubbasinCenter(DBObjData *pntData, DBObjData *netData) {
DBCoordinate massCoord;
DBVPointIF *pntIF = new DBVPointIF(pntData);
DBObjTable *pointTable = pntData->Table(DBrNItems);
DBObjTableField *massCoordXFLD = pointTable->Field(RGlibMassCoordX);
DBObjTableField *massCoordYFLD = pointTable->Field(RGlibMassCoordY);
DBNetworkIF *netIF = new DBNetworkIF(netData);
DBObjRecord *pointRec, *cellRec;
if (massCoordXFLD == NULL) {
massCoordXFLD = new DBObjTableField(RGlibMassCoordX, DBTableFieldFloat, "%10.3f", sizeof(DBFloat4));
pointTable->AddField(massCoordXFLD);
}
if (massCoordYFLD == NULL) {
massCoordYFLD = new DBObjTableField(RGlibMassCoordY, DBTableFieldFloat, "%10.3f", sizeof(DBFloat4));
pointTable->AddField(massCoordYFLD);
}
for (pointRec = pntIF->FirstItem(); pointRec != (DBObjRecord *) NULL; pointRec = pntIF->NextItem()) {
if ((pointRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) {
massCoordXFLD->Float(pointRec, massCoordXFLD->FloatNoData());
massCoordYFLD->Float(pointRec, massCoordYFLD->FloatNoData());
continue;
}
if (DBPause(pointRec->RowID() * 100 / pntIF->ItemNum())) goto Stop;
if ((cellRec = netIF->Cell(pntIF->Coordinate(pointRec))) == (DBObjRecord *) NULL)
massCoord = pntIF->Coordinate(pointRec);
else {
if (netIF->CellBasinCells(cellRec) > 1) {
massCoord.X = 0.0;
massCoord.Y = 0.0;
netIF->UpStreamSearch(cellRec, (DBNetworkACTION) _RGlibSubbasinCenterAction, &massCoord);
massCoord.X = massCoord.X / (DBFloat) netIF->CellBasinCells(cellRec);
massCoord.Y = massCoord.Y / (DBFloat) netIF->CellBasinCells(cellRec);
}
else massCoord = netIF->Center(cellRec);
}
massCoordXFLD->Float(pointRec, massCoord.X);
massCoordYFLD->Float(pointRec, massCoord.Y);
}
Stop:
if (pointRec != (DBObjRecord *) NULL) {
pointTable->DeleteField(massCoordXFLD);
pointTable->DeleteField(massCoordYFLD);
return (DBFault);
}
return (DBSuccess);
}
示例8: 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);
}
示例9: RGISEditNetAddBasinXYCBK
void RGISEditNetAddBasinXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt basinID;
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBNetworkIF *netIF = new DBNetworkIF (dbData);
DBObjTable *itemTable = dbData->Table (DBrNItems);
DBObjTableField *xCoordFLD = itemTable->Field (RGISNetMouthXCoord);
DBObjTableField *yCoordFLD = itemTable->Field (RGISNetMouthYCoord);
DBCoordinate coord;
DBObjRecord *basinRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,itemTable));
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISNetMouthXCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
itemTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISNetMouthYCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
itemTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (basinID = 0;basinID < netIF->BasinNum ();++basinID)
{
basinRec = netIF->Basin (basinID);
if (UIPause (80 + basinID * 20 / netIF->BasinNum ())) goto Stop;
coord = netIF->Center (netIF->MouthCell (basinRec));
xCoordFLD->Float (basinRec,coord.X);
yCoordFLD->Float (basinRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例10: RGISEditPointAddXYCBK
void RGISEditPointAddXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBVPointIF *pntIF = new DBVPointIF (dbData);
DBObjTable *pointTable = dbData->Table (DBrNItems);
DBObjTableField *xCoordFLD = pointTable->Field (RGISEditPointXCoord);
DBObjTableField *yCoordFLD = pointTable->Field (RGISEditPointYCoord);
DBCoordinate coord;
DBObjRecord *pointRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,pointTable));
widget = widget; workspace = workspace; callData = callData;
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISEditPointXCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4));
pointTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISEditPointYCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4));
pointTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (pointRec = pntIF->FirstItem (); pointRec != (DBObjRecord *) NULL; pointRec = pntIF->NextItem ())
{
if (UIPause (80 + pointRec->RowID () * 20 / pntIF->ItemNum ())) goto Stop;
coord = pntIF->Coordinate (pointRec);
xCoordFLD->Float (pointRec,coord.X);
yCoordFLD->Float (pointRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例11: _RGISToolsExportNetworkCBK
static void _RGISToolsExportNetworkCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
FILE *outFILE;
DBInt cellID, fieldID, fieldNum = 0;
DBCoordinate coord;
DBObjRecord *cellRec,*toCellRec, *basinRec;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBNetworkIF *netIF = new DBNetworkIF (netData);
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTableField *field, **fields = (DBObjTableField **) NULL;
static Widget dirSelect = NULL;
widget = widget; workspace = workspace; callData = callData;
if (dirSelect == NULL)
{ if ((dirSelect = UIFileSelectionCreate ((char *) "Network File",NULL,(char *) "*.txt",XmFILE_REGULAR)) == NULL) return; }
if ((selection = UIFileSelection (dirSelect,False)) == NULL) return;
if ((outFILE = fopen (selection,"w")) == (FILE *) NULL)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }
fprintf (outFILE,"\"CellID\"\t\"XCoord\"\t\"YCoord\"\t\"BasinID\"\t\"ToCell\"\t\"CellArea\"\t\"CellLength\"");
for (fieldID = 0;fieldID < cellTable->FieldNum (); fieldID++)
{
if ((field = cellTable->Field (fieldID)) == (DBObjTableField *) NULL)
{
if (fields != (DBObjTableField **) NULL) free (fields);
CMmsgPrint (CMmsgSysError, "Invalid field in: %s %d",__FILE__,__LINE__);
return;
}
if (field->Required ()) continue;
if ((fields = (DBObjTableField **) realloc (fields,(fieldNum + 1) * sizeof (DBObjTableField *))) == (DBObjTableField **) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory allocation error in: %s %d",__FILE__,__LINE__); return; }
fields [fieldNum] = field;
fprintf (outFILE,"\t\"%s\"",field->Name ());
fieldNum++;
}
fprintf (outFILE,"\n");
for (cellID = 0;cellID < netIF->CellNum (); cellID++)
{
cellRec = netIF->Cell (cellID);
coord = netIF->Center (cellRec);
basinRec = netIF->Basin (cellRec);
toCellRec = netIF->ToCell (cellRec);
fprintf (outFILE,"%d\t%f\t%f\t%d\t%d\t%f\t%f",cellRec->RowID () + 1,
coord.X, coord.Y,
basinRec->RowID () + 1,
toCellRec == (DBObjRecord *) NULL ? DBFault : toCellRec->RowID () + 1,
netIF->CellArea (cellRec),
netIF->CellLength (cellRec));
for (fieldID = 0;fieldID < fieldNum; fieldID++)
switch (fields [fieldID]->Type ())
{
default:
case DBTableFieldString: fprintf (outFILE,"%c\"%s\"",DBASCIISeparator,fields [fieldID]->String (cellRec)); break;
case DBTableFieldInt:
if (fields [fieldID]->Int (cellRec) == fields [fieldID]->IntNoData ())
fprintf (outFILE,"%c",DBASCIISeparator);
else fprintf (outFILE,"%c%d",DBASCIISeparator,fields [fieldID]->Int (cellRec));
break;
case DBTableFieldFloat:
if (CMmathEqualValues (fields [fieldID]->Float (cellRec),fields [fieldID]->FloatNoData ()))
fprintf (outFILE,"%c",DBASCIISeparator);
else fprintf (outFILE,"%c%f",DBASCIISeparator,fields [fieldID]->Float (cellRec));
break;
case DBTableFieldDate: fprintf (outFILE,"%c\"%s\"",DBASCIISeparator,fields [fieldID]->String(cellRec)); break;
}
fprintf (outFILE,"\n");
}
fclose (outFILE);
}
示例12: 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"))
//.........这里部分代码省略.........
示例13: RGISAnNetworkStreamLinesCBK
void RGISAnNetworkStreamLinesCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjData *arcData = new DBObjData ("",DBTypeVectorLine);
DBNetworkIF *netIF = new DBNetworkIF (netData);
static Widget fieldSelect = (Widget) NULL;
widget = widget; callData = callData;
if (fieldSelect == (Widget) NULL) fieldSelect = UISelectionCreate ((char *) "Select Field");
if ((selection = UISelectObject (fieldSelect,(DBObjectLIST<DBObject> *) cellTable->Fields (),DBTableFieldIsInteger)) == (char *) NULL)
return;
if ((_RGISAnNetOrderField = cellTable->Field (selection)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Field Selection Error in: %s %d",__FILE__,__LINE__); return; }
arcData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain));
arcData->Document (DBDocSubject,"Stream Lines");
if (UIDataHeaderForm (arcData))
{
DBInt cellID;
char objName [DBStringLength];
DBVLineIF *lineIF = new DBVLineIF (arcData);
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTable *lineTable = arcData->Table (DBrNItems);
DBObjTableField *basinFLD = new DBObjTableField (DBrNBasin,DBTableFieldInt,"%8d",sizeof (DBInt));
DBObjTableField *fieldFLD = new DBObjTableField (_RGISAnNetOrderField->Name (),
_RGISAnNetOrderField->Type (),
_RGISAnNetOrderField->Format (),
_RGISAnNetOrderField->Length ());
DBObjTableField *lengthFLD = new DBObjTableField (RGISNetStreamLength,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4));
DBObjTableField *areaFLD = new DBObjTableField (RGISNetStreamArea,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4));
DBObjTableField *basinAreaFLD = new DBObjTableField (RGISNetBasinArea,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4));
DBObjTableField *nextFLD = new DBObjTableField (RGISNetStreamNext,DBTableFieldInt,"%6d",sizeof (DBInt));
DBObjRecord *cellRec, *toCellRec, *lineRec;
arcData->Projection (netData->Projection ());
arcData->Precision (netData->Precision ());
arcData->MaxScale (netData->MaxScale ());
arcData->MinScale (netData->MinScale ());
lineTable->AddField (basinFLD);
lineTable->AddField (fieldFLD);
lineTable->AddField (lengthFLD);
lineTable->AddField (areaFLD);
lineTable->AddField (basinAreaFLD);
lineTable->AddField (nextFLD);
cellTable->AddField (_RGISAnNetStreamIDFLD = new DBObjTableField ("StreamID",DBTableFieldInt,"%8d",sizeof (DBInt)));
_RGISAnNetStreamID = 0;
UIPauseDialogOpen ((char *) "Creating Stream Lines");
cellID = netIF->CellNum () - 1;
cellRec = netIF->Cell (cellID);
if (lineIF->NewSymbol ("Default Symbol") == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Creation Error in: %s %d",__FILE__,__LINE__); return; }
for (;cellID >= 0;--cellID)
{
cellRec = netIF->Cell (cellID);
if (((toCellRec = netIF->ToCell (cellRec)) == (DBObjRecord *) NULL) ||
(_RGISAnNetOrderField->Int (cellRec) != _RGISAnNetOrderField->Int (toCellRec)) ||
(netIF->CellOrder (cellRec) != netIF->CellOrder (toCellRec)))
{
if (UIPause ((netIF->CellNum () - cellRec->RowID ()) * 100 / netIF->CellNum ())) goto Stop;
sprintf (objName,"Line: %5d",_RGISAnNetStreamID + 1);
if ((lineRec = lineIF->NewItem (objName)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Line Insertion Error in: %s %d",__FILE__,__LINE__); return; }
nextFLD->Int (lineRec,toCellRec == (DBObjRecord *) NULL ? 0 : _RGISAnNetStreamIDFLD->Int (toCellRec) + 1);
basinFLD->Int (lineRec,netIF->CellBasinID (cellRec));
fieldFLD->Int (lineRec,_RGISAnNetOrderField->Int (cellRec));
_RGISAnNetVertex = 0;
netIF->UpStreamSearch (_RGISAnNetworkCellRec = cellRec,(DBNetworkACTION) _RGISAnNetworkUpStreamAction);
lineIF->FromNode (lineRec,lineIF->Node (netIF->Center (_RGISAnNetworkCellRec),true));
lineIF->ToNode (lineRec,lineIF->Node (netIF->Center (cellRec) + netIF->Delta (cellRec),true));
_RGISAnNetArea = netIF->CellArea (_RGISAnNetworkCellRec);
if (_RGISAnNetVertex > 1)
{
if (_RGISAnNetVertexNum < _RGISAnNetVertex - 1)
{
_RGISAnNetCoord = (DBCoordinate *) realloc (_RGISAnNetCoord,(_RGISAnNetVertex - 1) * sizeof (DBCoordinate));
if (_RGISAnNetCoord == (DBCoordinate *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return; }
}
_RGISAnNetVertex = 0;
netIF->DownStreamSearch (netIF->ToCell (_RGISAnNetworkCellRec),(DBNetworkACTION) _RGISAnNetworkDownStreamAction);
}
else _RGISAnNetVertex = 0;
lineIF->Vertexes (lineRec,_RGISAnNetCoord,_RGISAnNetVertex);
lineIF->ItemSymbol (lineRec,lineIF->Symbol (0));
lengthFLD->Float (lineRec,netIF->CellBasinLength (cellRec));
areaFLD->Float (lineRec,_RGISAnNetArea);
basinAreaFLD->Float (lineRec,netIF->CellBasinArea (cellRec));
_RGISAnNetStreamID += 1;
}
}
//.........这里部分代码省略.........
示例14: _RGISToolsNetBasinMouthCBK
static void _RGISToolsNetBasinMouthCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data (), *pntData;
DBNetworkIF *netIF;
widget = widget; callData = callData;
if (netData == (DBObjData *) NULL)
{ CMmsgPrint (CMmsgAppError, "Null Data in: %s %d",__FILE__,__LINE__); return; }
netIF = new DBNetworkIF (netData);
if (UIDataHeaderForm (pntData = new DBObjData ("",DBTypeVectorPoint)))
{
char symName [DBStringLength];
DBInt basinID, order;
DBCoordinate coord;
DBObjTable *items = pntData->Table (DBrNItems);
DBObjTable *symbols = pntData->Table (DBrNSymbols);
DBObjTableField *coordField = items->Field (DBrNCoord);
DBObjTableField *symbolFLD = items->Field (DBrNSymbol);
DBObjTableField *orderFLD = new DBObjTableField (DBrNOrder,DBTableFieldInt,"%3d",sizeof (DBByte));
DBObjTableField *subbasinLengthFLD = new DBObjTableField (DBrNSubbasinLength,DBTableFieldFloat,"%10.1f",sizeof (float));
DBObjTableField *subbasinAreaFLD = new DBObjTableField (DBrNSubbasinArea,DBTableFieldFloat,"%10.1f",sizeof (float));
DBObjTableField *foregroundFLD = symbols->Field (DBrNForeground);
DBObjTableField *backgroundFLD = symbols->Field (DBrNBackground);
DBObjTableField *styleFLD = symbols->Field (DBrNStyle);
DBObjRecord *pntRec, *symRec, *cellRec, *basinRec;
DBRegion dataExtent;
items->AddField (orderFLD);
items->AddField (subbasinLengthFLD);
items->AddField (subbasinAreaFLD);
cellRec = netIF->Cell ((DBInt) 0);
for (order = 0;order <= netIF->CellOrder (cellRec);++order)
{
sprintf (symName,"Strahler Order:%2d",order);
symRec = symbols->Add (symName);
styleFLD->Int (symRec,0);
foregroundFLD->Int (symRec,1);
backgroundFLD->Int (symRec,0);
}
UIPauseDialogOpen ((char *) "Creating Basin Mouth");
for (basinID = 0;basinID < netIF->BasinNum ();++basinID)
{
basinRec = netIF->Basin (basinID);
if (UIPause (basinID * 100 / netIF->BasinNum ())) goto Stop;
symRec = symbols->Item (netIF->CellOrder (cellRec));
cellRec = netIF->MouthCell (basinRec);
pntRec = items->Add (basinRec->Name ());
coord = netIF->Center (cellRec);
coordField->Coordinate (pntRec,coord);
symbolFLD->Record (pntRec,symRec);
orderFLD->Int (pntRec,netIF->CellOrder (cellRec));
subbasinLengthFLD->Float (pntRec,netIF->CellBasinLength (cellRec));
subbasinAreaFLD->Float (pntRec,netIF->CellBasinArea (cellRec));
dataExtent.Expand (coord);
}
Stop:
UIPauseDialogClose ();
pntData->Extent (dataExtent);
workspace->CurrentData (pntData);
}
else delete pntData;
delete netIF;
}
示例15: 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)
{
//.........这里部分代码省略.........