Skip to content

Commit

Permalink
fix for 360+ degrees wedgebuffer
Browse files Browse the repository at this point in the history
(cherry-picked from 5121f72)
  • Loading branch information
raymondnijssen authored and nyalldawson committed Aug 9, 2018
1 parent 7c2a998 commit 829a983
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -260,6 +260,35 @@ QgsGeometry QgsGeometry::collectGeometry( const QVector< QgsGeometry > &geometri

QgsGeometry QgsGeometry::createWedgeBuffer( const QgsPoint &center, const double azimuth, const double angularWidth, const double outerRadius, const double innerRadius )
{
if ( angularWidth >= 360.0 )
{
std::unique_ptr< QgsCompoundCurve > outer = qgis::make_unique< QgsCompoundCurve >();

const QgsPoint outerP1 = center.project( outerRadius, azimuth );
const QgsPoint outerP2 = center.project( outerRadius, azimuth + 180.0 );

outer->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( outerP1, outerP2, center ) ) );
outer->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( outerP2, outerP1, center ) ) );

std::unique_ptr< QgsCurvePolygon > cp = qgis::make_unique< QgsCurvePolygon >();
cp->setExteriorRing( outer.release() );

if ( !qgsDoubleNear( innerRadius, 0.0 ) && innerRadius > 0 )
{
std::unique_ptr< QgsCompoundCurve > inner = qgis::make_unique< QgsCompoundCurve >();

const QgsPoint innerP1 = center.project( innerRadius, azimuth );
const QgsPoint innerP2 = center.project( innerRadius, azimuth + 180.0 );

inner->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( innerP1, innerP2, center ) ) );
inner->addCurve( new QgsCircularString( QgsCircularString::fromTwoPointsAndCenter( innerP2, innerP1, center ) ) );

cp->setInteriorRings( { inner.release() } );
}

return QgsGeometry( std::move( cp ) );
}

std::unique_ptr< QgsCompoundCurve > wedge = qgis::make_unique< QgsCompoundCurve >();

const double startAngle = azimuth - angularWidth * 0.5;
Expand Down

0 comments on commit 829a983

Please sign in to comment.