Changeset 16413
- Timestamp:
- 10/15/13 14:17:49 (11 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 1 deleted
- 3 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r16388 r16413 708 708 ./modules/Kml2Expx/Kml2Expx.h\ 709 709 ./modules/Kml2Expx/Kml2Expx.cpp\ 710 ./modules/Shp2Expx/Shp2Expx.h\711 ./modules/Shp2Expx/Shp2Expx.cpp\712 710 ./modules/Shp2Kmlx/Shp2Kmlx.h\ 713 711 ./modules/Shp2Kmlx/Shp2Kmlx.cpp\ -
issm/trunk-jpl/src/c/modules/modules.h
r16388 r16413 86 86 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h" 87 87 #include "./Scotchx/Scotchx.h" 88 #include "./Shp2Expx/Shp2Expx.h"89 88 #include "./Shp2Kmlx/Shp2Kmlx.h" 90 89 #include "./SmbGradientsx/SmbGradientsx.h" -
issm/trunk-jpl/src/wrappers/ShpRead/ShpRead.cpp
r16407 r16413 1 /*\file Shp 2Exp.c1 /*\file ShpRead.c 2 2 *\brief: shp to exp file conversion mex module. 3 3 */ … … 9 9 #endif 10 10 11 #include "./Shp2Exp.h" 11 #include "./ShpRead.h" 12 #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in. 13 #include "shapefil.h" 14 #endif 12 15 13 void Shp 2ExpUsage(void){/*{{{*/14 _printf0_("Shp 2Exp - shp to exp file conversion module:\n");16 void ShpReadUsage(void){/*{{{*/ 17 _printf0_("ShpRead - Read shapefile\n"); 15 18 _printf0_("\n"); 16 _printf0_(" This module converts a file from shp to exp format.\n");19 _printf0_(" This module reads shapefiles and converts them to matlab/python structures\n"); 17 20 _printf0_("\n"); 18 21 _printf0_(" Usage:\n"); 19 _printf0_(" [ret]=Shp2Exp(filshp,filexp,sgn,'param name',param,...);\n"); 20 _printf0_("\n"); 21 _printf0_(" filshp file name of shp file to be read (char, extension optional)\n"); 22 _printf0_(" filexp file name of exp file to be written (char)\n"); 23 _printf0_("\n"); 24 _printf0_(" ret return code (non-zero for warning)\n"); 22 _printf0_(" ShpRead(filename);\n"); 23 _printf0_(" filexp file name of exp file to be written\n"); 25 24 _printf0_("\n"); 26 25 _printf0_(" Examples:\n"); 27 _printf0_(" [ret]=Shp2Exp('file.shp','file.exp');\n"); 28 _printf0_("\n"); 26 _printf0_(" ShpRead('file.shp');\n"); 29 27 }/*}}}*/ 30 WRAPPER(Shp2Exp){ 31 32 int i,verbose=1; 28 WRAPPER(ShpRead){ 33 29 34 30 /*input: */ 35 char *filshp=NULL,*filexp=NULL; 36 37 /* output: */ 38 int iret=0; 39 40 #ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in. 41 _error_("Shapelib not available! Cannot carry out shp file translation!"); 42 #endif 31 char *filename= NULL; 43 32 44 33 /*Boot module: */ 45 34 MODULEBOOT(); 46 35 36 #ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in. 37 _error_("Shapelib not available! Cannot carry out shp file translation!"); 38 #else 39 47 40 /*checks on arguments on the matlab side: */ 48 if (nlhs > NLHS){49 Shp 2ExpUsage(); _error_("Shp2Expusage error");41 if(nlhs > NLHS){ 42 ShpReadUsage(); _error_("ShpRead usage error"); 50 43 } 51 if (nrhs < NRHS){52 Shp 2ExpUsage(); _error_("Shp2Expusage error");44 if(nrhs != NRHS){ 45 ShpReadUsage(); _error_("ShpRead usage error"); 53 46 } 54 47 55 48 /*Input datasets: */ 56 FetchData(&filshp,SHP_IN); 57 FetchData(&filexp,EXP_IN); 49 FetchData(&filename,SHP_IN); 58 50 59 /* Run core computations: */ 60 iret=Shp2Expx(filshp,filexp); 51 /*Intermediaries*/ 52 int nShapeType,nEntities; 53 IssmPDouble adfMinBound[4], adfMaxBound[4]; 61 54 62 /*Write data: */ 63 WriteData(RET_OUT,iret); 55 /*Open shapefile*/ 56 SHPHandle hSHP = SHPOpen( filename, "rb" ); 57 if(!hSHP) _error_("Error opening shp/shx files."); 58 59 /*read header and print out file bounds*/ 60 SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound ); 61 _printf_("Shapefile Type: "<<SHPTypeName(nShapeType)<<" number of Shapes: "<< nEntities<<"\n\n"); 62 63 /*Initialize output*/ 64 Contours* contours=new Contours(); 65 66 /*Read all objects*/ 67 for(int i=0; i<nEntities;i++ ){ 68 SHPObject* psShape = SHPReadObject(hSHP,i); 69 _printf_( "Shape #"<<i<<" ("<<SHPTypeName(psShape->nSHPType)<<") nVertices="<<psShape->nVertices<<", nParts="<<psShape->nParts<<"\n"); 70 71 Contour<double> *contour = NULL; 72 73 if(psShape->nSHPType==SHPT_ARC){ 74 contour=new Contour<double>(0,psShape->nVertices,psShape->padfX,psShape->padfY,false); 75 } 76 77 /*Add to contours*/ 78 if(contour) contours->AddObject(contour); 79 80 /*Destroy current shape*/ 81 SHPDestroyObject( psShape ); 82 } 83 84 /*Write output*/ 85 //ExpWrite(contours,filexp); 64 86 65 87 /*Clean-up*/ 66 xDelete<char>(filexp);67 xDelete<char>(fil shp);88 delete contours; 89 xDelete<char>(filename); 68 90 91 #endif 69 92 /*end module: */ 70 93 MODULEEND(); -
issm/trunk-jpl/src/wrappers/ShpRead/ShpRead.h
r16407 r16413 1 /*!\file Shp 2Exp.h2 * \brief: prototype for shp to exp file conversionmex module.1 /*!\file ShpRead.h 2 * \brief: prototype for shp read mex module. 3 3 */ 4 4 5 #ifndef _SHP 2EXP_H6 #define _SHP 2EXP_H5 #ifndef _SHPREAD_H 6 #define _SHPREAD_H 7 7 8 8 #ifdef HAVE_CONFIG_H … … 23 23 24 24 #undef __FUNCT__ 25 #define __FUNCT__ "Shp 2Exp"25 #define __FUNCT__ "ShpRead" 26 26 27 27 #ifdef _HAVE_MATLAB_MODULES_ 28 28 /* serial input macros: */ 29 29 #define SHP_IN prhs[0] 30 #define EXP_IN prhs[1]31 30 /* serial output macros: */ 32 #define RET_OUT(mxArray**)&plhs[0]31 #define SHP_OUT (mxArray**)&plhs[0] 33 32 #endif 34 33 … … 36 35 /* serial input macros: */ 37 36 #define SHP_IN PyTuple_GetItem(args,0) 38 #define EXP_IN PyTuple_GetItem(args,1)39 37 /* serial output macros: */ 40 #define RET_OUT output,038 #define SHP_OUT output,0 41 39 #endif 42 40 43 41 /* serial arg counts: */ 44 42 #undef NRHS 45 #define NRHS 243 #define NRHS 1 46 44 #undef NLHS 47 45 #define NLHS 1 -
issm/trunk-jpl/src/wrappers/matlab/Makefile.am
r16128 r16413 88 88 Exp2Kml.la\ 89 89 Kml2Exp.la\ 90 Shp 2Exp.la\90 ShpRead.la\ 91 91 Shp2Kml.la 92 92 endif … … 269 269 Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB) $(BLASLAPACKLIB) 270 270 271 Shp 2Exp_la_SOURCES = ../Shp2Exp/Shp2Exp.cpp\272 ../Shp 2Exp/Shp2Exp.h273 Shp 2Exp_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB)271 ShpRead_la_SOURCES = ../ShpRead/ShpRead.cpp\ 272 ../ShpRead/ShpRead.h 273 ShpRead_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB) 274 274 275 275 Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
Note:
See TracChangeset
for help on using the changeset viewer.