Package noaa.coastwatch.render.feature
Class BinnedGSHHSLineReader
java.lang.Object
noaa.coastwatch.render.feature.AbstractFeatureSource
noaa.coastwatch.render.feature.LineFeatureSource
noaa.coastwatch.render.feature.BinnedGSHHSLineReader
- All Implemented Interfaces:
Iterable<Feature>
,FeatureSource
- Direct Known Subclasses:
HDFGSHHSLineReader
,OpendapGSHHSLineReader
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
Modifier and TypeClassDescriptionclass
The bin class acts as a container for GSHHS segments. -
Field Summary
Modifier and TypeFieldDescriptionprotected 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
ModifierConstructorDescriptionprotected
Creates a new reader with no initialization. -
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, and segmentStart.protected void
Initializes this reader using the specified database.iterator()
Gets an iterator over all selected features.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
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
The database name. -
sdID
protected int sdIDThe database ID. -
segmentLevelID
protected int segmentLevelIDThe segment level ID. -
segmentPointsID
protected int segmentPointsIDThe segment points 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. -
segmentStart
protected int[] segmentStartThe starting point for each segment.
-
-
Constructor Details
-
BinnedGSHHSLineReader
protected BinnedGSHHSLineReader()Creates a new reader with no initialization.
-
-
Method Details
-
getBinIndex
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
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
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, 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.
-
iterator
Description copied from interface:FeatureSource
Gets an iterator over all selected features.- Specified by:
iterator
in interfaceFeatureSource
- Specified by:
iterator
in interfaceIterable<Feature>
- Overrides:
iterator
in classAbstractFeatureSource
-
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.
-