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

Last change on this file since 15099 was 15099, checked in by Eric.Larour, 12 years ago

CHG: greatly simplified the shared/io/Print routines. Replaced
_printf_ by _pprintString_ , then replaced all _printLine_ by _printString_
and _pprintLine_ by _pprintString_
We will then replace the _printString_ by _printf_ and _pprintString_ by _printf0_

File size: 3.5 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){/*{{{*/
[15099]7 _pprintString_("Exp2Kml - exp to kml file conversion module:" << "\n");
8 _pprintString_("" << "\n");
9 _pprintString_(" This module converts a file from exp to kml format." << "\n");
10 _pprintString_("" << "\n");
11 _pprintString_(" Usage:" << "\n");
12 _pprintString_(" [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);" << "\n");
13 _pprintString_("" << "\n");
14 _pprintString_(" filexp file name of exp file to be read (char)" << "\n");
15 _pprintString_(" filkml file name of kml file to be written (char)" << "\n");
16 _pprintString_(" sgn sign for hemisphere (double, +1 (north) or -1 (south))" << "\n");
17 _pprintString_("" << "\n");
18 _pprintString_(" central_meridian central meridian (double, optional, but must specify with sp)" << "\n");
19 _pprintString_(" standard_parallel standard parallel (double, optional, but must specify with cm)" << "\n");
20 _pprintString_(" holes flag for treatment of multiple profiles (char, optional, 'yes' for holes))" << "\n");
21 _pprintString_("" << "\n");
22 _pprintString_(" ret return code (non-zero for warning)" << "\n");
23 _pprintString_("" << "\n");
24 _pprintString_(" Examples:" << "\n");
25 _pprintString_(" [ret]=Exp2Kml('file.exp','file.kml', 1);" << "\n");
26 _pprintString_(" [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');" << "\n");
27 _pprintString_(" [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');" << "\n");
28 _pprintString_("" << "\n");
[13236]29}/*}}}*/
30WRAPPER(Exp2Kml){
[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");
[15099]69 if (verbose) _printString_(" cm=" << cm << "\n");
[8714]70 options->Get(&sp,"standard_parallel");
[15099]71 if (verbose) _printString_(" 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.