public ActionResult GetGuangDongAirQualityPNG() { List <double> t = new List <double>(), x = new List <double>(), y = new List <double>(); double[] extent = new double[] { 109.46, 20.05, 117.48, 25.63 }; string fileName; using (DataCenterServiceClient client = new DataCenterServiceClient()) { StationHourData[] data = client.GetStationHourDataListFromHistoryByTime("GDAEIB", "2019!@GD", new DateTime(2020, 6, 23, 17, 0, 0)); data = data.Where(o => o.AQI != "—").ToArray(); double[] tExtent = new double[] { 106.79, 18.19, 120.15, 27.49 }; foreach (StationHourData item in data) { double xi = double.Parse(item.Longitude), yi = double.Parse(item.Latitude); if (xi >= tExtent[0] && xi <= tExtent[2] && yi >= tExtent[1] && yi <= tExtent[3]) { double ti = double.Parse(item.AQI); t.Add(ti); x.Add(xi); y.Add(yi); } } fileName = string.Format("D:\\440000_{0}.png", data.First().TimePoint.ToString("yyyyMMddHH")); } double resolution = (extent[2] - extent[0]) / 1023; BitmapHelper.DrawGridByKriging(t.ToArray(), x.ToArray(), y.ToArray(), extent, resolution, fileName); return(Content("Done")); }
public ActionResult TestIDW(DateTime time) { IDW idw; Kriging kriging; using (DataCenterServiceClient client = new DataCenterServiceClient()) { StationHourData[] data = client.GetStationHourDataListFromHistoryByTime("GDAEIB", "2019!@GD", time); data = data.Where(o => o.AQI != "—").ToArray(); double[] X = new double[data.Length], Y = new double[data.Length], T = new double[data.Length]; for (int i = 0; i < data.Length; i++) { StationHourData item = data[i]; double x = double.Parse(item.Longitude), y = double.Parse(item.Latitude); double t = double.Parse(item.AQI); X[i] = x; Y[i] = y; T[i] = t; } idw = new IDW(X, Y, T); kriging = new Kriging(X, Y, T); } double temp = idw.Predict(112, 36); kriging.Train(KrigingModel.Exponential, 0, 100); temp = kriging.Predict(112, 36); return(Content(temp.ToString())); }
public ActionResult GetStationHourData() { using (DataCenterServiceClient client = new DataCenterServiceClient()) { StationHourData[] stationHourData = client.GetStationHourDataListFromHistoryByTime("normal", "normal!@123", new DateTime(2020, 6, 11, 10, 0, 0)); return(Json(stationHourData, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetStationHourData(DateTime timePoint) { using (DataCenterServiceClient client = new DataCenterServiceClient()) { StationHourData[] data = client.GetStationHourDataListFromHistoryByTime("GDAEIB", "2019!@GD", timePoint); data = data.Where(o => o.AQI != "—").ToArray(); return(Json(data, JsonRequestBehavior.AllowGet)); } }