本文整理汇总了C++中DBGridIF类的典型用法代码示例。如果您正苦于以下问题:C++ DBGridIF类的具体用法?C++ DBGridIF怎么用?C++ DBGridIF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBGridIF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UIAuxSetLabelString
void UIAttribView::Draw (DBObjRecord *record)
{
DBObjTableField *field;
DBObjectLIST<DBObjTableField> *fields;
UIXYGraphShell *graphCLS;
if (record == (DBObjRecord *) NULL)
{
Cardinal i, numChildren;
WidgetList rowCols;
UIAuxSetLabelString (ItemNameWGT,(char *) "");
XtVaGetValues (FieldsRowCol,XmNchildren, &rowCols, XmNnumChildren, &numChildren,NULL);
for (i = 0;i < numChildren; ++i)
XmTextFieldSetString (XtNameToWidget (rowCols [i],"UIAttribViewTextField"),(char *) "");
return;
}
UIAuxSetLabelString (ItemNameWGT,record->Name ());
switch (DataPTR->Type ())
{
case DBTypeVectorPoint:
case DBTypeVectorLine:
case DBTypeVectorPolygon:
case DBTypeGridDiscrete:
fields = ItemTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record));
break;
case DBTypeGridContinuous:
{
DBCoordinate coord = *((DBCoordinate *) (record->Data ()));
DBGridIF *gridIF = new DBGridIF (DataPTR);
for (record = ItemTable->First ();record != (DBObjRecord *) NULL;record = ItemTable->Next ())
DrawField (record->Name (),gridIF->ValueString (record,coord));
delete gridIF;
} break;
case DBTypeNetwork:
{
DBObjTable *cellTable = DataPTR->Table (DBrNCells);
DBObjTableField *basinFLD = cellTable->Field (DBrNBasin);
DBObjRecord *basinRec;
if ((basinRec = ItemTable->Item (basinFLD->Int (record) - 1)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "BasinID Error in:%s %d",__FILE__,__LINE__); return; }
DrawField ((char *) "Basin Name",basinRec->Name ());
fields = ItemTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (basinRec));
fields = cellTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record));
} break;
default: break;
}
if ((graphCLS = (UIXYGraphShell *) DataPTR->Display (UIXYGraphShellStr)) != (UIXYGraphShell *) NULL)
graphCLS->Configure (record);
}
示例2: RGISEditGridStatsCBK
void RGISEditGridStatsCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBGridIF *gridIF = new DBGridIF (dbData);
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,dbData->Table (DBrNItems)));
if (dbData->Type () == DBTypeGridContinuous)
gridIF->RecalcStats ();
else gridIF->DiscreteStats ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例3: RGISEditGridRenameLayerCBK
void RGISEditGridRenameLayerCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *layerName;
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBGridIF *gridIF;
if ((layerName = UIGetString ((char *) "Layer Name",DBStringLength)) == (char *) NULL) return;
gridIF= new DBGridIF (dbData);
gridIF->RenameLayer (layerName);
delete gridIF;
workspace->CurrentData (dbData);
}
示例4:
~CMDgrdVariable() {
DBObjData *data;
if (GridIF != (DBGridIF *) NULL) {
data = GridIF->Data();
delete GridIF;
delete data;
}
}
示例5: switch
void DBObjData::RecalcExtent() {
DBRegion extent;
switch (Type()) {
case DBTypeVectorPoint:
case DBTypeVectorLine:
case DBTypeVectorPolygon: {
DBVectorIF *vectorIF = new DBVectorIF(this);
DBInt recordID;
for (recordID = 0; recordID < vectorIF->ItemNum(); ++recordID)
extent.Expand(Extent(vectorIF->Item(recordID)));
delete vectorIF;
}
break;
case DBTypeGridDiscrete:
case DBTypeGridContinuous: {
DBGridIF *gridIF = new DBGridIF(this);
extent.LowerLeft = Extent().LowerLeft;
extent.UpperRight.X = extent.LowerLeft.X + gridIF->ColNum() * gridIF->CellWidth();
extent.UpperRight.Y = extent.LowerLeft.Y + gridIF->RowNum() * gridIF->CellHeight();
delete gridIF;
}
break;
case DBTypeNetwork: {
DBNetworkIF *netIF = new DBNetworkIF(this);
extent.LowerLeft = Extent().LowerLeft;
extent.UpperRight.X = extent.LowerLeft.X + netIF->ColNum() * netIF->CellWidth();
extent.UpperRight.Y = extent.LowerLeft.Y + netIF->RowNum() * netIF->CellHeight();
delete netIF;
}
break;
case DBTypeTable:
default:
return;
}
Extent(extent);
}
示例6: 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 ();
}
示例7: DBPointToGrid
DBInt DBPointToGrid(DBObjData *pntData, DBObjData *netData, DBObjData *grdData) {
DBInt i;
DBPosition pos;
DBObjTable *pntTable = pntData->Table(DBrNItems);
DBObjTable *grdTable = grdData->Table(DBrNItems);
DBObjTable *symTable = grdData->Table(DBrNSymbols);
DBObjectLIST<DBObjTableField> *pntFields = pntTable->Fields();
DBObjTableField *pntFLD;
DBObjTableField *grdAttribFLD;
DBObjTableField *grdFLD = grdTable->Field(DBrNGridValue);
DBObjTableField *symFLD = grdTable->Field(DBrNSymbol);
DBObjRecord *cellRec, *toCell, *pntRec, *itemRec;
DBObjRecord *symRec = symTable->First();
DBVPointIF *pntIF;
DBNetworkIF *netIF;
DBGridIF *grdIF;
pntIF = new DBVPointIF(pntData);
netIF = new DBNetworkIF(netData);
grdIF = new DBGridIF(grdData);
grdIF->RenameLayer(grdIF->Layer((DBInt) 0), (char *) "Subbasins");
for (pos.Row = 0; pos.Row < grdIF->RowNum(); ++pos.Row)
for (pos.Col = 0; pos.Col < grdIF->ColNum(); ++pos.Col) grdIF->Value(pos, DBFault);
for (pntFLD = pntFields->First(); pntFLD != (DBObjTableField *) NULL; pntFLD = pntFields->Next())
if (DBTableFieldIsVisible(pntFLD)) grdTable->AddField(new DBObjTableField(*pntFLD));
for (i = 0; i < pntIF->ItemNum(); ++i) {
DBPause(i * 100 / pntIF->ItemNum());
pntRec = pntIF->Item(i);
if ((pntRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
if ((cellRec = netIF->Cell(pntIF->Coordinate(pntRec))) == (DBObjRecord *) NULL) continue;
itemRec = grdTable->Add(pntRec->Name());
grdFLD->Int(itemRec, pntRec->RowID() + 1);
symFLD->Record(itemRec, symRec);
for (pntFLD = pntFields->First(); pntFLD != (DBObjTableField *) NULL; pntFLD = pntFields->Next())
if ((grdAttribFLD = grdTable->Field(pntFLD->Name())) != (DBObjTableField *) NULL)
switch (pntFLD->Type()) {
case DBTableFieldString:
grdAttribFLD->String(itemRec, pntFLD->String(pntRec));
break;
case DBTableFieldInt:
grdAttribFLD->Int(itemRec, pntFLD->Int(pntRec));
break;
case DBTableFieldFloat:
grdAttribFLD->Float(itemRec, pntFLD->Float(pntRec));
break;
case DBTableFieldDate:
grdAttribFLD->Date(itemRec, pntFLD->Date(pntRec));
break;
}
grdIF->Value(netIF->CellPosition(cellRec), itemRec->RowID());
}
for (i = 0; i < netIF->CellNum(); ++i) {
if ((cellRec = netIF->Cell(i)) == (DBObjRecord *) NULL) continue;
if ((itemRec = grdIF->GridItem(netIF->CellPosition(cellRec))) != (DBObjRecord *) NULL) continue;
if ((toCell = netIF->ToCell(cellRec)) == (DBObjRecord *) NULL) continue;
if ((itemRec = grdIF->GridItem(netIF->CellPosition(toCell))) != (DBObjRecord *) NULL)
grdIF->Value(netIF->CellPosition(cellRec), itemRec->RowID());
}
grdIF->DiscreteStats();
delete pntIF;
delete netIF;
delete grdIF;
return (DBSuccess);
}
示例8: RGPDrawGridContinuous
DBInt RGPDrawGridContinuous (DBInt mode, DBInt *entryNum, DBObjData *grdData)
{
DBInt r, g, b;
DBInt ret, shadeNum, colorNum, scaleMode = 0;
DBPosition pos;
char charBuffer [RGPBufferSIZE], errorMsg [RGPBufferSIZE];
const char *colorMaps [] = { "default", "grey", "blue", "red", "blue-red", "elevation", "custom", NULL };
char colorMap;
const char *scaleModes [] = { "linear", "logarithmic", "square-root", NULL };
RGPColorMapEntry *customColors;
DBFloat value;
float *array, translation [6], min, max, unit = 1.0;
DBRegion extent = grdData->Extent ();
DBObjRecord *layerRec;
DBGridIF *gridIF = new DBGridIF (grdData);
do {
RGPPrintMessage (mode,entryNum,"Grid Layer:");
if (fgets (charBuffer,sizeof (charBuffer) - 2,stdin) == (char *) NULL) { ret = DBFault; goto Stop; }
if ((strlen (charBuffer) > 0) && (charBuffer [strlen (charBuffer) - 1] == '\n'))
charBuffer [strlen (charBuffer) - 1] = '\0';
if ((layerRec = gridIF->Layer (charBuffer)) != NULL) break;
sprintf (errorMsg,"Invalid grid layer [%s]",charBuffer);
if (RGPPrintError (mode,*entryNum,errorMsg)) { ret = DBFault; goto Stop;}
} while (true);
do {
RGPPrintMessage (mode,entryNum,"Colormap [default|grey|blue|red-blue|elevation|custom]:");
if (fgets (charBuffer,sizeof (charBuffer) - 2,stdin) == (char *) NULL) { ret = DBFault; goto Stop; }
if ((strlen (charBuffer) > 0) && (charBuffer [strlen (charBuffer) - 1] == '\n'))
charBuffer [strlen (charBuffer) - 1] = '\0';
if ((colorMap = CMoptLookup (colorMaps,charBuffer,true)) != DBFault) break;
sprintf (errorMsg,"Invalid colormap [%s]",charBuffer);
if (RGPPrintError (mode,*entryNum,errorMsg)) { ret = DBFault; goto Stop; }
} while (true);
switch (colorMap)
{
default:
case 0:
switch (grdData->Flags () & DBDataFlagDispModeFlags)
{
case DBDataFlagDispModeContStandard:
case DBDataFlagDispModeContGreyScale:
shadeNum = RGPSetColorMap (_RGPGreyColors, RGPColorNum (_RGPGreyColors)); break;
case DBDataFlagDispModeContBlueScale:
shadeNum = RGPSetColorMap (_RGPBlueColors, RGPColorNum (_RGPBlueColors)); break;
case DBDataFlagDispModeContBlueRed:
shadeNum = RGPSetColorMap (_RGPBlueRedColors, RGPColorNum (_RGPBlueRedColors)); break;
case DBDataFlagDispModeContElevation:
shadeNum = RGPSetColorMap (_RGPElevationColors, RGPColorNum (_RGPElevationColors)); break;
}
break;
case 1: shadeNum = RGPSetColorMap (_RGPGreyColors, RGPColorNum (_RGPGreyColors)); break;
case 2: shadeNum = RGPSetColorMap (_RGPBlueColors, RGPColorNum (_RGPBlueColors)); break;
case 3: shadeNum = RGPSetColorMap (_RGPRedColors, RGPColorNum (_RGPRedColors)); break;
case 4: shadeNum = RGPSetColorMap (_RGPBlueRedColors, RGPColorNum (_RGPBlueRedColors)); break;
case 5: shadeNum = RGPSetColorMap (_RGPElevationColors, RGPColorNum (_RGPElevationColors)); break;
case 6:
colorNum = 0;
if ((customColors = (RGPColorMapEntry *) calloc (1,sizeof (RGPColorMapEntry))) == (RGPColorMapEntry *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); delete gridIF; return (DBFault); }
do {
RGPPrintMessage (mode,entryNum,"Background Shade [red,green,blue]:");
if (fgets (charBuffer,sizeof (charBuffer) - 2,stdin) == (char *) NULL) { ret = DBFault; goto Stop; }
if (sscanf (charBuffer,"%d,%d,%d",&r,&g,&b) == 3)
{
customColors [colorNum].Red = r;
customColors [colorNum].Green = g;
customColors [colorNum].Blue = b;
colorNum++;
break;
}
else if (RGPPrintError (mode,*entryNum,"Background Color Entry Error")) { ret = DBFault; goto Stop; }
} while (true);
do {
RGPPrintMessage (mode,entryNum,"Color Shade [red,green,blue]:");
if (fgets (charBuffer,sizeof (charBuffer) - 2,stdin) == (char *) NULL) { ret = DBFault; goto Stop; }
if (sscanf (charBuffer,"%d,%d,%d",&r,&g,&b) == 3)
{
if ((customColors = (RGPColorMapEntry *) realloc (customColors,(colorNum + 1) * sizeof (RGPColorMapEntry))) == (RGPColorMapEntry *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); delete gridIF; return (DBFault); }
customColors [colorNum].Red = r;
customColors [colorNum].Green = g;
customColors [colorNum].Blue = b;
colorNum++;
}
else
{
if (colorNum < 3)
{ if (RGPPrintError (mode,*entryNum,"Color Shade Entry Error")) { ret = DBFault; goto Stop; }}
else break;
}
} while (true);
shadeNum = RGPSetColorMap (customColors,colorNum);
free (customColors);
break;
}
if (shadeNum == DBFault) { RGPPrintError (mode,*entryNum,"Colormap Initialization Error") ; ret = DBFault; goto Stop; }
do {
//.........这里部分代码省略.........
示例9: _RGISToolsGridExportARCInfo
int _RGISToolsGridExportARCInfo (DBObjData *data,char *selection)
{
DBInt layerID, i;
FILE *file;
char coverName [11], command [256];
char asciiGrid [FILENAME_MAX];
char attribDef [FILENAME_MAX];
char attribData [FILENAME_MAX];
char amlFile [FILENAME_MAX];
DBGridIF *gridIF = new DBGridIF (data);
DBObjRecord *layerRec;
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
sprintf (asciiGrid,"%s/asciigrid%d.tmp",selection,layerID);
if (DBExportARCGridLayer (data,layerRec,asciiGrid) == DBFault) return (DBFault);
}
if (data->Type () == DBTypeGridDiscrete)
{
sprintf (attribDef,"%s/attrib.def",selection);
if (DBExportARCTableDef (data,DBrNItems,attribDef) == DBFault)
{ unlink (asciiGrid); return (DBFault); }
sprintf (attribData,"%s/attrib.dat",selection);
if (DBExportARCTableData (data,DBrNItems,attribData) == DBFault)
{ unlink (asciiGrid); unlink (attribDef); return (DBFault); }
}
sprintf (amlFile,"%s/grdcreate.aml",selection);
if ((file = fopen (amlFile,"w")) == NULL)
{
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
sprintf (asciiGrid,"%s/asciigrid%d.tmp",selection,layerID);
unlink (asciiGrid);
}
if (data->Type () == DBTypeGridDiscrete) { unlink (attribDef); unlink (attribData); }
CMmsgPrint (CMmsgAppError, "Aml File Creation Error in: %s %d",__FILE__,__LINE__);
return (DBFault);
}
fprintf (file,"&workspace %s\n",selection);
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
strncpy (coverName,layerRec->Name (),sizeof (coverName) - 1);
coverName [sizeof (coverName) - 1] = '\0';
for (i = 0;i < (DBInt) strlen (coverName);++i) if (coverName [i] == '.') coverName [i] = '\0';
for (i = 0;i < (DBInt) strlen (coverName);++i) coverName [i] = tolower (coverName [i]);
sprintf (asciiGrid,"%s/asciigrid%d.tmp",selection,layerID);
if (data->Type () == DBTypeGridContinuous)
fprintf (file,"asciigrid %s g_%s float\n",asciiGrid,coverName);
else
fprintf (file,"asciigrid %s g_%s int\n",asciiGrid,coverName);
if (data->Type () == DBTypeGridDiscrete)
{
fprintf (file,"tables\n");
fprintf (file,"define g_%s.vattr\n",coverName);
fprintf (file,"&r %s\n",attribDef);
fprintf (file,"~\n");
fprintf (file,"alter GridValue\n");
fprintf (file,"value,,,,\n");
fprintf (file,"add\n");
fprintf (file,"&r %s\n",attribData);
fprintf (file,"~\n");
fprintf (file,"q stop\n");
fprintf (file,"joinitem g_%s.vat g_%s.vattr g_%s.vat value count\n",coverName,coverName,coverName);
fprintf (file,"tables\n");
fprintf (file,"select g_%s.vattr\n",coverName);
fprintf (file,"erase g_%s.vattr\ny\n",coverName);
fprintf (file,"q stop\n");
}
}
fclose (file);
if (getenv ("GHAAS_ARC") != NULL)
{
sprintf (command,getenv ("GHAAS_ARC"),amlFile);
system (command);
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
sprintf (asciiGrid,"%s/asciigrid%d.tmp",selection,layerID);
unlink (asciiGrid);
}
if (data->Type () == DBTypeGridDiscrete) { unlink (attribDef); unlink (attribData); }
unlink (amlFile);
}
return (DBSuccess);
}
示例10: DBGridOperation
void DBGridOperation(DBObjData *grdData, DBFloat constant, DBInt oper) {
DBInt layerID;
DBFloat value;
DBPosition pos;
DBObjRecord *layerRec;
DBGridIF *gridIF = new DBGridIF(grdData);
for (layerID = 0; layerID < gridIF->LayerNum(); ++layerID) {
layerRec = gridIF->Layer(layerID);
if ((layerRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) break;
}
if (layerID == gridIF->LayerNum()) {
CMmsgPrint(CMmsgAppError, "No Layer to Process in %s %d", __FILE__, __LINE__);
return;
}
for (layerID = 0; layerID < gridIF->LayerNum(); ++layerID) {
layerRec = gridIF->Layer(layerID);
if ((layerRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (pos.Row = 0; pos.Row < gridIF->RowNum(); pos.Row++) {
if (DBPause((layerID * gridIF->RowNum() + pos.Row) * 100 / (gridIF->LayerNum() * gridIF->RowNum())))
goto Stop;
for (pos.Col = 0; pos.Col < gridIF->ColNum(); pos.Col++) {
if (gridIF->Value(layerRec, pos, &value))
switch (oper) {
case DBMathOperatorAdd:
gridIF->Value(layerRec, pos, value + constant);
break;
case DBMathOperatorSub:
gridIF->Value(layerRec, pos, value - constant);
break;
case DBMathOperatorMul:
gridIF->Value(layerRec, pos, value * constant);
break;
case DBMathOperatorDiv:
gridIF->Value(layerRec, pos, value / constant);
break;
}
}
}
gridIF->RecalcStats(layerRec);
}
Stop:
return;
}
示例11: DBGridOperationAbs
void DBGridOperationAbs(DBObjData *grdData) {
DBInt layerID;
DBFloat value;
DBPosition pos;
DBObjRecord *layerRec;
DBGridIF *gridIF = new DBGridIF(grdData);
for (layerID = 0; layerID < gridIF->LayerNum(); ++layerID) {
layerRec = gridIF->Layer(layerID);
if ((layerRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) break;
}
if (layerID == gridIF->LayerNum()) {
CMmsgPrint(CMmsgAppError, "No Layer to Process in %s %d", __FILE__, __LINE__);
return;
}
for (layerID = 0; layerID < gridIF->LayerNum(); ++layerID) {
layerRec = gridIF->Layer(layerID);
if ((layerRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (pos.Row = 0; pos.Row < gridIF->RowNum(); pos.Row++) {
if (DBPause((layerID * gridIF->RowNum() + pos.Row) * 100 / (gridIF->LayerNum() * gridIF->RowNum())))
goto Stop;
for (pos.Col = 0; pos.Col < gridIF->ColNum(); pos.Col++)
if (gridIF->Value(layerRec, pos, &value)) gridIF->Value(layerRec, pos, fabs(value));
}
gridIF->RecalcStats(layerRec);
}
Stop:
return;
}
示例12: main
int main(int argc, char* argv[])
{
int argPos, argNum = argc, ret, verbose = false;
int layerID;
int shadeSet = DBDataFlagDispModeContGreyScale;
bool changeShadeSet = false;
DBObjData *dbData;
DBGridIF *gridIF;
class RenameCLS
{
public:
DBInt LayerID;
char *LayerName;
RenameCLS *Next;
RenameCLS (DBInt layerID, char * layerName)
{ LayerID = layerID; LayerName = layerName; Next = (RenameCLS *) NULL; }
void AddLink (RenameCLS *renameCLS)
{
if (Next == (RenameCLS *) NULL) Next = renameCLS;
else Next->AddLink (renameCLS);
}
void DeleteLink ()
{
if (Next != (RenameCLS *) NULL) { Next->DeleteLink (); delete Next; }
}
void RenameLayer (DBGridIF *gridIF)
{
DBObjRecord *layerRec;
if ((layerRec = gridIF->Layer (LayerID - 1)) != (DBObjRecord *) NULL) gridIF->RenameLayer (layerRec,LayerName);
if (Next != (RenameCLS *) NULL) Next->RenameLayer (gridIF);
}
} *renameCLS = (RenameCLS *) NULL;
for (argPos = 1;argPos < argNum; )
{
if (CMargTest (argv [argPos],"-r","--rename"))
{
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing layerID!"); return (CMfailed); }
if (sscanf (argv[argPos],"%d",&layerID) != 1)
{
CMmsgPrint (CMmsgUsrError,"Invalid layerID!");
if (renameCLS != (RenameCLS *) NULL) { renameCLS->DeleteLink (); delete renameCLS; }
return (CMfailed);
}
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{
CMmsgPrint (CMmsgUsrError,"Missing layername!");
if (renameCLS != (RenameCLS *) NULL) { renameCLS->DeleteLink (); delete renameCLS; }
return (CMfailed);
}
if (renameCLS == (RenameCLS *) NULL) renameCLS = new RenameCLS (layerID,argv [argPos]);
else renameCLS->AddLink (new RenameCLS (layerID,argv [argPos]));
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
continue;
}
if (CMargTest (argv [argPos],"-s","--shadeset"))
{
int shadeCodes [] = { DBDataFlagDispModeContStandard,
DBDataFlagDispModeContGreyScale,
DBDataFlagDispModeContBlueScale,
DBDataFlagDispModeContBlueRed,
DBDataFlagDispModeContElevation };
const char *shadeSets [] = { "standard","grey","blue","blue-to-red","elevation", (char *) NULL };
if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
{ CMmsgPrint (CMmsgUsrError,"Missing shadeset!"); return (CMfailed); }
if ((shadeSet = CMoptLookup (shadeSets,argv [argPos],true)) == CMfailed)
{ CMmsgPrint (CMmsgUsrError,"Invalid shadeset!"); return (CMfailed); }
shadeSet = shadeCodes [shadeSet];
changeShadeSet = true;
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 grid> <output grid>",CMprgName(argv[0]));
CMmsgPrint (CMmsgInfo," -r,--rename [layerID layerName]");
CMmsgPrint (CMmsgInfo," -s,--shadeset [standard|grey|blue|blue-to-red|elevation]");
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]);
if (renameCLS != (RenameCLS *) NULL) { renameCLS->DeleteLink (); delete renameCLS; }
return (CMfailed);
}
argPos++;
}
//.........这里部分代码省略.........
示例13: RGlibRGIS2DataStream
DBInt RGlibRGIS2DataStream(DBObjData *grdData, DBObjData *tmplData, char *fieldName, FILE *outFile) {
DBInt layerID, ret = DBSuccess, itemSize, itemID;
DBInt intValue;
DBFloat floatValue;
void *data;
MFVarHeader_t varHeader;
DBObjRecord *layerRec, *gridRec;
DBObjTableField *fieldPTR = (DBObjTableField *) NULL;
DBGridIF *gridIF;
DBVPointIF *tmplPntIF = (DBVPointIF *) NULL;
DBGridIF *tmplGrdIF = (DBGridIF *) NULL;
DBNetworkIF *tmplNetIF = (DBNetworkIF *) NULL;
gridIF = new DBGridIF(grdData);
varHeader.Swap = 1;
if (grdData->Type() == DBTypeGridDiscrete) {
DBObjTable *itemTable = grdData->Table(DBrNItems);
if (fieldName == (char *) NULL) fieldName = DBrNGridValue;
if ((fieldPTR = itemTable->Field(fieldName)) == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgAppError, "Error: Invalid field [%s] in: %s %d", fieldName, __FILE__, __LINE__);
return (DBFault);
}
itemSize = fieldPTR->Length();
switch (fieldPTR->Type()) {
case DBTableFieldInt:
switch (itemSize) {
default:
case sizeof(DBByte):
varHeader.DataType = MFByte;
break;
case sizeof(DBShort):
varHeader.DataType = MFShort;
break;
case sizeof(DBInt):
varHeader.DataType = MFInt;
break;
}
varHeader.Missing.Int = fieldPTR->IntNoData();
break;
case DBTableFieldFloat:
switch (itemSize) {
default:
case sizeof(DBFloat4):
varHeader.DataType = MFFloat;
break;
case sizeof(DBFloat):
varHeader.DataType = MFDouble;
break;
}
varHeader.Missing.Float = fieldPTR->FloatNoData();
break;
}
}
else {
if (fieldName != (char *) NULL) CMmsgPrint(CMmsgUsrError, "Warning: Fieldname ignored for continuous grid!");
itemSize = gridIF->ValueSize();
switch (gridIF->ValueType()) {
case DBVariableInt:
switch (itemSize) {
case 1:
varHeader.DataType = MFByte;
break;
case 2:
varHeader.DataType = MFShort;
break;
case 4:
varHeader.DataType = MFInt;
break;
}
varHeader.Missing.Int = (int) gridIF->MissingValue();
break;
case DBVariableFloat:
switch (itemSize) {
case 4:
varHeader.DataType = MFFloat;
break;
case 8:
varHeader.DataType = MFDouble;
break;
}
varHeader.Missing.Float = gridIF->MissingValue();
break;
}
}
if (tmplData == (DBObjData *) NULL) {
tmplGrdIF = gridIF;
varHeader.ItemNum = gridIF->RowNum() * gridIF->ColNum();
}
else {
switch (tmplData->Type()) {
case DBTypeVectorPoint:
tmplPntIF = new DBVPointIF(tmplData);
varHeader.ItemNum = tmplPntIF->ItemNum();
break;
case DBTypeGridContinuous:
case DBTypeGridDiscrete:
tmplGrdIF = new DBGridIF(tmplData);
//.........这里部分代码省略.........
示例14: RGlibDataStream2RGIS
DBInt RGlibDataStream2RGIS(DBObjData *outData, DBObjData *tmplData, FILE *inFile) {
DBInt layerID = 0, itemSize;
DBPosition pos;
DBFloat val;
void *data = (void *) NULL;
MFVarHeader_t header;
DBObjRecord *record;
switch (tmplData->Type()) {
case DBTypeVectorPoint: {
DBInt itemID;
DBDate date;
DBObjTable *itemTable = outData->Table(DBrNItems);
DBObjTableField *idField = new DBObjTableField("ItemID", DBTableFieldInt, "%6d", sizeof(DBInt), false);
DBObjTableField *dateField = new DBObjTableField("Date", DBTableFieldDate, "%s", sizeof(DBDate), false);
DBObjTableField *valField;
DBVPointIF *pntIF = new DBVPointIF(tmplData);
itemTable->AddField(idField);
itemTable->AddField(dateField);
while (MFVarReadHeader(&header, inFile)) {
if (header.ItemNum != pntIF->ItemNum()) {
CMmsgPrint(CMmsgUsrError, "Error: Datastream inconsistency %d %d!", header.ItemNum,
pntIF->ItemNum());
return (DBFault);
}
if (data == (void *) NULL) {
itemSize = MFVarItemSize(header.DataType);
if ((data = (void *) realloc(data, header.ItemNum * itemSize)) == (void *) NULL) {
CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
switch (header.DataType) {
case MFByte:
valField = new DBObjTableField("Value", DBTableFieldInt, "%2d", sizeof(char), false);
case MFShort:
valField = new DBObjTableField("Value", DBTableFieldInt, "%4d", sizeof(DBShort), false);
case MFInt:
valField = new DBObjTableField("Value", DBTableFieldInt, "%8d", sizeof(DBInt), false);
case MFFloat:
valField = new DBObjTableField("Value", DBTableFieldFloat, "%8.2f", sizeof(DBFloat4),
false);
case MFDouble:
valField = new DBObjTableField("Value", DBTableFieldFloat, "%8.2f", sizeof(DBFloat), false);
}
itemTable->AddField(valField);
}
if ((int) fread(data, itemSize, header.ItemNum, inFile) != header.ItemNum) {
CMmsgPrint(CMmsgSysError, "Error: Data stream read in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
for (itemID = 0; itemID < header.ItemNum; ++itemID) {
record = itemTable->Add(header.Date);
date.Set(header.Date);
idField->Int(record, itemID);
dateField->Date(record, date);
/* decDateField->Float (record,date);
*/ switch (header.DataType) {
case MFByte:
valField->Int(record, ((char *) data)[itemID]);
break;
case MFShort:
valField->Int(record, ((short *) data)[itemID]);
break;
case MFInt:
valField->Int(record, ((int *) data)[itemID]);
break;
case MFFloat:
valField->Float(record, ((float *) data)[itemID]);
break;
case MFDouble:
valField->Float(record, ((double *) data)[itemID]);
break;
}
}
}
delete pntIF;
}
break;
case DBTypeGridContinuous:
case DBTypeGridDiscrete: {
DBGridIF *gridIF = new DBGridIF(outData);
while (MFVarReadHeader(&header, inFile)) {
if (header.ItemNum != gridIF->RowNum() * gridIF->ColNum()) {
CMmsgPrint(CMmsgUsrError, "Error: Datastream inconsistency!");
return (DBFault);
}
if (layerID == 0) {
itemSize = MFVarItemSize(header.DataType);
if ((data = (void *) realloc(data, header.ItemNum * itemSize)) == (void *) NULL) {
CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
record = gridIF->Layer(layerID);
gridIF->RenameLayer(header.Date);
}
else record = gridIF->AddLayer(header.Date);
//.........这里部分代码省略.........
示例15: RenameLayer
void RenameLayer (DBGridIF *gridIF)
{
DBObjRecord *layerRec;
if ((layerRec = gridIF->Layer (LayerID - 1)) != (DBObjRecord *) NULL) gridIF->RenameLayer (layerRec,LayerName);
if (Next != (RenameCLS *) NULL) Next->RenameLayer (gridIF);
}