Skip to content
Permalink
Browse files
fix #13669 (Circular string generates duplicated nodes)
  • Loading branch information
PeterPetrik committed Jan 28, 2016
1 parent 1858cc7 commit 86e6771
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
@@ -447,6 +447,17 @@ void QgsLineStringV2::append( const QgsLineStringV2* line )
setZMTypeFromSubGeometry( line, QgsWKBTypes::LineString );
}

// do not store duplicit points
if ( numPoints() > 0 &&
line->numPoints() > 0 &&
endPoint() == line->startPoint() )
{
mX.pop_back();
mY.pop_back();
mZ.pop_back();
mM.pop_back();
}

mX += line->mX;
mY += line->mY;

@@ -1108,6 +1108,27 @@ void TestQgsGeometry::lineStringV2()
QCOMPARE( l10.pointN( 1 ), QgsPointV2( QgsWKBTypes::Point25D, 31, 32, 33 ) );
QCOMPARE( l10.pointN( 2 ), QgsPointV2( QgsWKBTypes::Point25D, 41, 42, 43 ) );

//append another line the closes the original geometry.
//Make sure there are not duplicit points except start and end point
l10.clear();
toAppend.reset( new QgsLineStringV2() );
toAppend->setPoints( QList< QgsPointV2 >()
<< QgsPointV2( 1, 1 )
<< QgsPointV2( 5, 5 )
<< QgsPointV2( 10, 1 ) );
l10.append( toAppend.data() );
QCOMPARE( l10.numPoints(), 3 );
QCOMPARE( l10.vertexCount(), 3 );
toAppend.reset( new QgsLineStringV2() );
toAppend->setPoints( QList< QgsPointV2 >()
<< QgsPointV2( 10, 1 )
<< QgsPointV2( 1, 1 ) );
l10.append( toAppend.data() );

QVERIFY( l10.isClosed() );
QCOMPARE( l10.numPoints(), 4 );
QCOMPARE( l10.vertexCount(), 4 );

//equality
QgsLineStringV2 e1;
QgsLineStringV2 e2;

0 comments on commit 86e6771

Please sign in to comment.