net.sourceforge.jgrib
Class GribRecordGDS

java.lang.Object
  extended by net.sourceforge.jgrib.GribRecordGDS
Direct Known Subclasses:
GribGDSLambert, GribGDSLatLon, GribGDSPolarStereo

public abstract class GribRecordGDS
extends java.lang.Object

A class that represents the grid definition section (GDS) of a GRIB record.

5 Okt 05 - Changed class to become abstract as intended by RDG all common methods between this class and all known subclasses is changed to abstract methods, so it becomes more clear, which methods one should actually implement, when adding support for a new type of GRIB files.

4 Sep 02 - Modified to be implemented using GribGDSFactory class.

This class is used to store the first 32 octets of the GDS, which are common, or similar, in all GDS types. Sometimes names vary slightly in Table D, but functionality is similar, e.g.

Grid type Octet Id Lat/Lon 7-8 Ni - Number of points along a latitude circle Lambert 7-8 Nx - Number of points along x-axis

Other times, functionality is different, e.g.

Lat/Lon 18-20 La2 - latitude of grid point Lambert 18-20 Lov - the orientation of the grid

However, all sets have at least 32 octets. Those 32 are stored here, and the differences are resolved in the child classes, and therefore, all attributes are set from the Child classes.

The names of the attributes are the same JGrib originally used , for simplicity and continuity. The fact that some grids use a different number of octets for doubles is irrelevant, as the conversion is stored, not the octets.

The child classes should call the proper setters and getters.

The class retains every bit of the original functionality, so it can continue to be used in legacy programs (still limited to grid_type 0 and 10).

New users should not create instances of this class directly (in fact, it should be changed to an abstract class - it's on the to do list), but use the GribGDS factory instead, and add new child classes (e.g. GribGDSXxxx) as needed for additional grid_types.

Version:
3.0
Author:
Benjamin Stark

, Capt Richard D. Gonzalez, USAF (Modified original code)

, Peter Gylling (Made class abstract)


Field Summary
protected  double EARTH_RADIUS
          Radius of earth used in calculating projections per table 7 - assumes spheroid
protected  double grid_dx
          x-distance between two grid points can be delta-Lon or delta x.
protected  double grid_dy
          y-distance of two grid points can be delta-Lat or delta y.
protected  double grid_lat1
          Latitude of grid start point.
protected  double grid_lat2
          Latitude of grid end point.
protected  double grid_latsp
          y-coordinate/latitude of south pole of a rotated lat/lon grid.
protected  double grid_lon1
          Longitude of grid start point.
protected  double grid_lon2
          Longitude of grid end point.
protected  double grid_lonsp
          x-coordinate/longitude of south pole of a rotated lat/lon grid.
protected  int grid_mode
          Mode of grid (See table 7) only 128 supported == increments given)
protected  int grid_nx
          Number of grid columns.
protected  int grid_ny
          Number of grid rows.
protected  double grid_rotang
          Rotation angle of rotated lat/lon grid.
protected  int grid_scan
          Scanning mode (See table 8).
protected  int grid_type
          Type of grid (See table 6)
protected  int length
          Length in bytes of this section.
 
Constructor Summary
GribRecordGDS(BitInputStream in)
          Deprecated. - Call GribGDSFactory.getGDS()
GribRecordGDS(int[] header)
          New constructor created for child classes, which has to be public!
 
Method Summary
abstract  int compare(GribRecordGDS gds)
          rdg - added this method to be used in a comparator for sorting while extracting records.
abstract  boolean equals(java.lang.Object obj)
          Overrides Object.equals() - perfect for testing
abstract  double[] getGridCoords()
          Get grid coordinates in longitude/latitude
abstract  double getGridDX()
          Get x-increment/distance between two grid points.
abstract  double getGridDY()
          Get y-increment/distance between two grid points.
abstract  double getGridLat1()
          Get y-coordinate/latitude of grid start point.
 double getGridLat2()
          NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get y-coordinate/latitude of grid end point.
 double getGridLatSP()
          NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get y-coordinate/latitude of south pole of a rotated latitude/longitude grid.
abstract  double getGridLon1()
          Get x-coordinate/longitude of grid start point.
 double getGridLon2()
          NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get x-coordinate/longitude of grid end point.
 double getGridLonSP()
          NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get x-coordinate/longitude of south pole of a rotated latitude/longitude grid.
abstract  int getGridMode()
          Get grid mode.
abstract  int getGridNX()
          Get number of grid columns.
abstract  int getGridNY()
          Get number of grid rows.
 double getGridRotAngle()
          NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get grid rotation angle of a rotated latitude/longitude grid.
abstract  int getGridScanmode()
          Get scan mode (sign of increments).
abstract  int getGridType()
          Get type of grid.
abstract  int getLength()
          Get length in bytes of this section.
abstract  double[] getXCoords()
          Get all longitide coordinates
abstract  double[] getYCoords()
          Get all latitude coordinates
abstract  int hashCode()
          Overrides Object.hashCode() to be used in hashTables
abstract  boolean isUVEastNorth()
          Table J.Resolution and Component Flags, bit 5 (from left) = 2^(8-5) = 8 = 0x08 : false = u and v components are relative to east, north true = u and v components are relative to grid x,y direction (i,j)
abstract  java.lang.String toString()
          Get a string representation of this GDS.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EARTH_RADIUS

protected final double EARTH_RADIUS
Radius of earth used in calculating projections per table 7 - assumes spheroid

See Also:
Constant Field Values

length

protected int length
Length in bytes of this section.


grid_type

protected int grid_type
Type of grid (See table 6)


grid_nx

protected int grid_nx
Number of grid columns. (Also Ni)


grid_ny

protected int grid_ny
Number of grid rows. (Also Nj)


grid_lat1

protected double grid_lat1
Latitude of grid start point.


grid_lon1

protected double grid_lon1
Longitude of grid start point.


grid_mode

protected int grid_mode
Mode of grid (See table 7) only 128 supported == increments given)


grid_lat2

protected double grid_lat2
Latitude of grid end point.


grid_lon2

protected double grid_lon2
Longitude of grid end point.


grid_dx

protected double grid_dx
x-distance between two grid points can be delta-Lon or delta x.


grid_dy

protected double grid_dy
y-distance of two grid points can be delta-Lat or delta y.


grid_scan

protected int grid_scan
Scanning mode (See table 8).


grid_latsp

protected double grid_latsp
y-coordinate/latitude of south pole of a rotated lat/lon grid.


grid_lonsp

protected double grid_lonsp
x-coordinate/longitude of south pole of a rotated lat/lon grid.


grid_rotang

protected double grid_rotang
Rotation angle of rotated lat/lon grid.

Constructor Detail

GribRecordGDS

public GribRecordGDS(int[] header)
New constructor created for child classes, which has to be public!

Parameters:
header - - integer array of header data (octets 1-6) read in GribGDSFactory exceptions are thrown in children and passed up
See Also:
GribGDSFactory.getGDS(BitInputStream)

GribRecordGDS

public GribRecordGDS(BitInputStream in)
              throws java.io.IOException,
                     NoValidGribException
Deprecated. - Call GribGDSFactory.getGDS()

Constructs a GribRecordGDS object from a bit input stream.

Parameters:
in - bit input stream with GDS content
Throws:
java.io.IOException - if stream can not be opened etc.
NoValidGribException - if stream contains no valid GRIB file
See Also:
GribGDSFactory.getGDS(BitInputStream)
Method Detail

getLength

public abstract int getLength()
Get length in bytes of this section.

Returns:
length in bytes of this section

getGridType

public abstract int getGridType()
Get type of grid.

Returns:
type of grid

getGridNX

public abstract int getGridNX()
Get number of grid columns.

Returns:
number of grid columns

getGridNY

public abstract int getGridNY()
Get number of grid rows.

Returns:
number of grid rows.

getGridLat1

public abstract double getGridLat1()
Get y-coordinate/latitude of grid start point.

Returns:
y-coordinate/latitude of grid start point

getGridLon1

public abstract double getGridLon1()
Get x-coordinate/longitude of grid start point.

Returns:
x-coordinate/longitude of grid start point

getGridMode

public abstract int getGridMode()
Get grid mode. Only 128 (increments given) supported so far.

Returns:
grid mode

getGridDX

public abstract double getGridDX()
Get x-increment/distance between two grid points.

Returns:
x-increment

getGridDY

public abstract double getGridDY()
Get y-increment/distance between two grid points.

Returns:
y-increment

getGridScanmode

public abstract int getGridScanmode()
Get scan mode (sign of increments). Only 64, 128 and 192 supported so far.

Returns:
scan mode

getXCoords

public abstract double[] getXCoords()
Get all longitide coordinates

Returns:
longtitude as double

getYCoords

public abstract double[] getYCoords()
Get all latitude coordinates

Returns:
latitude as double

getGridCoords

public abstract double[] getGridCoords()
Get grid coordinates in longitude/latitude

Returns:
longitide/latituide as doubles

isUVEastNorth

public abstract boolean isUVEastNorth()
Table J.Resolution and Component Flags, bit 5 (from left) = 2^(8-5) = 8 = 0x08 : false = u and v components are relative to east, north true = u and v components are relative to grid x,y direction (i,j)

Returns:
true/false

hashCode

public abstract int hashCode()
Overrides Object.hashCode() to be used in hashTables

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

equals

public abstract boolean equals(java.lang.Object obj)
Overrides Object.equals() - perfect for testing

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

compare

public abstract int compare(GribRecordGDS gds)
rdg - added this method to be used in a comparator for sorting while extracting records. Not currently used in the JGrib library, but is used in a library I'm using that uses JGrib.

Parameters:
gds - - GribRecordGDS
Returns:
- -1 if gds is "less than" this, 0 if equal, 1 if gds is "greater than" this.
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)

toString

public abstract java.lang.String toString()
Get a string representation of this GDS.

Overrides:
toString in class java.lang.Object
Returns:
string representation of this GDS
See Also:
Object.toString()

getGridLat2

public double getGridLat2()
NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get y-coordinate/latitude of grid end point.

Returns:
y-coordinate/latitude of grid end point

getGridLon2

public double getGridLon2()
NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get x-coordinate/longitude of grid end point.

Returns:
x-coordinate/longitude of grid end point

getGridLatSP

public double getGridLatSP()
NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get y-coordinate/latitude of south pole of a rotated latitude/longitude grid.

Returns:
latitude of south pole

getGridLonSP

public double getGridLonSP()
NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get x-coordinate/longitude of south pole of a rotated latitude/longitude grid.

Returns:
longitude of south pole

getGridRotAngle

public double getGridRotAngle()
NOTE: This method must remain here, so we don't break backward compability - thus this method does not make any sence if the grid type isn't standard lat/lon or rotated lat/lon Get grid rotation angle of a rotated latitude/longitude grid.

Returns:
rotation angle