Beispiel #1
0
        public static IGeometryCollection ConstructPolygon(IPoint[] pointArray)
        {
            //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象
            object             o = Type.Missing;
            ISegmentCollection pSegCollection = new RingClass();

            for (int i = 0; i < pointArray.Length - 1; i++)
            {
                IPoint from = pointArray[i];
                IPoint to   = pointArray[i + 1];

                ILine pLine = new LineClass();
                //设置Line对象的起始终止点
                pLine.PutCoords(from, to);
                //QI到ISegment
                ISegment pSegment = pLine as ISegment;
                pSegCollection.AddSegment(pSegment, ref o, ref o);
            }
            //QI到IRing接口封闭Ring对象,使其有效
            IRing pRing = pSegCollection as IRing;

            pRing.Close();

            //使用Ring对象构建Polygon对象
            IGeometryCollection pGeometryColl = new PolygonClass();

            pGeometryColl.AddGeometry(pRing, ref o, ref o);
            //释放AO对象
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pRing);

            return(pGeometryColl);
        }
Beispiel #2
0
        public static IGeometryCollection ConstructPolygon(List <IPoint> pointArray)
        {
            //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象
            object             o = Type.Missing;
            ISegmentCollection pSegCollection = new RingClass();

            for (int i = 0; i < pointArray.Count - 1; i++)
            {
                IPoint from = pointArray[i];
                IPoint to   = pointArray[i + 1];

                ILine pLine = new LineClass();
                //设置Line对象的起始终止点
                pLine.PutCoords(from, to);
                //QI到ISegment
                ISegment pSegment = pLine as ISegment;
                pSegCollection.AddSegment(pSegment, ref o, ref o);
            }
            //QI到IRing接口封闭Ring对象,使其有效
            IRing pRing = pSegCollection as IRing;

            pRing.Close();

            //使用Ring对象构建Polygon对象
            IGeometryCollection pGeometryColl = new PolygonClass();

            pGeometryColl.AddGeometry(pRing, ref o, ref o);

            return(pGeometryColl);
        }
Beispiel #3
0
 private IGeometry EllipticArcTransPolygon(IEllipticArc pEll)
 {
     try
     {
         object             missing      = Type.Missing;
         ISegmentCollection pSegmentColl = new RingClass();
         pSegmentColl.AddSegment((ISegment)pEll, ref missing, ref missing);
         IRing pRing = (IRing)pSegmentColl;
         pRing.Close();                                                    //得到闭合的环
         IGeometryCollection pGeometryCollection = new PolygonClass();
         pGeometryCollection.AddGeometry(pRing, ref missing, ref missing); //环转面
         IPolygon pPolygon = (IPolygon)pGeometryCollection;
         return(pPolygon);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #4
0
        private IPolygon Arc2Polygon(ICircularArc Arc)
        {
            ISegmentCollection pSegCol = new RingClass();
            object             obj     = Type.Missing;

            pSegCol.AddSegment((ISegment)Arc, ref obj, ref obj);
            //enclose ring make it valid
            IRing pRing;

            pRing = pSegCol as IRing;
            pRing.Close();
            IGeometryCollection pPolygonCol = new PolygonClass();

            pPolygonCol.AddGeometry(pRing, ref obj, ref obj);
            IPolygon circlePolygon = (IPolygon)pPolygonCol;
            // mirror spatial referrence
            ISpatialReference spr = Arc.SpatialReference;

            circlePolygon.SpatialReference = spr;
            return(circlePolygon);
        }
        private void DrawEllipse()
        {
            IEnvelope envelope = this.m_mapControl.TrackRectangle();

            if (!envelope.IsEmpty)
            {
                IConstructEllipticArc constructEllipticArc = new EllipticArcClass();
                constructEllipticArc.ConstructEnvelope(envelope);
                ISegment           inSegment         = constructEllipticArc as ISegment;
                ISegmentCollection segmentCollection = new RingClass();
                object             missing           = Type.Missing;
                segmentCollection.AddSegment(inSegment, ref missing, ref missing);
                IRing ring = segmentCollection as IRing;
                ring.Close();
                IGeometryCollection geometryCollection = new PolygonClass();
                geometryCollection.AddGeometry(ring, ref missing, ref missing);
                this.AppendNodeToTreeList(new EllipseElementClass
                {
                    Geometry = (geometryCollection as IGeometry)
                });
            }
        }
Beispiel #6
0
        public static IGeometryCollection ConstructPolygon(ISegment[] segmentArray)
        {
            //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象
            object             o = Type.Missing;
            ISegmentCollection pSegCollection = new RingClass();

            for (int i = 0; i < segmentArray.Length; i++)
            {
                pSegCollection.AddSegment(segmentArray[i], ref o, ref o);
            }
            //QI到IRing接口封闭Ring对象,使其有效
            IRing pRing = pSegCollection as IRing;

            pRing.Close();

            //使用Ring对象构建Polygon对象
            IGeometryCollection pGeometryColl = new PolygonClass();

            pGeometryColl.AddGeometry(pRing, ref o, ref o);

            return(pGeometryColl);
        }
Beispiel #7
0
        public static IPolygon GetVisilityPolygon(List <IPolyline> polylines)
        {
            IGeometryCollection geometryCollection = new PolygonClass();
            ISegmentCollection  ringSegColl1       = new RingClass();

            foreach (var polyline in polylines)
            {
                ILine line = new LineClass()
                {
                    FromPoint = polyline.FromPoint, ToPoint = polyline.ToPoint, SpatialReference = polyline.SpatialReference
                };
                var polylineSeg = (ISegment)line;
                ringSegColl1.AddSegment(polylineSeg);
            }

            var     ringGeometry = ringSegColl1 as IGeometry;
            IZAware zAwareRing   = ringGeometry as IZAware;

            zAwareRing.ZAware = true;

            IRing ring1 = ringSegColl1 as IRing;

            ring1.Close();

            IGeometryCollection polygon = new PolygonClass();

            polygon.AddGeometry(ring1 as IGeometry);

            var     geometry = polygon as IGeometry;
            IZAware zAware   = geometry as IZAware;

            zAware.ZAware = true;

            var result = polygon as IPolygon;

            result.SpatialReference = polylines[0].SpatialReference;

            return(result);
        }
Beispiel #8
0
        static private IPolygon ConstructPolygonFromPolyline(IPolyline pPolyline)
        {
            IGeometryCollection pPolygonGeoCol = new PolygonClass();

            if ((pPolyline != null) && (!pPolyline.IsEmpty))
            {
                IGeometryCollection pPolylineGeoCol = pPolyline as IGeometryCollection;
                ISegmentCollection  pSegCol         = new RingClass();
                ISegment            pSegment        = null;
                object missing = Type.Missing;

                for (int i = 0; i < pPolylineGeoCol.GeometryCount; i++)
                {
                    ISegmentCollection pPolylineSegCol = pPolylineGeoCol.get_Geometry(i) as ISegmentCollection;
                    for (int j = 0; j < pPolylineSegCol.SegmentCount; j++)
                    {
                        pSegment = pPolylineSegCol.get_Segment(j);
                        pSegCol.AddSegment(pSegment, ref missing, ref missing);
                    }
                    pPolygonGeoCol.AddGeometry(pSegCol as IGeometry, ref missing, ref missing);
                }
            }
            return(pPolygonGeoCol as IPolygon);
        }
Beispiel #9
0
        //}

        /// <summary>
        /// 矢量转换函数
        /// </summary>
        private void exprotMatrix()
        {
            ClsGDBDataCommon comm = new ClsGDBDataCommon();

            if (!textOutData.Text.EndsWith("shp"))
            {
                //timerShow.Start();
                MessageBox.Show("输出文件名不是shp文件!");
                return;
            }
            object featureOID;

            String strFullName = textOutData.Text;
            string strPath     = System.IO.Path.GetDirectoryName(strFullName);
            string strName     = System.IO.Path.GetFileName(strFullName);

            ILayer player = null;

            for (int i = 0; i < pMapControl.Map.LayerCount; i++)
            {
                if (pMapControl.Map.Layer[i].Name == cmbLayer.Text)
                {
                    player = pMapControl.Map.Layer[i];
                    break;
                }
            }
            IFeatureLayer pFlayer = player as IFeatureLayer;
            IFeatureClass pFclass = pFlayer.FeatureClass;
            IFields       pFields = pFclass.Fields;
            //设置空间参考
            ISpatialReference pSpatialRef;
            IGeoDataset       pGeo = (IGeoDataset)pFlayer;

            pSpatialRef = pGeo.SpatialReference;

            IFeatureClass pFtClassNew = comm.CreateShapefile(strPath, strName, pFields, pSpatialRef);
            //for (int i = 0; i < pFtClassNew.Fields.FieldCount;i++ )
            //{
            //    if (pFtClassNew.Fields.get_Field(i).Type != esriFieldType.esriFieldTypeGeometry &&
            //      pFtClassNew.Fields.get_Field(i).Type != esriFieldType.esriFieldTypeOID)
            //    {
            //        pFtClassNew.Fields.get_Field(i).IsNullable = true;
            //    }
            //}


            IFeatureCursor pFC = pFlayer.FeatureClass.Search(null, false);
            IFeature       pF  = pFC.NextFeature();

            while (pF != null)
            {
                if (pFclass.ShapeType == esriGeometryType.esriGeometryMultipoint || pFclass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    double[] oldarray = new double[3];
                    double[] newarray = new double[3];
                    Matrix   matrix   = new Matrix();

                    IPoint pPointOld = pF.Shape as IPoint;
                    IPoint pPointNew = new PointClass();
                    oldarray[0] = pPointOld.X;
                    oldarray[1] = pPointOld.Y;
                    if (pPointOld.Z.ToString() == "NaN" || pPointOld.Z.ToString() == "非数字")
                    {
                        oldarray[2] = 0;//pPointOld.Z;
                    }
                    else
                    {
                        oldarray[2] = pPointOld.Z;
                    }
                    matrix.coord_Trans(oldarray, rotateMat, tranVec, newarray);

                    pPointNew.X = newarray[0];
                    pPointNew.Y = newarray[1];
                    if (pPointOld.Z.ToString() == "NaN" || pPointOld.Z.ToString() == "非数字")
                    {
                        pPointNew.Z = 0;
                    }
                    else
                    {
                        pPointNew.Z = newarray[2];
                    }


                    IFeature pFeatureTemp = pFtClassNew.CreateFeature();
                    pFeatureTemp.Shape = pPointNew as IGeometry;
                    ClsGDBDataCommon.CopyFeatureFieldValue(pF, pFeatureTemp);
                    pFeatureTemp.Store();
                }
                else if (pFclass.ShapeType == esriGeometryType.esriGeometryLine || pFclass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    double[] oldarrayS = new double[3];
                    double[] oldarrayT = new double[3];
                    double[] newarrayS = new double[3];
                    double[] newarrayT = new double[3];
                    Matrix   matrix    = new Matrix();

                    ISegmentCollection pSegCOld = pF.Shape as ISegmentCollection;
                    ISegmentCollection pSegCNew = new PolylineClass();
                    // ISegment pSegmentNEW = new LineClass();
                    //ILine pLine = new LineClass();
                    IPoint pPointF = new PointClass();
                    IPoint pPointT = new PointClass();

                    for (int i = 0; i < pSegCOld.SegmentCount; i++)
                    {
                        ISegment pSegmentNEW = new LineClass();
                        ISegment pseg        = pSegCOld.Segment[i];
                        oldarrayS[0] = pseg.FromPoint.X;
                        oldarrayS[1] = pseg.FromPoint.Y;
                        if (pseg.FromPoint.Z.ToString() == "NaN" || pseg.FromPoint.Z.ToString() == "非数字")
                        {
                            oldarrayS[2] = 0;
                        }
                        else
                        {
                            oldarrayS[2] = pseg.FromPoint.Z;
                        }
                        matrix.coord_Trans(oldarrayS, rotateMat, tranVec, newarrayS);
                        pPointF.X = newarrayS[0];
                        pPointF.Y = newarrayS[1];
                        if (pseg.FromPoint.Z.ToString() == "NaN" || pseg.FromPoint.Z.ToString() == "非数字")
                        {
                            pPointF.Z = 0;
                        }
                        else
                        {
                            pPointF.Z = newarrayS[2];
                        }
                        pSegmentNEW.FromPoint = pPointF;
                        oldarrayT[0]          = pseg.ToPoint.X;
                        oldarrayT[1]          = pseg.ToPoint.Y;
                        if (pseg.ToPoint.Z.ToString() == "NaN" || pseg.ToPoint.Z.ToString() == "非数字")
                        {
                            oldarrayT[2] = 0;
                        }
                        else
                        {
                            oldarrayT[2] = pseg.ToPoint.Z;
                        }
                        matrix.coord_Trans(oldarrayT, rotateMat, tranVec, newarrayT);
                        pPointT.X = newarrayT[0];
                        pPointT.Y = newarrayT[1];
                        if (pseg.ToPoint.Z.ToString() == "NaN" || pseg.ToPoint.Z.ToString() == "非数字")
                        {
                            pPointT.Z = 0;
                        }
                        else
                        {
                            pPointT.Z = newarrayT[2];
                        }
                        pSegmentNEW.ToPoint = pPointT;

                        pSegCNew.AddSegment(pSegmentNEW);
                    }
                    IFeature pFeatureTemp = pFtClassNew.CreateFeature();
                    pFeatureTemp.Shape = pSegCNew as IGeometry;
                    ClsGDBDataCommon.CopyFeatureFieldValue(pF, pFeatureTemp);
                    pFeatureTemp.Store();
                }

                else if (pFclass.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                    double[] oldarrayS = new double[3];
                    double[] oldarrayT = new double[3];
                    double[] newarrayS = new double[3];
                    double[] newarrayT = new double[3];
                    Matrix   matrix    = new Matrix();

                    IGeometryCollection pGCollectionOld = pF.Shape as IGeometryCollection;
                    IGeometryCollection pGCollectionNew = new PolygonClass();
                    ISegmentCollection  psegCOld        = new RingClass();


                    //ILine pLine = new LineClass();
                    IPoint pPointF = new PointClass();
                    IPoint pPointT = new PointClass();

                    //IPointCollection pPointCOld = new PolygonClass();
                    //IPointCollection pPointCNew = new PolygonClass();
                    //pPointCOld=pF.Shape as IPointCollection;
                    //for (int i = 0; i < pPointCOld.PointCount;i++ )
                    //{
                    //    pPointF = pPointCOld.Point[i];
                    //    oldarrayS[0] = pPointF.X;
                    //    oldarrayS[0] = pPointF.Y;
                    //    if (pPointF.Z.ToString() == "NaN" || pPointF.Z.ToString() == "非数字")
                    //    {
                    //        oldarrayS[2] = 0;//pPointOld.Z;
                    //    }
                    //    else
                    //    {
                    //        oldarrayS[2] = pPointF.Z;
                    //    }
                    //    matrix.coord_Trans(oldarrayS, rotateMat, tranVec, newarrayT);
                    //    pPointT.X = newarrayT[0];
                    //    pPointT.Y = newarrayT[1];
                    //    if (pPointF.Z.ToString() == "NaN" || pPointF.Z.ToString() == "非数字")
                    //    {
                    //        pPointT.Z = 0;
                    //    }
                    //    else
                    //    {
                    //        pPointT.Z = newarrayT[2];
                    //    }
                    //    pPointCNew.AddPoint(pPointT);
                    //}
                    //IPolygon pPolygon = pPointCNew as IPolygon;
                    //pPolygon.Close();
                    //IFeature pFeatureTemp = pFtClassNew.CreateFeature();
                    //pFeatureTemp.Shape = pPolygon as IGeometry;
                    //CopyFeatureField(pF, pFeatureTemp);
                    //pFeatureTemp.Store();

                    ///方法一
                    //IPolygon pPolygon=pF.Shape as IPolygon;
                    //IRing pExterRingOld = new RingClass();
                    //IRing pExterRingNew = new RingClass();

                    //for (int i = 0; i<pPolygon.ExteriorRingCount;i++ )
                    //{
                    //    pExterRingOld = pPolygon.FindExteriorRing(null);
                    //}


                    //方法二
                    for (int i = 0; i < pGCollectionOld.GeometryCount; i++)
                    {
                        psegCOld = pGCollectionOld.Geometry[i] as ISegmentCollection;
                        ISegmentCollection pSegCNew = new RingClass();
                        for (int j = 0; j < psegCOld.SegmentCount - 1; j++)
                        {
                            ISegment pSegmentNEW = new LineClass();
                            ISegment pseg        = psegCOld.Segment[j];
                            oldarrayS[0] = pseg.FromPoint.X;
                            oldarrayS[1] = pseg.FromPoint.Y;
                            if (pseg.FromPoint.Z.ToString() == "NaN" || pseg.FromPoint.Z.ToString() == "非数字")
                            {
                                oldarrayS[2] = 0;
                            }
                            else
                            {
                                oldarrayS[2] = pseg.FromPoint.Z;
                            }
                            matrix.coord_Trans(oldarrayS, rotateMat, tranVec, newarrayS);
                            pPointF.X = newarrayS[0];
                            pPointF.Y = newarrayS[1];
                            if (pseg.FromPoint.Z.ToString() == "NaN" || pseg.FromPoint.Z.ToString() == "非数字")
                            {
                                pPointF.Z = 0;
                            }
                            else
                            {
                                pPointF.Z = newarrayS[2];
                            }
                            pSegmentNEW.FromPoint = pPointF;
                            oldarrayT[0]          = pseg.ToPoint.X;
                            oldarrayT[1]          = pseg.ToPoint.Y;
                            if (pseg.ToPoint.Z.ToString() == "NaN" || pseg.ToPoint.Z.ToString() == "非数字")
                            {
                                oldarrayT[2] = 0;
                            }
                            else
                            {
                                oldarrayT[2] = pseg.ToPoint.Z;
                            }
                            matrix.coord_Trans(oldarrayT, rotateMat, tranVec, newarrayT);
                            pPointT.X = newarrayT[0];
                            pPointT.Y = newarrayT[1];
                            if (pseg.ToPoint.Z.ToString() == "NaN" || pseg.ToPoint.Z.ToString() == "非数字")
                            {
                                pPointT.Z = 0;
                            }
                            else
                            {
                                pPointT.Z = newarrayT[2];
                            }
                            pSegmentNEW.ToPoint = pPointT;

                            pSegCNew.AddSegment(pSegmentNEW);
                        }
                        IRing pRing = pSegCNew as IRing;
                        pRing.Close();
                        object ob = Type.Missing;
                        pGCollectionNew.AddGeometry(pRing as IGeometry, ref ob, ref ob);
                    }
                    IFeature pFeatureTemp = pFtClassNew.CreateFeature();
                    pFeatureTemp.Shape = pGCollectionNew as IGeometry;
                    ClsGDBDataCommon.CopyFeatureFieldValue(pF, pFeatureTemp);
                    pFeatureTemp.Store();
                }


                pF = pFC.NextFeature();
            }

            IFeatureLayer ppFeatureLayer = new FeatureLayerClass();

            ppFeatureLayer.FeatureClass = pFtClassNew;
            ppFeatureLayer.Name         = strName;
            pMapControl.AddLayer(ppFeatureLayer as ILayer);
            //pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            this.Close();
        }
Beispiel #10
0
        public static IPolygon CreatePolygon(object[] rings)
        {
            IPolygon result = null;

            IGeometryCollection pGeomCol = new PolygonClass();
            object objMissing            = Type.Missing;

            foreach (object o in rings)//part
            {
                object[] ringpoints = o as object[];
                if (ringpoints != null)
                {
                    ISegmentCollection pSegCol = new RingClass();
                    ISegment           pSeg    = new LineClass();
                    IPoint             pFromPt = new PointClass();
                    IPoint             pToPt   = new PointClass();
                    IPoint             pEndPt  = new PointClass();

                    List <PointObject> poList = new List <PointObject>();
                    foreach (object po in ringpoints)
                    {
                        PointObject pObj  = new PointObject();
                        object[]    ptxya = po as object[];
                        if (ptxya != null)
                        {
                            if (ptxya.Length == 3)
                            {
                                pObj.X = double.Parse(ptxya[0].ToString());
                                pObj.Y = double.Parse(ptxya[1].ToString());
                                pObj.A = int.Parse(ptxya[2].ToString());
                            }
                            else if (ptxya.Length == 2)
                            {
                                pObj.X = double.Parse(ptxya[0].ToString());
                                pObj.Y = double.Parse(ptxya[1].ToString());
                                pObj.A = 0;
                            }
                            else
                            {
                                throw new Exception("坐标串输入错误!");
                            }
                            poList.Add(pObj);
                        }
                    }

                    if (poList.Count < 3)
                    {
                        throw new Exception("至少保证三个点来确定一个面!");
                    }

                    for (int i = 0; i < poList.Count - 1; i++)
                    {
                        if (poList[i].A.Equals(1))//处理狐段
                        {
                            PointObject poF = null;
                            PointObject poT = null;
                            PointObject poE = null;
                            if (i - 1 < 0)
                            {
                                poF = poList[poList.Count - 2];
                            }
                            else
                            {
                                poF = poList[i - 1];
                            }
                            poT = poList[i];
                            poE = poList[i + 1];

                            pFromPt.PutCoords(poF.X, poF.Y);
                            pToPt.PutCoords(poT.X, poT.Y);
                            pEndPt.PutCoords(poE.X, poE.Y);

                            //圆弧
                            ICircularArc          cirularArc           = new CircularArcClass();
                            IConstructCircularArc constructCircularArc = cirularArc as IConstructCircularArc;
                            constructCircularArc.ConstructThreePoints(pFromPt, pToPt, pEndPt, true);
                            pSeg = cirularArc as ISegment;
                            pSegCol.AddSegment(pSeg, ref objMissing, ref objMissing);
                        }
                        else
                        {
                            if (poList[i + 1].A.Equals(0))//处理直线,否则不处理
                            {
                                pFromPt.PutCoords(poList[i].X, poList[i].Y);
                                pToPt.PutCoords(poList[i + 1].X, poList[i + 1].Y);

                                pSeg           = new LineClass();
                                pSeg.FromPoint = pFromPt;
                                pSeg.ToPoint   = pToPt;
                                //一根线段
                                pSegCol.AddSegment(pSeg, ref objMissing, ref objMissing);
                            }
                        }
                    }

                    //QI到IRing接口封闭Ring对象,使其有效
                    IRing pRing = pSegCol as IRing;
                    pRing.Close();

                    //一个part
                    pGeomCol.AddGeometry(pSegCol as IGeometry, ref objMissing, ref objMissing);
                }
            }

            result = pGeomCol as IPolygon;
            ITopologicalOperator pTop = result as ITopologicalOperator;

            pTop.Simplify();

            return(result);
        }
Beispiel #11
0
        private IElement DrawCircle(double radius, double x, double y)
        {
            IPoint centralPoint = new PointClass();
            centralPoint.PutCoords(x, y);
            // 创建园
            ICircularArc circularArc = new CircularArcClass();
            IConstructCircularArc construtionCircularArc = circularArc as IConstructCircularArc;
            construtionCircularArc.ConstructCircle(centralPoint, radius, true);

            ISegment pSegment1 = circularArc as ISegment;
            //通过ISegmentCollection构建Ring对象
            ISegmentCollection pSegCollection = new RingClass();
            object o = Type.Missing;
            //添加Segement对象即圆
            pSegCollection.AddSegment(pSegment1, ref o, ref o);

            //QI到IRing接口封闭Ring对象,使其有效
            IRing pRing = pSegCollection as IRing;
            pRing.Close();
            //通过Ring对象使用IGeometryCollection构建Polygon对象
            IGeometryCollection pGeometryColl = new PolygonClass();
            pGeometryColl.AddGeometry(pRing, ref o, ref o);
            //构建一个CircleElement对象
            IElement pElement = new CircleElementClass();
            pElement.Geometry = pGeometryColl as IGeometry;

            IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;

            ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            //pFillSymbol.Color = pCircleColor;
            ILineSymbol pLineSymbol = new SimpleLineSymbolClass();

              //  pLineSymbol.Color = DefineColor(0, 255, 0);
            pFillSymbol.Outline = pLineSymbol;

            pFillShapeElement.Symbol = pFillSymbol;

            IFillShapeElement circleElement = pElement as IFillShapeElement;
            circleElement.Symbol = pFillSymbol;
            IGraphicsContainer pGC = this.axMapControl.ActiveView.GraphicsContainer;
            pGC.AddElement(pElement, 0);
            axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            return pElement;
        }
 /// <summary>
 /// ��ת��
 /// </summary>
 /// <params name="pPolyline"></params>
 /// <returns></returns>
 public static IPolygon PolylineToPolygon(IPolyline pPolyline)
 {
     IPolygon pPolygon = null;
     IGeometryCollection pGeometryCollection = new PolygonClass();
     if (pPolyline != null && pPolyline.IsEmpty == false)
     {
         IGeometryCollection pPolylineGeoCol = pPolyline as IGeometryCollection;
         ISegmentCollection pSegCol = new RingClass();
         ISegment pSegment = null;
         object missing = Type.Missing;
         for (int i = 0; i < pPolylineGeoCol.GeometryCount; i++)
         {
             ISegmentCollection pPolylineSegCol = pPolylineGeoCol.get_Geometry(i) as ISegmentCollection;
             for (int j = 0; j < pPolylineSegCol.SegmentCount; j++)
             {
                 pSegment = pPolylineSegCol.get_Segment(j);
                 pSegCol.AddSegment(pSegment, ref missing, ref missing);
             }
             pGeometryCollection.AddGeometry(pSegCol as IGeometry, ref missing, ref missing);
         }
     }
     pPolygon = pGeometryCollection as IPolygon;
     if (pPolygon.IsClosed == false)
         pPolygon.Close();
     pPolygon.SpatialReference = DataEditCommon.g_pMyMapCtrl.SpatialReference;
     return pPolygon;
 }
        private IPolygon CostruisciPoligonoBuffer(double xCentro, double yCentro, long raggio)
        {
            IPolygon cerchio = null;

            try
            {
                IGeoDataset geoDataset = fcClienti as IGeoDataset;

                #region Costruisco i 4 punti cardine del cerchio
                IPoint centro = new PointClass();
                centro.SpatialReference = geoDataset.SpatialReference;
                centro.X = xCentro;
                centro.Y = yCentro;

                IPoint puntoNord = new PointClass();
                puntoNord.SpatialReference = geoDataset.SpatialReference;
                puntoNord.X = xCentro;
                puntoNord.Y = (yCentro + raggio);

                IPoint puntoSud = new PointClass();
                puntoSud.SpatialReference = geoDataset.SpatialReference;
                puntoSud.X = xCentro;
                puntoSud.Y = (yCentro - raggio);

                IPoint puntoOvest = new PointClass();
                puntoOvest.SpatialReference = geoDataset.SpatialReference;
                puntoOvest.X = (xCentro + raggio);
                puntoOvest.Y = yCentro;

                IPoint puntoEst = new PointClass();
                puntoEst.SpatialReference = geoDataset.SpatialReference;
                puntoEst.X = (xCentro - raggio);
                puntoEst.Y = yCentro;

                #endregion

                ISegmentCollection ringSegColl = new RingClass();

                ICircularArc circularArc = new CircularArcClass();
                circularArc.PutCoords(centro, puntoNord, puntoOvest, esriArcOrientation.esriArcClockwise);
                ringSegColl.AddSegment(circularArc as ISegment);

                ICircularArc circularArc2 = new CircularArcClass();
                circularArc2.PutCoords(centro, puntoOvest, puntoSud, esriArcOrientation.esriArcClockwise);
                ringSegColl.AddSegment(circularArc2 as ISegment);

                ICircularArc circularArc3 = new CircularArcClass();
                circularArc3.PutCoords(centro, puntoSud, puntoEst, esriArcOrientation.esriArcClockwise);
                ringSegColl.AddSegment(circularArc3 as ISegment);

                ICircularArc circularArc4 = new CircularArcClass();
                circularArc4.PutCoords(centro, puntoEst, puntoNord, esriArcOrientation.esriArcClockwise);
                ringSegColl.AddSegment(circularArc4 as ISegment);


                IRing ringl = ringSegColl as IRing;
                ringl.Close();

                IGeometryCollection polygon = new PolygonClass();
                polygon.AddGeometry(ringl as IGeometry);

                cerchio = polygon as IPolygon;
            }
            catch (Exception errore)
            {
                logger.LogMessage(ServerLogger.msgType.error, "Construct", 8000, $@"SOE GeoMarketing GiancaGIS: {errore.Message}");
            }


            return(cerchio);
        }
        /// <summary>
        /// 通过线创建面
        /// </summary>
        /// <param name="pPolyline">线</param>
        /// <returns>面</returns>
        IPolygon ConstructPolygonFromPolyline(IPolyline _pPolyline)
        {
            IGeometryCollection pPolygonGeoCol = new PolygonClass();

               if ((_pPolyline != null) && (!_pPolyline.IsEmpty))
               {
               IGeometryCollection pPolylineGeoCol = _pPolyline as IGeometryCollection;

               ISegmentCollection pSegCol = new RingClass();

               ISegment pSegment = null;

               object missing = Type.Missing;

               for (int i = 0; i < pPolylineGeoCol.GeometryCount; i++)
               {
                   ISegmentCollection pPolylineSegCol = pPolylineGeoCol.get_Geometry(i) as ISegmentCollection;
                   for (int j = 0; j < pPolylineSegCol.SegmentCount; j++)
                   {
                       pSegment = pPolylineSegCol.get_Segment(j);

                       pSegCol.AddSegment(pSegment, ref missing, ref missing);
                   }
                   pPolygonGeoCol.AddGeometry(pSegCol as IGeometry, ref missing, ref missing);
               }
               }
               return pPolygonGeoCol as IPolygon;
        }