Changeset 16414


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

NEW: first verions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/wrappers/ShpRead/ShpRead.cpp

    r16413 r16414  
    3939
    4040        /*checks on arguments on the matlab side: */
    41         if(nlhs > NLHS){
    42                 ShpReadUsage(); _error_("ShpRead usage error");
    43         }
    44         if(nrhs != NRHS){
    45                 ShpReadUsage(); _error_("ShpRead usage error");
    46         }
     41        if(nlhs != NLHS){ShpReadUsage(); _error_("ShpRead usage error");}
     42        if(nrhs != NRHS){ShpReadUsage(); _error_("ShpRead usage error");}
    4743
    4844        /*Input datasets: */
    4945        FetchData(&filename,SHP_IN);
    50 
    51         /*Intermediaries*/
    52         int         nShapeType,nEntities;
    53         IssmPDouble adfMinBound[4], adfMaxBound[4];
    5446
    5547        /*Open shapefile*/
     
    5850
    5951        /*read header and print out file bounds*/
     52        int         nShapeType,nEntities;
     53        IssmPDouble adfMinBound[4], adfMaxBound[4];
    6054        SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
    6155        _printf_("Shapefile Type: "<<SHPTypeName(nShapeType)<<"   number of Shapes: "<< nEntities<<"\n\n");
    6256
    6357        /*Initialize output*/
    64         Contours* contours=new Contours();
     58        Contours* contours = new Contours();
    6559
    6660        /*Read all objects*/
    6761        for(int i=0; i<nEntities;i++ ){
     62
    6863                SHPObject* psShape = SHPReadObject(hSHP,i);
    6964                _printf_( "Shape #"<<i<<" ("<<SHPTypeName(psShape->nSHPType)<<") nVertices="<<psShape->nVertices<<", nParts="<<psShape->nParts<<"\n");
     
    7166                Contour<double> *contour = NULL;
    7267
    73                 if(psShape->nSHPType==SHPT_ARC){
    74                         contour=new Contour<double>(0,psShape->nVertices,psShape->padfX,psShape->padfY,false);
     68                switch(psShape->nSHPType){
     69                        case SHPT_ARC:
     70                                contour=new Contour<double>(0,psShape->nVertices,psShape->padfX,psShape->padfY,false);
     71                                break;
     72                        default:
     73                                _printf_("Shape type "<<SHPTypeName(psShape->nSHPType)<<"not supported yet, skipping...\n");
    7574                }
    7675
    77                 /*Add to contours*/
     76                /*Add to contours and clean up*/
    7877                if(contour) contours->AddObject(contour);
    79 
    80                 /*Destroy current shape*/
    81                 SHPDestroyObject( psShape );
     78                SHPDestroyObject(psShape);
    8279        }
    8380
    8481        /*Write output*/
    85         //ExpWrite(contours,filexp);
     82        WriteData(SHP_OUT,contours);
    8683
    8784        /*Clean-up*/
Note: See TracChangeset for help on using the changeset viewer.