Skip to content

Commit bd1f9b5

Browse files
strknyalldawson
authored andcommittedMay 7, 2018
Switch test to reentrant GEOS API
1 parent 28d7c8c commit bd1f9b5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎tests/src/core/testqgsgeometryimport.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ class TestQgsGeometryImport: public QObject
5656

5757
private:
5858
bool compareLineStrings( const QgsPolylineXY &polyline, QVariantList &line );
59+
60+
GEOSContextHandle_t geos = nullptr;
5961
};
6062

6163
void TestQgsGeometryImport::initTestCase()
6264
{
63-
initGEOS( 0, 0 );
65+
geos = initGEOS_r( 0, 0 );
6466
}
6567

6668
void TestQgsGeometryImport::pointWkt_data()
@@ -128,10 +130,10 @@ void TestQgsGeometryImport::pointGeos()
128130
QFETCH( double, x );
129131
QFETCH( double, y );
130132

131-
GEOSCoordSequence *coord = GEOSCoordSeq_create( 1, 2 );
132-
GEOSCoordSeq_setX( coord, 0, x );
133-
GEOSCoordSeq_setY( coord, 0, y );
134-
GEOSGeometry *geosPt = GEOSGeom_createPoint( coord );
133+
GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geos, 1, 2 );
134+
GEOSCoordSeq_setX_r( geos, coord, 0, x );
135+
GEOSCoordSeq_setY_r( geos, coord, 0, y );
136+
GEOSGeometry *geosPt = GEOSGeom_createPoint_r( geos, coord );
135137

136138
QgsGeometry geom = QgsGeos::geometryFromGeos( geosPt );
137139
QVERIFY( geom.wkbType() == QgsWkbTypes::Point );
@@ -210,14 +212,14 @@ void TestQgsGeometryImport::linestringGeos()
210212
QFETCH( QVariantList, line );
211213

212214
//create geos coord sequence first
213-
GEOSCoordSequence *coord = GEOSCoordSeq_create( line.count(), 2 );
215+
GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geos, line.count(), 2 );
214216
for ( int i = 0; i < line.count(); i++ )
215217
{
216218
QPointF pt = line.at( i ).toPointF();
217-
GEOSCoordSeq_setX( coord, i, pt.x() );
218-
GEOSCoordSeq_setY( coord, i, pt.y() );
219+
GEOSCoordSeq_setX_r( geos, coord, i, pt.x() );
220+
GEOSCoordSeq_setY_r( geos, coord, i, pt.y() );
219221
}
220-
GEOSGeometry *geosLine = GEOSGeom_createLineString( coord );
222+
GEOSGeometry *geosLine = GEOSGeom_createLineString_r( geos, coord );
221223
QgsGeometry geom = QgsGeos::geometryFromGeos( geosLine );
222224
QVERIFY( geom.wkbType() == QgsWkbTypes::LineString );
223225

0 commit comments

Comments
 (0)
Please sign in to comment.