private bool DrawMonitorMap() { try { IFeatureSet fsPoints = new FeatureSet(); fsPoints.DataTable.Columns.Add("Name"); fsPoints.DataTable.Columns.Add("Description"); fsPoints.DataTable.Columns.Add("Longitude"); fsPoints.DataTable.Columns.Add("Latitude"); string[] tmps = new string[_lstMonitorPoints[0].dicMetricValues.Count]; _lstMonitorPoints[0].dicMetricValues.Keys.CopyTo(tmps, 0); for (int i = 0; i < tmps.Length; i++) { fsPoints.DataTable.Columns.Add(tmps[i]); } MonitorValue mv = null; Feature feature = null; List <Coordinate> lstCoordinate = new List <Coordinate>(); List <double> fsInter = new List <double>(); mainMap.Layers.Clear(); mainMap.ProjectionModeReproject = ActionMode.Never; mainMap.ProjectionModeDefine = ActionMode.Never; mainMap.Layers.Clear(); if (File.Exists(this._gridShapeFile)) { mainMap.Layers.Add(this._gridShapeFile); } if (this._lstMonitorPoints != null && this.LstMonitorPoints.Count > 0) { PolygonScheme myScheme = new PolygonScheme(); PolygonCategory pcin = new PolygonCategory(); pcin.Symbolizer.SetFillColor(Color.Red); myScheme.Categories.Add(pcin); DotSpatial.Topology.Point point; for (int i = 0; i < LstMonitorPoints.Count; i++) { mv = LstMonitorPoints[i]; point = new DotSpatial.Topology.Point(mv.Longitude, mv.Latitude); feature = new Feature(point); fsPoints.AddFeature(feature); fsPoints.DataTable.Rows[i]["Name"] = mv.MonitorName; fsPoints.DataTable.Rows[i]["Latitude"] = mv.Latitude; fsPoints.DataTable.Rows[i]["Longitude"] = mv.Longitude; for (int col = 0; col < tmps.Length; col++) { fsPoints.DataTable.Rows[i][tmps[col]] = mv.dicMetricValues[tmps[col]]; } } mainMap.Layers.Add(fsPoints); mainMap.Layers[0].LegendText = "Air quality grid"; mainMap.Layers[1].LegendText = "Monitors"; } PolygonLayer player = mainMap.Layers[0] as PolygonLayer; float f = 0.9f; Color c = Color.Transparent; PolygonSymbolizer Transparent = new PolygonSymbolizer(c); Transparent.OutlineSymbolizer = new LineSymbolizer(Color.DarkBlue, 1); player.Symbolizer = Transparent; LayerObject = null; return(true); } catch (Exception ex) { Logger.LogError(ex); return(false); } }
private void MonitorRollbackSettings2_Load(object sender, EventArgs e) { try { if (CommonClass.GBenMAPGrid == null) { return; } mainMap.ProjectionModeReproject = ActionMode.Never; mainMap.ProjectionModeDefine = ActionMode.Never; if (_monitorRollbackLine.RollbackGrid is ShapefileGrid) { if (File.Exists(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as ShapefileGrid).ShapefileName + ".shp")) { mainMap.Layers.Add(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as ShapefileGrid).ShapefileName + ".shp"); } } else if (_monitorRollbackLine.RollbackGrid is RegularGrid) { if (File.Exists(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as RegularGrid).ShapefileName + ".shp")) { mainMap.Layers.Add(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as RegularGrid).ShapefileName + ".shp"); } } PolygonLayer playerRegion = mainMap.Layers[mainMap.Layers.Count - 1] as PolygonLayer; playerRegion.DataSet.DataTable.Columns.Add("MyColorIndex", typeof(int)); for (int i = 0; i < playerRegion.DataSet.DataTable.Rows.Count; i++) { playerRegion.DataSet.DataTable.Rows[i]["MyColorIndex"] = i; dicMyColorIndex.Add(Convert.ToInt32(playerRegion.DataSet.DataTable.Rows[i]["COL"]).ToString() + "," + Convert.ToInt32(playerRegion.DataSet.DataTable.Rows[i]["ROW"]).ToString(), i); } Color cRegion = Color.Transparent; PolygonSymbolizer TransparentRegion = new PolygonSymbolizer(cRegion); TransparentRegion.OutlineSymbolizer = new LineSymbolizer(Color.Black, 1); playerRegion.Symbolizer = TransparentRegion; lstMonitorValues = DataSourceCommonClass.GetMonitorData(_monitorRollbackLine.GridType, _monitorRollbackLine.Pollutant, _monitorRollbackLine); IFeatureSet fsPoints = new FeatureSet(); MonitorValue mv = null; Feature feature = null; List <DotSpatial.Topology.Coordinate> lstCoordinate = new List <DotSpatial.Topology.Coordinate>(); List <double> fsInter = new List <double>(); if (lstMonitorValues != null && lstMonitorValues.Count > 0) { PolygonScheme myScheme = new PolygonScheme(); PolygonCategory pcin = new PolygonCategory(); pcin.Symbolizer.SetFillColor(Color.Red); myScheme.Categories.Add(pcin); DotSpatial.Topology.Point point; for (int i = 0; i < lstMonitorValues.Count; i++) { mv = lstMonitorValues[i]; point = new DotSpatial.Topology.Point(mv.Longitude, mv.Latitude); feature = new Feature(point); fsPoints.AddFeature(feature); } mainMap.Layers.Add(fsPoints); } } catch (Exception ex) { Logger.LogError(ex); } }
public DrawPolygonTask(Workspace.Workspace workspace, PolygonLayer layer, MapExtent extent, int width, int height) : base(workspace, layer, extent, width, height) { }