public static void TrySaveFileToWorkspace(IMonitoringSubProduct subProduct, IMonitoringSession mession, string fname, IExtractResult restult) { if (string.IsNullOrEmpty(fname)) { return; } IWorkspace wks = mession.GetWorkspace(); RasterIdentify rst = new RasterIdentify(fname); ICatalog c = wks.GetCatalog("CurrentExtracting"); if (c != null) { c.AddItem(new CatalogItem(fname, c.Definition as SubProductCatalogDef)); } if (_contextEnvironment != null && subProduct != null) { rst.SubProductIdentify = subProduct.Identify; IExtractResultBase erb = restult as IExtractResultBase; if (erb != null && !string.IsNullOrEmpty(erb.OutIdentify)) { rst.SubProductIdentify = erb.OutIdentify; } GetOutFileIdentify(ref rst, subProduct); if (!string.IsNullOrEmpty(restult.Name) && restult.Name != rst.SubProductIdentify) { rst.SubProductIdentify = restult.Name; } _contextEnvironment.PutContextVar(rst.SubProductIdentify, fname); } }
private IExtractResult SITIAlgorithm(Action <int, string> progressTracker) { // string rasterFile = _argumentProvider.GetArg("SelectedPrimaryFiles") as string; if (string.IsNullOrWhiteSpace(rasterFile)) { ISmartSession session = _argumentProvider.GetArg("SmartSession") as ISmartSession; IMonitoringSession ms = session.MonitoringSession as IMonitoringSession; IWorkspace wks = ms.GetWorkspace(); if (wks.ActiveCatalog != null) { string[] fs = wks.ActiveCatalog.GetSelectedFiles("0SIT"); if (fs != null && fs.Length != 0) { rasterFile = fs[0]; _argumentProvider.SetArg("SelectedPrimaryFiles", rasterFile); } } } if (string.IsNullOrEmpty(rasterFile) || !File.Exists(rasterFile)) { return(null); } //栅格统计 Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >(); //海冰厚度中四个标记值 float[] rasterValues = new float[] { -1, 1, 5, 10 }; for (int i = 0; i < rasterValues.Length; i++) { float min = rasterValues[i]; string filterKey = min.ToString(); filters.Add(filterKey, (v) => { return(v == min); }); } Dictionary <string, SortedDictionary <string, double> > dic = RasterStatFactory.Stat(rasterFile, null, filters, progressTracker); if (dic == null || dic.Count < 1) { return(null); } SortedDictionary <string, double> statAreas = dic[dic.Keys.First()]; _statAreas = new List <double>(); double total = 0; foreach (string item in statAreas.Keys) { _statAreas.Add(statAreas[item]); total += statAreas[item]; } _statAreas.Add(total); return(ThemeGraphyResult(null)); }
private IExtractResult ICETFRI() { string outFileIdentify = GetStringArgument("OutFileIdentify"); SubProductInstanceDef instatnce = GetSubProductInstanceByOutIdentify(outFileIdentify); if (instatnce != null) { outFileIdentify = instatnce.OutFileIdentify; } string templatName = GetStringArgument("ThemeGraphTemplateName"); //获取冰缘线数据 string[] shpFiles = _argumentProvider.GetArg("ShpFile") as string[]; if (shpFiles == null || shpFiles.Length == 0) { ISmartSession session = _argumentProvider.GetArg("SmartSession") as ISmartSession; IMonitoringSession ms = session.MonitoringSession as IMonitoringSession; IWorkspace wks = ms.GetWorkspace(); if (wks.ActiveCatalog != null) { string[] fs = wks.ActiveCatalog.GetSelectedFiles("EDGE"); if (fs != null && fs.Length != 0) { shpFiles = fs; _argumentProvider.SetArg("SelectedPrimaryFiles", shpFiles); } } } if (!CheckShpFile(ref shpFiles)) { PrintInfo("冰缘线获取失败!"); //return null; } else { _shpFiles = shpFiles; //if (_shpFiles.Length == 1) // _iceControlPointShpFile = GeoDo.RSS.MIF.Prds.ICE.IceEdgeFileNameHelper.GetIceEdgeControlInfoFilename(_shpFiles[0]); ApplyMcd(_shpFiles, @"SystemData\ProductArgs\长序列冰缘线专题图文档.mcd"); CreateLegendItems(_shpFiles); } IExtractResult result = null; SubProductInstanceDef instance = new SubProductInstanceDef(); instance.OutFileIdentify = outFileIdentify; instance.isautogenerate = false; instance.LayoutName = templatName; result = ThemeGraphyByInstance(instance); _gxdFile = (result as FileExtractResult).FileName; if (CheckShpFile(ref shpFiles)) { AddShpLayerToGxd(); } (result as FileExtractResult).Add2Workspace = true; return(result as IExtractResult); }
private IExtractResult ISOIAlgorithm() { try { //获取冰缘线数据 string[] shpFiles = _argumentProvider.GetArg("SelectedPrimaryFiles") as string[]; if (shpFiles == null || shpFiles.Length == 0) { ISmartSession session = _argumentProvider.GetArg("SmartSession") as ISmartSession; IMonitoringSession ms = session.MonitoringSession as IMonitoringSession; IWorkspace wks = ms.GetWorkspace(); if (wks.ActiveCatalog != null) { string[] fs = wks.ActiveCatalog.GetSelectedFiles("EDGE"); if (fs != null && fs.Length != 0) { shpFiles = fs; _argumentProvider.SetArg("SelectedPrimaryFiles", shpFiles); } } } if (!CheckShpFile(ref shpFiles)) { PrintInfo("冰缘线获取失败!"); return(null); } _shpFiles = shpFiles; if (_shpFiles.Length == 1) { _iceControlPointShpFile = GeoDo.RSS.MIF.Prds.ICE.IceEdgeFileNameHelper.GetIceEdgeControlInfoFilename(_shpFiles[0]); } ApplyMcd(_shpFiles); //ReadShpFileAttribute(shpFile); if (!string.IsNullOrEmpty(_iceControlPointShpFile) && File.Exists(_iceControlPointShpFile)) { ReadIceControlPointInfo(_iceControlPointShpFile); } CreateLegendItems(_shpFiles); IExtractResult er = VectoryThemeGraphy(null);//生成空白的专题图 _gxdFile = (er as FileExtractResult).FileName; AddShpLayerToGxd(); return(er); } finally { _argumentProvider.SetArg("SelectedPrimaryFiles", null); } }
private static string[] GetFilesByWorkspace(ISmartSession session) { IMonitoringSession mession = session.MonitoringSession as IMonitoringSession; IWorkspace wks = mession.GetWorkspace(); if (wks == null) { return(null); } ICatalog catalog = wks.ActiveCatalog; if (catalog == null) { return(null); } return(catalog.GetSelectedFiles()); }
private IExtractResult ISOIAlgorithm() { try { //获取等值线数据 string shpFile = _argumentProvider.GetArg("SelectedPrimaryFiles") as string; if (string.IsNullOrWhiteSpace(shpFile)) { ISmartSession session = _argumentProvider.GetArg("SmartSession") as ISmartSession; IMonitoringSession ms = session.MonitoringSession as IMonitoringSession; IWorkspace wks = ms.GetWorkspace(); if (wks.ActiveCatalog != null) { string[] fs = wks.ActiveCatalog.GetSelectedFiles("ISOT"); if (fs != null && fs.Length != 0) { shpFile = fs[0]; _argumentProvider.SetArg("SelectedPrimaryFiles", shpFile); } } } if (!File.Exists(shpFile)) { PrintInfo("获取等值线shp文件失败。"); return(null); } _symbolColor.Clear(); CreateLegendItems(shpFile); _shpFile = shpFile; IExtractResult er = ThemeGraphyResult(null); _gxdFile = (er as FileExtractResult).FileName; AddShpToGxd(); return(er); } finally { _argumentProvider.SetArg("SelectedPrimaryFiles", null); } }
private IExtractResult SIAIAlgorithm(Action <int, string> progressTracker) { // string rasterFile = _argumentProvider.GetArg("SelectedPrimaryFiles") as string; if (string.IsNullOrWhiteSpace(rasterFile)) { ISmartSession session = _argumentProvider.GetArg("SmartSession") as ISmartSession; IMonitoringSession ms = session.MonitoringSession as IMonitoringSession; IWorkspace wks = ms.GetWorkspace(); if (wks.ActiveCatalog != null) { string[] fs = wks.ActiveCatalog.GetSelectedFiles("DBLV"); if (fs != null && fs.Length != 0) { rasterFile = fs[0]; _argumentProvider.SetArg("SelectedPrimaryFiles", rasterFile); } } } if (string.IsNullOrEmpty(rasterFile) || !File.Exists(rasterFile)) { return(null); } RasterIdentify rid = new RasterIdentify(rasterFile); if (rid.SubProductIdentify != "DBLV") { return(null); } //栅格统计 string title = ""; StatResultItem[] areaResult = CommProductStat.AreaStat <Int16>("", rasterFile, ref title, null, (v) => { return(v == 1); }); _statArea = areaResult[0].Value; return(ThemeGraphyResult(null)); }
public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage) { _contextMessage = contextMessage; if (_argumentProvider == null) { return(null); } if (_argumentProvider.GetArg("SelectedPrimaryFiles") == null) { ISmartSession session = _argumentProvider.GetArg("SmartSession") as ISmartSession; IMonitoringSession ms = session.MonitoringSession as IMonitoringSession; IWorkspace wks = ms.GetWorkspace(); if (wks.ActiveCatalog != null) { string[] fs = wks.ActiveCatalog.GetSelectedFiles("NDVI"); if (fs != null && fs.Length != 0) { _argumentProvider.SetArg("SelectedPrimaryFiles", fs); } } if (_argumentProvider.GetArg("SelectedPrimaryFiles") == null) { PrintInfo("请选择统计文件!"); return(null); } } string[] fname = GetStringArray("SelectedPrimaryFiles"); if (fname == null || fname.Length <= 0) { PrintInfo("请选择统计文件!"); return(null); } if (_argumentProvider.GetArg("AlgorithmName") == null) { PrintInfo("参数\"AlgorithmName\"为空。"); return(null); } string algorith = _argumentProvider.GetArg("AlgorithmName").ToString(); if (algorith != "AVGAlgorithm") { PrintInfo("指定的算法\"" + algorith + "\"没有实现。"); return(null); } short validMin = (short)_argumentProvider.GetArg("ValidMin"); short validMax = (short)_argumentProvider.GetArg("ValidMax"); if (validMin > validMax) { return(null); } string statString = AreaStatProvider.GetAreaStatItemFileName("行政区划"); SortedDictionary <string, double[]> srcResults = RasterStatFactory.SumAndCountByVector <short>(fname[0], statString, (v) => { return(v < validMax && v > validMin); }, progressTracker); if (srcResults == null || srcResults.Count < 1) { return(null); } SortedDictionary <string, double[]> statResults = new SortedDictionary <string, double[]>(); //去除无效值 foreach (string key in srcResults.Keys) { if (srcResults[key] == null) { continue; } statResults.Add(key, srcResults[key]); } if (statResults.Count <= 0) { return(null); } string title = _subProductDef.ProductDef.Name + "平均值统计"; string subTitle = GetSubTitle(fname[0]); string outFileIdentify = _argumentProvider.GetArg("OutFileIdentify").ToString(); IStatResult results = DicToStatResult(statResults, subTitle); if (results == null) { return(null); } string filename = StatResultToFile(fname, results, _subProductDef.ProductDef.Identify, outFileIdentify, title, null, 1, true, 1); return(new FileExtractResult(outFileIdentify, filename)); }