diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2019-01-10 16:29:12 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2019-01-14 09:00:08 +0000 |
commit | b544e2fe22333f0a5fbd24a1ee106c5501a6b886 (patch) | |
tree | 08ceef1ba7efb5bfe8f8fc0a3dfb28ba95258c3c /src | |
parent | c6cfb10b4eb8c227983fe7b4649cb0b691962743 (diff) | |
download | qtlocation-b544e2fe22333f0a5fbd24a1ee106c5501a6b886.tar.gz |
Fix QGeoRectangle::operator|=
This patch fixes the case when one QGeoRectangle contains the
second, and wraps around.
Change-Id: I7110c1864082c502845754fab2dc4e783455a446
Fixes: QTBUG-72935
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/positioning/qgeorectangle.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/positioning/qgeorectangle.cpp b/src/positioning/qgeorectangle.cpp index 337b4c76..a760831c 100644 --- a/src/positioning/qgeorectangle.cpp +++ b/src/positioning/qgeorectangle.cpp @@ -938,31 +938,36 @@ QGeoRectangle &QGeoRectangle::operator|=(const QGeoRectangle &rectangle) bool joinWrapLeft = (nonWrapRight >= wrapLeft); bool joinWrapRight = (nonWrapLeft <= wrapRight); - if (joinWrapLeft) { - if (joinWrapRight) { - left = -180.0; - right = 180.0; - } else { - left = nonWrapLeft; - right = wrapRight; - } + if (wrapLeft <= nonWrapLeft) { // The wrapping rectangle contains the non-wrapping one entirely + left = wrapLeft; + right = wrapRight; } else { - if (joinWrapRight) { - left = wrapLeft; - right = nonWrapRight; - } else { - double wrapRightDistance = nonWrapLeft - wrapRight; - double wrapLeftDistance = wrapLeft - nonWrapRight; - - if (wrapLeftDistance == wrapRightDistance) { + if (joinWrapLeft) { + if (joinWrapRight) { left = -180.0; right = 180.0; - } else if (wrapLeftDistance < wrapRightDistance) { + } else { left = nonWrapLeft; right = wrapRight; - } else { + } + } else { + if (joinWrapRight) { left = wrapLeft; right = nonWrapRight; + } else { + double wrapRightDistance = nonWrapLeft - wrapRight; + double wrapLeftDistance = wrapLeft - nonWrapRight; + + if (wrapLeftDistance == wrapRightDistance) { + left = -180.0; + right = 180.0; + } else if (wrapLeftDistance < wrapRightDistance) { + left = nonWrapLeft; + right = wrapRight; + } else { + left = wrapLeft; + right = nonWrapRight; + } } } } |