private void InitFrm() { if (File.Exists(_argFile)) { _collectArgs = ReadArgs(_argFile); } _proDic = CatalogCNHelper.GetDic(); //初始化产品列表 if (_proDic.Count != 0) { cbProduct.Items.AddRange(_proDic.Keys.ToArray()); if (_collectArgs != null && _proDic.ContainsKey(_collectArgs.ProIdentify)) { cbProduct.Text = _collectArgs.ProIdentify; } else { cbProduct.SelectedIndex = 0; } } //初始化工作空间 if (_collectArgs != null && !string.IsNullOrEmpty(_collectArgs.WorkspaceDir)) { txtWorksapce.Text = _collectArgs.WorkspaceDir; } else { MifConfig config = new MifConfig(); txtWorksapce.Text = config.GetConfigValue("Workspace"); } //初始化输出目录 if (_collectArgs != null) { txtOutdir.Text = _collectArgs.OutDirRoot; } if (_collectArgs != null) { ckRemove.Checked = _collectArgs.isRemove; } }
private string ProcessCloud(string srcFilename, int bandNo) { string cloudFile = GetClmFile(srcFilename); if (string.IsNullOrEmpty(cloudFile) || !File.Exists(cloudFile)) { return(srcFilename); } Int16 defCloudy = (Int16)_argumentProvider.GetArg("defCloudy"); List <RasterMaper> rms = new List <RasterMaper>(); IRasterDataProvider snwPrd = GeoDataDriver.Open(srcFilename) as RasterDataProvider; IRasterDataProvider cloudPrd = GeoDataDriver.Open(cloudFile) as RasterDataProvider; try { RasterMaper snwRm = new RasterMaper(snwPrd, new int[] { bandNo }); rms.Add(snwRm); RasterMaper cloudRm = new RasterMaper(cloudPrd, new int[] { GetCloudCHNO() }); rms.Add(cloudRm); MifConfig mifConfig = new MifConfig(); string outFileName = mifConfig.GetConfigValue("TEMP") + "\\" + Guid.NewGuid() + ".dat"; 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>(); rfr.SetRaster(fileIns, fileOuts); rfr.SetFeatureAOI(_argumentProvider.AOIs); rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) => { int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX; if (rvInVistor[0].RasterBandsData == null || rvInVistor[1].RasterBandsData == null || rvInVistor[0].RasterBandsData[0] == null || rvInVistor[1].RasterBandsData[0] == null) { return; } for (int index = 0; index < dataLength; index++) { if (rvInVistor[1].RasterBandsData[0][index] == 1 && rvInVistor[0].RasterBandsData[0][index] == 0) { rvOutVistor[0].RasterBandsData[0][index] = defCloudy; } else { rvOutVistor[0].RasterBandsData[0][index] = rvInVistor[0].RasterBandsData[0][index]; } } })); //执行 rfr.Excute(); return(outFileName); } } finally { snwPrd.Dispose(); cloudPrd.Dispose(); } }