Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <param name="dbFields"></param>
        /// <returns></returns>
        protected virtual bool setDBSegmentAttribute(DBSegment dbSegment, string attribute, string valueStr, List <DBField> dbFields)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_FLAGS:
                IntUtil.TryParse(valueStr, out tmp);
                dbSegment.Flags = tmp;
                break;

            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbSegment.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_FLD_ISN:
                int fldIsn;
                IntUtil.TryParse(valueStr, out fldIsn);
                dbSegment.Field = dbFields.Find(x => x.Isn == fldIsn);
                break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setAttribute(DatabaseDefinition databaseDefinition, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_DATABASE_NAME:
                databaseDefinition.Name = valueStr;
                break;

            case ConstInterface.MG_ATTR_DATABASE_LOCATION:
            {
                string localDatabaseLocation = String.Empty;
                databaseDefinition.Location = valueStr;
            }
            break;

            case ConstInterface.MG_ATTR_DATABASE_TYPE:
                IntUtil.TryParse(valueStr, out tmp);
                databaseDefinition.DatabaseType = tmp;
                break;

            case ConstInterface.MG_ATTR_DATABASE_USER_PASSWORD:
            {
                databaseDefinition.UserPassword = valueStr;
            }
            break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setDBKeyAttribute(DBKey dbKey, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_KEY_DB_NAME:
                dbKey.KeyDBName = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbKey.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_FLAGS:
                IntUtil.TryParse(valueStr, out tmp);
                dbKey.Flags = tmp;
                break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="elementName"></param>
        /// <param name="elementValue"></param>
        /// <param name="attributes"></param>
        public void endElement(string elementName, string elementValue, NameValueCollection attributes)
        {
            switch (elementName)
            {
            case ConstInterface.MG_TAG_KEYS:
            case ConstInterface.MG_TAG_SEGS:
            case ConstInterface.MG_TAG_FLDS:
                // closing collection - do nothing
                return;

            case ConstInterface.MG_TAG_DBH:
            case ConstInterface.MG_TAG_DBH_DATA_ID:
                // set the attributes
                dataSourceBuilder.SetAttributes(dataSourceDefinition, attributes);
                break;

            case ConstInterface.MG_TAG_FLD:
                // create the field and add it to the DataSourceDefinition
                DBField field = new DBField();
                dataSourceBuilder.SetDBFieldAttributes(field, attributes);
                dataSourceBuilder.AddField(dataSourceDefinition, field);
                break;

            case ConstInterface.MG_TAG_KEY:
                // create the key and add it to the DataSourceDefinition
                DBKey key = new DBKey();
                dataSourceBuilder.SetDBKeyAttributes(key, attributes);
                // Add the segments collection and reset the local one
                key.Segments = segments;
                segments     = new List <DBSegment>();
                dataSourceBuilder.AddKey(dataSourceDefinition, key);
                break;

            case ConstInterface.MG_TAG_SEG:
                // create the segment and add it to the DataSourceDefinition
                DBSegment segment = new DBSegment();
                dataSourceBuilder.SetDBSegmentAttributes(segment, attributes, dataSourceDefinition.Fields);
                dataSourceBuilder.AddSegment(dataSourceDefinition, segment);
                break;

            case ConstInterface.MG_TAG_SEGMENT:
                // Get the segment's isn and add the segment to the local segment collection. This way it will be added
                // later to the right key
                int isn;
                IntUtil.TryParse((string)attributes.GetValues(0)[0], out isn);
                segments.Add(dataSourceDefinition.Segments.Find(x => x.Isn == isn));
                break;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///  Sets the Data Source Definition
        /// </summary>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        private void SetDataSourceDefinitionAttribute(string valueStr)
        {
            int ctlIdx;
            int tableIsn;

            String[] data = StrUtil.tokenize(valueStr, ",");
            Debug.Assert(data.Length > 1);
            IntUtil.TryParse(data[0], out ctlIdx);
            IntUtil.TryParse(data[1], out tableIsn);
            DataSourceId id = new DataSourceId();

            id.CtlIdx            = ctlIdx;
            id.Isn               = tableIsn;
            DataSourceDefinition = ClientManager.Instance.LocalManager.ApplicationDefinitions.DataSourceDefinitionManager.GetDataSourceDefinition(id);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///  Sets the value of specific attribute (according the data from parser)
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr">value of attribute</param>
        /// <returns></returns>
        protected virtual bool setAttribute(string attribute, string valueStr)
        {
            int num;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_TASK_TABLE_NAME_EXP:
                IntUtil.TryParse(valueStr, out num);
                NameExpression = num;
                break;

            case ConstInterface.MG_ATTR_TASK_TABLE_ACCESS:
                Access = (Access)valueStr[0];
                break;

            case ConstInterface.MG_ATTR_TASK_TABLE_IDENTIFIER:
                SetDataSourceDefinitionAttribute(valueStr);
                break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setAttribute(DataSourceDefinition dataSourceDefinition, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.Id.Isn = tmp;
                break;

            case XMLConstants.MG_ATTR_CTL_IDX:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.Id.CtlIdx = tmp;
                break;

            case ConstInterface.MG_ATTR_NAME:
                dataSourceDefinition.Name = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_FLAGS:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.Flags = tmp;
                break;

            case ConstInterface.MG_ATTR_DBASE_NAME:
                dataSourceDefinition.DBaseName = valueStr == null ? null : valueStr.ToUpper();
                break;

            case ConstInterface.MG_ATTR_POSITION_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.PositionIsn = tmp;
                break;

            case ConstInterface.MG_ATTR_ARRAY_SIZE:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.ArraySize = tmp;
                break;

            case ConstInterface.MG_ATTR_ROW_IDENTIFIER:
                dataSourceDefinition.RowIdentifier = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_CHECK_EXIST:
                dataSourceDefinition.CheckExist = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DEL_UPD_MODE:
                dataSourceDefinition.DelUpdMode = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DBH_DATA_URL:
                dataSourceDefinition.FileUrl = XmlParser.unescape(valueStr);

                Debug.Assert(DataSourceReader != null);
                byte[] buf = DataSourceReader(dataSourceDefinition.FileUrl);
                new DataSourceDefinitionSaxHandler(dataSourceDefinition, this, buf);
                break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setDBFieldAttribute(DBField dbField, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_ATTR:
                dbField.Attr = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_ALLOW_NULL:
                dbField.AllowNull = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_DEFAULT_NULL:
                dbField.DefaultNull = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_STORAGE:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Storage = (FldStorage)tmp;
                break;

            case ConstInterface.MG_ATTR_LENGTH:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Length = tmp;
                break;

            case ConstInterface.MG_ATTR_DATASOURCE_DEFINITION:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.DataSourceDefinition = (DatabaseDefinitionType)tmp;
                break;

            case ConstInterface.MG_ATTR_DIFF_UPDATE:
                dbField.DiffUpdate = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DEC:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Dec = tmp;
                break;

            case ConstInterface.MG_ATTR_WHOLE:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Whole = tmp;
                break;

            case ConstInterface.MG_ATTR_PART_OF_DATETIME:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.PartOfDateTime = tmp;
                break;

            case ConstInterface.MG_ATTR_DEFAULT_STORAGE:
                dbField.DefaultStorage = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_CONTENT:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.BlobContent = (BlobContent)BlobType.ParseContentType(tmp);
                break;

            case ConstInterface.MG_ATTR_PICTURE:
                dbField.Picture = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_DEFAULT_VALUE:
                dbField.DbDefaultValue = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_FLD_DB_INFO:
                dbField.DbInfo = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_NAME:
                dbField.DbName = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_TYPE:
                dbField.DbType = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_USER_TYPE:
                dbField.UserType = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_NULL_DISPLAY:
                dbField.NullDisplay = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_DEFAULTVALUE:
                dbField.DefaultValue = valueStr;
                if (dbField.Attr == (char)StorageAttribute.ALPHA || dbField.Attr == (char)StorageAttribute.UNICODE)
                {
                    dbField.DefaultValue = XmlParser.unescape(valueStr);
                    dbField.DefaultValue = StrUtil.padStr(dbField.DefaultValue, dbField.Length);
                }
                else if (dbField.DefaultValue.Length == 0 && dbField.Attr != (char)StorageAttribute.BLOB &&
                         dbField.Attr != (char)StorageAttribute.BLOB_VECTOR)
                {
                    dbField.DefaultValue = null;
                }
                else if (dbField.Attr == (char)StorageAttribute.BLOB)
                {
                    dbField.DefaultValue = BlobType.createFromString(dbField.DefaultValue, (char)dbField.BlobContent);
                }
                break;

            case ConstInterface.MG_ATTR_FIELD_NAME:
                dbField.Name = XmlParser.unescape(valueStr);
                break;

            default:
                return(false);
            }
            return(true);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///  读取RINEX文件的头文件。
        /// </summary>
        /// <param name="path">文件路径</param>
        /// <returns></returns>
        public IonoHeader ReadHeader(string path)
        {
            if (!Geo.Utils.FileUtil.IsValid(path))
            {
                return(null);
            }
            IonoHeader header = new IonoHeader();

            header.FileName = Path.GetFileName(path);
            using (StreamReader r = new StreamReader(path, true))
            {
                int    lineIndex = 0;
                string line      = null;
                while ((line = ReadNextNoNullLine(r)) != null)
                {
                    lineIndex++;
                    //中文字符支持
                    int    nonAscCount = StringUtil.GetNonAscCount(line.Substring(0, 60 > line.Length ? line.Length : 60));
                    string headerLabel = line.Substring(60 - nonAscCount).TrimEnd();//header label 61-80
                    if (headerLabel.Contains(RinexHeaderLabel.END_OF_HEADER))
                    {
                        break;
                    }
                    string content = line.Substring(0, 60);
                    if (String.IsNullOrWhiteSpace(content))
                    {
                        continue;
                    }                                                    //没有内容

                    switch (headerLabel)
                    {
                    case RinexHeaderLabel.IONEX_VERSION_TYPE:
                        header.Version           = double.Parse(line.Substring(0, 8));
                        header.FileType          = line.Substring(20, 1);
                        header.SatSysOrTheoModel = line.Substring(40, 3);
                        break;

                    case RinexHeaderLabel.PGM_RUN_BY_DATE:
                        header.FileInfo.CreationProgram = line.Substring(0, 20).TrimEnd();
                        header.FileInfo.CreationAgence  = line.Substring(20, 20).Trim();
                        header.FileInfo.CreationDate    = line.Substring(40, 20).TrimEnd();
                        break;

                    case RinexHeaderLabel.COMMENT:
                        if (header.Comments == null)
                        {
                            header.Comments = new List <string>();
                        }
                        header.Comments.Add(line.Substring(0, 60 - nonAscCount).Trim());
                        break;

                    case RinexHeaderLabel.DESCRIPTION:
                        header.Description = (line.Substring(0, 60 - nonAscCount).Trim());
                        break;

                    case RinexHeaderLabel.EPOCH_OF_FIRST_MAP:
                        header.EpochOfFirstMap = Time.Parse(line.Substring(0, 60 - nonAscCount).Trim());
                        break;

                    case RinexHeaderLabel.EPOCH_OF_LAST_MAP:
                        header.EpochOfLastMap = Time.Parse(line.Substring(0, 60 - nonAscCount).Trim());
                        break;

                    case RinexHeaderLabel.INTERVAL:
                        header.Interval = double.Parse(line.Substring(0, 10));
                        break;

                    case RinexHeaderLabel.OF_MAPS_IN_FILE:
                        var str = line.Substring(0, 60);
                        if (String.IsNullOrWhiteSpace(str))
                        {
                            break;
                        }
                        header.NumOfTotalMaps = IntUtil.TryParse(str);
                        break;

                    case RinexHeaderLabel.MAPPING_FUNCTION:
                        header.Description = (line.Substring(0, 60 - nonAscCount).Trim());
                        break;

                    case RinexHeaderLabel.ELEVATION_CUTOFF:
                        header.ElevatonCutOff = StringUtil.ParseDouble(line.Substring(0, 10));
                        break;

                    case RinexHeaderLabel.OBSERVABLES_USED:
                        header.ObservablesUsed = (line.Substring(0, 60 - nonAscCount).Trim());
                        break;

                    case RinexHeaderLabel.OF_STATIONS:
                        var str2 = line.Substring(0, 6);
                        if (String.IsNullOrWhiteSpace(str2))
                        {
                            break;
                        }
                        header.NumOfStations = IntUtil.TryParse(str2);
                        break;

                    case RinexHeaderLabel.OF_SATELLITES:
                        var str3 = line.Substring(0, 6);
                        if (String.IsNullOrWhiteSpace(str3))
                        {
                            break;
                        }
                        header.NumOfSatellites = IntUtil.TryParse(str3);
                        break;

                    case RinexHeaderLabel.BASE_RADIUS:
                        header.MeanEarthRadius = double.Parse(line.Substring(0, 10));
                        break;

                    case RinexHeaderLabel.MAP_DIMENSION:
                        var str4 = line.Substring(0, 6);
                        if (String.IsNullOrWhiteSpace(str4))
                        {
                            break;
                        }
                        header.MapDimension = IntUtil.TryParse(str4);
                        break;

                    case RinexHeaderLabel.HGT1_HGT2_DHGT:
                        header.HeightRange = ParseIncreaseValue(line);
                        break;

                    case RinexHeaderLabel.LON1_LON2_DLON:
                        header.HeightRange = ParseIncreaseValue(line);
                        break;

                    case RinexHeaderLabel.LAT1_LAT2_DLAT:
                        header.HeightRange = ParseIncreaseValue(line);
                        break;

                    case RinexHeaderLabel.EXPONENT:
                        header.Exponent = int.Parse(line.Substring(0, 6));
                        break;

                    case RinexHeaderLabel.START_OF_AUX_DATA:
                        header.StartOfAuxData = line.Substring(0, 60).Trim();
                        break;

                    case RinexHeaderLabel.END_OF_AUX_DATA:
                        header.EndOfAuxData = line.Substring(0, 60).Trim();
                        break;

                    case RinexHeaderLabel.STATION_BIAS_RMS:
                        var satFlag  = line.Substring(3, 1);                                  //GNSS系统标识 如 G
                        var siteName = satFlag + "_" + line.Substring(6, 4).Trim().ToLower(); //IGS code
                        var val      = new RmsedNumeral()
                        {
                            Value = Double.Parse(line.Substring(26, 10)),
                            Rms   = Double.Parse(line.Substring(36, 10)),
                        };
                        header.StationsWithBiasRms[siteName] = val;
                        break;

                    case RinexHeaderLabel.PRN_BIAS_RMS:
                        var Name = SatelliteNumber.Parse(line.Substring(0, 6).Trim());
                        var val2 = new RmsedNumeral()
                        {
                            Value = Double.Parse(line.Substring(6, 10)),
                            Rms   = Double.Parse(line.Substring(16, 10)),
                        };
                        header.SatellitesWithBiasRms[Name] = val2;
                        break;

                    case RinexHeaderLabel.END_OF_HEADER:
                        return(header);

                    default: break;
                    }
                    header.LineNumber = lineIndex + 1;
                }
            }

            return(header);
        }