/// <summary> /// 根据已有控件重绘 /// </summary> /// <param name="map"></param> /// <param name=""></param> public LegendSymbol(Map.MyMap map, LegendSymbol from, Point location, double resizescale2formal) { ResizeScale = resizescale2formal; SetLegend(map, ResizeScale); Box.Name = "LegendSymbol"; Box.Location = location; }
public LegendSymbol(Map.MyMap map, double scale, Point location) { SetLegend(map, scale); Box.Name = "LegendSymbol"; ResizeScale = scale; Box.Location = location; }
public LegendSymbol(Map.MyMap map, Point location) { Box.Name = "LegendSymbol"; SetLegend(map, 0.8); ResizeScale = 1; Box.Location = location; }
/// <summary> /// 构造函数 /// </summary> /// <param name="newmap">地图文件</param> /// <param name="centerpos">中心点位</param> /// <param name="ratio">比例尺</param> /// <param name="scaleindex">比例尺索引</param> internal CGM(Map.MyMap newmap, PointF centerpos, double ratio, int scaleindex) { _map = newmap; //TODO坐标系的记录 _centerpos = centerpos; _ratio = ratio; _scaleindex = scaleindex; }
public Layout(Map.MyMap map, double datascale, Bitmap mapbit, Size size, Point location) { boxscale = 1; mapbitmap = mapbit; InitializeComponent(); thismap = map; this.Width = size.Width; this.Height = size.Height; this.Location = location; InitializePB_background(); UpdateMapBackground(); real2map = datascale * ratio2screen; Update(); }
/// <summary> /// 绘制图例 /// </summary> /// <param name="map"></param> /// <param name="scale"></param> private void SetLegend(Map.MyMap map, double resizescale) { int layercount = map.LayerNum; int dis = (int)(resizescale * 10); int layerdis = (int)(resizescale * 20); int symbolcount = 0; int visiblelayercount = 0; List <int> visiblelayers = new List <int>(); Box.BackColor = Color.Transparent; for (int i = 0; i < layercount; i++) { if (map.Layers[i].Visible == true) { visiblelayercount++; symbolcount += map.Layers[i].Renderer.SymbolCount; visiblelayers.Add(i); } } Bitmap newbitmap = new Bitmap((int)(resizescale * 150), (int)(resizescale * (symbolcount * dis + (visiblelayercount + 2) * layerdis + (symbolcount + visiblelayercount + 1) * 24))); Graphics image = Graphics.FromImage(newbitmap); Point start = new Point(0, 0); image.DrawString("图例", new Font("黑体", (int)(resizescale * 15)), Brushes.Black, start); start.Y = (layerdis + (int)(resizescale * 15)); for (int i = 0; i < visiblelayercount; i++) { start = LegendOfLayer(image, map.Layers[visiblelayers[i]], start, resizescale); } Box.AutoSize = false; Box.Size = new Size((int)(newbitmap.Width * resizescale), (int)(newbitmap.Height * resizescale)); // Bitmap sbit = new Bitmap(newbitmap, new Size((int)(newbitmap.Width * scale), (int)(newbitmap.Height * scale))); newbitmap.MakeTransparent(Color.White); Box.Image = newbitmap; Box.Left = 100; Box.Top = 30; }
public void Open() { FileStream fs = new FileStream(_filepath, FileMode.Open); StreamReader sr = new StreamReader(fs); string line = sr.ReadLine(); string[] words = line.Split(' '); _Geocoordinate = Map.MyCoordinates.WGS1984; //由于不存在null选项 _Procoordinate = Map.MyCoordinates.WGS1984; //由于不存在null选项 //记录地理坐标系 switch (words[1]) { case "WGS1984": _Geocoordinate = Map.MyCoordinates.WGS1984; break; } //记录投影坐标系 switch (words[2]) { case "WGS1984": _Geocoordinate = Map.MyCoordinates.WGS1984; break; } //生成地图 _map = new Map.MyMap(words[0], _Geocoordinate, Convert.ToDouble(words[3])); _ratio = Convert.ToDouble(words[3]); _scaleindex = Convert.ToInt32(words[4]); //显示中心点位 _centerpos = new PointF((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6])); //图层数量 int layercount = Convert.ToInt32(words[7]); for (int i = 0; i < layercount; i++) { string layerpath = sr.ReadLine(); Map.MyLayer newlayer = null; if (Path.GetExtension(layerpath) == ".shp") { //TODO先只可读SHP Shapefile newshp = new Shapefile(layerpath); newlayer = new MyLayer(newshp); } else { CosmosGisVector newcgv = new CosmosGisVector(layerpath); newlayer = new MyLayer(newcgv); } newlayer.FilePath = layerpath; //设置是否可见 string visible = sr.ReadLine(); if (visible == "True") { newlayer.Visible = true; } else { newlayer.Visible = false; } //获取渲染方式 string layerline = sr.ReadLine(); RendererType newrendertyppe = new GetType().RendererType(layerline.Split(' ')[0]); newlayer.rendertype = newrendertyppe; switch (newrendertyppe) { //唯一值渲染 case RendererType.UniqueValueRenderer: string field_uvr = layerline.Split(' ')[1]; //TODO 获得属性唯一值 DataTable dt_uvr = newlayer.SpaceData.Property.SqlQuery("Select Distinct " + field_uvr + " From " + newlayer.LayerName); List <string> values_uvr = new List <string>(); for (int j = 0; j < dt_uvr.Rows.Count; j++) { values_uvr.Add(dt_uvr.Rows[j][field_uvr].ToString()); } //List<string> values = new List<string>() { "1", "2", "3", "3" ,"3","3","7"}; newlayer.Renderer = new UniqueValueRenderer(newlayer.DataType, field_uvr, values_uvr); break; //分级渲染 case RendererType.ClassBreakRenderer: string field_cbr = layerline.Split(' ')[1]; DataTable dt_cbr = newlayer.SpaceData.Property.SqlQuery("Select Distinct " + field_cbr + " From " + newlayer.LayerName); List <double> values_cbr = new List <double>(); for (int j = 0; j < dt_cbr.Rows.Count; j++) { values_cbr.Add(Convert.ToDouble(dt_cbr.Rows[j][field_cbr])); } //List<double> breaks = new List<double>() { 1, 2, 3 }; newlayer.Renderer = new ClassBreakRenderer(newlayer.DataType, field_cbr, values_cbr); break; //简单渲染 default: newlayer.Renderer = new SimpleRenderer(newlayer.DataType); break; } //判断是否有注记信息 string hastext = sr.ReadLine(); if (hastext == "True") { newlayer.HasText = true; newlayer.Textrender = new TextRenderer(sr.ReadLine()); } else { newlayer.HasText = false; } _map.AddLayer(newlayer); } sr.Close(); fs.Close(); }