@@ -111,6 +111,16 @@ void geos::GeosDeleter::operator()( const GEOSPreparedGeometry *geom )
111
111
GEOSPreparedGeom_destroy_r ( geosinit.ctxt , geom );
112
112
}
113
113
114
+ void geos::GeosDeleter::operator ()( GEOSBufferParams *params )
115
+ {
116
+ GEOSBufferParams_destroy_r ( geosinit.ctxt , params );
117
+ }
118
+
119
+ void geos::GeosDeleter::operator ()( GEOSCoordSequence *sequence )
120
+ {
121
+ GEOSCoordSeq_destroy_r ( geosinit.ctxt , sequence );
122
+ }
123
+
114
124
115
125
// /@endcond
116
126
@@ -1851,18 +1861,17 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeos::singleSidedBuffer( double distance
1851
1861
geos::unique_ptr geos;
1852
1862
try
1853
1863
{
1854
- GEOSBufferParams *bp = GEOSBufferParams_create_r ( geosinit.ctxt );
1855
- GEOSBufferParams_setSingleSided_r ( geosinit.ctxt , bp, 1 );
1856
- GEOSBufferParams_setQuadrantSegments_r ( geosinit.ctxt , bp, segments );
1857
- GEOSBufferParams_setJoinStyle_r ( geosinit.ctxt , bp, joinStyle );
1858
- GEOSBufferParams_setMitreLimit_r ( geosinit.ctxt , bp, miterLimit ); // #spellok
1864
+ geos::buffer_params_unique_ptr bp ( GEOSBufferParams_create_r ( geosinit.ctxt ) );
1865
+ GEOSBufferParams_setSingleSided_r ( geosinit.ctxt , bp. get () , 1 );
1866
+ GEOSBufferParams_setQuadrantSegments_r ( geosinit.ctxt , bp. get () , segments );
1867
+ GEOSBufferParams_setJoinStyle_r ( geosinit.ctxt , bp. get () , joinStyle );
1868
+ GEOSBufferParams_setMitreLimit_r ( geosinit.ctxt , bp. get () , miterLimit ); // #spellok
1859
1869
1860
1870
if ( side == 1 )
1861
1871
{
1862
1872
distance = -distance;
1863
1873
}
1864
- geos.reset ( GEOSBufferWithParams_r ( geosinit.ctxt , mGeos .get (), bp, distance ) );
1865
- GEOSBufferParams_destroy_r ( geosinit.ctxt , bp );
1874
+ geos.reset ( GEOSBufferWithParams_r ( geosinit.ctxt , mGeos .get (), bp.get (), distance ) );
1866
1875
}
1867
1876
CATCH_GEOS_WITH_ERRMSG ( nullptr );
1868
1877
return fromGeos ( geos.get () );
@@ -2020,11 +2029,10 @@ QgsGeometry QgsGeos::closestPoint( const QgsGeometry &other, QString *errorMsg )
2020
2029
double ny = 0.0 ;
2021
2030
try
2022
2031
{
2023
- GEOSCoordSequence * nearestCoord = GEOSNearestPoints_r ( geosinit.ctxt , mGeos .get (), otherGeom.get () );
2032
+ geos::coord_sequence_unique_ptr nearestCoord ( GEOSNearestPoints_r ( geosinit.ctxt , mGeos .get (), otherGeom.get () ) );
2024
2033
2025
- ( void )GEOSCoordSeq_getX_r ( geosinit.ctxt , nearestCoord, 0 , &nx );
2026
- ( void )GEOSCoordSeq_getY_r ( geosinit.ctxt , nearestCoord, 0 , &ny );
2027
- GEOSCoordSeq_destroy_r ( geosinit.ctxt , nearestCoord );
2034
+ ( void )GEOSCoordSeq_getX_r ( geosinit.ctxt , nearestCoord.get (), 0 , &nx );
2035
+ ( void )GEOSCoordSeq_getY_r ( geosinit.ctxt , nearestCoord.get (), 0 , &ny );
2028
2036
}
2029
2037
catch ( GEOSException &e )
2030
2038
{
@@ -2057,14 +2065,12 @@ QgsGeometry QgsGeos::shortestLine( const QgsGeometry &other, QString *errorMsg )
2057
2065
double ny2 = 0.0 ;
2058
2066
try
2059
2067
{
2060
- GEOSCoordSequence *nearestCoord = GEOSNearestPoints_r ( geosinit.ctxt , mGeos .get (), otherGeom.get () );
2061
-
2062
- ( void )GEOSCoordSeq_getX_r ( geosinit.ctxt , nearestCoord, 0 , &nx1 );
2063
- ( void )GEOSCoordSeq_getY_r ( geosinit.ctxt , nearestCoord, 0 , &ny1 );
2064
- ( void )GEOSCoordSeq_getX_r ( geosinit.ctxt , nearestCoord, 1 , &nx2 );
2065
- ( void )GEOSCoordSeq_getY_r ( geosinit.ctxt , nearestCoord, 1 , &ny2 );
2068
+ geos::coord_sequence_unique_ptr nearestCoord ( GEOSNearestPoints_r ( geosinit.ctxt , mGeos .get (), otherGeom.get () ) );
2066
2069
2067
- GEOSCoordSeq_destroy_r ( geosinit.ctxt , nearestCoord );
2070
+ ( void )GEOSCoordSeq_getX_r ( geosinit.ctxt , nearestCoord.get (), 0 , &nx1 );
2071
+ ( void )GEOSCoordSeq_getY_r ( geosinit.ctxt , nearestCoord.get (), 0 , &ny1 );
2072
+ ( void )GEOSCoordSeq_getX_r ( geosinit.ctxt , nearestCoord.get (), 1 , &nx2 );
2073
+ ( void )GEOSCoordSeq_getY_r ( geosinit.ctxt , nearestCoord.get (), 1 , &ny2 );
2068
2074
}
2069
2075
catch ( GEOSException &e )
2070
2076
{
0 commit comments