//统计最低温 private cityTeme getMinTemp() { cityTeme CT2 = new cityTeme("低温城市", 0.0); IFeatureLayer featLayer = (IFeatureLayer)Utilities.GetLayerByName("省市", axMapControl1.Map); IFeatureClass featClass = featLayer.FeatureClass; IDataStatistics maxTemp = new DataStatistics(); IDataStatistics minTemp = new DataStatistics(); IFeatureCursor featCursor; IQueryFilter queryfilter = new QueryFilterClass(); featCursor = featClass.Search(null, false); ICursor cursor = (ICursor)featCursor; minTemp.Cursor = cursor; minTemp.Field = "LowTemperature"; IStatisticsResults MINtemp; MINtemp = minTemp.Statistics; CT2.Teme = MINtemp.Minimum; String minWhereClause = "[LowTemperature] = " + CT2.Teme; queryfilter.WhereClause = minWhereClause; featCursor = featClass.Search(queryfilter, false); IFeature MINpFeature = featCursor.NextFeature(); if (MINpFeature != null) { int index2 = featClass.FindField("NAME"); CT2.City = MINpFeature.get_Value(index2).ToString(); } return(CT2); }
private void Form1_Load(object sender, EventArgs e) { _mapPath = Application.StartupPath + "\\Map\\Weather.Mxd"; axMapControl1.LoadMxFile(_mapPath); string[] provinces = new string[] { "全国", "黑龙江省", "内蒙古自治区", "新疆维吾尔自治区", "吉林省", "甘肃省", "河北省", "北京市", "山西省", "天津市", "陕西省", "宁夏回族自治区", "青海省", "辽宁省", "山东省", "西藏自治区", "河南省", "江苏省", "安徽省", "四川省", "湖北省", "重庆市", "上海市", "浙江省", "湖南省", "江西省", "云南省", "贵州省", "广西壮族自治区", "福建省", "台湾省", "海南省", "广东省", "香港特别行政区", "澳门" }; ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop); foreach (string str in provinces) { comboBox1.Items.Add(str); } comboBox1.SelectedIndex = 0; QueryTool qryTool = new QueryTool(); axToolbarControl1.AddItem(qryTool, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); qryTool.LabelEvent += new QueryTool.LabelEventHandler(qryTool_LabelEvent); RemoveLabesCmd delete = new RemoveLabesCmd(); axToolbarControl1.AddItem(delete, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); delete.LabelEvent += new RemoveLabesCmd.LabelEventHandler(revLabels_RemoveLabelsEvent); ZoomtoProvince(provinces[0]); InitialWeather(); AddField(); cityTeme cityteme1 = getMaxTemp(); cityTeme cityteme2 = getMinTemp(); label3.Text = "明日气温最高的城市:" + cityteme1.City + "\n温度为:" + cityteme1.Teme + "℃"; label4.Text = "明日气温最低的城市:" + cityteme2.City + "\n温度为:" + cityteme2.Teme + "℃"; }
//统计最低温 private cityTeme getMinTemp() { cityTeme CT2 = new cityTeme("低温城市", 0.0); IFeatureLayer featLayer = (IFeatureLayer)Utilities.GetLayerByName("省市", axMapControl1.Map); IFeatureClass featClass = featLayer.FeatureClass; IDataStatistics maxTemp = new DataStatistics(); IDataStatistics minTemp = new DataStatistics(); IFeatureCursor featCursor; IQueryFilter queryfilter = new QueryFilterClass(); featCursor = featClass.Search(null, false); ICursor cursor = (ICursor)featCursor; minTemp.Cursor = cursor; minTemp.Field = "LowTemperature"; IStatisticsResults MINtemp; MINtemp = minTemp.Statistics; CT2.Teme = MINtemp.Minimum; String minWhereClause = "[LowTemperature] = " + CT2.Teme; queryfilter.WhereClause = minWhereClause; featCursor = featClass.Search(queryfilter, false); IFeature MINpFeature = featCursor.NextFeature(); if (MINpFeature != null) { int index2 = featClass.FindField("NAME"); CT2.City = MINpFeature.get_Value(index2).ToString(); } return CT2; }