Skip to content

Commit 189c616

Browse files
committed
nav: handle route responses with duplicate points
1 parent e5edbe9 commit 189c616

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

selfdrive/ui/qt/maps/map_helpers.cc

+5
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ static float dot(QGeoCoordinate v, QGeoCoordinate w) {
160160
}
161161

162162
float minimum_distance(QGeoCoordinate a, QGeoCoordinate b, QGeoCoordinate p) {
163+
// If a and b are the same coordinate the computation below doesn't work
164+
if (a.distanceTo(b) < 0.01) {
165+
return a.distanceTo(p);
166+
}
167+
163168
const QGeoCoordinate ap = sub(p, a);
164169
const QGeoCoordinate ab = sub(b, a);
165170
const float t = std::clamp(dot(ap, ab) / dot(ab, ab), 0.0f, 1.0f);

0 commit comments

Comments
 (0)