Exemple #1
0
        private static object[] WriteFiles(MosaicOutputArg arg)
        {
            if (arg == null || arg.OutputFiles == null || arg.OutputFiles.Length == 0)
            {
                return(null);
            }
            List <XElement> files = new List <XElement>();

            for (int i = 0; i < arg.OutputFiles.Length; i++)
            {
                OutFileArg file = arg.OutputFiles[i];
                files.Add(new XElement("File",
                                       new XElement("OutputFilename", file.OutputFilename),
                                       new XElement("Thumbnail", file.Thumbnail),
                                       new XElement("ExtendFiles", file.ExtendFiles),
                                       new XElement("Envelope",
                                                    new XAttribute("name", file.Envelope.Name),
                                                    new XAttribute("minx", file.Envelope.PrjEnvelope.MinX),
                                                    new XAttribute("maxx", file.Envelope.PrjEnvelope.MaxX),
                                                    new XAttribute("miny", file.Envelope.PrjEnvelope.MinY),
                                                    new XAttribute("maxy", file.Envelope.PrjEnvelope.MaxY)),
                                       new XElement("ResolutionX", file.ResolutionX),
                                       new XElement("ResolutionY", file.ResolutionY),
                                       new XElement("Length", file.Length)));
            }
            return(files.ToArray());
        }
Exemple #2
0
        public static void WriteXml(MosaicOutputArg arg, string argXml)
        {
            XElement xml = new XElement("xml",
                                        new XElement("Satellite", arg.Satellite),
                                        new XElement("Sensor", arg.Sensor),
                                        new XElement("Level", arg.Level),
                                        new XElement("ProjectionIdentify", arg.ProjectionIdentify),
                                        new XElement("ObservationDate", arg.ObservationDate),
                                        new XElement("Station", arg.Station),
                                        new XElement("DayOrNight", arg.DayOrNight),
                                        new XElement("OutputFiles",
                                                     WriteFiles(arg)),
                                        new XElement("log",
                                                     new XElement("loglevel", arg.LogLevel),
                                                     new XElement("loginfo", arg.LogInfo)));

            xml.Save(argXml);
        }
Exemple #3
0
        private void TryMosaicFile(InputArg inArg, IRasterDataProvider fileRaster, DataIdentify dataIdentify, string dayOrNight)
        {
            if (inArg.MosaicInputArg == null || string.IsNullOrWhiteSpace(inArg.MosaicInputArg.OutputDir) || inArg.MosaicInputArg.Envelope == null)
            {
                return;
            }
            //if (!Day.Contains(dayOrNight))
            //{
            //    Console.WriteLine("非白天数据,不执行拼接");
            //    return;
            //}
            MosaicInputArg  mosaicInputArg     = inArg.MosaicInputArg;
            string          projectionIdentify = inArg.ProjectionIdentify;
            string          station            = ParseStation(inArg.InputFilename);
            MosaicOutputArg outArg             = new MosaicOutputArg();

            outArg.Satellite          = dataIdentify.Satellite;
            outArg.Sensor             = dataIdentify.Sensor;
            outArg.Level              = "L1";
            outArg.ProjectionIdentify = projectionIdentify;
            outArg.ObservationDate    = dataIdentify.OrbitDateTime.ToString("yyyyMMdd");
            outArg.Station            = station;
            outArg.DayOrNight         = dayOrNight;
            IRasterDataProvider mosaicFileRaster = null;

            try
            {
                string mosaicFilename = CreateMosaicFilename(inArg, dataIdentify, projectionIdentify, fileRaster.ResolutionX, station, dayOrNight);
                mosaicFilename = Path.Combine(mosaicInputArg.OutputDir, mosaicFilename);
                Mosaic mosaic = new Mosaic(inArg, fileRaster, new Action <int, string>(OnProgress));
                mosaicFileRaster = mosaic.MosaicToFile(mosaicFilename);
                OutFileArg fileArg = new OutFileArg();
                if (mosaicFileRaster != null)
                {
                    OnProgress(0, "生成缩略图");
                    string overViewFilename = OverViewHelper.OverView(mosaicFileRaster, 1024);
                    OnProgress(100, "完成缩略图");
                    fileArg.Envelope       = mosaicInputArg.Envelope;
                    fileArg.ResolutionX    = mosaicFileRaster.ResolutionX.ToString();
                    fileArg.ResolutionY    = mosaicFileRaster.ResolutionY.ToString();
                    fileArg.OutputFilename = Path.GetFileName(mosaicFileRaster.fileName);
                    fileArg.Thumbnail      = (string.IsNullOrWhiteSpace(overViewFilename) ? "" : Path.GetFileName(overViewFilename));
                    fileArg.ExtendFiles    = Path.ChangeExtension(Path.GetFileName(mosaicFileRaster.fileName), "hdr");
                    fileArg.Length         = new FileInfo(mosaicFileRaster.fileName).Length;
                }
                outArg.OutputFiles = new OutFileArg[] { fileArg };
                outArg.LogLevel    = "info";
                outArg.LogInfo     = "拼接完成";
            }
            catch (Exception ex)
            {
                outArg.LogLevel = "error";
                outArg.LogInfo  = ex.Message;
            }
            finally
            {
                if (mosaicFileRaster != null)
                {
                    mosaicFileRaster.Dispose();
                }
                string outXmlFilename = Path.Combine(inArg.MosaicInputArg.OutputDir, Path.GetFileName(inArg.InputFilename) + ".xml");
                MosaicOutputArg.WriteXml(outArg, outXmlFilename);
            }
        }