Skip to content
Permalink
Browse files

Added QgsRect::intersects(QgsRect) predicate

git-svn-id: http://svn.osgeo.org/qgis/trunk@8651 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jun 17, 2008
1 parent 8b512ce commit b7b9f62e70ccc26ffc6030f0f5d401ddd30281a1
Showing with 15 additions and 0 deletions.
  1. +2 −0 python/core/qgsrect.sip
  2. +11 −0 src/core/qgsrect.cpp
  3. +2 −0 src/core/qgsrect.h
@@ -59,6 +59,8 @@ class QgsRect
void expand(double, const QgsPoint *c = 0);
//! return the intersection with the given rectangle
QgsRect intersect(QgsRect *rect);
//! returns true when rectangle intersects with other rectangle
bool intersects(const QgsRect& rect) const;
//! expand the rectangle so that covers both the original rectangle and the given rectangle
void combineExtentWith(QgsRect *rect);
//! expand the rectangle so that covers both the original rectangle and the given point
@@ -138,6 +138,17 @@ QgsRect QgsRect::intersect(QgsRect * rect) const
return intersection;
}

bool QgsRect::intersects(const QgsRect& rect) const
{
double x1 = (xmin > rect.xmin ? xmin : rect.xmin);
double x2 = (xmax < rect.xmax ? xmax : rect.xmax);
if (x1 > x2) return FALSE;
double y1 = (ymin > rect.ymin ? ymin : rect.ymin);
double y2 = (ymax < rect.ymax ? ymax : rect.ymax);
if (y1 > y2) return FALSE;
return TRUE;
}


void QgsRect::combineExtentWith(QgsRect * rect)
{
@@ -82,6 +82,8 @@ class CORE_EXPORT QgsRect
void expand(double, const QgsPoint *c = 0);
//! return the intersection with the given rectangle
QgsRect intersect(QgsRect *rect) const;
//! returns true when rectangle intersects with other rectangle
bool intersects(const QgsRect& rect) const;
//! expand the rectangle so that covers both the original rectangle and the given rectangle
void combineExtentWith(QgsRect *rect);
//! expand the rectangle so that covers both the original rectangle and the given point

0 comments on commit b7b9f62

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