Fix QGeoPathPrivate::lineContains() logic
The prior logic was using the bounding-box of the whole path to
constrain which wrapped version of each point to use. However, simply
putting each point on the right of the bounding-box's left edge did
not assure that the points were within half a cycle of the x-direction
of one another, which is actually what is needed. So remove the
bounding-box wrapping and instead wrap, at each step along the path,
the start-point to be within half an x-cycle of the end. We can then
wrap the target point to within half an x-cycle of the segment's
mid-point. This shall usually be the closest representation of that
point to the chosen representation of the segment.
There is, however, a corner-case where this representation of the
target is y-closer to the end it's x-further from, that allows a
region just over 0.5 x-further from the latter (but within 0.5 of the
x-mid) where the next cycle's version of the target point is actually
closer to that further end than to the line, despite being x-further
from its mid-point. So take a second pass through the
candidate-finding code to try out the relevant other cycle's version
of the target point when we can't (cheaply) rule out this (frankly
obscure) possibility.
This made determination of the bounding box redundant, since we no
longer rely on or indeed reference it, so mark that computation as
redundant. Retain it for now, in case other code relies on the
side-effect of the bounding box being up to date after determing
whether the line contains a given point.
In the process, when studing each segment of the path, move the later
end-point's local variable into the loop body. Since we now wrap the
earlier end-point, when needed, this later end-point can be
const. Also rename the end-points to reflect their roles.
Fixes: QTBUG-142317
Pick-to: 6.11 6.10 6.8 6.5
Change-Id: Ia28fe18de0fbad48720e44eeeeeff7ce387047ef
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>