Skip to content

Commit

Permalink
Fix build and multi-arc duplicated points
Browse files Browse the repository at this point in the history
  • Loading branch information
strk committed Aug 25, 2017
1 parent 48c9539 commit 320c305
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/core/geometry/qgsgeometryutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,15 +779,15 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
{
if ( clockwise )
{
if ( *stringPoints.begin() != circlePoint2 )
if ( stringPoints.empty() || stringPoints.front() != circlePoint2 )
{
QgsDebugMsg( QString( "Adding control point, with angle %1 (%2)" ) . arg( a2 ) .arg( a2 * 180 / M_PI ) );
stringPoints.insert( 0, circlePoint2 );
}
}
else
{
if ( *stringPoints.rbegin() != circlePoint2 )
if ( stringPoints.empty() || stringPoints.back() != circlePoint2 )
{
QgsDebugMsg( QString( "Adding control point, with angle %1 (%2)" ) . arg( a2 ) .arg( a2 * 180 / M_PI ) );
stringPoints.insert( stringPoints.size(), circlePoint2 );
Expand Down Expand Up @@ -822,6 +822,7 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
{
std::reverse( stringPoints.begin(), stringPoints.end() );
}
if ( ! points.empty() && stringPoints.front() == points.back() ) stringPoints.pop_front();
points.append( stringPoints );
}

Expand Down
11 changes: 6 additions & 5 deletions tests/src/core/testqgscurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TestQgsCurve : public QObject
); \
std::unique_ptr< QgsLineString > expgeom( \
dynamic_cast<QgsLineString *>( \
QgsGeometryFactory::geomFromWkt( exp ) \
QgsGeometryFactory::geomFromWkt( exp ).release() \
) \
); \
expgeom.reset( expgeom->reversed() ); \
Expand All @@ -80,10 +80,11 @@ void TestQgsCurve::curveToLine()
std::unique_ptr< QgsCircularString > circularString;

/* input: 2 quadrants arc (180 degrees, PI radians) */
circularString.reset( dynamic_cast<QgsCircularString *>(
circularString.reset( dynamic_cast< QgsCircularString *>(
QgsGeometryFactory::geomFromWkt( QString(
"CIRCULARSTRING(0 0,100 100,200 0)"
) )
)
).release()
) );
QVERIFY( circularString.get() );

Expand All @@ -105,13 +106,13 @@ void TestQgsCurve::curveToLine()
circularString.reset( dynamic_cast<QgsCircularString *>(
QgsGeometryFactory::geomFromWkt( QString(
"CIRCULARSTRING(0 0,100 100,200 0,300 -100,400 0)"
) )
) ).release()
) );
QVERIFY( circularString.get() );

/* op: Maximum of M_PI / 3 degrees of angle */
TEST_C2L( circularString, M_PI / 3, QgsAbstractGeometry::MaximumAngle,
"LineString (0 0, 50 86.6, 150 86.6, 200 0, 200 0, 250 -86.6, 350 -86.6, 400 0)", 2 );
"LineString (0 0, 50 86.6, 150 86.6, 200 0, 250 -86.6, 350 -86.6, 400 0)", 2 );
}


Expand Down

0 comments on commit 320c305

Please sign in to comment.