本文整理汇总了C++中DBNetworkIF::DownStreamSearch方法的典型用法代码示例。如果您正苦于以下问题:C++ DBNetworkIF::DownStreamSearch方法的具体用法?C++ DBNetworkIF::DownStreamSearch怎么用?C++ DBNetworkIF::DownStreamSearch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBNetworkIF
的用法示例。
在下文中一共展示了DBNetworkIF::DownStreamSearch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _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;
}
//.........这里部分代码省略.........
示例2: 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;
}
}
//.........这里部分代码省略.........
示例3: main
int main (int argc,char *argv [])
{
int argPos, argNum = argc, ret;
bool upStream = true;
DBCoordinate coord;
DBObjData *data;
for (argPos = 1;argPos < argNum; ) {
if (CMargTest (argv [argPos],"-c","--coordinates")) {
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing sampling coordinates!"); return (CMfailed); }
if (sscanf (argv [argPos],"%lf,%lf", &(coord.X),&(coord.Y)) != 2)
{ CMmsgPrint (CMmsgUsrError,"Invalid sampling coordinates!"); return (CMfailed); }
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest(argv[argPos],"-d","--direction")) {
if ((argNum = CMargShiftLeft(argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError, "Missing aggregate method!"); return (CMfailed); }
else {
const char *options [] = { "upstream", "downstream", (char *) NULL };
if ((ret = CMoptLookup (options,argv [argPos],false)) == CMfailed) {
CMmsgPrint (CMmsgWarning,"Ignoring illformed direction [%s]!",argv [argPos]);
}
else upStream = ret == 0 ? true : false;
}
if ((argNum = CMargShiftLeft(argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help")) {
CMmsgPrint (CMmsgInfo,"%s [options] <input network> <output list>",CMfileName(argv[0]));
CMmsgPrint (CMmsgInfo," -c,--coordinates");
CMmsgPrint (CMmsgInfo," -d,--direction [upstream|downstream]");
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 > 2) { CMmsgPrint (CMmsgUsrError,"Extra arguments!"); return (CMfailed); }
data = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? data->Read (argv [1]) : data->Read (stdin);
if (data->Type () == DBTypeNetwork) {
DBNetworkIF *netIF = new DBNetworkIF (data);
DBObjRecord *cellRec = netIF->Cell (coord);
if (upStream) netIF->UpStreamSearch (cellRec,_CMDnetCellSearchPrintID);
else netIF->DownStreamSearch (cellRec,_CMDnetCellSearchPrintID);
delete netIF;
}
delete data;
return (ret);
}