Beispiel #1
0
 public static void main(String[] args) throws IOException {
   RandomAccessFile raf =
       new RandomAccessFile("Q:/cdmUnitTest/formats/grib2/sfc_d01_20080430_1200_f00000.grb2", "r");
   Grib2RecordScanner scan = new Grib2RecordScanner(raf);
   while (scan.hasNext()) scan.next();
   raf.close();
 }
Beispiel #2
0
 /**
  * tricky bit of business. recapture the entire record based on drs position. for validation.
  *
  * @param raf from this RandomAccessFile
  * @param drsPos Grib2SectionDataRepresentation starts here
  */
 public static Grib2Record findRecordByDrspos(RandomAccessFile raf, long drsPos)
     throws IOException {
   Grib2Record result = null;
   Grib2RecordScanner scanner = new Grib2RecordScanner(raf);
   long pos = Math.max(0, drsPos - 10000); // go back 10000 bytes
   raf.seek(pos);
   while (scanner.hasNext()) { // find GRIB header
     result = scanner.next();
     if (result.getDataRepresentationSection().getStartingPosition() == drsPos) return result;
     if (raf.getFilePointer() > drsPos) break;
   }
   return null;
 }