source: issm/trunk-jpl/src/wrappers/Exp2Kml/Exp2Kml.cpp@ 20877

Last change on this file since 20877 was 20877, checked in by Mathieu Morlighem, 9 years ago

BUG: added _python in WRAPPER

File size: 3.3 KB
RevLine 
[8714]1/*\file Exp2Kml.c
2 *\brief: exp to kml file conversion mex module.
3 */
4#include "./Exp2Kml.h"
5
[13236]6void Exp2KmlUsage(void){/*{{{*/
[15105]7 _printf0_("Exp2Kml - exp to kml file conversion module:\n");
8 _printf0_("\n");
9 _printf0_(" This module converts a file from exp to kml format.\n");
10 _printf0_("\n");
11 _printf0_(" Usage:\n");
12 _printf0_(" [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);\n");
13 _printf0_("\n");
14 _printf0_(" filexp file name of exp file to be read (char)\n");
15 _printf0_(" filkml file name of kml file to be written (char)\n");
16 _printf0_(" sgn sign for hemisphere (double, +1 (north) or -1 (south))\n");
17 _printf0_("\n");
18 _printf0_(" central_meridian central meridian (double, optional, but must specify with sp)\n");
19 _printf0_(" standard_parallel standard parallel (double, optional, but must specify with cm)\n");
20 _printf0_(" holes flag for treatment of multiple profiles (char, optional, 'yes' for holes))\n");
21 _printf0_("\n");
22 _printf0_(" ret return code (non-zero for warning)\n");
23 _printf0_("\n");
24 _printf0_(" Examples:\n");
25 _printf0_(" [ret]=Exp2Kml('file.exp','file.kml', 1);\n");
26 _printf0_(" [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n");
27 _printf0_(" [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n");
28 _printf0_("\n");
[13236]29}/*}}}*/
[20877]30WRAPPER(Exp2Kml_python){
[8714]31
32 int i,verbose=1;
33
34 /*input: */
35 char *filexp=NULL,*filkml=NULL;
36 int sgn;
37
38 Options* options=NULL;
39 char *choles=NULL;
40 bool holes=false;
41 double cm=0.,sp=0.;
42
43 /* output: */
44 int iret=0;
45
46 /*Boot module: */
47 MODULEBOOT();
48
49 /*checks on arguments on the matlab side: */
50 if (nlhs > NLHS) {
[13036]51 Exp2KmlUsage(); _error_("Exp2Kml usage error");
[8714]52 }
53 if (nrhs < NRHS) {
[13036]54 Exp2KmlUsage(); _error_("Exp2Kml usage error");
[8714]55 }
56
57 /*Input datasets: */
[11933]58 FetchData(&filexp,EXP_IN);
59 FetchData(&filkml,KML_IN);
60 FetchData(&sgn,SGN_IN);
[12049]61 FetchData(&options,NRHS,nrhs,prhs);
[8714]62
[13216]63 options->Get(&choles,"holes",(char*)"no");
[12049]64 if (!strncmp(choles,"y",1) || !strncmp(choles,"on",2)) holes=true;
65
[8714]66 /* defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified */
67 if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
68 options->Get(&cm,"central_meridian");
[15100]69 if (verbose) _printf_(" cm=" << cm << "\n");
[8714]70 options->Get(&sp,"standard_parallel");
[15100]71 if (verbose) _printf_(" sp=" << sp << "\n");
[8714]72 }
73
74 /*some checks*/
[13036]75 if (sgn !=+1 && sgn !=-1) _error_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
76 if (fabs(cm) > 180.) _error_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
77 if (sp < 0. || sp > 90.) _error_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
[8714]78
79 /* Run core computations: */
80 if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
[12049]81 iret=Exp2Kmlx(filexp,filkml,sgn,cm,sp,holes);
[8714]82 else
[12049]83 iret=Exp2Kmlx(filexp,filkml,sgn,holes);
[8714]84
85 /*Write data: */
[11933]86 WriteData(RET_OUT,iret);
[8714]87
88 /*Clean-up*/
[13250]89 xDelete<char>(choles);
90 xDelete<char>(filkml);
91 xDelete<char>(filexp);
[8714]92 delete options;
93
94 /*end module: */
95 MODULEEND();
96}
Note: See TracBrowser for help on using the repository browser.