Beispiel #1
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);
            }
        }
Beispiel #2
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);
        }