From 89dc1125724e43a3a2486d1a1bffeaadc667b13f Mon Sep 17 00:00:00 2001 From: Remek Zajac Date: Thu, 18 Jun 2020 17:26:17 +0200 Subject: [PATCH] remember to floor before bresenham to work in the negative domain --- src/Terrain/TerrainQuery.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Terrain/TerrainQuery.cc b/src/Terrain/TerrainQuery.cc index 7ed3105db..4ab20567a 100644 --- a/src/Terrain/TerrainQuery.cc +++ b/src/Terrain/TerrainQuery.cc @@ -871,10 +871,10 @@ QPair, QList> UnitTestTerrainQuery::requestPathHei coordinates.push_back(fromCoord); //cast to pixels - long x0 = fromCoord.longitude()/one_second_deg; - long x1 = toCoord.longitude()/one_second_deg; - long y0 = fromCoord.latitude()/one_second_deg; - long y1 = toCoord.latitude()/one_second_deg; + long x0 = std::floor(fromCoord.longitude()/one_second_deg); + long x1 = std::floor(toCoord.longitude()/one_second_deg); + long y0 = std::floor(fromCoord.latitude()/one_second_deg); + long y1 = std::floor(toCoord.latitude()/one_second_deg); //bresenham line algo long dx = abs(x1-x0), sx = x0