本文整理汇总了C++中DBNetworkIF::FromCell方法的典型用法代码示例。如果您正苦于以下问题:C++ DBNetworkIF::FromCell方法的具体用法?C++ DBNetworkIF::FromCell怎么用?C++ DBNetworkIF::FromCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBNetworkIF
的用法示例。
在下文中一共展示了DBNetworkIF::FromCell方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: main
//.........这里部分代码省略.........
CMmsgPrint (CMmsgInfo,"%s [options] <input rgisdata> <output domain>",CMprgName(argv[0]));
CMmsgPrint (CMmsgInfo," -l,--lengthcorrection");
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); }
outFile = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? fopen (argv [2],"w") : stdout;
if (outFile == (FILE *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Output file Opening error in: %s",CMprgName(argv[0])); exit (DBFault); }
data = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? data->Read (argv [1]) : data->Read (stdin);
if ((domain = (MFDomain_t *) calloc (1,sizeof (MFDomain_t))) != (MFDomain_t *) NULL)
{
domain->Objects = (MFObject_t *) NULL;
switch (data->Type ())
{
case DBTypeVectorPoint:
{
DBVPointIF *pntIF = new DBVPointIF (data);
domain->ObjNum = pntIF->ItemNum ();
if ((domain->Objects = (MFObject_t *) calloc (domain->ObjNum,sizeof (MFObject_t))) == (MFObject_t *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); MFDomainFree (domain); goto Stop; }
for (objID = 0;objID < domain->ObjNum;++objID)
{
objRec = pntIF->Item (objID);
coord = pntIF->Coordinate (objRec);
domain->Objects [objID].ID = objRec->RowID ();
domain->Objects [objID].DLinkNum = 0;
domain->Objects [objID].ULinkNum = 0;
domain->Objects [objID].DLinks = (size_t *) NULL;
domain->Objects [objID].ULinks = (size_t *) NULL;
domain->Objects [objID].XCoord = domain->Objects [objID].Lon = coord.X;
domain->Objects [objID].YCoord = domain->Objects [objID].Lat = coord.Y;
domain->Objects [objID].Area = 0.0;
domain->Objects [objID].Length = 0.0;
}
} break;
case DBTypeGridContinuous:
case DBTypeGridDiscrete:
{
} break;
case DBTypeNetwork:
{
DBInt dir;
DBObjRecord *nextCell;
DBNetworkIF *netIF = new DBNetworkIF (data);
domain->ObjNum = netIF->CellNum ();
if ((domain->Objects = (MFObject_t *) calloc (domain->ObjNum,sizeof (MFObject_t))) == (MFObject_t *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); MFDomainFree (domain); goto Stop; }
for (objID = 0;objID < domain->ObjNum;++objID)
{
domain->Objects [objID].DLinks = (size_t *) NULL;
domain->Objects [objID].ULinks = (size_t *) NULL;
}
for (objID = 0;objID < domain->ObjNum;++objID)
{
objRec = netIF->Cell (objID);
coord = netIF->Center (objRec);
domain->Objects [objID].ID = objRec->RowID ();
domain->Objects [objID].DLinkNum = 0;
domain->Objects [objID].ULinkNum = 0;
domain->Objects [objID].XCoord = domain->Objects [objID].Lon = coord.X;
domain->Objects [objID].YCoord = domain->Objects [objID].Lat = coord.Y;
domain->Objects [objID].Area = netIF->CellArea (objRec);
domain->Objects [objID].Length = netIF->CellLength (objRec) *lCorrection;
if ((nextCell = netIF->ToCell (objRec)) != (DBObjRecord *) NULL)
{
size = (domain->Objects [objID].DLinkNum + 1) * sizeof (size_t);
if ((domain->Objects [objID].DLinks = (size_t *) realloc (domain->Objects [objID].DLinks,size)) == (size_t *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); MFDomainFree (domain); goto Stop; }
domain->Objects [objID].DLinks [domain->Objects [objID].DLinkNum] = nextCell->RowID ();
domain->Objects [objID].DLinkNum++;
}
for (dir = 0;dir < 8;++dir)
if ((nextCell = netIF->FromCell (objRec,0x01 << dir)) != (DBObjRecord *) NULL)
{
size = (domain->Objects [objID].ULinkNum + 1) * sizeof (size_t);
if ((domain->Objects [objID].ULinks = (size_t *) realloc (domain->Objects [objID].ULinks,size)) == (size_t *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); MFDomainFree (domain);goto Stop; }
domain->Objects [objID].ULinks [domain->Objects [objID].ULinkNum] = nextCell->RowID ();
domain->Objects [objID].ULinkNum++;
}
}
} break;
}
ret = MFDomainWrite (domain,outFile);
}
Stop:
if (outFile != stdout) fclose (outFile);
return (ret);
}
示例3: RGISEditGridNetFilterCBK
void RGISEditGridNetFilterCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt layerID, cellID, count, ret, kernel, kernelSize, maxProgress, dir;
DBFloat elev, cellElev, prevElev, upElev [5], meanElev, minElev, dElev;
DBDataset *dataset = UIDataset ();
DBObjData *grdData = dataset->Data ();
DBObjData *netData = grdData->LinkedData ();
DBGridIF *gridIF = new DBGridIF (grdData);
DBNetworkIF *netIF = new DBNetworkIF (netData);
DBObjRecord *cellRec, *fromCell, *nextCell, *layerRec;
UIPauseDialogOpen ((char *) "Network Filtering");
maxProgress = netIF->CellNum () * gridIF->LayerNum ();
for (layerID = 0;layerID < gridIF->LayerNum (); ++layerID)
{
layerRec = gridIF->Layer (layerID);
for (cellID = 0;cellID < netIF->CellNum (); ++cellID)
{
if (UIPause (((layerID + 1) * netIF->CellNum () - cellID) * 100 / maxProgress)) goto Stop;
fromCell = netIF->Cell (cellID);
if (netIF->FromCell (fromCell) != (DBObjRecord *) NULL) continue;
while (gridIF->Value (layerRec,netIF->Center (fromCell),&prevElev) == (DBInt) false)
if ((fromCell = netIF->ToCell (fromCell)) == (DBObjRecord *) NULL) break;
if (fromCell == (DBObjRecord *) NULL) continue;
kernelSize = 0;
for (cellRec = netIF->ToCell (fromCell); (cellRec != (DBObjRecord *) NULL) && (netIF->FromCell (cellRec) == fromCell); cellRec = netIF->ToCell (cellRec))
{
dElev = netIF->CellLength (fromCell) * RGlibMinSLOPE;
if ((ret = gridIF->Value (layerRec,netIF->Center (cellRec),&cellElev)) == false) { count = 0; meanElev = 0.0; }
else { count = 1, meanElev = cellElev; }
if (kernelSize + 1 < (int) (sizeof (upElev) / sizeof (upElev [0]))) kernelSize++;
for (kernel = kernelSize - 1;kernel > 0;--kernel) upElev [kernel] = upElev [kernel - 1]; upElev [0] = prevElev;
for (kernel = 0;kernel < kernelSize;++kernel) { meanElev += upElev [kernel]; count++; }
minElev = prevElev;
for (dir = 0; dir < 8;++dir)
if (((fromCell = netIF->FromCell (cellRec,0x01 << dir,true)) != (DBObjRecord *) NULL) &&
(gridIF->Value (layerRec,netIF->Center (fromCell),&elev) == true) && (minElev > elev))
{ minElev = elev; dElev = netIF->CellLength (fromCell) * RGlibMinSLOPE; }
nextCell = netIF->ToCell (cellRec);
for (kernel = 0;(kernel < kernelSize) && (nextCell != (DBObjRecord *) NULL);++kernel)
{
if(gridIF->Value (layerRec,netIF->Center (nextCell),&elev) != (DBInt) false) { meanElev += elev; count++; }
nextCell = netIF->ToCell (nextCell);
}
if (count > 0)
{
meanElev = meanElev / count;
if (meanElev > minElev - dElev) meanElev = minElev - dElev;
gridIF->Value (layerRec,netIF->Center (cellRec),meanElev);
prevElev = meanElev;
}
else gridIF->Value (layerRec,netIF->Center (cellRec),gridIF->MissingValue ());
fromCell = cellRec;
}
}
gridIF->RecalcStats (layerRec);
}
Stop:
UIPauseDialogClose ();
delete gridIF;
delete netIF;
}