Class BinnedGSHHSReader

All Implemented Interfaces:
Iterable<Feature>, FeatureSource
Direct Known Subclasses:
HDFGSHHSReader, OpendapGSHHSReader

public abstract class BinnedGSHHSReader extends PolygonFeatureSource

The binned GSHHS reader class reads Global Self-consistent Hierarchical High-resolution Shorelines (GSHHS) data from the binned format provided with the Generic Mapping Tools (GMT). For source code and data files, see:

http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html
http://gmt.soest.hawaii.edu
Since:
3.1.2
Author:
Peter Hollemans
  • Field Details

    • database

      protected String database
      The database name.
    • sdID

      protected int sdID
      The database ID.
    • segmentInfoID

      protected int segmentInfoID
      The segment info ID.
    • segmentAreaID

      protected int segmentAreaID
      The segment area ID.
    • dxID

      protected int dxID
      The relative longitude point ID.
    • dyID

      protected int dyID
      The relative latitude point ID.
    • multiplier

      protected double multiplier
      The multiplier for converting scaled segment units to degrees.
    • binSize

      protected double binSize
      The bin size in degrees.
    • lonBins

      protected int lonBins
      The number of bins in the longitude direction.
    • latBins

      protected int latBins
      The number of bins in the latitude direction.
    • totalBins

      protected int totalBins
      The total number of bins.
    • totalPoints

      protected int totalPoints
      The total number of points.
    • totalSegments

      protected int totalSegments
      The total number of segments.
    • firstSegment

      protected int[] firstSegment
      The index of the first segment in each bin.
    • numSegments

      protected short[] numSegments
      The number of segments in each bin.
    • binInfo

      protected short[] binInfo
      The info for each bin.
    • segmentStart

      protected int[] segmentStart
      The starting point for each segment.
  • Constructor Details

    • BinnedGSHHSReader

      public BinnedGSHHSReader(String name) throws IOException
      Creates a new binned GSHHS reader from the database file 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 in BinnedGSHHSReaderFactory: HIGH, INTER, LOW, and CRUDE. See the constants for descriptions of the database resolutions.
      Throws:
      IOException - if an error occurred reading the file.
    • BinnedGSHHSReader

      protected BinnedGSHHSReader()
      Creates a new reader with no initialization.
  • Method Details

    • getBinIndex

      public int getBinIndex(EarthLocation loc)
      Gets a bin index using the specified earth location.
    • setMinArea

      public void setMinArea(double minArea)
      Sets the minimum area used in polygon selection. Polygons less than the minimum area are not included. By default the minimum area is -1, which causes all polygons to be selected, regardless of area.
      Parameters:
      minArea - the minimum area in km^2. Negative values disable filtering by minimum area.
    • getMinArea

      public double getMinArea()
      Gets the minimum area used in polygon selection.
      Returns:
      the minimum area in km^2, or a negative value to select all polygons regardless of area.
    • readData

      protected abstract void readData(int sdsid, int[] start, int[] count, Object data) throws IOException
      Reads data for the specified variable ID.
      Parameters:
      sdsid - the identifier for the variable.
      start - the starting data index for reading.
      count - the number of data values to read.
      data - the data array to fill with values.
      Throws:
      IOException - if an error occurred reading the data.
    • readData

      protected abstract void readData(String var, int[] start, int[] count, Object data) throws IOException
      Reads data for the specified variable name.
      Parameters:
      var - the name of the variable.
      start - the starting data index for reading.
      count - the number of data values to read.
      data - the data array to fill with values.
      Throws:
      IOException - if an error occurred reading the data.
    • selectData

      protected abstract int selectData(String var) throws IOException
      Gets the variable ID for the specified variable.
      Parameters:
      var - the variable name to retrieve an ID.
      Returns:
      the variable ID.
      Throws:
      IOException - if an error occurred retrieving the ID.
    • setPolygonRendering

      public void setPolygonRendering(boolean flag)
      Sets the polygon rendering flag. By default, the polygon rendering capability is turned off because of the extra work required for assembling segment data into closed polygons. When off, no polygons are created when the select() method is called, thus no polygons are ever rendered. When on, the select() call causes a set of polygons to be created from segment data, which may then be rendered via a call to renderPolygons().
    • getPolygonRendering

      public boolean getPolygonRendering()
      Gets the polygon rendering flag.
      Returns:
      the polygon rendering flag, true if polygons will be rendered from selected data.
      See Also:
    • openFile

      protected abstract int openFile(String name) throws IOException
      Opens the data file and returns the file ID.
      Parameters:
      name - the data file name.
      Throws:
      IOException - if an error occurred opening the file.
    • getGlobalData

      protected abstract void getGlobalData() throws IOException
      Reads data about the entire file, including binSize, multiplier, lonBins, latBins, totalBins, firstSegment, numSegments, binInfo, and segmentStart.
      Throws:
      IOException - if an error occurred reading the data.
    • init

      protected void init(String name) throws IOException
      Initializes this reader using the specified database.
      Throws:
      IOException
      See Also:
    • setBinListHint

      protected void setBinListHint(List indexList)
      Sets a hint that subsequent bin data access is about to occur for a list of bins. This may be used by child classes to increase the speed of bin data access.
      Parameters:
      indexList - the list of bin indices to be accessed sorted in increasing order.
    • setBinHint

      protected void setBinHint(int index)
      Sets a hint that subsequent bin data access is about to occur. This may be used by child classes to increase the speed of bin data access.
      Parameters:
      index - the bin that data access will be performed for next.
    • select

      protected void select() throws IOException
      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.
    • getBins

      public int getBins()
      Gets the total number of bins.
    • getBinIndices

      public Collection getBinIndices(EarthArea area)
      Gets the bin indices containing the specified earth area.
      Parameters:
      area - the earth area.
      Returns:
      a collection of bin indices as Integer objects.
    • getDatabase

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