Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 批量加载任务区 根据任务区所属的灾情id加载
        /// </summary>
        /// <param name="pMapCtr"></param>
        /// <param name="id"></param>
        public static void LoadTaskAreas(ESRI.ArcGIS.Controls.AxMapControl pMapCtr, int id)
        {
            //读取并图上显示任务区任务区信息
            Core.Map.MapHelper map = new Core.Map.MapHelper(pMapCtr);
            map.ClearAllElement();
            //灾区
            Core.DAL.TaskAreas t_dal = new Core.DAL.TaskAreas();
            list_model = new List <Core.Model.TaskAreas>();
            //交点
            Core.DAL.DisaCrossPoint          dal    = new Core.DAL.DisaCrossPoint();
            List <Core.Model.DisaCrossPoint> models = new List <Core.Model.DisaCrossPoint>();

            //集结点
            Core.DAL.DisaGatherPoint          g_dal    = new Core.DAL.DisaGatherPoint();
            List <Core.Model.DisaGatherPoint> g_models = new List <Core.Model.DisaGatherPoint>();

            IEnvelope envelope = null;

            try
            {
                list_model = t_dal.GetList(id);
                if (list_model.Count == 0)
                {
                    MessageBox.Show("该灾区尚未生成任务区!");
                    return;
                }
                //加载
                foreach (Core.Model.TaskAreas t_model in list_model)
                {
                    LoadTaskArea(map, t_model);
                    IPolygon pPolygon = Core.Generic.Convertor.ToPolygon(t_model.PolygonString);
                    //获取多个Polygon的Envelope外包矩形
                    if (envelope == null)
                    {
                        envelope = pPolygon.Envelope;
                    }
                    else
                    {
                        envelope.Union(pPolygon.Envelope);
                    }

                    //models = dal.GetList(t_model.ID, id);
                    //foreach (Core.Model.DisaCrossPoint model in models)
                    //{
                    //    LoadCrossPoint(map, model);
                    //}

                    //g_models = g_dal.GetList(t_model.ID, id);
                    //foreach (Core.Model.DisaGatherPoint model in g_models)
                    //{
                    //    LoadGatherPoint(map, model);
                    //}
                }

                if (!envelope.IsEmpty)
                {
                    envelope.Expand(1.1, 1.1, true);
                }
                pMapCtr.Extent = envelope;
                pMapCtr.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误:" + ex);
            }
        }