File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ class QgsRect
59
59
void expand(double, const QgsPoint *c = 0);
60
60
//! return the intersection with the given rectangle
61
61
QgsRect intersect(QgsRect *rect);
62
+ //! returns true when rectangle intersects with other rectangle
63
+ bool intersects(const QgsRect& rect) const;
62
64
//! expand the rectangle so that covers both the original rectangle and the given rectangle
63
65
void combineExtentWith(QgsRect *rect);
64
66
//! expand the rectangle so that covers both the original rectangle and the given point
Original file line number Diff line number Diff line change @@ -138,6 +138,17 @@ QgsRect QgsRect::intersect(QgsRect * rect) const
138
138
return intersection;
139
139
}
140
140
141
+ bool QgsRect::intersects (const QgsRect& rect) const
142
+ {
143
+ double x1 = (xmin > rect.xmin ? xmin : rect.xmin );
144
+ double x2 = (xmax < rect.xmax ? xmax : rect.xmax );
145
+ if (x1 > x2) return FALSE ;
146
+ double y1 = (ymin > rect.ymin ? ymin : rect.ymin );
147
+ double y2 = (ymax < rect.ymax ? ymax : rect.ymax );
148
+ if (y1 > y2) return FALSE ;
149
+ return TRUE ;
150
+ }
151
+
141
152
142
153
void QgsRect::combineExtentWith (QgsRect * rect)
143
154
{
Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ class CORE_EXPORT QgsRect
82
82
void expand (double , const QgsPoint *c = 0 );
83
83
// ! return the intersection with the given rectangle
84
84
QgsRect intersect (QgsRect *rect) const ;
85
+ // ! returns true when rectangle intersects with other rectangle
86
+ bool intersects (const QgsRect& rect) const ;
85
87
// ! expand the rectangle so that covers both the original rectangle and the given rectangle
86
88
void combineExtentWith (QgsRect *rect);
87
89
// ! expand the rectangle so that covers both the original rectangle and the given point
You can’t perform that action at this time.
0 commit comments