private GraphicsLayer GenerateGraphicLayer(HydrologicEntity entity) { var graphics = new List <Graphic>(); if (entity != null && entity.Items != null) { foreach (var item in entity.Items) { if (!double.IsNaN(item.Longitude) && !double.IsNaN(item.Latitude) && item.Wl1 >= 0) { var graphic = GenerateGraphic(item); graphics.Add(graphic); } } } var layer = new GraphicsLayer { GraphicsSource = graphics }; return(layer); }
private HydrologicEntity FakeDataSource() { var entity = new HydrologicEntity(); entity.Items = new List <HydrologicEntityItem>(); var item = new HydrologicEntityItem { Latitude = 44.081, Longitude = 130.176, Wl1 = 10, L = 11, Name = "库威", Stationid = "00100400", Recordid = 1, Type = "河道站", Q = 10, Time = DateTime.Now }; entity.Items.Add(item); item = new HydrologicEntityItem { Latitude = 50.224, Longitude = 119.53, Wl1 = 18, L = 11, Name = "库威", Stationid = "00100400", Recordid = 1, Type = "水库站", Q = 10, Time = DateTime.Now }; entity.Items.Add(item); item = new HydrologicEntityItem { Latitude = 45.639, Longitude = 130.069, Wl1 = 10, L = 11, Name = "库威", Stationid = "00100400", Recordid = 1, Type = "河道站", Q = 10, Time = DateTime.Now }; entity.Items.Add(item); item = new HydrologicEntityItem { Latitude = 43.937, Longitude = 119.449, Wl1 = 15, L = 11, Name = "库威", Stationid = "00100400", Recordid = 1, Type = "河道站", Q = 10, Time = DateTime.Now }; entity.Items.Add(item); return(entity); }
public static List <RiverWarningRecord> GetRiverWarningInfo() { List <RiverWarningRecord> infoList = new List <RiverWarningRecord>(); List <RiverWarningRecord> rtnList = new List <RiverWarningRecord>(); HydrologicReader dbReader = new HydrologicReader(); HydrologicEntity entity = dbReader.RetrieveEntity(DateTime.Now.AddDays(-1), DateTime.Now, "河道站"); //获取最近1天河道站最新水情 foreach (var item in entity.Items) { if ((item.L - item.Wl1) > -0.5) //超过监测门限-0.5 { RiverWarningRecord record = new RiverWarningRecord(); if (item.Basin != null) { int index = item.Basin.IndexOf("流域"); record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index); } else { record.Basin = item.Basin; } if (item.L > item.Wl1) { record.IsBeyond = true; } else { record.IsBeyond = false; } record.Level = item.L; record.Name = item.Name; record.OverWarningLevel = item.L - item.Wl1; record.Province = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名 record.River = item.River; record.Stationid = item.Stationid; record.Time = item.Time; record.WarningLevel = item.Wl1; int tr = dbReader.ComparedWithRecent(item, DateTime.Now.AddDays(-2), DateTime.Now); //最近2天内的最新趋势 if (tr > 0) { record.ComparedBefore = Trend.Rise; } else if (tr == 0) { record.ComparedBefore = Trend.Hold; } else { record.ComparedBefore = Trend.Fall; } if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0)) { infoList.Add(record); } } } var groupedList = from info in infoList group info by info.Basin into g select g; /*infoList = new List<RiverWarningRecord>(); * foreach(var g in groupedList) * { * foreach(var x in g) * { * infoList.Add(x); * } * }*/ foreach (var group in groupedList) { foreach (var item in group) { rtnList.Add(item); } } return(rtnList); }
public static List <ReservoirWarningRecord> GetKeyReservoirWarningInfo() { List <ReservoirWarningRecord> infoList = new List <ReservoirWarningRecord>(); HydrologicReader dbReader = new HydrologicReader(); HydrologicEntity entity = dbReader.RetrieveEntity(DateTime.Now.AddDays(-1), DateTime.Now, "水库站"); //获取最近1天水库站最新水情 foreach (var item in entity.Items) { if ((item.L - item.Wl1) > -20 && item.Issign == true) //超过监测门限-20且为重点站 { ReservoirWarningRecord record = new ReservoirWarningRecord(); if (item.Basin != null) { int index = item.Basin.IndexOf("流域"); record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index); } else { record.Basin = item.Basin; } if (item.L > item.Wl1) { record.IsBeyond = true; } else { record.IsBeyond = false; } record.Level = item.L; record.Name = item.Name; record.OverWarningLevel = item.L - item.Wl1; record.Province = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名 record.River = item.River; record.Stationid = item.Stationid; record.Time = item.Time; record.WarningLevel = item.Wl1; int tr = dbReader.ComparedWithRecent(item, DateTime.Now.AddDays(-2), DateTime.Now); //最近2天内的最新趋势 if (tr > 0) { record.ComparedBefore = Trend.Rise; } else if (tr == 0) { record.ComparedBefore = Trend.Hold; } else { record.ComparedBefore = Trend.Fall; } if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0)) { infoList.Add(record); } } } return(infoList); }