RAVE
projection.c File Reference

Wrapper around PROJ.4. More...

#include "projection.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <proj.h>

Classes

struct  _Projection_t
 Represents one projection. More...
 

Macros

#define UV   PJ_UV
 

Functions

void Projection_setDebugLevel (int debugPj)
 Sets the debug level when using proj API.
 
int Projection_getDebugLevel (void)
 Returns the debug level when using proj API.
 
const char * Projection_getProjVersion (void)
 Returns the currently used Proj version.
 
void Projection_setDefaultLonLatProjDef (const char *projdef)
 Sets the default lon/lat proj definition to use.
 
const char * Projection_getDefaultLonLatProjDef (void)
 Returns the default lonlat proj definition.
 
int Projection_init (Projection_t *projection, const char *id, const char *description, const char *definition)
 Initializes a projection with the projection.
 
Projection_tProjection_create (const char *id, const char *description, const char *definition)
 Creates a projection directly.
 
Projection_tProjection_createDefaultLonLatProjection (void)
 Creates a default lon lat projection by using the default lonlat pcs definition.
 
const char * Projection_getID (Projection_t *projection)
 Returns the ID for this projection.
 
const char * Projection_getDescription (Projection_t *projection)
 Returns the description for this projection.
 
const char * Projection_getDefinition (Projection_t *projection)
 Returns the definition for this projection.
 
int Projection_isLatLong (Projection_t *projection)
 Returns if this projection is a latlong or not.
 
int Projection_transform (Projection_t *projection, Projection_t *tgt, double *x, double *y, double *z)
 Transforms the coordinates in this projection into the target projection.
 
int Projection_transformx (Projection_t *projection, Projection_t *tgt, double x, double y, double z, double *ox, double *oy, double *oz)
 This is an alternate version of Projection_transform.
 
int Projection_inv (Projection_t *projection, double x, double y, double *lon, double *lat)
 Translates surface coordinate into lon/lat.
 
int Projection_fwd (Projection_t *projection, double lon, double lat, double *x, double *y)
 Translates lon/lat coordinate into a surface coordinate.
 

Variables

RaveCoreObjectType Projection_TYPE
 Type definition to use when creating a rave object.
 

Detailed Description

Wrapper around PROJ.4.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-10-20

Function Documentation

◆ Projection_create()

Projection_t * Projection_create ( const char * id,
const char * description,
const char * definition )

Creates a projection directly.

Like writing: Projection_t* p = RAVE_OBJECT_NEW(&Projection_TYPE); if (p != NULL) { if (!Projection_init(p, id, description, definition)) { RAVE_OBJECT_RELEASE(p); } }

Parameters
[in]id- the id
[in]description- the description
[in]definition- the definition
Returns
the created projection

◆ Projection_createDefaultLonLatProjection()

Projection_t * Projection_createDefaultLonLatProjection ( void )

Creates a default lon lat projection by using the default lonlat pcs definition.

Returns
the projection or NULL on failure

◆ Projection_fwd()

int Projection_fwd ( Projection_t * projection,
double lon,
double lat,
double * x,
double * y )

Translates lon/lat coordinate into a surface coordinate.

Parameters
[in]projection- the projection
[in]lon- the longitude (in radians)
[in]lat- the latitude (in radians)
[out]x- the x coordinate
[out]y- the y coordinate
Returns
0 on failure otherwise success

◆ Projection_getDebugLevel()

int Projection_getDebugLevel ( void )

Returns the debug level when using proj API.

Returns
Value between 0 (NONE) to 3 (FULL) and 4 (TELL?)

◆ Projection_getDefaultLonLatProjDef()

const char * Projection_getDefaultLonLatProjDef ( void )

Returns the default lonlat proj definition.

Returns
the default lonlat proj definition

◆ Projection_getDefinition()

const char * Projection_getDefinition ( Projection_t * projection)

Returns the definition for this projection.

Parameters
[in]projection- the projection
Returns
the definition for this projection

◆ Projection_getDescription()

const char * Projection_getDescription ( Projection_t * projection)

Returns the description for this projection.

Parameters
[in]projection- the projection
Returns
the description for this projection

◆ Projection_getID()

const char * Projection_getID ( Projection_t * projection)

Returns the ID for this projection.

Parameters
[in]projection- the projection
Returns
the ID for this projection

◆ Projection_getProjVersion()

const char * Projection_getProjVersion ( void )

Returns the currently used Proj version.

Returns
the proj version

◆ Projection_init()

int Projection_init ( Projection_t * projection,
const char * id,
const char * description,
const char * definition )

Initializes a projection with the projection.

◆ Projection_inv()

int Projection_inv ( Projection_t * projection,
double x,
double y,
double * lon,
double * lat )

Translates surface coordinate into lon/lat.

Parameters
[in]projection- the projection
[in]x- the x coordinate
[in]y- the y coordinate
[out]lon- the longitude (in radians)
[out]lat- the latitude (in radians)
Returns
0 on failure otherwise success

◆ Projection_isLatLong()

int Projection_isLatLong ( Projection_t * projection)

Returns if this projection is a latlong or not.

Parameters
[in]projection- self
Returns
if this is a latlong projection or not

◆ Projection_setDebugLevel()

void Projection_setDebugLevel ( int debugPj)

Sets the debug level when using proj API.

Parameters
[in]debugPj- Value between 0 (NONE) to 3 (FULL) and 4 (TELL?)

◆ Projection_setDefaultLonLatProjDef()

void Projection_setDefaultLonLatProjDef ( const char * projdef)

Sets the default lon/lat proj definition to use.

Default is '+proj=longlat +ellps=WGS84 +datum=WGS84'

Parameters
[in]projdef- A proj string, not longer than 1023 chars

◆ Projection_transform()

int Projection_transform ( Projection_t * projection,
Projection_t * tgt,
double * x,
double * y,
double * z )

Transforms the coordinates in this projection into the target projection.

Parameters
[in]projection- this projection
[in]tgt- target projection
[in,out]x- coordinate
[in,out]y- coordinate
[in,out]z- coordinate (MAY BE NULL in some cases), see PROJ.4
[in]projection- the projection
Returns
0 on failure, otherwise success

◆ Projection_transformx()

int Projection_transformx ( Projection_t * projection,
Projection_t * tgt,
double x,
double y,
double z,
double * ox,
double * oy,
double * oz )

This is an alternate version of Projection_transform.

This function will set the output valuesin ox, oy and oz respectively. x/y and ox/oy are always required. Some projections requires the z values as well but that is not enforced by this function and is up to the user to manage properly. If oz == NULL, then the transform will atempt to project without the z value.

Parameters
[in]projection- self
[in]tgt- the target projection
[in]x- coordinate
[in]y- coordinate
[in]z- coordinate
[out]ox- coordinate
[out]oy- coordinate
[out]oz- coordinate
Returns
1 on success, otherwise 0

Variable Documentation

◆ Projection_TYPE

RaveCoreObjectType Projection_TYPE
Initial value:
= {
"Projection",
sizeof(Projection_t),
Projection_constructor,
Projection_destructor,
Projection_copyconstructor
}
struct _Projection_t Projection_t
Defines a transformer.
Definition projection.h:35

Type definition to use when creating a rave object.