@@ -42,22 +42,6 @@ email : morb at ozemail dot com dot au
42
42
throw ; \
43
43
}
44
44
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
-
61
45
class GEOSException
62
46
{
63
47
public:
@@ -107,6 +91,53 @@ void printGEOSNotice( const char *fmt, ... )
107
91
#endif
108
92
}
109
93
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
110
141
111
142
int QgsGeometry::refcount = 0 ;
112
143
0 commit comments