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


C++ DBObjTableField::Region方法代码示例

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


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

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

示例2: 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

示例3: DBImportARCPoly

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

	{
	DBInt polyNum = 0, line, lineNum, vertexNum,  polyDir;
	DBObjTable *items = vecData->Table (DBrNItems);
	DBObjTable *lines	= vecData->Table (DBrNContours);
	DBObjTableField *firstLineFLD	= items->Field (DBrNFirstLine);
	DBObjTableField *lineNumFLD	= items->Field (DBrNLineNum);
	DBObjTableField *polyVertexNumFLD = items->Field (DBrNVertexNum);
	DBObjTableField *polyExtentFLD	= items->Field (DBrNRegion);
	DBObjTableField *leftPolyFLD	= lines->Field (DBrNLeftPoly);
	DBObjTableField *rightPolyFLD	= lines->Field (DBrNRightPoly);
	DBObjTableField *nextLineFLD	= lines->Field (DBrNNextLine);
	DBObjTableField *prevLineFLD	= lines->Field (DBrNPrevLine);
	DBObjTableField *fromNodeFLD	= lines->Field (DBrNFromNode);
	DBObjTableField *toNodeFLD		= lines->Field (DBrNToNode);
	DBObjTableField *lineVertextNumFLD	= lines->Field (DBrNVertexNum);
	DBObjTableField *lineExtentFLD	= lines->Field (DBrNRegion);
	DBObjRecord *polyRec, *lineRec, *firstNodeRec, *nodeRec, **lineRecArray;
	DBRegion extent, initRegion;

	if (DBImportARCLine (vecData,arcCov) == DBFault) return (DBFault);

	items->Delete (0);
	for (polyRec = items->First ();polyRec != (DBObjRecord *) NULL;polyRec = items->Next ())
		lineNumFLD->Int (polyRec,0);

	for (lineRec = lines->First ();lineRec != (DBObjRecord *) NULL;lineRec = lines->Next ())
		{
		rightPolyFLD->Record	(lineRec,items->Item ((DBInt) (rightPolyFLD->Record(lineRec) - (DBObjRecord *) NULL)));
		leftPolyFLD->Record  (lineRec,items->Item ((DBInt) (leftPolyFLD->Record (lineRec) - (DBObjRecord *) NULL)));
		nextLineFLD->Record (lineRec,(DBObjRecord *) NULL);
		prevLineFLD->Record (lineRec,(DBObjRecord *) NULL);
		}

	if ((lineRecArray = (DBObjRecord **) calloc (lines->ItemNum (),sizeof (DBObjRecord *))) == (DBObjRecord **) NULL)
		{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }

	for (polyRec = items->First ();polyRec != (DBObjRecord *) NULL;polyRec = items->Next ())
		{
		DBPause ((++polyNum * 100) / items->ItemNum ());

		lineNum = vertexNum = 0;
		extent = initRegion;
		for (lineRec = lines->First ();lineRec != (DBObjRecord *) NULL;lineRec = lines->Next ())
			if ((rightPolyFLD->Record (lineRec) == polyRec) || (leftPolyFLD->Record (lineRec) == polyRec))
				{
				lineRecArray [lineNum++] = lineRec;
				vertexNum += lineVertextNumFLD->Int (lineRec);
				extent.Expand (lineExtentFLD->Region (lineRec));
				}
		lineNumFLD->Int (polyRec,lineNum);
		polyExtentFLD->Region (polyRec,extent);
		firstLineFLD->Record (polyRec,lineRecArray [0]);
		firstNodeRec = (rightPolyFLD->Record (lineRecArray [0]) == polyRec) ?
							fromNodeFLD->Record  (lineRecArray [0]) : toNodeFLD->Record(lineRecArray [0]);
		for (lineNum = 1;lineNum < lineNumFLD->Int (polyRec);++lineNum)
			{
			polyDir = (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec);
			nodeRec = polyDir ?	toNodeFLD->Record  (lineRecArray [lineNum - 1]) :
										fromNodeFLD->Record(lineRecArray [lineNum - 1]);
			for (line = lineNum;line < lineNumFLD->Int (polyRec); ++line)
				if ((nodeRec == fromNodeFLD->Record (lineRecArray [line])) ||
					 (nodeRec == toNodeFLD->Record   (lineRecArray [line]))) break;
			if (line < lineNumFLD->Int (polyRec))
				{
				lineRec = lineRecArray [lineNum];
				lineRecArray [lineNum] = lineRecArray [line];
				lineRecArray [line] = lineRec;
				}
			else
				{
				vertexNum += 1;
				if (nodeRec != firstNodeRec) vertexNum += 1;
				}
			}
		polyDir = (rightPolyFLD->Record (lineRecArray [lineNum - 1]) == polyRec);
		nodeRec = polyDir ?	toNodeFLD->Record  (lineRecArray [lineNum - 1]) :
									fromNodeFLD->Record(lineRecArray [lineNum - 1]);
		polyVertexNumFLD->Int (polyRec,vertexNum + lineNum + 1 + (nodeRec != firstNodeRec ? 1 : 0));
		for (lineNum = 1;lineNum < lineNumFLD->Int (polyRec);++lineNum)
			{
			if (rightPolyFLD->Record  (lineRecArray [lineNum - 1]) == polyRec)
					nextLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [lineNum]);
			else	prevLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [lineNum]);
			}
		if (rightPolyFLD->Record  (lineRecArray [lineNum - 1]) == polyRec)
				nextLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [0]);
		else	prevLineFLD->Record (lineRecArray [lineNum - 1],lineRecArray [0]);
		}
	free (lineRecArray);
	return (DBSuccess);
	}
开发者ID:amiara,项目名称:RGIS,代码行数:93,代码来源:DBImpARCPoly.C


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