Changeset 16413


Ignore:
Timestamp:
10/15/13 14:17:49 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: removing Shp2Exp and replace with ShpRead to be continued

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  
    708708                             ./modules/Kml2Expx/Kml2Expx.h\
    709709                             ./modules/Kml2Expx/Kml2Expx.cpp\
    710                              ./modules/Shp2Expx/Shp2Expx.h\
    711                              ./modules/Shp2Expx/Shp2Expx.cpp\
    712710                             ./modules/Shp2Kmlx/Shp2Kmlx.h\
    713711                             ./modules/Shp2Kmlx/Shp2Kmlx.cpp\
  • issm/trunk-jpl/src/c/modules/modules.h

    r16388 r16413  
    8686#include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
    8787#include "./Scotchx/Scotchx.h"
    88 #include "./Shp2Expx/Shp2Expx.h"
    8988#include "./Shp2Kmlx/Shp2Kmlx.h"
    9089#include "./SmbGradientsx/SmbGradientsx.h"
  • issm/trunk-jpl/src/wrappers/ShpRead/ShpRead.cpp

    r16407 r16413  
    1 /*\file Shp2Exp.c
     1/*\file ShpRead.c
    22 *\brief: shp to exp file conversion mex module.
    33 */
     
    99#endif
    1010
    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
    1215
    13 void Shp2ExpUsage(void){/*{{{*/
    14         _printf0_("Shp2Exp - shp to exp file conversion module:\n");
     16void ShpReadUsage(void){/*{{{*/
     17        _printf0_("ShpRead - Read shapefile\n");
    1518        _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");
    1720        _printf0_("\n");
    1821        _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");
    2524        _printf0_("\n");
    2625        _printf0_("   Examples:\n");
    27         _printf0_("      [ret]=Shp2Exp('file.shp','file.exp');\n");
    28         _printf0_("\n");
     26        _printf0_("      ShpRead('file.shp');\n");
    2927}/*}}}*/
    30 WRAPPER(Shp2Exp){
    31 
    32         int i,verbose=1;
     28WRAPPER(ShpRead){
    3329
    3430        /*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;
    4332
    4433        /*Boot module: */
    4534        MODULEBOOT();
    4635
     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
    4740        /*checks on arguments on the matlab side: */
    48         if (nlhs > NLHS) {
    49                 Shp2ExpUsage(); _error_("Shp2Exp usage error");
     41        if(nlhs > NLHS){
     42                ShpReadUsage(); _error_("ShpRead usage error");
    5043        }
    51         if (nrhs < NRHS) {
    52                 Shp2ExpUsage(); _error_("Shp2Exp usage error");
     44        if(nrhs != NRHS){
     45                ShpReadUsage(); _error_("ShpRead usage error");
    5346        }
    5447
    5548        /*Input datasets: */
    56         FetchData(&filshp,SHP_IN);
    57         FetchData(&filexp,EXP_IN);
     49        FetchData(&filename,SHP_IN);
    5850
    59         /* Run core computations: */
    60         iret=Shp2Expx(filshp,filexp);
     51        /*Intermediaries*/
     52        int         nShapeType,nEntities;
     53        IssmPDouble adfMinBound[4], adfMaxBound[4];
    6154
    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);
    6486
    6587        /*Clean-up*/
    66         xDelete<char>(filexp);
    67         xDelete<char>(filshp);
     88        delete contours;
     89        xDelete<char>(filename);
    6890
     91        #endif
    6992        /*end module: */
    7093        MODULEEND();
  • issm/trunk-jpl/src/wrappers/ShpRead/ShpRead.h

    r16407 r16413  
    1 /*!\file Shp2Exp.h
    2  * \brief: prototype for shp to exp file conversion mex module.
     1/*!\file ShpRead.h
     2 * \brief: prototype for shp read mex module.
    33 */
    44
    5 #ifndef _SHP2EXP_H
    6 #define _SHP2EXP_H
     5#ifndef _SHPREAD_H
     6#define _SHPREAD_H
    77
    88#ifdef HAVE_CONFIG_H
     
    2323
    2424#undef __FUNCT__
    25 #define __FUNCT__  "Shp2Exp"
     25#define __FUNCT__  "ShpRead"
    2626
    2727#ifdef _HAVE_MATLAB_MODULES_
    2828/* serial input macros: */
    2929#define SHP_IN  prhs[0]
    30 #define EXP_IN  prhs[1]
    3130/* serial output macros: */
    32 #define RET_OUT (mxArray**)&plhs[0]
     31#define SHP_OUT (mxArray**)&plhs[0]
    3332#endif
    3433
     
    3635/* serial input macros: */
    3736#define SHP_IN PyTuple_GetItem(args,0)
    38 #define EXP_IN PyTuple_GetItem(args,1)
    3937/* serial output macros: */
    40 #define RET_OUT output,0
     38#define SHP_OUT output,0
    4139#endif
    4240
    4341/* serial arg counts: */
    4442#undef NRHS
    45 #define NRHS  2
     43#define NRHS  1
    4644#undef NLHS
    4745#define NLHS  1
  • issm/trunk-jpl/src/wrappers/matlab/Makefile.am

    r16128 r16413  
    8888                                   Exp2Kml.la\
    8989                                   Kml2Exp.la\
    90                                    Shp2Exp.la\
     90                                   ShpRead.la\
    9191                                   Shp2Kml.la
    9292endif
     
    269269Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB) $(BLASLAPACKLIB)
    270270
    271 Shp2Exp_la_SOURCES = ../Shp2Exp/Shp2Exp.cpp\
    272                                                         ../Shp2Exp/Shp2Exp.h
    273 Shp2Exp_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB)
     271ShpRead_la_SOURCES = ../ShpRead/ShpRead.cpp\
     272                                                        ../ShpRead/ShpRead.h
     273ShpRead_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB)
    274274
    275275Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
Note: See TracChangeset for help on using the changeset viewer.