Skip to content

Commit

Permalink
Fix date line breaks with non geographic input CRS
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 8, 2019
1 parent 654d7a4 commit e286c09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core/qgsdistancearea.cpp
Expand Up @@ -560,6 +560,7 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
currentPart << p1;
double d = interval;
double prevLon = p1.x();
double prevLat = p1.y();
bool lastRun = false;
double t = 0;
while ( true )
Expand All @@ -582,7 +583,7 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
// when breaking the geodesic at the date line, we need to calculate the latitude
// at which the geodesic intersects the date line, and add points to both line segments at this latitude
// on the date line.
double lat180 = latitudeGeodesicCrossesDateLine( currentPart.constLast(), QgsPointXY( lon, lat ) );
double lat180 = latitudeGeodesicCrossesDateLine( QgsPointXY( prevLon, prevLat ), QgsPointXY( lon, lat ) );

try
{
Expand Down Expand Up @@ -621,6 +622,7 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
}

prevLon = lon;
prevLat = lat;

try
{
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsdistancearea.py
Expand Up @@ -723,7 +723,7 @@ def testGeodesicLine(self):
g = QgsGeometry.fromMultiPolylineXY(da.geodesicLine(QgsPointXY(-13536427, 14138932), QgsPointXY(13760912, -13248201),
1000000, True))
self.assertEqual(g.asWkt(0),
'MultiLineString ((-13536427 14138932, -16514348 11691516, -17948849 9406595, -18744235 7552985, -19255354 6014890, -19622372 4688888, -19909239 3505045),(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))')
'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))')


if __name__ == '__main__':
Expand Down

0 comments on commit e286c09

Please sign in to comment.