本文整理汇总了C++中DBNetworkIF::Basin方法的典型用法代码示例。如果您正苦于以下问题:C++ DBNetworkIF::Basin方法的具体用法?C++ DBNetworkIF::Basin怎么用?C++ DBNetworkIF::Basin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBNetworkIF
的用法示例。
在下文中一共展示了DBNetworkIF::Basin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 ();
}
示例2: main
int main(int argc, char *argv[]) {
int argPos, argNum = argc, ret, verbose = false;
DBInt recID;
DBObjData *data;
char *tableName = (char *) NULL;
char *fieldIDName = (char *) NULL;
char *fieldXName = (char *) NULL;
char *fieldYName = (char *) NULL;
DBObjTable *table;
DBObjTableField *fieldID, *fieldX, *fieldY;
DBObjRecord *record;
DBNetworkIF *netIF;
DBCoordinate coord;
for (argPos = 1; argPos < argNum;) {
if (CMargTest (argv[argPos], "-a", "--table")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing table name!");
return (CMfailed);
}
tableName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-f", "--IDfield")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing field name!");
return (CMfailed);
}
fieldIDName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-x", "--Xfield")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing field name!");
return (CMfailed);
}
fieldXName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-y", "--Yfield")) {
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
CMmsgPrint(CMmsgUsrError, "Missing field name!");
return (CMfailed);
}
fieldYName = argv[argPos];
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-V", "--verbose")) {
verbose = true;
if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv[argPos], "-h", "--help")) {
CMmsgPrint(CMmsgInfo, "%s [options] <input file> <output file>", CMfileName(argv[0]));
CMmsgPrint(CMmsgInfo, " -a, --table [ [DBCells] | DBItems ]");
CMmsgPrint(CMmsgInfo, " -f, --IDfield [ [CellID] | BasinID ]");
CMmsgPrint(CMmsgInfo, " -x, --Xfield [ [CellXCoord] | MouthXCoord ]");
CMmsgPrint(CMmsgInfo, " -y, --Yfield [ [CellYCoord] | MouthYCoord ]");
CMmsgPrint(CMmsgInfo, " -V, --verbose");
CMmsgPrint(CMmsgInfo, " -h, --help");
return (DBSuccess);
}
if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
return (CMfailed);
}
argPos++;
}
if (argNum > 3) {
CMmsgPrint(CMmsgUsrError, "Extra arguments!");
return (CMfailed);
}
if (verbose) RGlibPauseOpen(argv[0]);
if (tableName == (char *) NULL) tableName = (char *) "DBCells";
if (fieldIDName == (char *) NULL) fieldIDName = (char *) "CellID";
if (fieldXName == (char *) NULL) fieldXName = (char *) "CellXCoord";
if (fieldYName == (char *) NULL) fieldYName = (char *) "CellYCoord";
data = new DBObjData();
if (((argNum > 1) && (strcmp(argv[1], "-") != 0) ? data->Read(argv[1]) : data->Read(stdin)) == DBFault) {
delete data;
return (CMfailed);
}
if ((table = data->Table(tableName)) == (DBObjTable *) NULL) {
CMmsgPrint(CMmsgUsrError, "Invalid table: %s!", tableName);
delete data;
return (CMfailed);
}
netIF = new DBNetworkIF(data);
fieldID = new DBObjTableField(fieldIDName, DBTableFieldInt, (char *) "%8d", sizeof (DBInt));
fieldX = new DBObjTableField (fieldXName, DBTableFieldFloat, (char *) "%10.3f", sizeof (DBFloat4));
//.........这里部分代码省略.........
示例3: _RGISUserFuncionNetwork
void _RGISUserFuncionNetwork (DBObjData *data,UI2DView *view,XEvent *event)
{
DBInt sX, sY, redraw = false;
DBNetworkIF *netIF;
DBCoordinate coord;
DBObjRecord *cellRec, *basinRec;
void _RGISUserFuncionQuery (DBObjData *,UI2DView *,XEvent *);
if ((data->Flags () & DBDataFlagUserModeFlags) == DBDataFlagUserModeQuery)
{ _RGISUserFuncionQuery (data,view,event); return; }
if (event->type != ButtonPress) return;
if (DBTypeNetwork != data->Type ())
{ CMmsgPrint (CMmsgAppError, "Invalid data Type in: %s %d",__FILE__,__LINE__); }
sX = event->xbutton.x;
sY = event->xbutton.y;
view->Window2Map (sX,sY, &coord.X, &coord.Y);
netIF = new DBNetworkIF (data);
switch (data->Flags () & DBDataFlagUserModeFlags)
{
case DBDataFlagUserModeSelect:
{
DBInt basinID, cellID;
DBRegion extent;
UITable *tableView;
if ((cellRec = netIF->Cell (coord)) == (DBObjRecord *) NULL)
{ UIMessage ((char *) "Cell Does not Exists!"); return; }
for (basinID = 0;basinID < netIF->BasinNum ();++basinID)
{
basinRec = netIF->Basin (basinID);
if ((basinRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected)
{
data->SelectObject (basinRec,DBClear);
extent.Expand (data->Extent (basinRec));
}
}
for (cellID = 0;cellID < netIF->CellNum ();++cellID)
{
cellRec = netIF->Cell (cellID);
if ((cellRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected)
{
extent.Expand (netIF->Center (cellRec) + (netIF->CellSize () / 2.0));
extent.Expand (netIF->Center (cellRec) - (netIF->CellSize () / 2.0));
cellRec->Flags (DBObjectFlagSelected,DBClear);
}
}
if ((tableView = (UITable *) data->Display (UITableName (data,data->Table (DBrNItems)))) != (UITable *) NULL)
tableView->Draw ();
if ((tableView = (UITable *) data->Display (UITableName (data,data->Table (DBrNCells)))) != (UITable *) NULL)
tableView->Draw ();
UI2DViewRedrawAll (extent);
cellRec = netIF->Cell (coord);
switch (data->Flags () & DBDataFlagSelectMode)
{
case DBDataFlagSelectMode: netIF->DownStreamSearch (cellRec, DBNetworkSelect); break;
default: netIF->UpStreamSearch (cellRec, DBNetworkSelect); break;
}
extent.Initialize ();
for (cellID = 0;cellID < netIF->CellNum ();++cellID)
{
cellRec = netIF->Cell (cellID);
if ((cellRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected)
{
extent.Expand (netIF->Center (cellRec) + (netIF->CellSize () / 2.0));
extent.Expand (netIF->Center (cellRec) - (netIF->CellSize () / 2.0));
}
}
UI2DViewRedrawAll (extent);
if ((tableView = (UITable *) data->Display (UITableName (data,data->Table (DBrNCells)))) != (UITable *) NULL)
tableView->Draw ();
} break;
case DBDataFlagUserModeAdd:
if (netIF->CellAdd (coord) == (DBObjRecord *) NULL) UIMessage ((char *) "Cell Creation Error");
else redraw = true;
break;
case DBDataFlagUserModeDelete:
if (netIF->CellDelete (coord) == DBFault) UIMessage ((char *) "Cell Does not Exists!");
else redraw = true;
break;
case DBDataFlagUserModeRotate:
{
DBObjRecord *cellRec = netIF->Cell (coord);
if (cellRec != (DBObjRecord *) NULL)
{
switch (netIF->CellDirection (cellRec))
{
case DBNull: netIF->CellDirection (cellRec,DBNetDirN); break;
case DBNetDirNW: netIF->CellDirection (cellRec,DBNull); break;
default: netIF->CellRotate (cellRec,DBForward); break;
}
redraw = true;
}
} break;
default: printf ("Unknown Mode %lX",data->Flags () & DBDataFlagUserModeFlags); break;
}
//.........这里部分代码省略.........
示例4: _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;
}
示例5: _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);
}
示例6: 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);
//.........这里部分代码省略.........