Exemple #1
0
        private string GenerateProgramVersionAndAgencyInfo(RinexType version)
        {
            // program, agency, date of generation
            string fileCreationDate = "";

            switch (version)
            {
            case RinexType.Version3:
                fileCreationDate = DateTime.UtcNow.ToString("yyyyMMdd HHmmss") + " UTC";
                break;

            case RinexType.Version2:
            case RinexType.Bipm:
            case RinexType.Cctf:
                fileCreationDate = DateTime.UtcNow.ToString("dd-MMM-yy HH:mm", CultureInfo.InvariantCulture).ToUpper();
                break;

            case RinexType.Unknown:
                break;
            }

            return(string.Format("{0}{1}{2}PGM / RUN BY / DATE",
                                 RinexTools.Consolidate(ProgramName),
                                 RinexTools.Consolidate(AgencyName),
                                 RinexTools.Consolidate(fileCreationDate)
                                 ));
        }
Exemple #2
0
 public MeteoSensorDescription(string observationType, string model, string type, double accuracy)
 {
     this.observationType = observationType.Trim().ToUpper();
     if (observationType.Length > 4)
     {
         this.observationType = unknownObservation;
     }
     this.model    = RinexTools.Consolidate(model);
     this.type     = RinexTools.Consolidate(type);
     this.accuracy = accuracy;
 }
Exemple #3
0
        public string GetObservationType(RinexType version)
        {
            switch (version)
            {
            case RinexType.Unknown:
                return(unknownObservation);

            case RinexType.Version3:
            case RinexType.Version2:
            case RinexType.Bipm:
                if (observationType.Length != 2)
                {
                    return(unknownObservation);
                }
                return(observationType);

            case RinexType.Cctf:
                return(RinexTools.Consolidate(observationType, 4));
            }
            return(unknownObservation); // this can not happen
        }
Exemple #4
0
        private string GenerateLabNameInfo(RinexType version)
        {
            string returnString = "";

            switch (version)
            {
            case RinexType.Version3:
            case RinexType.Version2:
                returnString = RinexTools.Consolidate(AgencyName, 60) + "LAB NAME";
                break;

            case RinexType.Bipm:
            case RinexType.Cctf:
                returnString = RinexTools.Consolidate(bipmStationCode, 60) + "LAB NAME";
                break;

            case RinexType.Unknown:
                returnString = RinexTools.Consolidate("< UNDEFINED >", 60) + "LAB NAME";
                break;
            }
            return(returnString);
        }
Exemple #5
0
        /// <summary>
        /// Generates the file header. AddComment() must be called in advance.
        /// </summary>
        /// <returns>A single string representing the file header.</returns>
        public string ToRinex()
        {
            if (meteoSensorDescriptions.Length < 3)
            {
                return(string.Empty);
            }
            StringBuilder sb = new StringBuilder();

            AddSensorPositionToComments(version);
            sb.AppendLine(GenerateVersionHeaderInfo(version));
            sb.AppendLine(GenerateProgramVersionAndAgencyInfo(version));

            // marker
            switch (version)
            {
            case RinexType.Version3:
            case RinexType.Version2:
                sb.AppendLine(RinexTools.Consolidate(StationName, 60) + "MARKER NAME");
                if (!string.IsNullOrWhiteSpace(StationNumber))
                {
                    sb.AppendLine(RinexTools.Consolidate(StationNumber, 60) + "MARKER NUMBER");
                }
                break;

            case RinexType.Bipm:
            case RinexType.Cctf:
            case RinexType.Unknown:
                break;
            }

            foreach (var s in Comments)
            {
                sb.AppendLine(RinexTools.Consolidate(s, 60) + "COMMENT");
            }
            sb.AppendLine(GenerateLabNameInfo(version));

            // sensor info
            // sb.AppendLine("     3    TD    HR    PR                                    # / TYPES OF OBSERV");

            string typeOfObs = string.Format("{0,6}", meteoSensorDescriptions.Length);

            foreach (var sensor in meteoSensorDescriptions)
            {
                typeOfObs += string.Format("  {0,4}", sensor.GetObservationType(version));
            }
            sb.AppendLine(typeOfObs.PadRight(60, ' ') + "# / TYPES OF OBSERV");
            foreach (var sensor in meteoSensorDescriptions)
            {
                sb.AppendLine(sensor.ToRinex(version));
            }

            // sensor position (not for BIPM / CCTF files)
            switch (version)
            {
            case RinexType.Version3:
            case RinexType.Version2:
                sb.AppendLine(string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0,14:0.0000}{1,14:0.0000}{2,14:0.0000}{3,14:0.0000} PR SENSOR POS XYZ/H", PositionX, PositionY, PositionZ, PositionH));
                break;

            case RinexType.Bipm:
            case RinexType.Cctf:
            case RinexType.Unknown:
                break;
            }

            sb.AppendLine(new string(' ', 60) + "END OF HEADER");
            return(sb.ToString());
        }