本文整理汇总了C++中DBGridIF::MissingValue方法的典型用法代码示例。如果您正苦于以下问题:C++ DBGridIF::MissingValue方法的具体用法?C++ DBGridIF::MissingValue怎么用?C++ DBGridIF::MissingValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBGridIF
的用法示例。
在下文中一共展示了DBGridIF::MissingValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _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);
}
示例2: DBGridOperation
void DBGridOperation(DBObjData *leftGrd, DBObjData *rightGrd, DBInt oper, DBInt mergeMissingVal) {
DBInt leftID, rightID;
DBFloat leftVal, rightVal;
DBPosition pos;
DBCoordinate coord;
DBObjRecord *leftRec, *rightRec;
DBGridIF *leftIF = new DBGridIF(leftGrd);
DBGridIF *rightIF = new DBGridIF(rightGrd);
for (leftID = 0; leftID < leftIF->LayerNum(); ++leftID) {
leftRec = leftIF->Layer(leftID);
if ((leftRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) break;
}
if (leftID == leftIF->LayerNum()) {
CMmsgPrint(CMmsgAppError, "No Layer to Process in %s %d", __FILE__, __LINE__);
return;
}
for (rightID = 0; rightID < rightIF->LayerNum(); ++rightID) {
rightRec = rightIF->Layer(rightID);
if ((rightRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) break;
}
if (rightID == rightIF->LayerNum()) {
CMmsgPrint(CMmsgAppError, "No Layer to Process in %s %d", __FILE__, __LINE__);
return;
}
rightID = (DBInt) 0;
for (leftID = 0; leftID < leftIF->LayerNum(); ++leftID) {
leftRec = leftIF->Layer(leftID);
while ((leftRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) {
++leftID;
if (leftID == leftIF->LayerNum()) goto Stop;
leftRec = leftIF->Layer(leftID);
}
if ((rightRec = rightIF->Layer(rightID)) == (DBObjRecord *) NULL) {
rightID = 0;
rightRec = rightIF->Layer(rightID);
}
while ((rightRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) {
++rightID;
if (rightID == rightIF->LayerNum()) rightID = 0;
rightRec = rightIF->Layer(rightID);
}
for (pos.Row = 0; pos.Row < leftIF->RowNum(); pos.Row++) {
if (DBPause((leftID * leftIF->RowNum() + pos.Row) * 100 / (leftIF->LayerNum() * leftIF->RowNum())))
goto Stop;
for (pos.Col = 0; pos.Col < leftIF->ColNum(); pos.Col++) {
leftIF->Pos2Coord(pos, coord);
if (leftIF->Value(leftRec, pos, &leftVal)) {
if (rightIF->Value(rightRec, coord, &rightVal))
switch (oper) {
case DBMathOperatorAdd:
leftIF->Value(leftRec, pos, leftVal + rightVal);
break;
case DBMathOperatorSub:
leftIF->Value(leftRec, pos, leftVal - rightVal);
break;
case DBMathOperatorMul:
leftIF->Value(leftRec, pos, leftVal * rightVal);
break;
case DBMathOperatorDiv:
if (fabs(rightVal) > 0.000001) leftIF->Value(leftRec, pos, leftVal / rightVal);
else leftIF->Value(leftRec, pos, leftIF->MissingValue());
break;
}
else if (mergeMissingVal) leftIF->Value(leftRec, pos, leftIF->MissingValue());
}
}
}
++rightID;
leftIF->RecalcStats(leftRec);
}
Stop:
return;
}
示例3: RGlibDataStream2RGIS
//.........这里部分代码省略.........
case MFDouble:
valField->Float(record, ((double *) data)[itemID]);
break;
}
}
}
delete pntIF;
}
break;
case DBTypeGridContinuous:
case DBTypeGridDiscrete: {
DBGridIF *gridIF = new DBGridIF(outData);
while (MFVarReadHeader(&header, inFile)) {
if (header.ItemNum != gridIF->RowNum() * gridIF->ColNum()) {
CMmsgPrint(CMmsgUsrError, "Error: Datastream inconsistency!");
return (DBFault);
}
if (layerID == 0) {
itemSize = MFVarItemSize(header.DataType);
if ((data = (void *) realloc(data, header.ItemNum * itemSize)) == (void *) NULL) {
CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
record = gridIF->Layer(layerID);
gridIF->RenameLayer(header.Date);
}
else record = gridIF->AddLayer(header.Date);
switch (header.DataType) {
case MFByte:
case MFShort:
case MFInt:
gridIF->MissingValue(record, header.Missing.Int);
break;
case MFFloat:
case MFDouble:
gridIF->MissingValue(record, header.Missing.Float);
break;
}
if ((int) fread(data, itemSize, header.ItemNum, inFile) != header.ItemNum) {
CMmsgPrint(CMmsgSysError, "Error: Data stream read in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
for (pos.Row = 0; pos.Row < gridIF->RowNum(); ++pos.Row)
for (pos.Col = 0; pos.Col < gridIF->ColNum(); ++pos.Col) {
switch (header.DataType) {
case MFByte:
val = (DBFloat) (((char *) data)[pos.Row * gridIF->ColNum() + pos.Col]);
break;
case MFShort:
val = (DBFloat) (((short *) data)[pos.Row * gridIF->ColNum() + pos.Col]);
break;
case MFInt:
val = (DBFloat) (((int *) data)[pos.Row * gridIF->ColNum() + pos.Col]);
break;
case MFFloat:
val = (DBFloat) (((float *) data)[pos.Row * gridIF->ColNum() + pos.Col]);
break;
case MFDouble:
val = (DBFloat) (((double *) data)[pos.Row * gridIF->ColNum() + pos.Col]);
break;
}
gridIF->Value(record, pos, val);
}
示例4: RGlibRGIS2DataStream
DBInt RGlibRGIS2DataStream(DBObjData *grdData, DBObjData *tmplData, char *fieldName, FILE *outFile) {
DBInt layerID, ret = DBSuccess, itemSize, itemID;
DBInt intValue;
DBFloat floatValue;
void *data;
MFVarHeader_t varHeader;
DBObjRecord *layerRec, *gridRec;
DBObjTableField *fieldPTR = (DBObjTableField *) NULL;
DBGridIF *gridIF;
DBVPointIF *tmplPntIF = (DBVPointIF *) NULL;
DBGridIF *tmplGrdIF = (DBGridIF *) NULL;
DBNetworkIF *tmplNetIF = (DBNetworkIF *) NULL;
gridIF = new DBGridIF(grdData);
varHeader.Swap = 1;
if (grdData->Type() == DBTypeGridDiscrete) {
DBObjTable *itemTable = grdData->Table(DBrNItems);
if (fieldName == (char *) NULL) fieldName = DBrNGridValue;
if ((fieldPTR = itemTable->Field(fieldName)) == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgAppError, "Error: Invalid field [%s] in: %s %d", fieldName, __FILE__, __LINE__);
return (DBFault);
}
itemSize = fieldPTR->Length();
switch (fieldPTR->Type()) {
case DBTableFieldInt:
switch (itemSize) {
default:
case sizeof(DBByte):
varHeader.DataType = MFByte;
break;
case sizeof(DBShort):
varHeader.DataType = MFShort;
break;
case sizeof(DBInt):
varHeader.DataType = MFInt;
break;
}
varHeader.Missing.Int = fieldPTR->IntNoData();
break;
case DBTableFieldFloat:
switch (itemSize) {
default:
case sizeof(DBFloat4):
varHeader.DataType = MFFloat;
break;
case sizeof(DBFloat):
varHeader.DataType = MFDouble;
break;
}
varHeader.Missing.Float = fieldPTR->FloatNoData();
break;
}
}
else {
if (fieldName != (char *) NULL) CMmsgPrint(CMmsgUsrError, "Warning: Fieldname ignored for continuous grid!");
itemSize = gridIF->ValueSize();
switch (gridIF->ValueType()) {
case DBVariableInt:
switch (itemSize) {
case 1:
varHeader.DataType = MFByte;
break;
case 2:
varHeader.DataType = MFShort;
break;
case 4:
varHeader.DataType = MFInt;
break;
}
varHeader.Missing.Int = (int) gridIF->MissingValue();
break;
case DBVariableFloat:
switch (itemSize) {
case 4:
varHeader.DataType = MFFloat;
break;
case 8:
varHeader.DataType = MFDouble;
break;
}
varHeader.Missing.Float = gridIF->MissingValue();
break;
}
}
if (tmplData == (DBObjData *) NULL) {
tmplGrdIF = gridIF;
varHeader.ItemNum = gridIF->RowNum() * gridIF->ColNum();
}
else {
switch (tmplData->Type()) {
case DBTypeVectorPoint:
tmplPntIF = new DBVPointIF(tmplData);
varHeader.ItemNum = tmplPntIF->ItemNum();
break;
case DBTypeGridContinuous:
case DBTypeGridDiscrete:
tmplGrdIF = new DBGridIF(tmplData);
//.........这里部分代码省略.........
示例5: _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))
//.........这里部分代码省略.........
示例6: 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;
}