Exemplo n.º 1
0
        /// <summary>
        ///  将相同列合并到一个表格中,标题以不同表名称命名。
        /// </summary>
        /// <param name="indexes"></param>
        /// <param name="colNames"></param>
        /// <param name="tableNamePostfix"></param>
        /// <returns></returns>
        public ObjectTableManager GetSameColAssembledTableManager(List <object> indexes, List <string> colNames, string tableNamePostfix = "")
        {
            var indexColName             = this.GetIndexColName();
            ObjectTableManager newManger = new ObjectTableManager(this.OutputDirectory);

            //建立表格
            foreach (var oldColName in colNames)
            {
                if (indexColName.Equals(oldColName, StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                var newTableName = oldColName;
                if (!String.IsNullOrWhiteSpace(tableNamePostfix))
                {
                    newTableName = TableNameHelper.BuildName(oldColName, tableNamePostfix, true);
                }

                newManger.AddTable(newTableName);
            }
            //填充数据
            foreach (var indexVal in indexes)        //逐历元
            {
                foreach (var oldColName in colNames) //逐新表
                {
                    if (indexColName.Equals(oldColName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    var newTable = newManger.Get(oldColName);

                    newTable.NewRow();

                    newTable.AddItem(indexColName, indexVal);
                    foreach (var oldTableName in this.Keys) // 逐新表列, 逐老表
                    {
                        var oldTable = this[oldTableName];

                        if (!oldTable.ParamNames.Contains(oldColName))
                        {
                            continue;
                        }

                        var val = oldTable[indexVal, oldColName];
                        if (val != null)
                        {
                            var colName = TableNameHelper.ParseName(oldTableName);
                            newTable.AddItem(colName, val);
                        }
                    }
                    newTable.EndRow();
                }
            }
            return(newManger);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 同步索引,删除参数中没有的行。
 /// </summary>
 /// <param name="intWideLaneValues"></param>
 public void SynchronizeIndexes(ObjectTableManager intWideLaneValues)
 {
     Parallel.ForEach <string>(this.Keys, item =>
     {
         if (intWideLaneValues.Contains(item))
         {
             this[item].SynchronizeIndexes(intWideLaneValues[item]);
         }
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// DiviDivisor
        /// </summary>
        /// <param name="divisor"></param>
        /// <param name="isReplacePrevPosfix"></param>
        /// <param name="nameSuffix"></param>
        /// <returns></returns>
        public ObjectTableManager GetNewTableByDivision(double divisor, bool isReplacePrevPosfix = false, string nameSuffix = "DiviDivisor")
        {
            var dic = new ConcurrentDictionary <string, ObjectTableStorage>();

            Parallel.ForEach <string>(this.Keys, item =>
            {
                var table = this[item].GetNewTableByDivision(divisor, isReplacePrevPosfix, nameSuffix);
                dic.TryAdd(table.Name, table);
            });
            var mwTables = new ObjectTableManager(dic, this.OutputBufferCount, OutputDirectory);

            return(mwTables);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取减去一个列的新表。
        /// </summary>
        /// <param name="colNameOfSubtractor"></param>
        /// <returns></returns>
        public ObjectTableManager GetNewByMinusCol(string colNameOfSubtractor, string tablePostfixName = "-ColName", bool isReplacePrevPosfix = false)
        {
            var dic = new ConcurrentDictionary <string, ObjectTableStorage>();

            Parallel.ForEach <string>(this.Keys, item =>
            {
                var table = this[item].GetTableByMinusCol(colNameOfSubtractor, tablePostfixName, isReplacePrevPosfix);
                dic.TryAdd(table.Name, table);
            });
            var mwTables = new ObjectTableManager(dic, this.OutputBufferCount, OutputDirectory);

            return(mwTables);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 完全平滑
        /// </summary>
        /// <param name="maxError">最大误差</param>
        /// <param name="isAsWhole">是否全局考虑</param>
        /// <param name="namePostfix">表后缀</param>
        /// <param name="isReplaceNamePosfix">是否移除之前的后缀</param>
        /// <returns></returns>
        public ObjectTableManager GetSmoothedTable(double maxError, bool isAsWhole = true, string namePostfix = "Smoothed", bool isReplaceNamePosfix = true)
        {
            var dic = new ConcurrentDictionary <string, ObjectTableStorage>();

            Parallel.ForEach <string>(this.Keys, item =>
            {
                var newTable = this[item].GetSquentionAjustSmoothedTable(maxError, isAsWhole, namePostfix, isReplaceNamePosfix);
                dic.TryAdd(newTable.Name, newTable);
            });
            var mwTables = new ObjectTableManager(dic, this.OutputBufferCount, OutputDirectory);

            return(mwTables);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 通过减去指定小数后,四舍五入取整。
        /// </summary>
        /// <param name="fractionTables"></param>
        /// <param name="tableNamePostfix"></param>
        /// <param name="isReplacePrevPosfix"></param>
        /// <returns></returns>
        public ObjectTableManager GetIntByMinusAndRound(ObjectTableManager fractionTables, string tableNamePostfix = "Int", bool isReplacePrevPosfix = false)
        {
            var dic = new ConcurrentDictionary <string, ObjectTableStorage>();

            Parallel.ForEach(this, tableA =>
            {
                var tableB = fractionTables.Get(tableA.Name);
                if (tableB == null)
                {
                    return;
                }
                var table = tableA.GetIntByMinusAndRound(tableB, tableNamePostfix, isReplacePrevPosfix);
                dic.TryAdd(table.Name, table);
            });
            var mwTables = new ObjectTableManager(dic, this.OutputBufferCount, OutputDirectory);

            return(mwTables);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 追加列,返回新表
        /// </summary>
        /// <param name="tables"></param>
        /// <param name="appdenColPostfix"></param>
        /// <param name="tableNamePostfix"></param>
        /// <param name="isReplacePrevPosfix"></param>
        /// <returns></returns>
        public ObjectTableManager GetAppendColTables(ObjectTableManager tables, string appdenColPostfix, string tableNamePostfix = "Combined", bool isReplacePrevPosfix = false)
        {
            var newTableManager = new ObjectTableManager(this.OutputDirectory, this.OutputBufferCount, this.Name + "_append_" + tables.Name + "_" + appdenColPostfix);
            int i = -1;

            foreach (var tableA in this) //便利PPP星间单差,一次一颗卫星
            {
                i++;
                var tableB = tables.Get(tableA.Name);
                if (tableB == null)
                {
                    continue;
                }

                var newTable = tableA.GetAppendColTable(tableB, appdenColPostfix, tableNamePostfix, isReplacePrevPosfix);

                newTableManager.Add(newTable);
            }
            return(newTableManager);
        }
Exemplo n.º 8
0
        void TimeLooper_Looping(Time Time)
        {
            log.Info("正在计算 " + Time);
            ObjectTableManager TableManager = new Geo.ObjectTableManager(OutputDirectory);


            var           Table            = TableManager.AddTable(FileNamePrefix + "_DOPS_at_" + Geo.Utils.DateTimeUtil.GetDateTimePathString(Time.DateTime));
            GeoGridLooper NewGeoGridLooper = GeoGridLooper.Clone();
            var           DopCaculator     = new DopCaculator(EphemerisService, EnabledPrns, CutOffAngle, SatWeights);

            NewGeoGridLooper.Looping += new Action <LonLat>(delegate(LonLat geo)
            {
                NewGeoGridLooper.IsCancel = GeoGridLooper.IsCancel;
                var geoCoord = new GeoCoord(geo.Lon, geo.Lat, 10);
                Build(DopCaculator, Table, Time, geoCoord, IsSimpleModel);
            });
            NewGeoGridLooper.Init();
            NewGeoGridLooper.Run();
            TableManager.WriteAllToFileAndCloseStream();
            log.Info("计算完毕 " + Time);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 对两个表相同位置的数据进行计算,并返回新表。
        /// </summary>
        /// <param name="tableAManager"></param>
        /// <param name="tableBManager"></param>
        /// <param name="Func"></param>
        /// <param name="postfixOfTableName"></param>
        /// <returns></returns>
        static public ObjectTableManager HandleSameNumeralCellValue(ObjectTableManager tableAManager, ObjectTableManager tableBManager, Func <double, double, double> Func, string postfixOfTableName)
        {
            var dic = new ConcurrentDictionary <string, ObjectTableStorage>();

            Parallel.ForEach <ObjectTableStorage>(tableAManager, tableA =>
            {
                var tableB = tableBManager.Get(tableA.Name);
                if (tableB != null)
                {
                    var newTableName = tableA.Name;
                    if (!String.IsNullOrWhiteSpace(postfixOfTableName))
                    {
                        newTableName += "_" + postfixOfTableName;
                    }
                    var newTable = tableA.HandleSameNumeralCellValue(tableB, Func, newTableName);
                    dic.TryAdd(newTable.Name, newTable);
                }
            });
            var mwTables = new ObjectTableManager(dic, tableAManager.OutputBufferCount, tableAManager.OutputDirectory);

            return(mwTables);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 同步表,删除多余列
        /// </summary>
        /// <param name="tableObjectManager"></param>
        public void SynchronizeTable(ObjectTableManager tableObjectManager)
        {
            List <string> toremoveTable = new List <string>();

            foreach (var item in this)
            {
                var table = (tableObjectManager.Get(item.Name));
                if (table != null)
                {
                    item.SynchronizeCol(table);
                }
                else
                {
                    toremoveTable.Add(item.Name);
                }
            }
            if (toremoveTable.Count > 0)
            {
                this.Remove(toremoveTable);
                log.Debug(this.Name + " 与 " + tableObjectManager.Name + " 同步移除了 " + toremoveTable.Count + " 个表");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 读取返回表集合。移除下划线以后的字符串。
        /// </summary>
        /// <param name="inputPathes"></param>
        /// <param name="nameSplitter"></param>
        /// <returns></returns>
        public static ObjectTableManager Read(string[] inputPathes, string nameSplitter = "_")
        {
            new Log(typeof(ObjectTableManager)).Info("准备并行读取 " + inputPathes.Length + " 个文件!");
            DateTime start = DateTime.Now;
            var      data  = new ConcurrentDictionary <string, ObjectTableStorage>();

            Parallel.ForEach(inputPathes, (path) =>
            {
                if (!File.Exists(path))
                {
                    return;
                }

                ObjectTableReader reader = new ObjectTableReader(path);

                var storage     = reader.Read();
                var key         = Path.GetFileNameWithoutExtension(path);
                var fistDivChar = key.LastIndexOf(nameSplitter);
                var name        = key;
                if (fistDivChar != -1)
                {
                    name = name.Substring(0, fistDivChar);
                }
                storage.Name = name;
                data.TryAdd(storage.Name, storage);
            });


            var tableManager = new ObjectTableManager(data);

            tableManager.OutputDirectory = Path.GetDirectoryName(inputPathes[0]);

            var span = DateTime.Now - start;

            new Log(typeof(ObjectTableManager)).Info("并行读取了" + tableManager.Count + " 个文件,耗时:" + span);

            return(tableManager);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 对两个表相同位置的数据进行计算,并返回新表。
 /// </summary>
 /// <param name="tableBManager"></param>
 /// <param name="Func"></param>
 /// <param name="postfixOfTableName"></param>
 /// <returns></returns>
 public ObjectTableManager HandleSameCellFloatCellValue(ObjectTableManager tableBManager, Func <double, double, double> Func, string postfixOfTableName)
 {
     return(HandleSameNumeralCellValue(this, tableBManager, Func, postfixOfTableName));
 }