//由点集生成面(环形Polygon) private IGeometry getGeometry(IPointCollection Points) { Ring ring = new RingClass(); object missing = Type.Missing; ring.AddPointCollection(Points); IGeometryCollection pointPolygon = new PolygonClass(); pointPolygon.AddGeometry(ring as IGeometry, ref missing, ref missing); IPolygon polyGonGeo = pointPolygon as IPolygon; //polyGonGeo.Close(); polyGonGeo.SimplifyPreserveFromTo(); return(polyGonGeo as IGeometry); }
/// <summary> /// 创建面实体 /// </summary> /// <param name="pITable">数据表对象</param> /// <param name="entinyNode">VCT空间实体节点</param> public override void CreateFeature(ITable pITable, EntityNode entinyNode) { PolygonNode pPolygonNode = entinyNode as PolygonNode; if (pPolygonNode != null) { IFeatureClass pFeatureCls = pITable as IFeatureClass; this.Feature = pFeatureCls.CreateFeature(); ///标识码赋值 int dBSMIndex = -1; dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled); if (dBSMIndex != -1) this.Feature.set_Value(dBSMIndex, pPolygonNode.EntityID); ///要素代码赋值 int dSYDMIndex = -1; dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField); if (dSYDMIndex != -1) this.Feature.set_Value(dSYDMIndex, pPolygonNode.FeatureCode); //根据面特征类型构面 bool bGetGeometry = false;///指示是否获取图形数据 ///从配置表获取面的类型InDireCoordinatePolygon表示间接坐标构面 if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("POLYGONFEATURETYPE", pPolygonNode.PolygonType.ToString()) == "InDireCoordinatePolygon") { IGeometryCollection pGeoCollection = new PolygonClass(); IPointCollection pPtCollection = new RingClass(); ///采用间接构面的方式LineStructPolygon表示引用线构面 if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("POLYGONTYPE", pPolygonNode.ComposeType.ToString()) == "LineStructPolygon") { for (int i = 0; i < pPolygonNode.LineNodes.Count; i++) { LineNodeEx pLineNodeEx = pPolygonNode.LineNodes[i]; if (pLineNodeEx == null) continue; ///标识码为0表示对象分割标识 if (pLineNodeEx.EntityID != 0) { IPoint pPrePoint=null; if (pPtCollection.PointCount > 0) pPrePoint = pPtCollection.get_Point(pPtCollection.PointCount-1); IPointCollection pPointCollection=GetPointCollection(pLineNodeEx, pPrePoint); if (pPointCollection != null) pPtCollection.AddPointCollection(pPointCollection); if (i == pPolygonNode.LineNodes.Count - 1) { IRing pRing = pPtCollection as IRing; pRing.Close();///闭合当前环 object oTypeMissing = Type.Missing; pGeoCollection.AddGeometry(pRing as IGeometry, ref oTypeMissing, ref oTypeMissing); bGetGeometry = true; pPtCollection = new RingClass();///清空点集数据 } } else///独到标识码为0时闭合图形 { IRing pRing = pPtCollection as IRing; pRing.Close();///闭合当前环 object oTypeMissing = Type.Missing; pGeoCollection.AddGeometry(pRing as IGeometry, ref oTypeMissing, ref oTypeMissing); bGetGeometry = true; pPtCollection = new RingClass();///清空点集数据 } } if (bGetGeometry) { (this.Feature as IFeature).Shape = pGeoCollection as IGeometry; } } } else if (pPolygonNode.PolygonType == 1) { } this.Feature.Store(); } }
/// <summary> /// 生成可视与不可视域的多面体 张琪 20110621 /// </summary> /// <param name="bIsVis">是否可视</param> /// <param name="pObsPt">观察点</param> /// <param name="pTarPt">目标点</param> /// <param name="pVisLine">可视线要素</param> /// <param name="pInVisLine">不可视线要素</param> /// <param name="pVisPatch">可视多面体</param> /// <param name="pInVisPatch">不可视多面体</param> /// <param name="dTargetHeight"></param> public void CreateVerticalLOSPatches(bool bIsVis, ESRI.ArcGIS.Geometry.IPoint pObsPt, ESRI.ArcGIS.Geometry.IPoint pTarPt, IPolyline pVisLine, IPolyline pInVisLine, IGeometryCollection pVisPatch, IGeometryCollection pInVisPatch, double dTargetHeight) { IGeometryCollection pGeomColl = pVisLine as IGeometryCollection; //存储可视域线要素 IMultiPatch pVisMPatch = pVisPatch as IMultiPatch; IMultiPatch pInVisMPatch = pInVisPatch as IMultiPatch; //生成不可视域要素 dTargetHeight = pTarPt.Z; double dist1 = 0; double dist2; IPointCollection pPc; IClone pClone; ESRI.ArcGIS.Geometry.IPoint pLastVisPoint = null; IPointCollection pVisFan = new TriangleFanClass();//用于存储可视域多面体要素 object before = Type.Missing; object after = Type.Missing; for (int i = 0; i < pGeomColl.GeometryCount; i++)//遍历可视域线要素 { pPc = pGeomColl.get_Geometry(i) as IPointCollection; if (i == 0)//当为第一个可视域线要素是先要存储观察点要素 { pClone = pObsPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pPc.get_Point(0) as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); ESRI.ArcGIS.Geometry.IPoint pStartPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; } pClone = pPc as IClone; pVisFan.AddPointCollection(pClone.Clone() as IPointCollection); //将可视域线要素的点集合存储于pVisFan中 if (i == pGeomColl.GeometryCount - 1) //当为可视域最后一个线要素时 { IVector3D pV = new Vector3DClass(); ESRI.ArcGIS.Geometry.IPoint p1; pClone = pObsPt as IClone; p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p1.Z = 0; ESRI.ArcGIS.Geometry.IPoint p2; pClone = pPc.get_Point(pPc.PointCount - 1) as IClone; p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); dist1 = pV.Magnitude; pLastVisPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; if (pInVisLine == null) { if (pTarPt.Z > pPc.get_Point(pPc.PointCount - 1).Z)//当被观察点高程高于最后一点要素时则到被观点都是可视的 { pClone = pTarPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); } } } pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); //根据获得的点要素集生成TriangleFanClass } if (pInVisLine != null) //当不可视域的线要素不为空时 { pGeomColl = pInVisLine as IGeometryCollection; IPointCollection pInVisRing = new RingClass();//用于存储不可视域点要素集并生成RingClass for (int i = 0; i < pGeomColl.GeometryCount; i++) { pPc = pGeomColl.get_Geometry(i) as IPointCollection; pClone = pPc.get_Point(0) as IClone; pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pPc as IClone; pInVisRing.AddPointCollection(pClone.Clone() as IPointCollection); if (i == pGeomColl.GeometryCount - 1) { IVector3D pV = new Vector3DClass(); pClone = pObsPt as IClone; ESRI.ArcGIS.Geometry.IPoint p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p1.Z = 0; pClone = pPc.get_Point(pPc.PointCount - 1) as IClone; ESRI.ArcGIS.Geometry.IPoint p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); dist2 = pV.Magnitude; if (dist1 < dist2) { pClone = pObsPt as IClone; p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p1.Z = 0; pClone = pPc.get_Point(0) as IClone; p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); double theDist1; theDist1 = pV.Magnitude; double slope = (pObsPt.Z - pPc.get_Point(0).Z) / theDist1; pClone = pPc.get_Point(pPc.PointCount - 1) as IClone; ESRI.ArcGIS.Geometry.IPoint pEndPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); double theDist2 = pV.Magnitude; double deltaZ = theDist2 * slope; double theHeight = pObsPt.Z - deltaZ; pEndPoint.Z = theHeight; pClone = pEndPoint as IClone; pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after); if (bIsVis)//为True时说明不可视域线要素空间范围内存在可视区域 { pVisFan = new TriangleFanClass(); pClone = pObsPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pTarPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); } else { dTargetHeight = pEndPoint.Z; } } else { if (bIsVis) { if (pTarPt.Z > pLastVisPoint.Z) { pVisFan = new TriangleFanClass(); pClone = pObsPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pTarPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pLastVisPoint as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); } } } } pClone = pPc.get_Point(0) as IClone; pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pInVisPatch.AddGeometry(pInVisRing as IGeometry, ref before, ref after);//获取每段不可视域线要素点集合并生成RingClass pInVisMPatch.PutRingType(pInVisRing as IRing, esriMultiPatchRingType.esriMultiPatchRing); } } }
/// <summary> /// ������ʵ�� /// </summary> /// <param name="pITable">���ݱ����</param> /// <param name="entinyNode">VCT�ռ�ʵ��ڵ�</param> public override void CreateFeature(ITable pITable, EntityNode entinyNode) { PolygonNode pPolygonNode = entinyNode as PolygonNode; if (pPolygonNode != null) { IFeatureClass pFeatureCls = pITable as IFeatureClass; this.Feature = pFeatureCls.CreateFeature(); ///��ʶ�븳ֵ int dBSMIndex = -1; dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled); if (dBSMIndex != -1) this.Feature.set_Value(dBSMIndex, pPolygonNode.EntityID); ///Ҫ�ش��븳ֵ int dSYDMIndex = -1; dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField); if (dSYDMIndex != -1) this.Feature.set_Value(dSYDMIndex, pPolygonNode.FeatureCode); //���������������� bool bGetGeometry = false;///ָʾ�Ƿ��ȡͼ������ ///�����ñ��ȡ�������InDireCoordinatePolygon��ʾ������깹�� if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("POLYGONFEATURETYPE", pPolygonNode.PolygonType.ToString()) == "InDireCoordinatePolygon") { IGeometryCollection pGeoCollection = new PolygonClass(); IPointCollection pPtCollection = new RingClass(); ///���ü�ӹ���ķ�ʽLineStructPolygon��ʾ�����߹��� if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("POLYGONTYPE", pPolygonNode.ComposeType.ToString()) == "LineStructPolygon") { for (int i = 0; i < pPolygonNode.LineNodes.Count; i++) { LineNodeEx pLineNodeEx = pPolygonNode.LineNodes[i]; if (pLineNodeEx == null) continue; ///��ʶ��Ϊ0��ʾ����ָ��ʶ if (pLineNodeEx.EntityID != 0) { IPoint pPrePoint=null; if (pPtCollection.PointCount > 0) pPrePoint = pPtCollection.get_Point(pPtCollection.PointCount-1); IPointCollection pPointCollection=GetPointCollection(pLineNodeEx, pPrePoint); if (pPointCollection != null) pPtCollection.AddPointCollection(pPointCollection); if (i == pPolygonNode.LineNodes.Count - 1) { IRing pRing = pPtCollection as IRing; pRing.Close();///�պϵ�ǰ�� object oTypeMissing = Type.Missing; pGeoCollection.AddGeometry(pRing as IGeometry, ref oTypeMissing, ref oTypeMissing); bGetGeometry = true; pPtCollection = new RingClass();///��յ㼯���� } } else///������ʶ��Ϊ0ʱ�պ�ͼ�� { IRing pRing = pPtCollection as IRing; pRing.Close();///�պϵ�ǰ�� object oTypeMissing = Type.Missing; pGeoCollection.AddGeometry(pRing as IGeometry, ref oTypeMissing, ref oTypeMissing); bGetGeometry = true; pPtCollection = new RingClass();///��յ㼯���� } } if (bGetGeometry) { (this.Feature as IFeature).Shape = pGeoCollection as IGeometry; } } } else if (pPolygonNode.PolygonType == 1) { } this.Feature.Store(); } }