本文整理汇总了C++中DBGridIF::ValueSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DBGridIF::ValueSize方法的具体用法?C++ DBGridIF::ValueSize怎么用?C++ DBGridIF::ValueSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBGridIF
的用法示例。
在下文中一共展示了DBGridIF::ValueSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: Write
DBInt Write (FILE *file,DBObjData *data)
{
char *dmRecord;
DBInt layerID, docLen, dbType, intVal;
DBFloat floatVal;
DBPosition pos;
DBObjRecord *layerRec;
DBGridIF *gridIF = new DBGridIF (data);
DMLayerHeader dmLayerHeader;
dbType = gridIF->ValueType ();
switch (dbType)
{
case DBTableFieldFloat: DataType (DMFloat); break;
case DBTableFieldInt:
DataType (gridIF->ValueSize () > 1 ? DMInt : DMByte); break;
}
CellWidth (gridIF->CellWidth ());
CellHeight (gridIF->CellHeight ());
Extent (data->Extent ());
LayerNum (gridIF->LayerNum ());
RowNum (gridIF->RowNum ());
ColNum (gridIF->ColNum ());
dmRecord = (char *) calloc (RowNum () * ColNum (),DataType () != DMByte ? sizeof (int) : sizeof (char));
if (dmRecord == (char *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
DMFileHeader::Write (file);
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
dmLayerHeader.Description (layerRec->Name ());
dmLayerHeader.Write (file);
}
docLen = strlen (data->Document (DBDocComment));
if (fwrite (&docLen,sizeof (int),1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Writing Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (docLen > 0)
{
if (fwrite (data->Document (DBDocComment),docLen,1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Writing Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
}
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
switch (data->Type ())
{
case DBTypeGridContinuous:
layerRec = gridIF->Layer (layerID);
if (dbType == DBTableFieldFloat)
{
for (pos.Row = 0;pos.Row < RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < ColNum ();pos.Col++)
if (gridIF->Value (layerRec,pos,&floatVal))
((float *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = (float) floatVal;
else
((float *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = MissingValue ();
}
else
{
for (pos.Row = 0;pos.Row < RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < ColNum ();pos.Col++)
if (gridIF->Value (layerRec,pos,&intVal))
{
if (DataType () == DMInt)
((int *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = (int) intVal;
else
dmRecord [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = intVal;
}
else
{
if (DataType () == DMInt)
((int *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = (int) MissingValue ();
else
dmRecord [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = -99;
}
}
break;
case DBTypeGridDiscrete:
for (pos.Row = 0;pos.Row < RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < ColNum ();pos.Col++)
{
intVal = gridIF->GridValue (layerRec,pos);
if (DataType () == DMInt)
((int *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = intVal;
else
dmRecord [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = -99;
}
break;
default:
CMmsgPrint (CMmsgAppError, "Invalid Data Type in: %s %d",__FILE__,__LINE__);
free (dmRecord);
delete gridIF;
return (DBFault);
}
if ((DBInt) fwrite (dmRecord,DataType () == DMByte ? sizeof (char) : sizeof (int),DataPointNum (),file) != DataPointNum ())
{ CMmsgPrint (CMmsgSysError, "File Writing Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
}
//.........这里部分代码省略.........