当前位置: 首页>>代码示例>>C++>>正文


C++ DBObjectLIST::Add方法代码示例

本文整理汇总了C++中DBObjectLIST::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjectLIST::Add方法的具体用法?C++ DBObjectLIST::Add怎么用?C++ DBObjectLIST::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObjectLIST的用法示例。


在下文中一共展示了DBObjectLIST::Add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _RGISGrpPanelNewCBK

static void _RGISGrpPanelNewCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)

	{
	char *groupName;
	DBDataset *dataset = UIDataset ();
	DBObjData *dbData  = dataset->Data ();
	DBObjTable *groupTable = dbData->Table (DBrNGroups);
	DBObjTableField *group;
	DBObjRecord *record;

	if ((groupName = UIGetString ((char *) "Group Name",16)) == (char *) NULL) return;
	if (groupTable == (DBObjTable *) NULL)
		{
		DBObjTable *items  = dbData->Table (DBrNItems);
		DBObjectLIST<DBObjTable> *tables  = dbData->Tables ();

		DBTableFieldDefinition fieldDefs [] =	{
					DBTableFieldDefinition (groupName,	DBTableFieldInt,(char *) 	"%1d",sizeof (DBByte)),
					DBTableFieldDefinition () };
		tables->Add (groupTable = new DBObjTable (DBrNGroups,fieldDefs));
		grpPanel->Groups (groupTable->Fields ());
		group = groupTable->Field (groupName);
		for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
			group->Int (groupTable->Add (record->Name ()),true);
		}
	else
		{
		groupTable->AddField (group = new DBObjTableField (groupName,DBTableFieldInt,"%1d",sizeof (DBByte)));
		for (record = groupTable->First ();record != (DBObjRecord *) NULL;record = groupTable->Next ())
			group->Int (record,true);
		}
	grpPanel->Add (group);
	}
开发者ID:gyelnats,项目名称:RGIS,代码行数:33,代码来源:RGISPanels.C

示例2: Vertexes

void DBVLineIF::Vertexes (DBObjRecord *lineRec,DBCoordinate *coord,DBInt vertexNum)

	{
	DBInt vertex;
	DBFloat length = 0;
	DBCoordinate *vertexes, prevCoord;
	DBObjRecord *dataRec = (DBObjRecord *) NULL;
	DBObjectLIST<DBObjRecord> *dataArrays = Data ()->Arrays ();
	DBRegion lineExtent, dataExtent = Data ()->Extent ();
	DBMathDistanceFunction distFunc = DBMathGetDistanceFunction (Data ());

	prevCoord = NodeCoordFLD->Coordinate (FromNodeFLD->Record (lineRec));
	lineExtent.Expand (prevCoord);
	if (vertexNum > 0)
		{
		if ((dataRec = dataArrays->Item (lineRec->RowID ())) == (DBObjRecord *) NULL)
			{
			if ((dataRec = new DBObjRecord (lineRec->Name (),((size_t) vertexNum) * sizeof (DBCoordinate),sizeof (DBFloat))) == (DBObjRecord *) NULL) return;
			dataArrays->Add (dataRec);
			}
		else	dataRec->Realloc (vertexNum * sizeof (DBCoordinate));
		if ((vertexes = (DBCoordinate *) dataRec->Data ()) == NULL)
			{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return; }
		for (vertex = 0;vertex < vertexNum;vertex++)
			{
			lineExtent.Expand (vertexes [vertex] = coord [vertex]);
			length += DBMathCoordinateDistance (distFunc,prevCoord,coord [vertex]);
			prevCoord = coord [vertex];
			}
		}
	VertexesFLD->Record (lineRec,dataRec);
	VertexNumFLD->Int (lineRec,vertexNum);
	length += DBMathCoordinateDistance (distFunc,prevCoord,NodeCoordFLD->Coordinate (ToNodeFLD->Record (lineRec)));
	PerimeterFLD->Float (lineRec,length);
	lineExtent.Expand (NodeCoordFLD->Coordinate (ToNodeFLD->Record (lineRec)));
	ExtentFLD->Region (lineRec,lineExtent);
	dataExtent.Expand (lineExtent);
	Data ()->Extent (dataExtent);
	}
开发者ID:bandi13,项目名称:RGIS,代码行数:39,代码来源:DBVLineMisc.C

示例3: RGISAnalyseLineMSampleGridCBK

void RGISAnalyseLineMSampleGridCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)

	{
	DBInt layerID, layerNum;
	DBCoordinate coord;
	DBFloat realValue;
	DBDataset *dataset  = UIDataset ();
	DBObjData *dbData  = dataset->Data ();
	DBObjData *grdData  = dbData->LinkedData ();
	DBObjData *tblData;
	DBObjTable *table, *itemTable = dbData->Table (DBrNItems);
	DBObjTableField *lineIDFLD;
	DBObjTableField *layerIDFLD;
	DBObjTableField *layerNameFLD;
	DBObjTableField *fromValueFLD = (DBObjTableField *) NULL;
	DBObjTableField *toValueFLD = (DBObjTableField *) NULL;
	DBVLineIF	*lineIF = (DBVLineIF *)	 NULL;
	DBGridIF *gridIF;
	DBObjRecord *record, *layerRec, *tblRec;
	DBObjectLIST<DBObjTableField> *fields;

	widget = widget; callData = callData;

	gridIF = new DBGridIF (grdData);
	for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
		{
		layerRec = gridIF->Layer (layerID);
		if ((layerRec->Flags () & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
		}
	if (layerNum < 1)
		{ CMmsgPrint (CMmsgAppError, "No Layer to Process in: %s %d",__FILE__,__LINE__); delete gridIF; return; }


	tblData  = new DBObjData ("",DBTypeTable);
	tblData->Document (DBDocGeoDomain,dbData->Document (DBDocGeoDomain));
	tblData->Document (DBDocSubject,grdData->Document (DBDocSubject));

	if (UIDataHeaderForm (tblData) == false) { delete gridIF; delete tblData; return; }
	table = tblData->Table (DBrNItems);

	lineIF = new DBVLineIF (dbData);

	table->AddField (lineIDFLD =		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 (fromValueFLD =	new DBObjTableField (RGISLineFromNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4)));
	table->AddField (toValueFLD =		new DBObjTableField (RGISLineToNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4)));

	grdData->Flags (DBObjectFlagProcessed,DBSet);
	UIPauseDialogOpen ((char *) "Sampling Grid(s)");
	for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
		{
		layerRec = gridIF->Layer (layerID);
		if ((layerRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
		for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ())
			{
			if (UIPause ((layerRec->RowID () * itemTable->ItemNum () + record->RowID ()) * 100 / (itemTable->ItemNum () * gridIF->LayerNum ()))) goto Stop;
			if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
			tblRec = table->Add (record->Name ());
			lineIDFLD->Int (tblRec,record->RowID () + 1);
			layerIDFLD->Int (tblRec,layerRec->RowID ());
			layerNameFLD->String (tblRec,layerRec->Name ());
			coord = lineIF->FromCoord (record);
			if (gridIF->Value (layerRec,coord,&realValue))
				fromValueFLD->Float (tblRec,realValue);
			coord = lineIF->ToCoord (record);
			if (gridIF->Value (layerRec,coord,&realValue))
				toValueFLD->Float (tblRec,realValue);
			}
		}
Stop:
	UIPauseDialogClose ();
	delete gridIF;
	delete lineIF;

	fields = new DBObjectLIST<DBObjTableField> ("Field List");
	fields->Add (new DBObjTableField (*lineIDFLD));
	fields->Add (new DBObjTableField (*layerIDFLD));
	table->ListSort (fields);
	workspace->CurrentData  (tblData);
	delete fields;
	}
开发者ID:amiara,项目名称:RGIS,代码行数:82,代码来源:RGISAnLine.C

示例4: DBImportARCLine

int DBImportARCLine (DBObjData *vecData,const char *arcCov)

	{
	FILE *inFile;
	DBInt arcNum, vertex, swap = DBByteOrder (DBByteOrderLITTLE), floatCov;
	char fileName [DBDataFileNameLen], objName [DBStringLength];
	short infoHeader [50];
	DBARCRecord arcRecord;
	DBObjTable  *lines;
	DBObjTable  *nodes;
	DBObjectLIST<DBObjRecord> *data;
	DBObjRecord *lineRec, *nodeRec, *dataRec;
	DBRegion dataExtent = vecData->Extent (), itemExtent;

	DBObjTableField *fromNodeFLD;
	DBObjTableField *toNodeFLD;
	DBObjTableField *leftPolyFLD;
	DBObjTableField *rightPolyFLD;
	DBObjTableField *vertexesFLD;
	DBObjTableField *vertexNumFLD;
	DBObjTableField *extentFLD;
	
	DBObjTableField *coordFLD;
	DBObjTableField *linkNumFLD;
	DBCoordinate *vertexes, nodeCoord;
	DBFloat4 floatVAR [2];

	switch (vecData->Type ())
		{
		case DBTypeVectorLine:		lines = vecData->Table (DBrNItems);		break;
		case DBTypeVectorPolygon:	lines = vecData->Table (DBrNContours);	break;
		default: CMmsgPrint (CMmsgAppError, "Invalide Vector Data Type in: %s %d",__FILE__,__LINE__); return (DBFault);
		}

	fromNodeFLD	= lines->Field (DBrNFromNode);
	toNodeFLD	= lines->Field (DBrNToNode);
	leftPolyFLD	= lines->Field (DBrNLeftPoly);
	rightPolyFLD= lines->Field (DBrNRightPoly);
	vertexesFLD	= lines->Field (DBrNVertexes);
	vertexNumFLD= lines->Field (DBrNVertexNum);
	extentFLD	= lines->Field (DBrNRegion);

	nodes = vecData->Table (DBrNNodes);	
	coordFLD		= nodes->Field (DBrNCoord);
	linkNumFLD	= nodes->Field (DBrNLinkNum);
	data = vecData->Arrays ();
	
	sprintf (fileName,"%s/arc",arcCov);	
	if (access (fileName,R_OK) == DBFault) sprintf (fileName,"%s/arc.adf",arcCov);

	if ((inFile = fopen (fileName,"r")) == NULL)
		{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
	if (fread (infoHeader,sizeof (short),50,inFile) != 50)
		{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
	
	arcNum = 0;			
	for (lineRec = lines->First ();arcRecord.Read (inFile,swap) != DBFault;lineRec = lines->Next ())
		{
		if (lineRec == NULL)
			{
			sprintf (objName,"Line: %5d",arcRecord.ID () + 1);
			if ((lineRec = lines->Add (objName)) == (DBObjRecord *) NULL)	return (DBFault);
			}
		else DBPause ((++arcNum * 100) / lines->ItemNum ());
		
		floatCov = arcRecord.RecordLength () - 12 == arcRecord.NumOfPnts () * (DBInt) sizeof (float) ? true : false;
		while (arcRecord.FromNode () > nodes->ItemNum ())
			{
			sprintf (objName,"Node: %5d",nodes->ItemNum () + 1);
			nodes->Add (objName);
			if ((nodeRec = nodes->Item ()) == NULL) return (DBFault);
			linkNumFLD->Int (nodeRec,0);
			}
		if ((nodeRec = nodes->Item (arcRecord.FromNode () - 1)) == (DBObjRecord *) NULL)
			{ CMmsgPrint (CMmsgAppError, "Node Not Found in: %s %d",__FILE__,__LINE__); return (DBFault); }
		if (floatCov)
			{
			if (fread (floatVAR,sizeof (floatVAR),1,inFile) != 1)
				{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
			if (swap)	{ DBByteOrderSwapWord (floatVAR); DBByteOrderSwapWord (floatVAR + 1); }
			nodeCoord.X = (DBFloat) floatVAR [0];
			nodeCoord.Y = (DBFloat) floatVAR [1];
			}
		else
			{
			if (fread (&nodeCoord,sizeof (DBCoordinate),1,inFile) != 1)
				{ CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
			if (swap) nodeCoord.Swap ();
			}
		coordFLD->Coordinate (nodeRec,nodeCoord);
		fromNodeFLD->Record	(lineRec,nodeRec);
		if (leftPolyFLD  != (DBObjTableField *) NULL) leftPolyFLD->Record  (lineRec,arcRecord.LeftPoly  ());
		if (rightPolyFLD != (DBObjTableField *) NULL) rightPolyFLD->Record (lineRec,arcRecord.RightPoly ());
		itemExtent.LowerLeft	 = nodeCoord;
		itemExtent.UpperRight = nodeCoord;
		linkNumFLD->Int (nodeRec,linkNumFLD->Int (nodeRec) + 1);
		if (arcRecord.NumOfPnts () > 2)
			{
			if ((dataRec = data->Item (lineRec->RowID ())) == (DBObjRecord *) NULL)
				{
//.........这里部分代码省略.........
开发者ID:rjs80,项目名称:RGIS,代码行数:101,代码来源:DBImpARCLine.C

示例5: DBObject

UI2DView::UI2DView () : DBObject ("Noname 2DView",sizeof (UI2DView))

	{
	char name [DBStringLength];
	Widget menuBar, scrolledWindow, radioBox;
	Widget button;
	static Pixmap iconPixmap	 = (Pixmap) NULL, meshPixmap	 = (Pixmap) NULL;
	static Pixmap fullPixmap	 = (Pixmap) NULL, extentPixmap = (Pixmap) NULL;
	static Pixmap capturePixmap = (Pixmap) NULL, redrawPixmap = (Pixmap) NULL;
	static Pixmap zoomPixmap	 = (Pixmap) NULL, panePixmap	 = (Pixmap) NULL, userPixmap	 = (Pixmap) NULL;
	Pixel foreground, background;
	XWindowAttributes xwa;
	XSetWindowAttributes xswa;
	Atom deleteWindowAtom = XmInternAtom(XtDisplay(UITopLevel ()),(char *) "WM_DELETE_WINDOW",FALSE);

	_UI2DViewLIST.Add (this); sprintf (name,"2DView:%2d",RowID ()); Name (name);
	Image = (XImage *) NULL;
	DrawRegion = FullRegion = NULL;
	MaxVertexNumVAR = 0;
	PointARR = (XPoint *) NULL;
	RequiredEXT = (UIDataset ())->Extent ();
	DShell = XtVaCreatePopupShell ("UI2DView",xmDialogShellWidgetClass,UITopLevel (),
												XmNkeyboardFocusPolicy,		XmPOINTER,
												XmNtitle,						Name (),
												XmNtransient,					false,
												XmNminWidth,					600,
												XmNminHeight,					450,
												NULL);
	XmAddWMProtocolCallback (DShell,deleteWindowAtom,(XtCallbackProc) _UI2DViewDeleteCBK,(XtPointer) this);
	MainFormW = XtVaCreateManagedWidget ("UI2DViewForm",xmFormWidgetClass,DShell,
												XmNdialogStyle,				XmDIALOG_WORK_AREA,
												XmNshadowThickness,			0,
												XmNwidth,						600,
												XmNheight,						450,
												NULL);
	menuBar = XtVaCreateManagedWidget ("UI2DViewMenuBar",xmRowColumnWidgetClass,MainFormW,
												XmNtopAttachment,				XmATTACH_FORM,
												XmNtopOffset,					2,
												XmNleftAttachment,			XmATTACH_FORM,
												XmNleftOffset,					2,
												XmNrightAttachment, 			XmATTACH_FORM,
												XmNrightOffset,				2,
												XmNorientation,				XmHORIZONTAL,
												XmNrowColumnType,				XmWORK_AREA,
												NULL);
	XtVaGetValues (MainFormW,XmNforeground,	&foreground,XmNbackground,	&background,NULL);

	iconPixmap = iconPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen (UITopLevel()),(char *) "GHAAS2Dview.bmp",foreground,background): iconPixmap;
	XtVaSetValues (DShell,XmNiconPixmap, iconPixmap,NULL);

	fullPixmap = fullPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASfull.bmp",  foreground,background) : fullPixmap;
	extentPixmap = extentPixmap  == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASextent.bmp",foreground,background) : extentPixmap;
	capturePixmap= capturePixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAAScapture.bmp",foreground,background):capturePixmap;
	redrawPixmap = redrawPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASredraw.bmp", foreground,background) : redrawPixmap;
	zoomPixmap = zoomPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASzoom.bmp",  foreground,background) : zoomPixmap;
	panePixmap = panePixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASpane.bmp",  foreground,background) : panePixmap;
	userPixmap = userPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASuser.bmp",  foreground,background) : userPixmap;
	meshPixmap = meshPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASmesh.bmp",  foreground,background) : meshPixmap;

	button = XtVaCreateManagedWidget ("UI2DViewRedrawButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				redrawPixmap,
												NULL);
	XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewRedrawCBK,this);
	button = XtVaCreateManagedWidget ("UI2DViewFullButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				fullPixmap,
												NULL);
	XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewFullActivateCBK,this);
	button = XtVaCreateManagedWidget ("UI2DViewExtentButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				extentPixmap,
												NULL);
	XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewExtentActivateCBK,this);
	button = XtVaCreateManagedWidget ("UI2DViewCaptureButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				capturePixmap,
												NULL);
	radioBox = XtVaCreateManagedWidget ("UI2DViewRadioBox",xmRowColumnWidgetClass,menuBar,
												XmNorientation,				XmHORIZONTAL,
												XmNpacking,						XmPACK_COLUMN,
												XmNisHomogeneous,				true,
												XmNentryClass,					xmToggleButtonGadgetClass,
												XmNradioBehavior,				true,
												NULL);
	ZoomToggle = XtVaCreateManagedWidget ("UI2DViewZoomToggle",xmToggleButtonGadgetClass,radioBox,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				zoomPixmap,
												XmNshadowThickness,			0,
												XmNset,							true,
												NULL);
//.........这里部分代码省略.........
开发者ID:bandi13,项目名称:RGIS,代码行数:101,代码来源:UI2DView.C

示例6: main


//.........这里部分代码省略.........
        }
        if (CMargTest (argv[argPos], "-d", "--domain")) {
            if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
                CMmsgPrint(CMmsgUsrError, "Missing domain!");
                return (CMfailed);
            }
            domain = argv[argPos];
            if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) break;
            continue;
        }
        if (CMargTest (argv[argPos], "-v", "--version")) {
            if ((argNum = CMargShiftLeft(argPos, argv, argNum)) <= argPos) {
                CMmsgPrint(CMmsgUsrError, "Missing version!");
                return (CMfailed);
            }
            version = 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      [ table name ]");
            CMmsgPrint(CMmsgInfo, "     -A,--ascending  [ fieldname ]");
            CMmsgPrint(CMmsgInfo, "     -D,--descending [ fieldname ]");
            CMmsgPrint(CMmsgInfo, "     -t,--title      [dataset title]");
            CMmsgPrint(CMmsgInfo, "     -u,--subject    [subject]");
            CMmsgPrint(CMmsgInfo, "     -d,--domain     [domain]");
            CMmsgPrint(CMmsgInfo, "     -v,--version    [version]");
            CMmsgPrint(CMmsgInfo, "     -V,--verbose");
            CMmsgPrint(CMmsgInfo, "     -h,--help");
            if (fields != (CMDtblSortField *) NULL) free(fields);
            return (DBSuccess);
        }
        if ((argv[argPos][0] == '-') && ((int) strlen(argv[argPos]) > 1)) {
            CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
            if (fields != (CMDtblSortField *) NULL) free(fields);
            return (CMfailed);
        }
        argPos++;
    }

    if (argNum > 3) {
        CMmsgPrint(CMmsgUsrError, "Extra arguments!");
        if (fields != (CMDtblSortField *) NULL) free(fields);
        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) {
        if (fields != (CMDtblSortField *) NULL)free(fields);
        delete data;
        return (CMfailed);
    }

    if (title != (char *) NULL) data->Name(title);
    if (subject != (char *) NULL) data->Document(DBDocSubject, subject);
    if (domain != (char *) NULL) data->Document(DBDocGeoDomain, domain);
    if (version != (char *) NULL) data->Document(DBDocVersion, version);

    if (tableName == (char *) NULL) tableName = DBrNItems;

    if ((table = data->Table(tableName)) == (DBObjTable *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Invalid table!");
        if (fields != (CMDtblSortField *) NULL) free(fields);
        delete data;
        return (CMfailed);
    }

    if (fields != (CMDtblSortField *) NULL) {
        DBInt fieldID;
        fieldList = new DBObjectLIST<DBObjTableField>("Fields");
        for (fieldID = 0; fieldID < fieldNum; ++fieldID) {
            if ((fieldPTR = table->Field(fields[fieldID].FieldName())) == (DBObjTableField *) NULL) {
                CMmsgPrint(CMmsgUsrError, "Invalid field: %s!", fields[fieldID].FieldName());
                free(fields);
                return (CMfailed);
            }
            if (fields[fieldID].Ascending())
                fieldPTR->Flags(DBObjectFlagSortReversed, DBClear);
            else fieldPTR->Flags(DBObjectFlagSortReversed, DBSet);
            fieldList->Add(new DBObjTableField(*fieldPTR));
        }
        table->ListSort(fieldList);
        table->ItemSort();
        delete fieldList;
        free(fields);
    }
    ret = (argNum > 2) && (strcmp(argv[2], "-") != 0) ? data->Write(argv[2]) : data->Write(stdout);

    delete data;
    if (verbose) RGlibPauseClose();
    return (ret);
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例7: 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);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:89,代码来源:RGlibPoint.C

示例8: RGlibPointSubbasinStats

DBInt RGlibPointSubbasinStats(DBObjData *pntData, DBObjData *netData, DBObjData *grdData, DBObjData *tblData) {
    DBInt layerID, layerNum = 0, progress = 0, maxProgress;
    DBObjTable *table;
    DBObjTableField *pointIDFLD;
    DBObjTableField *layerIDFLD;
    DBObjTableField *layerNameFLD;
    DBObjTableField *minimumFLD;
    DBObjTableField *maximumFLD;
    DBObjTableField *averageFLD;
    DBObjTableField *stdDevFLD;
    DBObjTableField *areaFLD;
    DBVPointIF *pntIF;
    DBNetworkIF *netIF;
    DBObjRecord *pntRec, *tblRec;
    DBObjectLIST<DBObjTableField> *fields;

    _RGlibPointGrdIF = new DBGridIF(grdData);
    for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
        _RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
        if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
    }
    if (layerNum < 1) {
        CMmsgPrint(CMmsgUsrError, "No Layer to Process!");
        delete _RGlibPointGrdIF;
        return (DBFault);
    }

    table = tblData->Table(DBrNItems);
    pntIF = new DBVPointIF(pntData);
    netIF = new DBNetworkIF(netData);

    table->AddField(pointIDFLD = new DBObjTableField("GHAASPointID", DBTableFieldInt, "%8d", sizeof(DBInt)));
    table->AddField(layerIDFLD = new DBObjTableField("LayerID", DBTableFieldInt, "%4d", sizeof(DBShort)));
    table->AddField(layerNameFLD = new DBObjTableField("LayerName", DBTableFieldString, "%s", DBStringLength));
    table->AddField(averageFLD = new DBObjTableField(RGlibPointMean, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
                                                     sizeof(DBFloat4)));
    table->AddField(minimumFLD = new DBObjTableField(RGlibPointMin, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
                                                     sizeof(DBFloat4)));
    table->AddField(maximumFLD = new DBObjTableField(RGlibPointMax, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
                                                     sizeof(DBFloat4)));
    table->AddField(
            stdDevFLD = new DBObjTableField(RGlibPointStdDev, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
                                            sizeof(DBFloat4)));
    table->AddField(areaFLD = new DBObjTableField(RGlibPointArea, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
                                                  sizeof(DBFloat4)));

    grdData->Flags(DBObjectFlagProcessed, DBSet);
    maxProgress = pntIF->ItemNum() * _RGlibPointGrdIF->LayerNum();
    for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
        _RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
        if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
        for (pntRec = pntIF->FirstItem(); pntRec != (DBObjRecord *) NULL; pntRec = pntIF->NextItem()) {
            if (DBPause(progress * 100 / maxProgress)) goto Stop;
            progress++;
            if ((pntRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
            tblRec = table->Add(pntRec->Name());
            pointIDFLD->Int(tblRec, pntRec->RowID() + 1);
            layerIDFLD->Int(tblRec, _RGlibPointGrdLayerRec->RowID());
            layerNameFLD->String(tblRec, _RGlibPointGrdLayerRec->Name());
            _RGlibSubbasinArea = 0.0;
            _RGlibSubbasinMin = DBHugeVal;
            _RGlibSubbasinMax = -DBHugeVal;
            _RGlibSubbasinMean = 0.0;
            _RGlibSubbasinStdDev = 0.0;
            netIF->UpStreamSearch(netIF->Cell(pntIF->Coordinate(pntRec)), (DBNetworkACTION) _RGlibSubbasinStatistics);
            _RGlibSubbasinMean = _RGlibSubbasinMean / _RGlibSubbasinArea;
            _RGlibSubbasinStdDev = _RGlibSubbasinStdDev / _RGlibSubbasinArea;
            _RGlibSubbasinStdDev = _RGlibSubbasinStdDev - _RGlibSubbasinMean * _RGlibSubbasinMean;
            _RGlibSubbasinStdDev = sqrt(_RGlibSubbasinStdDev);
            minimumFLD->Float(tblRec, _RGlibSubbasinMin);
            maximumFLD->Float(tblRec, _RGlibSubbasinMax);
            averageFLD->Float(tblRec, _RGlibSubbasinMean);
            stdDevFLD->Float(tblRec, _RGlibSubbasinStdDev);
            areaFLD->Float(tblRec, _RGlibSubbasinArea);
        }
    }
    Stop:
    delete _RGlibPointGrdIF;
    delete netIF;
    delete pntIF;

    if (progress == maxProgress) {
        fields = new DBObjectLIST<DBObjTableField>("Field List");
        fields->Add(new DBObjTableField(*pointIDFLD));
        fields->Add(new DBObjTableField(*layerIDFLD));
        table->ListSort(fields);
        delete fields;
        return (DBSuccess);
    }
    return (DBFault);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:91,代码来源:RGlibPoint.C

示例9: 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;
//.........这里部分代码省略.........
开发者ID:bmfekete,项目名称:RGIS,代码行数:101,代码来源:RGlibPoint.C

示例10: main


//.........这里部分代码省略.........
			}
		if ((argv[argPos][0] == '-') && (strlen (argv[argPos]) > 1))
			{ CMmsgPrint (CMmsgUsrError, "Unknown option: %s!",argv[argPos]); return (CMfailed); }
		argPos++;
		}

	if(outFile == (FILE *) NULL) outFile = stdout;
	if(head->next == (FieldOptions *) NULL) return(DBSuccess);

	inData = new DBObjData();
	if ((argNum > 1) && (strcmp(argv[1],"-") != 0)) inData->Read(argv[1]);
	else inData->Read(stdin);

	if (outData->Name() == (char *) NULL) outData->Name("Untitled");
	if (outData->Document(DBDocSubject) == (char *) NULL) outData->Document(DBDocSubject,inData->Document(DBDocSubject));
	if (outData->Document(DBDocGeoDomain) == (char *) NULL) outData->Document(DBDocGeoDomain,inData->Document(DBDocGeoDomain));
	if (outData->Document(DBDocVersion) == (char *) NULL) outData->Document(DBDocVersion,inData->Document(DBDocVersion));

	if(tableName == (char *) NULL) tableName = DBrNItems;
	if((inTable = inData->Table(tableName)) == (DBObjTable *) NULL)
		{ CMmsgPrint (CMmsgUsrError,"Invalid table!"); delete inData; return (CMfailed); }

	if((groups = (Groups **) malloc(numGrpNames * sizeof(Groups *))) == (Groups **) NULL)
		{ CMmsgPrint (CMmsgSysError, "Memory allocation error in: %s %d",__FILE__,__LINE__); return(DBFault); }
	for(i = 0; i < numGrpNames; i++)
		{
		if((field = inTable->Field(groupnames[i])) == (DBObjTableField *) NULL)
			{ CMmsgPrint (CMmsgUsrError, "Invalid group name: %s",groupnames[i]); return (CMfailed); }
		if(DBTableFieldIsCategory(field))
			{
			groups[i] = new Groups();
			groups[i]->srcFLD = field;
			groups[i]->dstFLD = new DBObjTableField(*field);
			outTable->AddField(groups[i]->dstFLD);
//			CMmsgPrint (CMmsgUsrError, "Added Group: %s",groups[i]->dstFLD->Name());
			}
		else CMmsgPrint (CMmsgUsrError, "Group %s is not Category!",groupnames[i]);
		}
	delete groupnames;

	p = head->next;
	temp = head;
	while(p->next)
		{
		FieldOptions *duplicate = (FieldOptions *) NULL, *prev = p;
		if(!p->getPrint() && FLDExists(p,p->getOldName(),p->getFunc(),&duplicate))
			{ temp->next = p->next; delete p; p = temp->next; continue; }
		while(FLDExists(prev,prev->getOldName(),prev->getFunc(),&prev,&duplicate) && !duplicate->getPrint())
			{ prev->next = duplicate->next; delete duplicate; }
		temp = p;
		p = p->next;
		}
//	p = head->next;
//	while(p) { CMmsgPrint (CMmsgUsrError, "Added: o:%s n:%s p:",p->getOldName(),p->getNewName()); if(p->getPrint()) CMmsgPrint (CMmsgUsrError, "true"); else CMmsgPrint (CMmsgUsrError, "false"); p = p->next; }

	fields = inTable->Fields();
	p = head->next;
	while(p)
		{
		field = fields->Item (p->getOldName());
		if (p->getFunc() == MIN || p->getFunc() == MAX)
			p->field = new DBObjTableField(p->getNewName(),field->Type(),field->Format(),field->Length());
		else if(p->getFunc() == NUM || p->getFunc() == NONNULL)
			p->field = new DBObjTableField(p->getNewName(), DBTableFieldInt, DBHiddenField, sizeof (DBInt));
		else p->field = new DBObjTableField(p->getNewName(), DBTableFieldFloat, DBHiddenField, sizeof(DBFloat));
		if(p->getFunc() != NUM && p->getFunc() != NONNULL)
开发者ID:amiara,项目名称:RGIS,代码行数:67,代码来源:CMDtblStatistics.C


注:本文中的DBObjectLIST::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。