Skip to content
Permalink
Browse files

Fix build and multi-arc duplicated points

  • Loading branch information
strk committed Aug 25, 2017
1 parent 48c9539 commit 320c305d929fbabd79120dea360fdb50f266d82c
Showing with 9 additions and 7 deletions.
  1. +3 −2 src/core/geometry/qgsgeometryutils.cpp
  2. +6 −5 tests/src/core/testqgscurve.cpp
@@ -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 );
@@ -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 );
}

@@ -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() ); \
@@ -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() );

@@ -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 );
}


0 comments on commit 320c305

Please sign in to comment.
You can’t perform that action at this time.