Skip to content

Commit

Permalink
Merge pull request #4713 from nyalldawson/rect_api
Browse files Browse the repository at this point in the history
Remove duplicate QgsRectangle::unionRect method
  • Loading branch information
nyalldawson committed Jun 11, 2017
2 parents 1034131 + 74ce555 commit dd0bb8c
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 34 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Expand Up @@ -1927,6 +1927,7 @@ QgsRectangle {#qgis_api_break_3_0_QgsRectangle}
------------

- The protected members were removed - QgsRectangle is not intended to be subclassed.
- unionRect was removed. Use combineExtentWith instead.

QgsRelation {#qgis_api_break_3_0_QgsRelation}
-----------
Expand Down
5 changes: 0 additions & 5 deletions python/core/geometry/qgsrectangle.sip
Expand Up @@ -267,11 +267,6 @@ Copy constructor
%End


void unionRect( const QgsRectangle &rect );
%Docstring
Updates the rectangle to include another rectangle.
%End

bool isFinite() const;
%Docstring
Returns true if the rectangle has finite boundaries. Will
Expand Down
12 changes: 0 additions & 12 deletions src/core/geometry/qgsrectangle.cpp
Expand Up @@ -342,18 +342,6 @@ QgsRectangle &QgsRectangle::operator=( const QgsRectangle &r )
return *this;
}

void QgsRectangle::unionRect( const QgsRectangle &r )
{
if ( r.xMinimum() < xMinimum() )
setXMinimum( r.xMinimum() );
if ( r.xMaximum() > xMaximum() )
setXMaximum( r.xMaximum() );
if ( r.yMinimum() < yMinimum() )
setYMinimum( r.yMinimum() );
if ( r.yMaximum() > yMaximum() )
setYMaximum( r.yMaximum() );
}

bool QgsRectangle::isFinite() const
{
if ( qIsInf( mXmin ) || qIsInf( mYmin ) || qIsInf( mXmax ) || qIsInf( mYmax ) )
Expand Down
5 changes: 0 additions & 5 deletions src/core/geometry/qgsrectangle.h
Expand Up @@ -259,11 +259,6 @@ class CORE_EXPORT QgsRectangle
*/
QgsRectangle &operator=( const QgsRectangle &r1 );

/**
* Updates the rectangle to include another rectangle.
*/
void unionRect( const QgsRectangle &rect );

/**
* Returns true if the rectangle has finite boundaries. Will
* return false if any of the rectangle boundaries are NaN or Inf.
Expand Down
2 changes: 1 addition & 1 deletion src/core/providers/memory/qgsmemoryprovider.cpp
Expand Up @@ -278,7 +278,7 @@ QgsRectangle QgsMemoryProvider::extent() const
Q_FOREACH ( const QgsFeature &feat, mFeatures )
{
if ( feat.hasGeometry() )
mExtent.unionRect( feat.geometry().boundingBox() );
mExtent.combineExtentWith( feat.geometry().boundingBox() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgml.cpp
Expand Up @@ -249,7 +249,7 @@ void QgsGml::calculateExtentFromFeatures()
}
else
{
mExtent.unionRect( currentGeometry.boundingBox() );
mExtent.combineExtentWith( currentGeometry.boundingBox() );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmapsettings.cpp
Expand Up @@ -523,7 +523,7 @@ QgsRectangle QgsMapSettings::fullExtent() const
QgsRectangle extent = layerExtentToOutputExtent( lyr, lyr->extent() );

QgsDebugMsg( "Output extent: " + extent.toString() );
fullExtent.unionRect( extent );
fullExtent.combineExtentWith( extent );
}
}

Expand Down
Expand Up @@ -117,7 +117,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors,
if ( QgsGeometryCheckerUtils::sharedEdgeLength( geom, geom2, QgsGeometryCheckPrecision::reducedTolerance() ) > 0 )
{
neighboringIds.insert( feature.id() );
gapAreaBBox.unionRect( geom2->boundingBox() );
gapAreaBBox.combineExtentWith( geom2->boundingBox() );
}
}
if ( neighboringIds.isEmpty() )
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/geometry_checker/qgsgeometrychecker.cpp
Expand Up @@ -117,7 +117,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method )
if ( mFeaturePool->get( id, f ) )
{
recheckFeatures.insert( id );
recheckArea.unionRect( f.geometry().boundingBox() );
recheckArea.combineExtentWith( f.geometry().boundingBox() );
}
}
}
Expand All @@ -128,7 +128,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method )
{
if ( err->affectedAreaBBox().intersects( recheckArea ) )
{
recheckArea.unionRect( err->affectedAreaBBox() );
recheckArea.combineExtentWith( err->affectedAreaBBox() );
}
}
}
Expand Down
Expand Up @@ -366,7 +366,7 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
}
else
{
totextent.unionRect( geomextent );
totextent.combineExtentWith( geomextent );
}
}
}
Expand All @@ -392,12 +392,12 @@ void QgsGeometryCheckerResultTab::highlightErrors( bool current )
extent.setXMaximum( extent.xMaximum() + diff.x() );
extent.setYMinimum( extent.yMinimum() + diff.y() );
extent.setYMaximum( extent.yMaximum() + diff.y() );
extent.unionRect( pointExtent );
extent.combineExtentWith( pointExtent );
totextent = extent;
}
else
{
totextent.unionRect( pointExtent );
totextent.combineExtentWith( pointExtent );
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsrectangle.cpp
Expand Up @@ -47,8 +47,8 @@ void TestQgsRectangle::manipulate()
QVERIFY( ! rect2.contains( rect1 ) );

// Create the union
rect3.unionRect( rect1 );
rect3.unionRect( rect2 );
rect3.combineExtentWith( rect1 );
rect3.combineExtentWith( rect2 );
// Check union
QVERIFY( rect3 == QgsRectangle( 1.0, 1.0, 7.0, 5.0 ) );
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsrectangle.py
Expand Up @@ -172,7 +172,7 @@ def testUnion(self):
self.assertEqual(myResult, myExpectedResult, myMessage)

rect1 = QgsRectangle(0.0, 0.0, 5.0, 5.0)
rect1.unionRect(rect2)
rect1.combineExtentWith(rect2)
myMessage = ('Expected: %s\nGot: %s\n' %
(True, rect1.contains(rect2)))
assert rect1.contains(rect2), myMessage
Expand Down

0 comments on commit dd0bb8c

Please sign in to comment.