本文整理汇总了C++中DBObjTableField::Record方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTableField::Record方法的具体用法?C++ DBObjTableField::Record怎么用?C++ DBObjTableField::Record使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTableField
的用法示例。
在下文中一共展示了DBObjTableField::Record方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBObject
DBObjData::DBObjData(DBObjData &data) : DBObject(data), DBDataHeader(data._Header()) {
DBObjTable *table;
DBObjRecord *record, *obj;
DBObjTableField *field;
DBObjectLIST<DBObjTableField> *fields;
strcpy(FileNameSTR, "");
TablesPTR = new DBObjectLIST<DBObjTable>(*data.TablesPTR);
DocsPTR = new DBObjectLIST<DBObjRecord>(*data.DocsPTR);
ArraysPTR = new DBObjectLIST<DBObjRecord>(*data.ArraysPTR);
DispPTR = new DBObjectLIST<DBObject>("Data Display");
LinkedDataPTR = (DBObjData *) NULL;
for (table = TablesPTR->First(); table != (DBObjTable *) NULL; table = TablesPTR->Next()) {
fields = table->Fields();
for (record = table->First(); record != (DBObjRecord *) NULL; record = table->Next()) {
for (field = fields->First(); field != (DBObjTableField *) NULL; field = fields->Next())
switch (field->Type()) {
case DBTableFieldTableRec:
case DBTableFieldDataRec:
if ((obj = field->Record(record)) != NULL)
field->Record(record, (DBObjRecord *) ((char *) NULL + obj->RowID()));
else field->Record(record, (DBObjRecord *) DBFault);
break;
}
}
}
BuildFields();
}
示例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: CMmsgPrint
DBNetworkIF::DBNetworkIF (DBObjData *data)
{
DBObjTableField *layerFLD;
DataPTR = data;
BasinTable = data->Table (DBrNItems);
CellTable = data->Table (DBrNCells);
LayerTable = data->Table (DBrNLayers);
SymbolTable = data->Table (DBrNSymbols);
MouthPosFLD = BasinTable->Field (DBrNMouthPos);
ColorFLD = BasinTable->Field (DBrNColor);
BasinOrderFLD = BasinTable->Field (DBrNBasinOrder);
SymbolFLD = BasinTable->Field (DBrNSymbol);
BasinLengthFLD = BasinTable->Field (DBrNBasinLength);
BasinAreaFLD = BasinTable->Field (DBrNBasinArea);
SymbolIDFLD = SymbolTable->Field (DBrNSymbolID);
ForegroundFLD = SymbolTable->Field (DBrNForeground);
BackgroundFLD = SymbolTable->Field (DBrNBackground);
PositionFLD = CellTable->Field (DBrNPosition);
ToCellFLD = CellTable->Field (DBrNToCell);
FromCellFLD = CellTable->Field (DBrNFromCell);
OrderFLD = CellTable->Field (DBrNOrder);
MagnitudeFLD = CellTable->Field (DBrNMagnitude);
BasinFLD = CellTable->Field (DBrNBasin);
BasinCellsFLD = CellTable->Field (DBrNBasinCells);
TravelFLD = CellTable->Field (DBrNTravel);
UpCellPosFLD = CellTable->Field (DBrNUpCellPos);
CellAreaFLD = CellTable->Field (DBrNCellArea);
CellLengthFLD = CellTable->Field (DBrNCellLength);
DistToMouthFLD = CellTable->Field (DBrNDistToMouth);
DistToOceanFLD = CellTable->Field (DBrNDistToOcean);
SubbasinLengthFLD = CellTable->Field (DBrNSubbasinLength);
SubbasinAreaFLD = CellTable->Field (DBrNSubbasinArea);
RowNumFLD = LayerTable->Field (DBrNRowNum);
ColNumFLD = LayerTable->Field (DBrNColNum);
CellWidthFLD = LayerTable->Field (DBrNCellWidth);
CellHeightFLD = LayerTable->Field (DBrNCellHeight);
layerFLD = LayerTable->Field (DBrNLayer);
if ((LayerRecord = LayerTable->Item (DBrNLookupGrid)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError,"Bailing Out like ARC/INFO in: %s %d",__FILE__,__LINE__); exit (-1); }
if((DataRec = layerFLD->Record (LayerRecord)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError,"Bailing Out in: %s %d",__FILE__,__LINE__); exit (-1); }
if (CellLengthFLD == (DBObjTableField *) NULL)
{
DBInt cellID;
DBObjRecord *cellRec;
DBCoordinate coord0, coord1;
CellLengthFLD = new DBObjTableField (DBrNCellLength,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4),true);
CellTable->AddField (CellLengthFLD);
for (cellID = 0;cellID < CellNum ();++cellID)
{
cellRec = Cell (cellID);
coord0 = Center (cellRec);
coord1 = Center (cellRec) + Delta (cellRec);
CellLengthFLD->Float (cellRec,DBMathCoordinateDistance (DataPTR->Projection (),coord0,coord1));
}
}
}
示例5: DBImportARCPoly
int DBImportARCPoly (DBObjData *vecData,const char *arcCov)
{
DBInt polyNum = 0, line, lineNum, vertexNum, polyDir;
DBObjTable *items = vecData->Table (DBrNItems);
DBObjTable *lines = vecData->Table (DBrNContours);
DBObjTableField *firstLineFLD = items->Field (DBrNFirstLine);
DBObjTableField *lineNumFLD = items->Field (DBrNLineNum);
DBObjTableField *polyVertexNumFLD = items->Field (DBrNVertexNum);
DBObjTableField *polyExtentFLD = items->Field (DBrNRegion);
DBObjTableField *leftPolyFLD = lines->Field (DBrNLeftPoly);
DBObjTableField *rightPolyFLD = lines->Field (DBrNRightPoly);
DBObjTableField *nextLineFLD = lines->Field (DBrNNextLine);
DBObjTableField *prevLineFLD = lines->Field (DBrNPrevLine);
DBObjTableField *fromNodeFLD = lines->Field (DBrNFromNode);
DBObjTableField *toNodeFLD = lines->Field (DBrNToNode);
DBObjTableField *lineVertextNumFLD = lines->Field (DBrNVertexNum);
DBObjTableField *lineExtentFLD = lines->Field (DBrNRegion);
DBObjRecord *polyRec, *lineRec, *firstNodeRec, *nodeRec, **lineRecArray;
DBRegion extent, initRegion;
if (DBImportARCLine (vecData,arcCov) == DBFault) return (DBFault);
items->Delete (0);
for (polyRec = items->First ();polyRec != (DBObjRecord *) NULL;polyRec = items->Next ())
lineNumFLD->Int (polyRec,0);
for (lineRec = lines->First ();lineRec != (DBObjRecord *) NULL;lineRec = lines->Next ())
{
rightPolyFLD->Record (lineRec,items->Item ((DBInt) (rightPolyFLD->Record(lineRec) - (DBObjRecord *) NULL)));
leftPolyFLD->Record (lineRec,items->Item ((DBInt) (leftPolyFLD->Record (lineRec) - (DBObjRecord *) NULL)));
nextLineFLD->Record (lineRec,(DBObjRecord *) NULL);
prevLineFLD->Record (lineRec,(DBObjRecord *) NULL);
}
if ((lineRecArray = (DBObjRecord **) calloc (lines->ItemNum (),sizeof (DBObjRecord *))) == (DBObjRecord **) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
for (polyRec = items->First ();polyRec != (DBObjRecord *) NULL;polyRec = items->Next ())
{
DBPause ((++polyNum * 100) / items->ItemNum ());
lineNum = vertexNum = 0;
extent = initRegion;
for (lineRec = lines->First ();lineRec != (DBObjRecord *) NULL;lineRec = lines->Next ())
if ((rightPolyFLD->Record (lineRec) == polyRec) || (leftPolyFLD->Record (lineRec) == polyRec))
{
lineRecArray [lineNum++] = lineRec;
vertexNum += lineVertextNumFLD->Int (lineRec);
extent.Expand (lineExtentFLD->Region (lineRec));
}
lineNumFLD->Int (polyRec,lineNum);
polyExtentFLD->Region (polyRec,extent);
firstLineFLD->Record (polyRec,lineRecArray [0]);
firstNodeRec = (rightPolyFLD->Record (lineRecArray [0]) == polyRec) ?
fromNodeFLD->Record (lineRecArray [0]) : toNodeFLD->Record(lineRecArray [0]);
for (lineNum = 1;lineNum < lineNumFLD->Int (polyRec);++lineNum)
{
polyDir = (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec);
nodeRec = polyDir ? toNodeFLD->Record (lineRecArray [lineNum - 1]) :
fromNodeFLD->Record(lineRecArray [lineNum - 1]);
for (line = lineNum;line < lineNumFLD->Int (polyRec); ++line)
if ((nodeRec == fromNodeFLD->Record (lineRecArray [line])) ||
(nodeRec == toNodeFLD->Record (lineRecArray [line]))) break;
if (line < lineNumFLD->Int (polyRec))
{
lineRec = lineRecArray [lineNum];
lineRecArray [lineNum] = lineRecArray [line];
lineRecArray [line] = lineRec;
}
else
{
vertexNum += 1;
if (nodeRec != firstNodeRec) vertexNum += 1;
}
}
polyDir = (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec);
nodeRec = polyDir ? toNodeFLD->Record (lineRecArray [lineNum - 1]) :
fromNodeFLD->Record(lineRecArray [lineNum - 1]);
polyVertexNumFLD->Int (polyRec,vertexNum + lineNum + 1 + (nodeRec != firstNodeRec ? 1 : 0));
for (lineNum = 1;lineNum < lineNumFLD->Int (polyRec);++lineNum)
{
if (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec)
nextLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [lineNum]);
else prevLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [lineNum]);
}
if (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec)
nextLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [0]);
else prevLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [0]);
}
free (lineRecArray);
return (DBSuccess);
}
示例6: _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;
}
示例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: 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;
//.........这里部分代码省略.........
示例9: RGISToolsConvertToPointCBK
//.........这里部分代码省略.........
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);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&convert);
}
convert = false;
UIDialogFormPopup (dShell);
while (UILoop ())
{
xText = XmTextFieldGetString (xCoordTextF);
yText = XmTextFieldGetString (yCoordTextF);
allowOk = (strlen (xText) > 0) && (strlen (yText) > 0);
XtFree (xText); XtFree (yText);
XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
}
UIDialogFormPopdown (dShell);
if (convert)
{
DBObjData *pntData = new DBObjData ("",DBTypeVectorPoint);
pntData->Name (dbData->Name ());
pntData->Document (DBDocSubject,dbData->Document (DBDocSubject));
pntData->Document (DBDocGeoDomain,dbData->Document (DBDocGeoDomain));
if (UIDataHeaderForm (pntData))
{
DBCoordinate coord;
DBObjTableField *nField, *xField, *yField, *tblFLD, *pntFLD;
DBObjRecord *tblRec, *pntRec, *symRec;
DBObjTable *pntTable = pntData->Table (DBrNItems);
DBObjTable *symbols = pntData->Table (DBrNSymbols);
DBObjTableField *symbolIDFLD = symbols->Field (DBrNSymbolID);
DBObjTableField *fgFLD = symbols->Field (DBrNForeground);
DBObjTableField *bgFLD = symbols->Field (DBrNBackground);
DBObjTableField *stFLD = symbols->Field (DBrNStyle);
DBObjTableField *coordFLD = pntTable->Field (DBrNCoord);
DBObjTableField *symbolFLD = pntTable->Field (DBrNSymbol);
DBRegion extent;
symRec = symbols->Add ("Default Symbol");
symbolIDFLD->Int (symRec,0);
fgFLD->Int (symRec,1);
bgFLD->Int (symRec,2);
stFLD->Int (symRec,0);
nText = XmTextFieldGetString (nameTextF);
xText = XmTextFieldGetString (xCoordTextF);
yText = XmTextFieldGetString (yCoordTextF);
nField = _RGISToolsConvertToPointFields->Item (nText);
xField = _RGISToolsConvertToPointFields->Item (xText);
yField = _RGISToolsConvertToPointFields->Item (yText);
XtFree (nText); XtFree (xText); XtFree (yText);
for (tblRec = itemTable->First ();tblRec != (DBObjRecord *) NULL;tblRec = itemTable->Next ())
{
if (CMmathEqualValues (coord.X = xField->Float (tblRec),xField->FloatNoData ())) continue;
if (CMmathEqualValues (coord.Y = yField->Float (tblRec),yField->FloatNoData ())) continue;
if (nField == (DBObjTableField *) NULL) pntRec = pntTable->Add (tblRec->Name ());
else pntRec = pntTable->Add (nField->String (tblRec));
coordFLD->Coordinate (pntRec,coord);
symbolFLD->Record (pntRec,symRec);
extent.Expand (coord);
}
pntData->Extent (extent);
pntData->Projection (DBMathGuessProjection (extent));
pntData->Precision (DBMathGuessPrecision (extent));
for (tblFLD = _RGISToolsConvertToPointFields->First ();tblFLD != (DBObjTableField *) NULL;tblFLD = _RGISToolsConvertToPointFields->Next ())
if ((tblFLD != nField) && (tblFLD != xField) && (tblFLD != yField) && DBTableFieldIsVisible (tblFLD))
{
pntTable->AddField (pntFLD = new DBObjTableField (*tblFLD));
pntFLD->Required (false);
pntRec = pntTable->First ();
for (tblRec = itemTable->First ();tblRec != (DBObjRecord *) NULL;tblRec = itemTable->Next ())
{
if (CMmathEqualValues (coord.X = xField->Float (tblRec),xField->FloatNoData ())) continue;
if (CMmathEqualValues (coord.Y = yField->Float (tblRec),yField->FloatNoData ())) continue;
switch (tblFLD->Type ())
{
case DBTableFieldString: pntFLD->String (pntRec,tblFLD->String (tblRec)); break;
case DBTableFieldInt: pntFLD->Int (pntRec,tblFLD->Int (tblRec)); break;
case DBTableFieldFloat: pntFLD->Float (pntRec,tblFLD->Float (tblRec)); break;
case DBTableFieldDate: pntFLD->Date (pntRec,tblFLD->Date (tblRec)); break;
default: CMmsgPrint (CMmsgAppError, "Invalid Field Type in: %s %d",__FILE__,__LINE__); break;
}
pntRec = pntTable->Next ();
}
}
workspace->CurrentData (pntData);
}
else delete pntData;
}
}