org.openstreetmap.josm.data.projection.datum
Class NTV2SubGrid

java.lang.Object
  extended by org.openstreetmap.josm.data.projection.datum.NTV2SubGrid
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class NTV2SubGrid
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Models the NTv2 Sub Grid within a Grid Shift File

See Also:
Serialized Form

Field Summary
(package private)  boolean bigEndian
           
private  java.lang.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  java.lang.String parentSubGridName
           
private  NTV2SubGrid[] subGrid
           
private  java.lang.String subGridName
           
private  java.lang.String updated
           
 
Constructor Summary
NTV2SubGrid(java.io.InputStream in, boolean bigEndian, boolean loadAccuracy)
          Construct a Sub Grid from an InputStream, loading the node data into arrays in this object.
 
Method Summary
 java.lang.Object clone()
          Make a deep clone of this Sub Grid
 java.lang.String getDetails()
           
 double getMaxLat()
           
 double getMaxLon()
           
 double getMinLat()
           
 double getMinLon()
           
 int getNodeCount()
           
 java.lang.String getParentSubGridName()
           
 NTV2SubGrid getSubGrid(int index)
           
 int getSubGridCount()
           
 NTV2SubGrid getSubGridForCoord(double lon, double lat)
          Tests if a specified coordinate is within this Sub Grid or one of its Sub Grids.
 java.lang.String getSubGridName()
           
private  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
 NTV2GridShift 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.
 void setSubGridArray(NTV2SubGrid[] subGrid)
          Set an array of Sub Grids of this sub grid
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subGridName

private java.lang.String subGridName

parentSubGridName

private java.lang.String parentSubGridName

created

private java.lang.String created

updated

private java.lang.String updated

minLat

private double minLat

maxLat

private double maxLat

minLon

private double minLon

maxLon

private double maxLon

latInterval

private double latInterval

lonInterval

private double lonInterval

nodeCount

private int nodeCount

lonColumnCount

private int lonColumnCount

latRowCount

private int latRowCount

latShift

private float[] latShift

lonShift

private float[] lonShift

latAccuracy

private float[] latAccuracy

lonAccuracy

private float[] lonAccuracy

bigEndian

boolean bigEndian

subGrid

private NTV2SubGrid[] subGrid
Constructor Detail

NTV2SubGrid

public NTV2SubGrid(java.io.InputStream in,
                   boolean bigEndian,
                   boolean loadAccuracy)
            throws java.io.IOException
Construct a Sub Grid from an InputStream, loading the node data into arrays in this object.

Parameters:
in - GridShiftFile InputStream
bigEndian - is the file bigEndian?
loadAccuracy - is the node Accuracy data to be loaded?
Throws:
java.lang.Exception
java.io.IOException
Method Detail

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 Seconds
lat - 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 Seconds
lat - Latitude in Seconds
Returns:
true or false

interpolate

private final 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 node
b - value at the B node
c - value at the C node
d - value at the D node
X - Longitude factor
Y - Latitude factor
Returns:
interpolated value

interpolateGridShift

public NTV2GridShift 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 Melbourne

This 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
Returns:
the GridShift object supplied, with values updated.
Throws:
java.io.IOException

getParentSubGridName

public java.lang.String getParentSubGridName()

getSubGridName

public java.lang.String getSubGridName()

getNodeCount

public int getNodeCount()

getSubGridCount

public int getSubGridCount()

getSubGrid

public NTV2SubGrid getSubGrid(int index)

setSubGridArray

public void setSubGridArray(NTV2SubGrid[] subGrid)
Set an array of Sub Grids of this sub grid

Parameters:
subGrid -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDetails

public java.lang.String getDetails()

clone

public java.lang.Object clone()
Make a deep clone of this Sub Grid

Overrides:
clone in class java.lang.Object

getMaxLat

public double getMaxLat()
Returns:

getMaxLon

public double getMaxLon()
Returns:

getMinLat

public double getMinLat()
Returns:

getMinLon

public double getMinLon()
Returns:


JOSM