summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/positioning/qgeopath.cpp2
-rw-r--r--tests/auto/qgeopath/tst_qgeopath.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index b24daec6..ad3536af 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -464,7 +464,7 @@ bool QGeoPathPrivate::contains(const QGeoCoordinate &coordinate) const
QDoubleVector2D candidate = ( (p-a).length() < (p-b).length() ) ? a : b;
- if (u < (b - a).length()
+ if (u > 0 && u < 1
&& (p-intersection).length() < (p-candidate).length() ) // And it falls in the segment
candidate = intersection;
diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp
index 8c4ac767..9244394a 100644
--- a/tests/auto/qgeopath/tst_qgeopath.cpp
+++ b/tests/auto/qgeopath/tst_qgeopath.cpp
@@ -275,8 +275,8 @@ void tst_QGeoPath::contains_data()
c.append(QGeoCoordinate(3,0));
QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true;
- QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false;
- QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0, 0) << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0.8, 0.8) << false;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0.8, 0.8) << true;
}
void tst_QGeoPath::contains()
@@ -378,7 +378,7 @@ void tst_QGeoPath::extendShape_data()
QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true << true;
QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false << true;
- QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0, 0) << true << true;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0.8, 0.8) << true << true;
}
QTEST_MAIN(tst_QGeoPath)