当前位置: 首页>>代码示例>>C++>>正文


C++ DBNetworkIF::UpStreamSearch方法代码示例

本文整理汇总了C++中DBNetworkIF::UpStreamSearch方法的典型用法代码示例。如果您正苦于以下问题:C++ DBNetworkIF::UpStreamSearch方法的具体用法?C++ DBNetworkIF::UpStreamSearch怎么用?C++ DBNetworkIF::UpStreamSearch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBNetworkIF的用法示例。


在下文中一共展示了DBNetworkIF::UpStreamSearch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:48,代码来源:RGlibPoint.C

示例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;
				}
			}
//.........这里部分代码省略.........
开发者ID:amiara,项目名称:RGIS,代码行数:101,代码来源:RGISAnNetStreams.C

示例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;
		}
//.........这里部分代码省略.........
开发者ID:bandi13,项目名称:RGIS,代码行数:101,代码来源:RGISUsrFuncNet.C

示例4: 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);
}
开发者ID:bandi13,项目名称:RGIS,代码行数:61,代码来源:CMDnetCellSearch.C

示例5: RGlibPointSTNCharacteristics


//.........这里部分代码省略.........
            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);
        }
        else {
            cellIDFLD->Int(pointRec, cellRec->RowID() + 1);
            basinRec = netIF->Basin(cellRec);
            basinFLD->Int(pointRec, basinRec->RowID() + 1);
            basinNameFLD->String(pointRec, basinRec->Name());
            orderFLD->Int(pointRec, netIF->CellOrder(cellRec));
            colorFLD->Int(pointRec, 0);
            basinCellsFLD->Int(pointRec, netIF->CellBasinCells(cellRec));
            basinLengthFLD->Float(pointRec, netIF->CellBasinLength(cellRec));
            basinAreaFLD->Float(pointRec, netIF->CellBasinArea(cellRec));
            interAreaFLD->Float(pointRec, netIF->CellBasinArea(cellRec));
        }
        nextStationFLD->Int(pointRec, 0);
    }
    for (cellID = 0; cellID < cellTable->ItemNum(); ++cellID) {
        if (DBPause(20 + cellID * 20 / cellTable->ItemNum())) goto Stop;
        cellRec = cellTable->Item(cellID);
        _RGlibTEMPPointIDFLD->Int(cellRec, DBFault);
    }
    pointTable->ListSort(basinAreaFLD);
    for (pointRec = pointTable->Last(); pointRec != (DBObjRecord *) NULL; pointRec = pointTable->Next(DBBackward)) {
        if ((pointRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
        if (DBPause(40 + pointID * 20 / pointTable->ItemNum())) goto Stop;
        cellRec = netIF->Cell(pntIF->Coordinate(pointRec));
        netIF->UpStreamSearch(cellRec, (DBNetworkACTION) _RGlibSetPointID,
                              (void *) ((char *) NULL + pointRec->RowID()));
    }
    for (pointID = 0; pointID < pointTable->ItemNum(); pointID++) {
        pointRec = pointTable->Item(pointID);
        if ((pointRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
        if (DBPause(60 + pointID * 20 / pointTable->ItemNum())) goto Stop;
        if ((cellRec = netIF->Cell(pntIF->Coordinate(pointRec))) != (DBObjRecord *) NULL) {
            if ((cellRec = netIF->ToCell(cellRec)) == (DBObjRecord *) NULL) continue;
            if ((dPointID = _RGlibTEMPPointIDFLD->Int(cellRec)) != DBFault) {
                dPointRec = pointTable->Item(dPointID);
                nextStationFLD->Int(pointRec, dPointRec->RowID() + 1);
                interAreaFLD->Float(dPointRec, interAreaFLD->Float(dPointRec) - basinAreaFLD->Float(pointRec));
            }
        }
    }
    pointTable->ListSort(interAreaFLD);

    i = 0;
    for (pointRec = pointTable->Last(); pointRec != (DBObjRecord *) NULL; pointRec = pointTable->Next(DBBackward)) {
        if (DBPause(80 + (i++) * 20 / pointTable->ItemNum())) goto Stop;
        pointID = pointRec->RowID();
        if ((pointRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;

        if ((basinID = basinFLD->Int(pointRec)) == 0) continue;
        cellRec = netIF->Cell(pntIF->Coordinate(pointRec));
        mouthID = cellRec->RowID();
        color = 1;
        Start:
        for (cellID = mouthID; cellID < cellTable->ItemNum(); ++cellID) {
            cellRec = cellTable->Item(cellID);
            if (netIF->CellBasinID(cellRec) != basinID) break;
            if (_RGlibTEMPPointIDFLD->Int(cellRec) != pointID) continue;

            for (dir = 0; dir < 8; ++dir) {
                if ((fromCell = netIF->FromCell(cellRec, 0x01 << dir, false)) == (DBObjRecord *) NULL) continue;
                if ((dPointID = _RGlibTEMPPointIDFLD->Int(fromCell)) == pointID) continue;
                if (dPointID == DBFault) continue;

                dPointRec = pointTable->Item(dPointID);
                if (colorFLD->Int(dPointRec) == color) {
                    color++;
                    goto Start;
                }
            }
        }
        colorFLD->Int(pointRec, color);
    }
    ret = DBSuccess;
    Stop:
    pointTable->ListSort();
    cellTable->DeleteField(_RGlibTEMPPointIDFLD);
    delete pntIF;
    delete netIF;
    return (ret);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:101,代码来源:RGlibPoint.C

示例6: 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);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:89,代码来源:RGlibPoint.C

示例7: 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);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:91,代码来源:RGlibPoint.C


注:本文中的DBNetworkIF::UpStreamSearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。