org.proj4
Class PJ

Show UML class diagram
Object
  extended by PJ

public class PJ
extends Object

Wraps the Proj4 PJ native data structure. Almost every methods defined in this class are native methods delegating the work to the Proj.4 library. This class is the only place where such native methods are defined.

In the Proj.4 library, the PJ structure aggregates in a single place information usually splitted in many different ISO 19111 interfaces: Ellipsoid, Datum, PrimeMeridian, CoordinateSystem, CoordinateReferenceSystem and their sub-interfaces. The relationship with the GeoAPI methods is indicated in the "See" tags when appropriate.

Since:
3.1

Nested Class Summary
static class PJ.Type
          The coordinate reference system (CRS) type returned by getType().
 
Field Summary
static int DIMENSION_MAX
          The maximal number of dimension accepted by the transform(PJ, int, double[], int, int) method.
 
Constructor Summary
PJ(PJ crs, PJ.Type type)
          Creates a new PJ structure derived from an existing PJ object.
PJ(String definition)
          Creates a new PJ structure from the given Proj4 definition string.
 
Method Summary
protected  void finalize()
          Deallocates the native PJ data structure.
 char[] getAxisDirections()
          Returns an array of character indicating the direction of each axis.
 String getDefinition()
          Returns the Proj4 definition string.
 double getEccentricitySquared()
          Returns the square of the ellipsoid eccentricity (ε²).
 double getGreenwichLongitude()
          Longitude of the prime meridian measured from the Greenwich meridian, positive eastward.
 String getLastError()
          Returns a description of the last error that occurred, or null if none.
 double getLinearUnitToMetre(boolean vertical)
          Returns the conversion factor from the linear units to metres.
 double getSemiMajorAxis()
          Returns the value stored in the a_orig PJ field.
 double getSemiMinorAxis()
          Returns the value computed from PJ fields by √((a_orig)² × (1 - es_orig)).
 PJ.Type getType()
          Returns the Coordinate Reference System type.
static String getVersion()
          Returns the version number of the Proj4 library.
 String toString()
          Returns the string representation of the PJ structure.
 void transform(PJ target, int dimension, double[] coordinates, int offset, int numPts)
          Transforms in-place the coordinates in the given array.
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIMENSION_MAX

public static final int DIMENSION_MAX
The maximal number of dimension accepted by the transform(PJ, int, double[], int, int) method. This upper limit is actually somewhat arbitrary. This limit exists mostly as a safety against potential misuse.

See Also:
Constant Field Values
Constructor Detail

PJ

public PJ(String definition)
   throws IllegalArgumentException
Creates a new PJ structure from the given Proj4 definition string.

Parameters:
definition - The Proj.4 definition string.
Throws:
IllegalArgumentException - If the PJ structure can not be created from the given string.

PJ

public PJ(PJ crs,
          PJ.Type type)
   throws IllegalArgumentException
Creates a new PJ structure derived from an existing PJ object. This constructor is usually for getting the base geographic CRS from a projected CRS.

Parameters:
crs - The CRS (usually projected) from which to derive a new CRS.
type - The type of the new CRS. Currently, only PJ.Type.GEOGRAPHIC is supported.
Throws:
IllegalArgumentException - If the PJ structure can not be created.
Method Detail

getVersion

public static String getVersion()
Returns the version number of the Proj4 library.

Returns:
The Proj.4 release string.

getDefinition

public String getDefinition()
Returns the Proj4 definition string. This is the string given to the constructor, expanded with as much information as possible.

Returns:
The Proj4 definition string.

getType

public PJ.Type getType()
Returns the Coordinate Reference System type.

Returns:
The CRS type.

getSemiMajorAxis

public double getSemiMajorAxis()
Returns the value stored in the a_orig PJ field.

Returns:
The axis length stored in a_orig.
See Also:
Ellipsoid.getSemiMajorAxis()

getSemiMinorAxis

public double getSemiMinorAxis()
Returns the value computed from PJ fields by √((a_orig)² × (1 - es_orig)).

Returns:
The axis length computed by √((a_orig)² × (1 - es_orig)).
See Also:
Ellipsoid.getSemiMinorAxis()

getEccentricitySquared

public double getEccentricitySquared()
Returns the square of the ellipsoid eccentricity (ε²). The eccentricity is related to axis length by ε=√(1-(b/a)²). The eccentricity of a sphere is zero.

Returns:
The eccentricity.
See Also:
Ellipsoid.isSphere(), Ellipsoid.getInverseFlattening()

getAxisDirections

public char[] getAxisDirections()
Returns an array of character indicating the direction of each axis. Directions are characters like 'e' for East, 'n' for North and 'u' for Up.

Returns:
The axis directions.
See Also:
CoordinateSystemAxis.getDirection()

getGreenwichLongitude

public double getGreenwichLongitude()
Longitude of the prime meridian measured from the Greenwich meridian, positive eastward.

Returns:
The prime meridian longitude, in degrees.
See Also:
PrimeMeridian.getGreenwichLongitude()

getLinearUnitToMetre

public double getLinearUnitToMetre(boolean vertical)
Returns the conversion factor from the linear units to metres.

Parameters:
vertical - false for the conversion factor of horizontal axes, or true for the conversion factor of the vertical axis.
Returns:
The conversion factor to metres for the given axis.

transform

public void transform(PJ target,
                      int dimension,
                      double[] coordinates,
                      int offset,
                      int numPts)
               throws PJException
Transforms in-place the coordinates in the given array. The coordinates array shall contain (x,y,z,…) tuples, where the z and following dimensions are optional. Note that any dimension after the z value are ignored.

Input and output units:

Parameters:
target - The target CRS.
dimension - The dimension of each coordinate value. Must be in the [2-100] range.
coordinates - The coordinates to transform, as a sequence of (x,y,<z>,…) tuples.
offset - Offset of the first coordinate in the given array.
numPts - Number of points to transform.
Throws:
NullPointerException - If the target or coordinates argument is null.
IndexOutOfBoundsException - if the offset or numPts arguments are invalid.
PJException - If the operation failed for an other reason (provided by Proj4).
See Also:
MathTransform.transform(double[], int, double[], int, int)

getLastError

public String getLastError()
Returns a description of the last error that occurred, or null if none.

Returns:
The last error that occurred, or null.

toString

public String toString()
Returns the string representation of the PJ structure.

Overrides:
toString in class Object
Returns:
The string representation.

finalize

protected final void finalize()
Deallocates the native PJ data structure. This method can be invoked only by the garbage collector, and must be invoked exactly once (no more, no less). NEVER INVOKE THIS METHOD EXPLICITELY, NEVER OVERRIDE.

Overrides:
finalize in class Object


Copyright © 1994-2012 Open Geospatial Consortium. All Rights Reserved.