Class Grib2Index


  • public class Grib2Index
    extends GribIndex
    Read and Write Grib2 index (gbx9). Hides GribIndexProto sample use:
     GribIndex index = new GribIndex();
     if (!index.readIndex(path))
       index.makeIndex(path);
     
     for (Grib2SectionGridDefinition gds : index.getGds()) {
       if (gdsSet.get(gds.calcCRC()) == null)
         gdsSet.put(gds.calcCRC(), gds);
     }
     
     for (Grib2Record gr : index.getRecords()) {
       gr.setFile(fileno);
     
       Grib2Pds pds = gr.getPDSsection().getPDS();
       int discipline = gr.getDiscipline();
     
       int id = gr.cdmVariableHash();
       Grib2ParameterBean bean = pdsSet.get(id);
       if (bean == null) {
         bean = new Grib2ParameterBean(gr);
         pdsSet.put(id, bean);
         params.add(bean);
       }
       bean.addRecord(gr);
     }
     
    Since:
    4/1/11
    • Constructor Detail

      • Grib2Index

        public Grib2Index()
    • Method Detail

      • getNRecords

        public int getNRecords()
        Description copied from class: GribIndex
        The number of records in the index.
        Specified by:
        getNRecords in class GribIndex
        Returns:
        The number of records in the index.
      • readIndex

        public boolean readIndex​(String filename,
                                 long gribLastModified)
      • readIndex

        public boolean readIndex​(String filename,
                                 long gribLastModified,
                                 CollectionUpdateType force)
        Description copied from class: GribIndex
        Read the gbx9 index file.
        Specified by:
        readIndex in class GribIndex
        Parameters:
        filename - location of the data file
        gribLastModified - last modified date of the data file
        force - rewrite? always, test, nocheck, never
        Returns:
        true if index was successfully read, false if index must be (re)created
      • makeIndex

        public boolean makeIndex​(String filename,
                                 RandomAccessFile dataRaf)
                          throws IOException
        Description copied from class: GribIndex
        Make the gbx9 index file.
        Specified by:
        makeIndex in class GribIndex
        Parameters:
        filename - location of the data file
        dataRaf - already opened data raf (leave open); if null, makeIndex opens and closes)
        Returns:
        true
        Throws:
        IOException - on io error