Skip to content

Commit 320c305

Browse files
committed
Fix build and multi-arc duplicated points
1 parent 48c9539 commit 320c305

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/core/geometry/qgsgeometryutils.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -779,15 +779,15 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
779779
{
780780
if ( clockwise )
781781
{
782-
if ( *stringPoints.begin() != circlePoint2 )
782+
if ( stringPoints.empty() || stringPoints.front() != circlePoint2 )
783783
{
784784
QgsDebugMsg( QString( "Adding control point, with angle %1 (%2)" ) . arg( a2 ) .arg( a2 * 180 / M_PI ) );
785785
stringPoints.insert( 0, circlePoint2 );
786786
}
787787
}
788788
else
789789
{
790-
if ( *stringPoints.rbegin() != circlePoint2 )
790+
if ( stringPoints.empty() || stringPoints.back() != circlePoint2 )
791791
{
792792
QgsDebugMsg( QString( "Adding control point, with angle %1 (%2)" ) . arg( a2 ) .arg( a2 * 180 / M_PI ) );
793793
stringPoints.insert( stringPoints.size(), circlePoint2 );
@@ -822,6 +822,7 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
822822
{
823823
std::reverse( stringPoints.begin(), stringPoints.end() );
824824
}
825+
if ( ! points.empty() && stringPoints.front() == points.back() ) stringPoints.pop_front();
825826
points.append( stringPoints );
826827
}
827828

tests/src/core/testqgscurve.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class TestQgsCurve : public QObject
6767
); \
6868
std::unique_ptr< QgsLineString > expgeom( \
6969
dynamic_cast<QgsLineString *>( \
70-
QgsGeometryFactory::geomFromWkt( exp ) \
70+
QgsGeometryFactory::geomFromWkt( exp ).release() \
7171
) \
7272
); \
7373
expgeom.reset( expgeom->reversed() ); \
@@ -80,10 +80,11 @@ void TestQgsCurve::curveToLine()
8080
std::unique_ptr< QgsCircularString > circularString;
8181

8282
/* input: 2 quadrants arc (180 degrees, PI radians) */
83-
circularString.reset( dynamic_cast<QgsCircularString *>(
83+
circularString.reset( dynamic_cast< QgsCircularString *>(
8484
QgsGeometryFactory::geomFromWkt( QString(
8585
"CIRCULARSTRING(0 0,100 100,200 0)"
86-
) )
86+
)
87+
).release()
8788
) );
8889
QVERIFY( circularString.get() );
8990

@@ -105,13 +106,13 @@ void TestQgsCurve::curveToLine()
105106
circularString.reset( dynamic_cast<QgsCircularString *>(
106107
QgsGeometryFactory::geomFromWkt( QString(
107108
"CIRCULARSTRING(0 0,100 100,200 0,300 -100,400 0)"
108-
) )
109+
) ).release()
109110
) );
110111
QVERIFY( circularString.get() );
111112

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

117118

0 commit comments

Comments
 (0)