Ice Sheet System Model  4.18
Code documentation
CoordinateSystemTransformx.cpp
Go to the documentation of this file.
1 
5 /*Header files*/
7 #include "../../shared/shared.h"
8 #include "../../toolkits/toolkits.h"
9 #define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
10 #include <proj_api.h>
11 
12 void CoordinateSystemTransformx(double** px_dest,double** py_dest,double* x_src,double* y_src,int size,const char* str_src,const char* str_dst){
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
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: CoordinateSystemTransformx.cpp:12
CoordinateSystemTransformx.h
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49