Skip to content
Permalink
Browse files

Fix date line breaks with non geographic input CRS

  • Loading branch information
nyalldawson committed Jan 8, 2019
1 parent 654d7a4 commit e286c094d6915df0695b467746abcc0959048ec2
Showing with 4 additions and 2 deletions.
  1. +3 −1 src/core/qgsdistancearea.cpp
  2. +1 −1 tests/src/python/test_qgsdistancearea.py
@@ -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 )
@@ -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
{
@@ -621,6 +622,7 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
}

prevLon = lon;
prevLat = lat;

try
{
@@ -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__':

0 comments on commit e286c09

Please sign in to comment.
You can’t perform that action at this time.