Ice Sheet System Model  4.18
Code documentation
Macros | Functions
CoordinateSystemTransformx.cpp File Reference
#include "./CoordinateSystemTransformx.h"
#include "../../shared/shared.h"
#include "../../toolkits/toolkits.h"
#include <proj_api.h>

Go to the source code of this file.

Macros

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
 

Functions

void CoordinateSystemTransformx (double **px_dest, double **py_dest, double *x_src, double *y_src, int size, const char *str_src, const char *str_dst)
 

Macro Definition Documentation

◆ ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

Definition at line 9 of file CoordinateSystemTransformx.cpp.

Function Documentation

◆ CoordinateSystemTransformx()

void CoordinateSystemTransformx ( double **  px_dest,
double **  py_dest,
double *  x_src,
double *  y_src,
int  size,
const char *  str_src,
const char *  str_dst 
)

Definition at line 12 of file CoordinateSystemTransformx.cpp.

12  {
13 
14 #if !defined(_HAVE_PROJ_)
15  _error_("proj not installed");
16 #else
17 
18  /*Allocate output and initialize values as src*/
19  _assert_(size>0);
20  double* x_dest = xNew<double>(size);
21  double* y_dest = xNew<double>(size);
22  for(int i=0;i<size;i++){
23  x_dest[i] = x_src[i];
24  y_dest[i] = y_src[i];
25  }
26 
27  /*Create proj.4 projection objects for src and dst*/
28  projPJ pj_src = pj_init_plus(str_src);
29  projPJ pj_dst = pj_init_plus(str_dst);
30  if(!pj_src) _error_("Failed to initialize PROJ with source projection \"" <<str_src<<"\"\n");
31  if(!pj_dst) _error_("Failed to initialize PROJ with destination projection\""<<str_dst<<"\"\n");
32 
33  /*Perform transformation*/
34  int p = pj_transform(pj_src,pj_dst,size,1,x_dest,y_dest,NULL);
35  if(p!=0) _error_("Reprojection failed, PROJ error code: "<<p<<"\n");
36 
37  /*Output : */
38  *px_dest=x_dest;
39  *py_dest=y_dest;
40 #endif
41 }
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49