本文整理汇总了C++中DBObjTable::AddField方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTable::AddField方法的具体用法?C++ DBObjTable::AddField怎么用?C++ DBObjTable::AddField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTable
的用法示例。
在下文中一共展示了DBObjTable::AddField方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: _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);
}
示例3: RGISEditNetAddBasinXYCBK
void RGISEditNetAddBasinXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt basinID;
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBNetworkIF *netIF = new DBNetworkIF (dbData);
DBObjTable *itemTable = dbData->Table (DBrNItems);
DBObjTableField *xCoordFLD = itemTable->Field (RGISNetMouthXCoord);
DBObjTableField *yCoordFLD = itemTable->Field (RGISNetMouthYCoord);
DBCoordinate coord;
DBObjRecord *basinRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,itemTable));
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISNetMouthXCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
itemTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISNetMouthYCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
itemTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (basinID = 0;basinID < netIF->BasinNum ();++basinID)
{
basinRec = netIF->Basin (basinID);
if (UIPause (80 + basinID * 20 / netIF->BasinNum ())) goto Stop;
coord = netIF->Center (netIF->MouthCell (basinRec));
xCoordFLD->Float (basinRec,coord.X);
yCoordFLD->Float (basinRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例4: RGISEditPointAddXYCBK
void RGISEditPointAddXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBVPointIF *pntIF = new DBVPointIF (dbData);
DBObjTable *pointTable = dbData->Table (DBrNItems);
DBObjTableField *xCoordFLD = pointTable->Field (RGISEditPointXCoord);
DBObjTableField *yCoordFLD = pointTable->Field (RGISEditPointYCoord);
DBCoordinate coord;
DBObjRecord *pointRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,pointTable));
widget = widget; workspace = workspace; callData = callData;
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISEditPointXCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4));
pointTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISEditPointYCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4));
pointTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (pointRec = pntIF->FirstItem (); pointRec != (DBObjRecord *) NULL; pointRec = pntIF->NextItem ())
{
if (UIPause (80 + pointRec->RowID () * 20 / pntIF->ItemNum ())) goto Stop;
coord = pntIF->Coordinate (pointRec);
xCoordFLD->Float (pointRec,coord.X);
yCoordFLD->Float (pointRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例5: 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;
}
}
示例6: main
//.........这里部分代码省略.........
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));
fieldY = new DBObjTableField (fieldYName, DBTableFieldFloat, (char *) "%10.3f", sizeof (DBFloat4));
table->AddField(fieldID);
table->AddField(fieldX);
table->AddField(fieldY);
if (strcmp(fieldIDName, "CellID") == 0) {
for (recID = 0; recID < table->ItemNum(); ++recID) {
record = netIF->Cell(recID);
coord = netIF->Center(record);
fieldID->Int(record, recID+1);
fieldX->Float(record, coord.X);
fieldY->Float(record, coord.Y);
}
} else if (strcmp(fieldIDName, "BasinID") == 0) {
for (recID = 0; recID < netIF->BasinNum(); ++recID) {
record = netIF->Basin(recID);
coord = netIF->Center(netIF->MouthCell(record));
fieldID->Int(record, recID+1);
fieldX->Float(record,coord.X);
fieldY->Float(record,coord.Y);
}
} else {
CMmsgPrint(CMmsgUsrError, "Invalid field name: %s!", fieldIDName);
delete data;
return (CMfailed);
}
ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);
delete data;
if (verbose) RGlibPauseClose();
return (ret);
}
示例7: _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;
}
示例8: 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);
}
示例9: 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);
}
示例10: RGlibPointInterStationTS
DBInt RGlibPointInterStationTS(DBObjData *pntData, DBObjData *tsData, char *relateFldName, char *joinFldName) {
DBInt first = true, tsIndex, tsRowNum = 0;
DBObjTable *pntTBL = pntData->Table(DBrNItems), *tsTBL;
DBObjectLIST<DBObjTableField> *fields;
DBObjTableField *pntNextFLD = pntTBL->Field(RGlibNextStation);
DBObjTableField *pntAreaFLD = pntTBL->Field(RGlibArea);
DBObjTableField *pntInterStnFLD = pntTBL->Field(RGlibInterStation);
DBObjTableField *pntRelateFLD;
DBObjTableField *pntNewNextFLD;
DBObjTableField *pntNewInterStnFLD;
DBObjTableField *tsTimeFLD;
DBObjTableField *tsJoinFLD;
DBObjTableField *tsNextStnFLD, *tsInterStnFLD;
DBObjRecord *pntRec, *nextPntRec, *tsRec, *tsIndexRec;
DBDate curDate, date;
if (pntNextFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Next Station Field!");
return (DBFault);
}
if (pntAreaFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing STN Area Field!");
return (DBFault);
}
if (pntInterStnFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Interfluvial Area Field!");
return (DBFault);
}
tsTBL = tsData->Table(DBrNItems);
tsNextStnFLD = new DBObjTableField(RGlibNextStation, DBTableFieldInt, "%8d", sizeof(DBInt));
tsTBL->AddField(tsNextStnFLD);
tsInterStnFLD = new DBObjTableField(RGlibInterStation, DBTableFieldFloat, "%9.1f", sizeof(DBFloat4));
tsTBL->AddField(tsInterStnFLD);
fields = tsTBL->Fields();
for (tsTimeFLD = fields->First(); tsTimeFLD != (DBObjTableField *) NULL; tsTimeFLD = fields->Next())
if (tsTimeFLD->Type() == DBTableFieldDate) break;
if (tsTimeFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Date Field!");
return (DBFault);
}
if ((tsJoinFLD = tsTBL->Field(joinFldName)) == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Join Field!");
return (DBFault);
}
fields = new DBObjectLIST<DBObjTableField>("Field List");
fields->Add(new DBObjTableField(*tsTimeFLD));
fields->Add(new DBObjTableField(*tsJoinFLD));
tsTBL->ListSort(fields);
delete fields;
pntTBL = new DBObjTable(*pntTBL);
pntNextFLD = pntTBL->Field(RGlibNextStation);
pntAreaFLD = pntTBL->Field(RGlibArea);
pntInterStnFLD = pntTBL->Field(RGlibInterStation);
pntNewNextFLD = new DBObjTableField("NextStnTS", pntNextFLD->Type(), pntNextFLD->Format(), pntNextFLD->Length());
pntNewInterStnFLD = new DBObjTableField("InterFluTS", pntInterStnFLD->Type(), pntInterStnFLD->Format(),
pntInterStnFLD->Length());
pntRelateFLD = pntTBL->Field(relateFldName);
pntTBL->AddField(pntNewNextFLD);
pntTBL->AddField(pntNewInterStnFLD);
pntTBL->ListSort(pntRelateFLD);
tsIndexRec = tsTBL->First(&tsIndex);
for (tsRec = tsTBL->First(); tsRec != (DBObjRecord *) NULL; tsRec = tsTBL->Next()) {
DBPause(tsRowNum++ * 100 / tsTBL->ItemNum());
date = tsTimeFLD->Date(tsRec);
if (date != curDate) {
if (first) first = false;
else {
for (pntRec = pntTBL->First(); pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next()) {
if ((pntRec->Flags() & DBObjectFlagLocked) != DBObjectFlagLocked) continue;
for (nextPntRec = pntTBL->Item(pntNextFLD->Int(pntRec) - 1);
(nextPntRec != (DBObjRecord *) NULL) &&
((nextPntRec->Flags() & DBObjectFlagLocked) != DBObjectFlagLocked);
nextPntRec = pntTBL->Item(pntNextFLD->Int(nextPntRec) - 1));
if (nextPntRec != (DBObjRecord *) NULL) {
pntNewNextFLD->Int(pntRec, nextPntRec->RowID() + 1);
pntNewInterStnFLD->Float(nextPntRec,
pntNewInterStnFLD->Float(nextPntRec) - pntAreaFLD->Float(pntRec));
}
}
pntRec = pntTBL->First();
for (; tsIndexRec != (DBObjRecord *) NULL; tsIndexRec = tsTBL->Next(&tsIndex)) {
if (tsRec == tsIndexRec) break;
for (; pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next())
if (pntRelateFLD->Int(pntRec) == tsJoinFLD->Int(tsIndexRec)) {
tsNextStnFLD->Int(tsIndexRec, pntNewNextFLD->Int(pntRec));
tsInterStnFLD->Float(tsIndexRec, pntNewInterStnFLD->Float(pntRec));
break;
}
if (pntRec == (DBObjRecord *) NULL) pntRec = pntTBL->First();
}
}
for (pntRec = pntTBL->First(); pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next()) {
pntNewNextFLD->Int(pntRec, 0);
pntNewInterStnFLD->Float(pntRec, pntAreaFLD->Float(pntRec));
pntRec->Flags(DBObjectFlagLocked, DBClear);
}
curDate = date;
//.........这里部分代码省略.........
示例11: RGISAnNetworkStreamLinesCBK
void RGISAnNetworkStreamLinesCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjData *arcData = new DBObjData ("",DBTypeVectorLine);
DBNetworkIF *netIF = new DBNetworkIF (netData);
static Widget fieldSelect = (Widget) NULL;
widget = widget; callData = callData;
if (fieldSelect == (Widget) NULL) fieldSelect = UISelectionCreate ((char *) "Select Field");
if ((selection = UISelectObject (fieldSelect,(DBObjectLIST<DBObject> *) cellTable->Fields (),DBTableFieldIsInteger)) == (char *) NULL)
return;
if ((_RGISAnNetOrderField = cellTable->Field (selection)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError, "Field Selection Error in: %s %d",__FILE__,__LINE__); return; }
arcData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain));
arcData->Document (DBDocSubject,"Stream Lines");
if (UIDataHeaderForm (arcData))
{
DBInt cellID;
char objName [DBStringLength];
DBVLineIF *lineIF = new DBVLineIF (arcData);
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTable *lineTable = arcData->Table (DBrNItems);
DBObjTableField *basinFLD = new DBObjTableField (DBrNBasin,DBTableFieldInt,"%8d",sizeof (DBInt));
DBObjTableField *fieldFLD = new DBObjTableField (_RGISAnNetOrderField->Name (),
_RGISAnNetOrderField->Type (),
_RGISAnNetOrderField->Format (),
_RGISAnNetOrderField->Length ());
DBObjTableField *lengthFLD = new DBObjTableField (RGISNetStreamLength,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4));
DBObjTableField *areaFLD = new DBObjTableField (RGISNetStreamArea,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4));
DBObjTableField *basinAreaFLD = new DBObjTableField (RGISNetBasinArea,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4));
DBObjTableField *nextFLD = new DBObjTableField (RGISNetStreamNext,DBTableFieldInt,"%6d",sizeof (DBInt));
DBObjRecord *cellRec, *toCellRec, *lineRec;
arcData->Projection (netData->Projection ());
arcData->Precision (netData->Precision ());
arcData->MaxScale (netData->MaxScale ());
arcData->MinScale (netData->MinScale ());
lineTable->AddField (basinFLD);
lineTable->AddField (fieldFLD);
lineTable->AddField (lengthFLD);
lineTable->AddField (areaFLD);
lineTable->AddField (basinAreaFLD);
lineTable->AddField (nextFLD);
cellTable->AddField (_RGISAnNetStreamIDFLD = new DBObjTableField ("StreamID",DBTableFieldInt,"%8d",sizeof (DBInt)));
_RGISAnNetStreamID = 0;
UIPauseDialogOpen ((char *) "Creating Stream Lines");
cellID = netIF->CellNum () - 1;
cellRec = netIF->Cell (cellID);
if (lineIF->NewSymbol ("Default Symbol") == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Symbol Creation Error in: %s %d",__FILE__,__LINE__); return; }
for (;cellID >= 0;--cellID)
{
cellRec = netIF->Cell (cellID);
if (((toCellRec = netIF->ToCell (cellRec)) == (DBObjRecord *) NULL) ||
(_RGISAnNetOrderField->Int (cellRec) != _RGISAnNetOrderField->Int (toCellRec)) ||
(netIF->CellOrder (cellRec) != netIF->CellOrder (toCellRec)))
{
if (UIPause ((netIF->CellNum () - cellRec->RowID ()) * 100 / netIF->CellNum ())) goto Stop;
sprintf (objName,"Line: %5d",_RGISAnNetStreamID + 1);
if ((lineRec = lineIF->NewItem (objName)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Line Insertion Error in: %s %d",__FILE__,__LINE__); return; }
nextFLD->Int (lineRec,toCellRec == (DBObjRecord *) NULL ? 0 : _RGISAnNetStreamIDFLD->Int (toCellRec) + 1);
basinFLD->Int (lineRec,netIF->CellBasinID (cellRec));
fieldFLD->Int (lineRec,_RGISAnNetOrderField->Int (cellRec));
_RGISAnNetVertex = 0;
netIF->UpStreamSearch (_RGISAnNetworkCellRec = cellRec,(DBNetworkACTION) _RGISAnNetworkUpStreamAction);
lineIF->FromNode (lineRec,lineIF->Node (netIF->Center (_RGISAnNetworkCellRec),true));
lineIF->ToNode (lineRec,lineIF->Node (netIF->Center (cellRec) + netIF->Delta (cellRec),true));
_RGISAnNetArea = netIF->CellArea (_RGISAnNetworkCellRec);
if (_RGISAnNetVertex > 1)
{
if (_RGISAnNetVertexNum < _RGISAnNetVertex - 1)
{
_RGISAnNetCoord = (DBCoordinate *) realloc (_RGISAnNetCoord,(_RGISAnNetVertex - 1) * sizeof (DBCoordinate));
if (_RGISAnNetCoord == (DBCoordinate *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return; }
}
_RGISAnNetVertex = 0;
netIF->DownStreamSearch (netIF->ToCell (_RGISAnNetworkCellRec),(DBNetworkACTION) _RGISAnNetworkDownStreamAction);
}
else _RGISAnNetVertex = 0;
lineIF->Vertexes (lineRec,_RGISAnNetCoord,_RGISAnNetVertex);
lineIF->ItemSymbol (lineRec,lineIF->Symbol (0));
lengthFLD->Float (lineRec,netIF->CellBasinLength (cellRec));
areaFLD->Float (lineRec,_RGISAnNetArea);
basinAreaFLD->Float (lineRec,netIF->CellBasinArea (cellRec));
_RGISAnNetStreamID += 1;
}
}
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
CMmsgPrint (CMmsgInfo," -V,--verbose");
CMmsgPrint (CMmsgInfo," -h,--help");
return (DBSuccess);
}
if ((argv [argPos][0] == '-') && ((int) 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]);
data = new DBObjData ();
if (((argNum > 1) && (strcmp (argv [1],"-") != 0) ? data->Read (argv [1]) : data->Read (stdin)) == DBFault)
{ delete data; return (CMfailed); }
if (tableName == (char *) NULL) tableName = DBrNItems;
if ((table = data->Table (tableName)) == (DBObjTable *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Invalid table!"); delete data; return (CMfailed); }
if (fieldName == (char *) NULL) fieldName = (char *) "Date";
if ((srcField = table->Field (fieldName)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Missing date field!"); delete data; return (CMfailed); }
if ((srcField->Type () != DBTableFieldString) &&
(srcField->Type () != DBTableFieldDate))
{ CMmsgPrint (CMmsgUsrError,"Invalid date field!"); delete data; return (CMfailed); }
if (yearFieldName != (char *) NULL)
{
if ((yearField = table->Field (yearFieldName)) == (DBObjTableField *) NULL)
{
yearField = new DBObjTableField (yearFieldName,DBTableFieldInt,"%4d",sizeof(DBShort),false);
table->AddField (yearField);
}
}
if (monthFieldName != (char *) NULL)
{
if ((monthField = table->Field (monthFieldName)) == (DBObjTableField *) NULL)
{
monthField = new DBObjTableField (monthFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (monthField);
}
}
if (dayFieldName != (char *) NULL)
{
if (monthField == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Month field is not set!"); delete data; return (CMfailed); }
if ((dayField = table->Field (dayFieldName)) == (DBObjTableField *) NULL)
{
dayField = new DBObjTableField (dayFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (dayField);
}
}
if (hourFieldName != (char *) NULL)
{
if (dayField == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Day field is not set!"); delete data; return (CMfailed); }
if ((hourField = table->Field (hourFieldName)) == (DBObjTableField *) NULL)
{
hourField = new DBObjTableField (hourFieldName,dbInputType,"%2d",dbInputSize,false);
table->AddField (hourField);
}
示例13: RGISAnalyseLineSSampleGridCBK
//.........这里部分代码省略.........
XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameLabel",xmLabelWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, button,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, toNameTextF,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNlabelString, string,
NULL);
XmStringFree (string);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&sample);
}
sample = false;
UIDialogFormPopup (dShell);
while (UILoop ())
{
allowOk = false;
fText = XmTextFieldGetString (fromNameTextF);
if (strlen (fText) > 0) allowOk = true;
XtFree (fText);
fText = XmTextFieldGetString (toNameTextF);
if (strlen (fText) > 0) allowOk = true;
XtFree (fText);
XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
}
UIDialogFormPopdown (dShell);
if (sample)
{
DBInt ret;
DBFloat value;
DBCoordinate coord;
DBGridIF *gridIF = new DBGridIF (grdData);
DBVLineIF *lineIF = new DBVLineIF (dbData);
DBObjTableField *fromField;
DBObjTableField *toField;
DBObjRecord *record;
fText = XmTextFieldGetString (fromNameTextF);
if (strlen (fText) > 0)
{
if ((fromField = itemTable->Field (fText)) == (DBObjTableField *) NULL)
itemTable->AddField (fromField = new DBObjTableField (fText,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4)));
}
else fromField = (DBObjTableField *) NULL;
XtFree (fText);
fText = XmTextFieldGetString (toNameTextF);
if (strlen (fText) > 0)
{
if ((toField = itemTable->Field (fText)) == (DBObjTableField *) NULL)
itemTable->AddField (toField = new DBObjTableField (fText,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4)));
}
else toField = (DBObjTableField *) NULL;
XtFree (fText);
UIPauseDialogOpen ((char *) "Sampling Grid");
for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ())
{
if (UIPause (record->RowID () * 100 / itemTable->ItemNum ())) goto Stop;
if (fromField != (DBObjTableField *) NULL)
{
coord = lineIF->FromCoord (record);
ret = gridIF->Value (coord,&value);
if (fromField->Type () == DBTableFieldFloat)
{
if (ret) fromField->Float (record,value);
else fromField->Float (record,fromField->FloatNoData ());
}
else
{
if (ret) fromField->Int (record,(DBInt) value);
else fromField->Int (record,fromField->IntNoData ());
}
}
if (toField != (DBObjTableField *) NULL)
{
coord = lineIF->ToCoord (record);
ret = gridIF->Value (coord,&value);
if (toField->Type () == DBTableFieldFloat)
{
if (ret) toField->Float (record,value);
else toField->Float (record,toField->FloatNoData ());
}
else
{
if (ret) toField->Int (record,(DBInt) value);
else toField->Int (record,toField->IntNoData ());
}
}
}
Stop:
UIPauseDialogClose ();
delete lineIF;
delete gridIF;
}
}