Class GSHHSReader

All Implemented Interfaces:
Iterable<Feature>, FeatureSource

@Deprecated public class GSHHSReader extends LineFeatureSource
Deprecated.
This class has been replaced by BinnedGSHHSReader which provides better overall performance. This class uses the full GSHHS binary data files as input, with a supplementary index file to speed up polygon access. The new binned class uses true binned GSHHS polygon data in HDF format with access routines and polygon assembly methods. The new class uses a reduced data file size and is faster at handling small sections of polygons with a large number of points outside the area of interest.

The GSHHS reader class reads Global Self-consistent Hierarchical High-resolution Shorelines (GSHHS) binary data files. GSHHS is distributed as a set of data files and routines that provide worldwide vector coastline data in a closed polygon format. GSHHS is descibed in:

Wessel, P., and W. H. F. Smith, 1996, A global self-consistent, hierarchical, high-resolution shoreline database, J. Geophys. Res., 101, 8741-8743.

and is available from:

http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html

The GSHHS reader can read GSHHS data files either from a set of predefined resource data files or from a user supplied data file. The predefined resources have been passed through a precomputation routine that creates an index of the files based on a 1x1 degree global grid. If the GSHHS reader is created from one of the predefined resource files, the precomputed index file allows for quick selection of polygons via the select() routine. If the GSHHS reader is created from a user file, the entire set of GSHHS polygons is read into memory and the selection method performs no operation.

Since:
3.1.0
Author:
Peter Hollemans
  • Field Details

  • Constructor Details

    • GSHHSReader

      public GSHHSReader(String name)
      Deprecated.
      Creates a new GSHHS reader instance from the database name. By default, there is no minimum area for polygon selection and no polygons are selected.
      Parameters:
      name - the database name. Several predefined database names are available using the constants HIGH, INTER, LOW, and CRUDE. See the constants for descriptions of the database resolutions.
    • GSHHSReader

      public GSHHSReader(double resolution)
      Deprecated.
      Creates a new GSHHS reader instance from the resolution. By default, there is no minimum area for polygon selection and no polygons are selected.
      Parameters:
      resolution - the pixel resolution in kilometers. The resolution determines the tolerance level used to decimate polygons from the full resolution database. Resolution values should reflect the desired accuracy of coastline rendering. For example, if the coastlines are to be rendered on an image where each pixel measures 5 km across, the polygons need not include features any smaller than 5 km. The resolution is used to determine the appropriate predefined database.
    • GSHHSReader

      public GSHHSReader(File file) throws IOException
      Deprecated.
      Creates a new GSHHS reader from the data file. With this constructor, all polygons are selected and the selection method performs no operation.
      Parameters:
      file - the data file to read.
      Throws:
      IOException - if the file had input errors.
    • GSHHSReader

      public GSHHSReader(InputStream stream) throws IOException
      Deprecated.
      Creates a new GSHHS reader from the input stream. With this constructor, all polygons are selected and the selection method performs no operation.
      Parameters:
      stream - the input stream to read.
      Throws:
      IOException - if the stream had input errors.
  • Method Details

    • setCacheSize

      public static void setCacheSize(int cacheSize)
      Deprecated.
      Sets the polygon cache size. The cache size is measured in terms of the number of polygon earth location points.
      Parameters:
      cacheSize - the cache size in bytes.
    • setMinArea

      public void setMinArea(double minArea)
      Deprecated.
      Sets the minimum area used in polygon selection. Polygons less than the minimum area are not included.
      Parameters:
      minArea - the minimum area in km^2.
    • select

      protected void select() throws IOException
      Deprecated.
      Description copied from class: AbstractFeatureSource
      Selects a set of features from the data source based on the current area.
      Specified by:
      select in class AbstractFeatureSource
      Throws:
      IOException - if an error occurred accessing the data source.
    • readHeader

      public GSHHSReader.PolygonHeader readHeader(DataInput in) throws IOException
      Deprecated.
      Reads a polygon header from the specified input.
      Parameters:
      in - the data input. The header is constructed by reading at the current input position.
      Returns:
      the GSHHS polygon header read.
      Throws:
      IOException - if an error occurred reading the data file.
    • readPolygon

      public LineFeature readPolygon(GSHHSReader.PolygonHeader header, DataInput in) throws IOException
      Deprecated.
      Reads a polygon from the specified input.
      Parameters:
      header - the polygon header from the last call to readHeader(java.io.DataInput).
      in - the data input. The polygon is constructed by reading at the current input position.
      Returns:
      a new polygon as a vector of earth locations.
      Throws:
      IOException - if an error occurred reading the data file.
    • getDatabase

      public String getDatabase()
      Deprecated.
      Gets the database name currently being used for selection.
    • getDatabase

      public static String getDatabase(double resolution)
      Deprecated.
      Gets the predefined database name with resolution closest to the specified resolution. If the resolution is invalid, the crude resolution database is returned.
      Parameters:
      resolution - the image resolution in km/pixel.
      Returns:
      the GSHHS database name.