Skip to content

Commit 1c02154

Browse files
author
wonder
committed
Added QgsRectangle::contains predicate.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9973 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 898e510 commit 1c02154

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

python/core/qgsrect.sip

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class QgsRectangle
6161
QgsRectangle intersect(QgsRectangle *rect);
6262
//! returns true when rectangle intersects with other rectangle
6363
bool intersects(const QgsRectangle& rect) const;
64+
//! return true when rectangle contains other rectangle
65+
//! @note added in version 1.1
66+
bool contains( const QgsRectangle& rect ) const;
6467
//! expand the rectangle so that covers both the original rectangle and the given rectangle
6568
void combineExtentWith(QgsRectangle *rect);
6669
//! expand the rectangle so that covers both the original rectangle and the given point

src/core/qgsrectangle.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ bool QgsRectangle::intersects( const QgsRectangle& rect ) const
156156
return TRUE;
157157
}
158158

159+
bool QgsRectangle::contains( const QgsRectangle& rect ) const
160+
{
161+
return (rect.xmin >= xmin && rect.xmax <= xmax && rect.ymin >= ymin && rect.ymax <= ymax);
162+
}
163+
159164

160165
void QgsRectangle::combineExtentWith( QgsRectangle * rect )
161166
{

src/core/qgsrectangle.h

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class CORE_EXPORT QgsRectangle
8484
QgsRectangle intersect( QgsRectangle *rect ) const;
8585
//! returns true when rectangle intersects with other rectangle
8686
bool intersects( const QgsRectangle& rect ) const;
87+
//! return true when rectangle contains other rectangle
88+
//! @note added in version 1.1
89+
bool contains( const QgsRectangle& rect ) const;
8790
//! expand the rectangle so that covers both the original rectangle and the given rectangle
8891
void combineExtentWith( QgsRectangle *rect );
8992
//! expand the rectangle so that covers both the original rectangle and the given point

0 commit comments

Comments
 (0)