Changeset 10239
- Timestamp:
- 10/19/11 14:10:26 (13 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk/src/c/Makefile.am ¶
r10229 r10239 534 534 ./modules/Ll2xyx/Ll2xyx.h\ 535 535 ./modules/Ll2xyx/Ll2xyx.cpp\ 536 ./modules/Exp2Kmlx/Exp2Kmlx.h\ 536 537 ./modules/Exp2Kmlx/Exp2Kmlx.cpp\ 537 ./modules/ Exp2Kmlx/Exp2Kmlx.cpp\538 ./modules/Kml2Expx/Kml2Expx.h\ 538 539 ./modules/Kml2Expx/Kml2Expx.cpp\ 539 ./modules/Kml2Expx/Kml2Expx.cpp\ 540 ./modules/Shp2Kmlx/Shp2Kmlx.h\ 541 ./modules/Shp2Kmlx/Shp2Kmlx.cpp\ 540 542 ./modules/InputDuplicatex/InputDuplicatex.h\ 541 543 ./modules/InputDuplicatex/InputDuplicatex.cpp\ -
TabularUnified issm/trunk/src/c/modules/modules.h ¶
r10205 r10239 59 59 #include "./Exp2Kmlx/Exp2Kmlx.h" 60 60 #include "./Kml2Expx/Kml2Expx.h" 61 #include "./Shp2Kmlx/Shp2Kmlx.h" 61 62 #include "./MassFluxx/MassFluxx.h" 62 63 #include "./MaxAbsVxx/MaxAbsVxx.h" -
TabularUnified issm/trunk/src/mex/Shp2Kml/Shp2Kml.cpp ¶
r10229 r10239 1 1 /*\file Shp2Kml.c 2 *\brief: build degrees of freedom for every node.2 *\brief: shp to kml file conversion mex module. 3 3 */ 4 5 #ifdef HAVE_CONFIG_H 6 #include "config.h" 7 #else 8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 9 #endif 4 10 5 11 #include "./Shp2Kml.h" 6 12 7 8 13 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){ 9 14 10 /*input datasets: */ 11 Nodes* nodes=NULL; 12 Parameters* parameters=NULL; 13 Constraints* constraints=NULL; 14 int analysis_type; 15 int i,verbose=1; 16 17 /*input: */ 18 char *filshp=NULL,*filkml=NULL; 19 int sgn; 20 21 Options* options=NULL; 22 char *choles=NULL; 23 bool holes=false; 24 double cm=0.,sp=0.; 25 26 /* output: */ 27 int iret=0; 28 29 #ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in. 30 _error_(" Shapelib not available! Cannot carry out shp file translation!"); 31 #endif 15 32 16 33 /*Boot module: */ … … 18 35 19 36 /*checks on arguments on the matlab side: */ 20 CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&Shp2KmlUsage); 37 if (nlhs > NLHS) { 38 Shp2KmlUsage(); 39 _error_("Shp2Kml usage error"); 40 } 41 if (nrhs < NRHS) { 42 Shp2KmlUsage(); 43 _error_("Shp2Kml usage error"); 44 } 21 45 22 46 /*Input datasets: */ 23 FetchMatlabData((DataSet**)&nodes,NODESIN);24 FetchMatlabData( (DataSet**)&constraints,CONSTRAINTS);25 FetchMatlabData(¶meters,PARAMETERS);26 FetchMatlabData(& analysis_type,ANALYSISTYPE);27 28 /*!Generate internal degree of freedom numbers: */29 SpcNodesx(nodes,constraints,parameters,analysis_type);47 if (verbose) printf("Fetching inputs:\n"); 48 FetchMatlabData(&filshp,SHP_IN); 49 if (verbose) printf(" filshp=\"%s\"\n",filshp); 50 FetchMatlabData(&filkml,KML_IN); 51 if (verbose) printf(" filkml=\"%s\"\n",filkml); 52 FetchMatlabData(&sgn,SGN_IN); 53 if (verbose) printf(" sgn=%d\n",sgn); 30 54 31 /*write output datasets: */ 32 WriteMatlabData(NODES,nodes); 55 if (verbose) printf("Parsing options:\n"); 56 options=new Options(NRHS,nrhs,prhs); 57 if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho(); 58 options->Get(&choles,"holes","no"); 59 if (!strncmp(choles,"y",1) || !strncmp(choles,"on",2)) 60 holes=true; 61 /* defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified */ 62 if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) { 63 options->Get(&cm,"central_meridian"); 64 if (verbose) printf(" cm=%g\n",cm); 65 options->Get(&sp,"standard_parallel"); 66 if (verbose) printf(" sp=%g\n",sp); 67 } 33 68 34 /*Free ressources: */ 35 delete nodes; 36 delete constraints; 37 delete parameters; 69 /*some checks*/ 70 if (verbose) printf("Checking inputs:\n"); 71 72 if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn); 73 if (fabs(cm) > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm); 74 if (sp < 0. || sp > 90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp); 75 76 /* Run core computations: */ 77 if (verbose) printf("Calling core:\n"); 78 if (options->GetOption("central_meridian") && options->GetOption("standard_parallel")) 79 iret=Shp2Kmlx(filshp,filkml, 80 sgn,cm,sp, 81 holes); 82 else 83 iret=Shp2Kmlx(filshp,filkml, 84 sgn, 85 holes); 86 if (verbose) printf(" iret=%d\n",iret); 87 88 /*Write data: */ 89 WriteMatlabData(RET_OUT,iret); 90 91 /*Clean-up*/ 92 xfree((void**)&choles); 93 delete options; 94 xfree((void**)&filkml); 95 xfree((void**)&filshp); 38 96 39 97 /*end module: */ … … 43 101 void Shp2KmlUsage(void) 44 102 { 103 _printf_(true,"Shp2Kml - shp to kml file conversion module:\n"); 45 104 _printf_(true,"\n"); 46 _printf_(true," usage: [m.node]=%s(m.nodes,m.constraints,m.parameters);\n",__FUNCT__); 105 _printf_(true," This module converts a file from shp to kml format.\n"); 106 _printf_(true,"\n"); 107 _printf_(true," Usage:\n"); 108 _printf_(true," [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);\n"); 109 _printf_(true,"\n"); 110 _printf_(true," filshp file name of shp file to be read (char)\n"); 111 _printf_(true," filkml file name of kml file to be written (char)\n"); 112 _printf_(true," sgn sign for hemisphere (double, +1 (north) or -1 (south))\n"); 113 _printf_(true,"\n"); 114 _printf_(true," central_meridian central meridian (double, optional, but must specify with sp)\n"); 115 _printf_(true," standard_parallel standard parallel (double, optional, but must specify with cm)\n"); 116 _printf_(true," holes flag for treatment of multiple profiles (char, optional, 'yes' for holes))\n"); 117 _printf_(true,"\n"); 118 _printf_(true," ret return code (non-zero for warning)\n"); 119 _printf_(true,"\n"); 120 _printf_(true," Examples:\n"); 121 _printf_(true," [ret]=Shp2Kml('file.shp','file.kml', 1);\n"); 122 _printf_(true," [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n"); 123 _printf_(true," [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n"); 47 124 _printf_(true,"\n"); 48 125 } 126 -
TabularUnified issm/trunk/src/mex/Shp2Kml/Shp2Kml.h ¶
r10229 r10239 1 2 /* 3 Shp2Kml.h 4 */ 5 1 /*!\file Shp2Kml.h 2 * \brief: prototype for shp to kml file conversion mex module. 3 */ 6 4 7 5 #ifndef _SHP2KML_H … … 18 16 #define __FUNCT__ "Shp2Kml" 19 17 18 20 19 /* serial input macros: */ 21 #define NODESIN (mxArray*)prhs[0] 22 #define CONSTRAINTS (mxArray*)prhs[1] 23 #define PARAMETERS (mxArray*)prhs[2] 24 #define ANALYSISTYPE (mxArray*)prhs[3] 20 #define SHP_IN prhs[0] 21 #define KML_IN prhs[1] 22 #define SGN_IN prhs[2] 25 23 26 24 /* serial output macros: */ 27 #define NODES(mxArray**)&plhs[0]25 #define RET_OUT (mxArray**)&plhs[0] 28 26 29 27 /* serial arg counts: */ 28 #undef NRHS 29 #define NRHS 3 30 30 #undef NLHS 31 31 #define NLHS 1 32 #undef NRHS33 #define NRHS 434 32 33 #endif 35 34 36 #endif /* _SHP2KML_H */37
Note:
See TracChangeset
for help on using the changeset viewer.