Package org.proj4
Class PJ
- Object
-
- PJ
-
public class PJ extends ObjectWraps the PROJPJnative data structure. Almost every methods defined in this class are native methods delegating the work to the PROJ library. This class is the only place where such native methods are defined.In the PROJ library, the
PJstructure aggregates in a single place information usually splitted in many different ISO 19111 interfaces:Ellipsoid,Datum,PrimeMeridian,CoordinateSystem,CoordinateReferenceSystemand their sub-interfaces. The relationship with the GeoAPI methods is indicated in the "See" tags when appropriate.- Since:
- 4.8
- Version:
- 5.1
-
-
Field Summary
Fields Modifier and Type Field Description static intDIMENSION_MAXThe maximal number of dimension accepted by thetransform(PJ, int, double[], int, int)method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfinalize()Deallocates the native PJ data structure.char[]getAxisDirections()Returns an array of character indicating the direction of each axis.StringgetDefinition()Returns the PROJ definition string.doublegetEccentricitySquared()Returns the square of the ellipsoid eccentricity (ε²).doublegetGreenwichLongitude()Longitude of the prime meridian measured from the Greenwich meridian, positive eastward.StringgetLastError()Returns a description of the last error that occurred, ornullif none.doublegetLinearUnitToMetre(boolean vertical)Returns the conversion factor from the linear units to metres.doublegetSemiMajorAxis()Returns the value stored in thea_origPJ field.doublegetSemiMinorAxis()Returns the value computed from PJ fields by\u221a((a_orig)² × (1 - es_orig)).PJ.TypegetType()Returns the Coordinate Reference System type.static StringgetVersion()Returns the version number of the PROJ library.StringtoString()Returns the string representation of the PJ structure.voidtransform(PJ target, int dimension, double[] coordinates, int offset, int numPts)Transforms in-place the coordinates in the given array.
-
-
-
Field Detail
-
DIMENSION_MAX
@Native public static final int DIMENSION_MAX
The maximal number of dimension accepted by thetransform(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 newPJstructure from the given PROJ definition string.- Parameters:
definition- the PROJ 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 newPJstructure derived from an existingPJobject. 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, onlyPJ.Type.GEOGRAPHICis supported.- Throws:
IllegalArgumentException- if the PJ structure can not be created.
-
-
Method Detail
-
getVersion
public static String getVersion()
Returns the version number of the PROJ library.- Returns:
- the PROJ release string.
-
getDefinition
public String getDefinition()
Returns the PROJ definition string. This is the string given to the constructor, expanded with as much information as possible.- Returns:
- the PROJ 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 thea_origPJ field.- Returns:
- the axis length stored in
a_orig. - See Also:
Ellipsoid
-
getSemiMinorAxis
public double getSemiMinorAxis()
Returns the value computed from PJ fields by\u221a((a_orig)² × (1 - es_orig)).- Returns:
- the axis length computed by
\u221a((a_orig)² × (1 - es_orig)). - See Also:
Ellipsoid
-
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.
-
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
-
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
-
getLinearUnitToMetre
public double getLinearUnitToMetre(boolean vertical)
Returns the conversion factor from the linear units to metres.- Parameters:
vertical-falsefor the conversion factor of horizontal axes, ortruefor 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 any additional dimensions are optional. Note that any dimension after the z value are ignored.Input and output units:
- Angular units (as in longitude and latitudes) are decimal degrees.
- Linear units are usually metres, but this is actually projection-dependent.
- 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 thetargetorcoordinatesargument is null.IndexOutOfBoundsException- if theoffsetornumPtsarguments are invalid.PJException- if the operation failed for another reason (provided by PROJ).- See Also:
MathTransform
-
getLastError
public String getLastError()
Returns a description of the last error that occurred, ornullif none.- Returns:
- the last error that occurred, or
null.
-
toString
public String toString()
Returns the string representation of the PJ structure.- Overrides:
toStringin classObject- Returns:
- the string representation.
-
finalize
protected final void finalize()
Deallocates the native PJ data structure. This method should be invoked exactly once, only by the garbage collector,- Overrides:
finalizein classObject
-
-