本文整理汇总了C++中DBObjTable::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTable::Add方法的具体用法?C++ DBObjTable::Add怎么用?C++ DBObjTable::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTable
的用法示例。
在下文中一共展示了DBObjTable::Add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _RGISGrpPanelNewCBK
static void _RGISGrpPanelNewCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)
{
char *groupName;
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *groupTable = dbData->Table (DBrNGroups);
DBObjTableField *group;
DBObjRecord *record;
if ((groupName = UIGetString ((char *) "Group Name",16)) == (char *) NULL) return;
if (groupTable == (DBObjTable *) NULL)
{
DBObjTable *items = dbData->Table (DBrNItems);
DBObjectLIST<DBObjTable> *tables = dbData->Tables ();
DBTableFieldDefinition fieldDefs [] = {
DBTableFieldDefinition (groupName, DBTableFieldInt,(char *) "%1d",sizeof (DBByte)),
DBTableFieldDefinition () };
tables->Add (groupTable = new DBObjTable (DBrNGroups,fieldDefs));
grpPanel->Groups (groupTable->Fields ());
group = groupTable->Field (groupName);
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
group->Int (groupTable->Add (record->Name ()),true);
}
else
{
groupTable->AddField (group = new DBObjTableField (groupName,DBTableFieldInt,"%1d",sizeof (DBByte)));
for (record = groupTable->First ();record != (DBObjRecord *) NULL;record = groupTable->Next ())
group->Int (record,true);
}
grpPanel->Add (group);
}
示例2: RGlibGenFuncSymbolField
int RGlibGenFuncSymbolField (DBObjData *data, const char *fieldName)
{
DBInt recID;
char symbolName [DBStringLength + 1];
DBObjTable *table = data->Table (DBrNItems);
DBObjTable *symbols = data->Table (DBrNSymbols);
DBObjRecord *record, *symbolRec;
DBObjTableField *field;
DBObjTableField *symbolFLD;
DBObjTableField *symbolIDFLD;
DBObjTableField *foregroundFLD;
DBObjTableField *backgroundFLD;
DBObjTableField *styleFLD;
if (table == (DBObjTable *) NULL) return (DBFault);
if ((field = table->Field (fieldName)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Invalid field name in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((symbolFLD = table->Field (DBrNSymbol)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing symbol field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (symbols == (DBObjTable *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing symbol table in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((symbolIDFLD = symbols->Field (DBrNSymbolID)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing symbolID field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((foregroundFLD = symbols->Field (DBrNForeground)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing foreground field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((backgroundFLD = symbols->Field (DBrNBackground)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing background field in: %s %d",__FILE__,__LINE__); return (DBFault); }
if ((styleFLD = symbols->Field (DBrNStyle)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Missing style field in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbols->DeleteAll ();
for (recID = 0;recID < table->ItemNum (); ++recID)
{
record = table->Item (recID);
DBPause (record->RowID () * 100 / table->ItemNum ());
if (field->Type () == DBTableFieldString) sprintf (symbolName,"%s",field->String (record));
else sprintf (symbolName,"Symbol:%03d",field->Int (record));
if ((symbolRec = (DBObjRecord *) symbols->Item (symbolName)) == (DBObjRecord *) NULL)
{
if ((symbolRec = symbols->Add (symbolName)) == NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,field->Type () == DBTableFieldString ? symbolRec->RowID () : field->Int (record));
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
}
symbolFLD->Record (record,symbolRec);
}
return (DBSuccess);
}
示例3: DBImportARCLine
int DBImportARCLine (DBObjData *vecData,const char *arcCov)
{
FILE *inFile;
DBInt arcNum, vertex, swap = DBByteOrder (DBByteOrderLITTLE), floatCov;
char fileName [DBDataFileNameLen], objName [DBStringLength];
short infoHeader [50];
DBARCRecord arcRecord;
DBObjTable *lines;
DBObjTable *nodes;
DBObjectLIST<DBObjRecord> *data;
DBObjRecord *lineRec, *nodeRec, *dataRec;
DBRegion dataExtent = vecData->Extent (), itemExtent;
DBObjTableField *fromNodeFLD;
DBObjTableField *toNodeFLD;
DBObjTableField *leftPolyFLD;
DBObjTableField *rightPolyFLD;
DBObjTableField *vertexesFLD;
DBObjTableField *vertexNumFLD;
DBObjTableField *extentFLD;
DBObjTableField *coordFLD;
DBObjTableField *linkNumFLD;
DBCoordinate *vertexes, nodeCoord;
DBFloat4 floatVAR [2];
switch (vecData->Type ())
{
case DBTypeVectorLine: lines = vecData->Table (DBrNItems); break;
case DBTypeVectorPolygon: lines = vecData->Table (DBrNContours); break;
default: CMmsgPrint (CMmsgAppError, "Invalide Vector Data Type in: %s %d",__FILE__,__LINE__); return (DBFault);
}
fromNodeFLD = lines->Field (DBrNFromNode);
toNodeFLD = lines->Field (DBrNToNode);
leftPolyFLD = lines->Field (DBrNLeftPoly);
rightPolyFLD= lines->Field (DBrNRightPoly);
vertexesFLD = lines->Field (DBrNVertexes);
vertexNumFLD= lines->Field (DBrNVertexNum);
extentFLD = lines->Field (DBrNRegion);
nodes = vecData->Table (DBrNNodes);
coordFLD = nodes->Field (DBrNCoord);
linkNumFLD = nodes->Field (DBrNLinkNum);
data = vecData->Arrays ();
sprintf (fileName,"%s/arc",arcCov);
if (access (fileName,R_OK) == DBFault) sprintf (fileName,"%s/arc.adf",arcCov);
if ((inFile = fopen (fileName,"r")) == NULL)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (fread (infoHeader,sizeof (short),50,inFile) != 50)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
arcNum = 0;
for (lineRec = lines->First ();arcRecord.Read (inFile,swap) != DBFault;lineRec = lines->Next ())
{
if (lineRec == NULL)
{
sprintf (objName,"Line: %5d",arcRecord.ID () + 1);
if ((lineRec = lines->Add (objName)) == (DBObjRecord *) NULL) return (DBFault);
}
else DBPause ((++arcNum * 100) / lines->ItemNum ());
floatCov = arcRecord.RecordLength () - 12 == arcRecord.NumOfPnts () * (DBInt) sizeof (float) ? true : false;
while (arcRecord.FromNode () > nodes->ItemNum ())
{
sprintf (objName,"Node: %5d",nodes->ItemNum () + 1);
nodes->Add (objName);
if ((nodeRec = nodes->Item ()) == NULL) return (DBFault);
linkNumFLD->Int (nodeRec,0);
}
if ((nodeRec = nodes->Item (arcRecord.FromNode () - 1)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Node Not Found in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (floatCov)
{
if (fread (floatVAR,sizeof (floatVAR),1,inFile) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (swap) { DBByteOrderSwapWord (floatVAR); DBByteOrderSwapWord (floatVAR + 1); }
nodeCoord.X = (DBFloat) floatVAR [0];
nodeCoord.Y = (DBFloat) floatVAR [1];
}
else
{
if (fread (&nodeCoord,sizeof (DBCoordinate),1,inFile) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (swap) nodeCoord.Swap ();
}
coordFLD->Coordinate (nodeRec,nodeCoord);
fromNodeFLD->Record (lineRec,nodeRec);
if (leftPolyFLD != (DBObjTableField *) NULL) leftPolyFLD->Record (lineRec,arcRecord.LeftPoly ());
if (rightPolyFLD != (DBObjTableField *) NULL) rightPolyFLD->Record (lineRec,arcRecord.RightPoly ());
itemExtent.LowerLeft = nodeCoord;
itemExtent.UpperRight = nodeCoord;
linkNumFLD->Int (nodeRec,linkNumFLD->Int (nodeRec) + 1);
if (arcRecord.NumOfPnts () > 2)
{
if ((dataRec = data->Item (lineRec->RowID ())) == (DBObjRecord *) NULL)
{
//.........这里部分代码省略.........
示例4: DBImportARCVector
int DBImportARCVector (DBObjData *vecData,const char *arcCov,const char *nameFieldStr,const char *symbolFieldStr)
{
char symbolName [DBStringLength + 1];
DBObjTable *items = vecData->Table (DBrNItems);
DBObjTable *symbols = vecData->Table (DBrNSymbols);
DBObjTableField *nameFLD = NULL, *symbolResFLD, *symbolFLD = NULL;
DBObjTableField *symbolIDFLD = symbols->Field (DBrNSymbolID);
DBObjTableField *foregroundFLD = symbols->Field (DBrNForeground);
DBObjTableField *backgroundFLD = symbols->Field (DBrNBackground);
DBObjTableField *styleFLD = symbols->Field (DBrNStyle);
DBObjRecord *record;
DBObjRecord *symbolRec;
if (DBInfoGetFields (items,DBInfoFileName (arcCov,vecData->Type ())) == DBSuccess)
if (DBInfoGetTable (items,DBInfoFileName (arcCov,vecData->Type ())) == DBFault) return (DBFault);
switch (vecData->Type ())
{
case DBTypeVectorPoint:
if (DBImportARCPoint (vecData,arcCov) == DBFault) return (DBFault); else break;
case DBTypeVectorLine:
if (DBImportARCLine (vecData,arcCov) == DBFault) return (DBFault); else break;
case DBTypeVectorPolygon:
if (DBImportARCPoly (vecData,arcCov) == DBFault) return (DBFault); else break;
default: return (DBFault);
}
nameFLD = nameFieldStr != NULL ? items->Field (nameFieldStr) : (DBObjTableField *) NULL;
symbolFLD = symbolFieldStr != NULL ? items->Field (symbolFieldStr) : (DBObjTableField *) NULL;
symbolResFLD = items->Field (DBrNSymbol);
if (symbolFLD != NULL)
{
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
{
switch (symbolFLD->Type ())
{
case DBTableFieldString:
if ((symbolRec = (DBObjRecord *) symbols->Item (symbolFLD->String (record))) == NULL)
{
if ((symbolRec = symbols->Add (symbolFLD->String (record))) == NULL)
{ CMmsgPrint (CMmsgAppError,"Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,symbolRec->RowID ());
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
}
break;
case DBTableFieldInt:
sprintf (symbolName,"Symbol:%5d",symbolFLD->Int (record));
if ((symbolRec = (DBObjRecord *) symbols->Item (symbolName)) == NULL)
{
if ((symbolRec = symbols->Add (symbolName)) == NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,symbolFLD->Int (record));
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
}
break;
default:
CMmsgPrint (CMmsgAppError, "Invalid Field Type in: %s %d",__FILE__,__LINE__);
break;
}
symbolResFLD->Record (record,symbolRec);
}
}
else
{
symbols->Add ("Default Symbol");
if ((symbolRec = (DBObjRecord *) symbols->Item ()) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
symbolIDFLD->Int (symbolRec,0);
foregroundFLD->Int (symbolRec,1);
backgroundFLD->Int (symbolRec,0);
styleFLD->Int (symbolRec,0);
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
symbolResFLD->Record (record,symbolRec);
}
if (nameFLD != NULL)
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
record->Name (nameFLD->String (record));
return (DBSuccess);
}
示例5: _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;
}
示例6: 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);
}
示例7: Read
DBInt Read (FILE *file,DBObjData *data)
{
DBInt i, layer, swap, valueType, valueSize, docLength;
DMLayerHeader dmLayerHeader;
DBObjRecord *layerRec, *dataRec;
DBObjTable *layerTable = data->Table (DBrNLayers);
DBObjTable *itemTable = data->Table (DBrNItems);
DBObjTableField *rowNumFLD = layerTable->Field (DBrNRowNum);
DBObjTableField *colNumFLD = layerTable->Field (DBrNColNum);
DBObjTableField *cellWidthFLD = layerTable->Field (DBrNCellWidth);
DBObjTableField *cellHeightFLD = layerTable->Field (DBrNCellHeight);
DBObjTableField *valueTypeFLD = layerTable->Field (DBrNValueType);
DBObjTableField *valueSizeFLD = layerTable->Field (DBrNValueSize);
DBObjTableField *layerFLD = layerTable->Field (DBrNLayer);
DBGridIF *gridIF;
if ((swap = DMFileHeader::Read (file)) == DBFault) return (DBFault);
data->Extent (Extent ());
data->Projection (DBMathGuessProjection (data->Extent ()));
data->Precision (DBMathGuessPrecision (data->Extent ()));
if (FileType () != DMMatrix)
{ CMmsgPrint (CMmsgAppError, "Wrong File Type in: %s %d",__FILE__,__LINE__); return (DBFault); }
switch (DataType ())
{
case DMFloat: valueType = DBTableFieldFloat; valueSize = sizeof (DBFloat4);break;
case DMInt: valueType = DBTableFieldInt; valueSize = sizeof (DBInt); break;
case DMByte: valueType = DBTableFieldInt; valueSize = sizeof (DBByte); break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Value Type in: %s %d",__FILE__,__LINE__); return (DBFault);
}
for (layer = 0;layer < LayerNum ();++layer)
{
if (dmLayerHeader.Read (file,swap) == DBFault) return (DBFault);
if (strlen (dmLayerHeader.Description ()) > 0) layerName = dmLayerHeader.Description ();
else { sprintf (layerNameSTR,"GHAASLayer%4d",layer + 1); layerName = layerNameSTR; }
layerTable->Add (layerName);
if ((layerRec = layerTable->Item ()) == (DBObjRecord *) NULL) return (DBFault);
rowNumFLD->Int (layerRec,RowNum ());
colNumFLD->Int (layerRec,ColNum ());
cellWidthFLD->Float (layerRec,CellWidth ());
cellHeightFLD->Float (layerRec,CellHeight ());
valueTypeFLD->Int (layerRec,((DBInt) DBTypeGridDiscrete) == data->Type () ? DBTableFieldInt : valueType);
valueSizeFLD->Int (layerRec,valueSize);
if ((dataRec = new DBObjRecord (layerName,((size_t) ColNum ()) * RowNum () * valueSize,valueSize)) == (DBObjRecord *) NULL)
return (DBFault);
(data->Arrays ())->Add (dataRec);
layerFLD->Record (layerRec,dataRec);
}
if (fread (&docLength,sizeof (int),1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (swap) DBByteOrderSwapWord (&docLength);
if (docLength > 0)
{
char *docString;
if ((docString = (char *) calloc (docLength,sizeof (char))) == (char *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (fread (docString,docLength,1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
data->Document (DBDocComment,docString);
free (docString);
}
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
if (fread (dataRec->Data (),ColNum () * valueSize * RowNum (),1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (swap && valueSize > 1)
{
int i;
void (*swapFunc) (void *);
switch (valueSize)
{
case 2: swapFunc = DBByteOrderSwapHalfWord; break;
case 4: swapFunc = DBByteOrderSwapWord; break;
case 8: swapFunc = DBByteOrderSwapLongWord; break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Value Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
for (i = 0;i < ColNum () * RowNum ();++i) (*swapFunc) ((char *) dataRec->Data () + i * valueSize);
}
switch (data->Type ())
{
case DBTypeGridDiscrete:
{
DBInt value;
char nameStr [DBStringLength];
DBObjRecord *symRec = (data->Table (DBrNSymbols))->Add ("Default Symbol");
DBObjRecord *itemRec;
DBObjTableField *gridValueFLD = itemTable->Field (DBrNGridValue);
DBObjTableField *gridSymbolFLD = itemTable->Field (DBrNSymbol);
DBObjTableField *symbolIDFLD = (data->Table (DBrNSymbols))->Field (DBrNSymbolID);
DBObjTableField *foregroundFLD = (data->Table (DBrNSymbols))->Field (DBrNForeground);
DBObjTableField *backgroundFLD = (data->Table (DBrNSymbols))->Field (DBrNBackground);
DBObjTableField *styleFLD = (data->Table (DBrNSymbols))->Field (DBrNStyle);
symbolIDFLD->Int (symRec,0);
foregroundFLD->Int (symRec,1);
backgroundFLD->Int (symRec,0);
styleFLD->Int (symRec,0);
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
{
for (i = 0;i < ColNum () * RowNum ();++i)
{
//.........这里部分代码省略.........
示例8: 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);
}
示例9: DBGridCont2Network
DBInt DBGridCont2Network (DBObjData *gridData,DBObjData *netData, bool downhill)
{
DBInt basinID, layerID, zLayerID, zLayerNum, dir, maxDir, projection = gridData->Projection (), *zones;
DBFloat elev0, elev1, delta, maxDelta, distance;
DBCoordinate coord0, coord1;
DBInt row, col;
DBPosition pos, auxPos;
char nameSTR [DBStringLength];
DBObjTable *basinTable = netData->Table (DBrNItems);
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTable *layerTable = netData->Table (DBrNLayers);
DBObjRecord *layerRec, *dataRec, *cellRec, *basinRec;
DBObjTableField *mouthPosFLD = basinTable->Field (DBrNMouthPos);
DBObjTableField *colorFLD = basinTable->Field (DBrNColor);
DBObjTableField *positionFLD = cellTable->Field (DBrNPosition);
DBObjTableField *toCellFLD = cellTable->Field (DBrNToCell);
DBObjTableField *fromCellFLD = cellTable->Field (DBrNFromCell);
DBObjTableField *orderFLD = cellTable->Field (DBrNOrder);
DBObjTableField *basinFLD = cellTable->Field (DBrNBasin);
DBObjTableField *basinCellsFLD= cellTable->Field (DBrNBasinCells);
DBObjTableField *travelFLD = cellTable->Field (DBrNTravel);
DBObjTableField *upCellPosFLD = cellTable->Field (DBrNUpCellPos);
DBObjTableField *cellAreaFLD = cellTable->Field (DBrNCellArea);
DBObjTableField *subbasinLengthFLD = cellTable->Field (DBrNSubbasinLength);
DBObjTableField *subbasinAreaFLD = cellTable->Field (DBrNSubbasinArea);
DBObjTableField *rowNumFLD = layerTable->Field (DBrNRowNum);
DBObjTableField *colNumFLD = layerTable->Field (DBrNColNum);
DBObjTableField *cellWidthFLD = layerTable->Field (DBrNCellWidth);
DBObjTableField *cellHeightFLD = layerTable->Field (DBrNCellHeight);
DBObjTableField *valueTypeFLD = layerTable->Field (DBrNValueType);
DBObjTableField *valueSizeFLD = layerTable->Field (DBrNValueSize);
DBObjTableField *layerFLD = layerTable->Field (DBrNLayer);
DBObjData *zGridData = gridData->LinkedData ();
DBGridIF *gridIF = new DBGridIF (gridData), *zGridIF;
DBNetworkIF *netIF;
if ((zGridData != (DBObjData *) NULL) && ((zGridData->Type () == DBTypeGridDiscrete) || (zGridData->Type () == DBTypeGridContinuous)))
{
zGridIF = new DBGridIF (zGridData);
zLayerNum = zGridIF->LayerNum () + 1;
}
else { zGridIF = (DBGridIF *) NULL; zLayerNum = 1; }
if ((zones = (DBInt *) calloc (9 * zLayerNum,sizeof (DBInt))) == (DBInt *) NULL)
{
CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__);
if (zGridIF != (DBGridIF *) NULL) delete zGridIF;
delete gridIF;
return (DBFault);
}
layerTable->Add (DBrNLookupGrid);
if ((layerRec = layerTable->Item (DBrNLookupGrid)) == (DBObjRecord *) NULL)
{
free (zones);
if (zGridIF != (DBGridIF *) NULL) delete zGridIF;
delete gridIF;
return (DBFault);
}
netData->Projection (projection);
netData->Extent (gridData->Extent ());
cellWidthFLD->Float (layerRec,gridIF->CellWidth ());
cellHeightFLD->Float (layerRec,gridIF->CellHeight ());
valueTypeFLD->Int (layerRec,DBTableFieldInt);
valueSizeFLD->Int (layerRec,sizeof (DBInt));
rowNumFLD->Int (layerRec,gridIF->RowNum ());
colNumFLD->Int (layerRec,gridIF->ColNum ());
dataRec = new DBObjRecord ("NetLookupGridRecord",((size_t) gridIF->RowNum ()) * gridIF->ColNum () * sizeof (DBInt),sizeof (DBInt));
if (dataRec == (DBObjRecord *) NULL)
{
if (zGridIF != (DBGridIF *) NULL) delete zGridIF;
return (DBFault);
}
layerFLD->Record (layerRec,dataRec);
(netData->Arrays ())->Add (dataRec);
for (pos.Row = 0;pos.Row < gridIF->RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < gridIF->ColNum ();pos.Col++)
((DBInt *) dataRec->Data ()) [pos.Row * gridIF->ColNum () + pos.Col] = DBFault;
for (pos.Row = 0;pos.Row < gridIF->RowNum ();pos.Row++)
{
if (DBPause (10 * pos.Row / gridIF->RowNum ())) goto PauseStop;
for (pos.Col = 0;pos.Col < gridIF->ColNum ();pos.Col++)
{
gridIF->Pos2Coord (pos,coord0);
zLayerID = 0;
if (zGridIF != (DBGridIF *) NULL)
for ( ; zLayerID < zGridIF->LayerNum (); zLayerID++)
{
layerRec = zGridIF->Layer (zLayerID);
if ((layerRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (dir = 0;dir < 8;++dir)
{
row = pos.Row;
col = pos.Col;
//.........这里部分代码省略.........
示例10: RGISToolsConvertToPointCBK
void RGISToolsConvertToPointCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *nText, *xText, *yText, *selection;
int allowOk;
static int convert;
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *itemTable;
static Widget tableSelect = (Widget) NULL;
static Widget dShell = (Widget) NULL, mainForm;
static Widget nameTextF, xCoordTextF, yCoordTextF;
XmString string;
if (tableSelect == (Widget) NULL) tableSelect = UISelectionCreate ((char *) "Table Selection");
selection = UISelectObject (tableSelect,(DBObjectLIST<DBObject> *) dbData->Tables ());
if (selection == (char *) NULL) return;
if ((itemTable = dbData->Table (selection)) == (DBObjTable *) NULL)
{ CMmsgPrint (CMmsgAppError, "Invalid Table in: %s %d",__FILE__,__LINE__); return; }
_RGISToolsConvertToPointFields = itemTable->Fields ();
if (dShell == (Widget) NULL)
{
Widget button;
dShell = UIDialogForm ((char *) "Convert Table To Point",false);
mainForm = UIDialogFormGetMainForm (dShell);
string = XmStringCreate ((char *) "Select",UICharSetBold);
button = XtVaCreateManagedWidget ("RGISToolsConvertToPointNameButton",xmPushButtonWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_FORM,
XmNtopOffset, 10,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 10,
XmNmarginHeight, 5,
XmNtraversalOn, False,
XmNlabelString, string,
XmNuserData, DBTableFieldIsString,
NULL);
XmStringFree (string);
nameTextF = XtVaCreateManagedWidget ("RGISToolsConvertToPointNameTextF",xmTextFieldWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, button,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, button,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNmaxLength, DBStringLength,
XmNcolumns, DBStringLength / 2,
NULL);
XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISToolsConvertToPointSelectCBK,nameTextF);
string = XmStringCreate ((char *) "Name Field:",UICharSetBold);
XtVaCreateManagedWidget ("RGISToolsConvertToPointNameLabel",xmLabelWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, button,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, nameTextF,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNlabelString, string,
NULL);
XmStringFree (string);
string = XmStringCreate ((char *) "Select",UICharSetBold);
button = XtVaCreateManagedWidget ("RGISToolsConvertToPointXCoordButton",xmPushButtonWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, button,
XmNtopOffset, 10,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 10,
XmNmarginHeight, 5,
XmNtraversalOn, False,
XmNlabelString, string,
XmNuserData, DBTableFieldIsNumeric,
NULL);
XmStringFree (string);
xCoordTextF = XtVaCreateManagedWidget ("RGISToolsConvertToPointXCoordTextF",xmTextFieldWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, button,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, button,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNmaxLength, DBStringLength,
XmNcolumns, DBStringLength / 2,
NULL);
XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISToolsConvertToPointSelectCBK,xCoordTextF);
string = XmStringCreate ((char *) "X Coordinate:",UICharSetBold);
XtVaCreateManagedWidget ("RGISToolsConvertToPointXCoordLabel",xmLabelWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, button,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, nameTextF,
//.........这里部分代码省略.........