Skip to content
Permalink
Browse files

If QgsRectangle is empty when combined, replace

It makes no sense to use an empty rectangle to combine with
  • Loading branch information
m-kuhn committed Aug 29, 2016
1 parent 9253228 commit 280203e98868325842702d9a5f4425082e645acc
Showing with 18 additions and 11 deletions.
  1. +18 −11 src/core/qgsrectangle.cpp
@@ -196,24 +196,31 @@ bool QgsRectangle::contains( const QgsPoint &p ) const

void QgsRectangle::combineExtentWith( const QgsRectangle &rect )
{
if ( isNull() )
*this = rect;
else
{
xmin = (( xmin < rect.xMinimum() ) ? xmin : rect.xMinimum() );
xmax = (( xmax > rect.xMaximum() ) ? xmax : rect.xMaximum() );

xmin = (( xmin < rect.xMinimum() ) ? xmin : rect.xMinimum() );
xmax = (( xmax > rect.xMaximum() ) ? xmax : rect.xMaximum() );

ymin = (( ymin < rect.yMinimum() ) ? ymin : rect.yMinimum() );
ymax = (( ymax > rect.yMaximum() ) ? ymax : rect.yMaximum() );
ymin = (( ymin < rect.yMinimum() ) ? ymin : rect.yMinimum() );
ymax = (( ymax > rect.yMaximum() ) ? ymax : rect.yMaximum() );
}

}

void QgsRectangle::combineExtentWith( double x, double y )
{
if ( isNull() )
*this = QgsRectangle( x, y, x, y );
else
{
xmin = (( xmin < x ) ? xmin : x );
xmax = (( xmax > x ) ? xmax : x );

xmin = (( xmin < x ) ? xmin : x );
xmax = (( xmax > x ) ? xmax : x );

ymin = (( ymin < y ) ? ymin : y );
ymax = (( ymax > y ) ? ymax : y );

ymin = (( ymin < y ) ? ymin : y );
ymax = (( ymax > y ) ? ymax : y );
}
}

bool QgsRectangle::isEmpty() const

0 comments on commit 280203e

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