Esempio n. 1
0
        /// <summary>
        /// 获取交点
        /// </summary>
        /// <param name="TaskAreas"></param>
        /// <param name="map"></param>
        public static void getIntersect(ESRI.ArcGIS.Controls.AxMapControl pMapCtr)
        {
            Core.Map.MapHelper map = new Core.Map.MapHelper(pMapCtr);
            Core.Generic.myXML xml = new Core.Generic.myXML(System.Windows.Forms.Application.StartupPath + "\\Setting.xml");
            try
            {
                IFeatureClass             pFeatureClass = null;
                Core.Model.DisaCrossPoint gatherPoint   = new Core.Model.DisaCrossPoint();
                Core.DAL.DisaCrossPoint   dal           = new Core.DAL.DisaCrossPoint();
                //删除以前生成的交点
                dal.Deletes(list_model[0].PID);

                map.getNetWorkData(ref pFeatureClass);
                if (list_model.Count == 0)
                {
                    MessageBox.Show("该灾区尚未生成任务区!");
                    return;
                }
                //pIntersectPoint = new List<IPoint>();
                string   Roadtype    = xml.GetElement("FilterPara", "RoadType");
                string[] typeArray   = Roadtype.Split(',');
                string   whereclause = "";
                if (Roadtype != null)
                {
                    for (int i = 0; i < typeArray.Length; i++)
                    {
                        if (i != (typeArray.Length - 1))
                        {
                            whereclause += "Type=" + typeArray[i] + " or ";
                        }
                        else
                        {
                            whereclause += "Type=" + typeArray[i];
                        }
                    }
                }
                foreach (Core.Model.TaskAreas taskarea in list_model)
                {
                    IPolygon pPolygon = CoScheduling.Core.Generic.Convertor.ToPolygon(taskarea.PolygonString);
                    //过滤道路网
                    IGeometry      pGeometry      = pPolygon as IGeometry;
                    ISpatialFilter pSpatialfilter = new SpatialFilterClass();
                    pSpatialfilter.Geometry      = pGeometry;
                    pSpatialfilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                    pSpatialfilter.WhereClause   = whereclause;
                    pSpatialfilter.GeometryField = "Shape";

                    IFeatureCursor FeatureCursor = pFeatureClass.Search(pSpatialfilter, false);
                    IFeature       pFeature      = FeatureCursor.NextFeature();

                    int count = 1;
                    while (pFeature != null)
                    {
                        IPolyline pPolyline = pFeature.ShapeCopy as IPolyline;

                        ITopologicalOperator pTopologicalOperator = pPolyline as ITopologicalOperator;
                        IGeometry            pGeometry1           =
                            pTopologicalOperator.Intersect(pPolygon, esriGeometryDimension.esriGeometry0Dimension) as
                            IGeometry;

                        if (!pGeometry1.IsEmpty)
                        {
                            IPointCollection Pc     = pGeometry1 as IPointCollection;
                            ISymbol          symbol = map.CreateSimpleSymbol(Color.Red, 8, ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle);
                            for (int i = 0; i < Pc.PointCount; i++)
                            {
                                //将交点显示在地图上
                                IPoint point = Pc.get_Point(i);

                                map.AddElement(Pc.get_Point(i), symbol, "Intersect|" + taskarea.ID + "|" + taskarea.PID);

                                //将交点存储到数据库中
                                gatherPoint.LON   = point.X;
                                gatherPoint.LAT   = point.Y;
                                gatherPoint.PID   = taskarea.ID;
                                gatherPoint.PName = "交点(" + count++ + ")";
                                dal.Add(gatherPoint);
                                //pIntersectPoint.Add(Pc.get_Point(i));
                            }
                        }
                        pFeature = FeatureCursor.NextFeature();
                    }
                }
            }
            catch (Exception ex) { throw ex; }
            finally
            {
                TaskAreas = null;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取交点
        /// </summary>
        /// <param name="pMapCtr"></param>
        /// <param name="id"></param>
        public static void getIntersect(ESRI.ArcGIS.Controls.AxMapControl pMapCtr, int id)
        {
            Core.Map.MapHelper map = new Core.Map.MapHelper(pMapCtr);
            Core.Generic.myXML xml = new Core.Generic.myXML(System.Windows.Forms.Application.StartupPath + "\\Setting.xml");
            try
            {
                IFeatureClass           pFeatureClass = null;
                Core.Model.DisaAreaInfo model         = new Core.Model.DisaAreaInfo();
                Core.DAL.DisaAreaInfo   dal0          = new Core.DAL.DisaAreaInfo();


                Core.Model.DisaCrossPoint gatherPoint = new Core.Model.DisaCrossPoint();
                Core.DAL.DisaCrossPoint   dal         = new Core.DAL.DisaCrossPoint();
                //删除以前生成的交点
                dal.Deletes(id);

                map.getNetWorkData(ref pFeatureClass);

                //pIntersectPoint = new List<IPoint>();
                string   Roadtype    = xml.GetElement("FilterPara", "RoadType");
                string[] typeArray   = Roadtype.Split(',');
                string   whereclause = "";
                if (Roadtype != null)
                {
                    for (int i = 0; i < typeArray.Length; i++)
                    {
                        if (i != (typeArray.Length - 1))
                        {
                            whereclause += "Type=" + typeArray[i] + " or ";
                        }
                        else
                        {
                            whereclause += "Type=" + typeArray[i];
                        }
                    }
                }

                //生成灾区影响范围Geometry
                model = dal0.GetModel(id);
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(model.LON, model.LAT);

                ITopologicalOperator pTopoOp   = default(ITopologicalOperator);
                IGeometry            geoBuffer = null;
                pTopoOp   = pPoint as ITopologicalOperator;
                geoBuffer = pTopoOp.Buffer(model.AffectedRadius / Core.Generic.SysEnviriment.LengthPerRad);

                ISpatialFilter pSpatialfilter = new SpatialFilterClass();
                pSpatialfilter.Geometry      = geoBuffer;
                pSpatialfilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelCrosses;
                pSpatialfilter.WhereClause   = whereclause;
                pSpatialfilter.GeometryField = "Shape";

                IFeatureCursor FeatureCursor = pFeatureClass.Search(pSpatialfilter, false);
                IFeature       pFeature      = FeatureCursor.NextFeature();

                int count = 1;
                while (pFeature != null)
                {
                    IPolyline pPolyline = pFeature.ShapeCopy as IPolyline;

                    ITopologicalOperator pTopologicalOperator = pPolyline as ITopologicalOperator;
                    IGeometry            pGeometry1           =
                        pTopologicalOperator.Intersect(geoBuffer as IPolygon, esriGeometryDimension.esriGeometry0Dimension) as
                        IGeometry;

                    if (!pGeometry1.IsEmpty)
                    {
                        IPointCollection Pc     = pGeometry1 as IPointCollection;
                        ISymbol          symbol = map.CreateSimpleSymbol(Color.Red, 8, ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle);
                        for (int i = 0; i < Pc.PointCount; i++)
                        {
                            //将交点显示在地图上
                            IPoint point = Pc.get_Point(i);

                            map.AddElement(Pc.get_Point(i), symbol, "Intersect|" + id);

                            //将交点存储到数据库中
                            gatherPoint.LON   = point.X;
                            gatherPoint.LAT   = point.Y;
                            gatherPoint.PID   = id;
                            gatherPoint.PName = "交点(" + count++ + ")";
                            dal.Add(gatherPoint);
                            //pIntersectPoint.Add(Pc.get_Point(i));
                        }
                    }
                    pFeature = FeatureCursor.NextFeature();
                }
                pMapCtr.ActiveView.Refresh();
            }
            catch (Exception ex) { throw ex; }
            finally
            {
                TaskAreas = null;
            }
        }