|
@@ -607,7 +607,7 @@ double QgsGeos::area( QString *errorMsg ) const |
|
|
if ( GEOSArea_r( geosinit()->ctxt, mGeos.get(), &area ) != 1 ) |
|
|
return -1.0; |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( -1.0 ); |
|
|
CATCH_GEOS_WITH_ERRMSG( -1.0 ) |
|
|
return area; |
|
|
} |
|
|
|
|
@@ -1367,7 +1367,6 @@ geos::unique_ptr QgsGeos::asGeos( const QgsAbstractGeometry *geom, double precis |
|
|
case QgsWkbTypes::UnknownGeometry: |
|
|
case QgsWkbTypes::NullGeometry: |
|
|
return nullptr; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
@@ -1390,20 +1389,16 @@ geos::unique_ptr QgsGeos::asGeos( const QgsAbstractGeometry *geom, double precis |
|
|
{ |
|
|
case QgsWkbTypes::PointGeometry: |
|
|
return createGeosPoint( static_cast<const QgsPoint *>( geom ), coordDims, precision ); |
|
|
break; |
|
|
|
|
|
case QgsWkbTypes::LineGeometry: |
|
|
return createGeosLinestring( static_cast<const QgsLineString *>( geom ), precision ); |
|
|
break; |
|
|
|
|
|
case QgsWkbTypes::PolygonGeometry: |
|
|
return createGeosPolygon( static_cast<const QgsPolygon *>( geom ), precision ); |
|
|
break; |
|
|
|
|
|
case QgsWkbTypes::UnknownGeometry: |
|
|
case QgsWkbTypes::NullGeometry: |
|
|
return nullptr; |
|
|
break; |
|
|
} |
|
|
} |
|
|
return nullptr; |
|
@@ -1430,9 +1425,11 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeos::overlay( const QgsAbstractGeometry |
|
|
case OverlayIntersection: |
|
|
opGeom.reset( GEOSIntersection_r( geosinit()->ctxt, mGeos.get(), geosGeom.get() ) ); |
|
|
break; |
|
|
|
|
|
case OverlayDifference: |
|
|
opGeom.reset( GEOSDifference_r( geosinit()->ctxt, mGeos.get(), geosGeom.get() ) ); |
|
|
break; |
|
|
|
|
|
case OverlayUnion: |
|
|
{ |
|
|
geos::unique_ptr unionGeometry( GEOSUnion_r( geosinit()->ctxt, mGeos.get(), geosGeom.get() ) ); |
|
@@ -1449,11 +1446,10 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeos::overlay( const QgsAbstractGeometry |
|
|
opGeom = std::move( unionGeometry ); |
|
|
} |
|
|
break; |
|
|
|
|
|
case OverlaySymDifference: |
|
|
opGeom.reset( GEOSSymDifference_r( geosinit()->ctxt, mGeos.get(), geosGeom.get() ) ); |
|
|
break; |
|
|
default: //unknown op |
|
|
return nullptr; |
|
|
} |
|
|
return fromGeos( opGeom.get() ); |
|
|
} |
|
@@ -1509,8 +1505,6 @@ bool QgsGeos::relation( const QgsAbstractGeometry *geom, Relation r, QString *er |
|
|
case RelationOverlaps: |
|
|
result = ( GEOSPreparedOverlaps_r( geosinit()->ctxt, mGeosPrepared.get(), geosGeom.get() ) == 1 ); |
|
|
break; |
|
|
default: |
|
|
return false; |
|
|
} |
|
|
return result; |
|
|
} |
|
@@ -1538,8 +1532,6 @@ bool QgsGeos::relation( const QgsAbstractGeometry *geom, Relation r, QString *er |
|
|
case RelationOverlaps: |
|
|
result = ( GEOSOverlaps_r( geosinit()->ctxt, mGeos.get(), geosGeom.get() ) == 1 ); |
|
|
break; |
|
|
default: |
|
|
return false; |
|
|
} |
|
|
} |
|
|
catch ( GEOSException &e ) |
|
@@ -1567,7 +1559,7 @@ QgsAbstractGeometry *QgsGeos::buffer( double distance, int segments, QString *er |
|
|
{ |
|
|
geos.reset( GEOSBuffer_r( geosinit()->ctxt, mGeos.get(), distance, segments ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
return fromGeos( geos.get() ).release(); |
|
|
} |
|
|
|
|
@@ -1583,7 +1575,7 @@ QgsAbstractGeometry *QgsGeos::buffer( double distance, int segments, int endCapS |
|
|
{ |
|
|
geos.reset( GEOSBufferWithStyle_r( geosinit()->ctxt, mGeos.get(), distance, segments, endCapStyle, joinStyle, miterLimit ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
return fromGeos( geos.get() ).release(); |
|
|
} |
|
|
|
|
@@ -1598,7 +1590,7 @@ QgsAbstractGeometry *QgsGeos::simplify( double tolerance, QString *errorMsg ) co |
|
|
{ |
|
|
geos.reset( GEOSTopologyPreserveSimplify_r( geosinit()->ctxt, mGeos.get(), tolerance ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
return fromGeos( geos.get() ).release(); |
|
|
} |
|
|
|
|
@@ -1613,7 +1605,7 @@ QgsAbstractGeometry *QgsGeos::interpolate( double distance, QString *errorMsg ) |
|
|
{ |
|
|
geos.reset( GEOSInterpolate_r( geosinit()->ctxt, mGeos.get(), distance ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
return fromGeos( geos.get() ).release(); |
|
|
} |
|
|
|
|
@@ -1638,7 +1630,7 @@ QgsPoint *QgsGeos::centroid( QString *errorMsg ) const |
|
|
GEOSGeomGetX_r( geosinit()->ctxt, geos.get(), &x ); |
|
|
GEOSGeomGetY_r( geosinit()->ctxt, geos.get(), &y ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
|
|
|
return new QgsPoint( x, y ); |
|
|
} |
|
@@ -1654,7 +1646,7 @@ QgsAbstractGeometry *QgsGeos::envelope( QString *errorMsg ) const |
|
|
{ |
|
|
geos.reset( GEOSEnvelope_r( geosinit()->ctxt, mGeos.get() ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
return fromGeos( geos.get() ).release(); |
|
|
} |
|
|
|
|
@@ -1681,7 +1673,7 @@ QgsPoint *QgsGeos::pointOnSurface( QString *errorMsg ) const |
|
|
GEOSGeomGetX_r( geosinit()->ctxt, geos.get(), &x ); |
|
|
GEOSGeomGetY_r( geosinit()->ctxt, geos.get(), &y ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
|
|
|
return new QgsPoint( x, y ); |
|
|
} |
|
@@ -1699,7 +1691,7 @@ QgsAbstractGeometry *QgsGeos::convexHull( QString *errorMsg ) const |
|
|
std::unique_ptr< QgsAbstractGeometry > cHullGeom = fromGeos( cHull.get() ); |
|
|
return cHullGeom.release(); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
} |
|
|
|
|
|
bool QgsGeos::isValid( QString *errorMsg, const bool allowSelfTouchingHoles, QgsGeometry *errorLoc ) const |
|
@@ -1757,7 +1749,7 @@ bool QgsGeos::isValid( QString *errorMsg, const bool allowSelfTouchingHoles, Qgs |
|
|
} |
|
|
return !invalid; |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( false ); |
|
|
CATCH_GEOS_WITH_ERRMSG( false ) |
|
|
} |
|
|
|
|
|
bool QgsGeos::isEqual( const QgsAbstractGeometry *geom, QString *errorMsg ) const |
|
@@ -1777,7 +1769,7 @@ bool QgsGeos::isEqual( const QgsAbstractGeometry *geom, QString *errorMsg ) cons |
|
|
bool equal = GEOSEquals_r( geosinit()->ctxt, mGeos.get(), geosGeom.get() ); |
|
|
return equal; |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( false ); |
|
|
CATCH_GEOS_WITH_ERRMSG( false ) |
|
|
} |
|
|
|
|
|
bool QgsGeos::isEmpty( QString *errorMsg ) const |
|
@@ -1791,7 +1783,7 @@ bool QgsGeos::isEmpty( QString *errorMsg ) const |
|
|
{ |
|
|
return GEOSisEmpty_r( geosinit()->ctxt, mGeos.get() ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( false ); |
|
|
CATCH_GEOS_WITH_ERRMSG( false ) |
|
|
} |
|
|
|
|
|
bool QgsGeos::isSimple( QString *errorMsg ) const |
|
@@ -1805,7 +1797,7 @@ bool QgsGeos::isSimple( QString *errorMsg ) const |
|
|
{ |
|
|
return GEOSisSimple_r( geosinit()->ctxt, mGeos.get() ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( false ); |
|
|
CATCH_GEOS_WITH_ERRMSG( false ) |
|
|
} |
|
|
|
|
|
GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, double precision, bool forceClose ) |
|
@@ -2093,7 +2085,7 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeos::singleSidedBuffer( double distance |
|
|
} |
|
|
geos.reset( GEOSBufferWithParams_r( geosinit()->ctxt, mGeos.get(), bp.get(), distance ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ); |
|
|
CATCH_GEOS_WITH_ERRMSG( nullptr ) |
|
|
return fromGeos( geos.get() ); |
|
|
} |
|
|
|
|
@@ -2228,7 +2220,7 @@ QgsGeometry QgsGeos::mergeLines( QString *errorMsg ) const |
|
|
{ |
|
|
geos.reset( GEOSLineMerge_r( geosinit()->ctxt, mGeos.get() ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( QgsGeometry() ); |
|
|
CATCH_GEOS_WITH_ERRMSG( QgsGeometry() ) |
|
|
return QgsGeometry( fromGeos( geos.get() ) ); |
|
|
} |
|
|
|
|
@@ -2420,7 +2412,7 @@ QgsGeometry QgsGeos::voronoiDiagram( const QgsAbstractGeometry *extent, double t |
|
|
|
|
|
return QgsGeometry( fromGeos( geos.get() ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( QgsGeometry() ); |
|
|
CATCH_GEOS_WITH_ERRMSG( QgsGeometry() ) |
|
|
} |
|
|
|
|
|
QgsGeometry QgsGeos::delaunayTriangulation( double tolerance, bool edgesOnly, QString *errorMsg ) const |
|
@@ -2442,7 +2434,7 @@ QgsGeometry QgsGeos::delaunayTriangulation( double tolerance, bool edgesOnly, QS |
|
|
|
|
|
return QgsGeometry( fromGeos( geos.get() ) ); |
|
|
} |
|
|
CATCH_GEOS_WITH_ERRMSG( QgsGeometry() ); |
|
|
CATCH_GEOS_WITH_ERRMSG( QgsGeometry() ) |
|
|
} |
|
|
|
|
|
|
|
@@ -2811,6 +2803,7 @@ geos::unique_ptr QgsGeos::reshapePolygon( const GEOSGeometry *polygon, const GEO |
|
|
GEOSGeometry *outerRingPoly = GEOSGeom_createPolygon_r( geosinit()->ctxt, GEOSGeom_clone_r( geosinit()->ctxt, newOuterRing ), nullptr, 0 ); |
|
|
if ( outerRingPoly ) |
|
|
{ |
|
|
ringList.reserve( nRings ); |
|
|
GEOSGeometry *currentRing = nullptr; |
|
|
for ( int i = 0; i < nRings; ++i ) |
|
|
{ |
|
|