public class GvrsFileSpecification extends Object
Constructor and Description |
---|
GvrsFileSpecification(GvrsFileSpecification s)
Construct a new instance copying the values from the supplied object.
|
GvrsFileSpecification(int nRowsInRaster,
int nColumnsInRaster)
Construct a specification for creating a GVRS raster with the indicated
dimensions.
|
GvrsFileSpecification(int nRowsInRaster,
int nColumnsInRaster,
int nRowsInTile,
int nColumnsInTile)
Construct a specification for creating a GVRS raster with the indicated
dimensions.
|
Modifier and Type | Method and Description |
---|---|
void |
addCompressionCodec(String codecID,
Class<?> codec)
Adds a data compression Codec to the specification.
|
void |
addCompressionCodec(String codecID,
Class<?> encoder,
Class<?> decoder)
Adds a data compression coder and decoder (a "codec") to the
specification.
|
void |
addElementFloat(String name)
Provides a convenience method that allows an application to add
an element specification without constructing its own instance.
|
void |
addElementInt(String name)
Provides a convenience method that allows an application to add
an element specification without constructing its own instance.
|
void |
addElementShort(String name)
Provides a convenience method that allows an application to add
an element specification without constructing its own instance.
|
void |
addElementSpecification(GvrsElementSpecification specification)
Adds an element specification to the file specification.
|
boolean |
doGeographicCoordinatesBracketLongitude()
Indicates whether a geographic coordinate system covers the full range of
longitude with redundant grid points at the beginning and end of each
row.
|
boolean |
doGeographicCoordinatesWrapLongitude()
Indicates whether a geographic coordinate system covers the full range of
longitude but crosses a 360 degree boundary between grid points.
|
Rectangle2D |
getBounds()
Gets the bounds for the coordinate system associated with the grid.
|
double[] |
getCellSizes()
Gets the sizes for the cells based on the coordinate system set in the
specification.
|
int |
getColumnsInGrid()
Gets the number of columns in the overall raster grid.
|
int |
getColumnsInTile()
Gets the number of columns in a tile.
|
int |
getColumnsOfTilesInGrid()
Get the number of columns of tiles.
|
List<org.gridfour.gvrs.CodecHolder> |
getCompressionCodecs()
Get the compression codes currently registered with the specification
|
GvrsElementSpecification |
getElementSpecification(String name)
Gets the element specification that matches the specified name, if any.
|
List<GvrsElementSpecification> |
getElementSpecifications()
Gets a safe copy of the element specifications currently stored
in this instance.
|
String |
getLabel()
Gets the product-label string associated with this specification and the
GvrsFile that is created from it.
|
long |
getNumberOfCellsInGrid()
Gets the number of cells (grid points) in the raster definition.
|
int |
getNumberOfCellsInTile()
Gets the number of cells (grid points) in the tile definition.
|
int |
getNumberOfElements()
Gets the number of data values stored for each grid cell.
|
RasterSpaceType |
getRasterSpaceType()
Gets the geometry type for this specification.
|
int |
getRowsInGrid()
Gets the number of rows in the overall raster.
|
int |
getRowsInTile()
Gets the number of rows in a tile.
|
int |
getRowsOfTilesInGrid()
Get the number of rows of tiles.
|
AffineTransform |
getTransformModelToRaster()
Gets an affine transform for mapping real-valued "model" coordinates
to the raster grid.
|
AffineTransform |
getTransformRasterToModel()
Gets an affine transform for mapping grid (raster) coordinates to
real-valued "model" coordinates.
|
double |
getX0()
Gets the minimum X coordinate in the model-coordinate-system
(a Cartesian coordinate system, or longitude for a geographic coordinate
system).
|
double |
getX1()
Gets the maximum X coordinate in the model-coordinate-system
(a Cartesian coordinate system, or longitude for a geographic coordinate
system).
|
double |
getY0()
Gets the minimum Y coordinate in the model-coordinate-system
(a Cartesian coordinate system, or latitude for a geographic coordinate
system).
|
double |
getY1()
Gets the maximum Y coordinate in the model-coordinate-system
(a Cartesian coordinate system, or latitude for a geographic coordinate
system).
|
boolean |
isCartesianCoordinateSystemSpecified()
Indicates whether a Cartesian coordinate system has been set for mapping
input coordinates to raster (grid) coordinates and vice versa.
|
boolean |
isChecksumEnabled()
Indicates that the computation of checksums is enabled
|
boolean |
isDataCompressionEnabled()
Indicates whether data compression is enabled
|
boolean |
isExtendedFileSizeEnabled()
Indicates whether the extended file size option is enabled.
|
boolean |
isGeographicCoordinateSystemSpecified()
Indicates whether a geographic coordinate system has been set for mapping
input coordinates to raster coordinates and vice versa.
|
double[] |
mapCartesianToGrid(double x,
double y)
Deprecated.
|
double[] |
mapGeographicToGrid(double latitude,
double longitude)
Deprecated.
|
GridPoint |
mapGeographicToGridPoint(double latitude,
double longitude)
Map geographic coordinates to grid coordinates storing the row and column
in an instance of the GridPoint class.
|
GridPoint |
mapGeographicToGridPoint(IGeoPoint geoPoint)
Map geographic coordinates to grid coordinates storing the row and column
in an instance of the GridPoint class.
|
double[] |
mapGridToCartesian(double row,
double column)
Deprecated.
|
double[] |
mapGridToGeographic(double row,
double column)
Deprecated.
|
GeoPoint |
mapGridToGeoPoint(double row,
double column)
Map grid coordinates to geographic coordinates storing the resulting
latitude and longitude in an instance of GvrsGeoPoint.
|
ModelPoint |
mapGridToModelPoint(double row,
double column)
Map grid coordinates to model coordinates storing the resulting x and y
values in a GvrsModelPoint instance.
|
GridPoint |
mapModelToGridPoint(double x,
double y)
Map model coordinates to grid coordinates storing the computed row and
column in an instance of GvrsGridPoint.
|
GridPoint |
mapModelToGridPoint(IModelPoint modelPoint)
Maps a model point to a grid point.
|
void |
removeAllCompressionCodecs()
Removes all compression coder-decoder (codec) definitions from the
specification.
|
boolean |
removeCompressionCodec(String codecID)
Removes the indicated compression codec from the specification.
|
void |
setCartesianCoordinates(double x0,
double y0,
double x1,
double y1)
Sets the real-valued model to a Cartesian coordinate system.
|
void |
setCartesianModel(double x0,
double y0,
double cellWidth,
double cellHeight)
Sets the real-valued model to a Cartesian coordinate system.
|
void |
setChecksumEnabled(boolean checksumEnabled)
Enables or disables the optional checksum computation feature.
|
void |
setDataCompressionEnabled(boolean dataCompressionEnabled)
Sets data compression to enabled or disabled.
|
void |
setExtendedFileSizeEnabled(boolean extendedFileSizeEnabled)
Indicates whether the extended file size option is enabled.
|
void |
setGeographicCoordinates(double latRow0,
double lonCol0,
double latRowLast,
double lonColLast)
Set a geographic coordinate system to be used for interpreting the data.
|
void |
setGeographicModel(double latRow0,
double lonCol0,
double cellWidth,
double cellHeight)
Set a geographic coordinate system to be used for interpreting the data.
|
void |
setLabel(String label)
Set an arbitrary label string for the raster file.
|
void |
setRasterSpaceType(RasterSpaceType geometryType)
Sets the geometry type associated with the row and column positions in
the raster.
|
void |
setTransformModelToRaster(AffineTransform a)
Set the transform for mapping model coordinates to the raster grid.
|
void |
setTransformRasterToModel(AffineTransform a)
Set the transform for mapping model coordinates to the raster grid.
|
void |
summarize(PrintStream ps)
Prints a summary of the specification to the indicated output stream.
|
public GvrsFileSpecification(int nRowsInRaster, int nColumnsInRaster, int nRowsInTile, int nColumnsInTile)
If the number of rows or columns in a tile specification does not evenly divide the number of rows or columns in the overall raster, it is assumed that the last row or column of tiles is partially populated.
Due to internal implementation limits, the maximum number of tiles is the maximum size of a 4-byte signed integer(2147483647). This condition could occur given a very large raster grid combined with an insufficiently large tile size.
For example, if an application were using geographic coordinates wait a one second of arc cell spacing for a grid, it would require a grid of dimensions 1296000 by 648000. A tile size of 60-by-60 would ensure that the maximum number of tiles was just over 233 million, and well within the limits imposed by this implementation. However, a tile size of 10-by-10 would product a maximum number of tiles of over 8 billion, and would exceed the limits of the implementation.
nRowsInRaster
- the number of rows in the rasternColumnsInRaster
- the number of columns in the rasternRowsInTile
- the number of rows in the tiling schemenColumnsInTile
- the number of columns in the tiling schemepublic GvrsFileSpecification(int nRowsInRaster, int nColumnsInRaster)
nRowsInRaster
- the number of rows in the rasternColumnsInRaster
- the number of columns in the rasterpublic GvrsFileSpecification(GvrsFileSpecification s)
s
- a valid instance of GvrsFileSpecification.public final void setGeographicCoordinates(double latRow0, double lonCol0, double latRowLast, double lonColLast)
Various data sources take different approaches in terms of how they order their raster data in relationship to latitude. Some start with the northernmost latitude and work their way south, some start with the southernmost latitude and work their way north. Thus the arguments for this method are based on the ordering of the raster. The first pair of arguments give the coordinates for the first row and column in the grid. The second pair of arguments give the coordinates for the last.
Unfortunately, the possibility of longitude wrapping around the International Date line limits the flexibility for longitude specifications. This implementation assumes that the raster is organized so that the longitudes progress from west to east (longitude increases with increasing grid index). Thus, if a longitude of -90 to 90 were specified, it would assume that the raster columns went from 90 west to 90 east. But if 90, -90 were specified, it would be assumed that the raster grid went from 90 east, across the International Date Line, to 90 west.
This method also populates the internal AffineTransform that can be used for transforming coordinates between the geographic and grid coordinate systems.
latRow0
- the latitude of the center point in the cell
in the first row and first column in the rasterlonCol0
- the longitude of the center point in the cell
in the first row and first column in the rasterlatRowLast
- the latitude of the center point in the cell
in the last row and last column in the rasterlonColLast
- the longitude of the center point in the cell
in the last row and last column in the rasterpublic final void setGeographicModel(double latRow0, double lonCol0, double cellWidth, double cellHeight)
Various data sources take different approaches in terms of how they order their raster data in relationship to latitude. Some start with the northernmost latitude and work their way south, some start with the southernmost latitude and work their way north. Thus the arguments for cell height may be either positive or negative.
Unfortunately, the possibility of longitude wrapping around the International Date line limits the flexibility for longitude specifications. This implementation assumes that the raster is organized so that the longitudes progress from west to east (longitude increases with increasing grid index).
This method also populates the internal AffineTransform that can be used for transforming coordinates between the geographic and grid coordinate systems.
latRow0
- the latitude of the center point in the cell
in the first row and first column in the rasterlonCol0
- the longitude of the center point in the cell
in the first row and first column in the rastercellWidth
- longitude measure across cells, in degreescellHeight
- latitude measure across cells, in degreespublic final void setCartesianCoordinates(double x0, double y0, double x1, double y1)
This method populates the internal AffineTransform that can be used for transforming coordinates between the model and grid coordinate systems.
The key assumption of this method is that the points (x0, y0) and (x1, y1) represent the real-valued coordinate at the center of their associated raster cells. Although (x0, y0) represents the first row and column in the raster and (x1, y1) represents the last, there is no requirement that x0 < x1 or y0 < y1. However, the coordinates for x0,x1 and y0,y1 must not be equal. That restriction means that this specification cannot be used for a raster containing only one row or column of cells.
x0
- the X coordinate of the center point in the cell
in the first row and first column of the raster.y0
- the Y coordinate of the center point in the cell
in the first row and first column of the raster.x1
- the X coordinate of the center point in the cell
in the last row and last column of the raster.y1
- the Y coordinate of the center point in the cell
in the last row and last column of the raster.public final void setCartesianModel(double x0, double y0, double cellWidth, double cellHeight)
This method populates the internal AffineTransform that can be used for transforming coordinates between the model and grid coordinate systems.
The key assumption of this method is that the point (x0, y0) represents the real-valued coordinate at the center of the raster cell in the first row and first column of the grid. raster cells. The Cartesian coordinates for all subsequent points are computed from (x0, y0) using the cell width and height factors.
x0
- the X coordinate of the center point in the cell
in the first row and first column of the raster.y0
- the Y coordinate of the center point in the cell
in the first row and first column of the raster.cellWidth
- the width of each cell in Cartesian coordinatescellHeight
- the height of each cell in Cartesian coordinatespublic void setLabel(String label)
label
- an application-defined string for labeling a GVRS filepublic String getLabel()
public boolean isDataCompressionEnabled()
public void setDataCompressionEnabled(boolean dataCompressionEnabled)
dataCompressionEnabled
- true if data compression is to be applied;
otherwise, false.public int getRowsInGrid()
public int getColumnsInGrid()
public int getRowsOfTilesInGrid()
public int getColumnsOfTilesInGrid()
public int getRowsInTile()
public int getColumnsInTile()
public int getNumberOfElements()
public boolean isExtendedFileSizeEnabled()
public void setExtendedFileSizeEnabled(boolean extendedFileSizeEnabled)
extendedFileSizeEnabled
- true if extended file sizes are enabled;
otherwise false.public boolean isChecksumEnabled()
public void setChecksumEnabled(boolean checksumEnabled)
checksumEnabled
- true if checksums are to be computed;
otherwise, falsepublic boolean isGeographicCoordinateSystemSpecified()
public boolean doGeographicCoordinatesWrapLongitude()
In the first case, we say that the coordinate system "brackets" the longitude range. The first and last grid point in each row are actually at the same coordinates (and should have the same values if properly populated). In the second case, we say that the coordinate system "crosses" the longitude boundary. But, in both cases, the coordinate system does offer a full 360-degrees of coverage.
This setting is useful for data queries and interpolation operations applied over a geographic coordinate system that covers the entire range of longitudes. In the "bracket" case, mapping a longitude to a column can be accomplished using simple arithmetic. But in the second case, more complicated logic may be required to select columns for interpolation.
public boolean doGeographicCoordinatesBracketLongitude()
public boolean isCartesianCoordinateSystemSpecified()
public void setRasterSpaceType(RasterSpaceType geometryType)
For both the Area and Point cases, GVRS treats the assignment of real-valued coordinates (Cartesian or geographic) as identifying the coordinates of a single point located at the center of a raster cell. This treatment is different than that used in some other raster data formats (such as GeoTiFF), so developers should be cognizant of the difference when creating raster specifications.
geometryType
- a valid instance of the enumeration.public RasterSpaceType getRasterSpaceType()
public double[] getCellSizes()
Note: If this instance specifies a geographic model, then the cell size will be in degrees, with the index-of-zero element of the array (the x coordinate) corresponding to longitude and the index-of-one corresponding to latitude.
public int getNumberOfCellsInTile()
public long getNumberOfCellsInGrid()
public void removeAllCompressionCodecs()
public boolean removeCompressionCodec(String codecID)
codecID
- a valid identification stringpublic final void addCompressionCodec(String codecID, Class<?> codec)
The codec class must implement both the interfaces IGvrsEncoder and IGvrsDecoder. It must also include an coder/decoder (e.g. a "codec") that has a no-argument constructor that can be successfully invoked by the GVRS classes..
codecID
- a unique identification following the syntax of Java
identifier strings, 16 character maximum.codec
- a valid class reference.public final void addCompressionCodec(String codecID, Class<?> encoder, Class<?> decoder)
The encoder class must implement the interfaces IGvrsEncoder interface. The decoder class must implement the IGvrsDecoder interface. Both classes must also include a no-argument constructor that can be successfully invoked by the GVRS classes.
The rationale for specifying separate classes for the encoder and decoder is that in some cases, the encoder may include substantially more complexity (and library dependencies) than the decoder. In such cases, it may be desirable to have some applications that can access compressed GVRS files on a read-only basis. Such applications may be able to operate correctly even though they do not include all the libraries required for the encoding.
codecID
- a unique identification following the syntax of Java
identifier strings, 16 character maximum.encoder
- a valid reference to a class that implements IGvrsEncoder.decoder
- a valid reference to a class that implements IGvrsDecoder.public List<org.gridfour.gvrs.CodecHolder> getCompressionCodecs()
public void summarize(PrintStream ps)
ps
- any valid PrintStream including System.out and
System.err.public Rectangle2D getBounds()
public void addElementSpecification(GvrsElementSpecification specification)
specification
- a valid instancepublic void addElementFloat(String name)
name
- the name of the floating-point element to be added.public void addElementInt(String name)
name
- the name of the integer element to be added.public void addElementShort(String name)
name
- the name of the integer element to be added.public AffineTransform getTransformModelToRaster()
public AffineTransform getTransformRasterToModel()
public void setTransformModelToRaster(AffineTransform a)
a
- a valid, well-conditioned transformation matrix.public void setTransformRasterToModel(AffineTransform a)
a
- a valid, well-conditioned transformation matrix.public double getX0()
public double getY0()
public double getX1()
public double getY1()
public ModelPoint mapGridToModelPoint(double row, double column)
The transformation performed by this method is based on the parameters established through a call to the setCartesianCoordinates{} method.
row
- a row (may be a non-integral value)column
- a column (may be a non-integral value)public GridPoint mapModelToGridPoint(double x, double y)
The transformation performed by this method is based on the parameters established through a call to the setCartesianCoordinates() method.
x
- a valid floating-point coordinatey
- a valid floating-point coordinatepublic GridPoint mapModelToGridPoint(IModelPoint modelPoint)
modelPoint
- a valid instancepublic GridPoint mapGeographicToGridPoint(double latitude, double longitude)
The transformation performed by this method is based on the parameters established through a call to the setGeographicCoordinates{} method. Longitudes may be adjusted according to the bounds established by the specification and in recognition of the cyclic nature of longitude coordinates (i.e. 450 degrees is equivalent to 90 degrees, etc.).
latitude
- a valid floating-point coordinatelongitude
- a valid floating-point coordinatepublic GridPoint mapGeographicToGridPoint(IGeoPoint geoPoint)
The transformation performed by this method is based on the parameters established through a call to the setGeographicCoordinates{} method. Longitudes may be adjusted according to the bounds established by the specification and in recognition of the cyclic nature of longitude coordinates (i.e. 450 degrees is equivalent to 90 degrees, etc.).
geoPoint
- a valid instance.public GeoPoint mapGridToGeoPoint(double row, double column)
The transformation performed by this method is based on the parameters established through a call to the setCartesianCoordinates{} method.
row
- the row coordinate (may be non-integral)column
- the column coordinate (may be non-integral)@Deprecated public double[] mapCartesianToGrid(double x, double y)
This method is deprecated. Please use mapModelToGridPoint() instead.
x
- a valid floating-point coordinatey
- a valid floating-point coordinate@Deprecated public double[] mapGridToCartesian(double row, double column)
This method is deprecated. Please use mapGridToModelPoint() instead.
row
- a row (may be a non-integral value)column
- a column (may be a non-integral value)@Deprecated public double[] mapGeographicToGrid(double latitude, double longitude)
This method is deprecated. Please use mapGeographicToGridPoint() instead.
latitude
- a valid floating-point coordinatelongitude
- a valid floating-point coordinate@Deprecated public double[] mapGridToGeographic(double row, double column)
This method is deprecated. Please use mapGridToGeoPoint() instead.
row
- the row coordinate (may be non-integral)column
- the column coordinate (may be non-integral)public List<GvrsElementSpecification> getElementSpecifications()
public GvrsElementSpecification getElementSpecification(String name)
Note that the return value from this method is a reference to the specification that is currently stored in this instance. It is not a safe copy. Any changes to the returned object will affect the content of this instance.
name
- the name to be matched.Copyright © 2022. All rights reserved.