Class BinnedGSHHSLineReader

All Implemented Interfaces:
Iterable<Feature>, FeatureSource
Direct Known Subclasses:
HDFGSHHSLineReader, OpendapGSHHSLineReader

public abstract class BinnedGSHHSLineReader extends LineFeatureSource

The BinnedGSHHSLineReader class reads Global Self-consistent Hierarchical High-resolution Shorelines (GSHHS) border and river data in 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.2.1
Author:
Peter Hollemans
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    The bin class acts as a container for GSHHS segments.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
    The bin size in degrees.
    protected String
    The database name.
    protected int
    The relative longitude point ID.
    protected int
    The relative latitude point ID.
    protected int[]
    The index of the first segment in each bin.
    protected int
    The number of bins in the latitude direction.
    protected int
    The number of bins in the longitude direction.
    protected double
    The multiplier for converting scaled segment units to degrees.
    protected short[]
    The number of segments in each bin.
    protected int
    The database ID.
    protected int
    The segment level ID.
    protected int
    The segment points ID.
    protected int[]
    The starting point for each segment.
    protected int
    The total number of bins.
    protected int
    The total number of points.
    protected int
    The total number of segments.

    Fields inherited from class noaa.coastwatch.render.feature.AbstractFeatureSource

    area, featureList
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new reader with no initialization.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets a bin index using the specified earth location.
    Gets the bin indices containing the specified earth area.
    int
    Gets the total number of bins.
    Gets the database name currently being used for selection.
    protected abstract void
    Reads data about the entire file, including binSize, multiplier, lonBins, latBins, totalBins, firstSegment, numSegments, and segmentStart.
    protected void
    init(String name)
    Initializes this reader using the specified database.
    Gets an iterator over all selected features.
    protected abstract int
    Opens the data file and returns the file ID.
    protected abstract void
    readData(int sdsid, int[] start, int[] count, Object data)
    Reads data for the specified variable ID.
    protected abstract void
    readData(String var, int[] start, int[] count, Object data)
    Reads data for the specified variable name.
    protected void
    Selects a set of features from the data source based on the current area.
    protected abstract int
    Gets the variable ID for the specified variable.
    protected void
    setBinHint(int index)
    Sets a hint that subsequent bin data access is about to occur.
    protected void
    setBinListHint(List indexList)
    Sets a hint that subsequent bin data access is about to occur for a list of bins.
    void
    setLevelRange(int minLevel, int maxLevel)
    Sets the hierarchical level range useds in line segment rendering.

    Methods inherited from class noaa.coastwatch.render.feature.LineFeatureSource

    render

    Methods inherited from class noaa.coastwatch.render.feature.AbstractFeatureSource

    getArea, getAttributeCount, getAttributeNameMap, getAttributes, getFilter, select, setAttributes, setFilter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • database

      protected String database
      The database name.
    • sdID

      protected int sdID
      The database ID.
    • segmentLevelID

      protected int segmentLevelID
      The segment level ID.
    • segmentPointsID

      protected int segmentPointsID
      The segment points 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.
    • segmentStart

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

    • BinnedGSHHSLineReader

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

    • getBinIndex

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

      public void setLevelRange(int minLevel, int maxLevel)
      Sets the hierarchical level range useds in line segment rendering. By default all line segments are rendered, regardless of level.
      Parameters:
      minLevel - the maximum hierarchical level.
      maxLevel - the maximum hierarchical level.
    • 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.
    • 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, 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.
    • iterator

      public Iterator iterator()
      Description copied from interface: FeatureSource
      Gets an iterator over all selected features.
      Specified by:
      iterator in interface FeatureSource
      Specified by:
      iterator in interface Iterable<Feature>
      Overrides:
      iterator in class AbstractFeatureSource
    • 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.