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;
        }
        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);
        }
Пример #3
0
    //----------------------------------------------------------------------------------



    private static IPointCollection MaakRingPointCollection()
    {
        IPointCollection RingPointCollection = new RingClass();
        int vertexaantal = ImportInArcscene.binReader.ReadInt32();

        for (int j = 0; j < vertexaantal; j++)
        {
            double ptx = ImportInArcscene.binReader.ReadSingle();
            double pty = ImportInArcscene.binReader.ReadSingle();
            double ptz = ImportInArcscene.binReader.ReadSingle();
            RingPointCollection.AddPoint(PuntTransformatie(ptx, pty, ptz), ref _missing, ref _missing);
        }
        RingPointCollection.AddPoint(RingPointCollection.get_Point(0), ref _missing, ref _missing);

        return(RingPointCollection);
    }
Пример #4
0
        /// <summary>
        /// 将字符串格式转化为Geometry
        /// </summary>
        /// <param name="geom">    客户端传递多边形格式 1) x1,y1;x2,y2;x3,y3.......xn,yn;x1,y1;保证起始闭合 为无环
        ///                                            2) x1,y1,flag3;x2,y2,flag3;x3,y3,flag3.......xn,yn,,flagn;
        /// </param>
        /// <returns></returns>
        public static IPolygon BuildPolygon(string geom)
        {
            if (string.IsNullOrEmpty(geom) == true)
            {
                throw new Exception(sErroCoordinatesIsNull);
            }

            string[] points = geom.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (points != null && points.Length > 2)
            {
                int pointCount = points.Length;
                IPolygon polygon = null;
                IPoint point = null;
                object missing = Type.Missing;
                IGeometryCollection pGeoColl = new PolygonClass() as IGeometryCollection;
                IPointCollection pPointCol = new RingClass();
                for (int i = 0; i < pointCount; i++)
                {
                    string[] pts = points[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    point = new PointClass();
                    double x = 0.0;
                    double y = 0.0;
                    int flag = 0;
                    bool bX = double.TryParse(pts[0], out x);
                    bool bY = double.TryParse(pts[1], out y);
                    bool bFlag = int.TryParse(pts[2], out flag);
                    if (bX && bY && bFlag)
                    {
                        pPointCol.AddPoint(point, ref  missing, ref missing);
                        if (flag == -1 || i == (pointCount - 1))
                        {
                            pGeoColl.AddGeometry(pPointCol as IRing, ref missing, ref missing);
                            pPointCol = null;
                            break;
                        }
                        else if (flag == -2)
                        {
                            pGeoColl.AddGeometry(pPointCol as IRing, ref missing, ref missing);
                            pPointCol = new RingClass();
                            continue;
                        }
                    }
                    else
                    {
                        throw new Exception(sErroCoordinatesValueIllegal);
                    }
                }
                if (pPointCol.PointCount > 0)
                {
                    pGeoColl.AddGeometry(pPointCol as IRing, ref missing, ref missing);
                }
                polygon = pGeoColl as IPolygon;
                SimplifyGeometry(polygon);
                return polygon;
            }
            else
            {
                throw new Exception(sErroCoordinatesValueIllegal);
            }
        }
Пример #5
0
        public CurveConstruction MoveTo([NotNull] IPoint point)
        {
            object missing = Type.Missing;

            if (Curve is IPolygon)
            {
                var rings    = (IGeometryCollection)Curve;
                var lastRing = (IRing)rings.Geometry[rings.GeometryCount - 1];
                lastRing.Close();

                IPointCollection newRing = new RingClass();
                newRing.AddPoint(point, ref missing, ref missing);

                rings.AddGeometry((IGeometry)newRing, ref missing, ref missing);
            }
            else if (Curve is IPolyline)
            {
                var paths = (IGeometryCollection)Curve;

                IPointCollection newPath = new PathClass();
                newPath.AddPoint(point, ref missing, ref missing);

                paths.AddGeometry((IGeometry)newPath, ref missing, ref missing);
            }
            else
            {
                throw new NotImplementedException("Unhandled geometryType" + Curve.GeometryType);
            }

            return(this);
        }
        public static IGeometry GetExample1()
        {
            //Ring: Upright Rectangle

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IPointCollection ringPointCollection = new RingClass();

            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 0, 7.5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, 0, 7.5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 0, 0), ref _missing, ref _missing);

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

            return multiPatchGeometryCollection as IGeometry;
        }
        public static IGeometry GetExample1()
        {
            //Ring: Upright Rectangle

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IPointCollection ringPointCollection = new RingClass();

            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 0, 7.5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, 0, 7.5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 0, 0), ref _missing, ref _missing);

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

            return(multiPatchGeometryCollection as IGeometry);
        }
        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);
        }
        //根据读取出来的坐标,创建新要素
        private void CreateFeatures(IFeatureClass targetClass, List <List <Vertex> > polygons, string TBBHFieldName)
        {
            //编辑器
            IWorkspaceEdit m_WorkspaceEdit = (targetClass as IDataset).Workspace as IWorkspaceEdit;

            m_WorkspaceEdit.StartEditing(true);
            m_WorkspaceEdit.StartEditOperation();

            //一个一个多边形地处理,对应一个要素
            foreach (List <Vertex> polygon in polygons)
            {
                IFeature newFeature = targetClass.CreateFeature();
                Ring     ring       = new RingClass();
                object   missing    = Type.Missing;
                //把每个顶点添加到环
                foreach (Vertex vertex in polygon)
                {
                    IPoint pt = new PointClass();
                    double X  = vertex.X;
                    double Y  = vertex.Y;
                    pt.PutCoords(X, Y);
                    ring.AddPoint(pt, ref missing, ref missing);
                }
                //投影
                IGeometry   geometry    = ring as IGeometry;
                IGeoDataset pGeoDataset = targetClass as IGeoDataset;
                if (pGeoDataset.SpatialReference != null)
                {
                    geometry.Project(pGeoDataset.SpatialReference);
                }
                else
                {
                    geometry.Project(pMapControl.SpatialReference);
                }
                //环构成多边形
                IGeometryCollection newPolygon = new PolygonClass();
                newPolygon.AddGeometry(geometry, ref missing, ref missing);
                IPolygon newPolygon2 = newPolygon as IPolygon;
                newPolygon2.SimplifyPreserveFromTo();
                newFeature.Shape = newPolygon2 as IGeometry;
                //加上TBBH属性
                int fieldIndex = newFeature.Fields.FindField(TBBHFieldName);
                newFeature.set_Value(fieldIndex, polygon[0].TBBH);//取任意一个顶点的tbbh
                newFeature.Store();
            }
            //保存
            m_WorkspaceEdit.StopEditOperation();
            m_WorkspaceEdit.StopEditing(true);
            IFeatureLayer pFeatureLayer = new FeatureLayerClass();

            pFeatureLayer.FeatureClass = targetClass;
        }
Пример #10
0
        private IGeometry ConstructRing(IEnumerable <IPoint> points)
        {
            var r = new RingClass();

            foreach (var point in points)
            {
                r.AddPoint(point);
            }

            r.Close();

            return(r);
        }
Пример #11
0
        public IGeometry XpgisFeatureToGeometry(ICoFeature icoFeature_0)
        {
            object before = Missing.Value;

            switch (icoFeature_0.Type)
            {
            case CoFeatureType.Point:
            {
                IPoint[] pointArray2 = this.method_4((icoFeature_0 as ICoPointFeature).Point);
                int      index       = 0;
                if (0 >= pointArray2.Length)
                {
                    break;
                }
                return(pointArray2[index]);
            }

            case CoFeatureType.Polygon:
            {
                IGeometryCollection geometrys2 = new PolygonClass();
                foreach (CoPointCollection points in (icoFeature_0 as ICoPolygonFeature).Points)
                {
                    IPointCollection points3 = new RingClass();
                    foreach (IPoint point2 in this.method_4(points))
                    {
                        points3.AddPoint(point2, ref before, ref before);
                    }
                    geometrys2.AddGeometry((IGeometry)points3, ref before, ref before);
                }
                ((IPolygon)geometrys2).SimplifyPreserveFromTo();
                return((IGeometry)geometrys2);
            }

            case CoFeatureType.Polyline:
            {
                IGeometryCollection geometrys = new PolylineClass();
                foreach (CoPointCollection points in (icoFeature_0 as ICoPolylineFeature).Points)
                {
                    IPoint[]         pointArray3 = this.method_4(points);
                    IPointCollection points2     = new PathClass();
                    for (int i = 0; i < pointArray3.Length; i++)
                    {
                        points2.AddPoint(pointArray3[i], ref before, ref before);
                    }
                    geometrys.AddGeometry((IGeometry)points2, ref before, ref before);
                }
                return((IGeometry)geometrys);
            }
            }
            return(null);
        }
Пример #12
0
        private IGeometry WKTCoordinateInfo2Polygon(string WKTCoor, out string message)
        {
            string[] polygons;
            if (WKTCoor.Contains("),("))
            {
                polygons = WKTCoor.Split(new string[] { "),(" }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                polygons = new string[] { WKTCoor };
            }
            IGeometryCollection polygon = new PolygonClass();

            foreach (var item in polygons)
            {
                string[] split = item.Split(',');
                if (split.Length < 3)
                {
                    message = "坐标点太少." + WKTCoor;
                    return(null);
                }
                Ring ring = new RingClass();
                int  len  = split.Length;
                for (int i = 0; i < len; i++)
                {
                    _coorStr = split[i].Split(' ');
                    if (_coorStr.Length != 2)
                    {
                        message = "坐标点不能正确分割." + WKTCoor;
                        return(null);
                    }
                    if (!double.TryParse(_coorStr[0], out _x) || !double.TryParse(_coorStr[1], out _y))
                    {
                        message = "坐标点不能转换为double." + WKTCoor;
                        return(null);
                    }
                    _point.PutCoords(x, y);
                    ring.AddPoint(_point, ref missing, ref missing);
                }
                polygon.AddGeometry(ring as IGeometry, ref missing, ref missing);
            }
            IPolygon poly = polygon as IPolygon;

            poly.SimplifyPreserveFromTo();
            IGeometry geometry = poly as IGeometry;

            message = "";
            return(geometry);
        }
        public static IGeometry GetExample3()
        {
            //Ring: Octagon With Non-Coplanar Points

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IPointCollection ringPointCollection = new RingClass();

            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, 8.5, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, 7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(8.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, -7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, -8.5, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, -7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-8.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 7.5, 5), ref _missing, ref _missing);

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

            return multiPatchGeometryCollection as IGeometry;
        }
        public static IGeometry GetExample3()
        {
            //Ring: Octagon With Non-Coplanar Points

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IPointCollection ringPointCollection = new RingClass();

            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, 8.5, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, 7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(8.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(7.5, -7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, -8.5, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, -7.5, 5), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-8.5, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-7.5, 7.5, 5), ref _missing, ref _missing);

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

            return(multiPatchGeometryCollection as IGeometry);
        }
Пример #15
0
        /// <summary>
        /// 通过点集构成多边形(只适用单环多边形)
        /// </summary>
        /// <param name="pointList">按顺序构成一个环的点集</param>
        /// <returns></returns>
        public static IPolygon CreatePolygon(IEnumerable <IPoint> pointList)
        {
            if (pointList.Count() < 3)
            {
                throw new Exception("地块点数小于3,不能构成多边形!");
            }

            IGeometryCollection pointPolygon = new PolygonClass();
            Ring   ring    = new RingClass();
            object missing = Type.Missing;

            foreach (var pt in pointList)
            {
                ring.AddPoint(pt, ref missing, ref missing);
            }

            pointPolygon.AddGeometry(ring as IGeometry, ref missing, ref missing);
            IPolygon polygon = pointPolygon as IPolygon;

            polygon.SimplifyPreserveFromTo();

            return(polygon);
        }
        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);
        }
Пример #17
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);
        }
Пример #18
0
        private void DWGLoad()
        {
            AcadApplication     acadApp             = new AcadApplicationClass();
            IGeometryCollection pGeometryCollection = new PolygonClass();

            foreach (DataGridViewRow eRow in dataGridView1.Rows)
            {
                if (eRow.Cells[0].Value != null && (bool)eRow.Cells[0].Value == true)
                {
                    if (eRow.Cells["FileSuffix"].Value.ToString().ToLower() == "dwg")
                    {
                        object       o           = Type.Missing;
                        string       strFileName = eRow.Cells["FilePath"].Value.ToString();
                        AcadDocument acadDoc     = acadApp.Documents.Open(strFileName, true, null);
                        System.Windows.Forms.Application.DoEvents();
                        AcadLayer        acadLyer    = acadDoc.Layers.Item(1);
                        AcadSelectionSet ssetObj     = acadDoc.SelectionSets.Add("FWX");
                        short[]          vFilterType = null;
                        object[]         vFilterData = null;
                        vFilterType    = new short[1];
                        vFilterType[0] = 8;
                        vFilterData    = new object[1];
                        vFilterData[0] = "FWX";
                        //ISegmentCollection pSegmentCollection = new RingClass();
                        //pSegmentCollection.AddSegment()
                        ssetObj.Select(AcSelect.acSelectionSetAll, null, null, vFilterType, vFilterData);
                        foreach (AcadObject eEntity in ssetObj)
                        {
                            if (eEntity.ObjectName == "AcDbPolyline")
                            {
                                AcadLWPolyline pPline = (AcadLWPolyline)eEntity;
                                double[]       polyLinePoint;
                                polyLinePoint = (Double[])pPline.Coordinates;
                                int i, pointCount = polyLinePoint.Length / 2;
                                IPointCollection pPointColl = new RingClass();
                                for (i = 0; i < polyLinePoint.Length - 1; i = i + 2)
                                {
                                    IPoint pPoint = new PointClass();
                                    pPoint.X = polyLinePoint[i];
                                    pPoint.Y = polyLinePoint[i + 1];
                                    pPointColl.AddPoint(pPoint, ref o, ref o);
                                }
                                pGeometryCollection.AddGeometry(pPointColl as IRing, ref o, ref o);
                            }
                        }
                    }
                    else if (eRow.Cells["FileSuffix"].Value.ToString().ToLower() == "txt")
                    {
                        object o           = Type.Missing;
                        string strFileName = eRow.Cells["FilePath"].Value.ToString();
                        m_strPointArray.Clear();
                        StreamReader ReadFile = new StreamReader(strFileName, System.Text.Encoding.Default);
                        while (!ReadFile.EndOfStream)
                        {
                            m_strPointArray.Add(ReadFile.ReadLine());
                        }
                        ReadFile.Close();
                        IPointCollection pPointColl = new RingClass();
                        for (int i = 0; i < m_strPointArray.Count; i++)
                        {
                            if (m_strPointArray[i].StartsWith("J"))
                            {
                                string[] split  = m_strPointArray[i].Split(new Char[] { ',', ',' });
                                IPoint   pPoint = new PointClass();
                                pPoint.X = Convert.ToDouble(split[2]);
                                pPoint.Y = Convert.ToDouble(split[3]);
                                pPointColl.AddPoint(pPoint, ref o, ref o);
                            }
                        }
                        pGeometryCollection.AddGeometry(pPointColl as IRing, ref o, ref o);
                    }
                }
            }
            acadApp.Quit();
            //DWGLoaded(this.m_Popfrm, new EventArgs());//引发完成事件,有异常待研究
            System.Windows.Forms.Application.DoEvents();
            if (pGeometryCollection.GeometryCount > 0)
            {
                m_pFeature       = EngineFuntions.m_Layer_BusStation.FeatureClass.CreateFeature();
                m_pFeature.Shape = pGeometryCollection as IPolygon;
                IFields fields = m_pFeature.Fields;
                int     nIndex = fields.FindField("任务号");
                m_pFeature.set_Value(nIndex, m_strFolder.Substring(m_strFolder.LastIndexOf("\\") + 1));
                m_pFeature.Store();
                EngineFuntions.ZoomTo(m_pFeature.ShapeCopy);
            }
            else
            {
                m_pFeature = null;
            }
        }
Пример #19
0
        private void Coordinate_Load(object sender, EventArgs e)
        {
            //定义点集环形
            Ring ring1 = new RingClass();
            object missing = Type.Missing;
            //新建一个datatable用于保存读入的数据
            DataTable dt = new DataTable();
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Multiselect = false;    //单选
            ofd.Title = "选择坐标文件";
            ofd.Filter = "txt文件|*.txt";
            // ofd.InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
            ofd.InitialDirectory = SystemSet.Base_Map + "\\处理数据库\\坐标数据";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //IGeometryCollection pointPolygon = new PolygonClass();
                FileInfo fi = new FileInfo(ofd.FileName);
                try
                {
                    paths1 = ofd.FileName;
                    lengh = paths1.Length - ofd.InitialDirectory.Length;
                    String paths = ofd.FileName;

                    int i = 0;
                    //给datatable添加5个列
                    dt.Columns.Add("编号", typeof(int));
                    dt.Columns.Add("坐标X", typeof(double));
                    dt.Columns.Add("坐标Y", typeof(double));
                    dt.Columns.Add("高程Z", typeof(double));
                    dt.Columns.Add("日期", typeof(string));
                    //读入文件
                    StreamReader sr = new StreamReader(paths, Encoding.Default);

                    //循环读取所有行
                    while (!sr.EndOfStream)//(line = sr.ReadLine()) != null)
                    {
                        i++;
                        //将每行数据,用-分割成2段
                        //sr.ReadLine().TrimStart();//消除前面空格
                        //sr.ReadLine().TrimEnd();//消除尾部空格
                        string[] data = sr.ReadLine().Split(',', ' ');
                        //新建一行,并将读出的数据分段,分别存入5个对应的列中
                        DataRow dr = dt.NewRow();
                        dr[0] = i;
                        dr[1] = data[0];
                        dr[2] = data[1];
                        dr[3] = 0;
                        dr[4] = DateTime.Now.ToLongDateString().ToString();
                        //将这行数据加入到datatable中
                        dt.Rows.Add(dr);
                        //点上生成面
                        IPoint ppp = new PointClass();
                        ppp.PutCoords((double)dr[1], (double)dr[2]);
                        ring1.AddPoint(ppp, ref missing, ref missing);
                        //调用画点工具
                        GISHandler.GISTools.CreatPoint(this.mapControl, (double)dr[1], (double)dr[2], i);
                    }
                }
                catch
                {
                    MessageBox.Show("坐标文件内容错误!请检查格式是否为:x,y或者x y");
                    return;
                }
                IGeometryCollection pointPolygon = new PolygonClass();
                pointPolygon.AddGeometry(ring1 as IGeometry, ref missing, ref missing);
                IPolygon polyGonGeo = pointPolygon as IPolygon;
                ply = polyGonGeo;
                polyGonGeo.SimplifyPreserveFromTo();
                //object miss = Type.Missing;
                //this.mapControl.DrawShape(polyGonGeo, ref miss);

            }
            else
                this.Close();
            gridControl1.DataSource = dt;
            dataGridView1.DataSource = dt;
            gridView1.OptionsView.ShowGroupPanel = false;
        }
Пример #20
0
        private IPolygon GetMGRSPolygon(IPoint point)
        {
            CoordinateMGRS mgrs;

            IPointCollection pc = new RingClass();

            // bottom left
            CoordinateMGRS.TryParse(InputCoordinate, out mgrs);

            // don't create a polygon for 1m resolution
            if (mgrs.Easting.ToString().Length > 4 && mgrs.Northing.ToString().Length > 4)
            {
                return(null);
            }

            var tempPoint = new PointClass() as IConversionNotation;

            (tempPoint as IPoint).SpatialReference = GetSR();
            var anotherMGRSstring = mgrs.ToString("", new CoordinateMGRSFormatter());

            tempPoint.PutCoordsFromMGRS(anotherMGRSstring, esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // top left
            var tempMGRS    = new CoordinateMGRS(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing);
            var tempEasting = mgrs.Easting.ToString().PadRight(5, '0');

            tempMGRS.Easting = Convert.ToInt32(tempEasting);
            var tempNorthing = mgrs.Northing.ToString().PadRight(5, '9');

            tempMGRS.Northing = Convert.ToInt32(tempNorthing.Replace('0', '9'));

            tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            anotherMGRSstring = tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter());
            tempPoint.PutCoordsFromMGRS(anotherMGRSstring, esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // top right
            tempEasting       = mgrs.Easting.ToString().PadRight(5, '9');
            tempMGRS.Easting  = Convert.ToInt32(tempEasting.Replace('0', '9'));
            tempNorthing      = mgrs.Northing.ToString().PadRight(5, '9');
            tempMGRS.Northing = Convert.ToInt32(tempNorthing.Replace('0', '9'));

            tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            tempPoint.PutCoordsFromMGRS(tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // bottom right
            tempEasting       = mgrs.Easting.ToString().PadRight(5, '9');
            tempMGRS.Easting  = Convert.ToInt32(tempEasting.Replace('0', '9'));
            tempNorthing      = mgrs.Northing.ToString().PadRight(5, '0');
            tempMGRS.Northing = Convert.ToInt32(tempNorthing);

            tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            tempPoint.PutCoordsFromMGRS(tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // create polygon
            var poly = new PolygonClass();

            poly.SpatialReference = GetSR();
            poly.AddPointCollection(pc);
            poly.Close();

            return(poly);
        }
        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);
        }
Пример #22
0
        private void Coordinate_Load(object sender, EventArgs e)
        {
            //定义点集环形
            Ring   ring1   = new RingClass();
            object missing = Type.Missing;
            //新建一个datatable用于保存读入的数据
            DataTable      dt  = new DataTable();
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;    //单选
            ofd.Title       = "选择坐标文件";
            ofd.Filter      = "txt文件|*.txt";
            // ofd.InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
            ofd.InitialDirectory = SystemSet.Base_Map + "\\处理数据库\\坐标数据";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //IGeometryCollection pointPolygon = new PolygonClass();
                FileInfo fi = new FileInfo(ofd.FileName);
                try
                {
                    paths1 = ofd.FileName;
                    lengh  = paths1.Length - ofd.InitialDirectory.Length;
                    String paths = ofd.FileName;

                    int i = 0;
                    //给datatable添加5个列
                    dt.Columns.Add("编号", typeof(int));
                    dt.Columns.Add("坐标X", typeof(double));
                    dt.Columns.Add("坐标Y", typeof(double));
                    dt.Columns.Add("高程Z", typeof(double));
                    dt.Columns.Add("日期", typeof(string));
                    //读入文件
                    StreamReader sr = new StreamReader(paths, Encoding.Default);

                    //循环读取所有行
                    while (!sr.EndOfStream)//(line = sr.ReadLine()) != null)
                    {
                        i++;
                        //将每行数据,用-分割成2段
                        //sr.ReadLine().TrimStart();//消除前面空格
                        //sr.ReadLine().TrimEnd();//消除尾部空格
                        string[] data = sr.ReadLine().Split(',', ' ');
                        //新建一行,并将读出的数据分段,分别存入5个对应的列中
                        DataRow dr = dt.NewRow();
                        dr[0] = i;
                        dr[1] = data[0];
                        dr[2] = data[1];
                        dr[3] = 0;
                        dr[4] = DateTime.Now.ToLongDateString().ToString();
                        //将这行数据加入到datatable中
                        dt.Rows.Add(dr);
                        //点上生成面
                        IPoint ppp = new PointClass();
                        ppp.PutCoords((double)dr[1], (double)dr[2]);
                        ring1.AddPoint(ppp, ref missing, ref missing);
                        //调用画点工具
                        GISHandler.GISTools.CreatPoint(this.mapControl, (double)dr[1], (double)dr[2], i);
                    }
                }
                catch
                {
                    MessageBox.Show("坐标文件内容错误!请检查格式是否为:x,y或者x y");
                    return;
                }
                IGeometryCollection pointPolygon = new PolygonClass();
                pointPolygon.AddGeometry(ring1 as IGeometry, ref missing, ref missing);
                IPolygon polyGonGeo = pointPolygon as IPolygon;
                ply = polyGonGeo;
                polyGonGeo.SimplifyPreserveFromTo();
                //object miss = Type.Missing;
                //this.mapControl.DrawShape(polyGonGeo, ref miss);
            }
            else
            {
                this.Close();
            }
            gridControl1.DataSource              = dt;
            dataGridView1.DataSource             = dt;
            gridView1.OptionsView.ShowGroupPanel = false;
        }
        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;
        }
        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;            
        }
        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;
        }
        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;
        }
Пример #27
0
        public List<IGeometry> getHouseGeomList()
        {
            leftTopPt = new PointClass();
            leftTopPt.PutCoords(leftTopX, leftTopY);
            rightTopPt = new PointClass();
            rightTopPt.PutCoords(leftTopX+ houseWidth, leftTopY);
            leftBottomPt = new PointClass();
            leftBottomPt.PutCoords(leftTopX, leftTopY - houseHeight);
            rightBottomPt = new PointClass();
            rightBottomPt.PutCoords(leftTopX + houseWidth, leftTopY - houseHeight);

            //靠宽度, 深度定下四个点. 画出房子那一圈.
            Ring ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon housePoly = GeneratePolygonFromRing(ring); //房子图形.

            //开始画外圈, 外圈左右前多2M, 后需要进行计算. 值为楼层数* 层高* 1.2
            double outerDist = houseFloor * houseFloorHeight * 1.2;
            leftTopPt.PutCoords(leftTopX - 2, leftTopY + outerDist);
            rightTopPt.PutCoords(leftTopX + houseWidth + 2, leftTopY - outerDist);
            leftBottomPt.PutCoords(leftTopX - 2, leftTopY - houseHeight - 2);
            rightBottomPt.PutCoords(leftTopX + houseWidth + 2, leftTopY - houseHeight - 2);

            ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon outerPoly = GeneratePolygonFromRing(ring);

            //然后依次左上, 右上, 左下, 右下, 朝南, 5个圈.
            double x = outerPoly.Envelope.UpperLeft.X;
            double y = outerPoly.Envelope.UpperLeft.Y;
            leftTopPt.PutCoords(x - cornerSize, y + cornerSize);
            rightTopPt.PutCoords(x + cornerSize, y + cornerSize);
            leftBottomPt.PutCoords(x - cornerSize, y - cornerSize);
            rightBottomPt.PutCoords(x + cornerSize, y - cornerSize);
            ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon leftTopPoly = GeneratePolygonFromRing(ring);

            x = outerPoly.Envelope.UpperRight.X;
            y = outerPoly.Envelope.UpperRight.Y;
            leftTopPt.PutCoords(x - cornerSize, y + cornerSize);
            rightTopPt.PutCoords(x + cornerSize, y + cornerSize);
            leftBottomPt.PutCoords(x - cornerSize, y - cornerSize);
            rightBottomPt.PutCoords(x + cornerSize, y - cornerSize);
            ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon rightTopPoly = GeneratePolygonFromRing(ring);

            x = outerPoly.Envelope.LowerLeft.X;
            y = outerPoly.Envelope.LowerLeft.Y;
            leftTopPt.PutCoords(x - cornerSize, y + cornerSize);
            rightTopPt.PutCoords(x + cornerSize, y + cornerSize);
            leftBottomPt.PutCoords(x - cornerSize, y - cornerSize);
            rightBottomPt.PutCoords(x + cornerSize, y - cornerSize);
            ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon leftBottomPoly = GeneratePolygonFromRing(ring);

            x = outerPoly.Envelope.LowerRight.X;
            x = outerPoly.Envelope.LowerRight.Y;
            leftTopPt.PutCoords(x - cornerSize, y + cornerSize);
            rightTopPt.PutCoords(x + cornerSize, y + cornerSize);
            leftBottomPt.PutCoords(x - cornerSize, y - cornerSize);
            rightBottomPt.PutCoords(x + cornerSize, y - cornerSize);
            ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon rightBottomPoly = GeneratePolygonFromRing(ring);

            x = (outerPoly.Envelope.LowerLeft.X + outerPoly.Envelope.LowerRight.X) / 2;
            y = outerPoly.Envelope.LowerLeft.Y;
            leftTopPt.PutCoords(x - cornerSize, y + cornerSize);
            rightTopPt.PutCoords(x + cornerSize, y + cornerSize);
            leftBottomPt.PutCoords(x - cornerSize, y - cornerSize);
            rightBottomPt.PutCoords(x + cornerSize, y - cornerSize);
            ring = new RingClass();
            ring.AddPoint(leftTopPt);
            ring.AddPoint(rightTopPt);
            ring.AddPoint(rightBottomPt);
            ring.AddPoint(leftBottomPt);
            IPolygon southPoly = GeneratePolygonFromRing(ring);

            //最后按照, 内, 外, 左上, 右上, 左下, 右下, 朝南放入list.
            List<IGeometry> houseGeomList = new List<IGeometry>();
            houseGeomList.Add(housePoly);
            houseGeomList.Add(outerPoly);
            houseGeomList.Add(leftTopPoly);
            houseGeomList.Add(rightTopPoly);
            houseGeomList.Add(leftBottomPoly);
            houseGeomList.Add(rightBottomPoly);
            houseGeomList.Add(southPoly);

            return houseGeomList;
        }
Пример #28
0
        static void CreateGrid(TileInfo tiles, int level, IFeatureWorkspace destination, String name)
        {
            ISpatialReferenceFactory2 sEnv = new SpatialReferenceEnvironment() as ISpatialReferenceFactory2;
            ISpatialReference sr = sEnv.CreateSpatialReference((int)tiles.spatialReference);
            sr.SetMDomain(-137434824702, 0);
            IFeatureClass fc = CreateFeatureClass(destination, name, sr);
            LOD lod = tiles.lods[level];
            double width = tiles.width * lod.resolution;
            double height = tiles.height * lod.resolution;
            double y = tiles.originY;
            long row = 0;
            double maxX = -(tiles.originX + width);
            double minY = -(tiles.originY - height);
            while (y > minY)
            {
                double x = tiles.originX;
                long col = 0;
                while (x < maxX)
                {
                    RingClass ring = new RingClass();
                    IPoint tl = new PointClass();
                    tl.PutCoords(x, y);
                    tl.M = -(((col & 0xFFFF) << 16) + (row & 0xFFFF));
                    ring.AddPoint(tl);
                    IPoint tr = new PointClass();
                    tr.PutCoords(x + width, y);
                    tr.M = -((((col + 1) & 0xFFFF) << 16) + (row & 0xFFFF));
                    ring.AddPoint(tr);
                    IPoint br = new PointClass();
                    br.PutCoords(x + width, y - width);
                    br.M = -((((col + 1) & 0xFFFF) << 16) + ((row + 1) & 0xFFFF));
                    ring.AddPoint(br);
                    IPoint bl = new PointClass();
                    bl.PutCoords(x, y - width);
                    bl.M = -(((col & 0xFFFF) << 16) + ((row + 1) & 0xFFFF));
                    ring.AddPoint(bl);

                    ring.AddPoint(tl);

                    ring.Close();
                    PolygonClass polygon = new PolygonClass();
                    polygon.AddGeometry(ring);
                    IFeature polyFeature = fc.CreateFeature();
                    polyFeature.Shape = polygon;
                    polyFeature.Store();
                    x += width;
                    col += 1;
                }
                row += 1;
                y -= height;
            }
            IFeatureClassDescriptor fd = new FeatureClassDescriptorClass();
            fd.Create(fc, null, "OBJECTID");
        }
Пример #29
0
        static private void GetMouOrBotFun(IFeatureLayer conFyr)
        {
            closedline = OrderedOfClosedCon(conFyr);
            List <int> idContain = new List <int>();

            for (int i = 0; i < closedline.Count; i++)
            {
                if (idContain.Count != 0)
                {
                    if (idContain.Contains(closedline[i].ConFea.OID))
                    {
                        continue;
                    }
                }
                IPointCollection    ptCol     = closedline[i].ConFea.Shape as IPointCollection;
                IPoint              pt1       = ptCol.get_Point(0);
                double              Z1        = closedline[i].Z;
                IPolygon            pPolygon1 = GetPolygon(closedline[i].ConFea.Shape as IPolyline);
                IRelationalOperator topo1     = pPolygon1 as IRelationalOperator;
                int m = 0;
                List <FeaInfoClass> bottomFlist = new List <FeaInfoClass>();
                for (int j = i + 1; j < closedline.Count; j++)
                {
                    IPointCollection    ptC       = closedline[j].ConFea.Shape as IPointCollection;
                    IPoint              pt2       = ptC.get_Point(0);
                    double              Z2        = closedline[j].Z;
                    IPolygon            pPolygon2 = GetPolygon(closedline[j].ConFea.Shape as IPolyline);
                    IRelationalOperator topo2     = pPolygon2 as IRelationalOperator;
                    if (topo2.Contains(pt1 as IGeometry))
                    {
                        if (m == 0)
                        {
                            hellollFea.Add(closedline[i].ConFea);
                            idContain.Add(closedline[i].ConFea.OID);
                        }
                        idContain.Add(closedline[j].ConFea.OID);
                        m++;
                    }
                    else if (topo1.Contains(pt2 as IGeometry))
                    {
                        bottomFlist.Add(closedline[j]);
                    }
                }
                if (bottomFlist.Count != 0)
                {
                    idContain.Add(closedline[i].ConFea.OID);
                    for (int n = 0; n < bottomFlist.Count; n++)
                    {
                        idContain.Add(bottomFlist[n].ConFea.OID);
                    }
                    bottomFea.Add(bottomFlist[bottomFlist.Count - 1].ConFea);
                }
                if (m == 0 && bottomFlist.Count == 0)//从开曲线
                {
                    IPointCollection ring = new RingClass() as IPointCollection;
                    IRing            rng  = ring as IRing;
                    for (int j = 0; j < ptCol.PointCount; j++)
                    {
                        ring.AddPoint(ptCol.get_Point(j));
                    }
                    bool isExterior = rng.IsExterior;
                    if (isExterior == true)
                    {
                        bottomFea.Add(closedline[i].ConFea);
                    }
                    else
                    {
                        hellollFea.Add(closedline[i].ConFea);
                    }
                    idContain.Add(closedline[i].ConFea.OID);
                }
            }
        }
        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);
        }
Пример #31
0
        static void CopyAndLabel(IFeatureClass inFC, IFeatureWorkspace destination, String name)
        {
            IFieldsEdit outFields = new FieldsClass();
            ISpatialReference outSR = null;
            for (int i = 0; i < inFC.Fields.FieldCount; i += 1) {
                IField field = inFC.Fields.get_Field(i);
                if (field.Type == esriFieldType.esriFieldTypeGeometry) {
                    outSR = field.GeometryDef.SpatialReference;
                } else {
                    outFields.AddField(field);
                }
            }
            outSR.SetMDomain(-137434824702, 137434824702);

            IGeometryDefEdit geom = new GeometryDefClass();
            geom.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            geom.SpatialReference_2 = outSR;
            geom.HasM_2 = true;
            geom.HasZ_2 = false;

            IFieldEdit geomField = new FieldClass();
            geomField.Name_2 = "SHAPE";
            geomField.AliasName_2 = "SHAPE";
            geomField.Type_2 = esriFieldType.esriFieldTypeGeometry;
            geomField.GeometryDef_2 = geom;
            outFields.AddField(geomField);

            IFeatureClass outFC = destination.CreateFeatureClass(name, outFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
            // Start numbering from 1, because index 0 is used by clipping cell
            int vIndex = 1;
            IFeatureCursor featureCursor = inFC.Search(null, true);
            IFeature inFeature;
            while ((inFeature = featureCursor.NextFeature()) != null) {
                IFeature outFeature = outFC.CreateFeature();
                for (int i = 0; i < outFields.FieldCount; i += 1) {
                    IField field = outFields.Field[i];
                    if (field.Editable && (field.Type != esriFieldType.esriFieldTypeGeometry)) {
                        outFeature.set_Value(i, inFeature.get_Value(i));
                    }
                }
                IPolygon4 inShape = inFeature.Shape as IPolygon4;
                PolygonClass outShape = new PolygonClass();

                IGeometryBag extRingBag = inShape.ExteriorRingBag;
                IGeometryCollection extRings = extRingBag as IGeometryCollection;
                for (int i = 0; i < extRings.GeometryCount; i += 1) {
                    IGeometry inExtRingGeom = extRings.get_Geometry(i);
                    IPointCollection inExtRing = inExtRingGeom as IPointCollection;
                    RingClass outExtRing = new RingClass();
                    for (int j = 0; j < inExtRing.PointCount; j += 1) {
                        IPoint point = inExtRing.get_Point(j);
                        point.M = vIndex;
                        vIndex += 2;
                        outExtRing.AddPoint(point);
                    }
                    outShape.AddGeometry(outExtRing);
                    IGeometryBag intRingBag = inShape.get_InteriorRingBag(inExtRingGeom as IRing);
                    IGeometryCollection intRings = intRingBag as IGeometryCollection;
                    for (int j = 0; j < intRings.GeometryCount; j += 1) {
                        IGeometry intRingGeom = intRings.get_Geometry(j);
                        IPointCollection inIntRing = intRingGeom as IPointCollection;
                        RingClass outIntRing = new RingClass();
                        for (int k = 0; k < inIntRing.PointCount; k += 1) {
                            IPoint point = inExtRing.get_Point(k);
                            point.M = vIndex;
                            vIndex += 2;
                            outIntRing.AddPoint(point);
                        }
                        outShape.AddGeometry(outIntRing);
                    }
                }
                outFeature.Shape = outShape;
                outFeature.Store();
            }
        }
        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;
        }
Пример #33
0
        private IFeatureBuffer method_9(ICoFeature icoFeature_0)
        {
            object         before = Missing.Value;
            IFeatureBuffer buffer = null;

            if (this.bool_0)
            {
                buffer = this.ifeatureClass_0.CreateFeatureBuffer();
            }
            else
            {
                buffer = this.ifeatureClass_0.CreateFeature() as IFeatureBuffer;
            }
            if (buffer != null)
            {
                buffer.Shape = null;
            }
            switch (icoFeature_0.Type)
            {
            case CoFeatureType.Point:
                if ((this.ifeatureClass_0.FeatureType != esriFeatureType.esriFTAnnotation) &&
                    (this.ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPoint))
                {
                    foreach (IPoint point in this.method_15((icoFeature_0 as ICoPointFeature).Point))
                    {
                        buffer.Shape = point;
                    }
                }
                break;

            case CoFeatureType.Polygon:
                if ((this.ifeatureClass_0.FeatureType != esriFeatureType.esriFTAnnotation) &&
                    (this.ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPolygon))
                {
                    IGeometryCollection geometrys2 = new PolygonClass();
                    foreach (CoPointCollection points in (icoFeature_0 as ICoPolygonFeature).Points)
                    {
                        IPointCollection points3 = new RingClass();
                        foreach (IPoint point2 in this.method_15(points))
                        {
                            points3.AddPoint(point2, ref before, ref before);
                        }
                        geometrys2.AddGeometry((IGeometry)points3, ref before, ref before);
                    }
                    ((IPolygon)geometrys2).SimplifyPreserveFromTo();
                    buffer.Shape = (IGeometry)geometrys2;
                }
                break;

            case CoFeatureType.Annotation:
                if (this.ifeatureClass_0.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    IAnnotationFeature   feature  = buffer as IAnnotationFeature;
                    IPoint               point    = new PointClass();
                    ICoAnnotationFeature feature2 = icoFeature_0 as ICoAnnotationFeature;
                    point.X = feature2.Point[0].X;
                    point.Y = feature2.Point[0].Y;
                    point.Z = feature2.Point[0].Z;
                    ITextElement element = this.method_11(feature2.Text, 0.0, (decimal)feature2.Font.Size,
                                                          feature2.Font.Name, feature2.Color.ToArgb(), point);
                    feature.Annotation = (IElement)element;
                }
                break;

            case CoFeatureType.Polyline:
                if ((this.ifeatureClass_0.FeatureType != esriFeatureType.esriFTAnnotation) &&
                    (this.ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPolyline))
                {
                    IGeometryCollection geometrys = new PolylineClass();
                    foreach (CoPointCollection points in (icoFeature_0 as ICoPolylineFeature).Points)
                    {
                        IPoint[]         pointArray = this.method_15(points);
                        IPointCollection points2    = new PathClass();
                        for (int i = 0; i < pointArray.Length; i++)
                        {
                            points2.AddPoint(pointArray[i], ref before, ref before);
                        }
                        geometrys.AddGeometry((IGeometry)points2, ref before, ref before);
                    }
                    buffer.Shape = (IGeometry)geometrys;
                }
                break;
            }
            if (buffer != null)
            {
                if (buffer.Shape != null)
                {
                    this.method_10(buffer, icoFeature_0);
                    return(buffer);
                }
                return(null);
            }
            return(null);
        }
Пример #34
0
 private IGeometry MakePolygonFromPointsList(List<IPoint> ptsList)
 {
     Ring ring = new RingClass();
     object missing = Type.Missing;
     for (int i = 0; i < ptsList.Count; i++)
     {
         ring.AddPoint(ptsList[i]);
     }
     IGeometryCollection pointPolygon = new PolygonClass();
     pointPolygon.AddGeometry(ring as IGeometry, ref missing, ref missing);
     IPolygon polygon = pointPolygon as IPolygon;
     polygon.SimplifyPreserveFromTo();
     return polygon;
 }
Пример #35
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);
        }
        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;
        }
Пример #37
0
 public IPolygon GetBoundaryAsPolygon(IRasterProps props)
 {
     double left = props.Extent.XMin;
     double top = props.Extent.YMax;
     IPnt cellSize = props.MeanCellSize();
     PolygonClass result = new PolygonClass();
     object missing = Type.Missing;
     for (int x = 0; x <= m_Width; x += 1) {
         for (int y = 0; y <= m_Height; y += 1) {
             if ((!CellVisited(x, y)) && IsFilled(x, y) && (!IsFilled(x - 1, y))) {
                 List<IntPoint> bmRing = GetCurve(x, y);
                 RingClass ring = new RingClass();
                 foreach (IntPoint bmPt in bmRing) {
                     PointClass point = new PointClass();
                     point.PutCoords(left + bmPt.X * cellSize.X,
                                     top - bmPt.Y * cellSize.Y);
                     ring.AddPoint(point, ref missing, ref missing);
                 }
                 result.AddGeometry(ring, ref missing, ref missing);
             }
         }
     }
     return result;
 }
Пример #38
0
 private void CreatePolygon(string filename)
 {
     try
     {
         using (StreamReader reader = new StreamReader(filename))
         {
             int    nIndex = 1;
             string line   = reader.ReadLine();
             if (line != null)
             {
                 IPoint point;
                 string str2;
                 IGeometryCollection geometrys = new PolygonClass();
                 IPointCollection    points    = new RingClass();
                 object before = Missing.Value;
                 bool   flag   = false;
                 if (line.ToLower() == "part")
                 {
                     flag = true;
                 }
                 else
                 {
                     point = this.CreatePoint(line, nIndex);
                     if (point == null)
                     {
                         str2 = string.Format("{0} 中第 {1}行数据有错误", filename, nIndex);
                         Logger.Current.Error("", null, str2);
                     }
                     else
                     {
                         points.AddPoint(point, ref before, ref before);
                     }
                 }
                 while ((line = reader.ReadLine()) != null)
                 {
                     line.Trim();
                     if (line.Length != 0)
                     {
                         nIndex++;
                         if (line.ToLower() == "part")
                         {
                             if (flag)
                             {
                                 if (points.PointCount >= 3)
                                 {
                                     if (!(points as IRing).IsClosed)
                                     {
                                         (points as IRing).Close();
                                     }
                                     geometrys.AddGeometry(points as IGeometry, ref before, ref before);
                                 }
                                 points = new RingClass();
                             }
                             else
                             {
                                 str2 = filename + " 中第 " + nIndex.ToString() + "行数据有错误";
                                 Logger.Current.Error("", null, str2);
                             }
                         }
                         else
                         {
                             point = this.CreatePoint(line, nIndex);
                             if (point == null)
                             {
                                 str2 = filename + " 中第 " + nIndex.ToString() + "行数据有错误";
                                 Logger.Current.Error("", null, str2);
                             }
                             else
                             {
                                 points.AddPoint(point, ref before, ref before);
                             }
                         }
                     }
                 }
                 if ((points != null) && (points.PointCount >= 3))
                 {
                     if (!(points as IRing).IsClosed)
                     {
                         (points as IRing).Close();
                     }
                     geometrys.AddGeometry(points as IGeometry, ref before, ref before);
                 }
                 try
                 {
                     if (geometrys.GeometryCount > 0)
                     {
                         IFeatureLayer featureLayer =
                             Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer;
                         this.SetZMProperty(geometrys as IGeometry);
                         IFeature feature = featureLayer.FeatureClass.CreateFeature();
                         feature.Shape = geometrys as IGeometry;
                         feature.Store();
                         IActiveView pMap = (IActiveView)this.m_pMap;
                         this.m_pMap.ClearSelection();
                         this.m_pMap.SelectFeature(featureLayer, feature);
                         pMap.Refresh();
                     }
                     else
                     {
                         MessageBox.Show("无法创建多边形!");
                     }
                 }
                 catch (Exception exception)
                 {
                     Logger.Current.Error("", exception, "");
                 }
             }
         }
     }
     catch (Exception exception2)
     {
         Logger.Current.Error("", exception2, "");
     }
 }
Пример #39
0
        public static IPolygon PreProcessArea(IGeometry geom)
        {
            /*
                预处理地区, 从地区中心挖出一块土地.
             *  返回被挖出的地块. 
             */
            object missing = Type.Missing;
            IPoint envelopLeftTopPt = geom.Envelope.UpperLeft;
            IPoint envelopRightTopPt = geom.Envelope.UpperRight;
            IPoint envelopLeftBottomPt = geom.Envelope.LowerLeft;
            IPoint envelopRightBottomPt = geom.Envelope.LowerRight;
            double initialDist = 5; //第一次各边向内移动5M;
            double dist = 1; //之后每次尝试向内移动1M;

            envelopLeftTopPt.X += initialDist;
            envelopLeftTopPt.Y -= initialDist;
            envelopRightTopPt.X -= initialDist;
            envelopRightTopPt.Y -= initialDist;
            envelopLeftBottomPt.X += initialDist;
            envelopLeftBottomPt.Y += initialDist;
            envelopRightBottomPt.X -= initialDist;
            envelopRightBottomPt.Y += initialDist;

            Ring ring = new RingClass();
            ring.AddPoint(envelopLeftTopPt);
            ring.AddPoint(envelopRightTopPt);
            ring.AddPoint(envelopRightBottomPt);
            ring.AddPoint(envelopLeftBottomPt);

            IPolygon areaPolygon = MakePolygonFromRing(ring);
            IRelationalOperator reOp = geom as IRelationalOperator;

            while (!reOp.Contains(areaPolygon))
            {
                envelopLeftTopPt.X += dist;
                envelopLeftTopPt.Y -= dist;
                envelopRightTopPt.X -= dist;
                envelopRightTopPt.Y -= dist;
                envelopLeftBottomPt.X += dist;
                envelopLeftBottomPt.Y += dist;
                envelopRightBottomPt.X -= dist;
                envelopRightBottomPt.Y += dist;

                ring = new RingClass();
                ring.AddPoint(envelopLeftTopPt);
                ring.AddPoint(envelopRightTopPt);
                ring.AddPoint(envelopRightBottomPt);
                ring.AddPoint(envelopLeftBottomPt);

                areaPolygon = MakePolygonFromRing(ring);
            }

            envelopLeftTopPt.X += initialDist;
            envelopLeftTopPt.Y -= initialDist;
            envelopRightTopPt.X -= initialDist;
            envelopRightTopPt.Y -= initialDist;
            envelopLeftBottomPt.X += initialDist;
            envelopLeftBottomPt.Y += initialDist;
            envelopRightBottomPt.X -= initialDist;
            envelopRightBottomPt.Y += initialDist;

            ring = new RingClass();
            ring.AddPoint(envelopLeftTopPt);
            ring.AddPoint(envelopRightTopPt);
            ring.AddPoint(envelopRightBottomPt);
            ring.AddPoint(envelopLeftBottomPt);

            areaPolygon = MakePolygonFromRing(ring);

            return areaPolygon;
        }
Пример #40
0
        public void ShowHouse(House house, CommonHouse commonHouse)
        {
            ClearShowcase();
            IPoint upperLeftPt = new PointClass()
                , upperRightPt = new PointClass()
                , lowerLeftPt = new PointClass()
                , lowerRightPt = new PointClass()
                , lowerMidPt = new PointClass()
                , midLeftPt = new PointClass()
                , midRightPt = new PointClass();
            Ring ring = new RingClass();
            IPolygon innerPolygon = null, outerPolygon = null;
            List<IPolygon> unitPolygonList = new List<IPolygon>();
            IEnvelope extent;

            if (house.width * commonHouse.height > 0)
            {
                upperLeftPt = new PointClass();
                upperLeftPt.X = upperLeftX;
                upperLeftPt.Y = upperLeftY;
                upperRightPt = new PointClass();
                upperRightPt.X = upperLeftPt.X + house.width;
                upperRightPt.Y = upperLeftPt.Y;
                lowerLeftPt = new PointClass();
                lowerLeftPt.X = upperLeftPt.X;
                lowerLeftPt.Y = upperLeftPt.Y - commonHouse.height;
                lowerRightPt = new PointClass();
                lowerRightPt.X = lowerLeftPt.X + house.width;
                lowerRightPt.Y = lowerLeftPt.Y;
                ring = new RingClass();
                ring.AddPoint(upperLeftPt);
                ring.AddPoint(upperRightPt);
                ring.AddPoint(lowerRightPt);
                ring.AddPoint(lowerLeftPt);
                innerPolygon = GisUtil.MakePolygonFromRing(ring);

                //每单元
                double unitWidth = house.width / house.unit;
                double unitUpperLeftX = upperLeftX;
                double unitUpperLeftY = upperLeftY;
                for (int i = 0; i < house.unit; i++)
                {
                    IPoint unitUpperLeftPt = new PointClass();
                    unitUpperLeftPt.X = unitUpperLeftX;
                    unitUpperLeftPt.Y = unitUpperLeftY;
                    IPoint unitUpperRightPt = new PointClass();
                    unitUpperRightPt.X = unitUpperLeftPt.X + unitWidth;
                    unitUpperRightPt.Y = unitUpperLeftPt.Y;
                    IPoint unitLowerLeftPt = new PointClass();
                    unitLowerLeftPt.X = unitUpperLeftPt.X;
                    unitLowerLeftPt.Y = unitUpperLeftPt.Y - commonHouse.height;
                    IPoint unitLowerRightPt = new PointClass();
                    unitLowerRightPt.X = unitLowerLeftPt.X + unitWidth;
                    unitLowerRightPt.Y = unitLowerLeftPt.Y;
                    Ring unitRing = new RingClass();
                    unitRing.AddPoint(unitUpperLeftPt);
                    unitRing.AddPoint(unitUpperRightPt);
                    unitRing.AddPoint(unitLowerRightPt);
                    unitRing.AddPoint(unitLowerLeftPt);
                    IPolygon unitPolygon = GisUtil.MakePolygonFromRing(unitRing);
                    unitPolygonList.Add(unitPolygon);
                    unitUpperLeftX += unitWidth;
                }
            }

            if (house.leftGap > 0 && house.rightGap > 0 && commonHouse.frontGap > 0 && commonHouse.backGap > 0 && house.width > 0 && commonHouse.height > 0)
            {
                upperLeftPt = new PointClass();
                upperLeftPt.X = upperLeftX - house.leftGap;
                upperLeftPt.Y = upperLeftY + commonHouse.backGap;
                upperRightPt = new PointClass();
                upperRightPt.X = upperLeftPt.X + house.leftGap + house.width + house.rightGap;
                upperRightPt.Y = upperLeftPt.Y;
                lowerLeftPt = new PointClass();
                lowerLeftPt.X = upperLeftPt.X;
                lowerLeftPt.Y = upperLeftPt.Y - commonHouse.backGap - commonHouse.height - commonHouse.frontGap;
                lowerRightPt = new PointClass();
                lowerRightPt.X = lowerLeftPt.X + house.leftGap + house.width + house.rightGap;
                lowerRightPt.Y = lowerLeftPt.Y;
                ring = new RingClass();
                ring.AddPoint(upperLeftPt);
                ring.AddPoint(upperRightPt);
                ring.AddPoint(lowerRightPt);
                ring.AddPoint(lowerLeftPt);
                outerPolygon = GisUtil.MakePolygonFromRing(ring);
            }

            if (outerPolygon != null)
            {
                GisUtil.drawPolygon(outerPolygon, mapControl, outerColor);
            }
            else
            { 
                //是否要绘制一个文本?
            }
            if (innerPolygon != null)
            {
                GisUtil.drawPolygon(innerPolygon, mapControl, innerColor);
            }
            else
            { 
                //是否要绘制一个文本?
            }
            for (int i = 0; i < unitPolygonList.Count; i++)
            {
                GisUtil.drawPolygon(unitPolygonList[i], mapControl, innerColor);
            }

            //绘制文字.
            upperLeftPt = new PointClass();
            upperLeftPt.X = upperLeftX;
            upperLeftPt.Y = upperLeftY;
            upperRightPt = new PointClass();
            upperRightPt.X = upperLeftPt.X + house.width;
            upperRightPt.Y = upperLeftPt.Y;
            lowerLeftPt = new PointClass();
            lowerLeftPt.X = upperLeftPt.X;
            lowerLeftPt.Y = upperLeftPt.Y - commonHouse.height;
            lowerRightPt = new PointClass();
            lowerRightPt.X = lowerLeftPt.X + house.width;
            lowerRightPt.Y = lowerLeftPt.Y;

            if (house.leftGap > 0 && house.rightGap > 0 && commonHouse.frontGap > 0 && commonHouse.backGap > 0 && house.width > 0 && commonHouse.height > 0)
            {
                midLeftPt = new PointClass();
                midLeftPt.X = lowerLeftPt.X;
                midLeftPt.Y = (lowerLeftPt.Y + upperLeftPt.Y) / 2;
                IPoint otherEndPt = new PointClass();
                otherEndPt.X = midLeftPt.X - house.leftGap;
                otherEndPt.Y = midLeftPt.Y;
                drawLineWithText(otherEndPt, midLeftPt, "左间距:" + String.Format("{0:F}", house.leftGap) + "(米)", true);
                midRightPt = new PointClass(); //画右间距.
                midRightPt.X = lowerRightPt.X;
                midRightPt.Y = (lowerLeftPt.Y + upperLeftPt.Y) / 2;
                otherEndPt = new PointClass();
                otherEndPt.X = midRightPt.X + house.rightGap;
                otherEndPt.Y = midRightPt.Y;
                drawLineWithText(midRightPt, otherEndPt, "右间距:" + String.Format("{0:F}", house.rightGap) + "(米)", true);
                IPoint upperMidPt = new PointClass(); //画后深.
                upperMidPt.X = (lowerLeftPt.X + lowerRightPt.X) / 2;
                upperMidPt.Y = upperLeftPt.Y;
                otherEndPt = new PointClass();
                otherEndPt.X = upperMidPt.X;
                otherEndPt.Y = upperMidPt.Y + commonHouse.backGap;
                drawLineWithText(otherEndPt, upperMidPt, "后间距:" + String.Format("{0:F}", commonHouse.backGap) + "(米)", false);
                lowerMidPt = new PointClass(); //画前深.
                lowerMidPt.X = (lowerLeftPt.X + lowerRightPt.X) / 2;
                lowerMidPt.Y = lowerLeftPt.Y;
                otherEndPt = new PointClass();
                otherEndPt.X = lowerMidPt.X;
                otherEndPt.Y = lowerMidPt.Y - commonHouse.frontGap;
                drawLineWithText(lowerMidPt, otherEndPt, "前深: " + String.Format("{0:F}", commonHouse.frontGap) + "(米)", false);
            }

            upperRightPt = new PointClass();
            if (house.width > 0)
            {
                upperRightPt.X = upperLeftX + house.width + house.rightGap;
                upperRightPt.Y = upperLeftY + commonHouse.backGap;
            }
            else
            {
                upperRightPt.X = upperLeftX;
                upperRightPt.Y = upperLeftY;
            }
            double extraTextY = 0;
            IPoint extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = upperRightPt.Y;
            extraTextY = extraTextPt.Y;
            if (house.width > 0)
                GisUtil.drawText("面宽: " + String.Format("{0:F}", house.width) + "(米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("面宽: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (commonHouse.height > 0)
                GisUtil.drawText("进深:" + String.Format("{0:F}", commonHouse.height) + "(米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("进深: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass(); //画房型名.
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (house.width > 0 && house.unit > 0)
                GisUtil.drawText("每单元面宽: " + String.Format("{0:F}", house.width / house.unit) + "(米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("每单元面宽: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass(); //画房型名.
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (commonHouse.height > 0 && house.unit > 0)
                GisUtil.drawText("每单元进深: " + String.Format("{0:F}", commonHouse.height / house.unit) + "(米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("每单元进深: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass(); //画房型名.
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            GisUtil.drawText("房型名: " + house.name, extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass(); //画层数.
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (commonHouse.floor > 0)
                GisUtil.drawText("层数: " + commonHouse.floor.ToString() + "(层)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("层数: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (commonHouse.floorHeight > 0)
                GisUtil.drawText("层高: " + String.Format("{0:F}", commonHouse.floorHeight) + "(米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("层高: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (house.unit > 0)
                GisUtil.drawText("单元数: " + house.unit.ToString(), extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("单元数: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (house.houseHold > 0)
                GisUtil.drawText("每单元户数: " + house.houseHold.ToString() + "(户)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("每单元户数: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (house.width > 0 && commonHouse.height > 0)
                GisUtil.drawText("层面积: " + String.Format("{0:F}", house.width * commonHouse.height) + "(平方米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("层面积: 未知", extraTextPt, textColor, mapControl);
            extraTextPt = new PointClass();
            extraTextPt.X = upperRightPt.X + extraTextRightGap;
            extraTextPt.Y = extraTextY + extraTextBottomGap;
            extraTextY = extraTextPt.Y;
            if (house.width > 0 && commonHouse.height > 0 && commonHouse.floor > 0)
                GisUtil.drawText("总面积: " + String.Format("{0:F}", house.width * commonHouse.height * commonHouse.floor) + "(平方米)", extraTextPt, textColor, mapControl);
            else
                GisUtil.drawText("总面积: 未知", extraTextPt, textColor, mapControl);

            //移动地图视角.
            if (outerPolygon == null)
            {
                extent = upperRightPt.Envelope;
            }
            else
            {
                extent = outerPolygon.Envelope;
            }
            extent.Expand(2, 2, true);
            mapControl.Extent = extent;
        }
        public static IGeometry GetExample4()
        {
            //Ring: Maze Lying On XY Plane

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IPointCollection ringPointCollection = new RingClass();

            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(10, 10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(10, -10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, -10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(6, 6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(6, -6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-6, -6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-6, 2, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-6, 2, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, 2, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-8, 4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-8, -8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(8, -8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(8, 8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 10, 0), ref _missing, ref _missing);

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

            return(multiPatchGeometryCollection as IGeometry);
        }
Пример #42
0
        /// <summary>
        /// 生成可视与不可视域的多面体    张琪    20110621
        /// </summary>
        /// <param name="bIsVis">是否可视</param>
        /// <param name="pObsPt">观察点</param>
        /// <param name="pTarPt">目标点</param>
        /// <param name="pVisLine">可视线要素</param>
        /// <param name="pInVisLine">不可视线要素</param>
        /// <param name="pVisPatch">可视多面体</param>
        /// <param name="pInVisPatch">不可视多面体</param>
        /// <param name="dTargetHeight"></param>
        public void CreateVerticalLOSPatches(bool bIsVis, ESRI.ArcGIS.Geometry.IPoint pObsPt, ESRI.ArcGIS.Geometry.IPoint pTarPt, IPolyline pVisLine, IPolyline pInVisLine, IGeometryCollection pVisPatch, IGeometryCollection pInVisPatch, double dTargetHeight)
        {
            IGeometryCollection pGeomColl    = pVisLine as IGeometryCollection; //存储可视域线要素
            IMultiPatch         pVisMPatch   = pVisPatch as IMultiPatch;
            IMultiPatch         pInVisMPatch = pInVisPatch as IMultiPatch;      //生成不可视域要素

            dTargetHeight = pTarPt.Z;
            double           dist1 = 0;
            double           dist2;
            IPointCollection pPc;
            IClone           pClone;

            ESRI.ArcGIS.Geometry.IPoint pLastVisPoint = null;
            IPointCollection            pVisFan       = new TriangleFanClass();//用于存储可视域多面体要素
            object before = Type.Missing;
            object after  = Type.Missing;

            for (int i = 0; i < pGeomColl.GeometryCount; i++)//遍历可视域线要素
            {
                pPc = pGeomColl.get_Geometry(i) as IPointCollection;
                if (i == 0)//当为第一个可视域线要素是先要存储观察点要素
                {
                    pClone = pObsPt as IClone;
                    pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                    pClone = pPc.get_Point(0) as IClone;
                    pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                    ESRI.ArcGIS.Geometry.IPoint pStartPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                }
                pClone = pPc as IClone;
                pVisFan.AddPointCollection(pClone.Clone() as IPointCollection); //将可视域线要素的点集合存储于pVisFan中

                if (i == pGeomColl.GeometryCount - 1)                           //当为可视域最后一个线要素时
                {
                    IVector3D pV = new Vector3DClass();
                    ESRI.ArcGIS.Geometry.IPoint p1;
                    pClone = pObsPt as IClone;
                    p1     = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                    p1.Z   = 0;
                    ESRI.ArcGIS.Geometry.IPoint p2;
                    pClone = pPc.get_Point(pPc.PointCount - 1) as IClone;
                    p2     = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                    p2.Z   = 0;
                    pV.ConstructDifference(p1, p2);
                    dist1         = pV.Magnitude;
                    pLastVisPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                    if (pInVisLine == null)
                    {
                        if (pTarPt.Z > pPc.get_Point(pPc.PointCount - 1).Z)//当被观察点高程高于最后一点要素时则到被观点都是可视的
                        {
                            pClone = pTarPt as IClone;
                            pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                        }
                    }
                }

                pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); //根据获得的点要素集生成TriangleFanClass
            }
            if (pInVisLine != null)                                                 //当不可视域的线要素不为空时
            {
                pGeomColl = pInVisLine as IGeometryCollection;
                IPointCollection pInVisRing = new RingClass();//用于存储不可视域点要素集并生成RingClass
                for (int i = 0; i < pGeomColl.GeometryCount; i++)
                {
                    pPc    = pGeomColl.get_Geometry(i) as IPointCollection;
                    pClone = pPc.get_Point(0) as IClone;
                    pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                    pClone = pPc as IClone;
                    pInVisRing.AddPointCollection(pClone.Clone() as IPointCollection);
                    if (i == pGeomColl.GeometryCount - 1)
                    {
                        IVector3D pV = new Vector3DClass();
                        pClone = pObsPt as IClone;
                        ESRI.ArcGIS.Geometry.IPoint p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                        p1.Z   = 0;
                        pClone = pPc.get_Point(pPc.PointCount - 1) as IClone;
                        ESRI.ArcGIS.Geometry.IPoint p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                        p2.Z = 0;
                        pV.ConstructDifference(p1, p2);
                        dist2 = pV.Magnitude;
                        if (dist1 < dist2)
                        {
                            pClone = pObsPt as IClone;
                            p1     = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                            p1.Z   = 0;
                            pClone = pPc.get_Point(0) as IClone;
                            p2     = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                            p2.Z   = 0;
                            pV.ConstructDifference(p1, p2);
                            double theDist1;
                            theDist1 = pV.Magnitude;
                            double slope = (pObsPt.Z - pPc.get_Point(0).Z) / theDist1;
                            pClone = pPc.get_Point(pPc.PointCount - 1) as IClone;
                            ESRI.ArcGIS.Geometry.IPoint pEndPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                            p2   = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
                            p2.Z = 0;
                            pV.ConstructDifference(p1, p2);
                            double theDist2  = pV.Magnitude;
                            double deltaZ    = theDist2 * slope;
                            double theHeight = pObsPt.Z - deltaZ;
                            pEndPoint.Z = theHeight;
                            pClone      = pEndPoint as IClone;
                            pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                            if (bIsVis)//为True时说明不可视域线要素空间范围内存在可视区域
                            {
                                pVisFan = new TriangleFanClass();
                                pClone  = pObsPt as IClone;
                                pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                                pClone = pTarPt as IClone;
                                pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                                pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after);
                            }
                            else
                            {
                                dTargetHeight = pEndPoint.Z;
                            }
                        }
                        else
                        {
                            if (bIsVis)
                            {
                                if (pTarPt.Z > pLastVisPoint.Z)
                                {
                                    pVisFan = new TriangleFanClass();
                                    pClone  = pObsPt as IClone;
                                    pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                                    pClone = pTarPt as IClone;
                                    pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                                    pClone = pLastVisPoint as IClone;
                                    pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                                    pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after);
                                }
                            }
                        }
                    }
                    pClone = pPc.get_Point(0) as IClone;
                    pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after);
                    pInVisPatch.AddGeometry(pInVisRing as IGeometry, ref before, ref after);//获取每段不可视域线要素点集合并生成RingClass
                    pInVisMPatch.PutRingType(pInVisRing as IRing, esriMultiPatchRingType.esriMultiPatchRing);
                }
            }
        }
        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;
        }
        private IPolygon GetMGRSPolygon(IPoint point)
        {
            CoordinateMGRS mgrs;

            IPointCollection pc = new RingClass();

            // bottom left
            CoordinateMGRS.TryParse(InputCoordinate, out mgrs);

            // don't create a polygon for 1m resolution
            if (mgrs.Easting.ToString().Length > 4 && mgrs.Northing.ToString().Length > 4)
                return null;

            var tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            var anotherMGRSstring = mgrs.ToString("", new CoordinateMGRSFormatter());
            tempPoint.PutCoordsFromMGRS(anotherMGRSstring, esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);
            
            // top left
            var tempMGRS = new CoordinateMGRS(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing);
            var tempEasting = mgrs.Easting.ToString().PadRight(5,'0');
            tempMGRS.Easting = Convert.ToInt32(tempEasting);
            var tempNorthing = mgrs.Northing.ToString().PadRight(5,'9');
            tempMGRS.Northing = Convert.ToInt32(tempNorthing.Replace('0','9'));

            tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            anotherMGRSstring = tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter());
            tempPoint.PutCoordsFromMGRS(anotherMGRSstring, esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // top right
            tempEasting = mgrs.Easting.ToString().PadRight(5,'9');
            tempMGRS.Easting = Convert.ToInt32(tempEasting.Replace('0', '9'));
            tempNorthing = mgrs.Northing.ToString().PadRight(5,'9');
            tempMGRS.Northing = Convert.ToInt32(tempNorthing.Replace('0', '9'));

            tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            tempPoint.PutCoordsFromMGRS(tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // bottom right
            tempEasting = mgrs.Easting.ToString().PadRight(5,'9');
            tempMGRS.Easting = Convert.ToInt32(tempEasting.Replace('0', '9'));
            tempNorthing = mgrs.Northing.ToString().PadRight(5,'0');
            tempMGRS.Northing = Convert.ToInt32(tempNorthing);

            tempPoint = new PointClass() as IConversionNotation;
            (tempPoint as IPoint).SpatialReference = GetSR();
            tempPoint.PutCoordsFromMGRS(tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_Automatic);
            pc.AddPoint(tempPoint as IPoint);

            // create polygon
            var poly = new PolygonClass();
            poly.SpatialReference = GetSR();
            poly.AddPointCollection(pc);
            poly.Close();

            return poly;
        }
        public static IGeometry GetExample4()
        {
            //Ring: Maze Lying On XY Plane

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IPointCollection ringPointCollection = new RingClass();

            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(10, 10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(10, -10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, -10, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(6, 6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(6, -6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-6, -6, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-6, 2, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-6, 2, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, 2, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(0, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-8, 4, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-8, -8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(8, -8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(8, 8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 8, 0), ref _missing, ref _missing);
            ringPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-10, 10, 0), ref _missing, ref _missing);

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

            return multiPatchGeometryCollection as IGeometry;
        }
        public static IGeometry GetExample3()
        {
            //Composite: House Composed Of 7 Ring, 1 TriangleStrip, And 1 Triangles Parts

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Base (Exterior Ring)

            IPointCollection basePointCollection = new RingClass();
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(basePointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(basePointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Front With Cutaway For Door (Exterior Ring)

            IPointCollection frontPointCollection = new RingClass();
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 1, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 1, 4), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -1, 4), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -1, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);
            frontPointCollection.AddPoint(frontPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(frontPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Back (Exterior Ring)

            IPointCollection backPointCollection = new RingClass();
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing);
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing);
            backPointCollection.AddPoint(backPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(backPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Right Side (Ring Group)

            //Exterior Ring

            IPointCollection rightSideExteriorPointCollection = new RingClass();
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(rightSideExteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(rightSideExteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring

            IPointCollection rightSideInteriorPointCollection = new RingClass();
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 4), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 2), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 2), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 4), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(rightSideInteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(rightSideInteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Left Side (Ring Group)

            //Exterior Ring

            IPointCollection leftSideExteriorPointCollection = new RingClass();
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(leftSideExteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(leftSideExteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring

            IPointCollection leftSideInteriorPointCollection = new RingClass();
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 4), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 4), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 2), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 2), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(leftSideInteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(leftSideInteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Roof

            IPointCollection roofPointCollection = new TriangleStripClass();
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 9), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 9), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);

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

            //Triangular Area Between Roof And Front/Back

            IPointCollection triangularAreaPointCollection = new TrianglesClass();

            //Area Between Roof And Front

            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 9), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);

            //Area Between Roof And Back

            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 9), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);

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

            return multiPatchGeometryCollection as IGeometry;
        }
Пример #47
0
        public static IGeometry GetExample3()
        {
            //Composite: House Composed Of 7 Ring, 1 TriangleStrip, And 1 Triangles Parts

            IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();

            IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

            //Base (Exterior Ring)

            IPointCollection basePointCollection = new RingClass();

            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing);
            basePointCollection.AddPoint(basePointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(basePointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Front With Cutaway For Door (Exterior Ring)

            IPointCollection frontPointCollection = new RingClass();

            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 1, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 1, 4), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -1, 4), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -1, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing);
            frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);
            frontPointCollection.AddPoint(frontPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(frontPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Back (Exterior Ring)

            IPointCollection backPointCollection = new RingClass();

            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing);
            backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing);
            backPointCollection.AddPoint(backPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(backPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Right Side (Ring Group)

            //Exterior Ring

            IPointCollection rightSideExteriorPointCollection = new RingClass();

            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing);
            rightSideExteriorPointCollection.AddPoint(rightSideExteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(rightSideExteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring

            IPointCollection rightSideInteriorPointCollection = new RingClass();

            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 4), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 2), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 2), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 4), ref _missing, ref _missing);
            rightSideInteriorPointCollection.AddPoint(rightSideInteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(rightSideInteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Left Side (Ring Group)

            //Exterior Ring

            IPointCollection leftSideExteriorPointCollection = new RingClass();

            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            leftSideExteriorPointCollection.AddPoint(leftSideExteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(leftSideExteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);

            //Interior Ring

            IPointCollection leftSideInteriorPointCollection = new RingClass();

            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 4), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 4), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 2), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 2), ref _missing, ref _missing);
            leftSideInteriorPointCollection.AddPoint(leftSideInteriorPointCollection.get_Point(0), ref _missing, ref _missing);

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

            multiPatch.PutRingType(leftSideInteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchInnerRing);

            //Roof

            IPointCollection roofPointCollection = new TriangleStripClass();

            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 9), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 9), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);

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

            //Triangular Area Between Roof And Front/Back

            IPointCollection triangularAreaPointCollection = new TrianglesClass();

            //Area Between Roof And Front

            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 9), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing);

            //Area Between Roof And Back

            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 9), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing);
            triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing);

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

            return(multiPatchGeometryCollection as IGeometry);
        }
        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;
        }
Пример #49
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);
        }
Пример #50
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);
        }
Пример #51
0
        private IGeometry ConstructRing(IEnumerable<IPoint> points)
        {
            var r = new RingClass();

            foreach (var point in points)
            {
                r.AddPoint(point);
            }

            r.Close();

            return r;
        }