Skip to content

Commit

Permalink
Bump minimum GEOS to version 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 30, 2022
1 parent ac13f28 commit a5e66c3
Show file tree
Hide file tree
Showing 22 changed files with 19 additions and 1,412 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Required build dependencies:

* Qt >= 5.14.0
* Proj >= 6.3.1
* GEOS >= 3.4
* GEOS >= 3.9
* Sqlite3 >= 3.0.0
* SpatiaLite >= 4.2.0
* libspatialindex
Expand Down
6 changes: 3 additions & 3 deletions cmake/FindGEOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ ELSE(WIN32)
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GEOS_VERSION_MAJOR "${GEOS_VERSION}")
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GEOS_VERSION_MINOR "${GEOS_VERSION}")

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

# set INCLUDE_DIR to prefix+include
EXEC_PROGRAM(${GEOS_CONFIG}
Expand Down
34 changes: 0 additions & 34 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,10 @@ void QgsSnapIndex::addPoint( const CoordIdx *idx, bool isEndPoint )
const QgsPoint p = idx->point();

GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler();
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
geos::unique_ptr point( GEOSGeom_createPointFromXY_r( geosctxt, p.x(), p.y() ) );
#else
GEOSCoordSequence *seq = GEOSCoordSeq_create_r( geosctxt, 1, 2 );
GEOSCoordSeq_setX_r( geosctxt, seq, 0, p.x() );
GEOSCoordSeq_setY_r( geosctxt, seq, 0, p.y() );
geos::unique_ptr point( GEOSGeom_createPoint_r( geosctxt, seq ) );
#endif

PointSnapItem *item = new PointSnapItem( idx, isEndPoint );
GEOSSTRtree_insert_r( geosctxt, mSTRTree, point.get(), item );
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR<9
mSTRTreeItems.emplace_back( std::move( point ) );
#endif
mSnapItems << item;
}

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

GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, 2, 2 );
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
GEOSCoordSeq_setXY_r( geosctxt, coord, 0, pointFrom.x(), pointFrom.y() );
GEOSCoordSeq_setXY_r( geosctxt, coord, 1, pointTo.x(), pointTo.y() );
#else
GEOSCoordSeq_setX_r( geosctxt, coord, 0, pointFrom.x() );
GEOSCoordSeq_setY_r( geosctxt, coord, 0, pointFrom.y() );
GEOSCoordSeq_setX_r( geosctxt, coord, 1, pointTo.x() );
GEOSCoordSeq_setY_r( geosctxt, coord, 1, pointTo.y() );
#endif
geos::unique_ptr segment( GEOSGeom_createLineString_r( geosctxt, coord ) );

SegmentSnapItem *item = new SegmentSnapItem( idxFrom, idxTo );
GEOSSTRtree_insert_r( geosctxt, mSTRTree, segment.get(), item );
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR<9
mSTRTreeItems.push_back( std::move( segment ) );
#endif
mSnapItems << item;
}

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

GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, 2, 2 );
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
GEOSCoordSeq_setXY_r( geosctxt, coord, 0, startPoint.x(), startPoint.y() );
GEOSCoordSeq_setXY_r( geosctxt, coord, 1, endPoint.x(), endPoint.y() );
#else
GEOSCoordSeq_setX_r( geosctxt, coord, 0, startPoint.x() );
GEOSCoordSeq_setY_r( geosctxt, coord, 0, startPoint.y() );
GEOSCoordSeq_setX_r( geosctxt, coord, 1, endPoint.x() );
GEOSCoordSeq_setY_r( geosctxt, coord, 1, endPoint.y() );
#endif
geos::unique_ptr searchDiagonal( GEOSGeom_createLineString_r( geosctxt, coord ) );

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

GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, 2, 2 );
#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=8
GEOSCoordSeq_setXY_r( geosctxt, coord, 0, pos.x() - tolerance, pos.y() - tolerance );
GEOSCoordSeq_setXY_r( geosctxt, coord, 1, pos.x() + tolerance, pos.y() + tolerance );
#else
GEOSCoordSeq_setX_r( geosctxt, coord, 0, pos.x() - tolerance );
GEOSCoordSeq_setY_r( geosctxt, coord, 0, pos.y() - tolerance );
GEOSCoordSeq_setX_r( geosctxt, coord, 1, pos.x() + tolerance );
GEOSCoordSeq_setY_r( geosctxt, coord, 1, pos.y() + tolerance );
#endif

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

Expand Down
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ set(QGIS_CORE_SRCS
geometry/qgsgeometrycollection.cpp
geometry/qgsgeometryeditutils.cpp
geometry/qgsgeometryfactory.cpp
geometry/qgsgeometrymakevalid.cpp
geometry/qgsgeometryutils.cpp
geometry/qgsgeos.cpp
geometry/qgsinternalgeometryengine.cpp
Expand Down
9 changes: 0 additions & 9 deletions src/core/expression/qgsexpressionfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6826,13 +6826,6 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
const QVariant minInscribedCircleRadiusValue = node->eval( parent, context );
ENSURE_NO_EVAL_ERROR
minInscribedCircleRadius = QgsExpressionUtils::getDoubleValue( minInscribedCircleRadiusValue, parent );
#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<9
if ( minInscribedCircleRadiusValue != -1 )
{
parent->setEvalErrorString( QObject::tr( "'min_inscribed_circle_radius' is only available when QGIS is built with GEOS >= 3.9." ) );
return QVariant();
}
#endif
node = QgsExpressionUtils::getNode( values.at( 7 ), parent );
// Return measures is only effective when an expression is set
returnDetails = !testOnly && node->eval( parent, context ).toBool(); //#spellok
Expand Down Expand Up @@ -7022,7 +7015,6 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
}
}

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

// Get the max values
Expand Down
8 changes: 0 additions & 8 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ email : morb at ozemail dot com dot au

#include <geos_c.h>

#if ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR<8 )
#include "qgsgeometrymakevalid.h"
#endif

#include "qgsgeometryutils.h"
#include "qgsinternalgeometryengine.h"
#include "qgsgeos.h"
Expand Down Expand Up @@ -2863,12 +2859,8 @@ QgsGeometry QgsGeometry::makeValid() const
return QgsGeometry();

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

QgsGeometry result = QgsGeometry( std::move( g ) );
result.mLastError = mLastError;
Expand Down
Loading

0 comments on commit a5e66c3

Please sign in to comment.