Ejemplo n.º 1
0
 internal EquatorialAzimuthalEquidistantProjectionGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     Dx = reader.ReadUInt32() * 1e-3f;
     Dy = reader.ReadUInt32() * 1e-3f;
     ProjectionCenter = reader.ReadUInt8();
     ScanMode         = reader.ReadUInt8();
 }
Ejemplo n.º 2
0
        internal static GridDefinitionSection BuildFrom(BufferedBinaryReader reader)
        {
            var currentPosition = reader.Position;
            var length          = reader.ReadUInt32();

            var section = reader.ReadUInt8();             // This is section 3

            if (section != (int)SectionCode.GridDefinitionSection)
            {
                throw new UnexpectedGribSectionException(SectionCode.GridDefinitionSection, section);
            }

            var source = reader.ReadUInt8();

            var numberPoints = reader.ReadUInt32();

            var olLength = reader.ReadUInt8();

            var olInterpretation = reader.ReadUInt8();

            var templateNumber = reader.ReadUInt16();

            var gridDefinition = GridDefinitionFactories.Build(reader, templateNumber);

            // Prevent from over-reading the stream
            reader.Seek(currentPosition + length, SeekOrigin.Begin);

            return(new GridDefinitionSection(length, section, source, numberPoints, olLength, olInterpretation,
                                             templateNumber, gridDefinition));
        }
Ejemplo n.º 3
0
        private void CreateTables()
        {
            if (_tables != null)
            {
                throw new BadMetadataException("Multiple table heaps.");
            }

            _reader.Advance(4);             //reserved: 4, always 0

            var header = new
            {
                MajorVersion = _reader.ReadUInt8(),
                MinorVersion = _reader.ReadUInt8(),
                HeapSizes    = _reader.ReadUInt8(),
                _            = _reader.Advance(1),              //reserved: 1, always 1
                Valid        = _reader.ReadUInt64(),
                Sorted       = _reader.ReadUInt64(),
            };

            _heapSizes = header.HeapSizes;

            // read table row nums
            ulong present = header.Valid;             // if bit is set table is presented, otherwise it is empty

            _tables = new MetadataTable[MaxTableCount];
            for (int i = 0; i < MaxTableCount; i++)
            {
                //NOTE: If flag set table is presented
                if (((present >> i) & 1) != 0)
                {
                    int rowCount = _reader.ReadInt32();
                    var id       = (TableId)i;
                    var table    = Schema.CreateTable(id);
                    table.RowCount = rowCount;
                    table.IsSorted = ((header.Sorted >> i) & 1) != 0;
                    _tables[i]     = table;
                }
            }

            //Setup tables (Offset, RowSize, Size)
            long pos = _reader.Position;

            for (int i = 0; i < MaxTableCount; i++)
            {
                var table = _tables[i];
                if (table != null)
                {
                    table.Offset = pos;
                    int rowSize = 0;
                    foreach (var column in table.Columns)
                    {
                        column.Size = GetColumnSize(column);
                        rowSize    += column.Size;
                    }
                    table.RowSize = rowSize;
                    table.Size    = table.RowCount * rowSize;
                    pos          += table.Size;
                }
            }
        }
 internal SphericalHarmonicCoefficientsGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     J      = reader.ReadSingle();
     K      = reader.ReadSingle();
     M      = reader.ReadSingle();
     Method = reader.ReadUInt8();
     Mode   = reader.ReadUInt8();
 }
Ejemplo n.º 5
0
 internal PolarStereographicProjectionGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     Lad = reader.ReadInt32() * 1e-6;
     Lov = reader.ReadUInt32() * 1e-6;
     Dx  = reader.ReadUInt32() * 1e-3;
     Dy  = reader.ReadUInt32() * 1e-3;
     ProjectionCenter = reader.ReadUInt8();
     ScanMode         = reader.ReadUInt8();
 }
Ejemplo n.º 6
0
        internal GridPointDataSimplePacking(BufferedBinaryReader reader)
        {
            ReferenceValue     = reader.ReadSingle();
            BinaryScaleFactor  = reader.ReadInt16();
            DecimalScaleFactor = reader.ReadInt16();
            NumberOfBits       = reader.ReadUInt8();

            OriginalFieldValuesType = (OriginalFieldValuesType)reader.ReadUInt8();
        }
Ejemplo n.º 7
0
 internal SpaceViewPerspectiveOrOrthographicGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     Lap        = reader.ReadInt32();
     Lop        = reader.ReadUInt32();
     Resolution = reader.ReadUInt8();
     Dx         = reader.ReadUInt32();
     Dy         = reader.ReadUInt32();
     Xp         = reader.ReadUInt32() * 1e-3f;
     Yp         = reader.ReadUInt32() * 1e-3f;
     ScanMode   = reader.ReadUInt8();
     Angle      = reader.ReadUInt32();
     Altitude   = reader.ReadUInt32() * 1_000_000;
     Xo         = reader.ReadUInt32();
     Yo         = reader.ReadUInt32();
 }
Ejemplo n.º 8
0
		private IArgument ReadNamedArgument(BufferedBinaryReader reader)
		{
			var arg = new Argument
				{
					Kind = ((ArgumentKind)reader.ReadUInt8())
				};

			if (!(arg.Kind == ArgumentKind.Field || arg.Kind == ArgumentKind.Property))
				throw new BadMetadataException();

			var elemType = (ElementType)reader.ReadUInt8();
			IType enumType;

			switch (elemType)
			{
				case ElementType.CustomArgsEnum:
					enumType = ReadEnumType(reader);
					arg.Type = enumType;
					arg.Name = reader.ReadCountedUtf8();
					arg.Value = ReadValue(reader, enumType);
					break;

				case ElementType.ArraySz:
					elemType = (ElementType)reader.ReadUInt8();
					if (elemType == ElementType.CustomArgsEnum)
					{
						enumType = ReadEnumType(reader);
						arg.Name = reader.ReadCountedUtf8();
						ResolveNamedArgType(arg, _owner.Type);
						arg.Value = ReadArray(reader, enumType);
					}
					else
					{
						arg.Name = reader.ReadCountedUtf8();
						ResolveNamedArgType(arg, _owner.Type);
						arg.Value = ReadArray(reader, elemType);
					}
					break;

				default:
					arg.Name = reader.ReadCountedUtf8();
					ResolveNamedArgType(arg, _owner.Type);
					arg.Value = ReadValue(reader, elemType);
					break;
			}

			return arg;
		}
Ejemplo n.º 9
0
        internal static DataRepresentationSection BuildFrom(BufferedBinaryReader reader)
        {
            var sectionStartPosition = reader.Position;

            // octets 1-4 (Length of DRS)
            var length = reader.ReadUInt32();

            var section = reader.ReadUInt8();

            if (section != (int)SectionCode.DataRepresentationSection)
            {
                throw new UnexpectedGribSectionException(
                          SectionCode.DataRepresentationSection,
                          section
                          );
            }

            var dataPoints = reader.ReadUInt32();

            var dataTemplateNumber = reader.ReadUInt16();

            var dataRepresentation = DataRepresentationFactory.Build(reader, dataTemplateNumber);

            // Prevent from over-reading the stream
            reader.Seek(sectionStartPosition + length, SeekOrigin.Begin);

            return(new DataRepresentationSection(length, section, dataPoints, dataTemplateNumber, dataRepresentation));
        }
Ejemplo n.º 10
0
        internal ProductDefinition0008(
            BufferedBinaryReader reader,
            Discipline discipline) : base(reader, discipline)
        {
            OverallTimeIntervalEnd = reader.ReadDateTime();
            RegisterContent(ProductDefinitionContent.OverallTimeIntervalEnd, () => OverallTimeIntervalEnd);

            // 42
            TimeRangeNumber = reader.ReadUInt8();

            // 43-46
            MissingDataValuesTotalNumber = reader.ReadUInt32();

            //47
            StatisticalProcess = reader.ReadUInt8();

            //48
            StatisticalProcessingTimeIncrementType = reader.ReadUInt8();

            //49
            StatisticalProcessingTimeRangeUnit = (TimeRangeUnit)reader.ReadUInt8();

            //50-53
            StatisticalProcessingTimeRangeLength = reader.ReadUInt32();

            var timeRange = CalculateTimeRangeFrom(StatisticalProcessingTimeRangeUnit, StatisticalProcessingTimeRangeLength);

            if (timeRange.HasValue)
            {
                RegisterContent(ProductDefinitionContent.StatisticalProcessingTimeRange, () => timeRange.Value);
            }

            //54
            SuccessiveFieldsIncrementUnit = (TimeRangeUnit)reader.ReadUInt8();

            //55-58
            SuccessiveFieldsTimeIncrement = reader.ReadUInt32();

            var successiveFieldsTimeIncrement = CalculateTimeRangeFrom(SuccessiveFieldsIncrementUnit, SuccessiveFieldsTimeIncrement);

            if (successiveFieldsTimeIncrement.HasValue)
            {
                RegisterContent(ProductDefinitionContent.StatisticalProcessingTimeRange, () => successiveFieldsTimeIncrement.Value);
            }
        }
Ejemplo n.º 11
0
        private protected ProductDefinition(BufferedBinaryReader reader, Discipline discipline)
        {
            Offset                = reader.Position;
            ParameterCategory     = reader.ReadUInt8();
            ParameterNumber       = reader.ReadUInt8();
            Parameter             = CodeTables.Parameter.Get(discipline, ParameterCategory, ParameterNumber);
            GeneratingProcessType = (GeneratingProcessType)reader.ReadUInt8();

            RegisterContent(ProductDefinitionContent.ParameterCategory, () => ParameterCategory);
            RegisterContent(ProductDefinitionContent.ParameterNumber, () => ParameterNumber);

            if (Parameter.HasValue)
            {
                RegisterContent(ProductDefinitionContent.Parameter, () => Parameter.Value);
            }

            RegisterContent(ProductDefinitionContent.GeneratingProcessType, () => GeneratingProcessType);
        }
Ejemplo n.º 12
0
        private static object ReadValue(BufferedBinaryReader reader, SystemTypeCode type)
        {
            switch (type)
            {
            case SystemTypeCode.Boolean:
                return(reader.ReadBoolean());

            case SystemTypeCode.Int8:
                return(reader.ReadInt8());

            case SystemTypeCode.UInt8:
                return(reader.ReadUInt8());

            case SystemTypeCode.Int16:
                return(reader.ReadInt16());

            case SystemTypeCode.UInt16:
                return(reader.ReadUInt16());

            case SystemTypeCode.Int32:
                return(reader.ReadInt32());

            case SystemTypeCode.UInt32:
                return(reader.ReadUInt32());

            case SystemTypeCode.Int64:
                return(reader.ReadInt64());

            case SystemTypeCode.UInt64:
                return(reader.ReadUInt64());

            case SystemTypeCode.Single:
                return(reader.ReadSingle());

            case SystemTypeCode.Double:
                return(reader.ReadDouble());

            case SystemTypeCode.Decimal:
                throw new NotImplementedException();

            case SystemTypeCode.DateTime:
                throw new NotImplementedException();

            case SystemTypeCode.Char:
                return(reader.ReadChar());

            case SystemTypeCode.String:
                return(reader.ReadCountedUtf8());

            case SystemTypeCode.Enum:
                throw new NotImplementedException();

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 13
0
        public static FieldSignature Decode(BufferedBinaryReader reader)
        {
            var h = (SignatureFlags)reader.ReadUInt8();

            if ((h & SignatureFlags.TYPEMASK) != SignatureFlags.FIELD)
            {
                throw new BadMetadataException("Incorrect signature for field.");
            }
            return(new FieldSignature(TypeSignature.Decode(reader)));
        }
Ejemplo n.º 14
0
 internal MercatorGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     Lad      = reader.ReadInt32() * 1e-6;
     La2      = reader.ReadInt32() * 1e-6;
     Lo2      = reader.ReadUInt32() * 1e-6;
     ScanMode = reader.ReadUInt8();
     Angle    = reader.ReadUInt32();
     Dx       = reader.ReadUInt32() * 1e-3;
     Dy       = reader.ReadUInt32() * 1e-3;
 }
Ejemplo n.º 15
0
        private protected EarthGridDefinition(BufferedBinaryReader reader) : base(reader)
        {
            EarthShapeCode = reader.ReadUInt8();

            EarthRadius    = reader.ReadScaledValue();
            EarthMajorAxis = reader.ReadScaledValue();
            EarthMinorAxis = reader.ReadScaledValue();

            EarthShape = ComputeEarthShape();
        }
        internal GaussianLatLonGridDefinition(BufferedBinaryReader reader) : base(reader)
        {
            Angle             = reader.ReadUInt32();
            Subdivisionsangle = reader.ReadUInt32();
            if (Angle == 0)
            {
                Ratio = 1e-6;
            }
            else
            {
                Ratio = Angle / (double)Subdivisionsangle;
            }

            La1        = reader.ReadInt32() * Ratio;
            Lo1        = reader.ReadInt32() * Ratio;
            Resolution = reader.ReadUInt8();
            La2        = reader.ReadUInt32() * Ratio;
            Lo2        = reader.ReadUInt32() * Ratio;
            Dx         = reader.ReadUInt32() * Ratio;
            N          = reader.ReadUInt32();
            ScanMode   = reader.ReadUInt8();
        }
Ejemplo n.º 17
0
        internal static BitmapSection BuildFrom(BufferedBinaryReader raf, long dataPointsNumber)
        {
            var length = raf.ReadUInt32();

            var section = raf.ReadUInt8();

            if (section != (int)SectionCode.BitmapSection)
            {
                throw new UnexpectedGribSectionException(
                          SectionCode.BitmapSection,
                          section
                          );
            }

            var bitmapIndicator = raf.ReadUInt8();
            var bitmapOffset    = raf.Position;

            // Skip through the bitmap data
            // There is no need to load it now
            raf.Skip((int)length - 6);

            return(new BitmapSection(length, section, bitmapIndicator, dataPointsNumber, bitmapOffset));
        }
Ejemplo n.º 18
0
        internal static IndicatorSection BuildFrom(BufferedBinaryReader reader)
        {
            var fileStart = reader.Read(Constants.GribFileStart.Length);

            if (!Constants.GribFileStart.SequenceEqual(fileStart))
            {
                throw new BadGribFormatException("Invalid file start.");
            }

            // Ignore the 2 reserved bytes
            reader.Skip(2);

            var disciplineNumber = reader.ReadUInt8();
            var gribEdition      = reader.ReadUInt8();

            if (gribEdition != 2)
            {
                throw new NotSupportedException($"Only GRIB edition 2 is supported. GRIB edition {gribEdition} is not yet supported");
            }

            var totalLength = reader.ReadUInt64();

            return(new IndicatorSection(disciplineNumber, 2, totalLength));
        }
Ejemplo n.º 19
0
        internal ProductDefinition0000(BufferedBinaryReader reader, Discipline discipline) : base(
                reader, discipline)
        {
            GeneratingProcessIdentifier = reader.ReadUInt8();
            HoursAfter              = reader.ReadUInt16();
            MinutesAfter            = reader.ReadUInt8();
            ObservationalDataCutoff = TimeSpan.FromHours(HoursAfter) + TimeSpan.FromMinutes(MinutesAfter);
            TimeRangeUnit           = (TimeRangeUnit)reader.ReadUInt8();
            ForecastTime            = reader.ReadInt32();

            FirstFixedSurfaceType  = (FixedSurfaceType)reader.ReadUInt8();
            FirstFixedSurfaceValue = reader.ReadScaledValue();

            SecondFixedSurfaceType  = (FixedSurfaceType)reader.ReadUInt8();
            SecondFixedSurfaceValue = reader.ReadScaledValue();

            RegisterContent(ProductDefinitionContent.GeneratingProcessId, () => GeneratingProcessIdentifier);
            RegisterContent(ProductDefinitionContent.ObservationalDataCutoff, () => ObservationalDataCutoff);
            var forecastTime = CalculateTimeRangeFrom(TimeRangeUnit, ForecastTime);

            if (forecastTime.HasValue)
            {
                RegisterContent(ProductDefinitionContent.ForecastTime, () => forecastTime.Value);
            }

            RegisterContent(ProductDefinitionContent.FirstFixedSurfaceType, () => FirstFixedSurfaceType);
            if (FirstFixedSurfaceValue.HasValue)
            {
                RegisterContent(ProductDefinitionContent.FirstFixedSurfaceValue, () => FirstFixedSurfaceValue.Value);
            }
            RegisterContent(ProductDefinitionContent.SecondFixedSurfaceType, () => SecondFixedSurfaceType);
            if (SecondFixedSurfaceValue.HasValue)
            {
                RegisterContent(ProductDefinitionContent.SecondFixedSurfaceValue, () => SecondFixedSurfaceValue.Value);
            }
        }
Ejemplo n.º 20
0
        internal LatLonGridDefinition(BufferedBinaryReader reader) : base(reader)
        {
            Angle             = reader.ReadUInt32();
            SubdivisionsAngle = reader.ReadUInt32();
            double ratio;

            if (Angle == 0)
            {
                ratio = 1e-6;
            }
            else
            {
                ratio = Angle / (double)SubdivisionsAngle;
            }

            La1 = reader.ReadInt32() * ratio;
            Lo1 = reader.ReadInt32() * ratio;
            ResolutionAndComponent = (ResolutionAndComponent)reader.ReadUInt8();
            La2      = reader.ReadInt32() * ratio;
            Lo2      = reader.ReadInt32() * ratio;
            Dx       = reader.ReadInt32() * ratio;
            Dy       = reader.ReadInt32() * ratio;
            ScanMode = reader.ReadUInt8();
        }
Ejemplo n.º 21
0
        public static string ReadCountedUtf8(this BufferedBinaryReader reader)
        {
            int b0 = reader.ReadUInt8();

            if (b0 == 0xFF)
            {
                return(null);
            }
            if (b0 == 0)
            {
                return(string.Empty);
            }
            int len = reader.ReadPackedInt(b0);

            return(reader.ReadUtf8(len));
        }
Ejemplo n.º 22
0
        internal static LocalUseSection BuildFrom(BufferedBinaryReader reader)
        {
            // octets 1-4 (Length of GDS)
            var length = reader.ReadUInt32();

            var section = reader.ReadUInt8();

            if (section != (int)SectionCode.LocalUseSection)
            {
                return(null);
            }

            var contentOffset = reader.Position;

            reader.Skip((int)length - 5);
            return(new LocalUseSection(length, section, contentOffset));
        }
Ejemplo n.º 23
0
        public static MetadataSignature DecodeMember(BufferedBinaryReader reader)
        {
            var flags = (SignatureFlags)reader.ReadUInt8();
            var type  = flags & SignatureFlags.TYPEMASK;

            switch (type)
            {
            case SignatureFlags.FIELD:
                return(new FieldSignature(TypeSignature.Decode(reader)));

            case SignatureFlags.LOCAL:
                throw new NotImplementedException();

            default:
                return(MethodSignature.Decode(reader, flags));
            }
        }
Ejemplo n.º 24
0
 internal TriangularGridBasedOnAnIcosahedronGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     N2          = reader.ReadUInt8();
     N3          = reader.ReadUInt8();
     Ni          = reader.ReadUInt16();
     Nd          = reader.ReadUInt8();
     PoleLat     = reader.ReadInt32() * 1e-6f;
     PoleLon     = reader.ReadUInt32() * 1e-6f;
     Lonofcenter = reader.ReadUInt32();
     Position    = reader.ReadUInt8();
     Order       = reader.ReadUInt8();
     ScanMode    = reader.ReadUInt8();
     N           = reader.ReadUInt32();
 }
Ejemplo n.º 25
0
        internal static IdentificationSection BuildFrom(BufferedBinaryReader reader)
        {
            // section 1 octet 1-4 (length of section)
            var length = reader.ReadUInt32();

            var section = reader.ReadUInt8();

            if (section != (int)SectionCode.IdentificationSection)
            {
                return(null);
            }

            // Center  octet 6-7
            var centerCode = reader.ReadUInt16();

            // Center  octet 8-9
            var subCenterCode = reader.ReadUInt16();

            // Parameter master table octet 10
            var masterTableVersion = reader.ReadUInt8();

            // Parameter local table octet 11
            var localTableVersion = reader.ReadUInt8();

            // significanceOfRT octet 12
            var significanceOfRt = reader.ReadUInt8();

            // octets 13-19 (base time of forecast)
            var refTime = reader.ReadDateTime();

            var productStatusCode = reader.ReadUInt8();

            var productTypeCode = reader.ReadUInt8();

            return(new IdentificationSection(
                       length,
                       section,
                       centerCode,
                       subCenterCode,
                       masterTableVersion,
                       localTableVersion,
                       significanceOfRt,
                       refTime,
                       productStatusCode,
                       productTypeCode));
        }
Ejemplo n.º 26
0
        internal static DataSection BuildFrom(BufferedBinaryReader reader)
        {
            // octets 1-4 (Length of DS)
            var length = reader.ReadUInt32();

            // octet 5  section 7
            var section = reader.ReadUInt8();

            if (section != (int)SectionCode.DataSection)
            {
                throw new UnexpectedGribSectionException(
                          SectionCode.DataSection,
                          section
                          );
            }

            var dataOffset = reader.Position;

            var dataLength = length - 5;

            reader.Skip((int)dataLength);

            return(new DataSection(length, section, dataOffset, dataLength));
        }
Ejemplo n.º 27
0
        internal static ProductDefinitionSection BuildFrom(BufferedBinaryReader reader, Discipline discipline)
        {
            var currentPosition = reader.Position;

            // octets 1-4 (Length of PDS)
            var length = reader.ReadUInt32();

            // octet 5
            var section = reader.ReadUInt8();

            // octet 6-7
            var coordinates = reader.ReadUInt16();

            // octet 8-9
            var productDefinitionTemplateNumber = reader.ReadUInt16();

            var productDefinition = ProductDefinitionFactories.Build(reader, productDefinitionTemplateNumber, discipline);

            // Prevent from over-reading the stream
            reader.Seek(currentPosition + length, SeekOrigin.Begin);

            return(new ProductDefinitionSection(length, section, coordinates, productDefinitionTemplateNumber,
                                                productDefinition));
        }
Ejemplo n.º 28
0
        internal GridPointDataComplexPacking(BufferedBinaryReader reader) : base(reader)
        {
            GroupSplittingMethod = (GroupSplittingMethod)reader.ReadUInt8();

            MissingValueManagement = (ComplexPackingMissingValueManagement)reader.ReadUInt8();

            PrimaryMissingValue   = reader.ReadSingle();
            SecondaryMissingValue = reader.ReadSingle();
            NumberOfGroups        = reader.ReadUInt32();

            ReferenceGroupWidths = reader.ReadUInt8();

            BitsGroupWidths = reader.ReadUInt8();
            // according to documentation subtract referenceGroupWidths
            BitsGroupWidths = BitsGroupWidths - ReferenceGroupWidths;

            ReferenceGroupLength = reader.ReadUInt32();

            LengthIncrement = reader.ReadUInt8();

            LastGroupLength = reader.ReadUInt32();

            BitsScaledGroupLength = reader.ReadUInt8();
        }
Ejemplo n.º 29
0
		private object ReadValue(BufferedBinaryReader reader, IType type)
		{
			var st = type.SystemType();
			if (st != null)
			{
				switch (st.Code)
				{
					case SystemTypeCode.Boolean:
						return reader.ReadBoolean();
					case SystemTypeCode.Int8:
						return reader.ReadInt8();
					case SystemTypeCode.UInt8:
						return reader.ReadUInt8();
					case SystemTypeCode.Int16:
						return reader.ReadInt16();
					case SystemTypeCode.UInt16:
						return reader.ReadUInt16();
					case SystemTypeCode.Int32:
						return reader.ReadInt32();
					case SystemTypeCode.UInt32:
						return reader.ReadUInt32();
					case SystemTypeCode.Int64:
						return reader.ReadInt64();
					case SystemTypeCode.UInt64:
						return reader.ReadUInt64();
					case SystemTypeCode.Single:
						return reader.ReadSingle();
					case SystemTypeCode.Double:
						return reader.ReadDouble();
					case SystemTypeCode.Char:
						return reader.ReadChar();
					case SystemTypeCode.String:
						return reader.ReadCountedUtf8();
					case SystemTypeCode.Object:
						//boxed value type
						var e = (ElementType)reader.ReadInt8();
						return ReadValue(reader, e);
					case SystemTypeCode.Type:
						return ReadType(reader);
				}
			}

			if (type.TypeKind == TypeKind.Enum)
			{
				return ReadValue(reader, type.ValueType);
			}

			if (type.IsArray)
			{
				int numElem = reader.ReadInt32();
				Array arr = null;
				for (int i = 0; i < numElem; ++i)
				{
					var val = ReadValue(reader, type.ElementType);
					if (arr == null)
						arr = Array.CreateInstance(val.GetType(), numElem);
					arr.SetValue(val, i);
				}
				return arr;
			}

			return null;
		}
Ejemplo n.º 30
0
 private protected GridPointEarthGridDefinition(BufferedBinaryReader reader) : base(reader)
 {
     La1        = reader.ReadInt32() * 1e-6;
     Lo1        = reader.ReadUInt32() * 1e-6;
     Resolution = reader.ReadUInt8();
 }