Ejemplo n.º 1
0
        private IExtractResult IceDegree()
        {
            string outFileIdentify          = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instatnce = GetSubProductInstanceByOutIdentify(outFileIdentify);

            if (instatnce != null)
            {
                outFileIdentify = instatnce.OutFileIdentify;
            }

            //string templatName = GetStringArgument("ThemeGraphTemplateName");
            string xIntervalStr = GetStringArgument("XInterval");
            string yIntervalStr = GetStringArgument("YInterval");
            float  xInterval = 0, yInterval = 0;

            if (string.IsNullOrWhiteSpace(xIntervalStr) || string.IsNullOrWhiteSpace(yIntervalStr))
            {
                return(null);
            }
            if (!float.TryParse(xIntervalStr, out xInterval) || !float.TryParse(yIntervalStr, out yInterval))
            {
                return(null);
            }
            string outidentify = _subProductDef.Identify;

            dblvFile = GetIceDblv();
            Feature[] features = GetIceDegreeShp(dblvFile, xInterval, yInterval);

            string gxd         = GenOutFiename(dblvFile, outFileIdentify, ".gxd");
            string shpFilename = Path.ChangeExtension(gxd, ".shp");

            SaveToShp(shpFilename, features);
            ApplyMcdToGxd(shpFilename);

            if (string.IsNullOrWhiteSpace(shpFilename) || !File.Exists(shpFilename))
            {
                return(null);
            }
            CreaterShpLayers(shpFilename);

            IExtractResult result = null;

            if (instatnce != null)
            {
                result = ThemeGraphyByInstance(instatnce);
            }
            else
            {
                result = VectoryThemeGraphy(null);
            }
            string gxdFile = (result as FileExtractResult).FileName;

            AddShpLayerToGxd(gxdFile);
            (result as FileExtractResult).Add2Workspace = true;
            return(result as IExtractResult);
        }
Ejemplo n.º 2
0
        private IExtractResult ICETFRI()
        {
            string outFileIdentify          = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instatnce = GetSubProductInstanceByOutIdentify(outFileIdentify);

            if (instatnce != null)
            {
                outFileIdentify = instatnce.OutFileIdentify;
            }
            string templatName = GetStringArgument("ThemeGraphTemplateName");

            //获取冰缘线数据
            string[] shpFiles = _argumentProvider.GetArg("ShpFile") as string[];
            if (shpFiles == null || shpFiles.Length == 0)
            {
                ISmartSession      session = _argumentProvider.GetArg("SmartSession") as ISmartSession;
                IMonitoringSession ms      = session.MonitoringSession as IMonitoringSession;
                IWorkspace         wks     = ms.GetWorkspace();
                if (wks.ActiveCatalog != null)
                {
                    string[] fs = wks.ActiveCatalog.GetSelectedFiles("EDGE");
                    if (fs != null && fs.Length != 0)
                    {
                        shpFiles = fs;
                        _argumentProvider.SetArg("SelectedPrimaryFiles", shpFiles);
                    }
                }
            }
            if (!CheckShpFile(ref shpFiles))
            {
                PrintInfo("冰缘线获取失败!");
                //return null;
            }
            else
            {
                _shpFiles = shpFiles;
                //if (_shpFiles.Length == 1)
                //    _iceControlPointShpFile = GeoDo.RSS.MIF.Prds.ICE.IceEdgeFileNameHelper.GetIceEdgeControlInfoFilename(_shpFiles[0]);
                ApplyMcd(_shpFiles, @"SystemData\ProductArgs\长序列冰缘线专题图文档.mcd");
                CreateLegendItems(_shpFiles);
            }
            IExtractResult        result   = null;
            SubProductInstanceDef instance = new SubProductInstanceDef();

            instance.OutFileIdentify = outFileIdentify;
            instance.isautogenerate  = false;
            instance.LayoutName      = templatName;
            result   = ThemeGraphyByInstance(instance);
            _gxdFile = (result as FileExtractResult).FileName;
            if (CheckShpFile(ref shpFiles))
            {
                AddShpLayerToGxd();
            }
            (result as FileExtractResult).Add2Workspace = true;
            return(result as IExtractResult);
        }
Ejemplo n.º 3
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _progressTracker = progressTracker;
            _contextMessage  = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                return(null);
            }
            //Initialize Argument
            string[] arguments = _argumentProvider.GetArg("CoverageArguments") as string[];
            if (arguments == null || arguments.Length < 2)
            {
                return(null);
            }
            if (!File.Exists(arguments[0]) || string.IsNullOrEmpty(arguments[1]))
            {
                return(null);
            }
            _fileName     = arguments[0];
            _fileOpenArgs = arguments[1];
            if (arguments[1].Contains("south"))
            {
                _outFileIdentify = "SICI";
                _aoiFileName     = _southAOIName;
            }
            else
            {
                _outFileIdentify = "NICI";
                _aoiFileName     = _northAOIName;
            }
            //产品制作
            IExtractResult result = null;

            if (_argumentProvider.GetArg("AlgorithmName").ToString() == "IceConverageAlgorithm")
            {
                _isUseAOIToClear = (bool)_argumentProvider.GetArg("BoolCustomAOI");
                if (_isUseAOIToClear)
                {
                    TryCreateNewAoiFile();
                }
                if (_isUseAOIToClear && AOIFileExist())
                {
                    result = IceConverageAlgorithmWithAOI(progressTracker);
                }
                else
                {
                    result = IceConverageAlgorithm(progressTracker);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        //日最大值合成
        void DayRaster_Click(object sender, EventArgs e)
        {
            (_session.MonitoringSession as IMonitoringSession).ChangeActiveSubProduct("CYCA");
            GetCommandAndExecute(6602);
            IMonitoringSubProduct msp = (_session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            msp.ArgumentProvider.SetArg("CYCAIdentify", "CYCAMax");
            IExtractResult result = msp.Make(null);

            DisplayResultClass.DisplayResult(_session, msp, result, false);
        }
Ejemplo n.º 5
0
        private IExtractResult AEDGAlgorithm()
        {
            int smaping, contourValue;

            if (!Int32.TryParse(_argumentProvider.GetArg("Smaping").ToString(), out smaping))
            {
                return(null);
            }
            if (!Int32.TryParse(_argumentProvider.GetArg("contourValue").ToString(), out contourValue))
            {
                return(null);
            }
            double[] contourValues = new double[] { contourValue };
            string[] files         = GetStringArray("SelectedPrimaryFiles");
            if (files == null || files.Length == 0)
            {
                PrintInfo("获取文件错误,可能是没有选择判识结果文件。");
                return(null);
            }

            IRasterDataProvider provider = null;

            try
            {
                provider = GeoDataDriver.Open(files[0], enumDataProviderAccess.ReadOnly, null) as IRasterDataProvider;
                if (provider == null)
                {
                    PrintInfo("获取文件错误,可能是系统不支持当前文件。");
                    return(null);
                }

                string shpFile           = GenFiename(files[0]);
                GenerateContourLines gcl = new GenerateContourLines(_progressTracker, _contextMessage);
                gcl.DoGenerateContourLines(provider, 1, _argumentProvider.AOI, contourValues, smaping, shpFile);
                if (!File.Exists(shpFile))
                {
                    PrintInfo("生成等值线数据失败。");
                    return(null);
                }
                CreateLegendItems(shpFile);
                CreateMcd(shpFile);
                _argumentProvider.SetArg("SelectedPrimaryFiles", shpFile);
                _shpFile = shpFile;
                IExtractResult er = ThemeGraphyResult(null);
                _gxdFile = (er as FileExtractResult).FileName;
                AddShpToGxd();
                return(er);
            }
            finally
            {
                provider.Dispose();
            }
        }
Ejemplo n.º 6
0
        public static IExtractResult StatAnaylsisBase(ISmartSession session, string outFileIdentify, string aoiTemplate, string subProductIdentify, string algorithmName, bool isCustom, bool multiSelect)
        {
            (session.MonitoringSession as IMonitoringSession).ChangeActiveSubProduct(subProductIdentify);
            GetCommandAndExecute(session, 6602);
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            if (msp == null)
            {
                return(null);
            }
            object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles");

            //if (obj == null || !File.Exists(obj.ToString()))
            //{
            if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName))
            {
                return(null);
            }
            //}
            string[] files = obj as string[];
            if (files == null || files.Length == 0)
            {
                if (File.Exists(obj.ToString()))
                {
                    files = new string[] { obj.ToString() }
                }
                ;
                else
                {
                    return(null);
                }
            }
            if (isCustom && !SetAOIArugment(files, msp, multiSelect))
            {
                return(null);
            }
            else if (!isCustom)
            {
                msp.ArgumentProvider.SetArg("AOI", string.IsNullOrEmpty(aoiTemplate) ? null : aoiTemplate);
            }
            try
            {
                msp.ArgumentProvider.SetArg("FileNameGenerator", (session.MonitoringSession as IMonitoringSession).FileNameGenerator);
                msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
                IExtractResult result = msp.Make(null);
                DisplayResultClass.DisplayResult(session, msp, result, false);
                return(result);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 7
0
        private IExtractResult ISOIAlgorithm()
        {
            try
            {
                //获取冰缘线数据
                string[] shpFiles = _argumentProvider.GetArg("SelectedPrimaryFiles") as string[];
                if (shpFiles == null || shpFiles.Length == 0)
                {
                    ISmartSession      session = _argumentProvider.GetArg("SmartSession") as ISmartSession;
                    IMonitoringSession ms      = session.MonitoringSession as IMonitoringSession;
                    IWorkspace         wks     = ms.GetWorkspace();
                    if (wks.ActiveCatalog != null)
                    {
                        string[] fs = wks.ActiveCatalog.GetSelectedFiles("EDGE");
                        if (fs != null && fs.Length != 0)
                        {
                            shpFiles = fs;
                            _argumentProvider.SetArg("SelectedPrimaryFiles", shpFiles);
                        }
                    }
                }
                if (!CheckShpFile(ref shpFiles))
                {
                    PrintInfo("冰缘线获取失败!");
                    return(null);
                }
                _shpFiles = shpFiles;
                if (_shpFiles.Length == 1)
                {
                    _iceControlPointShpFile = GeoDo.RSS.MIF.Prds.ICE.IceEdgeFileNameHelper.GetIceEdgeControlInfoFilename(_shpFiles[0]);
                }
                ApplyMcd(_shpFiles);
                //ReadShpFileAttribute(shpFile);

                if (!string.IsNullOrEmpty(_iceControlPointShpFile) && File.Exists(_iceControlPointShpFile))
                {
                    ReadIceControlPointInfo(_iceControlPointShpFile);
                }
                CreateLegendItems(_shpFiles);

                IExtractResult er = VectoryThemeGraphy(null);//生成空白的专题图
                _gxdFile = (er as FileExtractResult).FileName;
                AddShpLayerToGxd();
                return(er);
            }
            finally
            {
                _argumentProvider.SetArg("SelectedPrimaryFiles", null);
            }
        }
Ejemplo n.º 8
0
        private void btnExtract_Click(object sender, EventArgs e)
        {
            IMonitoringSubProduct subProduct = GetCurrentSubProduct();

            if (subProduct == null)
            {
                return;
            }
            IContextMessage msg = _session.SmartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(9006) as IContextMessage;

            SetAOIArgument(subProduct);
            IProgressMonitor tracker = _session.ProgressMonitorManager.DefaultProgressMonitor;
            IExtractResult   result  = null;

            try
            {
                subProduct.ArgumentProvider.SetArg("SmartSession", _session);
                //不能在这里设置SelectedPrimaryFiles参数,会将界面上设置好参数值的覆盖掉。
                //TrySetSelectedPrimaryFilesArgs(_session, subProduct);

                tracker.Start(false);
                tracker.Reset("正在生成...", 100);
                result = subProduct.Make((pro, tip) =>
                {
                    if (tracker != null)
                    {
                        tracker.Boost(pro, tip);
                    }
                },
                                         msg);
                if (result == null)
                {
                    _isNullResult = true;
                    return;
                }
            }
            finally
            {
                tracker.Finish();
            }
            if (!(result is IPixelIndexMapper) && !(result is IExtractResultArray))
            {
                _isAutoSave = false;
            }
            if (result is IExtractResultArray)
            {
                SetIsAutoSave(result as IExtractResultArray);
            }
            DisplayResultClass.DisplayResult(_session, subProduct, result, true);
        }
Ejemplo n.º 9
0
 public void Make(string[] args)
 {
     PrintInfo("启动LST计算");
     try
     {
         LstArgs arg = new LstArgs(args);
         if (arg == null)
         {
             PrintInfo("输入参数为空,计算终止");
         }
         _rstFileName = arg.LdfFile;
         _ndvi        = arg.NDVIFile;
         _outfile     = arg.OutFile;
         if (string.IsNullOrWhiteSpace(_rstFileName))
         {
             PrintInfo("输入ldf局地文件为空,计算终止");
             return;
         }
         if (string.IsNullOrWhiteSpace(_outfile))
         {
             PrintInfo("输出文件设置为空,计算终止");
             return;
         }
         IMonitoringSubProduct subprd = CreateMonitoringSubProduct(_rstFileName, "LST", "DBLV");
         if (subprd == null)
         {
             PrintInfo("激活或生成子产品失败,计算终止");
             return;
         }
         //下面需要设置文件来源参数(控制台程序中获得的参数)
         SetConsoleArgs(subprd);
         IExtractResult result     = subprd.Make(null, _context);
         string         resultFile = null;
         if (result is ExtractResultArray)
         {
             resultFile = ((result as ExtractResultArray).PixelMappers[0] as IFileExtractResult).FileName;
         }
         //搬运文件,或者裁切文件。
         TryCutFile(resultFile, _outfile);
     }
     catch (Exception ex)
     {
         PrintInfo(ex.Message);
     }
     finally
     {
         PrintInfo("结束LST计算");
     }
 }
Ejemplo n.º 10
0
        private IExtractResult CalcNDVI(Action <int, string> progressTracker)
        {
            //参数准备
            int bandV    = (int)_argumentProvider.GetArg("Visible");      //可见光
            int bandNear = (int)_argumentProvider.GetArg("NearInfrared"); //近红外

            if (bandV == -1 || bandNear == -1)
            {
                PrintInfo("通道序号设置不正确");
                return(null);
            }
            int[]  bandNos      = new int[] { bandV, bandNear };
            double visibleZoom  = (double)_argumentProvider.GetArg("Visible_Zoom");
            double nearInfrared = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
            float  zoom         = (ushort)_argumentProvider.GetArg("resultZoom");

            zoom = zoom == 0f ? 1000 : zoom;
            string[] aois        = _argumentProvider.GetArg("AOITemplate") as string[];
            string   aoiTemplate = aois == null ? null : aois[0];

            string[] inputFiles = _argumentProvider.GetArg("RasterFile") as string[];
            if (inputFiles == null || inputFiles.Length == 0)
            {
                PrintInfo("没有设置输入数据");
                return(null);
            }
            IExtractResultArray results = new ExtractResultArray("NDVI");

            foreach (string inputFile in inputFiles)
            {
                //计算NDVI
                IExtractResult ret = CalcNDVI(inputFile, bandNos, zoom, aoiTemplate, progressTracker);
                if (ret != null)
                {
                    results.Add(ret as IExtractResultBase);
                }
            }
            return(results);
        }
Ejemplo n.º 11
0
 private IExtractResult ISOIAlgorithm()
 {
     try
     {
         //获取等值线数据
         string shpFile = _argumentProvider.GetArg("SelectedPrimaryFiles") as string;
         if (string.IsNullOrWhiteSpace(shpFile))
         {
             ISmartSession      session = _argumentProvider.GetArg("SmartSession") as ISmartSession;
             IMonitoringSession ms      = session.MonitoringSession as IMonitoringSession;
             IWorkspace         wks     = ms.GetWorkspace();
             if (wks.ActiveCatalog != null)
             {
                 string[] fs = wks.ActiveCatalog.GetSelectedFiles("ISOT");
                 if (fs != null && fs.Length != 0)
                 {
                     shpFile = fs[0];
                     _argumentProvider.SetArg("SelectedPrimaryFiles", shpFile);
                 }
             }
         }
         if (!File.Exists(shpFile))
         {
             PrintInfo("获取等值线shp文件失败。");
             return(null);
         }
         _symbolColor.Clear();
         CreateLegendItems(shpFile);
         _shpFile = shpFile;
         IExtractResult er = ThemeGraphyResult(null);
         _gxdFile = (er as FileExtractResult).FileName;
         AddShpToGxd();
         return(er);
     }
     finally
     {
         _argumentProvider.SetArg("SelectedPrimaryFiles", null);
     }
 }
Ejemplo n.º 12
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);
                }
            }
        }
Ejemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            //IArgumentProviderFactory fac = MifEnvironment.ActiveArgumentProviderFactory;
            ThemeDef               themeDef    = MonitoringThemeFactory.GetThemeDefByIdentify("CMA");
            IMonitoringTheme       them        = new MonitoringThemeCMA(themeDef);
            IMonitoringProduct     fir         = them.GetProductByIdentify("FIR");
            ExtractProductIdentify prdIdentify = new ExtractProductIdentify();

            prdIdentify.ThemeIdentify      = "CMA";
            prdIdentify.ProductIdentify    = "FIR";
            prdIdentify.SubProductIdentify = "DBLV";
            ExtractAlgorithmIdentify algIdentify = new ExtractAlgorithmIdentify();

            algIdentify.Satellite  = "FY3A";
            algIdentify.Sensor     = "VIRR";
            algIdentify.Resolution = null;//not use
            IArgumentProvider     arg = MonitoringThemeFactory.GetArgumentProvider(prdIdentify, algIdentify);
            IMonitoringSubProduct bin = fir.GetSubProductByIdentify("DBLV");

            //arg.SetArg(bin.AlgorithmDefs[0].Indetify, bin.AlgorithmDefs[0]);
            arg.DataProvider = GetRasterDataProvider();
            arg.AOI          = GetAOI();
            IExtractResult result = bin.Make(null);
        }
Ejemplo n.º 14
0
        public static void TrySaveFileToWorkspace(IMonitoringSubProduct subProduct, IMonitoringSession mession, string fname, IExtractResult restult)
        {
            if (string.IsNullOrEmpty(fname))
            {
                return;
            }
            IWorkspace     wks = mession.GetWorkspace();
            RasterIdentify rst = new RasterIdentify(fname);
            ICatalog       c   = wks.GetCatalog("CurrentExtracting");

            if (c != null)
            {
                c.AddItem(new CatalogItem(fname, c.Definition as SubProductCatalogDef));
            }
            if (_contextEnvironment != null && subProduct != null)
            {
                rst.SubProductIdentify = subProduct.Identify;

                IExtractResultBase erb = restult as IExtractResultBase;
                if (erb != null && !string.IsNullOrEmpty(erb.OutIdentify))
                {
                    rst.SubProductIdentify = erb.OutIdentify;
                }
                GetOutFileIdentify(ref rst, subProduct);
                if (!string.IsNullOrEmpty(restult.Name) && restult.Name != rst.SubProductIdentify)
                {
                    rst.SubProductIdentify = restult.Name;
                }
                _contextEnvironment.PutContextVar(rst.SubProductIdentify, fname);
            }
        }
Ejemplo n.º 15
0
 private static void DisplayValueResult(ISmartSession session, IMonitoringSubProduct subProduct, IExtractResult restult)
 {
     //
     return;
 }
Ejemplo n.º 16
0
 private static void DisplayPixelIndexMapper(IExtractResult restult, ISmartSession session)
 {
     (session.MonitoringSession as IMonitoringSession).ExtractingSession.ApplyResult(restult as IPixelIndexMapper);
     TryOrbitToWorkspace(session);
 }
Ejemplo n.º 17
0
        private static void DisplayFileResult(IMonitoringSubProduct subProduct, ISmartSession session, IExtractResult restult)
        {
            string filename = (restult as IFileExtractResult).FileName;

            RecordFileForAfterProcess(filename);
            IFileExtractResult fileResult = restult as IFileExtractResult;

            if (fileResult.Add2Workspace)
            {
                TrySaveFileToWorkspace(subProduct, session, filename, restult, null);
            }
            if (!(restult as IExtractResultBase).Display)
            {
                return;
            }
            if (NeedOpenFile())
            {
                object   obj  = subProduct.ArgumentProvider.GetArg("fileOpenArgs");
                string[] args = null;
                if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                {
                    args = new string[] { obj.ToString() }
                }
                ;
                ICommand cmd = session.CommandEnvironment.Get(2000);
                if (cmd != null)
                {
                    cmd.Execute(filename, args);
                }
            }
        }
Ejemplo n.º 18
0
        //根据文件名提取区域标识,限定专题图输出数据范围。一般用于制作网络图。
        public static IExtractResult CreateThemeGraphyBase(ISmartSession session, string algorithmName, string outFileIdentify, string colorTableName, string dataIdentify, string templateName, bool isCustom, bool multiSelect, bool isUseRegion, int genralAndTheme)
        {
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            if (msp == null)
            {
                return(null);
            }
            string[]      files     = null;
            CoordEnvelope customEnv = null;

            if (genralAndTheme == 0)
            {
                object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles");
                if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName))
                {
                    return(null);
                }
                files = obj as string[];
                if (files == null || files.Length == 0)
                {
                    if (File.Exists(obj.ToString()))
                    {
                        files = new string[] { obj.ToString() }
                    }
                    ;
                    else
                    {
                        return(null);
                    }
                }
                //by chennan 20130319 根据需要查找相应文件
                UpdateFilesByDataIdentify(ref files, dataIdentify);

                //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923
                foreach (string fname in files)
                {
                    CanCreatThemegraph(fname);
                }
                msp.ArgumentProvider.SetArg("SelectedPrimaryFiles", files);

                if (isCustom && !SetAOIArugment(files, msp, multiSelect, out customEnv))//用户自定义区域
                {
                    return(null);
                }
                else if (!isCustom)
                {
                    msp.ArgumentProvider.SetArg("AOI", null);
                }
            }
            IThemeGraphGenerator tgg = new GeoDo.RSS.MIF.Prds.Comm.CmaThemeGraphGenerator(session);

            msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg);
            msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
            msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName);
            if (customEnv != null)
            {
                RasterProject.PrjEnvelope prjEnvelope = new RasterProject.PrjEnvelope(customEnv.MinX, customEnv.MaxX, customEnv.MinY, customEnv.MaxY);
                msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope);
            }
            else if (isUseRegion)// 换为字符串,为区域定义分组名称regionGroupName,为空代表不指定区域。
            {
                RasterIdentify rstId = new RasterIdentify(files[0]);
                if (!string.IsNullOrWhiteSpace(rstId.RegionIdentify))
                {
                    DefinedRegionParse reg        = new DefinedRegionParse();
                    BlockItemGroup     blockGroup = reg.BlockDefined.FindGroup("积雪");
                    PrjEnvelopeItem    envItem    = blockGroup.GetPrjEnvelopeItem(rstId.RegionIdentify);
                    if (envItem != null)
                    {
                        RasterProject.PrjEnvelope prjEnvelope = RasterProject.PrjEnvelope.CreateByCenter(envItem.PrjEnvelope.CenterX, envItem.PrjEnvelope.CenterY, 10, 10);
                        msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope);
                    }
                }
            }
            if (!string.IsNullOrEmpty(colorTableName))
            {
                msp.ArgumentProvider.SetArg("colortablename", "colortablename=" + colorTableName);
            }

            IProgressMonitor     tracker  = null;
            Action <int, string> progress = null;

            try
            {
                tracker = session.ProgressMonitorManager.DefaultProgressMonitor;
                if (tracker != null)
                {
                    tracker.Start(false);
                    tracker.Reset("正在生成...", 100);
                    progress = (p, txt) =>
                    {
                        tracker.Boost(p, txt);
                    };
                }
                IExtractResult result = msp.Make(progress);
                DisplayResultClass.DisplayResult(session, msp, result, false);
                return(result);
            }
            finally
            {
                if (tracker != null)
                {
                    tracker.Finish();
                }
            }
        }
Ejemplo n.º 19
0
        public static void DisplayResult(ISmartSession session, IMonitoringSubProduct subProduct, IExtractResult restult, bool extract)
        {
            if (restult == null)
            {
                ClosedActiveMonitoringSubProduct(session, subProduct);
                return;
            }
            IMonitoringSession msession = session.MonitoringSession as IMonitoringSession;

            if (restult is IPixelIndexMapper)
            {
                DisplayPixelIndexMapper(restult, session);
            }
            else if (restult is IFileExtractResult)
            {
                DisplayFileResult(subProduct, session, restult);
            }
            else if (restult is IExtractResultArray)
            {
                IExtractResultArray  extResultMapper = restult as ExtractResultArray;
                IExtractResultBase[] mappers         = extResultMapper.PixelMappers;
                if (mappers == null || mappers.Length == 0)
                {
                    return;
                }
                foreach (IExtractResultBase mapper in mappers)
                {
                    if (mapper is IFileExtractResult)
                    {
                        DisplayFileResult(subProduct, session, mapper as IExtractResult);
                    }
                    else if (mapper is IPixelIndexMapper && extract)
                    {
                        DisplayPixelIndexMapper(mapper as IPixelIndexMapper, session);
                    }
                    else
                    {
                        DisplayPixelFeatureMapper(session, subProduct, mapper as IExtractResult, false);
                    }
                }
            }
            else if (restult is IValueExtractResult)
            {
                DisplayValueResult(session, subProduct, restult);
            }
            else
            {
                DisplayPixelFeatureMapper(session, subProduct, restult, true);
            }
            ClosedActiveMonitoringSubProduct(session, subProduct);
        }
Ejemplo n.º 20
0
        private IExtractResult EVIAlgorithm1(Action <int, string> progressTracker)
        {
            int bands = _argumentProvider.DataProvider.BandCount;

            if (bands == 0 || bands == 1)
            {
                PrintInfo("请选择正确的局地文件进行计算。");
                return(null);
            }
            if (_argumentProvider.GetArg("Visible") == null)
            {
                PrintInfo("参数\"Visible\"为空。");
                return(null);
            }
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             bandV          = TryGetBandNo(bandNameRaster, "Visible");

            if (_argumentProvider.GetArg("NearInfrared") == null)
            {
                PrintInfo("参数\"NearInfrared\"为空。");
                return(null);
            }
            int bandN = TryGetBandNo(bandNameRaster, "NearInfrared");

            if (_argumentProvider.GetArg("Blue") == null)
            {
                PrintInfo("参数\"Blue\"为空。");
                return(null);
            }
            int bandB = TryGetBandNo(bandNameRaster, "Blue");

            if (bandV < 1 || bandB < 1 || bandN < 1 || bandV > bands || bandB > bands || bandN > bands)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            int bandMid = TryGetBandNo(bandNameRaster, "MiddInfrared");  //中红外
            int bandFar = TryGetBandNo(bandNameRaster, "FarInfrared11"); //远红外

            if (_argumentProvider.GetArg("Visible_Zoom") == null)
            {
                PrintInfo("参数\"Visible_Zoom\"为空。");
                return(null);
            }
            double visibleZoom = (double)_argumentProvider.GetArg("Visible_Zoom");

            if (_argumentProvider.GetArg("NearInfrared_Zoom") == null)
            {
                PrintInfo("参数\"NearInfrared_Zoom\"为空。");
                return(null);
            }
            double nearInfrared = (double)_argumentProvider.GetArg("NearInfrared_Zoom");

            if (_argumentProvider.GetArg("Blue_Zoom") == null)
            {
                PrintInfo("参数\"Blue_Zoom\"为空。");
                return(null);
            }
            double blueZoom = (double)_argumentProvider.GetArg("Blue_Zoom");
            double middZoom = (double)_argumentProvider.GetArg("MiddInfrared_Zoom");
            double farZoom  = (double)_argumentProvider.GetArg("FarInfrared11_Zoom");

            int[]    bandNos               = new int[] { bandV, bandN, bandB, bandMid, bandFar };
            double[] bandZoom              = new double[] { visibleZoom, nearInfrared, blueZoom, middZoom, farZoom };
            float    NearInfraredCLMMin    = float.Parse(_argumentProvider.GetArg("NearInfraredCLMMin").ToString());
            float    FarInfrared11CLMMax   = float.Parse(_argumentProvider.GetArg("FarInfrared11CLMMax").ToString());
            float    FarInfrared1112CLMMin = float.Parse(_argumentProvider.GetArg("FarInfrared1112CLMMin").ToString());

            float[] cloudyArgs = new float[] { NearInfraredCLMMin, FarInfrared11CLMMax, FarInfrared1112CLMMin };
            Int16   defCloudy  = (Int16)_argumentProvider.GetArg("defCloudy");
            float   zoom       = (ushort)_argumentProvider.GetArg("resultZoom");

            zoom = zoom == 0f ? 1000 : zoom;
            string[] aois        = _argumentProvider.GetArg("AOITemplate") as string[];
            string   aoiTemplate = (aois == null || aois.Length == 0) ? null : aois[0];

            string[] inputFiles = GetStringArray("RasterFile");
            if (inputFiles == null || inputFiles.Length == 0)
            {
                PrintInfo("没有设置输入数据");
                return(null);
            }
            bool isFitterCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isFilterCloudy").ToString(), out isFitterCloud))
            {
                PrintInfo("是否过滤云参数设置不正确!");
                return(null);
            }
            IExtractResultArray results = new ExtractResultArray("EVI");

            foreach (string inputFile in inputFiles)
            {
                //计算RVI
                IExtractResult ret = CalcEVIAlgorithm1(inputFile, bandNos, zoom, bandZoom, cloudyArgs, defCloudy, isFitterCloud, aoiTemplate, progressTracker);
                if (ret != null)
                {
                    results.Add(ret as IExtractResultBase);
                }
            }
            return(results);
        }
Ejemplo n.º 21
0
        public void HandleResult(IContextEnvironment contextEnvironment, IMonitoringProduct product, IMonitoringSubProduct subProduct, IExtractResult result)
        {
            (_session.MonitoringSession as IMonitoringSession).ChangeActiveSubProduct(subProduct.Identify);
            if (subProduct.Identify == "DBLV")//只有判识结果在叠加在影像上
            {
                (_session.MonitoringSession as IMonitoringSession).ExtractingSession.Start((_session.SmartWindowManager.ActiveCanvasViewer), product, subProduct);
                DisplayResultClass.DisplayResult(_session, subProduct, result, true);
            }
            else
            {
                DisplayResultClass.DisplayResult(_session, subProduct, result, true);
            }
            string fname;

            if (result is IPixelIndexMapper)
            {
                fname = (_session.MonitoringSession as IMonitoringSession).ExtractingSession.AddToWorkspace((_session.MonitoringSession as IMonitoringSession).Workspace);
                DisplayResultClass._contextEnvironment.PutContextVar(subProduct.Identify, fname);
            }
            else if (result is IExtractResultArray)
            {
                IExtractResultArray  extResultMapper = result as ExtractResultArray;
                IExtractResultBase[] mappers         = extResultMapper.PixelMappers;
                if (mappers == null || mappers.Length == 0)
                {
                    return;
                }
                foreach (IExtractResultBase mapper in mappers)
                {
                    if (mapper is IPixelIndexMapper)
                    {
                        fname = (_session.MonitoringSession as IMonitoringSession).ExtractingSession.AddToWorkspace((_session.MonitoringSession as IMonitoringSession).Workspace);
                        DisplayResultClass._contextEnvironment.PutContextVar(subProduct.Identify, fname);
                    }
                }
            }
            else if (result is IFileExtractResult && subProduct.Identify == "DBLV")
            {
                DisplayResultClass._contextEnvironment.PutContextVar(subProduct.Identify, (result as IFileExtractResult).FileName);
            }
        }
Ejemplo n.º 22
0
        private IExtractResult FRDSAlgorithm(Action <int, string> progressTracker)
        {
            string[] fileNames = GetStringArray("SelectedPrimaryFiles");
            if (fileNames == null || fileNames.Count() == 0)
            {
                PrintInfo("请选择参与积雪天数统计的数据!");
                return(null);
            }
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }
            int bandNo = 1;
            ExtractResultArray array = new ExtractResultArray("SNW");
            //输出文件准备(作为输入栅格并集处理)
            RasterIdentify ri          = GetRasterIdentifyID(ref fileNames);
            string         outFileName = ri.ToWksFullFileName(".dat");
            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();
            string             tempFilename;

            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    tempFilename = ProcessCloud(fileNames[i], bandNo);
                    IRasterDataProvider inRaster = RasterDataDriver.Open(tempFilename) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNo)
                    {
                        PrintInfo("请选择正确的数据进行积雪天数统计。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { tempFilename == fileNames[i] ? bandNo : 1 });
                    rms.Add(rm);
                }
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = null;
                    rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    Int16[] nanValues     = GetNanValues("CloudyValue");
                    Int16[] waterValues   = GetNanValues("WaterValue");
                    Int16[] invailValues  = GetNanValues("InvailValue");
                    Int16   currTimeValue = 0;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength         = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] timeValue      = new Int16[dataLength];
                        List <Int16> tempValue = new List <Int16>();
                        for (int i = 0; i < dataLength; i++)
                        {
                            timeValue[i] = 0;
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            foreach (RasterVirtualVistor <Int16> rvs in rvInVistor)
                            {
                                Int16[] dt = rvs.RasterBandsData[0];
                                if (dt == null)
                                {
                                    continue;
                                }
                                tempValue.Add(dt[index]);
                            }

                            if (tempValue.Count == 0)
                            {
                                continue;
                            }
                            if (TimeValue(tempValue.ToArray(), nanValues, invailValues, waterValues, out currTimeValue))
                            {
                                timeValue[index] = currTimeValue;
                            }
                            tempValue.Clear();
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            rvOutVistor[0].RasterBandsData[0][index] = timeValue[index];
                        }
                    }));
                    //执行
                    rfr.Excute(0);
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    array.Add(res);
                    res.SetDispaly(false);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }

            _argumentProvider.SetArg("SelectedPrimaryFiles", new string[] { outFileName });
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(array);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
            IExtractResult        ress     = ThemeGraphyByInstance(instance);

            if (ress != null)
            {
                array.Add(ress as IFileExtractResult);
            }
            return(array);
        }
Ejemplo n.º 23
0
        private IExtractResult EVIAlgorithm2(Action <int, string> progressTracker)
        {
            int bands = _argumentProvider.DataProvider.BandCount;

            if (bands == 0 || bands == 1)
            {
                PrintInfo("请选择正确的局地文件进行计算。");
                return(null);
            }
            if (_argumentProvider.GetArg("Visible") == null)
            {
                PrintInfo("参数\"Visible\"为空。");
                return(null);
            }
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             bandV          = TryGetBandNo(bandNameRaster, "Visible");

            if (_argumentProvider.GetArg("NearInfrared") == null)
            {
                PrintInfo("参数\"NearInfrared\"为空。");
                return(null);
            }
            int bandN = TryGetBandNo(bandNameRaster, "NearInfrared");

            if (_argumentProvider.GetArg("Blue") == null)
            {
                PrintInfo("参数\"Blue\"为空。");
                return(null);
            }
            int bandB = TryGetBandNo(bandNameRaster, "Blue");

            if (bandV < 1 || bandB < 1 || bandN < 1 || bandV > bands || bandB > bands || bandN > bands)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            if (_argumentProvider.GetArg("Visible_Zoom") == null)
            {
                PrintInfo("参数\"Visible_Zoom\"为空。");
                return(null);
            }
            double visibleZoom = (double)_argumentProvider.GetArg("Visible_Zoom");

            if (_argumentProvider.GetArg("NearInfrared_Zoom") == null)
            {
                PrintInfo("参数\"NearInfrared_Zoom\"为空。");
                return(null);
            }
            double nearInfrared = (double)_argumentProvider.GetArg("NearInfrared_Zoom");

            if (_argumentProvider.GetArg("Blue_Zoom") == null)
            {
                PrintInfo("参数\"Blue_Zoom\"为空。");
                return(null);
            }
            double blueZoom = (double)_argumentProvider.GetArg("Blue_Zoom");

            int[]    bandNos  = new int[] { bandV, bandN, bandB, };
            double[] bandZoom = new double[] { visibleZoom, nearInfrared, blueZoom };
            Dictionary <string, string> dic = Obj2Dic(_argumentProvider.GetArg("ArgumentSetting"));
            string nearVisiableMinStr       = dic.ContainsKey("NearVisableMin") ? dic["NearVisableMin"] : string.Empty;
            string nearVisiableMaxStr       = dic.ContainsKey("NearVisableMax") ? dic["NearVisableMax"] : string.Empty;
            string visibleMinStr            = dic.ContainsKey("VisibleMin") ? dic["VisibleMin"] : string.Empty;
            float  nearVisiableMin          = float.Parse(nearVisiableMinStr);
            float  nearVisiableMax          = float.Parse(nearVisiableMaxStr);
            float  visibleMin = float.Parse(visibleMinStr);

            float[] cloudyArgs = new float[] { visibleMin, nearVisiableMax, nearVisiableMin };
            Int16   defCloudy  = (Int16)_argumentProvider.GetArg("defCloudy");
            float   zoom       = (ushort)_argumentProvider.GetArg("resultZoom");

            zoom = zoom == 0f ? 1000 : zoom;
            string[] aois        = _argumentProvider.GetArg("AOITemplate") as string[];
            string   aoiTemplate = (aois == null || aois.Length == 0) ? null : aois[0];

            string[] inputFiles = GetStringArray("RasterFile");
            if (inputFiles == null || inputFiles.Length == 0)
            {
                PrintInfo("没有设置输入数据");
                return(null);
            }
            bool isFitterCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isFilterCloudy").ToString(), out isFitterCloud))
            {
                PrintInfo("是否过滤云参数设置不正确!");
                return(null);
            }
            IExtractResultArray results = new ExtractResultArray("EVI");

            foreach (string inputFile in inputFiles)
            {
                //计算RVI
                IExtractResult ret = CalcEVIAlgorithm2(inputFile, bandNos, zoom, bandZoom, cloudyArgs, defCloudy, isFitterCloud, aoiTemplate, progressTracker);
                if (ret != null)
                {
                    results.Add(ret as IExtractResultBase);
                }
            }
            return(results);
        }
Ejemplo n.º 24
0
        private IExtractResult CalcNDVIAlgorithm2(Action <int, string> progressTracker)
        {
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             bandV          = TryGetBandNo(bandNameRaster, "Visible");      //可见光
            int             bandNear       = TryGetBandNo(bandNameRaster, "NearInfrared"); //近红外

            if (bandV == -1 || bandNear == -1)
            {
                PrintInfo("通道序号设置不正确");
                return(null);
            }
            int[]  bandNos     = new int[] { bandV, bandNear };
            double visibleZoom = (double)_argumentProvider.GetArg("Visible_Zoom");
            double nearZoom    = (double)_argumentProvider.GetArg("NearInfrared_Zoom");

            double[] cloudyZoom             = new double[] { visibleZoom, nearZoom };
            Int16    defCloudy              = (Int16)_argumentProvider.GetArg("defCloudy");
            Dictionary <string, string> dic = Obj2Dic(_argumentProvider.GetArg("ArgumentSetting"));
            string nearVisiableMinStr       = dic.ContainsKey("NearVisableMin") ? dic["NearVisableMin"] : string.Empty;
            string nearVisiableMaxStr       = dic.ContainsKey("NearVisableMax") ? dic["NearVisableMax"] : string.Empty;
            string visibleMinStr            = dic.ContainsKey("VisibleMin") ? dic["VisibleMin"] : string.Empty;
            float  nearVisiableMin          = float.Parse(nearVisiableMinStr);
            float  nearVisiableMax          = float.Parse(nearVisiableMaxStr);
            float  visibleMin = float.Parse(visibleMinStr);

            float[] cloudyArgs = new float[] { visibleMin, nearVisiableMax, nearVisiableMin };
            float   zoom       = (ushort)_argumentProvider.GetArg("resultZoom");

            zoom = zoom == 0f ? 1000 : zoom;
            string[] aois        = _argumentProvider.GetArg("AOITemplate") as string[];
            string   aoiTemplate = (aois == null || aois.Length == 0) ? null : aois[0];

            string[] inputFiles = GetStringArray("RasterFile");
            bool     isFitterCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isFilterCloudy").ToString(), out isFitterCloud))
            {
                PrintInfo("是否过滤云参数设置不正确!");
                return(null);
            }
            if (inputFiles == null || inputFiles.Length == 0)
            {
                PrintInfo("没有设置输入数据");
                return(null);
            }
            bool isAppCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isAppCloud").ToString(), out isAppCloud))
            {
                PrintInfo("合并交互云参数设置不正确!");
                return(null);
            }
            IExtractResultArray results = new ExtractResultArray("NDVI");

            foreach (string inputFile in inputFiles)
            {
                //计算NDVI
                IExtractResult ret = CalcNDVIAgl2(inputFile, bandNos, zoom, cloudyZoom, cloudyArgs, defCloudy, isFitterCloud, isAppCloud, aoiTemplate, progressTracker);
                if (ret != null)
                {
                    results.Add(ret as IExtractResultBase);
                }
            }
            return(results);
        }
Ejemplo n.º 25
0
        private IExtractResult CalcNDVIAlgorithm1(Action <int, string> progressTracker)
        {
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             bandV          = TryGetBandNo(bandNameRaster, "Visible");       //可见光
            int             bandNear       = TryGetBandNo(bandNameRaster, "NearInfrared");  //近红外
            int             bandMid        = TryGetBandNo(bandNameRaster, "MiddInfrared");  //中红外
            int             bandFar        = TryGetBandNo(bandNameRaster, "FarInfrared11"); //远红外

            if (bandV == -1 || bandNear == -1 || bandMid == -1 || bandFar == -1)
            {
                PrintInfo("通道序号设置不正确");
                return(null);
            }
            int[]  bandNos               = new int[] { bandV, bandNear, bandMid, bandFar };
            double visibleZoom           = (double)_argumentProvider.GetArg("Visible_Zoom");
            double nearZoom              = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
            float  NearInfraredCLMMin    = float.Parse(_argumentProvider.GetArg("NearInfraredCLMMin").ToString());
            float  FarInfrared11CLMMax   = float.Parse(_argumentProvider.GetArg("FarInfrared11CLMMax").ToString());
            float  FarInfrared1112CLMMin = float.Parse(_argumentProvider.GetArg("FarInfrared1112CLMMin").ToString());

            float[] cloudyArgs = new float[] { NearInfraredCLMMin, FarInfrared11CLMMax, FarInfrared1112CLMMin };
            Int16   defCloudy  = (Int16)_argumentProvider.GetArg("defCloudy");
            double  middZoom   = (double)_argumentProvider.GetArg("MiddInfrared_Zoom");
            double  farZoom    = (double)_argumentProvider.GetArg("FarInfrared11_Zoom");

            double[] cloudyZoom = new double[] { nearZoom, middZoom, farZoom };
            float    zoom       = (ushort)_argumentProvider.GetArg("resultZoom");

            zoom = zoom == 0f ? 1000 : zoom;
            string[] aois        = _argumentProvider.GetArg("AOITemplate") as string[];
            string   aoiTemplate = (aois == null || aois.Length == 0) ? null : aois[0];

            string[] inputFiles = GetStringArray("RasterFile");
            bool     isFitterCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isFilterCloudy").ToString(), out isFitterCloud))
            {
                PrintInfo("是否过滤云参数设置不正确!");
                return(null);
            }
            if (inputFiles == null || inputFiles.Length == 0)
            {
                PrintInfo("没有设置输入数据");
                return(null);
            }
            bool isAppCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isAppCloud").ToString(), out isAppCloud))
            {
                PrintInfo("合并交互云参数设置不正确!");
                return(null);
            }
            IExtractResultArray results = new ExtractResultArray("NDVI");

            foreach (string inputFile in inputFiles)
            {
                //计算NDVI
                IExtractResult ret = CalcNDVI(inputFile, bandNos, zoom, cloudyZoom, cloudyArgs, defCloudy, isFitterCloud, isAppCloud, aoiTemplate, progressTracker);
                if (ret != null)
                {
                    results.Add(ret as IExtractResultBase);
                }
            }
            return(results);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 根据所选的文件提取产品标识和子产品标识,自动匹配应该生成的专题图类型,如ndvi
        /// </summary>
        /// <param name="session"></param>
        /// <param name="isCustom"></param>
        /// <param name="multiSelect"></param>
        /// <returns></returns>
        private static IExtractResult CreateThemeGraphyBase(ISmartSession session, string algorithmName, bool isCustom, bool multiSelect, bool isOriginal)
        {
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            if (msp == null)
            {
                return(null);
            }
            object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles");

            //从工作空间中获取选择的文件名
            if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName))
            {
                return(null);
            }
            string[] files = obj as string[];
            if (files == null || files.Length == 0)
            {
                if (File.Exists(obj.ToString()))
                {
                    files = new string[] { obj.ToString() }
                }
                ;
                else
                {
                    return(null);
                }
            }
            //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923
            foreach (string fname in files)
            {
                CanCreatThemegraph(fname);
            }
            string outFileIdentify = null;
            string templateName    = null;

            GetTemplateName(msp.Definition.SubProductInstanceDefs, files, multiSelect, isOriginal, out outFileIdentify, out templateName);
            if (string.IsNullOrEmpty(outFileIdentify) || string.IsNullOrEmpty(templateName))
            {
                return(null);
            }
            CoordEnvelope customEnv = null;

            if (isCustom && !SetAOIArugment(files, msp, multiSelect, out customEnv))
            {
                return(null);
            }
            else if (!isCustom)
            {
                msp.ArgumentProvider.SetArg("AOI", null);
            }
            IThemeGraphGenerator tgg = new GeoDo.RSS.MIF.Prds.Comm.CmaThemeGraphGenerator(session);

            if (customEnv != null)
            {
                RasterProject.PrjEnvelope prjEnvelope = new RasterProject.PrjEnvelope(customEnv.MinX, customEnv.MaxX, customEnv.MinY, customEnv.MaxY);
                msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope);
            }
            msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg);
            msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
            msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName);
            SetThemeEnvelope(tgg, customEnv);
            IExtractResult result = msp.Make(null);

            DisplayResultClass.DisplayResult(session, msp, result, false);
            return(result);
        }
Ejemplo n.º 27
0
        private static void DisplayPixelFeatureMapper(ISmartSession session, IMonitoringSubProduct subProduct, IExtractResult restult, bool openFile)
        {
            int    extHeaderSize = 0;
            object header        = null;

            GetExtHeader(subProduct, out extHeaderSize, out header);
            if (restult is IPixelFeatureMapper <float> )
            {
                IPixelFeatureMapper <float> ifm = restult as IPixelFeatureMapper <float>;
                RasterIdentify rid = GetRasterIdentifyID(session);
                if (!string.IsNullOrEmpty(ifm.Name) && ifm.Name != rid.SubProductIdentify)
                {
                    rid.SubProductIdentify = ifm.Name;
                }
                //文件已存在,并且使用感兴趣区域时,使用更新感兴趣区域值的方式。

                IInterestedRaster <float> iir = new InterestedRaster <float>(rid, ifm.Size, ifm.CoordEnvelope, ifm.SpatialRef, extHeaderSize);
                subProduct.SetExtHeader(iir, header);
                iir.Put(ifm);
                iir.Dispose();
                TryOrbitToWorkspace(session);
                //if (openFile && NeedOpenFile())
                //    TryOpenFile(session, iir.FileName);
                RecordFileForAfterProcess(iir.FileName);
                TrySaveFileToWorkspace(subProduct, session, iir.FileName, restult, null);
            }
            else if (restult is IPixelFeatureMapper <int> )
            {
                IPixelFeatureMapper <int> ifm = restult as IPixelFeatureMapper <int>;
                RasterIdentify            rid = GetRasterIdentifyID(session);
                IInterestedRaster <int>   iir = new InterestedRaster <int>(rid, ifm.Size, ifm.CoordEnvelope, ifm.SpatialRef, extHeaderSize);
                iir.Put(ifm);
                iir.Dispose();
                TryOrbitToWorkspace(session);
                if (openFile && NeedOpenFile())
                {
                    TryOpenFile(session, iir.FileName);
                }
                RecordFileForAfterProcess(iir.FileName);
                TrySaveFileToWorkspace(subProduct, session, iir.FileName, restult, null);
            }
            else if (restult is IPixelFeatureMapper <UInt16> )
            {
                IPixelFeatureMapper <UInt16> ifm = restult as IPixelFeatureMapper <UInt16>;
                RasterIdentify             rid   = GetRasterIdentifyID(session);
                IInterestedRaster <UInt16> iir   = new InterestedRaster <UInt16>(rid, ifm.Size, ifm.CoordEnvelope, ifm.SpatialRef, extHeaderSize);
                iir.Put(ifm);
                iir.Dispose();
                TryOrbitToWorkspace(session);
                //if (openFile && NeedOpenFile())
                //    TryOpenFile(session, iir.FileName);
                RecordFileForAfterProcess(iir.FileName);
                TrySaveFileToWorkspace(subProduct, session, iir.FileName, restult, null);
            }
            else if (restult is IPixelFeatureMapper <Int16> )
            {
                IPixelFeatureMapper <Int16> ifm = restult as IPixelFeatureMapper <Int16>;
                RasterIdentify            rid   = GetRasterIdentifyID(session);
                IInterestedRaster <Int16> iir   = new InterestedRaster <Int16>(rid, ifm.Size, ifm.CoordEnvelope, ifm.SpatialRef, extHeaderSize);
                iir.Put(ifm);
                iir.Dispose();
                TryOrbitToWorkspace(session);
                //if (openFile && NeedOpenFile())
                //    TryOpenFile(session, iir.FileName);
                RecordFileForAfterProcess(iir.FileName);
                TrySaveFileToWorkspace(subProduct, session, iir.FileName, restult, null);
            }
            ClearExtHeader(subProduct);
        }
Ejemplo n.º 28
0
        public static IExtractResult CreateThemeGraphyBase(ISmartSession session, string algorithmName, string outFileIdentify, string colorTableName, string dataIdentify, string templateName, bool isCustom, bool multiSelect, Dictionary <string, string> aoiTemplateList)
        {
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            if (msp == null)
            {
                return(null);
            }
            object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles");

            //if (obj == null)
            //{
            if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName))
            {
                return(null);
            }
            //}
            string[] files = obj as string[];
            if (files == null || files.Length == 0)
            {
                if (File.Exists(obj.ToString()))
                {
                    files = new string[] { obj.ToString() }
                }
                ;
                else
                {
                    return(null);
                }
            }
            //by chennan 20130319 根据需要查找相应文件
            UpdateFilesByDataIdentify(ref files, dataIdentify);
            //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923
            foreach (string fname in files)
            {
                CanCreatThemegraph(fname);
            }
            msp.ArgumentProvider.SetArg("SelectedPrimaryFiles", files);
            if (isCustom && !SetAOIArugment(files, msp, multiSelect, aoiTemplateList))
            {
                return(null);
            }
            else if (!isCustom)
            {
                msp.ArgumentProvider.SetArg("AOI", null);
            }
            //IThemeGraphGenerator tgg = (session.MonitoringSession as IMonitoringSession).ThemeGraphGenerator;
            IThemeGraphGenerator tgg = new GeoDo.RSS.MIF.Prds.Comm.CmaThemeGraphGenerator(session);

            msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg);
            msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
            msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName);
            if (!string.IsNullOrEmpty(colorTableName))
            {
                msp.ArgumentProvider.SetArg("colortablename", "colortablename=" + colorTableName);
            }
            IExtractResult result = msp.Make(null);

            DisplayResultClass.DisplayResult(session, msp, result, false);
            return(result);
        }
Ejemplo n.º 29
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);
                    }
                }
            }
        }
Ejemplo n.º 30
0
 /// <summary>
 /// NDVI\0RVI\0DVI\0EVI
 /// 0VCI
 /// </summary>
 /// <param name="args"></param>
 public void Make(string subproduct, string ldfFile, string outfile)
 {
     PrintInfo("启动计算");
     try
     {
         //LstArgs arg = new LstArgs(args);
         //if (arg == null)
         //    PrintInfo("输入参数为空,计算终止");
         //string ldf = arg.LdfFile;
         //string ndvi = arg.NDVIFile;
         //string outfile = arg.OutFile;
         if (string.IsNullOrWhiteSpace(subproduct))
         {
             PrintInfo("输出文件设置为空,计算终止");
             return;
         }
         if (string.IsNullOrWhiteSpace(ldfFile))
         {
             PrintInfo("输入ldf局地文件为空,计算终止");
             return;
         }
         if (string.IsNullOrWhiteSpace(outfile))
         {
             PrintInfo("输出文件设置为空,计算终止");
             return;
         }
         string subProductId = subproduct;
         string rstFileName  = ldfFile;
         //int zoomValue = 1;
         //int.TryParse(zoom, out zoomValue);
         IMonitoringSubProduct subprd = CreateMonitoringSubProduct(rstFileName, "VGT", subProductId);
         if (subprd == null)
         {
             PrintInfo(string.Format("创建子产品[{0}]失败,计算终止", subProductId));
             return;
         }
         string resultFile = null;
         //下面需要设置文件来源参数
         using (IRasterDataProvider raster = GeoDataDriver.Open(rstFileName) as IRasterDataProvider)
         {
             subprd.ArgumentProvider.DataProvider = raster;
             subprd.ArgumentProvider.SetArg("RasterFile", rstFileName);
             subprd.ArgumentProvider.SetArg("OutFile", outfile);
             IExtractResult result = subprd.Make(null, _context);
             if (result is ExtractResultArray)
             {
                 resultFile = ((result as ExtractResultArray).PixelMappers[0] as IFileExtractResult).FileName;
             }
         }
         //搬运文件,或者裁切文件。
         TryCutFile(resultFile, outfile);
     }
     catch (Exception ex)
     {
         PrintInfo(ex.Message);
     }
     finally
     {
         PrintInfo("结束计算");
     }
 }