Changeset 13317

Show
Ignore:
Timestamp:
12/10/07 23:49:39 (5 months ago)
Author:
warmerdam
Message:

use geos based organizeGeometry() method with geos (#1217)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/shape/shape2ogr.cpp

    r12722 r13317  
    307307    return ( poRing ); 
    308308} 
    309      
     309 
     310 
    310311/************************************************************************/ 
    311312/*                          SHPReadOGRObject()                          */ 
     
    459460            poOGRPoly->addRingDirectly( poRing ); 
    460461        } 
    461         else 
     462        else if( OGRGeometryFactory::haveGEOS() ) 
     463        { 
     464            OGRPolygon** tabPolygons = new OGRPolygon*[psShape->nParts]; 
     465            for( iRing = 0; iRing < psShape->nParts; iRing++ ) 
     466            { 
     467                tabPolygons[iRing] = new OGRPolygon(); 
     468                tabPolygons[iRing]->addRingDirectly(CreateLinearRing ( psShape, iRing )); 
     469            } 
     470 
     471            int isValidGeometry; 
     472            poOGR = OGRGeometryFactory::organizePolygons(  
     473                (OGRGeometry**)tabPolygons, psShape->nParts, &isValidGeometry ); 
     474 
     475            if (!isValidGeometry) 
     476            { 
     477                CPLError(CE_Warning, CPLE_AppDefined,  
     478                        "Geometry of polygon of fid %d cannot be translated to Simple Geometry. " 
     479                        "All polygons will be contained in a multipolygon.\n", 
     480                        iShape); 
     481            } 
     482 
     483            delete[] tabPolygons; 
     484        } 
     485        else  
    462486        { 
    463487            /* Multipart polygon. */ 
     
    638662            CPLFree( outer ); 
    639663            CPLFree( outside ); 
    640  
    641664        } /* End of multipart polygon processing. */ 
    642665