mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Added QgsRect::intersects(QgsRect) predicate
git-svn-id: http://svn.osgeo.org/qgis/trunk@8651 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
8b512cea39
commit
b7b9f62e70
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user