Skip to content

Commit a5e66c3

Browse files
committedAug 30, 2022
Bump minimum GEOS to version 3.9
1 parent ac13f28 commit a5e66c3

22 files changed

+19
-1412
lines changed
 

‎INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Required build dependencies:
101101

102102
* Qt >= 5.14.0
103103
* Proj >= 6.3.1
104-
* GEOS >= 3.4
104+
* GEOS >= 3.9
105105
* Sqlite3 >= 3.0.0
106106
* SpatiaLite >= 4.2.0
107107
* libspatialindex

‎cmake/FindGEOS.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ ELSE(WIN32)
9090
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GEOS_VERSION_MAJOR "${GEOS_VERSION}")
9191
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GEOS_VERSION_MINOR "${GEOS_VERSION}")
9292

93-
IF (GEOS_VERSION_MAJOR LESS 3 OR (GEOS_VERSION_MAJOR EQUAL 3 AND GEOS_VERSION_MINOR LESS 3) )
94-
MESSAGE (FATAL_ERROR "GEOS version is too old (${GEOS_VERSION}). Use 3.3.0 or higher.")
95-
ENDIF (GEOS_VERSION_MAJOR LESS 3 OR (GEOS_VERSION_MAJOR EQUAL 3 AND GEOS_VERSION_MINOR LESS 3) )
93+
IF (GEOS_VERSION_MAJOR LESS 3 OR (GEOS_VERSION_MAJOR EQUAL 3 AND GEOS_VERSION_MINOR LESS 9) )
94+
MESSAGE (FATAL_ERROR "GEOS version is too old (${GEOS_VERSION}). Use 3.9.0 or higher.")
95+
ENDIF (GEOS_VERSION_MAJOR LESS 3 OR (GEOS_VERSION_MAJOR EQUAL 3 AND GEOS_VERSION_MINOR LESS 9) )
9696

9797
# set INCLUDE_DIR to prefix+include
9898
EXEC_PROGRAM(${GEOS_CONFIG}

‎src/analysis/vector/qgsgeometrysnapper.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,10 @@ void QgsSnapIndex::addPoint( const CoordIdx *idx, bool isEndPoint )
128128
const QgsPoint p = idx->point();
129129

130130
GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler();
131-
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
132131
geos::unique_ptr point( GEOSGeom_createPointFromXY_r( geosctxt, p.x(), p.y() ) );
133-
#else
134-
GEOSCoordSequence *seq = GEOSCoordSeq_create_r( geosctxt, 1, 2 );
135-
GEOSCoordSeq_setX_r( geosctxt, seq, 0, p.x() );
136-
GEOSCoordSeq_setY_r( geosctxt, seq, 0, p.y() );
137-
geos::unique_ptr point( GEOSGeom_createPoint_r( geosctxt, seq ) );
138-
#endif
139132

140133
PointSnapItem *item = new PointSnapItem( idx, isEndPoint );
141134
GEOSSTRtree_insert_r( geosctxt, mSTRTree, point.get(), item );
142-
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR<9
143-
mSTRTreeItems.emplace_back( std::move( point ) );
144-
#endif
145135
mSnapItems << item;
146136
}
147137

@@ -153,22 +143,12 @@ void QgsSnapIndex::addSegment( const CoordIdx *idxFrom, const CoordIdx *idxTo )
153143
GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler();
154144

155145
GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, 2, 2 );
156-
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
157146
GEOSCoordSeq_setXY_r( geosctxt, coord, 0, pointFrom.x(), pointFrom.y() );
158147
GEOSCoordSeq_setXY_r( geosctxt, coord, 1, pointTo.x(), pointTo.y() );
159-
#else
160-
GEOSCoordSeq_setX_r( geosctxt, coord, 0, pointFrom.x() );
161-
GEOSCoordSeq_setY_r( geosctxt, coord, 0, pointFrom.y() );
162-
GEOSCoordSeq_setX_r( geosctxt, coord, 1, pointTo.x() );
163-
GEOSCoordSeq_setY_r( geosctxt, coord, 1, pointTo.y() );
164-
#endif
165148
geos::unique_ptr segment( GEOSGeom_createLineString_r( geosctxt, coord ) );
166149

167150
SegmentSnapItem *item = new SegmentSnapItem( idxFrom, idxTo );
168151
GEOSSTRtree_insert_r( geosctxt, mSTRTree, segment.get(), item );
169-
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR<9
170-
mSTRTreeItems.push_back( std::move( segment ) );
171-
#endif
172152
mSnapItems << item;
173153
}
174154

@@ -224,15 +204,8 @@ QgsPoint QgsSnapIndex::getClosestSnapToPoint( const QgsPoint &startPoint, const
224204
double minDistance = std::numeric_limits<double>::max();
225205

226206
GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, 2, 2 );
227-
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
228207
GEOSCoordSeq_setXY_r( geosctxt, coord, 0, startPoint.x(), startPoint.y() );
229208
GEOSCoordSeq_setXY_r( geosctxt, coord, 1, endPoint.x(), endPoint.y() );
230-
#else
231-
GEOSCoordSeq_setX_r( geosctxt, coord, 0, startPoint.x() );
232-
GEOSCoordSeq_setY_r( geosctxt, coord, 0, startPoint.y() );
233-
GEOSCoordSeq_setX_r( geosctxt, coord, 1, endPoint.x() );
234-
GEOSCoordSeq_setY_r( geosctxt, coord, 1, endPoint.y() );
235-
#endif
236209
geos::unique_ptr searchDiagonal( GEOSGeom_createLineString_r( geosctxt, coord ) );
237210

238211
QList<SnapItem *> items;
@@ -264,15 +237,8 @@ QgsSnapIndex::SnapItem *QgsSnapIndex::getSnapItem( const QgsPoint &pos, const do
264237
GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler();
265238

266239
GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, 2, 2 );
267-
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
268240
GEOSCoordSeq_setXY_r( geosctxt, coord, 0, pos.x() - tolerance, pos.y() - tolerance );
269241
GEOSCoordSeq_setXY_r( geosctxt, coord, 1, pos.x() + tolerance, pos.y() + tolerance );
270-
#else
271-
GEOSCoordSeq_setX_r( geosctxt, coord, 0, pos.x() - tolerance );
272-
GEOSCoordSeq_setY_r( geosctxt, coord, 0, pos.y() - tolerance );
273-
GEOSCoordSeq_setX_r( geosctxt, coord, 1, pos.x() + tolerance );
274-
GEOSCoordSeq_setY_r( geosctxt, coord, 1, pos.y() + tolerance );
275-
#endif
276242

277243
geos::unique_ptr searchDiagonal( GEOSGeom_createLineString_r( geosctxt, coord ) );
278244

‎src/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ set(QGIS_CORE_SRCS
796796
geometry/qgsgeometrycollection.cpp
797797
geometry/qgsgeometryeditutils.cpp
798798
geometry/qgsgeometryfactory.cpp
799-
geometry/qgsgeometrymakevalid.cpp
800799
geometry/qgsgeometryutils.cpp
801800
geometry/qgsgeos.cpp
802801
geometry/qgsinternalgeometryengine.cpp

‎src/core/expression/qgsexpressionfunction.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6826,13 +6826,6 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
68266826
const QVariant minInscribedCircleRadiusValue = node->eval( parent, context );
68276827
ENSURE_NO_EVAL_ERROR
68286828
minInscribedCircleRadius = QgsExpressionUtils::getDoubleValue( minInscribedCircleRadiusValue, parent );
6829-
#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<9
6830-
if ( minInscribedCircleRadiusValue != -1 )
6831-
{
6832-
parent->setEvalErrorString( QObject::tr( "'min_inscribed_circle_radius' is only available when QGIS is built with GEOS >= 3.9." ) );
6833-
return QVariant();
6834-
}
6835-
#endif
68366829
node = QgsExpressionUtils::getNode( values.at( 7 ), parent );
68376830
// Return measures is only effective when an expression is set
68386831
returnDetails = !testOnly && node->eval( parent, context ).toBool(); //#spellok
@@ -7022,7 +7015,6 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
70227015
}
70237016
}
70247017

7025-
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=9 )
70267018
// Check min inscribed circle radius for intersection (if set)
70277019
if ( minInscribedCircleRadius != -1 || requireMeasures )
70287020
{
@@ -7035,7 +7027,6 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
70357027
testResult = radiusValue >= minInscribedCircleRadius;
70367028
radiusValues.append( radiusValues );
70377029
}
7038-
#endif
70397030
} // end for parts
70407031

70417032
// Get the max values

‎src/core/geometry/qgsgeometry.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ email : morb at ozemail dot com dot au
2727

2828
#include <geos_c.h>
2929

30-
#if ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR<8 )
31-
#include "qgsgeometrymakevalid.h"
32-
#endif
33-
3430
#include "qgsgeometryutils.h"
3531
#include "qgsinternalgeometryengine.h"
3632
#include "qgsgeos.h"
@@ -2863,12 +2859,8 @@ QgsGeometry QgsGeometry::makeValid() const
28632859
return QgsGeometry();
28642860

28652861
mLastError.clear();
2866-
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=8 )
28672862
QgsGeos geos( d->geometry.get() );
28682863
std::unique_ptr< QgsAbstractGeometry > g( geos.makeValid( &mLastError ) );
2869-
#else
2870-
std::unique_ptr< QgsAbstractGeometry > g( _qgis_lwgeom_make_valid( d->geometry.get(), mLastError ) );
2871-
#endif
28722864

28732865
QgsGeometry result = QgsGeometry( std::move( g ) );
28742866
result.mLastError = mLastError;

0 commit comments

Comments
 (0)
Please sign in to comment.