Esempio n. 1
0
        void oprBar_Click(object sender, EventArgs e)
        {
            ICatalog             c          = _catalogs[(sender as ToolStripButton).Tag.ToString()];
            SubProductCatalogDef catalogDef = c.Definition as SubProductCatalogDef;
            string filter = catalogDef.Filter;

            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter           = filter;
                dlg.Multiselect      = true;
                dlg.InitialDirectory = MifEnvironment.GetWorkspaceDir();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    string[] fnames = dlg.FileNames;
                    if (fnames == null || fnames.Length == 0)
                    {
                        return;
                    }
                    foreach (string f in fnames)
                    {
                        c.AddItem(new CatalogItem(f, catalogDef, null));
                    }
                }
            }
        }
Esempio n. 2
0
        private void SearchData()
        {
            string dir        = Path.Combine(MifEnvironment.GetWorkspaceDir(), _productIdentify);
            string data       = DateTime.Now.ToString("yyyy-MM-dd");
            string prdRootDir = Path.Combine(dir, data);

            string[] files = Directory.GetFiles(prdRootDir, "*.*", SearchOption.AllDirectories);
            if (files == null || files.Length == 0)
            {
                return;
            }
            DateTime startTime, endTime;

            GetReportTime(out startTime, out endTime);
            List <string>  fileList  = new List <string>();
            string         reportDir = CreateSubFoldername();
            RasterIdentify rid       = null;

            foreach (string file in files)
            {
                rid = new RasterIdentify(file);
                if (rid.GenerateDateTime >= startTime && rid.GenerateDateTime <= endTime)
                {
                    fileList.Add(file);
                    CopyFile(reportDir, file);
                }
            }
            SaveToDb(reportDir);
        }
Esempio n. 3
0
 public override string[] Find(string currentRasterFile, ref string extinfo, string argument)
 {
     argDic = new Dictionary <string, string>();
     if (ParseArugment(argument, out argDic))
     {
         DateTime orbitDatetime = DateTime.Now;
         if (GetOrbitDatetime(currentRasterFile, out orbitDatetime))
         {
             string WorkDir = MifEnvironment.GetWorkspaceDir() + "\\" + "FLD" + "\\";
             if (argDic.ContainsKey("MONTHS"))
             {
                 string   monthStr    = argDic["MONTHS"];
                 int      months      = 0;
                 DateTime dstDatetime = DateTime.MinValue;
                 if (int.TryParse(monthStr, out months))
                 {
                     dstDatetime = orbitDatetime.AddMonths(months);
                 }
                 string searchStr = JointFindStr(dstDatetime);
             }
             else if (argDic.ContainsKey("DAYS"))
             {
                 string   dayStr      = argDic["DAYS"];
                 int      days        = 0;
                 DateTime dstDatetime = DateTime.MinValue;
                 if (int.TryParse(dayStr, out days))
                 {
                     dstDatetime = orbitDatetime.AddDays(days);
                 }
                 string searchStr = JointFindStr(dstDatetime);
             }
         }
     }
     return(null);
 }
Esempio n. 4
0
        /// <summary>
        /// 加载指定日期目录下的产品待入库文件
        /// yyyy-MM-dd\
        /// </summary>
        /// <param name="dt"></param>
        private void LoadTodayExtractResult(DateTime dt)
        {
            _catalogNodes.Clear();
            _treeView.Nodes.Clear();
            string dir = Path.Combine(MifEnvironment.GetWorkspaceDir(), wDef.Identify);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string dateDir = Path.Combine(dir, dt.ToString("yyyy-MM-dd"));

            if (!Directory.Exists(dateDir))
            {
                Directory.CreateDirectory(dateDir);
            }
            RadTreeNode rootNode = new RadTreeNode((new DirectoryInfo(dateDir)).Name);

            rootNode.Font = _font;
            _treeView.Nodes.Add(rootNode);
            ExtractingCatalogDef c = _definition as ExtractingCatalogDef;

            foreach (CatalogNodeItemDef it in (c.NodeDefs[0] as CatalogNodeGroupDef).NodeDefs)
            {
                LoadFiles(it, rootNode, dateDir);
            }
            rootNode.ExpandAll();
        }
Esempio n. 5
0
        private void LoadSubProductItems()
        {
            string wkddir     = MifEnvironment.GetWorkspaceDir();
            string catalogDir = Path.Combine(wkddir, _wks.Definition.Identify);

            if (!Directory.Exists(catalogDir))
            {
                return;
            }
            string[] dateFolders = Directory.GetDirectories(catalogDir);
            dateFolders = FilterByDate(dateFolders);
            string dir;
            SubProductCatalogDef def = _definition as SubProductCatalogDef;

            foreach (string dateDir in dateFolders)
            {
                string date = (new DirectoryInfo(dateDir)).Name;
                dir = Path.Combine(dateDir, def.Folder);
                if (!Directory.Exists(dir))
                {
                    continue;
                }
                string[] fnames = GetFiles(dir, def.Identify, def.Pattern, true);
                if (fnames != null && fnames.Length > 0)
                {
                    foreach (string f in fnames)
                    {
                        AddFileToUI(date, f);
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 加载指定日期目录下的产品待入库文件
        /// \Workspace\{PrdIdentify}\yyyy-MM-dd\...
        /// </summary>
        /// <param name="dt"></param>
        private void LoadTheDayExtractResult(DateTime dt)
        {
            _catalogNodes.Clear();
            _treeView.Nodes.Clear();

            string      dir        = Path.Combine(MifEnvironment.GetWorkspaceDir(), _wDef.Identify);
            string      data       = dt.ToString("yyyy-MM-dd");
            string      prdRootDir = Path.Combine(dir, data);
            RadTreeNode rootNode   = new RadTreeNode(data);

            rootNode.Font = _font;
            _treeView.Nodes.Add(rootNode);

            //区域名称,时间,文件
            Dictionary <string, Dictionary <string, List <string> > > fileClassic = null;

            if (Directory.Exists(prdRootDir))
            {
                //整理产品数据,用于TreeView
                fileClassic = ClassicFiles(prdRootDir, rootNode, fileClassic);
                if (fileClassic != null)
                {
                    FullTreeView(rootNode, fileClassic);
                }
            }
            rootNode.ExpandAll();
        }
Esempio n. 7
0
 private static string CreatOutFile()
 {
     //string dir = AppDomain.CurrentDomain.BaseDirectory + "\\TEMP";
     //if (!Directory.Exists(dir))
     //    Directory.CreateDirectory(dir);
     //return dir + "\\" + Guid.NewGuid().ToString() + ".dat";
     return(MifEnvironment.GetFullFileName(Guid.NewGuid().ToString() + ".dat"));
 }
Esempio n. 8
0
        public static void TestFromRaster(IRasterDataProvider raster)
        {
            string filename = Path.GetFileNameWithoutExtension(raster.fileName) + "_" + 1;

            filename = MifEnvironment.GetFullFileName(filename + ".ldf");
            IRasterDataProvider oraster = RasterMosaic.CreateRaster(filename, raster.CoordEnvelope, raster.ResolutionX * 2, raster.ResolutionY * 2, 1, raster);

            CloudsatToRaster.test(oraster);
            oraster.Dispose();
        }
Esempio n. 9
0
        private string[] GetFiles()
        {
            string dir = MifEnvironment.GetWorkspaceDir() + @"\VGT\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\栅格产品\\";

            if (!Directory.Exists(dir))
            {
                return(null);
            }
            return(Directory.GetFiles(dir, "*.dat", SearchOption.TopDirectoryOnly));
        }
Esempio n. 10
0
 public ReportPageControl()
 {
     InitializeComponent();
     _radPageView.Font = this.Font;
     _radPageView.Dock = DockStyle.Fill;
     _radPageView.ViewElement.ShowItemCloseButton = false;
     this.panel1.Controls.Add(_radPageView);
     _reportPath = MifEnvironment.GetReportDir();
     CreateSubFoldername();
 }
Esempio n. 11
0
        /// <summary>
        /// 加载指定日期目录下的产品待入库文件
        /// \Workspace\{PrdIdentify}\yyyy-MM-dd\...
        /// </summary>
        /// <param name="dt"></param>
        private void LoadTheDayExtractResult(DateTime dt)
        {
            _catalogNodes.Clear();
            _treeView.Nodes.Clear();

            string      dir        = Path.Combine(MifEnvironment.GetWorkspaceDir(), _wDef.Identify);
            string      data       = dt.ToString("yyyy-MM-dd");
            string      prdRootDir = Path.Combine(dir, data);
            RadTreeNode rootNode   = new RadTreeNode(data);

            rootNode.Font = _font;
            _treeView.Nodes.Add(rootNode);

            if (Directory.Exists(prdRootDir))
            {
                foreach (CatalogDef catalogDef in _wDef.CatalogDefs)
                {
                    if (catalogDef is SubProductCatalogDef)//子产品目录
                    {
                        SubProductCatalogDef subProductdef = catalogDef as SubProductCatalogDef;
                        string      subProductDir          = Path.Combine(prdRootDir, subProductdef.Folder);
                        RadTreeNode subProductNode         = new RadTreeNode(subProductdef.Text);
                        subProductNode.Tag         = subProductdef;
                        subProductNode.ToolTipText = subProductDir;
                        subProductNode.Font        = _font;
                        subProductNode.Image       = GetImge("Open");
                        rootNode.Nodes.Add(subProductNode);
                        string[] files = GetFiles(subProductDir, subProductdef.Identify, subProductdef.Pattern, false);
                        if (files != null && files.Length > 0)
                        {
                            foreach (string file in files)
                            {
                                ICatalogItem ca = new CatalogItem(file, subProductdef);
                                if (!_showHasToDb && ca.Info.GetPropertyValue(ToDBInfoKey) == ToDBInfoValue)//是否标记为已入库
                                {
                                    continue;
                                }
                                RadTreeNode fileNode = new RadTreeNode(GetCatalogCN(file));
                                fileNode.Tag         = file;
                                fileNode.ToolTipText = Path.GetFileName(file);
                                fileNode.Image       = GetImge(Path.GetExtension(file).ToUpper());
                                fileNode.CheckType   = CheckType.CheckBox;
                                fileNode.Checked     = true;
                                subProductNode.Nodes.Add(fileNode);
                            }
                        }
                    }
                }
            }
            else
            {
                rootNode.Nodes.Add(new RadTreeNode("当期日期下没有产品生成"));
            }
            rootNode.ExpandAll();
        }
Esempio n. 12
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);
            }
        }
Esempio n. 13
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            if (_maskObj != null)
            {
                _maskObj.Dispose();
            }
            _datValue = null;
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter           = "SMART Raster(*.dat)|*.dat|矢量数据(*.shp)|*.shp";
                dlg.InitialDirectory = Path.Combine(MifEnvironment.GetWorkspaceDir(), "\\FLD");
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    string filename = dlg.FileName;
                    string extName  = Path.GetExtension(filename).ToUpper();
                    switch (extName)
                    {
                    case ".SHP":
                        LoadMaskTemplateFromShapeFile(filename);
                        if (_maskObj != null)
                        {
                            txtFileName.Text = _maskObj.FieldNames[0];
                        }
                        _filename = filename;
                        return;

                    case ".DAT":
                        using (IRasterDataProvider udr = RasterDataDriver.Open(dlg.FileName) as IRasterDataProvider)
                        {
                            //if (udr == null || ((Math.Abs(Math.Round(udr.CoordEnvelope.MinX, 4) - Math.Round(_leftUpCoord.X, 4)) > udr.ResolutionX
                            //         || Math.Abs(Math.Round(udr.CoordEnvelope.MaxY, 4) - Math.Round(_leftUpCoord.Y, 4)) > udr.ResolutionY)
                            //     || udr.Width != _size.Width
                            //     || udr.Height != _size.Height
                            //     || udr.ResolutionX - _resolution > 1.0E-15
                            //     || udr.ResolutionY - _resolution > 1.0E-15))
                            //{
                            //    //MsgBox.ShowInfo("选择的背景水体与当前水体位置信息不一致,请重新选择!");
                            //    return;
                            //}
                            txtFileName.Text = Path.GetFileNameWithoutExtension(filename);
                            _filename        = filename;
                        }
                        break;

                    default:
                        return;
                    }
                }
            }
        }
Esempio n. 14
0
        public static string GetWorkspaceFileName(RasterIdentify identify)
        {
            string dir = Path.Combine(MifEnvironment.GetWorkspaceDir(), identify.ProductIdentify);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            dir = Path.Combine(dir, DateTime.Now.ToString("yyyy-MM-dd"));
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            return(identify.ToWksFullFileName(".dat"));
        }
Esempio n. 15
0
        private string CreateSubFoldername()
        {
            string baseDir       = MifEnvironment.GetReportDir() + "\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
            string folderTemp    = baseDir + "新素材信息-";
            string newFoldername = folderTemp + "1";
            int    index         = 1;

            while (Directory.Exists(newFoldername))
            {
                index++;
                newFoldername = folderTemp + index;
            }
            Directory.CreateDirectory(newFoldername);
            return(newFoldername);
        }
Esempio n. 16
0
        protected string FindCloudExtractResult(string inputFileName)
        {
            string         dirName     = Path.Combine(MifEnvironment.GetWorkspaceDir(), "VGT");
            RasterIdentify rstIdentify = GetRasterIdentify(inputFileName);
            string         fname       = InterestedRaster <Int16> .GetWorkspaceFileName(rstIdentify);

            string[] cloudFiles = Directory.GetFiles(dirName, Path.GetFileName(fname), SearchOption.AllDirectories);
            if (cloudFiles != null && cloudFiles.Length > 0)
            {
                return(cloudFiles[0]);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 17
0
 private bool GetBitmapAndSave(ICanvas canvas, out string fileName, out int width, out int height)
 {
     fileName = null;
     width    = 0;
     height   = 0;
     System.Drawing.Bitmap bitmap = canvas.FullRasterRangeToBitmap();
     if (bitmap == null)
     {
         return(false);
     }
     fileName = MifEnvironment.GetFullFileName(Guid.NewGuid().ToString() + ".bmp");
     width    = bitmap.Width;
     height   = bitmap.Height;
     if (bitmap == null)
     {
         return(false);
     }
     bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
     return(true);
 }
Esempio n. 18
0
        private bool GetOrginBmpAndSave(ICanvas canvas, out string fileName, out int width, out int height)
        {
            fileName = null;
            width    = 0;
            height   = 0;
            System.Drawing.Bitmap bitmap = (canvas.PrimaryDrawObject as IRasterDrawing).GetBitmapUseOriginResolution();
            if (bitmap == null)
            {
                return(false);
            }
            string ofilename = (canvas.PrimaryDrawObject as IRasterDrawing).FileName;

            fileName = MifEnvironment.GetFullFileName(Guid.NewGuid().ToString() + ".bmp");
            width    = bitmap.Width;
            height   = bitmap.Height;
            if (bitmap == null)
            {
                return(false);
            }
            bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
            return(true);
        }
Esempio n. 19
0
        private unsafe IRasterDataProvider GetSameSizeDataProvider(IRasterDataProvider bigDataProvider, IRasterDataProvider smallDataProvider)
        {
            double minX        = smallDataProvider.CoordEnvelope.MinX;
            double maxX        = smallDataProvider.CoordEnvelope.MaxX;
            double minY        = smallDataProvider.CoordEnvelope.MinY;
            double maxY        = smallDataProvider.CoordEnvelope.MaxY;
            double bigDataMinX = bigDataProvider.CoordEnvelope.MinX;
            double bigDataMaxX = bigDataProvider.CoordEnvelope.MaxX;
            double bigDataMinY = bigDataProvider.CoordEnvelope.MinY;
            double bigDataMaxY = bigDataProvider.CoordEnvelope.MaxY;

            if (maxY > bigDataMaxY || minY < bigDataMinY || maxX > bigDataMaxX || minX < bigDataMinX)
            {
                return(null);
            }
            int beginRow = (int)((bigDataProvider.CoordEnvelope.MaxY - maxY) / bigDataProvider.ResolutionY);
            int beginCol = (int)((minX - bigDataProvider.CoordEnvelope.MinX) / bigDataProvider.ResolutionX);
            int rows     = (int)Math.Round(((maxY - minY) / bigDataProvider.ResolutionY), 0);
            int cols     = (int)Math.Round(((maxX - minX) / bigDataProvider.ResolutionX), 0);

            byte[] dataBlock   = new byte[smallDataProvider.Width * smallDataProvider.Height];
            string dstFileName = MifEnvironment.GetFullFileName("1.ldf");

            fixed(byte *buffer = dataBlock)
            {
                IntPtr ptr = new IntPtr(buffer);

                bigDataProvider.GetRasterBand(1).Read(beginCol, beginRow, cols, rows, ptr, enumDataType.Byte, smallDataProvider.Width, smallDataProvider.Height);
                using (IRasterDataDriver drv = GeoDataDriver.GetDriverByName("LDF") as IRasterDataDriver)
                {
                    IRasterDataProvider prdWriter = drv.Create(dstFileName, smallDataProvider.Width, smallDataProvider.Height, 1,
                                                               enumDataType.Byte, "INTERLEAVE=BSQ", "VERSION=LDF", "WITHHDR=TRUE", "SPATIALREF=" + GetSpatialRefString(bigDataProvider),
                                                               GetMapInfoString(smallDataProvider.CoordEnvelope, smallDataProvider.Width, smallDataProvider.Height)) as IRasterDataProvider;
                    IRasterBand band = prdWriter.GetRasterBand(1);
                    band.Write(0, 0, band.Width, band.Height, ptr, enumDataType.Byte, band.Width, band.Height);
                    return(prdWriter);
                }
            }
        }
Esempio n. 20
0
        private string MAxValue(Action <int, string> progressTracker, string[] fileNames, int bandNo, float zoom)
        {
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }

            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    IRasterDataProvider inRaster = RasterDataDriver.Open(fileNames[i]) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNo)
                    {
                        PrintInfo("请选择正确的数据进行最大值合成。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { bandNo });
                    rms.Add(rm);
                }
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri = new RasterIdentify(fileNames);
                ri.GenerateDateTime = DateTime.Now;
                string outFileName            = MifEnvironment.GetFullFileName(ri.ToWksFileName(".dat"));
                IRasterDataProvider outRaster = null;
                try
                {
                    outRaster = CreateOutRaster(outFileName, rms.ToArray());
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength  = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] maxData = new Int16[dataLength];
                        foreach (RasterVirtualVistor <Int16> rv in rvInVistor)
                        {
                            if (rv.RasterBandsData == null)
                            {
                                continue;
                            }
                            Int16[] dt = rv.RasterBandsData[0];
                            if (dt != null)
                            {
                                for (int index = 0; index < dataLength; index++)
                                {
                                    if (dt[index] > maxData[index])
                                    {
                                        maxData[index] = dt[index];
                                        rvOutVistor[0].RasterBandsData[0][index] = maxData[index];
                                    }
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    return(outFileName);
                }
                finally
                {
                    outRaster.Dispose();
                    outRaster = null;
                }
            }
            finally
            {
                if (rms.Count != 0)
                {
                    foreach (RasterMaper rm in rms)
                    {
                        if (rm.Raster != null)
                        {
                            rm.Raster.Dispose();
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        private string ComputeBackgroudImage(Action <int, string> processTracker)
        {
            List <string> computeFiles = new List <string>();

            foreach (FileItem item in listBox1.Items)
            {
                computeFiles.Add(item.FileName);
            }
            if (computeFiles == null || computeFiles.Count < 1)
            {
                return(null);
            }
            foreach (string item in computeFiles)
            {
                if (!File.Exists(item))
                {
                    MessageBox.Show("所选择的数据:\"" + item + "\"不存在。");
                    return(null);
                }
            }
            IArgumentProvider argPrd = Tag as IArgumentProvider;

            if (argPrd == null)
            {
                return(null);
            }
            int visiNo = (int)argPrd.GetArg("Visible");
            int midNo2 = (int)argPrd.GetArg("MiddleInfrared2");
            int farNo1 = (int)argPrd.GetArg("FarInfrared11");
            int farNo2 = (int)argPrd.GetArg("FarInfrared12");

            int[] bandNos          = new int[] { farNo1, farNo2, midNo2, visiNo };
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                for (int i = 0; i < computeFiles.Count; i++)
                {
                    IRasterDataProvider inRaster = RasterDataDriver.Open(computeFiles[i]) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNos.Length)
                    {
                        MessageBox.Show("请选择正确的数据进行背景亮温计算。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, bandNos);
                    rms.Add(rm);
                }
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri          = new RasterIdentify(_dataProvider.fileName);
                string         outFileName = MifEnvironment.GetFullFileName(Path.GetFileName(ri.ToWksFullFileName(".ldf")));
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, bandNos.Length))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns    = rms.ToArray();
                    List <int>    bandNoList = new List <int>();
                    for (int i = 1; i <= bandNos.Length; i++)
                    {
                        bandNoList.Add(i);
                    }
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, bandNoList.ToArray()) };
                    //创建处理模型
                    RasterProcessModel <short, short> rfr = null;
                    rfr = new RasterProcessModel <short, short>(null);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.RegisterCalcModel(new RasterCalcHandler <short, short>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        for (int j = 0; j < rvInVistor.Length; j++)
                        {
                            for (int i = 0; i < bandNos.Length; i++)
                            {
                                short[] dt = rvInVistor[j].RasterBandsData[i];
                                if (dt != null)
                                {
                                    for (int index = 0; index < dt.Length; index++)
                                    {
                                        if (dt[index] > rvOutVistor[0].RasterBandsData[i][index])
                                        {
                                            rvOutVistor[0].RasterBandsData[i][index] = dt[index];
                                        }
                                    }
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    return(outFileName);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Esempio n. 22
0
        private IExtractResult LAODAlgorithm(Action <int, string> progressTracker)
        {
            IRasterOperator <Int16> roper = new RasterOperator <Int16>();

            string[] files = GetStringArray("SelectedPrimaryFiles");
            if (files == null || files.Length == 0)
            {
                return(null);
            }
            string[] argFileArg  = _argumentProvider.GetArg("RegionFileName") as string[];
            string   argFileName = argFileArg[0];

            if (string.IsNullOrEmpty(argFileName))
            {
                PrintInfo("请设置等级参数文件!");
                return(null);
            }
            SortedDictionary <float, float[]> levelRegions = GetArgFileRegion(argFileName);

            if (levelRegions == null || levelRegions.Count == 0)
            {
                return(null);
            }
            string AODFile = Convert.ToString(_argumentProvider.GetArg("AODFile"));

            if (string.IsNullOrWhiteSpace(AODFile))
            {
                return(null);
            }
            string[] aodFiles = AODFile.Split(new char[] { ',' });
            if (aodFiles.Length != 2)
            {
                return(null);
            }
            string             aodFile        = aodFiles[0];
            int                bandNo         = 1;
            IBandNameRaster    bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int                aodNo          = TryGetBandNo(bandNameRaster, "AODNO");
            List <RasterMaper> rms            = new List <RasterMaper>();

            try
            {
                IRasterDataProvider dblv   = RasterDataDriver.Open(files[0]) as IRasterDataProvider;
                RasterMaper         rmDBLV = new RasterMaper(dblv, new int[] { bandNo });
                rms.Add(rmDBLV);
                IRasterDataProvider aod = RasterDataDriver.Open(aodFile) as IRasterDataProvider;
                if (aod.BandCount < bandNo)
                {
                    PrintInfo("请选择正确的AOD数据进行定量产品计算。");
                    return(null);
                }
                RasterMaper rmAOD = new RasterMaper(aod, new int[] { aodNo });
                rms.Add(rmAOD);
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri          = GetRasterIdentifyID(files);
                string         outFileName = MifEnvironment.GetTempDir() + "\\" + ri.ToWksFileName(".dat");
                bool           isVaild     = false;
                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);
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        for (int index = 0; index < dataLength; index++)
                        {
                            if (rvInVistor[0].RasterBandsData != null && rvInVistor[0].RasterBandsData[0] != null &&
                                rvInVistor[0].RasterBandsData[0][index] != 0)
                            {
                                if (rvInVistor[1].RasterBandsData != null && rvInVistor[1].RasterBandsData[0] != null)
                                {
                                    foreach (float minValue in levelRegions.Keys)
                                    {
                                        if (rvInVistor[1].RasterBandsData[0][index] >= minValue && rvInVistor[1].RasterBandsData[0][index] < levelRegions[minValue][0])
                                        {
                                            rvOutVistor[0].RasterBandsData[0][index] = (Int16)levelRegions[minValue][1];
                                            isVaild = true;
                                        }
                                    }
                                    if (!isVaild)
                                    {
                                        rvOutVistor[0].RasterBandsData[0][index] = (Int16)1;
                                    }
                                    isVaild = false;
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    if (File.Exists(outFileName))
                    {
                        string dstFilename = ri.ToWksFullFileName(".dat");
                        CopyFileToDstDir(outFileName, dstFilename);
                        FileExtractResult res = new FileExtractResult(_subProductDef.Identify, dstFilename, true);
                        res.SetDispaly(false);
                        CreateThemegrahic(dstFilename);
                        return(res);
                    }
                    return(null);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Esempio n. 23
0
        private IExtractResult HFIIAlgorithmCompute(Action <int, string> progressTracker)
        {
            MemPixelFeatureMapper <UInt16> resultTemp = null;
            int    LstBandCH   = (int)_argumentProvider.GetArg("LstBand");
            double LstBandZoom = (double)_argumentProvider.GetArg("LstBand_Zoom");
            double HFIIZoom    = (double)_argumentProvider.GetArg("HFIIZoom");
            UInt16 defCloudy   = (UInt16)_argumentProvider.GetArg("defCloudy");
            UInt16 defWater    = (UInt16)_argumentProvider.GetArg("defWater");
            UInt16 minCount    = (UInt16)(_argumentProvider.GetArg("minCount"));

            UInt16[] nanValues   = GetNanValues("CloudyValue");
            UInt16[] waterValues = GetNanValues("WaterValue");
            float    LSTMin      = (float)((float.Parse(_argumentProvider.GetArg("VaildMin").ToString()) + 273) * LstBandZoom);
            float    LSTMax      = (float)((float.Parse(_argumentProvider.GetArg("VaildMax").ToString()) + 273) * LstBandZoom);
            string   lstFile     = GetStringArg("LSTFile");

            if (string.IsNullOrEmpty(lstFile) || !File.Exists(lstFile))
            {
                PrintInfo("获取数据失败,没有设定地表高温数据或数据不存在。");
                return(null);
            }
            Dictionary <UInt16, int> vaildLstList = new Dictionary <UInt16, int>();
            IRasterDataProvider      currPrd      = GeoDataDriver.Open(lstFile) as IRasterDataProvider;
            IRasterDataProvider      cloudPrd     = null;
            ArgumentProvider         ap           = new ArgumentProvider(currPrd, null);

            resultTemp = new MemPixelFeatureMapper <UInt16>("HFII", 1000, new Size(currPrd.Width, currPrd.Height), currPrd.CoordEnvelope, currPrd.SpatialRef);
            RasterPixelsVisitor <UInt16> rpVisitor = null;

            string cloudFile = GetStringArg("CloudFile");

            if (progressTracker != null)
            {
                progressTracker.Invoke(5, "开始计算热效应强度指数,请稍候...");
            }
            try
            {
                if (!string.IsNullOrEmpty(cloudFile) && File.Exists(cloudFile))
                {
                    if (progressTracker != null)
                    {
                        progressTracker.Invoke(15, "开始提取云信息,请稍候...");
                    }
                    cloudPrd = GeoDataDriver.Open(cloudFile) as IRasterDataProvider;
                    if (cloudPrd == null)
                    {
                        PrintInfo("请选择正确的云结果.");
                        return(null);
                    }
                    List <RasterMaper> rms = new List <RasterMaper>();
                    RasterMaper        brm = new RasterMaper(cloudPrd, new int[] { 1 });
                    rms.Add(brm);
                    RasterMaper rm = new RasterMaper(currPrd, new int[] { 1 });
                    rms.Add(rm);
                    //输出文件准备(作为输入栅格并集处理)
                    string outFileName = MifEnvironment.GetFullFileName(".dat");
                    using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                    {
                        //栅格数据映射
                        RasterMaper[] fileIns  = rms.ToArray();
                        RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                        //创建处理模型
                        RasterProcessModel <UInt16, UInt16> rfr = null;
                        rfr = new RasterProcessModel <UInt16, UInt16>();
                        rfr.SetRaster(fileIns, fileOuts);
                        int totalIndex = -1;
                        if (progressTracker != null)
                        {
                            progressTracker.Invoke(35, "开始处理云和地表温度信息,请稍候...");
                        }
                        rfr.RegisterCalcModel(new RasterCalcHandler <UInt16, UInt16>((rvInVistor, rvOutVistor, rfrAOI) =>
                        {
                            int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                            if (rvInVistor[0].RasterBandsData[0] != null && rvInVistor[1].RasterBandsData[0] != null)
                            {
                                for (int index = 0; index < dataLength; index++)
                                {
                                    totalIndex++;;
                                    UInt16 cloudData = rvInVistor[0].RasterBandsData[0][index];
                                    UInt16 valueData = rvInVistor[1].RasterBandsData[0][index];
                                    if (cloudData != 0 || nanValues.Contains(valueData))
                                    {
                                        resultTemp.Put(totalIndex, defCloudy);
                                    }
                                    else if (waterValues.Contains(valueData))
                                    {
                                        resultTemp.Put(totalIndex, defWater);
                                    }
                                    else if (valueData == 0)
                                    {
                                        resultTemp.Put(totalIndex, 0);
                                    }
                                    else
                                    {
                                        if (vaildLstList.ContainsKey(valueData))
                                        {
                                            vaildLstList[valueData]++;
                                        }
                                        else
                                        {
                                            vaildLstList.Add(valueData, 1);
                                        }
                                    }
                                }
                            }
                        }));
                        //执行
                        rfr.Excute();
                    }
                }
                else
                {
                    if (progressTracker != null)
                    {
                        progressTracker.Invoke(15, "开始提取地表温度信息,请稍候...");
                    }
                    rpVisitor = new RasterPixelsVisitor <UInt16>(ap);
                    rpVisitor.VisitPixel(new int[] { LstBandCH },
                                         (index, values) =>
                    {
                        if (nanValues.Contains(values[0]))
                        {
                            resultTemp.Put(index, defCloudy);
                        }
                        else if (waterValues.Contains(values[0]))
                        {
                            resultTemp.Put(index, defWater);
                        }
                        else if (values[0] == 0)
                        {
                            resultTemp.Put(index, 0);
                        }
                        else
                        {
                            if (vaildLstList.ContainsKey(values[0]))
                            {
                                vaildLstList[values[0]]++;
                            }
                            else
                            {
                                vaildLstList.Add(values[0], 1);
                            }
                        }
                    });
                }
                UInt16 minValue = 0;
                UInt16 maxValue = UInt16.MaxValue;
                GetMinMaxValue(vaildLstList, LSTMin, LSTMax, minCount, out minValue, out maxValue);
                if (maxValue == minValue)
                {
                    return(null);
                }
                UInt16 result = 0;
                if (rpVisitor == null)
                {
                    rpVisitor = new RasterPixelsVisitor <UInt16>(ap);
                }
                if (progressTracker != null)
                {
                    progressTracker.Invoke(65, "开始计算热效应强度信息,请稍候...");
                }
                int[]  tempIndexes = resultTemp.Indexes.ToArray();
                double resultHFII  = 0f;
                rpVisitor.VisitPixel(new int[] { LstBandCH },
                                     (index, values) =>
                {
                    if (!tempIndexes.Contains(index))
                    {
                        resultHFII = ((float)(values[0] - minValue)) / (maxValue - minValue) * HFIIZoom;
                        if (resultHFII <= 0)
                        {
                            result = (UInt16)1;
                        }
                        else
                        {
                            result = (UInt16)resultHFII;
                        }
                        resultTemp.Put(index, result);
                    }
                });
                if (progressTracker != null)
                {
                    progressTracker.Invoke(85, "开始保存热效应强度信息,请稍候...");
                }
                return(GenrateIInterested(resultTemp, currPrd, "HFII"));
            }
            finally
            {
                if (currPrd != null)
                {
                    currPrd.Dispose();
                }
                if (cloudPrd != null)
                {
                    cloudPrd.Dispose();
                }
            }
        }
Esempio n. 24
0
        private IExtractResult IceConverageAlgorithmWithAOI(Action <int, string> progressTracker)
        {
            enumDataType dataType;
            int          xSize, ySize, length;

            short[]  nicDataBuffer = null;
            string[] options       = null;
            using (IRasterDataProvider selectRaster = GeoDataDriver.Open(_fileName, _fileOpenArgs) as IRasterDataProvider)
            {
                dataType      = selectRaster.DataType;
                xSize         = selectRaster.Width;
                ySize         = selectRaster.Height;
                length        = xSize * ySize;
                nicDataBuffer = new short[xSize * ySize];
                using (IRasterDataProvider aoiRaster = GeoDataDriver.Open(_aoiFileName) as IRasterDataProvider)
                {
                    if (aoiRaster.Width != selectRaster.Width || aoiRaster.Height != selectRaster.Height)
                    {
                        return(null);
                    }
                    byte[]   aoi        = new byte[xSize * ySize];
                    GCHandle aoiHandle  = GCHandle.Alloc(aoi, GCHandleType.Pinned);
                    GCHandle dataHandle = GCHandle.Alloc(nicDataBuffer, GCHandleType.Pinned);
                    try
                    {
                        aoiRaster.GetRasterBand(1).Read(0, 0, xSize, ySize, aoiHandle.AddrOfPinnedObject(), enumDataType.Byte, xSize, ySize);
                        selectRaster.GetRasterBand(1).Read(0, 0, xSize, ySize, dataHandle.AddrOfPinnedObject(), enumDataType.Int16, xSize, ySize);
                        for (int i = 0; i < length; i++)
                        {
                            if (aoi[i] == 0 && nicDataBuffer[i] > 0 && nicDataBuffer[i] <= 100) //移除感兴趣区域外的海冰
                            {
                                nicDataBuffer[i] = 0;                                           //陆地是120,海洋0,目前是将误判的海冰设置为海洋
                            }
                            else if (aoi[i] == 1 && nicDataBuffer[i] == 110)
                            {
                                nicDataBuffer[i] = 100;//感兴趣区域内的无效区域填充为冰
                            }
                        }
                    }
                    finally
                    {
                        aoiHandle.Free();
                        dataHandle.Free();
                    }
                }
                //生成新的海冰覆盖度文件。
                options = CreateLDFOptions(selectRaster);
            }
            string            newfile = MifEnvironment.GetFullFileName(Path.GetFileNameWithoutExtension(_fileName) + Guid.NewGuid().ToString() + ".ldf");//系统配置的Temp目录
            IRasterDataDriver driver  = RasterDataDriver.GetDriverByName("LDF") as IRasterDataDriver;

            using (IRasterDataProvider newRaster = driver.Create(newfile, xSize, ySize, 1, dataType, options) as IRasterDataProvider)
            {
                GCHandle handle = GCHandle.Alloc(nicDataBuffer, GCHandleType.Pinned);
                try
                {
                    newRaster.GetRasterBand(1).Write(0, 0, xSize, ySize, handle.AddrOfPinnedObject(), dataType, xSize, ySize);
                }
                finally
                {
                    handle.Free();
                }
                _fileName     = newfile;
                _fileOpenArgs = "";
            }
            return(IceConverageAlgorithm(progressTracker));
        }
Esempio n. 25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rasterFile">土地利用类型文件</param>
        /// <param name="dblvFile">二值图文件</param>
        /// <returns></returns>
        private unsafe string GenerateNetImageFile(string rasterFile, string dblvFile)
        {
            using (IRasterDataProvider rasterprd = GeoDataDriver.Open(rasterFile) as IRasterDataProvider)
            {
                using (IRasterDataProvider dblvprd = GeoDataDriver.Open(dblvFile) as IRasterDataProvider)
                {
                    //step1:将文件转换为类型一致
                    IRasterDataProviderConverter converter = new RasterDataProviderConverter();
                    string dstFileName = MifEnvironment.GetFullFileName("1.dat");
                    using (IRasterDataProvider dstDataProvider = converter.ConvertDataType <UInt16, Byte>(dblvprd, enumDataType.Byte, dstFileName,
                                                                                                          (v) => { return((Byte)v); }))
                    {
                        //step2:裁切文件以保证大小一致
                        using (IRasterDataProvider sameSizeDataProvider = GetSameSizeDataProvider(rasterprd, dstDataProvider))
                        {
                            byte[] dataBlock = new byte[sameSizeDataProvider.Width * sameSizeDataProvider.Height];
                            fixed(byte *buffer = dataBlock)
                            {
                                IntPtr ptr = new IntPtr(buffer);

                                sameSizeDataProvider.GetRasterBand(1).Read(0, 0, sameSizeDataProvider.Width, sameSizeDataProvider.Height, ptr, enumDataType.Byte, sameSizeDataProvider.Width, sameSizeDataProvider.Height);
                                sameSizeDataProvider.Read(0, 0, sameSizeDataProvider.Width, sameSizeDataProvider.Height, ptr, enumDataType.Byte, sameSizeDataProvider.Width, sameSizeDataProvider.Height, 1, new int[] { 1 }, enumInterleave.BSQ);
                            }

                            if (sameSizeDataProvider == null)
                            {
                                return(null);
                            }
                            //step3:生成虚拟文件
                            VirtualRasterDataProvider vrd = new VirtualRasterDataProvider(new IRasterDataProvider[] { sameSizeDataProvider, dstDataProvider });
                            //step4:遍历虚拟文件生成结果
                            ArgumentProvider           ap      = new ArgumentProvider(vrd, null);
                            RasterPixelsVisitor <Byte> visitor = new RasterPixelsVisitor <Byte>(ap);
                            //生成结果
                            MemPixelFeatureMapper <Byte> memresult = new MemPixelFeatureMapper <Byte>("NIMG", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                            visitor.VisitPixel(new int[] { 1, 2 },
                                               (index, values) =>
                            {
                                if (values[0] == 0)
                                {
                                    memresult.Put(index, 0);
                                }
                                else if (values[1] == 0)
                                {
                                    memresult.Put(index, 100);
                                }
                                else if (values[1] == 1)
                                {
                                    memresult.Put(index, (byte)(100 + values[0]));
                                }
                            });
                            //保存文件
                            RasterIdentify idNIMG = new RasterIdentify(dblvFile);
                            idNIMG.ThemeIdentify      = "CMA";
                            idNIMG.ProductIdentify    = "SNW";
                            idNIMG.SubProductIdentify = "NIMG";
                            idNIMG.GenerateDateTime   = DateTime.Now;
                            idNIMG.Satellite          = dblvprd.DataIdentify.Satellite;
                            idNIMG.Sensor             = dblvprd.DataIdentify.Sensor;
                            string fileName = MifEnvironment.GetFullFileName(idNIMG.ToLongString() + ".dat");
                            if (File.Exists(fileName))
                            {
                                idNIMG.GenerateDateTime = DateTime.Now.AddSeconds(1);
                            }
                            IInterestedRaster <Byte> iirNIMG = new InterestedRaster <Byte>(idNIMG, new Size(sameSizeDataProvider.Width, sameSizeDataProvider.Height), sameSizeDataProvider.CoordEnvelope.Clone(), sameSizeDataProvider.SpatialRef);
                            iirNIMG.Put(memresult);
                            iirNIMG.Dispose();
                            if (File.Exists(dstFileName))
                            {
                                File.Delete(dstFileName);
                            }
                            return(iirNIMG.FileName);
                        }
                    }
                }
            }
        }
Esempio n. 26
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);
        }
Esempio n. 27
0
        private static string CreatOutFileName(string lstFile, string demFile)
        {
            RasterIdentify ri = new RasterIdentify(lstFile);

            return(MifEnvironment.GetFullFileName(ri.ToWksFileName(".dat")));
        }