async Task <Image> GetKyoshinImage(DateTime time, KyoshinType type, bool isbool) { try { Net.GetJsonFile Network = new Net.GetJsonFile(); return(byteArrayToImage(Network.GetData("http://www.kmoni.bosai.go.jp/data/map_img/" + GetTypeToLURL(type, isbool) + "/" + time.ToString("yyyyMMdd") + "/" + time.ToString("yyyyMMddHHmmss") + "." + GetTypeToURL(type, isbool) + ".gif"))); } catch (Exception e) { Console.WriteLine($"強震モニタのデータをダウンロードする際に例外エラー\n理由 : {e.Message}"); } return(null); }
public DateTime GetLatestUpdateTime()//強震モニタの最新更新時間を取得 { try { Net.GetJsonFile NetworkFile = new Net.GetJsonFile(); LatestKyoshinRoot latest = JsonConvert.DeserializeObject <LatestKyoshinRoot>(NetworkFile.GetJson("http://www.kmoni.bosai.go.jp/webservice/server/pros/latest.json")); DateTime ret = new DateTime(2000, 1, 1, 0, 0, 0); IsLastError = true; if (DateTime.TryParseExact(latest.latest_time, "yyyy/MM/dd HH:mm:ss", null, DateTimeStyles.AssumeLocal, out ret)) { return(ret); } IsLastError = false; LastErrorStatus = "正常に取得できませんでした。(GetLatestUpdateTime関数内)"; return(new DateTime(2000, 1, 1, 0, 0, 0)); } catch { IsLastError = true; LastErrorStatus = "予期しないエラー(GetLatestUpdateTime関数内)"; return(new DateTime(2000, 1, 1, 0, 0, 0)); } }
public Image GetFastImage(DateTime time, KyoshinType type, bool IsBour, bool IsESTShindo, bool IsPSV, bool NoneBG = false)//直接データが欲しい場合 (時間,表示タイプ,地中フラグ,予測震度表示,予測円表示) { try { Net.GetJsonFile Network = new Net.GetJsonFile(); string TypeName = GetTypeToURL(type, IsBour); //ImageオブジェクトのGraphicsオブジェクトを作成する Image BG = new Bitmap(352, 400); Graphics graphics; graphics = Graphics.FromImage(BG); Task <Image> ESTImg = null; Task <Image> RealTimeImg = null; Task <Image> CircleImg = null; if (IsESTShindo) { ESTImg = Task.Run <Image>(() => { return(GetKyoshinImage(time, KyoshinType.EEW_EST)); }); } RealTimeImg = Task.Run <Image>(() => { return(GetKyoshinImage(time, type, IsBour)); }); if (IsPSV) { CircleImg = Task.Run <Image>(() => { return(GetKyoshinImage(time, KyoshinType.EEW_Circle)); }); } if (!NoneBG) { graphics.DrawImage(Properties.Resources.Kyoshin_Basemap, new Point(0, 0)); } else { graphics.Clear(Color.FromArgb(0, 0, 0, 0)); } Image KImage = null; if (IsESTShindo) { ESTImg.Wait(); KImage = ESTImg.Result; if (KImage != null) { EEWShindo = (Image)KImage.Clone(); } else { EEWShindo = null; } if (KImage != null) { graphics.DrawImage(KImage, new Point(0, 0)); KImage.Dispose(); } } KImage = null; if (TypeName != "") { RealTimeImg.Wait(); KImage = RealTimeImg.Result; //KImage = byteArrayToImage(Network.GetData("http://www.kmoni.bosai.go.jp/data/map_img/RealTimeImg/" + TypeName + "/" + time.ToString("yyyyMMdd") + "/" + time.ToString("yyyyMMddHHmmss") + "." + TypeName + ".gif")); if (KImage != null) { graphics.DrawImage(KImage, new Point(0, 0)); KImage.Dispose(); } } KImage = null; if (IsPSV) { CircleImg.Wait(); KImage = CircleImg.Result; //KImage = byteArrayToImage(Network.GetData("http://www.kmoni.bosai.go.jp/data/map_img/PSWaveImg/eew/" + time.ToString("yyyyMMdd") + "/" + time.ToString("yyyyMMddHHmmss") + ".eew.gif")); EEWCircle = KImage; if (KImage != null) { graphics.DrawImage(KImage, new Point(0, 0)); KImage.Dispose(); } } KImage = null; graphics.Dispose(); graphics = null; IsLastError = false; return(BG); } catch { IsLastError = true; LastErrorStatus = "デバッグ操作中にエラー"; return(null); } }