Package noaa.coastwatch.render.feature
Class BinnedGSHHSReader
java.lang.Object
noaa.coastwatch.render.feature.AbstractFeatureSource
noaa.coastwatch.render.feature.LineFeatureSource
noaa.coastwatch.render.feature.PolygonFeatureSource
noaa.coastwatch.render.feature.BinnedGSHHSReader
- All Implemented Interfaces:
Iterable<Feature>
,FeatureSource
- Direct Known Subclasses:
HDFGSHHSReader
,OpendapGSHHSReader
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
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
The bin class acts as a container for GSHHS shore segments. -
Field Summary
Modifier and TypeFieldDescriptionprotected short[]
The info for each bin.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 area ID.protected int
The segment info 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.PolygonFeatureSource
polygonList
Fields inherited from class noaa.coastwatch.render.feature.AbstractFeatureSource
area, featureList
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new reader with no initialization.BinnedGSHHSReader
(String name) Creates a new binned GSHHS reader from the database file name. -
Method Summary
Modifier and TypeMethodDescriptionint
getBinIndex
(EarthLocation loc) Gets a bin index using the specified earth location.getBinIndices
(EarthArea area) Gets the bin indices containing the specified earth area.int
getBins()
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, binInfo, and segmentStart.double
Gets the minimum area used in polygon selection.boolean
Gets the polygon rendering flag.protected void
Initializes this reader using the specified database.protected abstract int
Opens the data file and returns the file ID.protected abstract void
Reads data for the specified variable ID.protected abstract void
Reads data for the specified variable name.protected void
select()
Selects a set of features from the data source based on the current area.protected abstract int
selectData
(String var) 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
setMinArea
(double minArea) Sets the minimum area used in polygon selection.void
setPolygonRendering
(boolean flag) Sets the polygon rendering flag.Methods inherited from class noaa.coastwatch.render.feature.PolygonFeatureSource
renderOutlines, renderPolygons
Methods inherited from class noaa.coastwatch.render.feature.LineFeatureSource
render
Methods inherited from class noaa.coastwatch.render.feature.AbstractFeatureSource
getArea, getAttributeCount, getAttributeNameMap, getAttributes, getFilter, iterator, 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
The database name. -
sdID
protected int sdIDThe database ID. -
segmentInfoID
protected int segmentInfoIDThe segment info ID. -
segmentAreaID
protected int segmentAreaIDThe segment area ID. -
dxID
protected int dxIDThe relative longitude point ID. -
dyID
protected int dyIDThe relative latitude point ID. -
multiplier
protected double multiplierThe multiplier for converting scaled segment units to degrees. -
binSize
protected double binSizeThe bin size in degrees. -
lonBins
protected int lonBinsThe number of bins in the longitude direction. -
latBins
protected int latBinsThe number of bins in the latitude direction. -
totalBins
protected int totalBinsThe total number of bins. -
totalPoints
protected int totalPointsThe total number of points. -
totalSegments
protected int totalSegmentsThe total number of segments. -
firstSegment
protected int[] firstSegmentThe index of the first segment in each bin. -
numSegments
protected short[] numSegmentsThe number of segments in each bin. -
binInfo
protected short[] binInfoThe info for each bin. -
segmentStart
protected int[] segmentStartThe starting point for each segment.
-
-
Constructor Details
-
BinnedGSHHSReader
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 inBinnedGSHHSReaderFactory
:HIGH
,INTER
,LOW
, andCRUDE
. 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
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
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 theselect()
method is called, thus no polygons are ever rendered. When on, theselect()
call causes a set of polygons to be created from segment data, which may then be rendered via a call torenderPolygons()
. -
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
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
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
Initializes this reader using the specified database.- Throws:
IOException
- See Also:
-
setBinListHint
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
Description copied from class:AbstractFeatureSource
Selects a set of features from the data source based on the current area.- Specified by:
select
in classAbstractFeatureSource
- Throws:
IOException
- if an error occurred accessing the data source.
-
getBins
public int getBins()Gets the total number of bins. -
getBinIndices
Gets the bin indices containing the specified earth area.- Parameters:
area
- the earth area.- Returns:
- a collection of bin indices as
Integer
objects.
-
getDatabase
Gets the database name currently being used for selection.
-