com.oziexplorer
Class GridRef
java.lang.Object
com.oziexplorer.Position
com.oziexplorer.GridRef
- Direct Known Subclasses:
- BNGGridRef, UserGridRef, UTMGridRef
public class GridRef
- extends Position
This class represents grid references. Grid references are defined by the
grid system they use, which may be one of the standard ones supported by
OziExplorer (see Grid
) or a user-specified grid (see
UserGridDef
).
Copyright 2011 Alan Burlison, . All rights reserved.
Use is subject to license terms, see
LICENSE.txt.
Field Summary |
protected static Grid |
defaultGrid
The default grid to use. |
protected double |
easting
The easting of this reference. |
protected Grid |
grid
The grid system for this reference. |
protected double |
northing
The northing of this reference. |
protected String |
zone
The zone of this reference, if required. |
Constructor Summary |
protected |
GridRef()
Default constructor, here so derived classes can provide their
own constructors. |
|
GridRef(Grid grid,
String datum,
String zone,
double easting,
double northing)
Create a new grid reference for the given grid, datum, zone, easting and
northing. |
|
GridRef(Position pos)
Create a new grid reference in the default grid and current map datum,
converting the given position to the grid and datum. |
|
GridRef(Position position,
Grid newGrid,
String newDatum)
Create a new grid reference for the given grid , converting
the given position to the specified grid and datum. |
|
GridRef(String zone,
double easting,
double northing)
Create a new grid reference in the default grid using the datum of the
currently loaded map and the specified zone ,
easting and northing . |
|
GridRef(String datum,
String zone,
double easting,
double northing)
Create a new grid reference in the default grid with the given
datum , zone , easting and
northing . |
grid
protected Grid grid
- The grid system for this reference.
zone
protected String zone
- The zone of this reference, if required.
easting
protected double easting
- The easting of this reference.
northing
protected double northing
- The northing of this reference.
defaultGrid
protected static Grid defaultGrid
- The default grid to use.
GridRef
public GridRef(Grid grid,
String datum,
String zone,
double easting,
double northing)
- Create a new grid reference for the given grid, datum, zone, easting and
northing.
- Parameters:
grid
- grid for the coordinates.datum
- datum for the coordinates.zone
- grid zone.easting
- the easting.northing
- the northing.
GridRef
public GridRef(String datum,
String zone,
double easting,
double northing)
- Create a new grid reference in the default grid with the given
datum
, zone
, easting
and
northing
. The initial default grid is UTM, and it can be
changed with setDefaultGrid(Grid)
.
- Parameters:
datum
- datum for the coordinates.zone
- grid zone.easting
- the easting.northing
- the northing.
GridRef
public GridRef(String zone,
double easting,
double northing)
throws OziException
- Create a new grid reference in the default grid using the datum of the
currently loaded map and the specified
zone
,
easting
and northing
. The initial default
grid is UTM, and it can be changed with setDefaultGrid(Grid)
.
- Parameters:
zone
- grid zone.easting
- the easting.northing
- the northing.
- Throws:
OziException
- if OziAPI returns an error.
GridRef
public GridRef(Position position,
Grid newGrid,
String newDatum)
throws OziException
- Create a new grid reference for the given
grid
, converting
the given position to the specified grid and datum.
- Parameters:
position
- Position to convertnewGrid
- grid for the coordinatesnewDatum
- datum for the coordinates
- Throws:
OziException
- if OziAPI returns an error
GridRef
public GridRef(Position pos)
throws OziException
- Create a new grid reference in the default grid and current map datum,
converting the given position to the grid and datum. The initial default
grid is UTM, and it can be changed with
setDefaultGrid(Grid)
.
- Parameters:
pos
- Position to convert.
- Throws:
OziException
- if OziAPI returns an error.
GridRef
protected GridRef()
throws OziException
- Default constructor, here so derived classes can provide their
own constructors.
- Throws:
OziException
- if OziAPI returns an error.
vectorBetween
public SpatialVector vectorBetween(Position position)
throws OziException
- Return the distance between two positions, in metres. Both positions
are normalised to WGS84
LatLon
s before the comparison. See
LatLon.vectorBetween(com.oziexplorer.Position)
for details.
- Specified by:
vectorBetween
in class Position
- Parameters:
position
- the Position to compare against.
- Returns:
- the distance between the positions, in metres.
- Throws:
OziException
- if OziAPI returns an error.
addVector
public GridRef addVector(SpatialVector vector)
throws OziException
- Description copied from class:
Position
- Return a new Position which is offset from the current position by the
given vector, specified as a
SpatialVector
.
- Specified by:
addVector
in class Position
- Parameters:
vector
- the SpatialVector to offset by.
- Returns:
- the new Position.
- Throws:
OziException
- if OziAPI returns an error.
equals
public boolean equals(Object that)
- Test if two grid references are equal. Both positions are normalised
to
LatLon
s in the WGS84 datum before the comparison, and the
positions will compare as equal if they are within
Position.getComparisonAccuracy()
of each other.
See LatLon.vectorBetween(com.oziexplorer.Position)
for full details.
- Overrides:
equals
in class Object
- Parameters:
that
- the object to compare against.
- Returns:
- true if the objects are equal, within the specified bounds.
hashCode
public int hashCode()
- Return the hash code for this object.
- Overrides:
hashCode
in class Object
- Returns:
- the hash code for this object.
getGrid
public Grid getGrid()
- Return the grid for this reference.
- Returns:
- the grid for this reference.
getZone
public String getZone()
- Return the zone of this reference.
- Returns:
- the zone of this reference.
getEasting
public double getEasting()
- Return the easting of this reference.
- Returns:
- the easting of this reference.
getNorthing
public double getNorthing()
- Return the northing of this reference.
- Returns:
- the northing of this reference.
toString
public String toString()
- Return a string representation of the grid reference.
- Overrides:
toString
in class Object
- Returns:
- a string representation of the grid reference.
setDefaultGrid
public static void setDefaultGrid(Grid grid)
- Set the default grid. Initial value is UTM.
- Parameters:
grid
- the default grid to use.
getDefaultGrid
public static Grid getDefaultGrid()
- Return the default grid. Initial value is UTM.
- Returns:
- the default grid.