Пример #1
0
        private List <IPoint> SplitPolyline(IPolyline polyline, IPointCollection intersectpointsColl, IPoint presentCP)
        {
            IEnumVertex pEnumVertex = intersectpointsColl.EnumVertices;
            //IPolycurve2 has SplitAtPoints

            IPolycurve2 pPolyCurve = polyline as IPolycurve2;

            pPolyCurve.SplitAtPoints(pEnumVertex, false, true, -1);
            IGeometryCollection geoColl = pPolyCurve as IGeometryCollection;
            //MessageBox.Show(geoColl.GeometryCount.ToString());
            List <IPoint> ptlist = new List <IPoint>();
            // The results are pathclass
            IPath resultPath;

            for (int i = 0; i < geoColl.GeometryCount; i++)
            {
                object obj = Type.Missing;
                resultPath = new PathClass();
                resultPath = (IPath)geoColl.get_Geometry(i);
                IGeometryCollection lineColl = new PolylineClass();
                lineColl.AddGeometry(resultPath, ref obj, ref obj);
                IPolyline           line         = (IPolyline)lineColl;
                IRelationalOperator pRelOperator = (IRelationalOperator)line;
                if (pRelOperator.Touches(presentCP) || pRelOperator.Contains(presentCP))
                {
                    IPoint temPT1 = resultPath.FromPoint;
                    IPoint temPT2 = resultPath.ToPoint;
                    //pGeometryCollection.AddGeometry(temPT1);
                    //pGeometryCollection.AddGeometry(temPT2);
                    ptlist.Add(temPT1);
                    ptlist.Add(temPT2);
                }
            }
            return(ptlist);
        }
Пример #2
0
        //分割线
        public virtual ZhFeature[] SplitPolyline(ZhFeature[] zhFeatures, ZhFeature[] pUsedZHFeatures)
        {
            List <ZhFeature> pMuliFeatures = new List <ZhFeature>();
            List <IGeometry> GeoList       = new List <IGeometry>();

            GeoList.Clear();
            List <IGeometry> CutterGeoList = new List <IGeometry>();
            IPointCollection pMultipoint   = null;

            IGeometry[] cgGeoArray = null;
            //几何对象分割
            foreach (ZhFeature tpByFeat in zhFeatures)
            {
                CutterGeoList.Clear();
                cgGeoArray = null;

                object    obj            = Type.Missing;
                IPolyline cutterPolyline = new PolylineClass();
                pMultipoint = (IPointCollection)cutterPolyline;

                //求相交点的所有集合
                foreach (ZhFeature tpUsedFeat in pUsedZHFeatures)
                {
                    //求相交点集合
                    cgGeoArray = this.MuliCutPolyline(tpByFeat, tpUsedFeat);
                    foreach (IGeometry tGeo in cgGeoArray)
                    {
                        if (((IRelationalOperator)pMultipoint).Contains(tGeo) == false)
                        {
                            pMultipoint.AddPoint((IPoint)tGeo, ref obj, ref obj);
                        }
                    }
                }

                //添加原线端点
                //pMultipoint.AddPointCollection((IPointCollection)tpByFeat.pFeature.ShapeCopy);

                //拓朴化处理  去掉重复点操作
                //ITopologicalOperator pTop = pMultipoint as ITopologicalOperator;
                //pTop.Simplify();
                //pMultipoint = pTop as IPointCollection;

                //清除原对象
                GeoList.Clear();

                //用相交点集合分割线
                if (tpByFeat.pFeature.Shape is IPolycurve2)
                {
                    //IPoint outVertex = null;
                    //IPoint preVertex = null;

                    //int outPartIndex = 0;
                    //int vertexIndex = 0;
                    IPolycurve2 Curve2      = tpByFeat.pFeature.Shape as IPolycurve2;
                    IEnumVertex SplitPoints = pMultipoint.EnumVertices;
                    Curve2.SplitAtPoints(SplitPoints, true, true, -1);
                    IGeometryCollection pcgGeoColl = Curve2 as IGeometryCollection;
                    for (int i = 0; i < pcgGeoColl.GeometryCount; i++)
                    {
                        IGeometry tpcgGeo = pcgGeoColl.get_Geometry(i);

                        IGeometryCollection oGeoCol = new PolylineClass();
                        oGeoCol.AddGeometries(1, ref tpcgGeo);

                        if (((ITopologicalOperator)oGeoCol).IsSimple == false)
                        {
                            ((ITopologicalOperator)oGeoCol).Simplify();
                        }

                        GeoList.Add(oGeoCol as IGeometry);
                    }
                    #region IEnumSplitPoint
                    //IEnumSplitPoint cgEnumPoint=Curve2.SplitAtPoints(SplitPoints,false,false,-1);
                    //cgEnumPoint.Reset();
                    //cgEnumPoint.Next(out outVertex, out outPartIndex, out vertexIndex);
                    //while (outVertex != null && outVertex.IsEmpty != true && cgEnumPoint.IsLastInPart()!=true)
                    //{
                    //    preVertex=outVertex;
                    //    cgEnumPoint.Next(out outVertex, out outPartIndex, out vertexIndex);
                    //    if (preVertex != null && outVertex != null && outVertex.IsEmpty!=true)
                    //    {
                    //        IPolyline pcgPolyline = new PolylineClass();
                    //        (pcgPolyline as IPointCollection).AddPoint(preVertex, ref obj, ref obj);
                    //        (pcgPolyline as IPointCollection).AddPoint(outVertex, ref obj, ref obj);
                    //        if (pcgPolyline.IsEmpty != true)
                    //        {
                    //            GeoList.Add(pcgPolyline);
                    //        }
                    //    }
                    //}
                    #endregion
                }

                //创建分割后对象 ZHFeatureByGeoList
                ZhFeature tpFeat = null;
                foreach (IGeometry pGeo in GeoList)
                {
                    if (pGeo.IsEmpty != true)
                    {
                        tpFeat = this.CreateFeature();
                        //属性拷贝(含GHDM赋码)
                        tpByFeat.CopyField(ref tpFeat);
                        tpFeat.pFeature.Shape = pGeo;
                        //保存
                        //tpFeat.pFeature.Store();
                        pMuliFeatures.Add(tpFeat);
                    }
                }
            }
            return(pMuliFeatures.ToArray());
        }
Пример #3
0
        private IArray method_2(IGeometry igeometry_0, IGeometry igeometry_1)
        {
            IArray array;

            if (!(igeometry_0 == null ? false : igeometry_1 != null))
            {
                array = null;
            }
            else if (igeometry_0.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                IGeometry geometry = ((ITopologicalOperator)igeometry_0).Intersect(igeometry_1,
                                                                                   esriGeometryDimension.esriGeometry0Dimension);
                if (geometry != null)
                {
                    ((ITopologicalOperator)geometry).Simplify();
                    IEnumVertex enumVertices = ((IPointCollection)geometry).EnumVertices;
                    if (enumVertices != null)
                    {
                        IPolycurve2 igeometry0 = (IPolycurve2)igeometry_0;
                        if (igeometry0.SplitAtPoints(enumVertices, true, true, -1).SplitHappened)
                        {
                            IGeometryCollection geometryCollection = (IGeometryCollection)igeometry0;
                            IArray arrayClass = new ESRI.ArcGIS.esriSystem.Array();
                            try
                            {
                                bool   zAware = false;
                                bool   mAware = false;
                                double zMin   = 0;
                                try
                                {
                                    zAware = (igeometry_0 as IZAware).ZAware;
                                    zMin   = (igeometry_0 as IZ).ZMin;
                                }
                                catch
                                {
                                }
                                try
                                {
                                    mAware = (igeometry_0 as IMAware).MAware;
                                }
                                catch
                                {
                                }
                                for (int i = 0; i < geometryCollection.GeometryCount; i++)
                                {
                                    IGeometry           geometry1     = geometryCollection.Geometry[i];
                                    IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;
                                    (polylineClass as IZAware).ZAware = zAware;
                                    (polylineClass as IMAware).MAware = mAware;
                                    polylineClass.AddGeometries(1, ref geometry1);
                                    if (zAware)
                                    {
                                        (polylineClass as IZ).SetConstantZ(zMin);
                                    }
                                    (polylineClass as ITopologicalOperator).Simplify();
                                    arrayClass.Add(polylineClass);
                                }
                            }
                            catch (Exception exception)
                            {
                                Trace.WriteLine(exception);
                            }
                            array = arrayClass;
                        }
                        else
                        {
                            array = null;
                        }
                    }
                    else
                    {
                        array = null;
                    }
                }
                else
                {
                    array = null;
                }
            }
            else
            {
                array = null;
            }
            return(array);
        }