private void GetDstResultByCompoundArea(Dictionary <string, Dictionary <string, StatInfoBase[]> > srcResult, Dictionary <string, Dictionary <enumStatCompoundType, IStatResult> > dstResult, string dimKey, enumStatCompoundType statCompoundType) { Dictionary <enumStatCompoundType, IStatResult> tempResult = null;; Dictionary <enumStatCompoundType, StatInfoBase> sibDic = new Dictionary <enumStatCompoundType, StatInfoBase>(); StatInfoBase daySibTemp = null; Dictionary <string, StatInfoBase[]> daysInfoTemp = srcResult[dimKey]; StatInfoBase dimSibTemp = srcResult[dimKey].First().Value[0]; foreach (var dayKey in daysInfoTemp.Keys) { if (daysInfoTemp[dayKey].Length > 1) { daySibTemp = daysInfoTemp[dayKey][0]; for (int index = 1; index < daysInfoTemp[dayKey].Length; index++) { CompareStatBaseInfoBySum(ref daySibTemp, daysInfoTemp[dayKey][index - 1], statCompoundType); } } else { CompareStatBaseInfoBySum(ref dimSibTemp, daysInfoTemp[dayKey][0], statCompoundType); } } tempResult = new Dictionary <enumStatCompoundType, IStatResult>(); tempResult.Add(statCompoundType, dimSibTemp.DayStatResult); if (dstResult.ContainsKey(dimKey)) { dstResult[dimKey].Add(statCompoundType, dimSibTemp.DayStatResult); } else { dstResult.Add(dimKey, tempResult); } }
private void CompareStatBaseInfoBySum(ref StatInfoBase compoundSib, StatInfoBase compareSib, enumStatCompoundType statCompoundType) { int rowLength = compoundSib.DayStatResult.Rows.Length; int colLength = compoundSib.DayStatResult.Columns.Length;; string[] tempSib = null; float areaTemp = 0; float compoundSum = 0; float compareSum = 0; for (int row = 0; row < rowLength; row++) { tempSib = compoundSib.DayStatResult.Rows[row]; for (int col = 0; col < colLength; col++) { compoundSum += float.TryParse(tempSib[col], out areaTemp) ? areaTemp : 0; } tempSib = compareSib.DayStatResult.Rows[row]; for (int col = 0; col < colLength; col++) { compareSum += float.TryParse(tempSib[col], out areaTemp) ? areaTemp : 0; } } switch (statCompoundType) { case enumStatCompoundType.全部: break; case enumStatCompoundType.最大: if (compareSum > compoundSum) { compoundSib = compareSib; } break; case enumStatCompoundType.最小: if (compareSum < compoundSum) { compoundSib = compareSib; } break; } }
private Dictionary <string, StatInfoBase[]> GetDayInfo(string filename, string key, Dictionary <string, StatInfoBase[]> subResult, ref StatInfoBase statInfo, IArgumentProvider argProvider, Action <int, string> progressTracker) { IStatResult result = CalcAreaByAlgorithmOneFile(argProvider, progressTracker, filename); if (result == null) { return(subResult); } statInfo.DayStatResult = result; if (!subResult.ContainsKey(key)) { subResult.Add(key, new StatInfoBase[] { statInfo }); } else { List <StatInfoBase> temp = new List <StatInfoBase>(); temp.AddRange(subResult[key]); temp.Add(statInfo); subResult[key] = temp.ToArray(); } return(subResult); }
public Dictionary <string, Dictionary <string, StatInfoBase[]> > GetStatInfo(SubProductDef subProductDef, IArgumentProvider argProvider, Action <int, string> progressTracker) { _subProductDef = subProductDef; _argumentProvider = argProvider; if (argProvider == null) { return(null); } string[] filenames = GetStringArray("SelectedPrimaryFiles"); if (filenames == null || filenames.Length == 0) { return(null); } StatDimClass dimClass = argProvider.GetArg("StatDim") == null ? null : argProvider.GetArg("StatDim") as StatDimClass; if (dimClass == null) { return(null); } enumStatDimType dimType = dimClass.DimType; enumStatDayMosaicType dayMosaicType = dimClass.DayMosaicType; Dictionary <string, Dictionary <string, StatInfoBase[]> > result = new Dictionary <string, Dictionary <string, StatInfoBase[]> >(); RasterIdentify rid = null; StatInfoBase statInfo = null; string key = string.Empty; if (progressTracker != null) { progressTracker.Invoke(10, "开始进行长序列面积统计,请稍后..."); } float interval = (80f / filenames.Length); int fileIndex = 0; foreach (string file in filenames) { if (progressTracker != null) { progressTracker.Invoke((int)(++fileIndex * interval) + 10, "开始进行第[" + fileIndex + "]个文件面积统计,请稍后..."); } if (string.IsNullOrEmpty(file) || !File.Exists(file)) { continue; } rid = new RasterIdentify(file); if (rid == null) { continue; } statInfo = new StatInfoBase(rid.OrbitDateTime.ToString("yyyyMMddHHmmss"), file); switch (dimType) { case enumStatDimType.区分: key = "不区分"; break; case enumStatDimType.年: key = rid.OrbitDateTime.ToString("yyyy年"); break; case enumStatDimType.季: key = GetSeason(rid.OrbitDateTime.ToString("yyyy年"), rid.OrbitDateTime.Month); break; case enumStatDimType.月: key = rid.OrbitDateTime.ToString("yyyy年MM月"); break; case enumStatDimType.旬: key = GetTenDays(rid.OrbitDateTime.ToString("yyyy年MM月"), rid.OrbitDateTime.Day); break; case enumStatDimType.日: key = rid.OrbitDateTime.ToString("yyyy年MM月dd日"); break; default: break; } if (string.IsNullOrEmpty(key)) { continue; } if (!result.ContainsKey(key)) { Dictionary <string, StatInfoBase[]> tempInfo = GetDayInfo(file, rid.OrbitDateTime.ToString("yyyyMMdd"), new Dictionary <string, StatInfoBase[]>(), ref statInfo, argProvider, progressTracker); if (tempInfo != null && tempInfo.Count != 0) { result.Add(key, tempInfo); } } else { Dictionary <string, StatInfoBase[]> tempInfo = GetDayInfo(file, rid.OrbitDateTime.ToString("yyyyMMdd"), result[key], ref statInfo, argProvider, progressTracker); if (tempInfo != null && tempInfo.Count != 0) { result[key] = tempInfo; } } } return(result.Count == 0 ? null : result); }