[QGIS Commit] r8651 - in trunk/qgis: python/core src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Jun 16 20:15:09 EDT 2008
Author: wonder
Date: 2008-06-16 20:15:08 -0400 (Mon, 16 Jun 2008)
New Revision: 8651
Modified:
trunk/qgis/python/core/qgsrect.sip
trunk/qgis/src/core/qgsrect.cpp
trunk/qgis/src/core/qgsrect.h
Log:
Added QgsRect::intersects(QgsRect) predicate
Modified: trunk/qgis/python/core/qgsrect.sip
===================================================================
--- trunk/qgis/python/core/qgsrect.sip 2008-06-16 21:09:31 UTC (rev 8650)
+++ trunk/qgis/python/core/qgsrect.sip 2008-06-17 00:15:08 UTC (rev 8651)
@@ -59,6 +59,8 @@
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
Modified: trunk/qgis/src/core/qgsrect.cpp
===================================================================
--- trunk/qgis/src/core/qgsrect.cpp 2008-06-16 21:09:31 UTC (rev 8650)
+++ trunk/qgis/src/core/qgsrect.cpp 2008-06-17 00:15:08 UTC (rev 8651)
@@ -138,7 +138,18 @@
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)
{
Modified: trunk/qgis/src/core/qgsrect.h
===================================================================
--- trunk/qgis/src/core/qgsrect.h 2008-06-16 21:09:31 UTC (rev 8650)
+++ trunk/qgis/src/core/qgsrect.h 2008-06-17 00:15:08 UTC (rev 8651)
@@ -82,6 +82,8 @@
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
More information about the QGIS-commit
mailing list