Exemplo n.º 1
0
        public void CopyFileToCopyFolder()
        {
            if (string.IsNullOrEmpty(FolderOfCopyTo) || GeneratedFileNames == null || GeneratedFileNames.Count == 0)
            {
                return;
            }
            IContextMessage msg = Session.SmartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(9006) as IContextMessage;

            if (msg != null)
            {
                msg.PrintMessage("开始拷贝文件......");
            }
            string fileName;

            foreach (string fname in GeneratedFileNames)
            {
                try
                {
                    fileName = Path.GetFileName(fname);
                    File.Copy(fname, Path.Combine(FolderOfCopyTo, fileName));
                    msg.PrintMessage("拷贝文件\"" + fileName + "\" 到 " + FolderOfCopyTo);
                }
                catch (Exception ex)
                {
                    if (msg != null)
                    {
                        msg.PrintMessage(ex.Message);
                    }
                }
            }
            if (msg != null)
            {
                msg.PrintMessage("开始拷贝文件结束。");
            }
        }
Exemplo n.º 2
0
        private void Execute(List <IMonitoringSubProduct> waitingSubProducts, IContextMessage contextMessage, IArgumentMissProcessor argumentMissProcessor, string executeGroup, Action <int, string> processTracker)
        {
            if (waitingSubProducts == null || waitingSubProducts.Count == 0)
            {
                if (contextMessage != null)
                {
                    contextMessage.PrintMessage("待批量生成的子产品(定量产品\\专题图产品\\统计分析表格等)为空,批量生成进程退出。");
                }
                return;
            }
            int step = 100 / waitingSubProducts.Count;
            int i    = 0;

            foreach (IMonitoringSubProduct subprd in waitingSubProducts)
            {
                if (processTracker != null)
                {
                    processTracker((i++) * step, "正在生成\"" + subprd.Name + "\"......");
                }
                if (contextMessage != null)
                {
                    contextMessage.PrintMessage("开始生成\"" + subprd.Name + "\"......");
                }
                MakeSubProduct("    ", subprd, contextMessage, argumentMissProcessor, executeGroup, processTracker);
                if (contextMessage != null)
                {
                    contextMessage.PrintMessage("\"" + subprd.Name + "\"生成完成。");
                }
            }
        }
Exemplo n.º 3
0
 private void PrintInfo(string message)
 {
     if (_context != null)
     {
         _context.PrintMessage(message);
     }
 }
Exemplo n.º 4
0
 private bool CheckDataTypeIsAccordant(IRasterBand raster1, IRasterBand raster2, string operatorType)
 {
     if (raster1.DataType != raster2.DataType)
     {
         string msg = "源栅格波段与目标栅格波段数据类型不一致,无法执行" + operatorType + "。";
         if (_contextMessage != null)
         {
             _contextMessage.PrintMessage(msg);
         }
         else
         {
             Console.WriteLine(msg);
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
 public void Execute(string beginSubProduct, IContextMessage contextMessage, IArgumentMissProcessor argumentMissProcessor, string executeGroup, Action <int, string> processTracker)
 {
     try
     {
         SubProductDef firstSubProduct = _monitoringProduct.Definition.GetSubProductDefByIdentify(beginSubProduct);
         List <IMonitoringSubProduct> waitingSubProducts = new List <IMonitoringSubProduct>();
         bool isBefore = true;
         if (string.IsNullOrEmpty(executeGroup))
         {
             foreach (IMonitoringSubProduct subprd in _monitoringProduct.SubProducts)
             {
                 if (firstSubProduct.Identify != subprd.Definition.Identify && isBefore)
                 {
                     continue;
                 }
                 if (!subprd.Definition.IsAutoGenerate)
                 {
                     continue;
                 }
                 isBefore = false;
                 waitingSubProducts.Add(subprd);
             }
             Execute(waitingSubProducts, contextMessage, argumentMissProcessor, null, processTracker);
         }
         else
         {
             foreach (IMonitoringSubProduct subprd in _monitoringProduct.SubProducts)
             {
                 if (firstSubProduct.Identify != subprd.Definition.Identify && isBefore)
                 {
                     continue;
                 }
                 if (!subprd.Definition.IsAutoGenerate)
                 {
                     continue;
                 }
                 if (subprd.Definition.AutoGenerateGroup != null)
                 {
                     if (!subprd.Definition.AutoGenerateGroup.Contains(executeGroup))
                     {
                         continue;
                     }
                 }
                 isBefore = false;
                 waitingSubProducts.Add(subprd);
             }
             Execute(waitingSubProducts, contextMessage, argumentMissProcessor, executeGroup, processTracker);
         }
     }
     catch (Exception ex)
     {
         if (contextMessage != null)
         {
             contextMessage.PrintMessage(ex.Message);
         }
     }
 }
Exemplo n.º 6
0
 public void PrintInfo(string info)
 {
     if (_contextMessage != null)
     {
         _contextMessage.PrintMessage(info);
     }
     else
     {
         Console.WriteLine(info);
     }
 }
Exemplo n.º 7
0
 private static void PrintInfo(IContextMessage contextMessage, string info)
 {
     if (contextMessage != null)
     {
         contextMessage.PrintMessage(info);
     }
     else
     {
         Console.WriteLine(info);
     }
 }
Exemplo n.º 8
0
        private IExtractResult TOUAlgorithm()
        {
            float  lonMin      = float.Parse(_argumentProvider.GetArg("LonMin").ToString());
            float  lonMax      = float.Parse(_argumentProvider.GetArg("LonMax").ToString());
            float  latMin      = float.Parse(_argumentProvider.GetArg("LatMin").ToString());
            float  latMax      = float.Parse(_argumentProvider.GetArg("LatMax").ToString());
            float  invaild     = float.Parse(_argumentProvider.GetArg("Invaild").ToString());
            float  zoom        = (float)_argumentProvider.GetArg("Zoom");
            int    width       = (int)_argumentProvider.GetArg("Width");
            int    height      = (int)_argumentProvider.GetArg("Height");
            string touFile     = Obj2String(_argumentProvider.GetArg("TOUTxt"));
            float  outlonMin   = float.Parse(_argumentProvider.GetArg("OutLonMin").ToString());
            float  outlonMax   = float.Parse(_argumentProvider.GetArg("OutLonMax").ToString());
            float  outlatMin   = float.Parse(_argumentProvider.GetArg("OutLatMin").ToString());
            float  outlatMax   = float.Parse(_argumentProvider.GetArg("OutLatMax").ToString());
            bool   isChina     = (bool)_argumentProvider.GetArg("isChina");
            string outFilename = MifEnvironment.GetFullFileName(Path.GetFileName(touFile));
            string chinaMask   = string.Empty;

            if (isChina)
            {
                chinaMask = AppDomain.CurrentDomain.BaseDirectory + "\\SystemData\\ProductArgs\\FOG\\TOUChinaMask\\china_mask.txt";
            }
            TouProcessor.ProcessTouFile(touFile, ref outFilename, chinaMask);
            touFile = outFilename;
            if (string.IsNullOrEmpty(touFile))
            {
                return(null);
            }
            FY3TouImportSMART import = new FY3TouImportSMART(new Size(width, height), new CoordEnvelope(lonMin, lonMax, latMin, latMax), zoom, invaild, _progressTracker);
            string            error;
            string            dstFilename = GetDstFilename(new RasterIdentify(touFile).OrbitDateTime, "FY3A", "VIRR", 0.5f);

            if (!import.ConvertTextToDat(touFile, dstFilename, new CoordEnvelope(outlonMin, outlonMax, outlatMin, outlatMax), out error))
            {
                if (_contextMessage != null && !string.IsNullOrEmpty(error))
                {
                    _contextMessage.PrintMessage(_error);
                }
                return(null);
            }

            if (File.Exists(dstFilename))
            {
                return(new FileExtractResult("0TOU", dstFilename, true));
            }

            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public void printMessage(string message)
        {
            IContextMessage msg = _smartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(9006) as IContextMessage;

            if (msg == null)
            {
                ICommand cmd = _commandEnvironment.Get(9006) as ICommand;
                if (cmd != null)
                {
                    cmd.Execute();
                    msg = _smartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(9006) as IContextMessage;
                }
            }
            if (msg != null)
            {
                msg.PrintMessage(message);
            }
        }
Exemplo n.º 10
0
 private bool GetAndSetFileVar(string preBanks, IMonitoringSubProduct subprd, ArgumentDef arg, IContextMessage contextMessage)
 {
     if (arg.FileProvider.Contains("ContextEnvironment:"))
     {
         string[] parts = arg.FileProvider.Split(':');
         string   v     = _contextEnvironment.GetContextVar(parts[1]);
         if (v == null)
         {
             if (contextMessage != null)
             {
                 contextMessage.PrintMessage(preBanks + "参数\"" + arg.Name + "\"为空,子产品\"" + subprd.Name + "\"过程终止!");
             }
             return(false);
         }
         _contextEnvironment.PutContextVar(parts[1], v);
         _contextEnvironment.PutContextVar(arg.Name, v);
         subprd.ArgumentProvider.SetArg(arg.Name, v);
     }
     return(true);
 }
Exemplo n.º 11
0
        private void DirectMakeSubProduct(string preBanks, IMonitoringSubProduct subprd, AlgorithmDef alg, IContextMessage contextMessage, IArgumentMissProcessor argumentMissProcessor, Action <int, string> processTracker)
        {
            IArgumentProvider prd = subprd.ArgumentProvider;

            prd.SetArg("ThemeGraphyGenerator", _layoutGenerator);
            prd.SetArg("FileNameGenerator", _fileNameGenerator);
            foreach (ArgumentDef arg in alg.Arguments.Where((a) => { return(a is ArgumentDef); }))
            {
                if (arg.IsOptional)
                {
                    continue;
                }
                if (arg.RefType == "file" && arg.FileProvider == null)
                {
                    if (contextMessage != null)
                    {
                        contextMessage.PrintMessage(preBanks + "参数\"" + arg.Name + "\"为空,子产品\"" + subprd.Name + "\"过程终止!");
                    }
                    return;
                }
                else if (arg.RefType == "file")
                {
                    GetAndSetFileVar(preBanks + " ", subprd, arg, contextMessage);
                }
            }
            //根据某个文件型参数生成AOI
            TryApplyAOITemplateBySeconaryArg(subprd);
            //
            IExtractResult result = subprd.Make(processTracker);

            if (result != null)
            {
                if (_resultHandler != null)
                {
                    _resultHandler.HandleResult(_contextEnvironment, _monitoringProduct, subprd, result);
                }
            }
        }
Exemplo n.º 12
0
        private void MakeSubProduct(string preBanks, IMonitoringSubProduct subprd, IContextMessage contextMessage, IArgumentMissProcessor argumentMissProcessor, string executeGroup, Action <int, string> processTracker)
        {
            bool isCreatDataProvider   = false;
            IRasterDataProvider raster = null;

            try
            {
                subprd.ArgumentProvider.Reset();
                subprd.ArgumentProvider.AOI = null;
                AlgorithmDef   alg         = subprd.AlgorithmDefs[0];
                RasterIdentify rstIdentify = null;
                rstIdentify = GetRasterIdentifOfCurrentFile();
                if (subprd.Definition.IsNeedCurrentRaster)
                {
                    string rstFileName = _contextEnvironment.GetContextVar(GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE);
                    raster = GeoDataDriver.Open(rstFileName) as IRasterDataProvider;
                    subprd.ArgumentProvider.DataProvider = raster;
                    isCreatDataProvider = true;
                    //
                    TryApplyAOITemplates(subprd);
                    //
                    if (rstIdentify == null)
                    {
                        if (contextMessage != null)
                        {
                            contextMessage.PrintMessage("参数\"" + GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE + "\"为空!");
                        }
                        if (argumentMissProcessor == null)
                        {
                            return;
                        }
                        string crtFileName = argumentMissProcessor.DoGettingArgument(subprd.Definition, subprd.UseDefaultAlgorithm(subprd.Definition.ProductDef.Identify), GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE);
                        if (crtFileName == null)
                        {
                            return;
                        }
                        rstIdentify = new RasterIdentify(crtFileName);
                        _contextEnvironment.PutContextVar(GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE, crtFileName);
                    }
                    ExtractAlgorithmIdentify id = new ExtractAlgorithmIdentify();
                    id.Satellite = rstIdentify.Satellite;
                    id.Sensor    = rstIdentify.Sensor;
                    alg          = subprd.Definition.GetAlgorithmDefByAlgorithmIdentify(id);
                    if (alg == null)
                    {
                        alg = subprd.Definition.Algorithms[0];
                    }
                }
                subprd.ResetArgumentProvider(alg.Identify);
                subprd.ArgumentProvider.SetArg("AlgorithmName", alg.Identify);
                if (alg.Bands != null && alg.Bands.Length > 0)
                {
                    MonitoringThemeFactory.SetBandArgs(subprd, rstIdentify.Satellite, rstIdentify.Sensor);
                    foreach (BandDef band in alg.Bands)
                    {
                        if (subprd.ArgumentProvider.GetArg(band.Identify).ToString() == "-1")
                        {
                            if (contextMessage != null)
                            {
                                contextMessage.PrintMessage(preBanks + "从波段映射表获取\"" + band.Identify + "\"的波段序号失败,生成过程终止!");
                            }
                            return;
                        }
                    }
                }
                //
                TryHandleCustomArguments(subprd.ArgumentProvider, alg);
                //
                if (subprd.Definition.SubProductInstanceDefs != null)
                {
                    MakeSubProductUseInstances(preBanks + "  ", subprd, alg, contextMessage, argumentMissProcessor, executeGroup, processTracker);
                }
                else
                {
                    DirectMakeSubProduct(preBanks + "  ", subprd, alg, contextMessage, argumentMissProcessor, processTracker);
                }
            }
            finally
            {
                if (raster != null)
                {
                    raster.Dispose();
                    raster = null;
                }
                if (subprd.ArgumentProvider.DataProvider != null && isCreatDataProvider)
                {
                    subprd.ArgumentProvider.DataProvider.Dispose();
                }
            }
        }
Exemplo n.º 13
0
        private IExtractResult HAZEAlgorithm()
        {
            float  lonMin        = float.Parse(_argumentProvider.GetArg("LonMin").ToString());
            float  lonMax        = float.Parse(_argumentProvider.GetArg("LonMax").ToString());
            float  latMin        = float.Parse(_argumentProvider.GetArg("LatMin").ToString());
            float  latMax        = float.Parse(_argumentProvider.GetArg("LatMax").ToString());
            float  invaild       = float.Parse(_argumentProvider.GetArg("Invaild").ToString());
            float  zoom          = (float)_argumentProvider.GetArg("Zoom");
            float  touResolution = (float)_argumentProvider.GetArg("TouResolution");
            int    width         = (int)_argumentProvider.GetArg("Width");
            int    height        = (int)_argumentProvider.GetArg("Height");
            string touFile       = Obj2String(_argumentProvider.GetArg("TOUTxt"));
            bool   IsComputerMid = (bool)_argumentProvider.GetArg("IsComputerMid");
            bool   IsBilinear    = (bool)_argumentProvider.GetArg("IsBilinear");
            float  BilinearRes   = float.Parse(_argumentProvider.GetArg("BilinearRes").ToString());

            if (string.IsNullOrEmpty(touFile) || !File.Exists(touFile))
            {
                return(null);
            }
            Dictionary <string, string> dic = Obj2Dic(_argumentProvider.GetArg("OutEnvelopeSetting"));
            float outlonMin = float.Parse(dic["outlonMin"]);
            float outlonMax = float.Parse(dic["outlonMax"]);
            float outlatMin = float.Parse(dic["outlatMin"]);
            float outlatMax = float.Parse(dic["outlatMax"]);

            UpdateOutEnvelope(ref outlonMin, ref outlonMax, ref outlatMin, ref outlatMax, touResolution);
            IMonitoringSession ms = null;

            #region 中国区域裁切

            bool   isChina     = (bool)_argumentProvider.GetArg("isChina");
            string outFilename = MifEnvironment.GetFullFileName(Path.GetFileName(touFile));
            string chinaMask   = string.Empty;
            if (isChina)
            {
                chinaMask = AppDomain.CurrentDomain.BaseDirectory + "\\SystemData\\ProductArgs\\FOG\\TOUChinaMask\\china_mask.txt";
            }
            TouProcessor.ProcessTouFile(touFile, ref outFilename, chinaMask);
            touFile = outFilename;
            if (string.IsNullOrEmpty(touFile) || !File.Exists(touFile))
            {
                return(null);
            }

            #endregion

            #region 数据格式转换

            FY3TouImportSMART import = new FY3TouImportSMART(new Size(width, height), new CoordEnvelope(lonMin, lonMax, latMin, latMax), zoom, invaild, _progressTracker);
            string            error;

            ISmartSession session = null;
            object        obj     = _argumentProvider.GetArg("SmartSession");
            if (obj != null)
            {
                session = obj as ISmartSession;
            }
            bool  isBackGround     = _argumentProvider.DataProvider != null && session != null && session.SmartWindowManager.ActiveCanvasViewer != null ? true : false;
            float rasterResulotion = !isBackGround ? touResolution : _argumentProvider.DataProvider.ResolutionX;
            rasterResulotion = IsBilinear ? (BilinearRes == -1 ? rasterResulotion : BilinearRes) : touResolution;
            RasterIdentify rid = new RasterIdentify(!isBackGround ? touFile : _argumentProvider.DataProvider.fileName);
            //中间计算用临时文件,最终结果保存为dstFilename
            string dstFilename  = GetDstFilename(new RasterIdentify(touFile).OrbitDateTime, rid.Satellite, rid.Sensor, rasterResulotion);
            string tempFilename = dstFilename.Insert(dstFilename.LastIndexOf('.'), "temp");
            if (_progressTracker != null)
            {
                _progressTracker.Invoke(10, "正在转换指数数据到栅格数据....");
            }
            if (!import.ConvertTextToDat(touFile, tempFilename, new CoordEnvelope(outlonMin, outlonMax, outlatMin, outlatMax), out error))
            {
                if (_contextMessage != null && !string.IsNullOrEmpty(error))
                {
                    _contextMessage.PrintMessage(_error);
                }
                return(null);
            }

            #endregion

            else
            {
                #region 输出结果插值处理

                //插值处理的放大 倍数
                Int16  intervalZoom    = (Int16)Math.Floor(touResolution / rasterResulotion);
                string tempMidFilename = tempFilename.Insert(tempFilename.LastIndexOf('.'), "_mid");
                try
                {
                    GeoDo.RSS.MIF.Prds.Comm.Raster.BiliNearAndSmoothHelper bilinear = new Comm.Raster.BiliNearAndSmoothHelper();
                    //中值滤波
                    if (IsComputerMid)
                    {
                        if (_progressTracker != null)
                        {
                            _progressTracker.Invoke(30, "正在进行中值滤波....");
                        }
                        bilinear.SmoothComputer(tempFilename, 5, tempMidFilename);
                    }
                    else
                    {
                        tempMidFilename = tempFilename;
                    }
                    //插值
                    if (IsBilinear)
                    {
                        bilinear.AndBiliNear(tempMidFilename, intervalZoom, dstFilename);
                        if (_progressTracker != null)
                        {
                            _progressTracker.Invoke(60, "正在进行插值处理....");
                        }
                    }
                    else
                    {
                        if (File.Exists(dstFilename))
                        {
                            File.Delete(dstFilename);
                        }
                        File.Copy(tempMidFilename, dstFilename);
                    }

                    #endregion

                    #region 专题产品生产

                    if (_progressTracker != null)
                    {
                        _progressTracker.Invoke(80, "正在生成专题产品....");
                    }

                    ms = _argumentProvider.EnvironmentVarProvider as IMonitoringSession;
                    ms.ChangeActiveSubProduct("0IMG");
                    ms.ActiveMonitoringSubProduct.ArgumentProvider.SetArg("IsBackGround", isBackGround);
                    bool isOriginal = (bool)_argumentProvider.GetArg("isOriginal");
                    if (isOriginal)
                    {
                        ms.ActiveMonitoringSubProduct.ArgumentProvider.SetArg("OutFileIdentify", "OHAI");
                    }
                    else
                    {
                        ms.ActiveMonitoringSubProduct.ArgumentProvider.SetArg("OutFileIdentify", "HAEI");
                    }
                    ms.ActiveMonitoringSubProduct.ArgumentProvider.SetArg("SelectedPrimaryFiles", new string[] { dstFilename });
                    ms.ActiveMonitoringSubProduct.ArgumentProvider.SetArg("isSpecifyFiles", true);
                    ms.DoAutoExtract(false);

                    #endregion
                }
                finally
                {
                    //删除临时文件
                    if (File.Exists(tempFilename))
                    {
                        DelteAboutFile(tempFilename);
                    }
                    if (File.Exists(tempMidFilename))
                    {
                        DelteAboutFile(tempMidFilename);
                    }
                }
            }
            if (File.Exists(dstFilename))
            {
                DisplayResultClass.TrySaveFileToWorkspace(ms.ActiveMonitoringSubProduct, ms, dstFilename, new FileExtractResult("HAZE", dstFilename));
                WriteAboutFile(dstFilename);
            }
            return(null);
        }
Exemplo n.º 14
0
        private bool SetPrimaryFiles(string preBanks, string fileProvider, string argument, ref string extinfo, IArgumentProvider prd, IContextMessage contextMessage)
        {
            string[] parts = fileProvider.Split(':');
            if (fileProvider.Contains("ContextEnvironment:"))
            {
                string v = _contextEnvironment.GetContextVar(parts[1]);
                if (v == null)
                {
                    if (contextMessage != null)
                    {
                        contextMessage.PrintMessage(preBanks + "参数\"SelectedPrimaryFiles\"为空,生成过程终止!");
                    }
                    return(false);
                }
                _contextEnvironment.PutContextVar(parts[1], v);
                prd.SetArg("SelectedPrimaryFiles", v);
            }
            else if (fileProvider.ToUpper().Contains(".DLL,"))
            {
                parts = fileProvider.Split(',');

                string   assembly = parts[0];
                string   cls      = parts[1];
                object   obj      = null;
                Assembly ass      = TryGetExistedAssembly(assembly);
                if (ass != null)
                {
                    obj = ass.CreateInstance(cls);
                }
                else
                {
                    if (GetType().Assembly.Location.Contains(assembly))
                    {
                        obj = GetType().Assembly.CreateInstance(cls);
                    }
                    else
                    {
                        ass = TryGetExistedAssembly(assembly);
                        if (ass != null)
                        {
                            obj = ass.CreateInstance(cls);
                        }
                        else
                        {
                            obj = Activator.CreateInstance(assembly, cls);
                        }
                    }
                }
                if (obj != null)
                {
                    IFileFinder finder = obj as IFileFinder;
                    if (finder != null)
                    {
                        string   fname = _contextEnvironment.GetContextVar(GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE);
                        string[] files = finder.Find(fname, ref extinfo, argument);
                        if (files != null)
                        {
                            prd.SetArg("SelectedPrimaryFiles", files);
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 15
0
        private void MakeSubProductUseInstances(string preBanks, IMonitoringSubProduct subprd, AlgorithmDef alg, IContextMessage contextMessage, IArgumentMissProcessor argumentMissProcessor, string executeGroup, Action <int, string> processTracker)
        {
            IArgumentProvider prd = subprd.ArgumentProvider;

            prd.SetArg("ThemeGraphyGenerator", _layoutGenerator);
            prd.SetArg("FileNameGenerator", _fileNameGenerator);
            foreach (SubProductInstanceDef ist in subprd.Definition.SubProductInstanceDefs)
            {
                if (!ist.isautogenerate)
                {
                    continue;
                }
                if (!string.IsNullOrEmpty(executeGroup) && ist.AutoGenerateGroup != null && !ist.AutoGenerateGroup.Contains(executeGroup))
                {
                    continue;
                }
                ResetFileVars(prd, alg);
                if (ist.FileProvider == null)
                {
                    if (contextMessage != null)
                    {
                        contextMessage.PrintMessage(preBanks + "参数\"FileProvider\"为空,子产品\"" + ist.Name + "\"过程终止!");
                    }
                    continue;
                }
                if (ist.AOIProvider != null)
                {
                    SetAOI(ist.AOIProvider, prd);
                }
                if (ist.FileProvider != null)
                {
                    if (!SetPrimaryFiles(preBanks, ist.FileProvider, ist.Argument, ref ist.extInfo, prd, contextMessage))
                    {
                        continue;
                    }
                }
                if (ist.OutFileIdentify != null)
                {
                    prd.SetArg("OutFileIdentify", ist.OutFileIdentify);
                }
                if (ist.LayoutName != null)
                {
                    prd.SetArg("ThemeGraphTemplateName", ist.LayoutName);
                }
                if (!string.IsNullOrEmpty(ist.ColorTableName))
                {
                    prd.SetArg("colortablename", "colortablename=" + ist.ColorTableName);
                }
                if (!string.IsNullOrEmpty(ist.extInfo))
                {
                    prd.SetArg("extinfo", ist.extInfo);
                }

                //多通道合成图需要使用Canverviewer中的数据。包括文件名,波段,图像增强方案等。
                prd.SetArg("SmartSession", _contextEnvironment.Session);

                //根据某个文件型参数生成AOI
                TryApplyAOITemplateBySeconaryArg(subprd);
                //
                IExtractResult result = subprd.Make(processTracker);
                if (result != null)
                {
                    if (_resultHandler != null)
                    {
                        _resultHandler.HandleResult(_contextEnvironment, _monitoringProduct, subprd, result);
                    }
                }
            }
        }
Exemplo n.º 16
0
 private void PrintInfo(string info)
 {
     _contextMessage.PrintMessage(info);
 }
Exemplo n.º 17
0
        public void ExportImageOfGxdFiles()
        {
            if (!AutoGeneratorSettings.CurrentSettings.IsOutputPng)
            {
                return;
            }
            if (AutoGeneratorSettings.CurrentSettings.GxdFileNames == null || AutoGeneratorSettings.CurrentSettings.GxdFileNames.Count == 0)
            {
                return;
            }
            bool isNeedCopy = !string.IsNullOrEmpty(AutoGeneratorSettings.CurrentSettings.FolderOfCopyTo);

            if (isNeedCopy)
            {
                AutoGeneratorSettings.CurrentSettings.GeneratedFileNames.Clear();
            }
            IContextMessage msg = Session.SmartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(9006) as IContextMessage;

            if (msg != null)
            {
                msg.PrintMessage("开始导出专题图图片......");
            }
            foreach (string fname in GxdFileNames)
            {
                IGxdDocument doc = GxdDocument.LoadFrom(fname);
                if (doc == null)
                {
                    if (msg != null)
                    {
                        msg.PrintMessage("专题图\"" + fname + "\"打开失败。");
                    }
                    return;
                }
                using (LayoutViewer viewer = new LayoutViewer())
                {
                    viewer.LayoutHost.ApplyGxdDocument(doc);
                    using (Bitmap bm = viewer.LayoutHost.ExportToBitmap(System.Drawing.Imaging.PixelFormat.Format32bppArgb))
                    {
                        if (bm == null)
                        {
                            if (msg != null)
                            {
                                msg.PrintMessage("专题图\"" + fname + "\"导出图片失败。");
                            }
                            return;
                        }
                        string fileName = Path.Combine(Path.GetDirectoryName(fname), Path.GetFileNameWithoutExtension(fname) + ".png");
                        bm.Save(fileName, ImageFormat.Png);
                        if (isNeedCopy)
                        {
                            AutoGeneratorSettings.CurrentSettings.GeneratedFileNames.Add(fileName);
                        }
                    }
                }
                if (msg != null)
                {
                    msg.PrintMessage("已导出专题图\"" + fname + "\"。");
                }
            }
            //
            if (msg != null)
            {
                msg.PrintMessage("导出专题图图片结束。");
            }
            //
            CopyFileToCopyFolder();
        }