JPROJ4
Macros | Functions
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 __C99FEATURES__   1
 
#define PJ_FIELD_NAME   "ptr"
 
#define PJ_FIELD_TYPE   "J"
 
#define PJ_MAX_DIMENSION   100
 
#define arraysize   300
 

Functions

 PJ_CVSID ("$Id: jniproj.c 2095 2011-09-02 08:44:02Z desruisseaux $")
 
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...
 
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...
 
JNIEXPORT void JNICALL Java_org_proj4_Projections_transform (JNIEnv *env, jobject parent, jdoubleArray firstcoord, jdoubleArray secondcoord, jdoubleArray values, jstring src, jstring dest, jlong pcount, jint poffset)
 executes reprojection More...
 
JNIEXPORT jstring JNICALL Java_org_proj4_Projections_getProjInfo (JNIEnv *env, jobject parent, jstring projdefinition)
 retrieves projection parameters More...
 
JNIEXPORT jstring JNICALL Java_org_proj4_Projections_getEllipsInfo (JNIEnv *env, jobject parent, jstring projdefinition)
 retrieves ellipsoid parameters More...
 

Detailed Description

Author
Antonello Andrea
Date
Wed Oct 20 23:10:24 CEST 2004
Author
Martin Desruisseaux
Date
August 2011

Macro Definition Documentation

#define __C99FEATURES__   1
#define PJ_FIELD_NAME   "ptr"
#define PJ_FIELD_TYPE   "J"
#define PJ_MAX_DIMENSION   100
#define arraysize   300

Function Documentation

PJ_CVSID ( "$Id: jniproj.c 2095 2011-09-02 08:44:02Z desruisseaux $"  )
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().

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.
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.
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().

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().

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().

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().

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().

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().

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().

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().

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().

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().

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.

Referenced by 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(), and PJ_MAX_DIMENSION.

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().

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.

JNIEXPORT void JNICALL Java_org_proj4_Projections_transform ( JNIEnv *  env,
jobject  parent,
jdoubleArray  firstcoord,
jdoubleArray  secondcoord,
jdoubleArray  values,
jstring  src,
jstring  dest,
jlong  pcount,
jint  poffset 
)

JNI informations: Class: org_proj4_Projections Method: transform Signature: ([D[D[DLjava/lang/String;Ljava/lang/String;JI)V

Parameters
env- parameter used by jni (see JNI specification)
parent- parameter used by jni (see JNI specification)
firstcoord- array of x coordinates
secondcoord- array of y coordinates
values- array of z coordinates
src- definition of the source projection
dest- definition of the destination projection
pcount
poffset
JNIEXPORT jstring JNICALL Java_org_proj4_Projections_getProjInfo ( JNIEnv *  env,
jobject  parent,
jstring  projdefinition 
)

JNI informations: Class: org_proj4_Projections Method: getProjInfo Signature: (Ljava/lang/String;)Ljava/lang/String;

Parameters
env- parameter used by jni (see JNI specification)
parent- parameter used by jni (see JNI specification)
projdefinition- definition of the projection

References arraysize.

JNIEXPORT jstring JNICALL Java_org_proj4_Projections_getEllipsInfo ( JNIEnv *  env,
jobject  parent,
jstring  projdefinition 
)

JNI informations: Class: org_proj4_Projections Method: getEllipsInfo Signature: (Ljava/lang/String;)Ljava/lang/String;

Parameters
env- parameter used by jni (see JNI specification)
parent- parameter used by jni (see JNI specification)
projdefinition- definition of the projection

References arraysize.