// *** constructors ******************************************************* /// <summary> Constructs a <tt>Grib2DataRepresentationSection</tt> object from a raf. /// /// </summary> /// <param name="raf">RandomAccessFile with Section DRS content /// </param> /// <throws> IOException if stream contains no valid GRIB file </throws> //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'" public Grib2DataRepresentationSection(System.IO.FileStream raf) { InitBlock(); // octets 1-4 (Length of DRS) length = GribNumbers.int4(raf); //System.out.println( "DRS length=" + length ); section = raf.ReadByte(); //System.out.println( "DRS is 5 section=" + section ); dataPoints = GribNumbers.int4(raf); //System.out.println( "DRS dataPoints=" + dataPoints ); dataTemplate = (int)GribNumbers.uint2(raf); //System.out.println( "DRS dataTemplate=" + dataTemplate ); switch (dataTemplate) { // Data Template Number case 0: case 1: // 0 - Grid point data - simple packing // 1 - Matrix values - simple packing //System.out.println( "DRS dataTemplate=" + dataTemplate ); referenceValue = GribNumbers.IEEEfloat4(raf); binaryScaleFactor = GribNumbers.int2(raf); decimalScaleFactor = GribNumbers.int2(raf); numberOfBits = raf.ReadByte(); //System.out.println( "DRS numberOfBits=" + numberOfBits ); originalType = raf.ReadByte(); //System.out.println( "DRS originalType=" + originalType ); if (dataTemplate == 0) { break; } // case 1 not implememted System.Console.Out.WriteLine("DRS dataTemplate=1 not implemented yet"); break; case 2: case 3: // Grid point data - complex packing //System.out.println( "DRS dataTemplate=" + dataTemplate ); // octet 12 - 15 referenceValue = GribNumbers.IEEEfloat4(raf); // octet 16 - 17 binaryScaleFactor = GribNumbers.int2(raf); // octet 18 - 19 decimalScaleFactor = GribNumbers.int2(raf); // octet 20 numberOfBits = raf.ReadByte(); //System.out.println( "DRS numberOfBits=" + numberOfBits ); // octet 21 originalType = raf.ReadByte(); //System.out.println( "DRS originalType=" + originalType ); // octet 22 splittingMethod = raf.ReadByte(); //System.out.println( "DRS splittingMethod=" + // splittingMethod ); // octet 23 missingValueManagement = raf.ReadByte(); //System.out.println( "DRS missingValueManagement=" + // missingValueManagement ); // octet 24 - 27 primaryMissingValue = GribNumbers.IEEEfloat4(raf); // octet 28 - 31 secondaryMissingValue = GribNumbers.IEEEfloat4(raf); // octet 32 - 35 numberOfGroups = GribNumbers.int4(raf); //System.out.println( "DRS numberOfGroups=" + // numberOfGroups ); // octet 36 referenceGroupWidths = raf.ReadByte(); //System.out.println( "DRS referenceGroupWidths=" + // referenceGroupWidths ); // octet 37 bitsGroupWidths = raf.ReadByte(); // according to documentation subtract referenceGroupWidths bitsGroupWidths = bitsGroupWidths - referenceGroupWidths; //System.out.println( "DRS bitsGroupWidths=" + // bitsGroupWidths ); // octet 38 - 41 referenceGroupLength = GribNumbers.int4(raf); //System.out.println( "DRS referenceGroupLength=" + // referenceGroupLength ); // octet 42 lengthIncrement = raf.ReadByte(); //System.out.println( "DRS lengthIncrement=" + // lengthIncrement ); // octet 43 - 46 lengthLastGroup = GribNumbers.int4(raf); //System.out.println( "DRS lengthLastGroup=" + // lengthLastGroup ); // octet 47 bitsScaledGroupLength = raf.ReadByte(); //System.out.println( "DRS bitsScaledGroupLength=" + // bitsScaledGroupLength ); if (dataTemplate == 2) { break; } // case 3 // complex packing & spatial differencing orderSpatial = raf.ReadByte(); //System.out.println( "DRS orderSpatial=" + orderSpatial); descriptorSpatial = raf.ReadByte(); //System.out.println( "DRS descriptorSpatial=" + descriptorSpatial); break; case 40: case 40000: // Grid point data - JPEG 2000 Code Stream Format //System.out.println( "DRS dataTemplate=" + dataTemplate ); referenceValue = GribNumbers.IEEEfloat4(raf); binaryScaleFactor = GribNumbers.int2(raf); decimalScaleFactor = GribNumbers.int2(raf); numberOfBits = raf.ReadByte(); //System.out.println( "DRS numberOfBits=" + numberOfBits ); originalType = raf.ReadByte(); //System.out.println( "DRS originalType=" + originalType ); compressionMethod = raf.ReadByte(); //System.out.println( "DRS compressionMethod=" + compressionMethod ); compressionRatio = raf.ReadByte(); //System.out.println( "DRS compressionRatio=" + compressionRatio ); break; default: break; } } // end of Grib2DataRepresentationSection