/// <summary> /// 加载单个任务区 根据任务区实体类加载 /// </summary> /// <param name="map"></param> /// <param name="model"></param> public static void LoadSatelliteTaskArea(Core.Map.MapHelper map, Core.Model.TASK_LAYOUT_LIST model) { if (model.TASKTYPE == 0) { ISymbol symbol = map.CreateSimpleSymbol(Color.OrangeRed, 4, esriSimpleMarkerStyle.esriSMSCross); IPoint pPoint = new PointClass(); pPoint.PutCoords(Convert.ToDouble(model.LON), Convert.ToDouble(model.LAT)); //SatelliteResaultAreas = new List<IPolygon>(); //SatelliteResaultAreas.Add(pPolygon); //添加任务区点 map.AddElement(pPoint, symbol, "TaskArea"); map.AddTextElement(pPoint, getTextElement(model.TASKNAME), "TaskAreaMark"); } else { ISymbol symbol = map.CreateSimpleFillSymbol(Color.OrangeRed, 4, esriSimpleFillStyle.esriSFSHollow); string[] points = model.AREASTRING.Split(' '); string polygon = ""; for (int i = 0; i < points.Length - 1; i += 2) { polygon += points[i + 1] + "," + points[i] + ";"; } IPolygon pPolygon = Core.Generic.Convertor.ToPolygon(polygon); SatelliteResaultAreas = new List <IPolygon>(); SatelliteResaultAreas.Add(pPolygon); //添加任务区多边形 map.AddElement(pPolygon, symbol, "TaskArea"); map.AddTextElement(pPolygon, getTextElement(model.TASKNAME), "TaskAreaMark"); } }
/// <summary> /// 加载集结点 /// </summary> /// <param name="map"></param> /// <param name="model"></param> public static void LoadGatherPoint(Core.Map.MapHelper map, Core.Model.DisaGatherPoint model) { ISymbol symbol = map.CreateSimpleSymbol(Color.Blue, 8, ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle); IPoint pPoint = new PointClass(); pPoint.PutCoords(model.LON, model.LAT); map.AddElement(pPoint, symbol, "GatherPoint|" + model.PID); }
/// <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; } }
/// <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; } }