Skip to content
Permalink
Browse files

Fix QgsGeometryCollection (and subclasses) `equal`

The previous behavior was to check if all parts of the collection are exactly the same.
The new check will check if all parts are equal (same vertice count, same vertice order, same vertice values).
  • Loading branch information
m-kuhn committed Jan 20, 2019
1 parent 8871a58 commit 2c00790cb7d774bbfdd9dcfdeb83c612a3347394
Showing with 7 additions and 2 deletions.
  1. +2 −1 src/core/geometry/qgsgeometrycollection.cpp
  2. +5 −1 tests/src/core/testqgsgeometry.cpp
@@ -78,7 +78,8 @@ bool QgsGeometryCollection::operator==( const QgsAbstractGeometry &other ) const

for ( int i = 0; i < mGeometries.count(); ++i )
{
if ( mGeometries.at( i ) != otherCollection->mGeometries.at( i ) )
if ( mGeometries.at( i ) != otherCollection->mGeometries.at( i )
&& mGeometries.at( i )->operator!=( *otherCollection->mGeometries.at( i ) ) )
return false;
}

QgsMultiPoint mp;
QgsMultiLineString ml;
QVERIFY( mp != ml );
QgsMultiLineString ml2;
part.setPoints( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointZ, 0, 0, 1 )
<< QgsPoint( QgsWkbTypes::PointZ, 0, 10, 2 ) << QgsPoint( QgsWkbTypes::PointZ, 10, 10, 3 )
<< QgsPoint( QgsWkbTypes::PointZ, 10, 0, 4 ) << QgsPoint( QgsWkbTypes::PointZ, 0, 0, 1 ) );
ml.addGeometry( part.clone() );
QgsMultiLineString ml2;
QVERIFY( ml != ml2 );
part.setPoints( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointZ, 1, 1, 1 )
<< QgsPoint( QgsWkbTypes::PointZ, 0, 10, 2 ) << QgsPoint( QgsWkbTypes::PointZ, 10, 10, 3 )
<< QgsPoint( QgsWkbTypes::PointZ, 10, 0, 4 ) << QgsPoint( QgsWkbTypes::PointZ, 0, 0, 1 ) );
ml2.addGeometry( part.clone() );
QVERIFY( ml != ml2 );

QgsMultiLineString ml3;
ml3.addGeometry( part.clone() );
QVERIFY( ml2 == ml3 );

//toCurveType
std::unique_ptr< QgsGeometryCollection > curveType( c12.toCurveType() );
QCOMPARE( curveType->wkbType(), QgsWkbTypes::GeometryCollection );

0 comments on commit 2c00790

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