コード例 #1
0
 public static SurfacePressureImage[] GetSurfacePressureImages(SurfacePressureCharts chart)
 {
     try
     {
         var webRequest = (HttpWebRequest)WebRequest.Create(GenerateUrl(chart));
         webRequest.UserAgent = Common.UserAgent;
         webRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
         webRequest.AllowAutoRedirect      = true;
         SurfacePressureImage[] images;
         using (var webResponse = (HttpWebResponse)webRequest.GetResponse())
         {
             var stream = webResponse.GetResponseStream();
             images = SurfacePressureImage.GetSurfacePressureImages(stream);
         }
         return(images);
     }
     catch (Exception e)
     {
         if (e.GetType() != typeof(WebException))
         {
             throw new Exception("An error occured while retreiving the requested surface pressure images.", e);
         }
         var webE = (WebException)e;
         if (((HttpWebResponse)webE.Response).StatusCode == HttpStatusCode.NotImplemented)
         {
             throw new Exception("The requested surface pressure format does not exist.", e);
         }
         throw new Exception("An error occured while retreiving the requested surface pressure images.", e);
     }
 }
コード例 #2
0
        private static string SurfacePressureChartToCode(SurfacePressureCharts chart)
        {
            switch (chart)
            {
            case SurfacePressureCharts.TasmanSeaCombined:
                return("tasmanSeaCombinedCharts");

            case SurfacePressureCharts.SouthWestPacificCombined:
                return("swPacificChartsCombined");

            case SurfacePressureCharts.SouthWestPacificLowBandwidth:
                return("swPacificCharts_LowBandwidth");

            default:
                goto case SurfacePressureCharts.SouthWestPacificLowBandwidth;
            }
        }
コード例 #3
0
 private static string GenerateUrl(SurfacePressureCharts chart)
 {
     return(Common.BaseUrl + "/publicData/" + SurfacePressureChartToCode(chart));
 }