Пример #1
0
        //线构面
        private static IPolygon PolylineToPolygon(ref IPolyline pPolyline)
        {
            try
            {
                //创建一个新的Polygon geometry.
                IGeometryCollection pPolygonGeometryCol = new PolygonClass();

                //克隆即将要操作的Polyline
                IClone pClone = pPolyline as IClone;

                IGeometryCollection pGeoms_Polyline = pClone.Clone() as IGeometryCollection;
                object pBObj = Type.Missing;
                object pAObj = Type.Missing;
                for (int i = 0; i < pGeoms_Polyline.GeometryCount; i++)
                {
                    //通过Polyline的每个Path创建为一个新的Ring,并把Ring增加到一个新的Polygon
                    ISegmentCollection pSegs_Ring = new RingClass();
                    pSegs_Ring.AddSegmentCollection(pGeoms_Polyline.get_Geometry(i) as ISegmentCollection);
                    pPolygonGeometryCol.AddGeometry(pSegs_Ring as IGeometry, ref pBObj, ref pAObj);
                }
                //生成的Polygon旋转的顺序可能不正确,为确保正确调用SimplifyPreserveFromTo
                IPolygon pNewPolygon = new PolygonClass();
                pNewPolygon = pPolygonGeometryCol as IPolygon;
                pNewPolygon.SimplifyPreserveFromTo();
                return(pNewPolygon);
            }
            catch
            {
                return(null);
            }
        }
Пример #2
0
        //cast the polyline object to the polygon xisheng 20110926
        private IPolygon GetPolygonFormLine(IPolyline pPolyline)
        {
            ISegmentCollection  pRing;
            IGeometryCollection pPolygon   = new PolygonClass();
            IGeometryCollection pPolylineC = pPolyline as IGeometryCollection;
            object o = Type.Missing;

            for (int i = 0; i < pPolylineC.GeometryCount; i++)
            {
                pRing = new RingClass();
                pRing.AddSegmentCollection(pPolylineC.get_Geometry(i) as ISegmentCollection);
                pPolygon.AddGeometry(pRing as IGeometry, ref o, ref o);
            }
            IPolygon polygon = pPolygon as IPolygon;

            return(polygon);
        }
Пример #3
0
 public IPolygon ConvertPolylineToPolygon(IPolyline pPolyline)
 {
     try
     {
         if (pPolyline == null)
         {
             return(null);
         }
         IClone clone = pPolyline as IClone;
         IGeometryCollection geometrys = null;
         geometrys = clone.Clone() as IGeometryCollection;
         if (geometrys.GeometryCount < 0)
         {
             return(null);
         }
         IGeometryCollection geometrys2 = null;
         geometrys2 = new PolygonClass();
         ISegmentCollection segments = null;
         int    index  = 0;
         object before = null;
         object after  = null;
         for (index = 0; index <= (geometrys.GeometryCount - 1); index++)
         {
             segments = new RingClass();
             segments.AddSegmentCollection(geometrys.get_Geometry(index) as ISegmentCollection);
             geometrys2.AddGeometry(segments as IGeometry, ref before, ref after);
         }
         (geometrys2 as ITopologicalOperator).Simplify();
         return(geometrys2 as IPolygon);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.GeometryFun", "ConvertPolylineToPolygon", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
Пример #4
0
        /// <summary>
        /// 根据传入的左邦点数组和右邦点数组生成巷道
        /// </summary>
        /// <param name="tunnel"></param>
        /// <param name="pts"></param>
        /// <param name="editlayer"></param>
        public void DrawHuDong(TunnelEntity tunnel, WirePointInfoEntity[] pts, IFeatureLayer editlayer)
        {
            IPoint                  point           = new PointClass();
            IPointCollection4       pointCollection = new PolygonClass();
            TunnelPointsCalculation TPC             = new TunnelPointsCalculation();

            Vector3_DW[] lstLeftBtmVertices  = null;
            Vector3_DW[] lstRightBtmVertices = null;
            TPC.CalcLeftAndRightVertics(pts, ref lstLeftBtmVertices, ref lstRightBtmVertices);
            for (int intI = 0; intI < lstLeftBtmVertices.Length; intI++)
            {
                point.X = lstLeftBtmVertices[intI].X;
                point.Y = lstLeftBtmVertices[intI].Y;
                point.Z = lstLeftBtmVertices[intI].Z;
                pointCollection.AddPoint(point);
            }
            for (int intI = lstRightBtmVertices.Length; intI >= 0; intI--)
            {
                point.X = lstRightBtmVertices[intI].X;
                point.Y = lstRightBtmVertices[intI].Y;
                point.Z = lstRightBtmVertices[intI].Z;
                pointCollection.AddPoint(point);
            }

            IFeature            f;
            IGeometryCollection polygon;
            //定义一个地物类,把要编辑的图层转化为定义的地物类
            IFeatureClass fc = editlayer.FeatureClass;
            //先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间,
            IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;

            //开始事务操作
            w.StartEditing(false);
            //开始编辑
            w.StartEditOperation();
            //创建一个地物

            //绘制巷道


            polygon = new PolygonClass();
            IGeometryCollection pGeoColl = pointCollection as IGeometryCollection;
            ISegmentCollection  pRing    = new RingClass();

            pRing.AddSegmentCollection(pGeoColl as ISegmentCollection);

            polygon.AddGeometry(pRing as IGeometry);
            IPolygon polyGonGeo = polygon as IPolygon;

            polyGonGeo.SimplifyPreserveFromTo();
            f = fc.CreateFeature();
            //polygon.PutCoords(Convert.ToDouble(ge.CoordinateX), Convert.ToDouble(ge.CoordinateY));
            //确定图形类型
            f.Shape = (IGeometry)polyGonGeo;

            //给巷道赋属性值
            int num3;

            //num3 = editlayer.FeatureClass.Fields.FindField("OBJECTID");
            //f.set_Value(num3, tunnel.TunnelID);
            num3 = editlayer.FeatureClass.Fields.FindField("MINE_NAME");
            f.set_Value(num3, tunnel.MineName);
            num3 = editlayer.FeatureClass.Fields.FindField("HORIZONTAL");
            f.set_Value(num3, tunnel.HorizontalName);
            num3 = editlayer.FeatureClass.Fields.FindField("MINING_AREA");
            f.set_Value(num3, tunnel.MiningAreaName);
            num3 = editlayer.FeatureClass.Fields.FindField("WORKING_FACE");
            f.set_Value(num3, tunnel.WorkingFaceName);
            num3 = editlayer.FeatureClass.Fields.FindField("TUNNEL_NAME");
            f.set_Value(num3, tunnel.TunnelName);
            num3 = editlayer.FeatureClass.Fields.FindField("SUPPORT_PATTERN");
            f.set_Value(num3, tunnel.TunnelSupportPattern);
            num3 = editlayer.FeatureClass.Fields.FindField("LITHOLOGY_ID");
            f.set_Value(num3, tunnel.TunnelLithologyID);
            num3 = editlayer.FeatureClass.Fields.FindField("FAULTAGETYPE");
            f.set_Value(num3, tunnel.TunnelSectionType);
            num3 = editlayer.FeatureClass.Fields.FindField("PARAM");
            f.set_Value(num3, tunnel.TunnelParam);
            num3 = editlayer.FeatureClass.Fields.FindField("DESIGNLENGTH");
            f.set_Value(num3, tunnel.TunnelDesignLength);
            //num3 = editlayer.FeatureClass.Fields.FindField("RULE_CODE");
            //f.set_Value(num3, tunnel.r);
            //保存地物
            f.Store();
            //渲染巷道样式
            ISimpleFillSymbol pFillSymbol;

            pFillSymbol               = new SimpleFillSymbolClass();
            pFillSymbol.Color         = getRGB(60, 100, 50);
            pFillSymbol.Outline.Color = getRGB(60, 100, 50);
            pFillSymbol.Outline.Width = 1;
            pFillSymbol.Style         = esriSimpleFillStyle.esriSFSSolid;
            RenderfeatureLayer(editlayer, pFillSymbol as ISymbol);
            //结束编辑
            w.StopEditOperation();
            //结束事务操作
            w.StopEditing(true);
        }
        private void createpolygon(IPointCollection ippoints)
        {
            ISegmentCollection ppath = new PathClass();
            IGeometryCollection ppolyline = new PolylineClass();
            if (ippoints.PointCount >= 3)
            {
                int i;
                object o = Type.Missing;
                if (ippoints.PointCount >= 4)
                {
                    ippoints.RemovePoints(ippoints.PointCount - 2, 1);
                }
                ippoints.AddPoint(ippoints.get_Point(0));
                for (i = 0; i < ippoints.PointCount - 1; i++)
                {
                    ILine pline = new LineClass();
                    pline.PutCoords(ippoints.get_Point(i), ippoints.get_Point(i + 1));
                    ISegment psegment = pline as ISegment;

                    ppath.AddSegment(psegment, ref o, ref o);
                    ppolyline.AddGeometry(ppath as IGeometry, ref o, ref o);
                }
                ipPolyResult = ppolyline as IPolyline;
                ISegmentCollection pRing = new RingClass();
                IGeometryCollection pGeometryColl = new PolygonClass();
                for (int j = 0; j < ppolyline.GeometryCount; j++)
                {
                    pRing.AddSegmentCollection(ppolyline.get_Geometry(j) as ISegmentCollection);
                    pGeometryColl.AddGeometry(pRing as IGeometry, ref o, ref o);
                }
                ipolygon = pGeometryColl as IPolygon;
            }
        }
        /// <summary>
        /// 根据传入的左邦点数组和右邦点数组生成巷道
        /// </summary>
        /// <param name="tunnel"></param>
        /// <param name="pts"></param>
        /// <param name="editlayer"></param>
        public void DrawHuDong(TunnelEntity tunnel, WirePointInfoEntity[] pts, IFeatureLayer editlayer)
        {
            IPoint point = new PointClass();
               IPointCollection4 pointCollection = new PolygonClass();
               TunnelPointsCalculation TPC = new TunnelPointsCalculation();
               Vector3_DW[] lstLeftBtmVertices = null;
               Vector3_DW[] lstRightBtmVertices = null;
               TPC.CalcLeftAndRightVertics(pts, ref lstLeftBtmVertices,ref lstRightBtmVertices);
               for (int intI = 0; intI < lstLeftBtmVertices.Length; intI++)
               {
               point.X = lstLeftBtmVertices[intI].X;
               point.Y = lstLeftBtmVertices[intI].Y;
               point.Z = lstLeftBtmVertices[intI].Z;
               pointCollection.AddPoint(point);
               }
               for (int intI = lstRightBtmVertices.Length; intI >=0; intI--)
               {
               point.X = lstRightBtmVertices[intI].X;
               point.Y = lstRightBtmVertices[intI].Y;
               point.Z = lstRightBtmVertices[intI].Z;
               pointCollection.AddPoint(point);
               }

               IFeature f;
               IGeometryCollection polygon;
               //定义一个地物类,把要编辑的图层转化为定义的地物类
               IFeatureClass fc = editlayer.FeatureClass;
               //先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间,
               IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;
               //开始事务操作
               w.StartEditing(false);
               //开始编辑
               w.StartEditOperation();
               //创建一个地物

               //绘制巷道

               polygon = new PolygonClass();
               IGeometryCollection pGeoColl = pointCollection as IGeometryCollection;
               ISegmentCollection pRing = new RingClass();
               pRing.AddSegmentCollection(pGeoColl as ISegmentCollection);

               polygon.AddGeometry(pRing as IGeometry);
               IPolygon polyGonGeo = polygon as IPolygon;
               polyGonGeo.SimplifyPreserveFromTo();
               f = fc.CreateFeature();
               //polygon.PutCoords(Convert.ToDouble(ge.CoordinateX), Convert.ToDouble(ge.CoordinateY));
               //确定图形类型
               f.Shape = (IGeometry)polyGonGeo;

               //给巷道赋属性值
               int num3;
               //num3 = editlayer.FeatureClass.Fields.FindField("OBJECTID");
               //f.set_Value(num3, tunnel.TunnelID);
               num3 = editlayer.FeatureClass.Fields.FindField("MINE_NAME");
               f.set_Value(num3, tunnel.MineName);
               num3 = editlayer.FeatureClass.Fields.FindField("HORIZONTAL");
               f.set_Value(num3, tunnel.HorizontalName);
               num3 = editlayer.FeatureClass.Fields.FindField("MINING_AREA");
               f.set_Value(num3, tunnel.MiningAreaName);
               num3 = editlayer.FeatureClass.Fields.FindField("WORKING_FACE");
               f.set_Value(num3, tunnel.WorkingFaceName);
               num3 = editlayer.FeatureClass.Fields.FindField("TUNNEL_NAME");
               f.set_Value(num3, tunnel.TunnelName);
               num3 = editlayer.FeatureClass.Fields.FindField("SUPPORT_PATTERN");
               f.set_Value(num3, tunnel.TunnelSupportPattern);
               num3 = editlayer.FeatureClass.Fields.FindField("LITHOLOGY_ID");
               f.set_Value(num3, tunnel.TunnelLithologyID);
               num3 = editlayer.FeatureClass.Fields.FindField("FAULTAGETYPE");
               f.set_Value(num3, tunnel.TunnelSectionType);
               num3 = editlayer.FeatureClass.Fields.FindField("PARAM");
               f.set_Value(num3, tunnel.TunnelParam);
               num3 = editlayer.FeatureClass.Fields.FindField("DESIGNLENGTH");
               f.set_Value(num3, tunnel.TunnelDesignLength);
               //num3 = editlayer.FeatureClass.Fields.FindField("RULE_CODE");
               //f.set_Value(num3, tunnel.r);
               //保存地物
               f.Store();
              //渲染巷道样式
               ISimpleFillSymbol pFillSymbol;
               pFillSymbol = new SimpleFillSymbolClass();
               pFillSymbol.Color = getRGB(60, 100, 50);
               pFillSymbol.Outline.Color = getRGB(60, 100, 50);
               pFillSymbol.Outline.Width = 1;
               pFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
               RenderfeatureLayer(editlayer, pFillSymbol as ISymbol);
               //结束编辑
               w.StopEditOperation();
               //结束事务操作
               w.StopEditing(true);
        }