Navigation Menu

Skip to content

Commit

Permalink
fix #1245
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9154 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 24, 2008
1 parent afbba96 commit 5331631
Showing 1 changed file with 47 additions and 16 deletions.
63 changes: 47 additions & 16 deletions src/core/qgsgeometry.cpp
Expand Up @@ -42,22 +42,6 @@ email : morb at ozemail dot com dot au
throw; \
}

#if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
#define GEOSGeom_clone(g) GEOSGeom_clone( (GEOSGeometry *) g )
#define GEOSGeom_getCoordSeq(g) GEOSGeom_getCoordSeq( (GEOSGeometry *) g )
#define GEOSGetExteriorRing(g) GEOSGetExteriorRing( (GEOSGeometry *)g )
#define GEOSGetNumInteriorRings(g) GEOSGetNumInteriorRings( (GEOSGeometry *)g )
#define GEOSGetInteriorRingN(g,i) GEOSGetInteriorRingN( (GEOSGeometry *)g, i )
#define GEOSDisjoint(g0,g1) GEOSDisjoint( (GEOSGeometry *)g0, (GEOSGeometry*)g1 )
#define GEOSIntersection(g0,g1) GEOSIntersection( (GEOSGeometry*) g0, (GEOSGeometry*)g1 )
#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s)
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a)

#define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n )
#define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x )
#define GEOSCoordSeq_getY(cs,i,y) GEOSCoordSeq_getY( (GEOSCoordSequence *)cs, i, y )
#endif

class GEOSException
{
public:
Expand Down Expand Up @@ -107,6 +91,53 @@ void printGEOSNotice( const char *fmt, ... )
#endif
}

#if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
#define GEOSGeom_getCoordSeq(g) GEOSGeom_getCoordSeq( (GEOSGeometry *) g )
#define GEOSGetExteriorRing(g) GEOSGetExteriorRing( (GEOSGeometry *)g )
#define GEOSGetNumInteriorRings(g) GEOSGetNumInteriorRings( (GEOSGeometry *)g )
#define GEOSGetInteriorRingN(g,i) GEOSGetInteriorRingN( (GEOSGeometry *)g, i )
#define GEOSDisjoint(g0,g1) GEOSDisjoint( (GEOSGeometry *)g0, (GEOSGeometry*)g1 )
#define GEOSIntersection(g0,g1) GEOSIntersection( (GEOSGeometry*) g0, (GEOSGeometry*)g1 )
#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s)
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a)

#define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n )
#define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x )
#define GEOSCoordSeq_getY(cs,i,y) GEOSCoordSeq_getY( (GEOSCoordSequence *)cs, i, y )

static GEOSGeometry *createGeosCollection( int typeId, QVector<GEOSGeometry*> geoms );

static GEOSGeometry *cloneGeosGeom( const GEOSGeometry *geom )
{
if ( GEOSGeomTypeId( geom ) == GEOS_MULTIPOLYGON )
{
QVector<GEOSGeometry *> geoms;

try
{

for ( int i = 0; i < GEOSGetNumGeometries( geom ); ++i )
geoms << GEOSGeom_clone(( GEOSGeometry * ) GEOSGetGeometryN(( GEOSGeometry * ) geom, i ) );

return createGeosCollection( GEOS_MULTIPOLYGON, geoms );
}
catch ( GEOSException &e )
{
Q_UNUSED( e );
for ( int i = 0; i < geoms.count(); i++ )
GEOSGeom_destroy( geoms[i] );

return 0;
}
}
else
{
return GEOSGeom_clone(( GEOSGeometry * ) geom );
}
}

#define GEOSGeom_clone(g) cloneGeosGeom(g)
#endif

int QgsGeometry::refcount = 0;

Expand Down

0 comments on commit 5331631

Please sign in to comment.