本文整理汇总了C++中DBObjRecord::RowID方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjRecord::RowID方法的具体用法?C++ DBObjRecord::RowID怎么用?C++ DBObjRecord::RowID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjRecord
的用法示例。
在下文中一共展示了DBObjRecord::RowID方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Trim
int DBNetworkIF::Trim ()
{
DBInt i, row, col;
DBPosition pos, min, max;
DBRegion extent = DataPTR->Extent ();
DBObjRecord *cellRec;
DBCoordinate coord;
min.Row = RowNum ();
min.Col = ColNum ();
max.Row = max.Col = 0;
for (i = 0;i < CellNum ();++i)
{
DBPause (33 * i / CellNum ());
cellRec = CellTable->Item (i);
pos = CellPosition (cellRec);
min.Row = min.Row < pos.Row ? min.Row : pos.Row;
min.Col = min.Col < pos.Col ? min.Col : pos.Col;
max.Row = max.Row > pos.Row ? max.Row : pos.Row;
max.Col = max.Col > pos.Col ? max.Col : pos.Col;
}
for (i = 0;i < CellNum ();++i)
{
DBPause (33 + 33 * i / CellNum ());
cellRec = CellTable->Item (i);
pos = CellPosition (cellRec);
pos.Row = pos.Row - min.Row;
pos.Col = pos.Col - min.Col;
PositionFLD->Position (cellRec,pos);
}
coord.X = min.Col * CellWidth ();
coord.Y = min.Row * CellHeight ();
extent.LowerLeft = extent.LowerLeft + coord;
coord.X = (ColNum () - max.Col - 1) * CellWidth ();
coord.Y = (RowNum () - max.Row - 1) * CellHeight ();
extent.UpperRight = extent.UpperRight - coord;
DataPTR->Extent (extent);
row = max.Row - min.Row + 1;
col = max.Col - min.Col + 1;
RowNumFLD->Int (LayerRecord,row);
ColNumFLD->Int (LayerRecord,col);
DataRec->Realloc (row * col * sizeof (int));
for (row = 0;row < RowNum ();row++) for (col = 0;col < ColNum ();col++)
((DBInt *) DataRec->Data ()) [row * ColNum () + col] = DBFault;
for (i = 0;i < CellNum ();++i)
{
DBPause (67 + 33 * i / CellNum ());
pos = CellPosition (CellTable->Item (i));
((DBInt *) DataRec->Data ()) [pos.Row * ColNum () + pos.Col] = cellRec->RowID ();
}
return (DBSuccess);
}
示例2: Extent
DBRegion DBObjData::Extent(DBObjRecord *record) {
DBRegion extent;
DBCoordinate coord;
DBFloat delta;
DBObjTable *items;
DBObjTableField *field;
if (record == (DBObjRecord *) NULL) return (Extent());
switch (Type()) {
case DBTypeVectorPoint:
delta = pow((double) 10.0, (double) Precision());
items = TablesPTR->Item(DBrNItems);
field = items->Field(DBrNCoord);
coord = field->Coordinate(record);
extent.Expand(coord + delta);
extent.Expand(coord - delta);
return (extent);
case DBTypeVectorLine:
case DBTypeVectorPolygon:
items = TablesPTR->Item(DBrNItems);
field = items->Field(DBrNRegion);
return (field->Region(record));
case DBTypeGridDiscrete:
case DBTypeGridContinuous:
return (Extent());
case DBTypeNetwork: {
DBInt cellID, cellNum;
DBObjRecord *cellRec;
DBNetworkIF *netIF = new DBNetworkIF(this);
cellRec = netIF->MouthCell(record);
cellNum = netIF->CellBasinCells(cellRec) + cellRec->RowID();
for (cellID = cellRec->RowID(); cellID < cellNum; ++cellID) {
cellRec = netIF->Cell(cellID);
extent.Expand(netIF->Center(cellRec) + (netIF->CellSize() / 2.0));
extent.Expand(netIF->Center(cellRec) - (netIF->CellSize() / 2.0));
}
delete netIF;
}
return (extent);
case DBTypeTable:
default:
return (extent);
}
}
示例3: _RGlibSubbasinCategories
static DBInt _RGlibSubbasinCategories(void *io, DBObjRecord *cellRec) {
DBObjRecord *grdRec;
DBNetworkIF *netIF = (DBNetworkIF *) io;
if (cellRec == (DBObjRecord *) NULL) return (false);
grdRec = _RGlibPointGrdIF->GridItem(_RGlibPointGrdLayerRec, netIF->Center(cellRec));
if (grdRec == (DBObjRecord *) NULL) return (true);
_RGlibHistogram[grdRec->RowID()].cellNum++;
_RGlibHistogram[grdRec->RowID()].area += netIF->CellArea(cellRec);
return (true);
}
示例4: _RGISGridLayerListCBK
static void _RGISGridLayerListCBK (Widget widget,void *dummy, XmListCallbackStruct *callData)
{
int item = 0;
DBObjData *data;
DBObjTable *layerTable;
DBObjRecord *record;
XtVaGetValues (widget,XmNuserData, &data, NULL);
layerTable = data->Table (DBrNLayers);
for (record = layerTable->First ();record != (DBObjRecord *) NULL;record = layerTable->Next ())
if (++item == callData->item_position) layerTable->Item (record->RowID (),true);
}
示例5: ColNum
DBObjRecord *DBNetworkIF::CellAdd (DBPosition pos)
{
char nameSTR [DBStringLength];
DBInt dir, fromDir;
DBPosition fromPos;
DBObjRecord *cellRec;
if (pos.Col < 0) return ((DBObjRecord *) NULL);
if (pos.Row < 0) return ((DBObjRecord *) NULL);
if (pos.Col >= ColNum ()) return ((DBObjRecord *) NULL);
if (pos.Row >= RowNum ()) return ((DBObjRecord *) NULL);
if (((DBInt *) DataRec->Data ()) [pos.Row * ColNum () + pos.Col] != DBFault) return ((DBObjRecord *) NULL);
sprintf (nameSTR,"Cell:%6d",CellNum ());
cellRec = CellTable->Add (nameSTR);
((DBInt *) DataRec->Data ()) [pos.Row * ColNum () + pos.Col] = cellRec->RowID ();
PositionFLD->Position (cellRec,pos);
ToCellFLD->Int (cellRec,DBNetDirN);
fromDir = DBNull;
for (dir = 0;dir < 8;++dir)
{
fromPos = pos;
if ((dir == DBNetDirNW) || (dir == DBNetDirN) || (dir == DBNetDirNE)) fromPos.Row++;
if ((dir == DBNetDirSE) || (dir == DBNetDirS) || (dir == DBNetDirSW)) fromPos.Row--;
if ((dir == DBNetDirNE) || (dir == DBNetDirE) || (dir == DBNetDirSE)) fromPos.Col++;
if ((dir == DBNetDirNW) || (dir == DBNetDirW) || (dir == DBNetDirSW)) fromPos.Col--;
if (((DBInt *) DataRec->Data ()) [fromPos.Row * ColNum () + fromPos.Col ] != DBFault) fromDir |= dir;
}
FromCellFLD->Int (cellRec,fromDir);
OrderFLD->Int (cellRec,1);
BasinFLD->Int (cellRec,1);
BasinCellsFLD->Int (cellRec,1);
TravelFLD->Int (cellRec,1);
UpCellPosFLD->Position (cellRec,pos);
CellAreaFLD->Float (cellRec,0.0);
SubbasinLengthFLD->Float (cellRec,0.0);
SubbasinAreaFLD->Float (cellRec,0.0);
return (cellRec);
}
示例6: 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 ();
}
示例7: RGISEditLineDirectionCBK
void RGISEditLineDirectionCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBFloat elev0, elev1;
DBCoordinate coord;
DBObjRecord *lineRec;
DBDataset *dataset = UIDataset ();
DBObjData *lineData = dataset->Data ();
DBObjData *gridData = lineData->LinkedData ();
DBVLineIF *lineIF = new DBVLineIF (lineData);
DBGridIF *gridIF = new DBGridIF (gridData);
UIPauseDialogOpen ((char *) "Changing Directionality");
for (lineRec = lineIF->FirstItem ();lineRec != (DBObjRecord *) NULL;lineRec = lineIF->NextItem ())
{
DBPause (lineRec->RowID () * 100 / lineIF->ItemNum ());
coord = lineIF->FromCoord (lineRec);
if (gridIF->Value (coord,&elev0) == false) continue;
coord = lineIF->ToCoord (lineRec);
if (gridIF->Value (coord,&elev1) == false) continue;
if (elev0 < elev1) lineIF->Flip (lineRec);
}
UIPauseDialogClose ();
}
示例8: 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;
}
}
示例9: 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);
}
示例10: Read
//.........这里部分代码省略.........
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)
{
switch (valueType)
{
case DBTableFieldFloat: value = (DBInt) rint (*((float *) ((char *) dataRec->Data () + i * valueSize))); break;
case DBTableFieldInt:
switch (valueSize)
{
case sizeof (DBByte): value = (DBInt) (*((DBByte *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBShort): value = (DBInt) (*((DBShort *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBInt): value = (DBInt) (*((DBInt *) ((char *) dataRec->Data () + i * valueSize))); break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Type in: %s %d",__FILE__,__LINE__); return (DBFault);
}
sprintf (nameStr,"Category%04d",value);
if ((itemRec = itemTable->Item (nameStr)) == (DBObjRecord *) NULL)
{
if ((itemRec = itemTable->Add (nameStr)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Item Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
gridValueFLD->Int (itemRec,value);
gridSymbolFLD->Record (itemRec,symRec);
}
value = itemRec->RowID ();
switch (valueSize)
{
case sizeof (DBByte): *((DBByte *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBShort): *((DBShort *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBInt): *((DBInt *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
}
}
itemTable->ListSort (gridValueFLD);
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
{
for (i = 0;i < ColNum () * RowNum ();++i)
{
switch (valueSize)
{
case sizeof (DBByte): value = (DBInt) (*((DBByte *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBShort): value = (DBInt) (*((DBShort *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBInt): value = (DBInt) (*((DBInt *) ((char *) dataRec->Data () + i * valueSize))); break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
itemRec = itemTable->Item (value);
value = itemRec->ListPos ();
switch (valueSize)
{
case sizeof (DBByte): *((DBByte *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBShort): *((DBShort *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBInt): *((DBInt *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
}
}
itemTable->ItemSort ();
gridIF = new DBGridIF (data);
gridIF->DiscreteStats ();
delete gridIF;
} break;
case DBTypeGridContinuous:
{
DBObjTableField *missingValueFLD = itemTable->Field (DBrNMissingValue);
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
{
itemTable->Add (dataRec->Name ());
missingValueFLD->Float (itemTable->Item (),MissingValue ());
}
gridIF = new DBGridIF (data);
gridIF->RecalcStats ();
delete gridIF;
data->Flags (DBDataFlagDispModeContBlueRed,DBSet);
break;
}
default: break;
}
return (DBSuccess);
}
示例11: main
int main (int argc,char *argv [])
{
FILE *outFile;
DBInt argPos, argNum = argc, ret;
int objID, size;
DBFloat lCorrection = 1.0;
MFDomain_t *domain = (MFDomain_t *) NULL;
DBCoordinate coord;
DBObjRecord *objRec;
DBObjData *data;
for (argPos = 1;argPos < argNum; )
{
if (CMargTest (argv [argPos],"-l","--lengthcorrection"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing length correction!"); return (CMfailed); }
if (sscanf (argv [argPos],"%lf", &lCorrection) != 1)
{ CMmsgPrint (CMmsgUsrError, "Invalid length correction!"); return (CMfailed); }
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-h","--help"))
{
CMmsgPrint (CMmsgInfo,"%s [options] <input rgisdata> <output domain>",CMprgName(argv[0]));
CMmsgPrint (CMmsgInfo," -l,--lengthcorrection");
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); }
outFile = (argNum > 2) && (strcmp (argv [2],"-") != 0) ? fopen (argv [2],"w") : stdout;
if (outFile == (FILE *) NULL)
{ CMmsgPrint (CMmsgUsrError,"Output file Opening error in: %s",CMprgName(argv[0])); exit (DBFault); }
data = new DBObjData ();
ret = (argNum > 1) && (strcmp (argv [1],"-") != 0) ? data->Read (argv [1]) : data->Read (stdin);
if ((domain = (MFDomain_t *) calloc (1,sizeof (MFDomain_t))) != (MFDomain_t *) NULL)
{
domain->Objects = (MFObject_t *) NULL;
switch (data->Type ())
{
case DBTypeVectorPoint:
{
DBVPointIF *pntIF = new DBVPointIF (data);
domain->ObjNum = pntIF->ItemNum ();
if ((domain->Objects = (MFObject_t *) calloc (domain->ObjNum,sizeof (MFObject_t))) == (MFObject_t *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); MFDomainFree (domain); goto Stop; }
for (objID = 0;objID < domain->ObjNum;++objID)
{
objRec = pntIF->Item (objID);
coord = pntIF->Coordinate (objRec);
domain->Objects [objID].ID = objRec->RowID ();
domain->Objects [objID].DLinkNum = 0;
domain->Objects [objID].ULinkNum = 0;
domain->Objects [objID].DLinks = (size_t *) NULL;
domain->Objects [objID].ULinks = (size_t *) NULL;
domain->Objects [objID].XCoord = domain->Objects [objID].Lon = coord.X;
domain->Objects [objID].YCoord = domain->Objects [objID].Lat = coord.Y;
domain->Objects [objID].Area = 0.0;
domain->Objects [objID].Length = 0.0;
}
} break;
case DBTypeGridContinuous:
case DBTypeGridDiscrete:
{
} break;
case DBTypeNetwork:
{
DBInt dir;
DBObjRecord *nextCell;
DBNetworkIF *netIF = new DBNetworkIF (data);
domain->ObjNum = netIF->CellNum ();
if ((domain->Objects = (MFObject_t *) calloc (domain->ObjNum,sizeof (MFObject_t))) == (MFObject_t *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); MFDomainFree (domain); goto Stop; }
for (objID = 0;objID < domain->ObjNum;++objID)
{
domain->Objects [objID].DLinks = (size_t *) NULL;
domain->Objects [objID].ULinks = (size_t *) NULL;
}
for (objID = 0;objID < domain->ObjNum;++objID)
{
objRec = netIF->Cell (objID);
coord = netIF->Center (objRec);
domain->Objects [objID].ID = objRec->RowID ();
domain->Objects [objID].DLinkNum = 0;
domain->Objects [objID].ULinkNum = 0;
domain->Objects [objID].XCoord = domain->Objects [objID].Lon = coord.X;
domain->Objects [objID].YCoord = domain->Objects [objID].Lat = coord.Y;
domain->Objects [objID].Area = netIF->CellArea (objRec);
domain->Objects [objID].Length = netIF->CellLength (objRec) *lCorrection;
if ((nextCell = netIF->ToCell (objRec)) != (DBObjRecord *) NULL)
//.........这里部分代码省略.........
示例12: RGISAnGNUXYPlotCBK
//.........这里部分代码省略.........
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, button,
XmNlabelString, string,
NULL);
XmStringFree (string);
string = XmStringCreate ((char *) "Logarithmic Scale",UICharSetBold);
toggle = XtVaCreateManagedWidget ("RGISEditCompLogScaleToggle",xmToggleButtonWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, button,
XmNtopOffset, 10,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_FORM,
XmNbottomOffset, 10,
XmNlabelString, string,
XmNhighlightThickness, 0,
XmNshadowThickness, 0,
XmNmarginWidth, 5,
XmNset, False,
NULL);
XmStringFree (string);
XtAddCallback (toggle,XmNvalueChangedCallback,(XtCallbackProc) UIAuxSetToggleCBK, (XtPointer) &logScale);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&plot);
}
plot = false;
XtVaSetValues (field0TextF,XmNuserData, itemTable->Fields (), NULL);
XtVaSetValues (field1TextF,XmNuserData, itemTable->Fields (), NULL);
UIDialogFormPopup (dShell);
while (UILoop ())
{
f0Text = XmTextFieldGetString (field0TextF);
f1Text = XmTextFieldGetString (field1TextF);
allowOk = (strlen (f0Text) > 0) && (strlen (f1Text) > 0);
XtFree (f0Text); XtFree (f1Text);
XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
}
UIDialogFormPopdown (dShell);
if (plot)
{
char buffer [256];
DBInt intVal, rowID;
DBFloat val;
DBObjTableField *field0 = itemTable->Field (f0Text = XmTextFieldGetString (field0TextF));
DBObjTableField *field1 = itemTable->Field (f1Text = XmTextFieldGetString (field1TextF));
DBObjRecord *record;
XtFree (f0Text); XtFree (f1Text);
if ((field0 == (DBObjTableField *) NULL) || (field1 == (DBObjTableField *) NULL))
{ CMmsgPrint (CMmsgAppError, "Invalid Compare Fields in: %s %d",__FILE__,__LINE__); return; }
strcpy (fileName,"ghaasXXXXXX");
if ((fd = mkstemp (fileName)) == DBFault)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }
if ((file = fdopen (fd,"w")) == (FILE *) NULL)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }
fprintf (file,"\"GHAASId\"\t\"RecordName\"\t\"Selected\"\t\"%s\"\t\"%s\"\n",field0->Name (),field1->Name ());
for (rowID = 0;rowID < itemTable->ItemNum ();++rowID)
{
record = itemTable->Item (rowID);
if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
sprintf (buffer,"%d\t\"%s\"\t%d",record->RowID () + 1,record->Name (),
(record->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected ? true : false);
if (field0->Type () == DBTableFieldInt)
{
intVal = field0->Int (record);
if (intVal == field0->IntNoData ()) continue;
sprintf (buffer + strlen (buffer),"\t%d",intVal);
}
else
{
val = field0->Float (record);
if (CMmathEqualValues (val,field0->FloatNoData ())) continue;
sprintf (buffer + strlen (buffer),"\t%f",val);
}
if (field1->Type () == DBTableFieldInt)
{
intVal = field1->Int (record);
if (intVal == field1->IntNoData ()) continue;
sprintf (buffer + strlen (buffer),"\t%d",intVal);
}
else
{
val = field1->Float (record);
if (CMmathEqualValues (val,field1->FloatNoData ())) continue;
sprintf (buffer + strlen (buffer),"\t%f",val);
}
fprintf (file,"%s\n",buffer);
}
fclose (file);
ghaasDir = getenv ("GHAAS_DIR");
sprintf (command,"%s/Scripts/xy-plot.sh %s %s",ghaasDir != (const char *) NULL ? ghaasDir : ".",fileName,logScale ? "log" : "normal");
system (command);
unlink (fileName);
}
}
示例13: RGISAnalysePointSTNPointsCBK
//.........这里部分代码省略.........
XmNbottomAttachment, XmATTACH_FORM,
XmNbottomOffset, 10,
XmNrowColumnType, XmMENU_OPTION,
XmNlabelString, string,
XmNsubMenuId, menu,
NULL);
XmStringFree (string);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&cont);
XtSetSensitive (UIDialogFormGetOkButton (dShell),true);
}
dataset = UIDataset ();
dbData = dataset->Data ();
table = dbData->Table (DBrNItems);
XtVaSetValues (srcTextF,XmNuserData,table->Fields (),NULL);
XtVaSetValues (dstTextF,XmNuserData,table->Fields (),NULL);
XtVaSetValues (cmpTextF,XmNuserData,table->Fields (),NULL);
XtVaSetValues (errTextF,XmNuserData,table->Fields (),NULL);
UIDialogFormPopup (dShell);
cont = false;
while (UILoop ())
{
if ((strlen (srcText = XmTextFieldGetString (srcTextF)) > 0) &&
((field = table->Field (srcText)) != (DBObjTableField *) NULL))
XtSetSensitive (UIDialogFormGetOkButton (dShell),True);
else XtSetSensitive (UIDialogFormGetOkButton (dShell),False);
XtFree (srcText);
if ((strlen (srcText = XmTextFieldGetString (cmpTextF)) > 0) &&
((field = table->Field (srcText)) != (DBObjTableField *) NULL))
{
XtSetSensitive (button,True);
XtSetSensitive (errTextF,True);
XtSetSensitive (menu,True);
}
else
{
XmTextFieldSetString (errTextF,(char *) "");
XtSetSensitive (button,False);
XtSetSensitive (errTextF,False);
XtSetSensitive (menu,False);
}
XtFree (srcText);
}
UIDialogFormPopdown (dShell);
if (cont)
{
char dataName [DBDataNameLen + 5];
DBObjData *netData = dbData->LinkedData ();
sprintf (dataName,"%s STN",dbData->Name ());
dbData = new DBObjData (*dbData);
dbData->Name (dataName);
if (UIDataHeaderForm (dbData))
{
char *dstText;
DBObjTable *groups;
DBObjRecord *pointRec;
srcText = XmTextFieldGetString (srcTextF);
dbData->LinkedData (netData);
table = dbData->Table (DBrNItems);
groups = dbData->Table (DBrNGroups);
for (pointRec = table->First ();pointRec != (DBObjRecord *) NULL;pointRec = table->Next ())
if ((pointRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle)
{
if (groups != (DBObjTable *) NULL)
groups->Delete (groups->Item (pointRec->RowID ()));
table->Delete (pointRec);
pointRec = table->Next (DBBackward);
}
field = table->Field (srcText);
XtFree (srcText);
RGlibPointSTNCoordinates (dbData,field);
UIPauseDialogOpen ((char *) "Moving Points");
RGlibPointSTNCharacteristics (dbData);
UIPauseDialogClose ();
srcText = XmTextFieldGetString (srcTextF);
if (strlen (dstText = XmTextFieldGetString (dstTextF)) > 0)
{
srcText = XmTextFieldGetString (srcTextF);
RGlibGenFuncTopoSubtract (table,RGlibNextStation,srcText,dstText);
XtFree (dstText);
}
if (strlen (dstText = XmTextFieldGetString (errTextF)) > 0)
{
char *cmpText;
srcText = XmTextFieldGetString (srcTextF);
cmpText = XmTextFieldGetString (cmpTextF);
RGlibGenFuncFieldCompare (table,srcText,cmpText,dstText,diffMethod);
XtFree (dstText);
XtFree (cmpText);
}
XtFree (srcText);
UI2DViewRedrawAll ();
workspace->CurrentData (dbData);
}
else delete dbData;
}
}
示例14: RGISEditGridDateLayersCBK
//.........这里部分代码省略.........
XmNuserData, &timeStep,
NULL);
XmStringFree (string);
XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditGridLayersYearButtonCBK,(XtPointer) DBTimeStepMinute);
string = XmStringCreate ((char *) "Time Step:",UICharSetBold);
menu = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepMenu",xmRowColumnWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_FORM,
XmNtopOffset, 10,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_FORM,
XmNbottomOffset, 10,
XmNrowColumnType, XmMENU_OPTION,
XmNlabelString, string,
XmNsubMenuId, menu,
NULL);
XmStringFree (string);
yearTextF = XtVaCreateManagedWidget ("RGISEditGridDateLayersYearTextF",xmTextFieldWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, menu,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, menu,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, menu,
XmNmaxLength, 4,
XmNcolumns, 4,
NULL);
XtAddCallback (yearTextF,XmNvalueChangedCallback,(XtCallbackProc) _RGISEditGridLayersYearTextCBK,yearText);
string = XmStringCreate ((char *) "Begin Year",UICharSetBold);
XtVaCreateManagedWidget ("RGISEditGridDateLayersYearLabel",xmLabelWidgetClass,mainForm,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, menu,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, yearTextF,
XmNrightOffset, 10,
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNbottomWidget, menu,
XmNlabelString, string,
NULL);
XmStringFree (string);
XtSetSensitive (UIDialogFormGetOkButton (dShell),true);
XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&proc);
}
proc = false;
UIDialogFormPopup (dShell);
while (UILoop ())
{ }
UIDialogFormPopdown (dShell);
if (proc)
{
DBInt layerID, year;
DBDate stepDate;
DBGridIF *gridIF = new DBGridIF (dbData);
DBObjRecord *layerRec;
DBDate date;
switch (timeStep)
{
case DBTimeStepYear: stepDate.Set (1); break;
case DBTimeStepMonth: stepDate.Set (0,1); break;
case DBTimeStepDay: stepDate.Set (0,0,1); break;
case DBTimeStepHour: stepDate.Set (0,0,0,1); break;
case DBTimeStepMinute: stepDate.Set (0,0,0,0,1); break;
}
if (sscanf (yearText,"%d",&year) != 1)
{
year = DBDefaultMissingIntVal;
if (((stepDate.Year () > 0) && (gridIF->LayerNum () > 1)) ||
((stepDate.Month () > 0) && (gridIF->LayerNum () > 12)) ||
((stepDate.Day () > 0) && (gridIF->LayerNum () > 365)) ||
((stepDate.Hour () > 0) && (gridIF->LayerNum () > 365 * 24)) ||
((stepDate.Minute () > 0) && (gridIF->LayerNum () > 365 * 24 * 60)))
{
UIMessage ((char *) "Too Many Layers in Dataset");
}
}
UIPauseDialogOpen ((char *) "Labeling Layers");
date.Set (year);
if (stepDate.Month () > 0) date.Set (year,0);
if (stepDate.Day () > 0) date.Set (year,0,0);
if (stepDate.Hour () > 0) date.Set (year,0,0,0);
if (stepDate.Minute () > 0) date.Set (year,0,0,0,0);
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
if (UIPause (layerRec->RowID () * 100 / gridIF->LayerNum ())) goto Stop;
gridIF->RenameLayer (layerRec,date.Get ());
date = date + stepDate;
}
Stop:
UIPauseDialogClose ();
delete gridIF;
}
}