本文整理匯總了C++中DBNetworkIF::Center方法的典型用法代碼示例。如果您正苦於以下問題:C++ DBNetworkIF::Center方法的具體用法?C++ DBNetworkIF::Center怎麽用?C++ DBNetworkIF::Center使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBNetworkIF
的用法示例。
在下文中一共展示了DBNetworkIF::Center方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: RGlibPointSTNCoordinates
DBInt RGlibPointSTNCoordinates(DBObjData *dbData, DBObjTableField *field) {
DBInt pointID, ret = DBFault;
DBCoordinate coord;
DBPosition pos;
DBObjData *linkedData = dbData->LinkedData();
DBVPointIF *pntIF;
DBNetworkIF *netIF;
DBObjRecord *pntRec, *cellRec;
if (linkedData == (DBObjData *) NULL) return (DBFault);
pntIF = new DBVPointIF(dbData);
netIF = new DBNetworkIF(linkedData);
for (pointID = 0; pointID < pntIF->ItemNum(); ++pointID) {
pntRec = pntIF->Item(pointID);
if (DBPause(pointID * 100 / pntIF->ItemNum())) goto Stop;
if ((pntRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
coord = pntIF->Coordinate(pntRec);
if (netIF->Coord2Pos(coord, pos) == DBFault) continue;
netIF->Pos2Coord(pos, coord);
if ((field != (DBObjTableField *) NULL) &&
(!CMmathEqualValues(field->Float(pntRec), field->FloatNoData())) &&
((cellRec = netIF->Cell(coord, field->Float(pntRec))) != (DBObjRecord *) NULL))
coord = netIF->Center(cellRec);
pntIF->Coordinate(pntRec, coord);
}
ret = DBSuccess;
Stop:
delete netIF;
delete pntIF;
return (ret);
}
示例2: _RGlibSubbasinCategories
static DBInt _RGlibSubbasinCategories(void *io, DBObjRecord *cellRec) {
DBObjRecord *grdRec;
DBNetworkIF *netIF = (DBNetworkIF *) io;
if (cellRec == (DBObjRecord *) NULL) return (false);
grdRec = _RGlibPointGrdIF->GridItem(_RGlibPointGrdLayerRec, netIF->Center(cellRec));
if (grdRec == (DBObjRecord *) NULL) return (true);
_RGlibHistogram[grdRec->RowID()].cellNum++;
_RGlibHistogram[grdRec->RowID()].area += netIF->CellArea(cellRec);
return (true);
}
示例3: _RGlibSubbasinStatistics
static DBInt _RGlibSubbasinStatistics(void *io, DBObjRecord *cellRec) {
DBFloat value;
DBNetworkIF *netIF = (DBNetworkIF *) io;
if (cellRec == (DBObjRecord *) NULL) return (false);
if (_RGlibPointGrdIF->Value(_RGlibPointGrdLayerRec, netIF->Center(cellRec), &value) == false) return (true);
_RGlibSubbasinArea = _RGlibSubbasinArea + netIF->CellArea(cellRec);
_RGlibSubbasinMean = _RGlibSubbasinMean + value * netIF->CellArea(cellRec);
_RGlibSubbasinMin = _RGlibSubbasinMin < value ? _RGlibSubbasinMin : value;
_RGlibSubbasinMax = _RGlibSubbasinMax > value ? _RGlibSubbasinMax : value;
_RGlibSubbasinStdDev = _RGlibSubbasinStdDev + value * value * netIF->CellArea(cellRec);
return (true);
}
示例4: 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);
}
示例5: 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);
}
}
示例6: 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 ();
}
示例7: main
//.........這裏部分代碼省略.........
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));
fieldY = new DBObjTableField (fieldYName, DBTableFieldFloat, (char *) "%10.3f", sizeof (DBFloat4));
table->AddField(fieldID);
table->AddField(fieldX);
table->AddField(fieldY);
if (strcmp(fieldIDName, "CellID") == 0) {
for (recID = 0; recID < table->ItemNum(); ++recID) {
record = netIF->Cell(recID);
coord = netIF->Center(record);
fieldID->Int(record, recID+1);
fieldX->Float(record, coord.X);
fieldY->Float(record, coord.Y);
}
} else if (strcmp(fieldIDName, "BasinID") == 0) {
for (recID = 0; recID < netIF->BasinNum(); ++recID) {
record = netIF->Basin(recID);
coord = netIF->Center(netIF->MouthCell(record));
fieldID->Int(record, recID+1);
fieldX->Float(record,coord.X);
fieldY->Float(record,coord.Y);
}
} else {
CMmsgPrint(CMmsgUsrError, "Invalid field name: %s!", fieldIDName);
delete data;
return (CMfailed);
}
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);
delete data;
if (verbose) RGlibPauseClose();
return (ret);
}
示例8: 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;
}
}
//.........這裏部分代碼省略.........
示例9: _CMDnetErosion
int _CMDnetErosion(DBObjData *netData, DBObjData *inData, DBObjData *weightData,
DBObjData *outData, DBFloat coeff, DBInt areaMult) {
DBInt ret = DBSuccess, layerID, cellID, progress, maxProgress;
DBFloat inValue, weight, outValue, *sumWeights;
DBPosition pos;
DBNetworkIF *netIF = new DBNetworkIF(netData);
DBGridIF *inIF = new DBGridIF(inData);
DBGridIF *outIF = new DBGridIF(outData);
DBGridIF *weightIF = weightData != (DBObjData *) NULL ? new DBGridIF(weightData) : (DBGridIF *) NULL;
DBObjRecord *inLayerRec, *outLayerRec, *weightLayerRec, *cellRec, *toCell;
if ((sumWeights = (DBFloat *) calloc(netIF->CellNum(), sizeof(DBFloat))) == (DBFloat *) NULL) {
CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
ret = DBFault;
goto Stop;
}
layerID = 0;
inLayerRec = inIF->Layer(layerID);
outLayerRec = outIF->Layer(layerID);
outIF->RenameLayer(outLayerRec, inLayerRec->Name());
outValue = outIF->MissingValue(outLayerRec);
for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);
for (layerID = 1; layerID < inIF->LayerNum(); ++layerID) {
inLayerRec = inIF->Layer(layerID);
if ((outLayerRec = outIF->AddLayer(inLayerRec->Name())) == (DBObjRecord *) NULL) {
ret = DBFault;
goto Stop;
}
for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);
}
maxProgress = inIF->LayerNum() * netIF->CellNum();
for (layerID = 0; layerID < inIF->LayerNum(); ++layerID) {
inLayerRec = inIF->Layer(layerID);
outLayerRec = outIF->Layer(layerID);
if (weightIF != (DBGridIF *) NULL)
weightLayerRec = weightIF->Layer(layerID % weightIF->LayerNum());
for (cellID = 0; cellID < netIF->CellNum(); cellID++) {
sumWeights[cellID] = 0.0;
cellRec = netIF->Cell(cellID);
if (inIF->Value(inLayerRec, netIF->Center(cellRec), &inValue) == false)
outIF->Value(outLayerRec, netIF->CellPosition(cellRec), 0.0);
else {
if (weightIF != (DBGridIF *) NULL)
weight = weightIF->Value(weightLayerRec, netIF->Center(cellRec), &weight) == false ?
0.0 : weight * coeff;
else weight = coeff;
if (areaMult) weight = weight * netIF->CellArea(cellRec);
sumWeights[cellID] = weight;
outIF->Value(outLayerRec, netIF->CellPosition(cellRec), inValue * weight);
}
}
for (cellID = netIF->CellNum() - 1; cellID >= 0; --cellID) {
progress = layerID * netIF->CellNum() + (netIF->CellNum() - cellID);
if (DBPause(progress * 100 / maxProgress)) goto Stop;
cellRec = netIF->Cell(cellID);
if ((toCell = netIF->ToCell(cellRec)) == (DBObjRecord *) NULL) continue;
if (outIF->Value(outLayerRec, netIF->CellPosition(cellRec), &inValue) == false) continue;
if (outIF->Value(outLayerRec, netIF->CellPosition(toCell), &outValue) == false) continue;
sumWeights[toCell->RowID()] = sumWeights[toCell->RowID()] + weight;
outIF->Value(outLayerRec, netIF->CellPosition(toCell), outValue + inValue);
}
outIF->RecalcStats(outLayerRec);
}
free(sumWeights);
Stop:
delete netIF;
delete inIF;
delete outIF;
if (weightIF != (DBGridIF *) NULL) delete weightIF;
return (ret);
}
示例10: _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;
}
//.........這裏部分代碼省略.........
示例11: _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;
}
示例12: _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);
}
示例13: main
int main (int argc,char *argv [])
{
FILE *outFile;
DBInt argPos, argNum = argc, ret;
int objID, size;
DBFloat lCorrection = 1.0;
MFDomain_t *domain = (MFDomain_t *) NULL;
DBCoordinate coord;
DBObjRecord *objRec;
DBObjData *data;
for (argPos = 1;argPos < argNum; )
{
if (CMargTest (argv [argPos],"-l","--lengthcorrection"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing length correction!"); return (CMfailed); }
if (sscanf (argv [argPos],"%lf", &lCorrection) != 1)
{ CMmsgPrint (CMmsgUsrError, "Invalid length correction!"); return (CMfailed); }
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
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)
//.........這裏部分代碼省略.........
示例14: _CMDnetTransfer
int _CMDnetTransfer(DBObjData *netData,
DBObjData *inData,
DBObjData *weightData,
DBObjData *outData,
DBFloat coeff,
DBObjData *coeffData,
DBObjData *QData,
DBObjData *HLData,
DBFloat umax,
DBFloat ksat,
DBInt areaMult) {
DBInt ret = DBSuccess, layerID, cellID, progress, maxProgress;
DBFloat inValue, weight, outValue, *sumWeights, kCoeff, q, hl, Conc, Uptake, Vf;
DBPosition pos;
DBNetworkIF *netIF = new DBNetworkIF(netData);
DBGridIF *inIF = new DBGridIF(inData);
DBGridIF *outIF = new DBGridIF(outData);
DBGridIF *weightIF = weightData != (DBObjData *) NULL ? new DBGridIF(weightData) : (DBGridIF *) NULL;
DBGridIF *coeffIF = coeffData != (DBObjData *) NULL ? new DBGridIF(coeffData) : (DBGridIF *) NULL;
DBGridIF *Q_IF = QData != (DBObjData *) NULL ? new DBGridIF(QData) : (DBGridIF *) NULL;
DBGridIF *HL_IF = HLData != (DBObjData *) NULL ? new DBGridIF(HLData) : (DBGridIF *) NULL;
DBObjRecord *inLayerRec, *outLayerRec, *weightLayerRec, *coeffLayerRec, *Q_LayerRec, *HL_LayerRec, *cellRec, *toCell;
DBCoordinate coord;
if ((sumWeights = (DBFloat *) calloc(netIF->CellNum(), sizeof(DBFloat))) == (DBFloat *) NULL) {
CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
ret = DBFault;
goto Stop;
}
layerID = 0;
inLayerRec = inIF->Layer(layerID);
outLayerRec = outIF->Layer(layerID);
outIF->RenameLayer(outLayerRec, inLayerRec->Name());
outValue = outIF->MissingValue(outLayerRec);
for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);
for (layerID = 1; layerID < inIF->LayerNum(); ++layerID) {
inLayerRec = inIF->Layer(layerID);
if ((outLayerRec = outIF->AddLayer(inLayerRec->Name())) == (DBObjRecord *) NULL) {
ret = DBFault;
goto Stop;
}
for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);
}
maxProgress = inIF->LayerNum() * netIF->CellNum();
for (layerID = 0; layerID < inIF->LayerNum(); ++layerID) {
inLayerRec = inIF->Layer(layerID);
outLayerRec = outIF->Layer(layerID);
if (weightIF != (DBGridIF *) NULL)
weightLayerRec = weightIF->Layer(layerID % weightIF->LayerNum());
if (coeffIF != (DBGridIF *) NULL)
coeffLayerRec = coeffIF->Layer(layerID % coeffIF->LayerNum());
if (Q_IF != (DBGridIF *) NULL)
Q_LayerRec = Q_IF->Layer(layerID % Q_IF->LayerNum());
if (HL_IF != (DBGridIF *) NULL)
HL_LayerRec = HL_IF->Layer(layerID % HL_IF->LayerNum());
for (cellID = 0; cellID < netIF->CellNum(); cellID++) {
sumWeights[cellID] = 0.0;
cellRec = netIF->Cell(cellID);
coord = netIF->Center(cellRec);
if (inIF->Value(inLayerRec, coord, &inValue) == false)
outIF->Value(outLayerRec, netIF->CellPosition(cellRec), 0.0);
else {
if (weightIF != (DBGridIF *) NULL)
weight = weightIF->Value(weightLayerRec, coord, &weight) == false ?
0.0 : weight * coeff;
else weight = coeff;
if (areaMult) weight = weight * netIF->CellArea(cellRec);
sumWeights[cellID] = weight;
outIF->Value(outLayerRec, netIF->CellPosition(cellRec), inValue * weight);
}
}
for (cellID = netIF->CellNum() - 1; cellID >= 0; --cellID) {
progress = layerID * netIF->CellNum() + (netIF->CellNum() - cellID);
if (DBPause(progress * 100 / maxProgress)) goto Stop;
cellRec = netIF->Cell(cellID);
coord = netIF->Center(cellRec);
if ((toCell = netIF->ToCell(cellRec)) == (DBObjRecord *) NULL) continue;
if (outIF->Value(outLayerRec, netIF->CellPosition(cellRec), &inValue) == false) continue;
if (outIF->Value(outLayerRec, netIF->CellPosition(toCell), &outValue) == false) continue;
sumWeights[toCell->RowID()] = sumWeights[toCell->RowID()] + weight;
if (coeffIF != (DBGridIF *) NULL) {
if (coeffIF->Value(coeffLayerRec, netIF->Center(cellRec), &kCoeff) == false) kCoeff = 1.0;
}
else {
if (((Q_IF == (DBGridIF *) NULL) || (Q_IF->Value(Q_LayerRec, netIF->Center(cellRec), &q) == false)) ||
((HL_IF == (DBGridIF *) NULL) ||
(HL_IF->Value(HL_LayerRec, netIF->Center(cellRec), &hl) == false)) ||
(umax == 0) || (ksat == 0))
//.........這裏部分代碼省略.........
示例15: 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;
}