Ejemplo n.º 1
0
        public static void HandleTextData(string filename, XRITHeader header)
        {
            if (header.PrimaryHeader.FileType == FileTypeCode.TEXT)
            {
                string basedir = FileHandler.FinalFileFolder;
                basedir = Path.Combine(basedir, TextFolder);

                try {
                    UIConsole.Log($"New {header.ToNameString()}");
                    if (!Directory.Exists(basedir))
                    {
                        Directory.CreateDirectory(basedir);
                    }
                    TextHandler.Handler.HandleFile(filename, basedir);
                    File.Delete(filename);
                } catch (Exception e) {
                    UIConsole.Warn($"Failed to parse Weather Data Image at {Path.GetFileName(filename)}: {e}");
                }
            }
            else
            {
                FileHandler.DefaultHandler(filename, header);
            }
        }
Ejemplo n.º 2
0
        public static void HandleWeatherData(string filename, XRITHeader header)
        {
            if (header.Filename.Contains("KWIN"))
            {
                // HRIT EMWIN wrongly has product id of weather data
                if (FileHandler.SkipEMWIN)
                {
                    try {
                        File.Delete(filename);
                    } catch (Exception) {
                        // Do nothing, file doesn't exists
                    }
                    return;
                }
                string fz = null;
                switch (header.Compression)
                {
                case CompressionType.ZIP:
                    fz = DumpFile(filename, header, "zip");
                    break;

                case CompressionType.GIF:
                    fz = DumpFile(filename, header, "gif");
                    break;

                case CompressionType.JPEG:
                    fz = DumpFile(filename, header, "jpg");
                    break;

                case CompressionType.NO_COMPRESSION:
                    fz = DumpFile(filename, header, "txt");
                    break;

                default:
                    fz = DumpFile(filename, header, "bin");
                    break;
                }
                if (fz != null)
                {
                    try {
                        File.Delete(fz);
                    } catch (Exception) {
                        // Do nothing, file doesn't exists
                    }
                }
            }
            else if (header.PrimaryHeader.FileType == FileTypeCode.IMAGE)
            {
                string basedir = FileHandler.FinalFileFolder;
                if (header.Product.ID == (int)NOAAProductID.OTHER_SATELLITES_1 || header.Product.ID == (int)NOAAProductID.OTHER_SATELLITES_2)
                {
                    basedir = Path.Combine(basedir, OtherSatellitesFolder);
                }
                else
                {
                    basedir = Path.Combine(basedir, WeatherDataFolder);
                }

                try {
                    UIConsole.Log($"New {header.ToNameString()}");
                    //UIConsole.Log($"New Weather Data - {header.SubProduct.Name}");
                    if (!Directory.Exists(basedir))
                    {
                        Directory.CreateDirectory(basedir);
                    }
                    ImageHandler.Handler.HandleFile(filename, basedir);
                    File.Delete(filename);
                } catch (Exception e) {
                    UIConsole.Warn($"Failed to parse Weather Data Image at {Path.GetFileName(filename)}: {e}");
                }
            }
            else if (header.PrimaryHeader.FileType == FileTypeCode.TEXT)
            {
                string fz = DumpFile(filename, header, "txt");

                if (fz != null)
                {
                    try {
                        File.Delete(fz);
                    } catch (Exception) {
                        // Do nothing, file doesn't exists
                    }
                }
            }
            else
            {
                FileHandler.DefaultHandler(filename, header);
            }
        }