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:
  • Field Details

  • Constructor Details

    • 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 InputStream
      bigEndian - is the file bigEndian?
      loadAccuracy - is the node Accuracy data to be loaded?
      Throws:
      IOException - if any I/O error occurs
  • Method Details

    • 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 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 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 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

      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
    • getParentSubGridName

      Returns the parent sub grid name.
      Returns:
      the parent sub grid name
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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