diff --git a/src/core/qgsdistancearea.cpp b/src/core/qgsdistancearea.cpp index 53b5ae42882..4fa5ad77d90 100644 --- a/src/core/qgsdistancearea.cpp +++ b/src/core/qgsdistancearea.cpp @@ -700,8 +700,8 @@ QVector< QVector > QgsDistanceArea::geodesicLine( const QgsPointXY & QVector< QgsPointXY > currentPart; currentPart << p1; double d = interval; - double prevLon = p1.x(); - double prevLat = p1.y(); + double prevLon = pp1.x(); + double prevLat = pp1.y(); bool lastRun = false; double t = 0; while ( true ) diff --git a/tests/src/python/test_qgsdistancearea.py b/tests/src/python/test_qgsdistancearea.py index 8685305cf28..84b1c261e1e 100644 --- a/tests/src/python/test_qgsdistancearea.py +++ b/tests/src/python/test_qgsdistancearea.py @@ -791,6 +791,10 @@ class TestQgsDistanceArea(unittest.TestCase): 1000000, True)) self.assertEqual(g.asWkt(0), 'MultiLineString ((-13536427 14138932, -16514348 11691516, -17948849 9406595, -18744235 7552985, -19255354 6014890, -19622372 4688888, -19909239 3505045, -20037508 2933522),(20037508 2933522, 19925702 2415579, 19712755 1385803, 19513769 388441, 19318507 -600065, 19117459 -1602293, 18899973 -2642347, 18651869 -3748726, 18351356 -4958346, 17960498 -6322823, 17404561 -7918366, 16514601 -9855937, 14851845 -12232940, 13760912 -13248201))') + g = QgsGeometry.fromMultiPolylineXY(da.geodesicLine(QgsPointXY(18933544, -5448034), QgsPointXY(-11638480, 3962206), + 1000000, True)) + self.assertEqual(g.asWkt(0), + 'MultiLineString ((18933544 -5448034, 20037508 -4772933),(-20037508 -4772933, -20002064 -4748323, -19015781 -3988451, -18153035 -3204936, -17383137 -2416816, -16678635 -1632067, -16015884 -852355, -15374147 -76043, -14734258 699941, -14077193 1478790, -13382634 2262546, -12627598 3050380, -11785404 3835868, -11638480 3962206))') def testSplitGeometryAtAntimeridian(self): da = QgsDistanceArea()