Skip to content

Commit 829a983

Browse files
raymondnijssennyalldawson
authored andcommitted
fix for 360+ degrees wedgebuffer
(cherry-picked from 5121f72)
1 parent 7c2a998 commit 829a983

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/core/geometry/qgsgeometry.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,35 @@ QgsGeometry QgsGeometry::collectGeometry( const QVector< QgsGeometry > &geometri
260260

261261
QgsGeometry QgsGeometry::createWedgeBuffer( const QgsPoint &center, const double azimuth, const double angularWidth, const double outerRadius, const double innerRadius )
262262
{
263+
if ( angularWidth >= 360.0 )
264+
{
265+
std::unique_ptr< QgsCompoundCurve > outer = qgis::make_unique< QgsCompoundCurve >();
266+
267+
const QgsPoint outerP1 = center.project( outerRadius, azimuth );
268+
const QgsPoint outerP2 = center.project( outerRadius, azimuth + 180.0 );
269+
270+
outer->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( outerP1, outerP2, center ) ) );
271+
outer->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( outerP2, outerP1, center ) ) );
272+
273+
std::unique_ptr< QgsCurvePolygon > cp = qgis::make_unique< QgsCurvePolygon >();
274+
cp->setExteriorRing( outer.release() );
275+
276+
if ( !qgsDoubleNear( innerRadius, 0.0 ) && innerRadius > 0 )
277+
{
278+
std::unique_ptr< QgsCompoundCurve > inner = qgis::make_unique< QgsCompoundCurve >();
279+
280+
const QgsPoint innerP1 = center.project( innerRadius, azimuth );
281+
const QgsPoint innerP2 = center.project( innerRadius, azimuth + 180.0 );
282+
283+
inner->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( innerP1, innerP2, center ) ) );
284+
inner->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( innerP2, innerP1, center ) ) );
285+
286+
cp->setInteriorRings( { inner.release() } );
287+
}
288+
289+
return QgsGeometry( std::move( cp ) );
290+
}
291+
263292
std::unique_ptr< QgsCompoundCurve > wedge = qgis::make_unique< QgsCompoundCurve >();
264293

265294
const double startAngle = azimuth - angularWidth * 0.5;

0 commit comments

Comments
 (0)