本文整理汇总了C++中DBNetworkIF::Cell方法的典型用法代码示例。如果您正苦于以下问题:C++ DBNetworkIF::Cell方法的具体用法?C++ DBNetworkIF::Cell怎么用?C++ DBNetworkIF::Cell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBNetworkIF
的用法示例。
在下文中一共展示了DBNetworkIF::Cell方法的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: 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);
}
示例3: 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);
}
}
示例4: RGISEditNetAddCellXYCBK
void RGISEditNetAddCellXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt cellID;
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBNetworkIF *netIF = new DBNetworkIF (dbData);
DBObjTable *cellTable = dbData->Table (DBrNCells);
DBObjTableField *xCoordFLD = cellTable->Field (RGISNetCellXCoord);
DBObjTableField *yCoordFLD = cellTable->Field (RGISNetCellYCoord);
DBCoordinate coord;
DBObjRecord *cellRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,cellTable));
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISNetCellXCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
cellTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISNetCellYCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
cellTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (cellID = 0;cellID < netIF->CellNum ();++cellID)
{
cellRec = netIF->Cell (cellID);
if (UIPause (80 + cellID * 20 / netIF->CellNum ())) goto Stop;
coord = netIF->Center (cellRec);
xCoordFLD->Float (cellRec,coord.X);
yCoordFLD->Float (cellRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例5: SelectObject
DBInt DBObjData::SelectObject(DBObjRecord *record, DBInt select) {
DBObjTable *items = TablesPTR->Item(DBrNItems);
if (record == (DBObjRecord *) NULL) return (false);
if (items->Item(record->RowID()) != record) return (false);
record->Flags(DBObjectFlagSelected, select);
if (Type() == DBTypeNetwork) {
DBInt cellID;
DBObjRecord *cellRec;
DBNetworkIF *netIF = new DBNetworkIF(this);
for (cellID = 0; cellID < netIF->CellNum(); ++cellID) {
cellRec = netIF->Cell(cellID);
if (netIF->CellBasinID(cellRec) == record->RowID() + 1)
cellRec->Flags(DBObjectFlagSelected, select);
}
delete netIF;
}
return (DBSuccess);
}
示例6: _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))
//.........这里部分代码省略.........
示例7: 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));
//.........这里部分代码省略.........
示例8: _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);
}
示例9: _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;
}
//.........这里部分代码省略.........
示例10: 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);
}
示例11: 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);
//.........这里部分代码省略.........
示例12: 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);
}
示例13: 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);
}
示例14: RGISEditAdjustNetworkCBK
void RGISEditAdjustNetworkCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt vertex, vertexNum, dir, cell, cellNum, maxCellNum = 0;
DBPosition pos0, pos1;
DBCoordinate *vertexes;
DBObjRecord *lineRec, **cellList = (DBObjRecord **) NULL;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBObjData *lineData = netData->LinkedData ();
DBNetworkIF *netIF = new DBNetworkIF (netData);
DBVLineIF *lineIF = new DBVLineIF (lineData);
UIPauseDialogOpen ((char *) "Adjusting Networks");
cellNum = 0;
for (lineRec = lineIF->FirstItem ();lineRec != (DBObjRecord *) NULL; lineRec = lineIF->NextItem ())
{
UIPause (lineRec->RowID () * 100 / lineIF->ItemNum ());
if (lineIF->ToNode (lineRec) == lineIF->FromNode (lineRec)) continue;
if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
if ((cellList [cellNum] = netIF->Cell (lineIF->FromCoord (lineRec))) == (DBObjRecord *) NULL)
if((cellList [cellNum] = netIF->CellAdd (lineIF->FromCoord (lineRec))) != (DBObjRecord *) NULL) cellNum++;
if ((vertexNum = lineIF->VertexNum (lineRec)) > 0)
{
vertexes = lineIF->Vertexes (lineRec);
for (vertex = 0; vertex < vertexNum; ++vertex)
{
if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
if ((cellList [cellNum] = netIF->Cell (vertexes [vertex])) == (DBObjRecord *) NULL)
if((cellList [cellNum] = netIF->CellAdd (vertexes [vertex])) == (DBObjRecord *) NULL) continue;
for (cell = 0;cell < cellNum;++cell) if (cellList [cell] == cellList [cellNum]) break;
if (cell != cellNum) continue;
cellNum++;
/* if (cellNum > 1)
{
pos0 = netIF->CellPosition (cellList [cellNum - 2]);
pos1 = netIF->CellPosition (cellList [cellNum - 1]);
printf ("%5d %3d %3d %3d %3d\n",lineRec->RowID (),pos0.Col, pos0.Row, pos1.Col, pos1.Row);
if ((abs (pos0.Row - pos1.Row) <= 1) && (abs (pos0.Col - pos1.Col) <= 1)) continue;
if (abs (pos0.Row - pos1.Row) > abs (pos0.Col - pos1.Col))
for (pos.Row = pos0.Row; pos.Row != pos1.Row;
pos.Row = (pos0.Row < pos1.Row) ? pos.Row + 1 : pos.Row - 1)
{
pos.Col = pos0.Col + (DBUShort) ((((DBInt) pos.Row - (DBInt) pos0.Row) * ((DBInt) pos1.Col - (DBInt) pos0.Col)) / ((DBInt) pos1.Row - (DBInt) pos0.Row));
if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
if ((cellRec = netIF->Cell (pos)) != (DBObjRecord *) NULL)
{
cellList [cellNum] = cellList [cellNum - 1];
cellList [cellNum - 1] = cellRec;
cellNum++;
}
}
else
for (pos.Col = pos0.Col; pos.Col != pos1.Col;
pos.Col = (pos0.Col < pos1.Col) ? pos.Col + 1 : pos.Col - 1)
{
pos.Row = pos0.Row + (DBUShort) ((((DBInt) pos.Col - (DBInt) pos0.Col) * ((DBInt) pos1.Row - (DBInt) pos0.Row)) / ((DBInt) pos1.Col - (DBInt) pos0.Col));
if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
if ((cellRec = netIF->Cell (pos)) != (DBObjRecord *) NULL)
{
cellList [cellNum] = cellList [cellNum - 1];
cellList [cellNum - 1] = cellRec;
cellNum++;
}
}
}
*/ }
}
for (cell = 0;cell < cellNum - 1;++cell)
{
pos0 = netIF->CellPosition (cellList [cell]);
pos1 = netIF->CellPosition (cellList [cell + 1]);
if ((pos0.Col < pos1.Col) && (pos0.Row == pos1.Row)) dir = DBNetDirE;
else if ((pos0.Col < pos1.Col) && (pos0.Row > pos1.Row)) dir = DBNetDirSE;
else if ((pos0.Col == pos1.Col) && (pos0.Row > pos1.Row)) dir = DBNetDirS;
else if ((pos0.Col > pos1.Col) && (pos0.Row > pos1.Row)) dir = DBNetDirSW;
else if ((pos0.Col > pos1.Col) && (pos0.Row == pos1.Row)) dir = DBNetDirW;
else if ((pos0.Col > pos1.Col) && (pos0.Row < pos1.Row)) dir = DBNetDirNW;
else if ((pos0.Col == pos1.Col) && (pos0.Row < pos1.Row)) dir = DBNetDirN;
else if ((pos0.Col < pos1.Col) && (pos0.Row < pos1.Row)) dir = DBNetDirNE;
// printf ("%5d %3d %3d %3d %3d %2x\n",lineRec->RowID (),pos0.Col, pos0.Row, pos1.Col, pos1.Row,dir);
netIF->CellDirection (cellList [cell],dir);
}
}
if (maxCellNum > 0) free (cellList);
UIPauseDialogClose ();
UIPauseDialogOpen ((char *) "Building Networks");
// netIF->Build ();
UIPauseDialogClose ();
}
示例15: 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)
//.........这里部分代码省略.........