Class NTV2SubGrid
- java.lang.Object
-
- org.openstreetmap.josm.data.projection.datum.NTV2SubGrid
-
- All Implemented Interfaces:
Serializable
public class NTV2SubGrid extends Object implements Serializable
Models the NTv2 Sub Grid within a Grid Shift File.- Since:
- 2507
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private String
created
private float[]
latAccuracy
private double
latInterval
private int
latRowCount
private float[]
latShift
private float[]
lonAccuracy
private int
lonColumnCount
private double
lonInterval
private float[]
lonShift
private double
maxLat
private double
maxLon
private double
minLat
private double
minLon
private int
nodeCount
private String
parentSubGridName
private static long
serialVersionUID
private NTV2SubGrid[]
subGrid
private String
subGridName
private String
updated
-
Constructor Summary
Constructors Constructor Description NTV2SubGrid(InputStream in, boolean bigEndian, boolean loadAccuracy)
Construct a Sub Grid from an InputStream, loading the node data into arrays in this object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDetails()
Returns textual details about the sub grid.double
getMaxLat()
Get maximum latitude valuedouble
getMaxLon()
Get maximum longitude valuedouble
getMinLat()
Get minimum latitude valuedouble
getMinLon()
Get minimum longitude valueint
getNodeCount()
Returns the node count.String
getParentSubGridName()
Returns the parent sub grid name.int
getSubGridCount()
Returns the sub grid count.NTV2SubGrid
getSubGridForCoord(double lon, double lat)
Tests if a specified coordinate is within this Sub Grid or one of its Sub Grids.String
getSubGridName()
Returns the sub grid name.private static double
interpolate(float a, float b, float c, float d, double x, double y)
Bi-Linear interpolation of four nearest node values as described in 'GDAit Software Architecture Manual' produced by the Geomatics Department of the University of Melbournevoid
interpolateGridShift(NTV2GridShift gs)
Interpolate shift and accuracy values for a coordinate in the 'from' datum of the GridShiftFile.private boolean
isCoordWithin(double lon, double lat)
Tests if a specified coordinate is within this Sub Grid.private static void
readBytes(InputStream in, byte[] b)
void
setSubGridArray(NTV2SubGrid... subGrid)
Set an array of Sub Grids of this sub gridString
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
subGridName
private final String subGridName
-
parentSubGridName
private final String parentSubGridName
-
minLat
private final double minLat
-
maxLat
private final double maxLat
-
minLon
private final double minLon
-
maxLon
private final double maxLon
-
latInterval
private final double latInterval
-
lonInterval
private final double lonInterval
-
nodeCount
private final int nodeCount
-
lonColumnCount
private final int lonColumnCount
-
latRowCount
private final int latRowCount
-
latShift
private final float[] latShift
-
lonShift
private final float[] lonShift
-
latAccuracy
private float[] latAccuracy
-
lonAccuracy
private float[] lonAccuracy
-
subGrid
private NTV2SubGrid[] subGrid
-
-
Constructor Detail
-
NTV2SubGrid
public NTV2SubGrid(InputStream in, boolean bigEndian, boolean loadAccuracy) throws IOException
Construct a Sub Grid from an InputStream, loading the node data into arrays in this object.- Parameters:
in
- GridShiftFile InputStreambigEndian
- is the file bigEndian?loadAccuracy
- is the node Accuracy data to be loaded?- Throws:
IOException
- if any I/O error occurs
-
-
Method Detail
-
readBytes
private static void readBytes(InputStream in, byte[] b) throws IOException
- Throws:
IOException
-
getSubGridForCoord
public NTV2SubGrid getSubGridForCoord(double lon, double lat)
Tests if a specified coordinate is within this Sub Grid or one of its Sub Grids. If the coordinate is outside this Sub Grid, null is returned. If the coordinate is within this Sub Grid, but not within any of its Sub Grids, this Sub Grid is returned. If the coordinate is within one of this Sub Grid's Sub Grids, the method is called recursively on the child Sub Grid.- Parameters:
lon
- Longitude in Positive West Secondslat
- Latitude in Seconds- Returns:
- the Sub Grid containing the Coordinate or null
-
isCoordWithin
private boolean isCoordWithin(double lon, double lat)
Tests if a specified coordinate is within this Sub Grid. A coordinate on either outer edge (maximum Latitude or maximum Longitude) is deemed to be outside the grid.- Parameters:
lon
- Longitude in Positive West Secondslat
- Latitude in Seconds- Returns:
- true or false
-
interpolate
private static double interpolate(float a, float b, float c, float d, double x, double y)
Bi-Linear interpolation of four nearest node values as described in 'GDAit Software Architecture Manual' produced by the Geomatics Department of the University of Melbourne- Parameters:
a
- value at the A nodeb
- value at the B nodec
- value at the C noded
- value at the D nodex
- Longitude factory
- Latitude factor- Returns:
- interpolated value
-
interpolateGridShift
public void interpolateGridShift(NTV2GridShift gs)
Interpolate shift and accuracy values for a coordinate in the 'from' datum of the GridShiftFile. The algorithm is described in 'GDAit Software Architecture Manual' produced by the Geomatics Department of the University of MelbourneThis method is thread safe for both memory based and file based node data.
- Parameters:
gs
- GridShift object containing the coordinate to shift and the shift values
-
getParentSubGridName
public String getParentSubGridName()
Returns the parent sub grid name.- Returns:
- the parent sub grid name
-
getSubGridName
public String getSubGridName()
Returns the sub grid name.- Returns:
- the sub grid name
-
getNodeCount
public int getNodeCount()
Returns the node count.- Returns:
- the node count
-
getSubGridCount
public int getSubGridCount()
Returns the sub grid count.- Returns:
- the sub grid count
-
setSubGridArray
public void setSubGridArray(NTV2SubGrid... subGrid)
Set an array of Sub Grids of this sub grid- Parameters:
subGrid
- subgrids
-
getDetails
public String getDetails()
Returns textual details about the sub grid.- Returns:
- textual details about the sub grid
-
getMaxLat
public double getMaxLat()
Get maximum latitude value- Returns:
- maximum latitude
-
getMaxLon
public double getMaxLon()
Get maximum longitude value- Returns:
- maximum longitude
-
getMinLat
public double getMinLat()
Get minimum latitude value- Returns:
- minimum latitude
-
getMinLon
public double getMinLon()
Get minimum longitude value- Returns:
- minimum longitude
-
-