private void btnExcute_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(_currentRasterFile) || lstFiles.Items.Count < 1) { return; } if (_session == null) { return; } ICanvasViewer cv = _session.SmartWindowManager.ActiveCanvasViewer; if (cv == null) { return; } int[] drawedAOI = cv.AOIProvider.GetIndexes(); IMonitoringSession msession = _session.MonitoringSession as IMonitoringSession; IMonitoringSubProduct subProduct = msession.ActiveMonitoringSubProduct; IPixelIndexMapper pixelMapper = (_session.MonitoringSession as IMonitoringSession).ExtractingSession.GetBinaryValuesMapper(subProduct.Definition.ProductDef.Identify, subProduct.Definition.Identify); IPixelIndexMapper resultPixelMapper = GenerateHistoryResultByAOI(pixelMapper, drawedAOI); if (pixelMapper != null) { DisplayResultClass.DisplayResult(_session, subProduct, resultPixelMapper, true); } }
/// <summary> /// 生成动画 /// </summary> /// <param name="session"></param> /// <param name="argument">template:沙尘动画示意专题图,动画示意专题图,productIdentify, subProductIdentify</param> public static void CreatAVI(ISmartSession session, string argument) { string[] fnames = GetFilesByWorkspace(session); if (fnames == null || fnames.Length == 0) { return; } string tempArg = null; string wndName = null; string productIdentify = null; string subIdentify = null; ParserArgument(argument, ref tempArg, ref wndName, ref productIdentify, ref subIdentify); IAVILayerDisplay aviDis = new AVILayerDisplay(); if (subIdentify == "CMED") { aviDis.IsCustom = true; } string outputFname = null; aviDis.DisplayAvi(session, wndName, fnames, tempArg, subIdentify, out outputFname); IExtractResult er = new FileExtractResult(subIdentify, outputFname) as IExtractResult; if (er == null) { return; } DisplayResultClass.DisplayResult(session, null, er, false); }
/// <summary> /// 监测示意图 /// </summary> /// <param name="session"></param> /// <param name="argument">"template:沙尘监测示意图,监测示意图,DST,MCSI"</param> public static void DisplayMonitorShow(ISmartSession session, string argument) { string subIdentify = null; try { //MonitorShowSettings setting = GetMonitorShowSettings(); //if (setting == null) // return ; //MonitorShowSettings.CurrentSettings = setting; MonitorShowDisplay msd = new MonitorShowDisplay(); string fname = msd.DisplayMonitorBitmap(session, argument, out subIdentify); if (string.IsNullOrEmpty(fname)) { return; } IExtractResult er = new FileExtractResult(subIdentify, fname) as IExtractResult; if (er == null) { return; } DisplayResultClass.DisplayResult(session, null, er, false); } finally { //if (MonitorShowSettings.CurrentSettings != null) // MonitorShowSettings.CurrentSettings = null; } }
/// <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) { 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, out outFileIdentify, out templateName); if (string.IsNullOrEmpty(outFileIdentify) || string.IsNullOrEmpty(templateName)) { return(null); } if (isCustom && !SetAOIArugment(files, msp, multiSelect)) { return(null); } else if (!isCustom) { msp.ArgumentProvider.SetArg("AOI", null); } IThemeGraphGenerator tgg = (session.MonitoringSession as IMonitoringSession).ThemeGraphGenerator; msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg); msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify); msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName); IExtractResult result = msp.Make(null); DisplayResultClass.DisplayResult(session, msp, result, false); return(result); }
private void ActiveWorkSpace(string filename) { if (_mSession != null && _mSession.ActiveMonitoringSubProduct != null) { FileExtractResult result = new FileExtractResult(_subProductIdentify, filename, true); DisplayResultClass.DisplayResult(_session, _mSession.ActiveMonitoringSubProduct, result, false); } }
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 (!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); } } CoordEnvelope customEnv = null; if (isCustom && !SetAOIArugment(files, msp, multiSelect, out customEnv)) { return(null); } else if (!isCustom) { msp.ArgumentProvider.SetArg("AOI", string.IsNullOrEmpty(aoiTemplate) ? null : aoiTemplate); } else if (customEnv != null) { RasterProject.PrjEnvelope prjEnvelope = new RasterProject.PrjEnvelope(customEnv.MinX, customEnv.MaxX, customEnv.MinY, customEnv.MaxY); msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope); } 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); } }
/// <summary> /// 日合成 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void DayRaster_Click(object sender, EventArgs e) { (_session.MonitoringSession as IMonitoringSession).ChangeActiveSubProduct("CYCA"); GetCommandAndExecute(6602); IMonitoringSubProduct msp = (_session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct; IExtractResult result = msp.Make(null); DisplayResultClass.DisplayResult(_session, msp, result, false); }
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); } } //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923 foreach (string fname in files) { CanCreatThemegraph(fname); } if (isCustom && !SetAOIArugment(files, msp, multiSelect, aoiTemplateList)) { return(null); } else if (!isCustom) { msp.ArgumentProvider.SetArg("AOI", null); } IThemeGraphGenerator tgg = (session.MonitoringSession as IMonitoringSession).ThemeGraphGenerator; 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); }
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); }
//根据文件名提取区域标识,限定专题图输出数据范围。一般用于制作网络图。 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(); } } }
//根据文件名提取区域标识,限定专题图输出数据范围。一般用于制作网络图。 public static IExtractResult CreateThemeGraphyBase(ISmartSession session, string algorithmName, string outFileIdentify, string colorTableName, string dataIdentify, string templateName, bool isCustom, bool multiSelect, bool isUseRegion) { 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); } } //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923 foreach (string fname in files) { CanCreatThemegraph(fname); } if (isCustom && !SetAOIArugment(files, msp, multiSelect)) { return(null); } else if (!isCustom) { msp.ArgumentProvider.SetArg("AOI", null); } IThemeGraphGenerator tgg = (session.MonitoringSession as IMonitoringSession).ThemeGraphGenerator; msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg); msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify); msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName); 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); RasterProject.PrjEnvelope prjEnvelope = RasterProject.PrjEnvelope.CreateByCenter(envItem.PrjEnvelope.CenterX, envItem.PrjEnvelope.CenterY, 1000, 1000); msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope); } } if (!string.IsNullOrEmpty(colorTableName)) { msp.ArgumentProvider.SetArg("colortablename", "colortablename=" + colorTableName); } IExtractResult result = msp.Make(null); DisplayResultClass.DisplayResult(session, msp, result, false); return(result); }