Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 多部分(多外环)的多边形转成多个单部分的多边形
        /// </summary>
        /// <param name="polygon"></param>
        /// <returns></returns>
        public static IPolygon[] MultiPartToSinglePart(this IPolygon4 polygon)
        {
            List <IPolygon> polygons = new List <IPolygon>();

            //外部环
            IGeometryBag        exteriorRingGeometryBag        = polygon.ExteriorRingBag;
            IGeometryCollection exteriorRingGeometryCollection = exteriorRingGeometryBag as IGeometryCollection;

            for (int i = 0; i < exteriorRingGeometryCollection.GeometryCount; i++)
            {
                IGeometry exteriorRingGeometry = exteriorRingGeometryCollection.get_Geometry(i);
                IRing     ring = exteriorRingGeometry as IRing;
                ring.Close();
                IGeometryCollection pGeometryColl = new PolygonClass();
                pGeometryColl.AddGeometry(ring);

                //内部环
                IGeometryBag        interiorRingGeometryBag        = polygon.get_InteriorRingBag(exteriorRingGeometry as IRing);
                IGeometryCollection interiorRingGeometryCollection = interiorRingGeometryBag as IGeometryCollection;
                for (int k = 0; k < interiorRingGeometryCollection.GeometryCount; k++)
                {
                    IGeometry interiorRingGeometry = interiorRingGeometryCollection.get_Geometry(k);
                    IRing     ring2 = interiorRingGeometry as IRing;
                    ring2.Close();
                    pGeometryColl.AddGeometry(ring2);
                }

                ITopologicalOperator pTopological = pGeometryColl as ITopologicalOperator;
                pTopological.Simplify();
                IPolygon p = pGeometryColl as IPolygon;
                polygons.Add(p);
            }
            return(polygons.ToArray());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新半径 千米
        /// </summary>
        /// <param name="radius"></param>
        public void UpdatePosition(double radius)
        {
            this.Dosomething((Action) delegate()
            {
                pRadius = radius;

                MapLngLat center          = new MapLngLat(centerPoint.X, centerPoint.Y);
                MapLngLat around          = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)radius, center, 180);
                INewLineFeedback backline = new NewLineFeedbackClass();
                centerPoint = new PointClass()
                {
                    X = center.Lng, Y = center.Lat
                };
                IPoint aroundPoint = new PointClass()
                {
                    X = around.Lng, Y = around.Lat
                };
                backline.Start(centerPoint);
                backline.AddPoint(aroundPoint);
                var geo = backline.Stop();
                iSeg.SetCircle(centerPoint, geo.Length);
                object o = System.Type.Missing;
                pRing    = iSeg as IRing;
                pRing.Close();

                pGeometryColl = new PolygonClass();
                pGeometryColl.AddGeometry(pRing, ref o, ref o);
                pGeometry = pGeometryColl as IGeometry;

                base.Symbol   = fillSymbol;
                base.Geometry = pGeometry;
            }, true);

            Update();
        }
        public static IGeometry GetExample5()
        {
            const int    XRange            = 16;
            const int    YRange            = 16;
            const int    InteriorRingCount = 25;
            const double HoleRange         = 0.5;

            //RingGroup: Square Lying In XY Plane With Single Exterior Ring And Multiple Interior Rings

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Exterior Ring

            IPointCollection exteriorRingPointCollection = new RingClass();

            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing);
            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing);
            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing);
            exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing);

            IRing exteriorRing = exteriorRingPointCollection as IRing;

            exteriorRing.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Rings

            Random random = new Random();

            for (int i = 0; i < InteriorRingCount; i++)
            {
                double interiorRingOriginX = XRange * (random.NextDouble() - 0.5);
                double interiorRingOriginY = YRange * (random.NextDouble() - 0.5);

                IPointCollection interiorRingPointCollection = new RingClass();
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing);
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing);
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing);
                interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing);

                IRing interiorRing = interiorRingPointCollection as IRing;
                interiorRing.Close();

                multiPatchGeometryCollection.AddGeometry(interiorRing as IGeometry, ref _missing, ref _missing);

                multiPatch.PutRingType(interiorRing, esriMultiPatchRingType.esriMultiPatchInnerRing);
            }

            return(multiPatchGeometryCollection as IGeometry);
        }
Ejemplo n.º 6
0
        //public IPolygon GetPolygonGeomery(IPointCollection ipc)
        //{

        //    IGeometryCollection polygon = new PolygonClass();
        //    IPolyline polyline = ipc as IPolyline;
        //    ILine repolyline = new LineClass();
        //    repolyline.PutCoords(polyline.FromPoint, polyline.ToPoint);
        //    ISegment segment = repolyline as ISegment;
        //    ISegmentCollection psc = new RingClass();
        //    psc.AddSegment(segment);
        //    IRing pring = psc as IRing;
        //    pring.Close();
        //    polygon.AddGeometry(pring);
        //    IPolygon finalpolygon = polygon as IPolygon;
        //    return finalpolygon;

        //}
        public IPolygon GetPolygonGeomery(IPointCollection ipc)
        {
            IPolyline polyline = null;

            polyline = ipc as IPolyline;
            IRing pring = polyline as IRing;

            pring.Close();
            IPolygon polygon = pring as IPolygon;

            return(polygon);
        }
        public static IGeometry GetExample3()
        {
            //RingGroup: Upright Square With Hole

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Exterior Ring 1

            IPointCollection exteriorRing1PointCollection = new RingClass();

            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, -5), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, -5), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 5), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 5), ref _missing, ref _missing);

            IRing exteriorRing1 = exteriorRing1PointCollection as IRing;

            exteriorRing1.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing1, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 1

            IPointCollection interiorRing1PointCollection = new RingClass();

            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, -4), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, -4), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, 4), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, 4), ref _missing, ref _missing);

            IRing interiorRing1 = interiorRing1PointCollection as IRing;

            interiorRing1.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing1, esriMultiPatchRingType.esriMultiPatchInnerRing);

            return(multiPatchGeometryCollection as IGeometry);
        }
Ejemplo n.º 8
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;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Converts the ICircularArc to polygon.
        /// </summary>
        /// <param name="circularArc">The circulararc.</param>
        /// <returns>IPolygon.</returns>
        public static IPolygon ConvertCircularArcToPolygon(ICircularArc circularArc)
        {
            ISegmentCollection segmentCollection = new RingClass();
            ISegmentCollection arg_2B_0          = segmentCollection;
            ISegment           arg_2B_1          = circularArc as ISegment;
            object             value             = Missing.Value;
            object             value2            = Missing.Value;

            arg_2B_0.AddSegment(arg_2B_1, ref value, ref value2);
            IRing ring = segmentCollection as IRing;

            ring.Close();
            IGeometryCollection geometryCollection = new PolygonClass();
            IGeometryCollection arg_5D_0           = geometryCollection;
            IGeometry           arg_5D_1           = ring;

            value  = Missing.Value;
            value2 = Missing.Value;
            arg_5D_0.AddGeometry(arg_5D_1, ref value, ref value2);
            return(geometryCollection as IPolygon);
        }
Ejemplo n.º 10
0
        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)
                });
            }
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public static IGeometry GetExample4()
        {
            const double FromZ = 0;
            const double ToZ   = 8.5;

            //Extrusion: 2D Polygon Composed Of Multiple Square Shaped Rings, Extruded To Generate Multiple
            //           3D Buildings Via ConstructExtrudeFromTo()

            IPolygon polygon = new PolygonClass();

            IGeometryCollection geometryCollection = polygon as IGeometryCollection;

            //Ring 1

            IPointCollection ring1PointCollection = new RingClass();

            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, 1), ref _missing, ref _missing);
            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, 4), ref _missing, ref _missing);
            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, 4), ref _missing, ref _missing);
            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, 1), ref _missing, ref _missing);

            IRing ring1 = ring1PointCollection as IRing;

            ring1.Close();

            geometryCollection.AddGeometry(ring1 as IGeometry, ref _missing, ref _missing);

            //Ring 2

            IPointCollection ring2PointCollection = new RingClass();

            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, -1), ref _missing, ref _missing);
            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, -1), ref _missing, ref _missing);
            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, -4), ref _missing, ref _missing);
            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, -4), ref _missing, ref _missing);

            IRing ring2 = ring2PointCollection as IRing;

            ring2.Close();

            geometryCollection.AddGeometry(ring2 as IGeometry, ref _missing, ref _missing);

            //Ring 3

            IPointCollection ring3PointCollection = new RingClass();

            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, 1), ref _missing, ref _missing);
            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, 1), ref _missing, ref _missing);
            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, 4), ref _missing, ref _missing);
            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, 4), ref _missing, ref _missing);

            IRing ring3 = ring3PointCollection as IRing;

            ring3.Close();

            geometryCollection.AddGeometry(ring3 as IGeometry, ref _missing, ref _missing);

            //Ring 4

            IPointCollection ring4PointCollection = new RingClass();

            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, -1), ref _missing, ref _missing);
            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, -4), ref _missing, ref _missing);
            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, -4), ref _missing, ref _missing);
            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, -1), ref _missing, ref _missing);

            IRing ring4 = ring4PointCollection as IRing;

            ring4.Close();

            geometryCollection.AddGeometry(ring4 as IGeometry, ref _missing, ref _missing);

            IGeometry polygonGeometry = polygon as IGeometry;

            ITopologicalOperator topologicalOperator = polygonGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            IConstructMultiPatch constructMultiPatch = new MultiPatchClass();

            constructMultiPatch.ConstructExtrudeFromTo(FromZ, ToZ, polygonGeometry);

            return(constructMultiPatch as IGeometry);
        }
Ejemplo n.º 14
0
        public static IGeometry GetExample5()
        {
            const double FromZ = 0;
            const double ToZ   = 8.5;

            //Extrusion: 2D Polygon Composed Of Multiple Square Shaped Exterior Rings And Corresponding Interior Rings,
            //           Extruded To Generate Multiple 3D Buildings With Hollow Interiors Via ConstructExtrudeFromTo()

            IPolygon polygon = new PolygonClass();

            IGeometryCollection geometryCollection = polygon as IGeometryCollection;

            //Exterior Ring 1

            IPointCollection exteriorRing1PointCollection = new RingClass();

            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, 1), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, 4), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, 4), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, 1), ref _missing, ref _missing);

            IRing exteriorRing1 = exteriorRing1PointCollection as IRing;

            exteriorRing1.Close();

            geometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing);

            //Interior Ring 1

            IPointCollection interiorRing1PointCollection = new RingClass();

            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1.5, 1.5), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1.5, 3.5), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(3.5, 3.5), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(3.5, 1.5), ref _missing, ref _missing);

            IRing interiorRing1 = interiorRing1PointCollection as IRing;

            interiorRing1.Close();

            geometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing);

            //Exterior Ring 2

            IPointCollection exteriorRing2PointCollection = new RingClass();

            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, -1), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, -1), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(4, -4), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1, -4), ref _missing, ref _missing);

            IRing exteriorRing2 = exteriorRing2PointCollection as IRing;

            exteriorRing2.Close();

            geometryCollection.AddGeometry(exteriorRing2 as IGeometry, ref _missing, ref _missing);

            //Interior Ring 2

            IPointCollection interiorRing2PointCollection = new RingClass();

            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1.5, -1.5), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(3.5, -1.5), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(3.5, -3.5), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(1.5, -3.5), ref _missing, ref _missing);

            IRing interiorRing2 = interiorRing2PointCollection as IRing;

            interiorRing2.Close();

            geometryCollection.AddGeometry(interiorRing2 as IGeometry, ref _missing, ref _missing);

            //Exterior Ring 3

            IPointCollection exteriorRing3PointCollection = new RingClass();

            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, 1), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, 1), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, 4), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, 4), ref _missing, ref _missing);

            IRing exteriorRing3 = exteriorRing3PointCollection as IRing;

            exteriorRing3.Close();

            geometryCollection.AddGeometry(exteriorRing3 as IGeometry, ref _missing, ref _missing);

            //Interior Ring 3

            IPointCollection interiorRing3PointCollection = new RingClass();

            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1.5, 1.5), ref _missing, ref _missing);
            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-3.5, 1.5), ref _missing, ref _missing);
            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-3.5, 3.5), ref _missing, ref _missing);
            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1.5, 3.5), ref _missing, ref _missing);

            IRing interiorRing3 = interiorRing3PointCollection as IRing;

            interiorRing3.Close();

            geometryCollection.AddGeometry(interiorRing3 as IGeometry, ref _missing, ref _missing);

            //Exterior Ring 4

            IPointCollection exteriorRing4PointCollection = new RingClass();

            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, -1), ref _missing, ref _missing);
            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1, -4), ref _missing, ref _missing);
            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, -4), ref _missing, ref _missing);
            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-4, -1), ref _missing, ref _missing);

            IRing exteriorRing4 = exteriorRing4PointCollection as IRing;

            exteriorRing4.Close();

            geometryCollection.AddGeometry(exteriorRing4 as IGeometry, ref _missing, ref _missing);

            //Interior Ring 5

            IPointCollection interiorRing4PointCollection = new RingClass();

            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1.5, -1.5), ref _missing, ref _missing);
            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-1.5, -3.5), ref _missing, ref _missing);
            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-3.5, -3.5), ref _missing, ref _missing);
            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-3.5, -1.5), ref _missing, ref _missing);

            IRing interiorRing4 = interiorRing4PointCollection as IRing;

            interiorRing4.Close();

            geometryCollection.AddGeometry(interiorRing4 as IGeometry, ref _missing, ref _missing);

            IGeometry polygonGeometry = polygon as IGeometry;

            ITopologicalOperator topologicalOperator = polygonGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            IConstructMultiPatch constructMultiPatch = new MultiPatchClass();

            constructMultiPatch.ConstructExtrudeFromTo(FromZ, ToZ, polygonGeometry);

            return(constructMultiPatch as IGeometry);
        }
        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);
        }
Ejemplo n.º 16
0
        public static IGroupElement CreateRoadSurfaceFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0)
        {
            IGroupElement groupElement = null;
            IGroupElement result;

            try
            {
                IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties;
                IGroupElement       groupElement2      = new GroupElement() as IGroupElement;
                if (modFacades.m_limitAngle == 0.0)
                {
                    modFacades.m_limitAngle = 0.5235987666666666;
                }
                IGeometry geometry = null;
                if (ifeature_0 != null)
                {
                    if (ifeature3DProperties_0 != null && bool_0)
                    {
                        ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false);
                        modFacades.g_bFeaturePropertiesApplied = true;
                    }
                    else
                    {
                        geometry = ifeature_0.Shape;
                        modFacades.g_bFeaturePropertiesApplied = false;
                    }
                }
                else if (ipolygon_0 != null)
                {
                    geometry = ipolygon_0;
                }
                if (geometry == null)
                {
                    result = groupElement;
                    return(result);
                }
                if (!(geometry is IMultiPatch))
                {
                }
                IEnvelope envelope = geometry.Envelope;
                double    num      = envelope.ZMin;
                if (modFacades.IsNaN(num))
                {
                    num = 0.0;
                }
                double        num2          = 0.0;
                I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties;
                if (i3DProperties.OffsetExpressionString.Length > 0)
                {
                    num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString);
                }
                if (geometry is IPolygon)
                {
                    num += num2;
                }
                IGeometryCollection geometryCollection = geometry as IGeometryCollection;
                int geometryCount = geometryCollection.GeometryCount;
                int num3;
                if (geometry is IMultiPatch)
                {
                    geometryCount = geometryCollection.GeometryCount;
                    num3          = geometryCollection.GeometryCount * 2 / 3;
                    modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin;
                }
                else
                {
                    num3          = 0;
                    geometryCount = geometryCollection.GeometryCount;
                }
                if (modFacades.m_extrusionHeight >= 1.0)
                {
                }
                for (int i = num3; i <= geometryCount - 1; i++)
                {
                    IGeometry        geometry2    = geometryCollection.get_Geometry(i);
                    esriGeometryType geometryType = geometry2.GeometryType;
                    if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                    }
                    IPointCollection pointCollection = geometry2 as IPointCollection;
                    int pointCount = pointCollection.PointCount;
                    if (pointCount >= 2)
                    {
                    }
                    IVector3D vector3D = new Vector3D() as IVector3D;
                    vector3D.XComponent = 0.0;
                    vector3D.YComponent = 0.0;
                    vector3D.ZComponent = 1.0;
                    double m = 0.0;
                    encode3DProperties.PackNormal(vector3D, out m);
                    IPointCollection pointCollection2 = new Ring();
                    object           value            = Missing.Value;
                    short            num4             = 0;
                    while ((int)num4 <= pointCount - 1)
                    {
                        IPoint point = pointCollection.get_Point((int)num4);
                        point.Z = num;
                        point.M = m;
                        IClone clone = point as IClone;
                        pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                        num4 += 1;
                    }
                    IRing ring = pointCollection2 as IRing;
                    ring.Close();
                    IMultiPatch         multiPatch          = new MultiPatch() as IMultiPatch;
                    IGeometryCollection geometryCollection2 = multiPatch as IGeometryCollection;
                    IZAware             iZAware             = multiPatch as IZAware;
                    iZAware.ZAware = true;
                    IMAware iMAware = multiPatch as IMAware;
                    iMAware.MAware = true;
                    geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                    multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
                    IElement element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString());
                    if (element != null)
                    {
                        groupElement2.AddElement(element);
                    }
                }
                if (groupElement2 != null)
                {
                    IElementProperties elementProperties = groupElement2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                groupElement = groupElement2;
                result       = groupElement;
                return(result);
            }
            catch
            {
            }
            result = groupElement;
            return(result);
        }
Ejemplo n.º 17
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();
        }
        public static IGeometry GetExample4()
        {
            //RingGroup: Upright Square Composed Of Multiple Exterior Rings And Multiple Interior Rings

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Exterior Ring 1

            IPointCollection exteriorRing1PointCollection = new RingClass();

            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, -5), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, -5), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 5), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 5), ref _missing, ref _missing);

            IRing exteriorRing1 = exteriorRing1PointCollection as IRing;

            exteriorRing1.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing1, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 1

            IPointCollection interiorRing1PointCollection = new RingClass();

            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, -4), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, -4), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, 4), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, 4), ref _missing, ref _missing);

            IRing interiorRing1 = interiorRing1PointCollection as IRing;

            interiorRing1.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing1, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Exterior Ring 2

            IPointCollection exteriorRing2PointCollection = new RingClass();

            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 0, -3), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 0, -3), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 0, 3), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 0, 3), ref _missing, ref _missing);

            IRing exteriorRing2 = exteriorRing2PointCollection as IRing;

            exteriorRing2.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing2 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing2, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 2

            IPointCollection interiorRing2PointCollection = new RingClass();

            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-2, 0, -2), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(2, 0, -2), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(2, 0, 2), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-2, 0, 2), ref _missing, ref _missing);

            IRing interiorRing2 = interiorRing2PointCollection as IRing;

            interiorRing2.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing2 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing2, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Exterior Ring 3

            IPointCollection exteriorRing3PointCollection = new RingClass();

            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 0, -1), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 0, -1), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 0, 1), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 0, 1), ref _missing, ref _missing);

            IRing exteriorRing3 = exteriorRing3PointCollection as IRing;

            exteriorRing3.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing3 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing3, esriMultiPatchRingType.esriMultiPatchOuterRing);

            return(multiPatchGeometryCollection as IGeometry);
        }
        public static IGeometry GetExample1()
        {
            //RingGroup: Multiple Rings

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            //Ring 1

            IPointCollection ring1PointCollection = new RingClass();

            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 1, 0), ref _missing, ref _missing);
            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 0), ref _missing, ref _missing);
            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 4, 0), ref _missing, ref _missing);
            ring1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 1, 0), ref _missing, ref _missing);

            IRing ring1 = ring1PointCollection as IRing;

            ring1.Close();

            multiPatchGeometryCollection.AddGeometry(ring1 as IGeometry, ref _missing, ref _missing);

            //Ring 2

            IPointCollection ring2PointCollection = new RingClass();

            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -1, 0), ref _missing, ref _missing);
            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -1, 0), ref _missing, ref _missing);
            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -4, 0), ref _missing, ref _missing);
            ring2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 0), ref _missing, ref _missing);

            IRing ring2 = ring2PointCollection as IRing;

            ring2.Close();

            multiPatchGeometryCollection.AddGeometry(ring2 as IGeometry, ref _missing, ref _missing);

            //Ring 3

            IPointCollection ring3PointCollection = new RingClass();

            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 1, 0), ref _missing, ref _missing);
            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 1, 0), ref _missing, ref _missing);
            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 4, 0), ref _missing, ref _missing);
            ring3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 0), ref _missing, ref _missing);

            IRing ring3 = ring3PointCollection as IRing;

            ring3.Close();

            multiPatchGeometryCollection.AddGeometry(ring3 as IGeometry, ref _missing, ref _missing);

            //Ring 4

            IPointCollection ring4PointCollection = new RingClass();

            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -1, 0), ref _missing, ref _missing);
            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 0), ref _missing, ref _missing);
            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -4, 0), ref _missing, ref _missing);
            ring4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -1, 0), ref _missing, ref _missing);

            IRing ring4 = ring4PointCollection as IRing;

            ring4.Close();

            multiPatchGeometryCollection.AddGeometry(ring4 as IGeometry, ref _missing, ref _missing);

            return(multiPatchGeometryCollection as IGeometry);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_mapControl"></param>
        /// <param name="circle"></param>
        public Circle_ArcMap(AxMapControl _mapControl, KmlCircle circle, FactoryArcMap facArc)
        {
            this.mapControl    = _mapControl;
            this.factoryArcMap = facArc;

            Dosomething(new Action(delegate
            {
                lineSymbol       = new SimpleLineSymbolClass();
                lineSymbol.Color = new RgbColorClass()
                {
                    Red   = circle.StrokeColor.R,
                    Green = circle.StrokeColor.B,
                    Blue  = circle.StrokeColor.B
                };
                lineSymbol.Width = circle.StrokeWidth;

                fillSymbol         = new SimpleFillSymbol();
                fillSymbol.Outline = lineSymbol;
                //填充色
                IColor fillColor = new RgbColorClass()
                {
                    Transparency = circle.FillColor.A,
                    Red          = circle.FillColor.R,
                    Green        = circle.FillColor.G,
                    Blue         = circle.FillColor.B
                };
                fillSymbol.Color = fillColor;

                base.Symbol = fillSymbol;//颜色和风格

                iSeg        = new RingClass();
                centerPoint = new PointClass();//圆心坐标
                centerPoint.PutCoords(circle.Position.Lng, circle.Position.Lat);
                MapLngLat around          = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)circle.Radius, circle.Position, 180);
                INewLineFeedback backline = new NewLineFeedbackClass();
                IPoint aroundPoint        = new PointClass()
                {
                    X = around.Lng, Y = around.Lat
                };
                backline.Start(centerPoint);
                backline.AddPoint(aroundPoint);
                var geo = backline.Stop();

                iSeg.SetCircle(centerPoint, geo.Length);
                object o = System.Type.Missing;
                pRing    = iSeg as IRing;
                pRing.Close();

                pGeometryColl = new PolygonClass();
                pGeometryColl.AddGeometry(pRing, ref o, ref o);
                pGeometry = pGeometryColl as IGeometry;

                base.Geometry = pGeometry;
            }), true);

            pRadius       = circle.Radius;
            bOutLineColor = circle.StrokeColor;
            bFillColor    = circle.FillColor;
            bWidth        = circle.StrokeWidth;

            flashTimer          = new Timer();
            flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed);

            #region MyRegion

            //if (mapControl.InvokeRequired)
            //{
            //    mapControl.Invoke((Action)delegate()
            //    {
            //        lineSymbol = new SimpleLineSymbolClass();
            //        lineSymbol.Color = new RgbColorClass()
            //        {
            //            Red = circle.StrokeColor.R,
            //            Green = circle.StrokeColor.B,
            //            Blue = circle.StrokeColor.B
            //        };
            //        lineSymbol.Width = circle.StrokeWidth;

            //        fillSymbol = new SimpleFillSymbol();
            //        fillSymbol.Outline = lineSymbol;
            //        //填充色
            //        IColor fillColor = new RgbColorClass()
            //        {
            //            Transparency = circle.FillColor.A,
            //            Red = circle.FillColor.R,
            //            Green = circle.FillColor.G,
            //            Blue = circle.FillColor.B
            //        };
            //        fillSymbol.Color = fillColor;

            //        base.Symbol = fillSymbol;//颜色和风格

            //        iSeg = new RingClass();
            //        centerPoint = new PointClass();//圆心坐标
            //        centerPoint.PutCoords(circle.Position.Lng, circle.Position.Lat);
            //        //MapFrame.Core.Model.MapLngLat around = GetPointByDistanceAndAngle(circle.Radius, circle.Position);
            //        MapLngLat around = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)circle.Radius, circle.Position, 180);
            //        INewLineFeedback backline = new NewLineFeedbackClass();
            //        IPoint aroundPoint = new PointClass() { X = around.Lng, Y = around.Lat };
            //        backline.Start(centerPoint);
            //        backline.AddPoint(aroundPoint);
            //        var geo = backline.Stop();

            //        iSeg.SetCircle(centerPoint, geo.Length);
            //        object o = System.Type.Missing;
            //        pRing = iSeg as IRing;
            //        pRing.Close();

            //        pGeometryColl = new PolygonClass();
            //        pGeometryColl.AddGeometry(pRing, ref o, ref o);
            //        pGeometry = pGeometryColl as IGeometry;

            //        base.Geometry = pGeometry;
            //    });
            //}
            //else
            //{
            //    lineSymbol = new SimpleLineSymbolClass();
            //    lineSymbol.Color = new RgbColorClass()
            //    {
            //        Red = circle.StrokeColor.R,
            //        Green = circle.StrokeColor.B,
            //        Blue = circle.StrokeColor.B
            //    };
            //    lineSymbol.Width = circle.StrokeWidth;


            //    fillSymbol = new SimpleFillSymbol();
            //    fillSymbol.Outline = lineSymbol;
            //    //填充色
            //    IColor fillColor = new RgbColorClass()
            //    {
            //        Transparency = circle.FillColor.A,
            //        Red = circle.FillColor.R,
            //        Green = circle.FillColor.G,
            //        Blue = circle.FillColor.B
            //    };
            //    fillSymbol.Color = fillColor;

            //    base.Symbol = fillSymbol;//颜色和风格

            //    iSeg = new RingClass();
            //    centerPoint = new PointClass();//圆心坐标
            //    centerPoint.PutCoords(circle.Position.Lng, circle.Position.Lat);
            //    //MapFrame.Core.Model.MapLngLat around = GetPointByDistanceAndAngle(circle.Radius, circle.Position);
            //    MapLngLat around = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)circle.Radius, circle.Position, 180);
            //    INewLineFeedback backline = new NewLineFeedbackClass();
            //    IPoint aroundPoint = new PointClass() { X = around.Lng, Y = around.Lat };
            //    backline.Start(centerPoint);
            //    backline.AddPoint(aroundPoint);
            //    var geo = backline.Stop();

            //    iSeg.SetCircle(centerPoint, geo.Length);
            //    object o = System.Type.Missing;
            //    pRing = iSeg as IRing;
            //    pRing.Close();

            //    pGeometryColl = new PolygonClass();
            //    pGeometryColl.AddGeometry(pRing, ref o, ref o);
            //    pGeometry = pGeometryColl as IGeometry;

            //    base.Geometry = pGeometry;
            //}
            #endregion
        }
Ejemplo n.º 21
0
        public static IGeometry GetExample2()
        {
            //Composite: Cutaway Of Building With Multiple Floors Composed Of 1 TriangleStrip And 5 Ring Parts

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Walls

            IPointCollection wallsPointCollection = new TriangleStripClass();

            //Start

            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 0), ref _missing, ref _missing);
            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 16), ref _missing, ref _missing);

            //Right Wall

            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 0), ref _missing, ref _missing);
            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 16), ref _missing, ref _missing);

            //Back Wall

            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 0), ref _missing, ref _missing);
            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 16), ref _missing, ref _missing);

            //Left Wall

            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 0), ref _missing, ref _missing);
            wallsPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 16), ref _missing, ref _missing);

            multiPatchGeometryCollection.AddGeometry(wallsPointCollection as IGeometry, ref _missing, ref _missing);

            //Floors

            //Base

            IPointCollection basePointCollection = new RingClass();

            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 0), ref _missing, ref _missing);

            IRing baseRing = basePointCollection as IRing;

            baseRing.Close();

            multiPatchGeometryCollection.AddGeometry(baseRing as IGeometry, ref _missing, ref _missing);

            //First Floor

            IPointCollection firstFloorPointCollection = new RingClass();

            firstFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 4), ref _missing, ref _missing);
            firstFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 4), ref _missing, ref _missing);
            firstFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 4), ref _missing, ref _missing);
            firstFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 4), ref _missing, ref _missing);

            IRing firstFloorRing = firstFloorPointCollection as IRing;

            firstFloorRing.Close();

            multiPatchGeometryCollection.AddGeometry(firstFloorRing as IGeometry, ref _missing, ref _missing);

            //Second Floor

            IPointCollection secondFloorPointCollection = new RingClass();

            secondFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 8), ref _missing, ref _missing);
            secondFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 8), ref _missing, ref _missing);
            secondFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 8), ref _missing, ref _missing);
            secondFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 8), ref _missing, ref _missing);

            IRing secondFloorRing = secondFloorPointCollection as IRing;

            secondFloorRing.Close();

            multiPatchGeometryCollection.AddGeometry(secondFloorRing as IGeometry, ref _missing, ref _missing);

            //Third Floor

            IPointCollection thirdFloorPointCollection = new RingClass();

            thirdFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 12), ref _missing, ref _missing);
            thirdFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 12), ref _missing, ref _missing);
            thirdFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 12), ref _missing, ref _missing);
            thirdFloorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 12), ref _missing, ref _missing);

            IRing thirdFloorRing = thirdFloorPointCollection as IRing;

            thirdFloorRing.Close();

            multiPatchGeometryCollection.AddGeometry(thirdFloorRing as IGeometry, ref _missing, ref _missing);

            //Roof

            IPointCollection roofPointCollection = new RingClass();

            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 3, 16), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, -3, 16), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, -3, 16), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 3, 16), ref _missing, ref _missing);

            IRing roofRing = roofPointCollection as IRing;

            roofRing.Close();

            multiPatchGeometryCollection.AddGeometry(roofRing as IGeometry, ref _missing, ref _missing);

            return(multiPatchGeometryCollection as IGeometry);
        }
Ejemplo n.º 22
0
        public static IGeometry GetExample4()
        {
            const double CircleDegrees                   = 360.0;
            const int    CircleDivisions                 = 18;
            const double VectorComponentOffset           = 0.0000001;
            const double InnerBuildingRadius             = 3.0;
            const double OuterBuildingExteriorRingRadius = 9.0;
            const double OuterBuildingInteriorRingRadius = 6.0;
            const double BaseZ          = 0.0;
            const double InnerBuildingZ = 16.0;
            const double OuterBuildingZ = 6.0;

            //Composite: Tall Building Protruding Through Outer Ring-Shaped Building

            IMultiPatch multiPatch = new MultiPatchClass();

            IGeometryCollection multiPatchGeometryCollection = multiPatch as IGeometryCollection;

            IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0);

            IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10);

            IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10);

            lowerAxisVector3D.XComponent += VectorComponentOffset;

            IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D;

            double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions);

            //Inner Building

            IGeometry innerBuildingBaseGeometry = new PolygonClass();

            IPointCollection innerBuildingBasePointCollection = innerBuildingBaseGeometry as IPointCollection;

            //Outer Building

            IGeometry outerBuildingBaseGeometry = new PolygonClass();

            IGeometryCollection outerBuildingBaseGeometryCollection = outerBuildingBaseGeometry as IGeometryCollection;

            IPointCollection outerBuildingBaseExteriorRingPointCollection = new RingClass();

            IPointCollection outerBuildingBaseInteriorRingPointCollection = new RingClass();

            for (int i = 0; i < CircleDivisions; i++)
            {
                normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D);

                //Inner Building

                normalVector3D.Magnitude = InnerBuildingRadius;

                IPoint innerBuildingBaseVertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent,
                                                                                         originPoint.Y + normalVector3D.YComponent);

                innerBuildingBasePointCollection.AddPoint(innerBuildingBaseVertexPoint, ref _missing, ref _missing);

                //Outer Building

                //Exterior Ring

                normalVector3D.Magnitude = OuterBuildingExteriorRingRadius;

                IPoint outerBuildingBaseExteriorRingVertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent,
                                                                                                     originPoint.Y + normalVector3D.YComponent);

                outerBuildingBaseExteriorRingPointCollection.AddPoint(outerBuildingBaseExteriorRingVertexPoint, ref _missing, ref _missing);

                //Interior Ring

                normalVector3D.Magnitude = OuterBuildingInteriorRingRadius;

                IPoint outerBuildingBaseInteriorRingVertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent,
                                                                                                     originPoint.Y + normalVector3D.YComponent);

                outerBuildingBaseInteriorRingPointCollection.AddPoint(outerBuildingBaseInteriorRingVertexPoint, ref _missing, ref _missing);
            }

            IPolygon innerBuildingBasePolygon = innerBuildingBaseGeometry as IPolygon;

            innerBuildingBasePolygon.Close();

            IRing outerBuildingBaseExteriorRing = outerBuildingBaseExteriorRingPointCollection as IRing;

            outerBuildingBaseExteriorRing.Close();

            IRing outerBuildingBaseInteriorRing = outerBuildingBaseInteriorRingPointCollection as IRing;

            outerBuildingBaseInteriorRing.Close();
            outerBuildingBaseInteriorRing.ReverseOrientation();

            outerBuildingBaseGeometryCollection.AddGeometry(outerBuildingBaseExteriorRing as IGeometry, ref _missing, ref _missing);
            outerBuildingBaseGeometryCollection.AddGeometry(outerBuildingBaseInteriorRing as IGeometry, ref _missing, ref _missing);

            ITopologicalOperator topologicalOperator = outerBuildingBaseGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            IConstructMultiPatch innerBuildingConstructMultiPatch = new MultiPatchClass();

            innerBuildingConstructMultiPatch.ConstructExtrudeFromTo(BaseZ, InnerBuildingZ, innerBuildingBaseGeometry);

            IGeometryCollection innerBuildingMultiPatchGeometryCollection = innerBuildingConstructMultiPatch as IGeometryCollection;

            for (int i = 0; i < innerBuildingMultiPatchGeometryCollection.GeometryCount; i++)
            {
                multiPatchGeometryCollection.AddGeometry(innerBuildingMultiPatchGeometryCollection.get_Geometry(i), ref _missing, ref _missing);
            }

            IConstructMultiPatch outerBuildingConstructMultiPatch = new MultiPatchClass();

            outerBuildingConstructMultiPatch.ConstructExtrudeFromTo(BaseZ, OuterBuildingZ, outerBuildingBaseGeometry);

            IMultiPatch outerBuildingMultiPatch = outerBuildingConstructMultiPatch as IMultiPatch;

            IGeometryCollection outerBuildingMultiPatchGeometryCollection = outerBuildingConstructMultiPatch as IGeometryCollection;

            for (int i = 0; i < outerBuildingMultiPatchGeometryCollection.GeometryCount; i++)
            {
                IGeometry outerBuildingPatchGeometry = outerBuildingMultiPatchGeometryCollection.get_Geometry(i);

                multiPatchGeometryCollection.AddGeometry(outerBuildingPatchGeometry, ref _missing, ref _missing);

                if (outerBuildingPatchGeometry.GeometryType == esriGeometryType.esriGeometryRing)
                {
                    bool isBeginningRing = false;

                    esriMultiPatchRingType multiPatchRingType = outerBuildingMultiPatch.GetRingType(outerBuildingPatchGeometry as IRing, ref isBeginningRing);

                    multiPatch.PutRingType(outerBuildingPatchGeometry as IRing, multiPatchRingType);
                }
            }

            return(multiPatchGeometryCollection as IGeometry);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Create a geojson string from the geometry
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns></returns>
        public static GeoJSONGeometry CreateFromIGeometry(IGeometry geometry)
        {
            GeoJSONGeometry jsonGeom = new GeoJSONGeometry();

            jsonGeom.Type = geometry.GeometryType.ToString();
            StringBuilder sb = new StringBuilder();

            if (geometry.GeometryType != esriGeometryType.esriGeometryPoint)
            {
                sb.Append("[");
            }
            //Need to work out how to easily rip the coords out of the IGeometry

            switch (geometry.GeometryType)
            {
            case esriGeometryType.esriGeometryPoint:
                IPoint pt = (IPoint)geometry;
                sb.Append(string.Format("[{0}, {1}]", Math.Round(pt.X, 5), Math.Round(pt.Y, 5)));
                jsonGeom.Type = "Point";
                break;

            case esriGeometryType.esriGeometryLine:
                IPolyline line = geometry as IPolyline;
                if (line == null)
                {
                    return(null);
                }

                line.Densify(-1, -1);   //make sure it's all straight line segments
                line.Weed(20);          //weed out some vertices
                line.SimplifyNetwork(); //make sure it is simple


                IPointCollection points = line as IPointCollection;
                for (int i = 0; i < points.PointCount; i++)
                {
                    IPoint point = points.get_Point(i);
                    if (sb.Length > 1)
                    {
                        sb.Append(",");
                    }
                    sb.Append(string.Format("[{0}, {1}]", Math.Round(point.X, 4), Math.Round(point.Y, 4)));
                }

                jsonGeom.Type = "LineString";
                break;

            case esriGeometryType.esriGeometryPolygon:
                IPolygon4 poly = geometry as IPolygon4;
                if (poly == null)
                {
                    return(null);
                }

                poly.Densify(-1, -1);          //make sure it is all straight line segments
                poly.Weed(20);                 //weed out some vertices
                poly.SimplifyPreserveFromTo(); //make sure it's simple

                //We aren't gonna deal with interior rings right now (ie - no holes in polygons)
                IGeometryBag  multiRing         = poly.ExteriorRingBag;
                IEnumGeometry exteriorRingsEnum = multiRing as IEnumGeometry;
                exteriorRingsEnum.Reset();
                IRing currentExteriorRing = exteriorRingsEnum.Next() as IRing;
                while (currentExteriorRing != null)
                {
                    if (!currentExteriorRing.IsClosed)
                    {
                        currentExteriorRing.Close();
                    }

                    IPointCollection multiRingPoints = currentExteriorRing as IPointCollection;
                    for (int pointIdx = 0; pointIdx < multiRingPoints.PointCount; pointIdx++)
                    {
                        IPoint multiRingPoint = multiRingPoints.get_Point(pointIdx);
                        //coords.Add(new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(Math.Round(multiRingPoint.X, 5), Math.Round(multiRingPoint.Y, 5)));
                        if (sb.Length > 1)
                        {
                            sb.Append(",");
                        }
                        sb.Append(string.Format("[{0}, {1}]", Math.Round(multiRingPoint.X, 4), Math.Round(multiRingPoint.Y, 4)));
                    }

                    currentExteriorRing = exteriorRingsEnum.Next() as IRing;
                }
                jsonGeom.Type = "Polygon";
                break;
            }


            if (geometry.GeometryType != esriGeometryType.esriGeometryPoint)
            {
                sb.Append("]");
            }
            jsonGeom.coordinates = sb.ToString();
            return(jsonGeom);
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
0
        public static IGroupElement CreateFacadesFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0)
        {
            IGroupElement groupElement = null;
            IGroupElement result;

            try
            {
                IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties;
                IGroupElement       groupElement2      = new GroupElement() as IGroupElement;
                if (modFacades.m_limitAngle == 0.0)
                {
                    modFacades.m_limitAngle = 0.5235987666666666;
                }
                IGeometry geometry = null;
                if (ifeature_0 != null)
                {
                    if (ifeature3DProperties_0 != null && bool_0)
                    {
                        ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false);
                    }
                    else
                    {
                        geometry = ifeature_0.Shape;
                    }
                }
                else if (ipolygon_0 != null)
                {
                    geometry = ipolygon_0;
                }
                if (geometry == null)
                {
                    result = null;
                    return(result);
                }
                if (!(geometry is IMultiPatch))
                {
                }
                IEnvelope         envelope         = geometry.Envelope;
                double            num              = envelope.ZMin;
                ISpatialReference spatialReference = BuildingProperty.Scene.SpatialReference;
                geometry.Project(spatialReference);
                string a = num.ToString();
                if (a.Equals("非数字"))
                {
                    num = 0.0;
                }
                double num2 = 0.0;
                if (ifeature3DProperties_0 != null)
                {
                    I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties;
                    if (i3DProperties.OffsetExpressionString.Length > 0)
                    {
                        try
                        {
                            num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString);
                        }
                        catch
                        {
                        }
                    }
                    if (geometry is IPolygon)
                    {
                        num += num2;
                    }
                }
                IGeometryCollection geometryCollection = geometry as IGeometryCollection;
                int geometryCount = geometryCollection.GeometryCount;
                int num3;
                if (geometry is IMultiPatch)
                {
                    geometryCount = geometryCollection.GeometryCount;
                    num3          = geometryCollection.GeometryCount * 2 / 3;
                    modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin;
                }
                else
                {
                    num3          = 0;
                    geometryCount = geometryCollection.GeometryCount;
                }
                if (modFacades.m_extrusionHeight < 1.0)
                {
                    modFacades.m_extrusionHeight = 1.0;
                }
                IPoint point = null;
                double num4  = 0.0;
                double num5  = 0.0;
                double num6  = 0.0;
                object value = Missing.Value;
                for (int i = num3; i < geometryCount; i++)
                {
                    IGeometry        geometry2    = geometryCollection.get_Geometry(i);
                    esriGeometryType geometryType = geometry2.GeometryType;
                    if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPointCollection pointCollection = geometry2 as IPointCollection;
                        int pointCount = pointCollection.PointCount;
                        if (pointCount >= 2)
                        {
                            int                 num7 = 0;
                            int                 num8 = 1;
                            bool                flag = false;
                            IPointCollection    pointCollection2;
                            double              m;
                            IMultiPatch         multiPatch;
                            IGeometryCollection geometryCollection2;
                            IZAware             iZAware;
                            IMAware             iMAware;
                            IElement            element;
                            while (!flag)
                            {
                                bool flag2 = false;
                                while (num8 < pointCount && !flag2)
                                {
                                    if (num8 - num7 == 1)
                                    {
                                        IPoint point2 = pointCollection.get_Point(num7);
                                        point = pointCollection.get_Point(num8);
                                        num5  = point.X - point2.X;
                                        num6  = point.Y - point2.Y;
                                        num4  = Math.Sqrt(num5 * num5 + num6 * num6);
                                        if (isurface_0 != null)
                                        {
                                            num  = isurface_0.get_Z(point.X, point.Y);
                                            num += num2;
                                        }
                                    }
                                    else
                                    {
                                        IPoint point2 = point;
                                        double num9   = num5;
                                        double num10  = num6;
                                        point = pointCollection.get_Point(num8);
                                        if (isurface_0 != null)
                                        {
                                            num  = isurface_0.get_Z(point.X, point.Y);
                                            num += num2;
                                        }
                                        num5 = point.X - point2.X;
                                        num6 = point.Y - point2.Y;
                                        double num11 = Math.Sqrt(num9 * num9 + num10 * num10);
                                        double num12 = Math.Sqrt(num5 * num5 + num6 * num6);
                                        double num13 = (num9 * num5 + num10 * num6) / (num11 * num12);
                                        if (num13 < Math.Cos(modFacades.m_limitAngle))
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                        num4 += num12;
                                    }
                                    num8++;
                                }
                                if (flag2)
                                {
                                    num8--;
                                }
                                else
                                {
                                    num8--;
                                }
                                pointCollection2 = new TriangleStrip();
                                double num14 = 0.0;
                                for (int j = num7; j <= num8; j++)
                                {
                                    if (j > 0)
                                    {
                                        IPoint point2 = point;
                                        point  = pointCollection.get_Point(j);
                                        num5   = point.X - point2.Y;
                                        num6   = point.Y - point2.Y;
                                        num14 += Math.Sqrt(num5 * num5 + num6 * num6);
                                    }
                                    else
                                    {
                                        point = pointCollection.get_Point(j);
                                    }
                                    point.Z = num;
                                    m       = 0.0;
                                    encode3DProperties.PackTexture2D(num14 / num4, 0.0, out m);
                                    point.M = m;
                                    IClone clone = point as IClone;
                                    pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                                    point.Z = num + modFacades.m_extrusionHeight;
                                    m       = 0.0;
                                    encode3DProperties.PackTexture2D(num14 / num4, -1.0, out m);
                                    point.M = m;
                                    pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                                }
                                multiPatch          = new MultiPatch() as IMultiPatch;
                                geometryCollection2 = (multiPatch as IGeometryCollection);
                                iZAware             = (multiPatch as IZAware);
                                iZAware.ZAware      = true;
                                iMAware             = (multiPatch as IMAware);
                                iMAware.MAware      = true;
                                geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                                if (clsTextureGroup_0 != null)
                                {
                                    int index = modFacades.FindTextureByAspect(clsTextureGroup_0, num4 / modFacades.m_extrusionHeight);
                                    element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.Symbols[index], string_0);
                                }
                                else
                                {
                                    element = modFacades.CreateElement(multiPatch, null, string_0);
                                }
                                if (element != null)
                                {
                                    groupElement2.AddElement(element);
                                }
                                num7 = num8;
                                num8 = num7 + 1;
                                if (num7 >= pointCount - 1)
                                {
                                    flag = true;
                                }
                            }
                            IVector3D vector3D = new Vector3D() as IVector3D;
                            vector3D.XComponent = 0.0;
                            vector3D.YComponent = 0.0;
                            vector3D.ZComponent = 1.0;
                            m = 0.0;
                            encode3DProperties.PackNormal(vector3D, out m);
                            pointCollection2 = new Ring();
                            for (int j = 0; j <= pointCount - 1; j++)
                            {
                                IPoint point3 = pointCollection.get_Point(j);
                                point3.Z = num + modFacades.m_extrusionHeight;
                                point3.M = 0.0;
                                IClone clone = point3 as IClone;
                                pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                            }
                            IRing ring = pointCollection2 as IRing;
                            ring.Close();
                            multiPatch          = new MultiPatch() as IMultiPatch;
                            geometryCollection2 = (multiPatch as IGeometryCollection);
                            iZAware             = (multiPatch as IZAware);
                            iZAware.ZAware      = true;
                            iMAware             = (multiPatch as IMAware);
                            iMAware.MAware      = true;
                            geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                            multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
                            if (clsTextureGroup_0 != null)
                            {
                                element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString());
                            }
                            else
                            {
                                element = modFacades.CreateElement(multiPatch, null, string_0 + ";ROOFCOLOR=1");
                            }
                            if (element != null)
                            {
                                groupElement2.AddElement(element);
                            }
                        }
                    }
                }
                if (groupElement2 != null)
                {
                    IElementProperties elementProperties = groupElement2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                groupElement = groupElement2;
                result       = groupElement;
                return(result);
            }
            catch
            {
            }
            result = groupElement;
            return(result);
        }
Ejemplo n.º 26
0
        /// <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();
            }
        }
        public static IGeometry GetExample2()
        {
            //RingGroup: Multiple Exterior Rings With Corresponding Interior Rings

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Exterior Ring 1

            IPointCollection exteriorRing1PointCollection = new RingClass();

            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 1, 0), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 0), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 4, 0), ref _missing, ref _missing);
            exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 1, 0), ref _missing, ref _missing);

            IRing exteriorRing1 = exteriorRing1PointCollection as IRing;

            exteriorRing1.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing1, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 1

            IPointCollection interiorRing1PointCollection = new RingClass();

            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, 1.5, 0), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, 3.5, 0), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, 3.5, 0), ref _missing, ref _missing);
            interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, 1.5, 0), ref _missing, ref _missing);

            IRing interiorRing1 = interiorRing1PointCollection as IRing;

            interiorRing1.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing1, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Exterior Ring 2

            IPointCollection exteriorRing2PointCollection = new RingClass();

            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -1, 0), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -1, 0), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -4, 0), ref _missing, ref _missing);
            exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 0), ref _missing, ref _missing);

            IRing exteriorRing2 = exteriorRing2PointCollection as IRing;

            exteriorRing2.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing2 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing2, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 2

            IPointCollection interiorRing2PointCollection = new RingClass();

            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, -1.5, 0), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, -1.5, 0), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, -3.5, 0), ref _missing, ref _missing);
            interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, -3.5, 0), ref _missing, ref _missing);

            IRing interiorRing2 = interiorRing2PointCollection as IRing;

            interiorRing2.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing2 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing2, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Exterior Ring 3

            IPointCollection exteriorRing3PointCollection = new RingClass();

            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 1, 0), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 1, 0), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 4, 0), ref _missing, ref _missing);
            exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 0), ref _missing, ref _missing);

            IRing exteriorRing3 = exteriorRing3PointCollection as IRing;

            exteriorRing3.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing3 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing3, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 3

            IPointCollection interiorRing3PointCollection = new RingClass();

            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, 1.5, 0), ref _missing, ref _missing);
            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, 1.5, 0), ref _missing, ref _missing);
            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, 3.5, 0), ref _missing, ref _missing);
            interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, 3.5, 0), ref _missing, ref _missing);

            IRing interiorRing3 = interiorRing3PointCollection as IRing;

            interiorRing3.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing3 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing3, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Exterior Ring 4

            IPointCollection exteriorRing4PointCollection = new RingClass();

            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -1, 0), ref _missing, ref _missing);
            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 0), ref _missing, ref _missing);
            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -4, 0), ref _missing, ref _missing);
            exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -1, 0), ref _missing, ref _missing);

            IRing exteriorRing4 = exteriorRing4PointCollection as IRing;

            exteriorRing4.Close();

            multiPatchGeometryCollection.AddGeometry(exteriorRing4 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(exteriorRing4, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring 4

            IPointCollection interiorRing4PointCollection = new RingClass();

            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, -1.5, 0), ref _missing, ref _missing);
            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, -3.5, 0), ref _missing, ref _missing);
            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, -3.5, 0), ref _missing, ref _missing);
            interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, -1.5, 0), ref _missing, ref _missing);

            IRing interiorRing4 = interiorRing4PointCollection as IRing;

            interiorRing4.Close();

            multiPatchGeometryCollection.AddGeometry(interiorRing4 as IGeometry, ref _missing, ref _missing);

            multiPatch.PutRingType(interiorRing4, esriMultiPatchRingType.esriMultiPatchInnerRing);

            return(multiPatchGeometryCollection as IGeometry);
        }