mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Bump minimum GEOS version to 3.3
This commit is contained in:
parent
40b70a3ddf
commit
616a80f48e
@ -87,9 +87,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]+)" "\\1" GEOS_VERSION_MAJOR "${GEOS_VERSION}")
|
||||||
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GEOS_VERSION_MINOR "${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 1) )
|
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.1.0 or higher.")
|
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 1) )
|
ENDIF (GEOS_VERSION_MAJOR LESS 3 OR (GEOS_VERSION_MAJOR EQUAL 3 AND GEOS_VERSION_MINOR LESS 3) )
|
||||||
|
|
||||||
# set INCLUDE_DIR to prefix+include
|
# set INCLUDE_DIR to prefix+include
|
||||||
EXEC_PROGRAM(${GEOS_CONFIG}
|
EXEC_PROGRAM(${GEOS_CONFIG}
|
||||||
|
@ -1063,9 +1063,6 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
|||||||
{
|
{
|
||||||
if ( geom.type() == QgsWkbTypes::LineGeometry )
|
if ( geom.type() == QgsWkbTypes::LineGeometry )
|
||||||
{
|
{
|
||||||
//geos 3.3 needed for line offsets
|
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
|
|
||||||
GEOSGeometry* offsetGeom = GEOSOffsetCurve_r( geosctxt, ( *inputGeomIt ).asGeos(), -offset, 8 /*quadSegments*/, 0 /*joinStyle*/, 5.0 /*mitreLimit*/ );
|
GEOSGeometry* offsetGeom = GEOSOffsetCurve_r( geosctxt, ( *inputGeomIt ).asGeos(), -offset, 8 /*quadSegments*/, 0 /*joinStyle*/, 5.0 /*mitreLimit*/ );
|
||||||
if ( !offsetGeom || !GEOSisValid_r( geosctxt, offsetGeom ) )
|
if ( !offsetGeom || !GEOSisValid_r( geosctxt, offsetGeom ) )
|
||||||
{
|
{
|
||||||
@ -1077,9 +1074,6 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
|||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
}
|
}
|
||||||
outputGeomList.push_back( offsetGeom );
|
outputGeomList.push_back( offsetGeom );
|
||||||
#else
|
|
||||||
outputGeomList.push_back( GEOSGeom_clone_r( geosctxt, ( *inputGeomIt )->asGeos() ) );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if ( geom.type() == QgsWkbTypes::PointGeometry )
|
else if ( geom.type() == QgsWkbTypes::PointGeometry )
|
||||||
{
|
{
|
||||||
|
@ -1823,10 +1823,7 @@ void QgisApp::createActionGroups()
|
|||||||
mMapToolGroup->addAction( mActionCircularStringRadius );
|
mMapToolGroup->addAction( mActionCircularStringRadius );
|
||||||
mMapToolGroup->addAction( mActionMoveFeature );
|
mMapToolGroup->addAction( mActionMoveFeature );
|
||||||
mMapToolGroup->addAction( mActionRotateFeature );
|
mMapToolGroup->addAction( mActionRotateFeature );
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
|
|
||||||
mMapToolGroup->addAction( mActionOffsetCurve );
|
mMapToolGroup->addAction( mActionOffsetCurve );
|
||||||
#endif
|
|
||||||
mMapToolGroup->addAction( mActionReshapeFeatures );
|
mMapToolGroup->addAction( mActionReshapeFeatures );
|
||||||
mMapToolGroup->addAction( mActionSplitFeatures );
|
mMapToolGroup->addAction( mActionSplitFeatures );
|
||||||
mMapToolGroup->addAction( mActionSplitParts );
|
mMapToolGroup->addAction( mActionSplitParts );
|
||||||
@ -2805,16 +2802,8 @@ void QgisApp::createCanvasTools()
|
|||||||
mMapTools.mMoveFeature->setAction( mActionMoveFeature );
|
mMapTools.mMoveFeature->setAction( mActionMoveFeature );
|
||||||
mMapTools.mRotateFeature = new QgsMapToolRotateFeature( mMapCanvas );
|
mMapTools.mRotateFeature = new QgsMapToolRotateFeature( mMapCanvas );
|
||||||
mMapTools.mRotateFeature->setAction( mActionRotateFeature );
|
mMapTools.mRotateFeature->setAction( mActionRotateFeature );
|
||||||
//need at least geos 3.3 for OffsetCurve tool
|
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
|
|
||||||
mMapTools.mOffsetCurve = new QgsMapToolOffsetCurve( mMapCanvas );
|
mMapTools.mOffsetCurve = new QgsMapToolOffsetCurve( mMapCanvas );
|
||||||
mMapTools.mOffsetCurve->setAction( mActionOffsetCurve );
|
mMapTools.mOffsetCurve->setAction( mActionOffsetCurve );
|
||||||
#else
|
|
||||||
mAdvancedDigitizeToolBar->removeAction( mActionOffsetCurve );
|
|
||||||
mEditMenu->removeAction( mActionOffsetCurve );
|
|
||||||
mMapTools.mOffsetCurve = 0;
|
|
||||||
#endif //GEOS_VERSION
|
|
||||||
mMapTools.mReshapeFeatures = new QgsMapToolReshape( mMapCanvas );
|
mMapTools.mReshapeFeatures = new QgsMapToolReshape( mMapCanvas );
|
||||||
mMapTools.mReshapeFeatures->setAction( mActionReshapeFeatures );
|
mMapTools.mReshapeFeatures->setAction( mActionReshapeFeatures );
|
||||||
mMapTools.mSplitFeatures = new QgsMapToolSplitFeatures( mMapCanvas );
|
mMapTools.mSplitFeatures = new QgsMapToolSplitFeatures( mMapCanvas );
|
||||||
|
@ -359,9 +359,6 @@ void QgsMapToolOffsetCurve::deleteRubberBandAndGeometry()
|
|||||||
|
|
||||||
void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset )
|
void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset )
|
||||||
{
|
{
|
||||||
// need at least geos 3.3 for OffsetCurve tool
|
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
|
|
||||||
if ( !mRubberBand || mOriginalGeometry.isEmpty() )
|
if ( !mRubberBand || mOriginalGeometry.isEmpty() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -402,9 +399,6 @@ void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset )
|
|||||||
mRubberBand->setToGeometry( mModifiedGeometry, sourceLayer );
|
mRubberBand->setToGeometry( mModifiedGeometry, sourceLayer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else //GEOS_VERSION>=3.3
|
|
||||||
Q_UNUSED( offset );
|
|
||||||
#endif //GEOS_VERSION>=3.3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsGeometry QgsMapToolOffsetCurve::linestringFromPolygon( const QgsGeometry& featureGeom, int vertex )
|
QgsGeometry QgsMapToolOffsetCurve::linestringFromPolygon( const QgsGeometry& featureGeom, int vertex )
|
||||||
|
@ -889,10 +889,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
|
|||||||
mValidateGeometries->clear();
|
mValidateGeometries->clear();
|
||||||
mValidateGeometries->addItem( tr( "Off" ) );
|
mValidateGeometries->addItem( tr( "Off" ) );
|
||||||
mValidateGeometries->addItem( tr( "QGIS" ) );
|
mValidateGeometries->addItem( tr( "QGIS" ) );
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
( (GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR>=3) || GEOS_VERSION_MAJOR>3)
|
|
||||||
mValidateGeometries->addItem( tr( "GEOS" ) );
|
mValidateGeometries->addItem( tr( "GEOS" ) );
|
||||||
#endif
|
|
||||||
|
|
||||||
QString markerStyle = mSettings->value( "/qgis/digitizing/marker_style", "Cross" ).toString();
|
QString markerStyle = mSettings->value( "/qgis/digitizing/marker_style", "Cross" ).toString();
|
||||||
if ( markerStyle == "SemiTransparentCircle" )
|
if ( markerStyle == "SemiTransparentCircle" )
|
||||||
|
@ -1296,9 +1296,6 @@ QgsAbstractGeometry *QgsGeos::buffer( double distance, int segments, int endCapS
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
|
|
||||||
|
|
||||||
GEOSGeomScopedPtr geos;
|
GEOSGeomScopedPtr geos;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1306,9 +1303,6 @@ QgsAbstractGeometry *QgsGeos::buffer( double distance, int segments, int endCapS
|
|||||||
}
|
}
|
||||||
CATCH_GEOS_WITH_ERRMSG( nullptr );
|
CATCH_GEOS_WITH_ERRMSG( nullptr );
|
||||||
return fromGeos( geos.get() );
|
return fromGeos( geos.get() );
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif //0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAbstractGeometry* QgsGeos::simplify( double tolerance, QString* errorMsg ) const
|
QgsAbstractGeometry* QgsGeos::simplify( double tolerance, QString* errorMsg ) const
|
||||||
|
@ -196,8 +196,6 @@ void QgsGeometryValidator::validatePolygon( int idx, const QgsPolygon &polygon )
|
|||||||
void QgsGeometryValidator::run()
|
void QgsGeometryValidator::run()
|
||||||
{
|
{
|
||||||
mErrorCount = 0;
|
mErrorCount = 0;
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
( (GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR>=3) || GEOS_VERSION_MAJOR>3)
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
if ( settings.value( "/qgis/digitizing/validate_geometries", 1 ).toInt() == 2 )
|
if ( settings.value( "/qgis/digitizing/validate_geometries", 1 ).toInt() == 2 )
|
||||||
{
|
{
|
||||||
@ -241,7 +239,6 @@ void QgsGeometryValidator::run()
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QgsDebugMsg( "validation thread started." );
|
QgsDebugMsg( "validation thread started." );
|
||||||
|
|
||||||
|
@ -671,73 +671,6 @@ void QgsSymbolLayerUtils::drawStippledBackground( QPainter* painter, QRect rect
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
|
||||||
|
|
||||||
#if !defined(GEOS_VERSION_MAJOR) || !defined(GEOS_VERSION_MINOR) || \
|
|
||||||
((GEOS_VERSION_MAJOR<3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR<3)))
|
|
||||||
// calculate line's angle and tangent
|
|
||||||
static bool lineInfo( QPointF p1, QPointF p2, double& angle, double& t )
|
|
||||||
{
|
|
||||||
double x1 = p1.x(), y1 = p1.y(), x2 = p2.x(), y2 = p2.y();
|
|
||||||
|
|
||||||
if ( x1 == x2 && y1 == y2 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// tangent
|
|
||||||
t = ( x1 == x2 ? DBL_MAX : ( y2 - y1 ) / ( x2 - x1 ) );
|
|
||||||
|
|
||||||
// angle
|
|
||||||
if ( t == DBL_MAX )
|
|
||||||
angle = ( y2 > y1 ? M_PI / 2 : M_PI * 3 / 2 ); // angle is 90 or 270
|
|
||||||
else if ( t == 0 )
|
|
||||||
angle = ( x2 > x1 ? 0 : M_PI ); // angle is 0 or 180
|
|
||||||
else if ( t >= 0 )
|
|
||||||
angle = ( y2 > y1 ? atan( t ) : M_PI + atan( t ) );
|
|
||||||
else // t < 0
|
|
||||||
angle = ( y2 > y1 ? M_PI + atan( t ) : atan( t ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// offset a point with an angle and distance
|
|
||||||
static QPointF offsetPoint( QPointF pt, double angle, double dist )
|
|
||||||
{
|
|
||||||
return QPointF( pt.x() + dist * cos( angle ), pt.y() + dist * sin( angle ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// calc intersection of two (infinite) lines defined by one point and tangent
|
|
||||||
static QPointF linesIntersection( QPointF p1, double t1, QPointF p2, double t2 )
|
|
||||||
{
|
|
||||||
// parallel lines? (or the difference between angles is less than appr. 10 degree)
|
|
||||||
if (( t1 == DBL_MAX && t2 == DBL_MAX ) || qAbs( atan( t1 ) - atan( t2 ) ) < 0.175 )
|
|
||||||
return QPointF();
|
|
||||||
|
|
||||||
double x, y;
|
|
||||||
if ( t1 == DBL_MAX || t2 == DBL_MAX )
|
|
||||||
{
|
|
||||||
// in case one line is with angle 90 resp. 270 degrees (tangent undefined)
|
|
||||||
// swap them so that line 2 is with undefined tangent
|
|
||||||
if ( t1 == DBL_MAX )
|
|
||||||
{
|
|
||||||
QPointF pSwp = p1;
|
|
||||||
p1 = p2;
|
|
||||||
p2 = pSwp;
|
|
||||||
double tSwp = t1;
|
|
||||||
t1 = t2;
|
|
||||||
t2 = tSwp;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = p2.x();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// usual case
|
|
||||||
x = (( p1.y() - p2.y() ) + t2 * p2.x() - t1 * p1.x() ) / ( t2 - t1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
y = p1.y() + t1 * ( x - p1.x() );
|
|
||||||
return QPointF( x, y );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static QPolygonF makeOffsetGeometry( const QgsPolyline& polyline )
|
static QPolygonF makeOffsetGeometry( const QgsPolyline& polyline )
|
||||||
{
|
{
|
||||||
int i, pointCount = polyline.count();
|
int i, pointCount = polyline.count();
|
||||||
@ -760,7 +693,6 @@ static QList<QPolygonF> makeOffsetGeometry( const QgsPolygon& polygon )
|
|||||||
resultGeom.append( makeOffsetGeometry( polygon[ ring ] ) );
|
resultGeom.append( makeOffsetGeometry( polygon[ ring ] ) );
|
||||||
return resultGeom;
|
return resultGeom;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QList<QPolygonF> offsetLine( QPolygonF polyline, double dist, QgsWkbTypes::GeometryType geometryType )
|
QList<QPolygonF> offsetLine( QPolygonF polyline, double dist, QgsWkbTypes::GeometryType geometryType )
|
||||||
{
|
{
|
||||||
@ -772,12 +704,6 @@ QList<QPolygonF> offsetLine( QPolygonF polyline, double dist, QgsWkbTypes::Geome
|
|||||||
return resultLine;
|
return resultLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPolygonF newLine;
|
|
||||||
|
|
||||||
// need at least geos 3.3 for OffsetCurve tool
|
|
||||||
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
|
|
||||||
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
|
|
||||||
|
|
||||||
unsigned int i, pointCount = polyline.count();
|
unsigned int i, pointCount = polyline.count();
|
||||||
|
|
||||||
QgsPolyline tempPolyline( pointCount );
|
QgsPolyline tempPolyline( pointCount );
|
||||||
@ -840,48 +766,6 @@ QList<QPolygonF> offsetLine( QPolygonF polyline, double dist, QgsWkbTypes::Geome
|
|||||||
// returns original polyline when 'GEOSOffsetCurve' fails!
|
// returns original polyline when 'GEOSOffsetCurve' fails!
|
||||||
resultLine.append( polyline );
|
resultLine.append( polyline );
|
||||||
return resultLine;
|
return resultLine;
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
double angle = 0.0, t_new, t_old = 0;
|
|
||||||
QPointF pt_old, pt_new;
|
|
||||||
QPointF p1 = polyline[0], p2;
|
|
||||||
bool first_point = true;
|
|
||||||
|
|
||||||
for ( int i = 1; i < polyline.count(); i++ )
|
|
||||||
{
|
|
||||||
p2 = polyline[i];
|
|
||||||
|
|
||||||
if ( !lineInfo( p1, p2, angle, t_new ) )
|
|
||||||
continue; // not a line...
|
|
||||||
|
|
||||||
pt_new = offsetPoint( p1, angle + M_PI / 2, dist );
|
|
||||||
|
|
||||||
if ( ! first_point )
|
|
||||||
{
|
|
||||||
// if it's not the first line segment
|
|
||||||
// calc intersection with last line (with offset)
|
|
||||||
QPointF pt_tmp = linesIntersection( pt_old, t_old, pt_new, t_new );
|
|
||||||
if ( !pt_tmp.isNull() )
|
|
||||||
pt_new = pt_tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
newLine.append( pt_new );
|
|
||||||
|
|
||||||
pt_old = pt_new;
|
|
||||||
t_old = t_new;
|
|
||||||
p1 = p2;
|
|
||||||
first_point = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// last line segment:
|
|
||||||
pt_new = offsetPoint( p2, angle + M_PI / 2, dist );
|
|
||||||
newLine.append( pt_new );
|
|
||||||
|
|
||||||
resultLine.append( newLine );
|
|
||||||
return resultLine;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QPolygonF> offsetLine( const QPolygonF& polyline, double dist )
|
QList<QPolygonF> offsetLine( const QPolygonF& polyline, double dist )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user