using System; using System.Collections.Generic; using System.Data.OracleClient; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using DevComponents.DotNetBar; using GeoScene.Data; using GeoScene.Globe; namespace Cyberpipe { public partial class FrmBSQStatis : Office2007Form { private Dictionary<string, int> bsq = new Dictionary<string, int>(); private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { this.globeControl1 = globeControl1; this.polygon = polygon; InitializeComponent(); bsq = getBSQNameAndNumMap(polygon); } private void FrmBSQStatis_Load(object sender, EventArgs e) { try { chartStatis.Series.Add("标识器"); chartStatis.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; chartStatis.ChartAreas["ChartArea1"].AxisY.Title = "标识器个数"; chartStatis.ChartAreas["ChartArea1"].AxisX.Interval = 1; chartStatis.Series[0].ChartType = SeriesChartType.Column; chartStatis.Series[0]["DrawingStyle"] = "Cylinder"; chartStatis.Series[0].Points.DataBindXY(bsq.Keys, bsq.Values); for (int m = 0; m < bsq.Values.Count; m++) { if (chartStatis.Series[0].Points[m].YValues[0].ToString().Trim() != "0") { chartStatis.Series[0].Points[m].Label = chartStatis.Series[0].Points[m].YValues[0].ToString(); } } } catch (Exception ex) { } } private Dictionary<string, int> getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { Dictionary<string, int> result = new Dictionary<string, int>(); Dictionary<string, string> codeAndType = new Dictionary<string, string>(); //得到type的种类 for (int i = 0; i < Utility.listPipelineType.Count; i++) { if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") { result.Add(Utility.listPipelineType[i].type, 0); codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); } } return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); } public Dictionary<string, int> getAllAreaMap(Dictionary<string, int> typeAndCount,Dictionary<string, string> codeAndType) { try { OracleConnection conn = OledbHelper.sqlConnection(); conn.Open(); OracleCommand cmd; cmd = new OracleCommand("select 对象类型 from 标识器", conn); OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string str = Convert.ToString(dr["对象类型"]); if (str == null) continue; foreach (string key in codeAndType.Keys) { if (str.Contains(key)) { typeAndCount[codeAndType[key]] += 1; } } } conn.Close(); } catch (Exception ex) { LogHelper.Error(ex.Message); } return typeAndCount; } public Dictionary<string, int> getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary<string, int> typeAndCount, Dictionary<string, string> codeAndType) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); GSOFeatures bsqFs = FeatureStatisticsService.GetLayerFeatures(polygon, layer); if (bsqFs == null || bsqFs.Length <= 0) { LogHelper.Error("标识器图层下的Feature为空!"); return null; } for (int i = 0; i < bsqFs.Length; i++) { string str = bsqFs[i].GetValue("对象类型").ToString(); foreach (string key in codeAndType.Keys) { if (str.Contains(key)) { typeAndCount[codeAndType[key]] += 1; } } } return typeAndCount; } private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.ClearAnalysis(); } } }