Skip to content

Commit 07cd098

Browse files
author
jef
committed
fix #1245
git-svn-id: http://svn.osgeo.org/qgis/trunk@9154 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1f1532a commit 07cd098

File tree

1 file changed

+47
-16
lines changed

1 file changed

+47
-16
lines changed

src/core/qgsgeometry.cpp

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,6 @@ email : morb at ozemail dot com dot au
4242
throw; \
4343
}
4444

45-
#if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
46-
#define GEOSGeom_clone(g) GEOSGeom_clone( (GEOSGeometry *) g )
47-
#define GEOSGeom_getCoordSeq(g) GEOSGeom_getCoordSeq( (GEOSGeometry *) g )
48-
#define GEOSGetExteriorRing(g) GEOSGetExteriorRing( (GEOSGeometry *)g )
49-
#define GEOSGetNumInteriorRings(g) GEOSGetNumInteriorRings( (GEOSGeometry *)g )
50-
#define GEOSGetInteriorRingN(g,i) GEOSGetInteriorRingN( (GEOSGeometry *)g, i )
51-
#define GEOSDisjoint(g0,g1) GEOSDisjoint( (GEOSGeometry *)g0, (GEOSGeometry*)g1 )
52-
#define GEOSIntersection(g0,g1) GEOSIntersection( (GEOSGeometry*) g0, (GEOSGeometry*)g1 )
53-
#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s)
54-
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a)
55-
56-
#define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n )
57-
#define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x )
58-
#define GEOSCoordSeq_getY(cs,i,y) GEOSCoordSeq_getY( (GEOSCoordSequence *)cs, i, y )
59-
#endif
60-
6145
class GEOSException
6246
{
6347
public:
@@ -107,6 +91,53 @@ void printGEOSNotice( const char *fmt, ... )
10791
#endif
10892
}
10993

94+
#if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
95+
#define GEOSGeom_getCoordSeq(g) GEOSGeom_getCoordSeq( (GEOSGeometry *) g )
96+
#define GEOSGetExteriorRing(g) GEOSGetExteriorRing( (GEOSGeometry *)g )
97+
#define GEOSGetNumInteriorRings(g) GEOSGetNumInteriorRings( (GEOSGeometry *)g )
98+
#define GEOSGetInteriorRingN(g,i) GEOSGetInteriorRingN( (GEOSGeometry *)g, i )
99+
#define GEOSDisjoint(g0,g1) GEOSDisjoint( (GEOSGeometry *)g0, (GEOSGeometry*)g1 )
100+
#define GEOSIntersection(g0,g1) GEOSIntersection( (GEOSGeometry*) g0, (GEOSGeometry*)g1 )
101+
#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s)
102+
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a)
103+
104+
#define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n )
105+
#define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x )
106+
#define GEOSCoordSeq_getY(cs,i,y) GEOSCoordSeq_getY( (GEOSCoordSequence *)cs, i, y )
107+
108+
static GEOSGeometry *createGeosCollection( int typeId, QVector<GEOSGeometry*> geoms );
109+
110+
static GEOSGeometry *cloneGeosGeom( const GEOSGeometry *geom )
111+
{
112+
if ( GEOSGeomTypeId( geom ) == GEOS_MULTIPOLYGON )
113+
{
114+
QVector<GEOSGeometry *> geoms;
115+
116+
try
117+
{
118+
119+
for ( int i = 0; i < GEOSGetNumGeometries( geom ); ++i )
120+
geoms << GEOSGeom_clone(( GEOSGeometry * ) GEOSGetGeometryN(( GEOSGeometry * ) geom, i ) );
121+
122+
return createGeosCollection( GEOS_MULTIPOLYGON, geoms );
123+
}
124+
catch ( GEOSException &e )
125+
{
126+
Q_UNUSED( e );
127+
for ( int i = 0; i < geoms.count(); i++ )
128+
GEOSGeom_destroy( geoms[i] );
129+
130+
return 0;
131+
}
132+
}
133+
else
134+
{
135+
return GEOSGeom_clone(( GEOSGeometry * ) geom );
136+
}
137+
}
138+
139+
#define GEOSGeom_clone(g) cloneGeosGeom(g)
140+
#endif
110141

111142
int QgsGeometry::refcount = 0;
112143

0 commit comments

Comments
 (0)