jniproj.c File Reference

Functions used by the Java Native Interface (JNI) wrappers of Proj.4. More...

Include dependency graph for jniproj.c:

## Macros

#define | PJ_FIELD_NAME "ptr"
#define | PJ_FIELD_TYPE "J"
#define | PJ_MAX_DIMENSION 100

## Functions

PJ * | getPJ (JNIEnv *env, jobject object)
| Internal method returning the address of the PJ structure wrapped by the given Java object. This function looks for a field named "ptr" and of type "long" (Java signature "J") in the given object. More...
jdouble | javaNaN (JNIEnv *env)
| Internal method returning the java.lang.Double.NaN constant value. Efficiency is no a high concern for this particular method, because it is used mostly when the user wrongly attempt to use a disposed PJ object. More...
JNIEXPORT jstring JNICALL | Java_org_proj4_PJ_getVersion (JNIEnv *env, jclass class)
| Returns the Proj4 release number. More...
JNIEXPORT jlong JNICALL | Java_org_proj4_PJ_allocatePJ (JNIEnv *env, jclass class, jstring definition)
| Allocates a new PJ structure from a definition string. More...
JNIEXPORT jlong JNICALL | Java_org_proj4_PJ_allocateGeoPJ (JNIEnv *env, jclass class, jobject projected)
| Allocates a new geographic PJ structure from an existing one. More...
JNIEXPORT jstring JNICALL | Java_org_proj4_PJ_getDefinition (JNIEnv *env, jobject object)
| Returns the definition string. More...
JNIEXPORT jstring JNICALL | Java_org_proj4_PJ_toString (JNIEnv *env, jobject object)
| Returns the description associated to the PJ structure. More...
JNIEXPORT jobject JNICALL | Java_org_proj4_PJ_getType (JNIEnv *env, jobject object)
| Returns the CRS type as one of the PJ.Type enum: GEOGRAPHIC, GEOCENTRIC or PROJECTED. This function should never return NULL, unless class or fields have been renamed in such a way that we can not find anymore the expected enum values. More...
JNIEXPORT jdouble JNICALL | Java_org_proj4_PJ_getSemiMajorAxis (JNIEnv *env, jobject object)
| Returns the semi-major axis length. More...
JNIEXPORT jdouble JNICALL | Java_org_proj4_PJ_getSemiMinorAxis (JNIEnv *env, jobject object)
| Computes the semi-minor axis length from the semi-major axis length and the eccentricity squared. More...
JNIEXPORT jdouble JNICALL | Java_org_proj4_PJ_getEccentricitySquared (JNIEnv *env, jobject object)
| Returns the eccentricity squared. More...
JNIEXPORT jcharArray JNICALL | Java_org_proj4_PJ_getAxisDirections (JNIEnv *env, jobject object)
| Returns an array of character indicating the direction of each axis. More...
JNIEXPORT jdouble JNICALL | Java_org_proj4_PJ_getGreenwichLongitude (JNIEnv *env, jobject object)
| Longitude of the prime meridian measured from the Greenwich meridian, positive eastward. More...
JNIEXPORT jdouble JNICALL | Java_org_proj4_PJ_getLinearUnitToMetre (JNIEnv *env, jobject object, jboolean vertical)
| Returns the conversion factor from linear units to metres. More...
void | convertAngularOrdinates (PJ *pj, double *data, jint numPts, int dimension, double factor)
| Converts input values from degrees to radians before coordinate operation, or the output values from radians to degrees after the coordinate operation. More...
JNIEXPORT void JNICALL | Java_org_proj4_PJ_transform (JNIEnv *env, jobject object, jobject target, jint dimension, jdoubleArray coordinates, jint offset, jint numPts)
| Transforms in-place the coordinates in the given array. More...
JNIEXPORT jstring JNICALL | Java_org_proj4_PJ_getLastError (JNIEnv *env, jobject object)
| Returns a description of the last error that occurred, or NULL if none. More...
JNIEXPORT void JNICALL | Java_org_proj4_PJ_finalize (JNIEnv *env, jobject object)

Deallocate the PJ structure. This method is invoked by the garbage collector exactly once. This method will also set the Java "ptr" final field to 0 as a safety. In theory we are not supposed to change the value of a final field. But no Java code should use this field, and the PJ object is being garbage collected anyway. We set the field to 0 as a safety in case some user invoked the finalize() method explicitely despite our warning in the Javadoc to never do such thing. More...

## Detailed Description

Author
  Antonello Andrea

Date
  Wed Oct 20 23:10:24 CEST 2004

Author
  Martin Desruisseaux

Date
  August 2011

## Macro Definition Documentation

## PJ_FIELD_NAME

#define PJ_FIELD_NAME "ptr"

Referenced by getPJ(), and Java_org_proj4_PJ_finalize().

## PJ_FIELD_TYPE

#define PJ_FIELD_TYPE "J"

Referenced by getPJ(), and Java_org_proj4_PJ_finalize().

## PJ_MAX_DIMENSION

#define PJ_MAX_DIMENSION 100

Referenced by Java_org_proj4_PJ_transform().

## Function Documentation

## getPJ()

PJ* getPJ | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The address of the PJ structure, or NULL if the operation fails (for example because the "ptr" field was not found).

References PJ_FIELD_NAME, and PJ_FIELD_TYPE.

Referenced by Java_org_proj4_PJ_allocateGeoPJ(), Java_org_proj4_PJ_getAxisDirections(), Java_org_proj4_PJ_getDefinition(), Java_org_proj4_PJ_getEccentricitySquared(), Java_org_proj4_PJ_getGreenwichLongitude(), Java_org_proj4_PJ_getLastError(), Java_org_proj4_PJ_getLinearUnitToMetre(), Java_org_proj4_PJ_getSemiMajorAxis(), Java_org_proj4_PJ_getSemiMinorAxis(), Java_org_proj4_PJ_getType(), Java_org_proj4_PJ_toString(), and Java_org_proj4_PJ_transform().

## javaNaN()

jdouble javaNaN | ( | JNIEnv * | env | ) |

Parameters

  env | - The JNI environment.

Returns
  The java.lang.Double.NaN constant value.

References Java_org_proj4_PJ_getVersion().

Referenced by Java_org_proj4_PJ_getEccentricitySquared(), Java_org_proj4_PJ_getGreenwichLongitude(), Java_org_proj4_PJ_getLinearUnitToMetre(), Java_org_proj4_PJ_getSemiMajorAxis(), and Java_org_proj4_PJ_getSemiMinorAxis().

## Java_org_proj4_PJ_getVersion()

JNIEXPORT jstring JNICALL Java_org_proj4_PJ_getVersion | ( | JNIEnv * | env,
|  | jclass | class
| ) |  |

Parameters

  env | - The JNI environment.
  class | - The class from which this method has been invoked.

Returns
  The Proj4 release number, or NULL.

References Java_org_proj4_PJ_allocatePJ().

Referenced by javaNaN().

## Java_org_proj4_PJ_allocatePJ()

JNIEXPORT jlong JNICALL Java_org_proj4_PJ_allocatePJ | ( | JNIEnv * | env,
|  | jclass | class,
|  | jstring | definition
| ) |  |

Parameters

  env | - The JNI environment.
  class | - The class from which this method has been invoked.
  definition | - The string definition to be given to Proj4.

Returns
  The address of the new PJ structure, or 0 in case of failure.

References Java_org_proj4_PJ_allocateGeoPJ().

Referenced by Java_org_proj4_PJ_getVersion().

## Java_org_proj4_PJ_allocateGeoPJ()

JNIEXPORT jlong JNICALL Java_org_proj4_PJ_allocateGeoPJ | ( | JNIEnv * | env,
|  | jclass | class,
|  | jobject | projected
| ) |  |

Parameters

  env | - The JNI environment.
  class | - The class from which this method has been invoked.
  projected | - The PJ object from which to derive a new one.

Returns
  The address of the new PJ structure, or 0 in case of failure.

References getPJ(), and Java_org_proj4_PJ_getDefinition().

Referenced by Java_org_proj4_PJ_allocatePJ().

## Java_org_proj4_PJ_getDefinition()

JNIEXPORT jstring JNICALL Java_org_proj4_PJ_getDefinition | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The definition string.

References getPJ(), and Java_org_proj4_PJ_toString().

Referenced by Java_org_proj4_PJ_allocateGeoPJ().

## Java_org_proj4_PJ_toString()

JNIEXPORT jstring JNICALL Java_org_proj4_PJ_toString | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The description associated to the PJ structure.

References getPJ(), and Java_org_proj4_PJ_getType().

Referenced by Java_org_proj4_PJ_getDefinition().

## Java_org_proj4_PJ_getType()

JNIEXPORT jobject JNICALL Java_org_proj4_PJ_getType | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The CRS type as one of the PJ.Type enum.

References getPJ(), and Java_org_proj4_PJ_getSemiMajorAxis().

Referenced by Java_org_proj4_PJ_toString().

## Java_org_proj4_PJ_getSemiMajorAxis()

JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getSemiMajorAxis | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The semi-major axis length.

References getPJ(), Java_org_proj4_PJ_getSemiMinorAxis(), and javaNaN().

Referenced by Java_org_proj4_PJ_getType().

## Java_org_proj4_PJ_getSemiMinorAxis()

JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getSemiMinorAxis | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The semi-minor axis length.

References getPJ(), Java_org_proj4_PJ_getEccentricitySquared(), and javaNaN().

Referenced by Java_org_proj4_PJ_getSemiMajorAxis().

## Java_org_proj4_PJ_getEccentricitySquared()

JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getEccentricitySquared | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The eccentricity.

References getPJ(), Java_org_proj4_PJ_getAxisDirections(), and javaNaN().

Referenced by Java_org_proj4_PJ_getSemiMinorAxis().

## Java_org_proj4_PJ_getAxisDirections()

JNIEXPORT jcharArray JNICALL Java_org_proj4_PJ_getAxisDirections | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The axis directions.

References getPJ(), and Java_org_proj4_PJ_getGreenwichLongitude().

Referenced by Java_org_proj4_PJ_getEccentricitySquared().

## Java_org_proj4_PJ_getGreenwichLongitude()

JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getGreenwichLongitude | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The prime meridian longitude, in degrees.

References getPJ(), Java_org_proj4_PJ_getLinearUnitToMetre(), and javaNaN().

Referenced by Java_org_proj4_PJ_getAxisDirections().

## Java_org_proj4_PJ_getLinearUnitToMetre()

JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getLinearUnitToMetre | ( | JNIEnv * | env,
|  | jobject | object,
|  | jboolean | vertical
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).
  vertical | - JNI_FALSE for horizontal axes, or JNI_TRUE for the vertical axis.

Returns
  The conversion factor to metres.

References getPJ(), and javaNaN().

Referenced by Java_org_proj4_PJ_getGreenwichLongitude().

## convertAngularOrdinates()

void convertAngularOrdinates | ( | PJ * | pj,
|  | double * | data,
|  | jint | numPts,
|  | int | dimension,
|  | double | factor
| ) |  |

Parameters

  pj | - The Proj.4 PJ structure.
  data | - The coordinate array to transform.
  numPts | - Number of points to transform.
  dimension | - Dimension of points in the coordinate array.
  factor | - The scale factor to apply: M_PI/180 for inputs or 180/M_PI for outputs.

References Java_org_proj4_PJ_transform().

Referenced by Java_org_proj4_PJ_transform().

## Java_org_proj4_PJ_transform()

JNIEXPORT void JNICALL Java_org_proj4_PJ_transform | ( | JNIEnv * | env,
|  | jobject | object,
|  | jobject | target,
|  | jint | dimension,
|  | jdoubleArray | coordinates,
|  | jint | offset,
|  | jint | numPts
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).
  target | - The target CRS.
  dimension | - The dimension of each coordinate value. Must be equals or greater than 2.
  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.

References convertAngularOrdinates(), getPJ(), Java_org_proj4_PJ_getLastError(), and PJ_MAX_DIMENSION.

Referenced by convertAngularOrdinates().

## Java_org_proj4_PJ_getLastError()

JNIEXPORT jstring JNICALL Java_org_proj4_PJ_getLastError | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

Returns
  The last error, or NULL.

References getPJ(), and Java_org_proj4_PJ_finalize().

Referenced by Java_org_proj4_PJ_transform().

## Java_org_proj4_PJ_finalize()

JNIEXPORT void JNICALL Java_org_proj4_PJ_finalize | ( | JNIEnv * | env,
|  | jobject | object
| ) |  |

Parameters

  env | - The JNI environment.
  object | - The Java object wrapping the PJ structure (not allowed to be NULL).

References PJ_FIELD_NAME, and PJ_FIELD_TYPE.

Referenced by Java_org_proj4_PJ_getLastError().