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

Go to the source code of this file.

Macros

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
 

Functions

void CoordTransformUsage (void)
 
 WRAPPER (CoordTransform_python)
 

Macro Definition Documentation

◆ ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

Definition at line 6 of file CoordTransform.cpp.

Function Documentation

◆ CoordTransformUsage()

void CoordTransformUsage ( void  )

Definition at line 9 of file CoordTransform.cpp.

9  {/*{{{*/
10  _printf_(" type help CoordTransform\n");
11 }/*}}}*/

◆ WRAPPER()

WRAPPER ( CoordTransform_python  )

Definition at line 12 of file CoordTransform.cpp.

12  {
13 
14  /*intermediary: */
15  double *xin = NULL;
16  double *yin = NULL;
17  char *projin = NULL;
18  char *projout = NULL;
19  int M,N;
20  int test1,test2;
21 
22  printf("%i %i %i %i\n",NLHS,nlhs,NRHS,nrhs);
23 
24  /*Boot module: */
25  MODULEBOOT();
26 
27  /*checks on arguments: */
28  CHECKARGUMENTS(NLHS,NRHS,&CoordTransformUsage);
29 
30  /*Fetch data needed for meshing: */
31  FetchData(&xin,&M,&N,XIN);
32  FetchData(&yin,&test1,&test2,YIN);
33  if(!M*N) _error_("no coordinate provided");
34  if(test1!=M) _error_("x and y do not have the same size");
35  if(test2!=N) _error_("x and y do not have the same size");
36  FetchData(&projin,PROJIN);
37  FetchData(&projout,PROJOUT);
38 
39  /*Initialize output*/
40  double* xout = xNew<double>(M*N);
41  double* yout = xNew<double>(M*N);
42 
43  /*Initialize projections*/
44  projPJ pj_src = pj_init_plus(projin);
45  projPJ pj_dst = pj_init_plus(projout);
46  if(!pj_src) _error_("Failed to initialize PROJ with source projection\n");
47  if(!pj_dst) _error_("Failed to initialize PROJ with destination projection\n");
48 
49  /*Transform coordinates*/
50  int p = pj_transform(pj_src,pj_dst,M*N,1,xout,yout,NULL);
51  if(p!=0){
52  _error_("PROJ failed with error code: "<<p);
53  }
54 
55  /*write outputs: */
56  WriteData(XOUT,xout,M,N);
57  WriteData(YOUT,yout,M,N);
58 
59  /*Clean-up and return*/
60  mxFree(projin);
61  mxFree(projout);
62  xDelete<double>(xin);
63  xDelete<double>(yin);
64  xDelete<double>(xout);
65  xDelete<double>(yout);
66  xDelete<char>(projin);
67  xDelete<char>(projout);
68 
69  /*end module: */
70  MODULEEND();
71 }
WriteData
void WriteData(IssmPDouble **pmatrix, int *pnel, int *matrix, int M, int N)
Definition: WriteJavascriptData.cpp:16
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
NRHS
#define NRHS
Definition: BamgConvertMesh.h:52
FetchData
void FetchData(char **pstring, char *stringin)
Definition: FetchJavascriptData.cpp:16
CoordTransformUsage
void CoordTransformUsage(void)
Definition: CoordTransform.cpp:9
NLHS
#define NLHS
Definition: BamgConvertMesh.h:50
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49