Skip to content

Commit 021f5ea

Browse files
committedJan 11, 2019
[needs-docs][api] Rename QgsDistanceArea methods to change "date line"
to "antimeridian" Because the date line =/= +/-180 degree longitude, which is what we were incorrectly using it to mean.
1 parent a8bd12c commit 021f5ea

File tree

4 files changed

+97
-97
lines changed

4 files changed

+97
-97
lines changed
 

‎python/core/auto_generated/qgsdistancearea.sip.in

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,17 @@ The ``interval`` parameter gives the maximum distance between points on the comp
384384
This argument is always specified in meters. A shorter distance results in a denser line,
385385
at the cost of extra computing time.
386386

387-
If the geodesic line crosses the international date line and ``breakLine`` is true, then
388-
the line will be split into two parts, broken at the date line. In this case the function
389-
will return two lines, corresponding to the portions at either side of the date line.
387+
If the geodesic line crosses the antimeridian (+/- 180 degrees longitude) and ``breakLine`` is true, then
388+
the line will be split into two parts, broken at the antimeridian. In this case the function
389+
will return two lines, corresponding to the portions at either side of the antimeridian.
390390

391391
.. versionadded:: 3.6
392392
%End
393393

394-
double latitudeGeodesicCrossesDateLine( const QgsPointXY &p1, const QgsPointXY &p2, double &fractionAlongLine /Out/ ) const;
394+
double latitudeGeodesicCrossesAntimeridian( const QgsPointXY &p1, const QgsPointXY &p2, double &fractionAlongLine /Out/ ) const;
395395
%Docstring
396396
Calculates the latitude at which the geodesic line joining ``p1`` and ``p2`` crosses
397-
the international date line (longitude +/- 180 degrees).
397+
the antimeridian (longitude +/- 180 degrees).
398398

399399
The ellipsoid settings defined on this QgsDistanceArea object will be used during the calculations.
400400

@@ -404,21 +404,21 @@ will also be in this same CRS.
404404
:param p1: Starting point, in ellipsoidCrs()
405405
:param p2: Ending point, in ellipsoidCrs()
406406

407-
:return: - the latitude at which the geodesic crosses the date line
408-
- fractionAlongLine: will be set to the fraction along the geodesic line joining ``p1`` to ``p2`` at which the date line crossing occurs.
407+
:return: - the latitude at which the geodesic crosses the antimeridian
408+
- fractionAlongLine: will be set to the fraction along the geodesic line joining ``p1`` to ``p2`` at which the antimeridian crossing occurs.
409409

410-
.. seealso:: :py:func:`breakGeometryAtDateLine`
410+
.. seealso:: :py:func:`breakGeometryAtAntimeridian`
411411

412412

413413
.. versionadded:: 3.6
414414
%End
415415

416-
QgsGeometry splitGeometryAtDateLine( const QgsGeometry &geometry ) const;
416+
QgsGeometry splitGeometryAtAntimeridian( const QgsGeometry &geometry ) const;
417417
%Docstring
418-
Splits a (Multi)LineString ``geometry`` at the international date line (longitude +/- 180 degrees).
418+
Splits a (Multi)LineString ``geometry`` at the antimeridian (longitude +/- 180 degrees).
419419
The returned geometry will always be a multi-part geometry.
420420

421-
Whenever line segments in the input geometry cross the international date line, they will be
421+
Whenever line segments in the input geometry cross the antimeridian, they will be
422422
split into two segments, with the latitude of the breakpoint being determined using a geodesic
423423
line connecting the points either side of this segment.
424424

@@ -428,13 +428,13 @@ The ellipsoid settings defined on this QgsDistanceArea object will be used durin
428428
will also be in this same CRS.
429429

430430
If ``geometry`` contains M or Z values, these will be linearly interpolated for the new vertices
431-
created at the date line.
431+
created at the antimeridian.
432432

433433
.. note::
434434

435435
Non-(Multi)LineString geometries will be returned unchanged.
436436

437-
.. seealso:: :py:func:`latitudeGeodesicCrossesDateLine`
437+
.. seealso:: :py:func:`latitudeGeodesicCrossesAntimeridian`
438438

439439
.. versionadded:: 3.6
440440
%End

‎src/core/qgsdistancearea.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ QgsPointXY QgsDistanceArea::computeSpheroidProject(
457457
return QgsPointXY( RAD2DEG( lambda2 ), RAD2DEG( lat2 ) );
458458
}
459459

460-
double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1, const QgsPointXY &pp2, double &fractionAlongLine ) const
460+
double QgsDistanceArea::latitudeGeodesicCrossesAntimeridian( const QgsPointXY &pp1, const QgsPointXY &pp2, double &fractionAlongLine ) const
461461
{
462462
QgsPointXY p1 = pp1;
463463
QgsPointXY p2 = pp2;
@@ -487,7 +487,7 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
487487

488488
int iterations = 0;
489489
double t = 0;
490-
// iterate until our intersection candidate is within ~1 mm of the date line (or too many iterations happened)
490+
// iterate until our intersection candidate is within ~1 mm of the antimeridian (or too many iterations happened)
491491
while ( std::fabs( lon - 180.0 ) > 0.00000001 && iterations < 100 )
492492
{
493493
if ( iterations > 0 && std::fabs( p2x - p1x ) > 5 )
@@ -516,7 +516,7 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
516516
intersectionDist *= ( 180.0 - p1x ) / ( lon - p1x );
517517
}
518518

519-
// now work out the point on the geodesic this far from p1 - this becomes our new candidate for crossing the date line
519+
// now work out the point on the geodesic this far from p1 - this becomes our new candidate for crossing the antimeridian
520520

521521
geod_position( &line, intersectionDist, &lat, &lon, &t );
522522
// we don't want to wrap longitudes > 180 around)
@@ -533,7 +533,7 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
533533
return lat;
534534
}
535535

536-
QgsGeometry QgsDistanceArea::splitGeometryAtDateLine( const QgsGeometry &geometry ) const
536+
QgsGeometry QgsDistanceArea::splitGeometryAtAntimeridian( const QgsGeometry &geometry ) const
537537
{
538538
if ( QgsWkbTypes::geometryType( geometry.wkbType() ) != QgsWkbTypes::LineGeometry )
539539
return geometry;
@@ -585,14 +585,14 @@ QgsGeometry QgsDistanceArea::splitGeometryAtDateLine( const QgsGeometry &geometr
585585
lat = y;
586586
mCoordTransform.transformInPlace( lon, lat, z );
587587

588-
//test if we crossed the dateline in this segment
588+
//test if we crossed the antimeridian in this segment
589589
if ( i > 0 && ( ( prevLon < -120 && lon > 120 ) || ( prevLon > 120 && lon < -120 ) ) )
590590
{
591591
// we did!
592592
// when crossing the antimeridian, we need to calculate the latitude
593593
// at which the geodesic intersects the antimeridian
594594
double fract = 0;
595-
double lat180 = latitudeGeodesicCrossesDateLine( QgsPointXY( prevLon, prevLat ), QgsPointXY( lon, lat ), fract );
595+
double lat180 = latitudeGeodesicCrossesAntimeridian( QgsPointXY( prevLon, prevLat ), QgsPointXY( lon, lat ), fract );
596596
if ( line->is3D() )
597597
{
598598
z = prevZ + ( p.z() - prevZ ) * fract;
@@ -711,11 +711,11 @@ QVector< QVector<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &
711711

712712
if ( breakLine && ( ( prevLon < -120 && lon > 120 ) || ( prevLon > 120 && lon < -120 ) ) )
713713
{
714-
// when breaking the geodesic at the date line, we need to calculate the latitude
715-
// at which the geodesic intersects the date line, and add points to both line segments at this latitude
716-
// on the date line.
714+
// when breaking the geodesic at the antimeridian, we need to calculate the latitude
715+
// at which the geodesic intersects the antimeridian, and add points to both line segments at this latitude
716+
// on the antimeridian.
717717
double fraction;
718-
double lat180 = latitudeGeodesicCrossesDateLine( QgsPointXY( prevLon, prevLat ), QgsPointXY( lon, lat ), fraction );
718+
double lat180 = latitudeGeodesicCrossesAntimeridian( QgsPointXY( prevLon, prevLat ), QgsPointXY( lon, lat ), fraction );
719719

720720
try
721721
{

‎src/core/qgsdistancearea.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,17 @@ class CORE_EXPORT QgsDistanceArea
311311
* This argument is always specified in meters. A shorter distance results in a denser line,
312312
* at the cost of extra computing time.
313313
*
314-
* If the geodesic line crosses the international date line and \a breakLine is true, then
315-
* the line will be split into two parts, broken at the date line. In this case the function
316-
* will return two lines, corresponding to the portions at either side of the date line.
314+
* If the geodesic line crosses the antimeridian (+/- 180 degrees longitude) and \a breakLine is true, then
315+
* the line will be split into two parts, broken at the antimeridian. In this case the function
316+
* will return two lines, corresponding to the portions at either side of the antimeridian.
317317
*
318318
* \since QGIS 3.6
319319
*/
320320
QVector<QVector<QgsPointXY> > geodesicLine( const QgsPointXY &p1, const QgsPointXY &p2, double interval, bool breakLine = false ) const;
321321

322322
/**
323323
* Calculates the latitude at which the geodesic line joining \a p1 and \a p2 crosses
324-
* the international date line (longitude +/- 180 degrees).
324+
* the antimeridian (longitude +/- 180 degrees).
325325
*
326326
* The ellipsoid settings defined on this QgsDistanceArea object will be used during the calculations.
327327
*
@@ -330,20 +330,20 @@ class CORE_EXPORT QgsDistanceArea
330330
*
331331
* \param p1 Starting point, in ellipsoidCrs()
332332
* \param p2 Ending point, in ellipsoidCrs()
333-
* \param fractionAlongLine will be set to the fraction along the geodesic line joining \a p1 to \a p2 at which the date line crossing occurs.
333+
* \param fractionAlongLine will be set to the fraction along the geodesic line joining \a p1 to \a p2 at which the antimeridian crossing occurs.
334334
*
335-
* \returns the latitude at which the geodesic crosses the date line
336-
* \see breakGeometryAtDateLine()
335+
* \returns the latitude at which the geodesic crosses the antimeridian
336+
* \see breakGeometryAtAntimeridian()
337337
*
338338
* \since QGIS 3.6
339339
*/
340-
double latitudeGeodesicCrossesDateLine( const QgsPointXY &p1, const QgsPointXY &p2, double &fractionAlongLine SIP_OUT ) const;
340+
double latitudeGeodesicCrossesAntimeridian( const QgsPointXY &p1, const QgsPointXY &p2, double &fractionAlongLine SIP_OUT ) const;
341341

342342
/**
343-
* Splits a (Multi)LineString \a geometry at the international date line (longitude +/- 180 degrees).
343+
* Splits a (Multi)LineString \a geometry at the antimeridian (longitude +/- 180 degrees).
344344
* The returned geometry will always be a multi-part geometry.
345345
*
346-
* Whenever line segments in the input geometry cross the international date line, they will be
346+
* Whenever line segments in the input geometry cross the antimeridian, they will be
347347
* split into two segments, with the latitude of the breakpoint being determined using a geodesic
348348
* line connecting the points either side of this segment.
349349
*
@@ -353,14 +353,14 @@ class CORE_EXPORT QgsDistanceArea
353353
* will also be in this same CRS.
354354
*
355355
* If \a geometry contains M or Z values, these will be linearly interpolated for the new vertices
356-
* created at the date line.
356+
* created at the antimeridian.
357357
*
358358
* \note Non-(Multi)LineString geometries will be returned unchanged.
359359
*
360-
* \see latitudeGeodesicCrossesDateLine()
360+
* \see latitudeGeodesicCrossesAntimeridian()
361361
* \since QGIS 3.6
362362
*/
363-
QgsGeometry splitGeometryAtDateLine( const QgsGeometry &geometry ) const;
363+
QgsGeometry splitGeometryAtAntimeridian( const QgsGeometry &geometry ) const;
364364

365365
private:
366366

‎tests/src/python/test_qgsdistancearea.py

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -627,93 +627,93 @@ def testFormatDistance(self):
627627
self.assertEqual(QgsDistanceArea.formatDistance(1.0, 1, QgsUnitTypes.DistanceUnknownUnit, False), '1.0')
628628
QLocale.setDefault(QLocale.system())
629629

630-
def testGeodesicIntersectionAtDateLine(self):
630+
def testGeodesicIntersectionAtAntimeridian(self):
631631
da = QgsDistanceArea()
632632
crs = QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
633633
da.setSourceCrs(crs, QgsProject.instance().transformContext())
634634
da.setEllipsoid("WGS84")
635635

636-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(0, 0), QgsPointXY(-170, 0))
636+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(0, 0), QgsPointXY(-170, 0))
637637
self.assertAlmostEqual(lat, 0, 5)
638638
self.assertAlmostEqual(fract, 0, 5)
639-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-170, 0), QgsPointXY(170, 0))
639+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-170, 0), QgsPointXY(170, 0))
640640
self.assertAlmostEqual(lat, 0, 5)
641641
self.assertAlmostEqual(fract, 0.5, 5)
642-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(179, 0), QgsPointXY(181, 0))
642+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(179, 0), QgsPointXY(181, 0))
643643
self.assertAlmostEqual(lat, 0, 5)
644644
self.assertAlmostEqual(fract, 0.5, 5)
645-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-170, 0), QgsPointXY(170, 0))
645+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-170, 0), QgsPointXY(170, 0))
646646
self.assertAlmostEqual(lat, 0, 5)
647647
self.assertAlmostEqual(fract, 0.5, 5)
648-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(180, 0), QgsPointXY(180, 0))
648+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(180, 0), QgsPointXY(180, 0))
649649
self.assertAlmostEqual(lat, 0, 5)
650-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(180, -10), QgsPointXY(180, -10))
650+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(180, -10), QgsPointXY(180, -10))
651651
self.assertAlmostEqual(lat, -10, 5)
652652

653-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(138.26237, -20.314687), QgsPointXY(-151.6, -77.8))
653+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(138.26237, -20.314687), QgsPointXY(-151.6, -77.8))
654654
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
655655
self.assertAlmostEqual(fract, 0.007113545719515548, 5)
656-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(138.26237, -20.314687), QgsPointXY(-151.6 + 360, -77.8))
656+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(138.26237, -20.314687), QgsPointXY(-151.6 + 360, -77.8))
657657
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
658658
self.assertAlmostEqual(fract, 0.007113545719515548, 5)
659-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-151.6, -77.8), QgsPointXY(138.26237, -20.314687))
659+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-151.6, -77.8), QgsPointXY(138.26237, -20.314687))
660660
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
661661
self.assertAlmostEqual(fract, 0.007113545719515548, 5)
662-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(170.60188754234980024, -70.81368329001529105),
663-
QgsPointXY(-164.61259948055175073, -76.66761193248410677))
662+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(170.60188754234980024, -70.81368329001529105),
663+
QgsPointXY(-164.61259948055175073, -76.66761193248410677))
664664
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
665665
self.assertAlmostEqual(fract, 0.0879577697523441, 5)
666-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-164.61259948055175073, -76.66761193248410677),
667-
QgsPointXY(170.60188754234980024,
668-
-70.81368329001529105))
666+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-164.61259948055175073, -76.66761193248410677),
667+
QgsPointXY(170.60188754234980024,
668+
-70.81368329001529105))
669669
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
670670
self.assertAlmostEqual(fract, 0.0879577697523441, 5)
671-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(178.44469761238570982, -73.47820480021761114),
672-
QgsPointXY(-179.21026002627399976, -74.08952948682963324))
671+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(178.44469761238570982, -73.47820480021761114),
672+
QgsPointXY(-179.21026002627399976, -74.08952948682963324))
673673
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
674674
self.assertAlmostEqual(fract, 0.6713541474159178, 5)
675-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-179.21026002627399976, -74.08952948682963324),
676-
QgsPointXY(178.44469761238570982,
677-
-73.47820480021761114))
675+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-179.21026002627399976, -74.08952948682963324),
676+
QgsPointXY(178.44469761238570982,
677+
-73.47820480021761114))
678678
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
679679
self.assertAlmostEqual(fract, 0.6713541474159178, 5)
680-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(179.83103440731269984, -73.8481044794813215),
681-
QgsPointXY(-179.93191793815378787, -73.90885909527753483))
680+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(179.83103440731269984, -73.8481044794813215),
681+
QgsPointXY(-179.93191793815378787, -73.90885909527753483))
682682
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
683683
self.assertAlmostEqual(fract, 0.7135414998986486, 5)
684-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-179.93191793815378787, -73.90885909527753483),
685-
QgsPointXY(179.83103440731269984, -73.8481044794813215))
684+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-179.93191793815378787, -73.90885909527753483),
685+
QgsPointXY(179.83103440731269984, -73.8481044794813215))
686686
self.assertAlmostEqual(lat, -73.89148222666744914, 5)
687687
self.assertAlmostEqual(fract, 0.7135414998986486, 5)
688688

689-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(179.92498611649580198, 7.24703528617311754),
690-
QgsPointXY(-178.20070563806575592, 16.09649962419504732))
689+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(179.92498611649580198, 7.24703528617311754),
690+
QgsPointXY(-178.20070563806575592, 16.09649962419504732))
691691
self.assertAlmostEqual(lat, 7.6112109902580265, 5)
692692
self.assertAlmostEqual(fract, 0.04111771567489498, 5)
693-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-178.20070563806575592, 16.09649962419504732),
694-
QgsPointXY(179.92498611649580198, 7.24703528617311754))
693+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-178.20070563806575592, 16.09649962419504732),
694+
QgsPointXY(179.92498611649580198, 7.24703528617311754))
695695
self.assertAlmostEqual(lat, 7.6112109902580265, 5)
696696
self.assertAlmostEqual(fract, 0.04111771567489498, 5)
697-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(360 - 178.20070563806575592, 16.09649962419504732),
698-
QgsPointXY(179.92498611649580198, 7.24703528617311754))
697+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(360 - 178.20070563806575592, 16.09649962419504732),
698+
QgsPointXY(179.92498611649580198, 7.24703528617311754))
699699
self.assertAlmostEqual(lat, 7.6112109902580265, 5)
700700
self.assertAlmostEqual(fract, 0.04111771567489498, 5)
701701

702-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(175.76717768974583578, 8.93749416467257873),
703-
QgsPointXY(-175.15030911497356669, 8.59851183021221033))
702+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(175.76717768974583578, 8.93749416467257873),
703+
QgsPointXY(-175.15030911497356669, 8.59851183021221033))
704704
self.assertAlmostEqual(lat, 8.80683758146703966, 5)
705705
self.assertAlmostEqual(fract, 0.46581637044475815, 5)
706-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-175.15030911497356669, 8.59851183021221033),
707-
QgsPointXY(175.76717768974583578,
708-
8.93749416467257873))
706+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-175.15030911497356669, 8.59851183021221033),
707+
QgsPointXY(175.76717768974583578,
708+
8.93749416467257873))
709709
self.assertAlmostEqual(lat, 8.80683758146703966, 5)
710710
self.assertAlmostEqual(fract, 0.46581637044475815, 5)
711711

712712
# calculation should be ellipsoid dependent!
713713
da.setEllipsoid("Phobos2000")
714-
lat, fract = da.latitudeGeodesicCrossesDateLine(QgsPointXY(-175.15030911497356669, 8.59851183021221033),
715-
QgsPointXY(175.76717768974583578,
716-
8.93749416467257873))
714+
lat, fract = da.latitudeGeodesicCrossesAntimeridian(QgsPointXY(-175.15030911497356669, 8.59851183021221033),
715+
QgsPointXY(175.76717768974583578,
716+
8.93749416467257873))
717717
self.assertAlmostEqual(lat, 8.836479503936307, 5)
718718
self.assertAlmostEqual(fract, 0.46593364650414865, 5)
719719

@@ -768,71 +768,71 @@ def testGeodesicLine(self):
768768
self.assertEqual(g.asWkt(0),
769769
'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))')
770770

771-
def testSplitGeometryAtDateline(self):
771+
def testSplitGeometryAtAntimeridian(self):
772772
da = QgsDistanceArea()
773773
crs = QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
774774
da.setSourceCrs(crs, QgsProject.instance().transformContext())
775775
da.setEllipsoid("WGS84")
776776

777777
# noops
778-
g = da.splitGeometryAtDateLine(QgsGeometry())
778+
g = da.splitGeometryAtAntimeridian(QgsGeometry())
779779
self.assertTrue(g.isNull())
780-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('Point(1 2)'))
780+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('Point(1 2)'))
781781
self.assertEqual(g.asWkt(), 'Point (1 2)')
782-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('MultiPoint(1 2, 3 4)'))
782+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('MultiPoint(1 2, 3 4)'))
783783
self.assertEqual(g.asWkt(), 'MultiPoint ((1 2),(3 4))')
784-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('PointZ(1 2 3)'))
784+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('PointZ(1 2 3)'))
785785
self.assertEqual(g.asWkt(), 'PointZ (1 2 3)')
786-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('PointM(1 2 3)'))
786+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('PointM(1 2 3)'))
787787
self.assertEqual(g.asWkt(), 'PointM (1 2 3)')
788-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString()'))
788+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString()'))
789789
self.assertEqual(g.asWkt(), 'MultiLineString ()')
790790

791791
# lines
792-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(0 0, -170 0)'))
792+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(0 0, -170 0)'))
793793
self.assertEqual(g.asWkt(), 'MultiLineString ((0 0, -170 0))')
794-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(-170 0, 0 0)'))
794+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(-170 0, 0 0)'))
795795
self.assertEqual(g.asWkt(), 'MultiLineString ((-170 0, 0 0))')
796-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(179 0, -179 0)'))
796+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(179 0, -179 0)'))
797797
self.assertEqual(g.asWkt(), 'MultiLineString ((179 0, 180 0),(-180 0, -179 0))')
798-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(179 0, 181 0)'))
798+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(179 0, 181 0)'))
799799
self.assertEqual(g.asWkt(), 'MultiLineString ((179 0, 180 0),(-180 0, -179 0))')
800-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(-179 0, 179 0)'))
800+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(-179 0, 179 0)'))
801801
self.assertEqual(g.asWkt(), 'MultiLineString ((-179 0, -180 0),(180 0, 179 0))')
802-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(181 0, 179 0)'))
802+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(181 0, 179 0)'))
803803
self.assertEqual(g.asWkt(), 'MultiLineString ((-179 0, -180 0),(180 0, 179 0))')
804-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(179 10, -179 -20)'))
804+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(179 10, -179 -20)'))
805805
self.assertEqual(g.asWkt(3), 'MultiLineString ((179 10, 180 -5.362),(-180 -5.362, -179 -20))')
806-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(179 -80, -179 70)'))
806+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(179 -80, -179 70)'))
807807
self.assertEqual(g.asWkt(3), 'MultiLineString ((179 -80, 180 -55.685),(-180 -55.685, -179 70))')
808808

809809
# multiline input
810-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('MultiLineString((1 10, 50 30),(179 -80, -179 70))'))
810+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('MultiLineString((1 10, 50 30),(179 -80, -179 70))'))
811811
self.assertEqual(g.asWkt(3), 'MultiLineString ((1 10, 50 30),(179 -80, 180 -55.685),(-180 -55.685, -179 70))')
812-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('MultiLineString((1 10, 50 30),(179 -80, 179.99 70))'))
812+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('MultiLineString((1 10, 50 30),(179 -80, 179.99 70))'))
813813
self.assertEqual(g.asWkt(3), 'MultiLineString ((1 10, 50 30),(179 -80, 179.99 70))')
814814

815815
# with z/m
816-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineStringZ(179 -80 1, -179 70 10)'))
816+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineStringZ(179 -80 1, -179 70 10)'))
817817
self.assertEqual(g.asWkt(3), 'MultiLineStringZ ((179 -80 1, 180 -55.685 2.466),(-180 -55.685 2.466, -179 70 10))')
818-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineStringM(179 -80 1, -179 70 10)'))
818+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineStringM(179 -80 1, -179 70 10)'))
819819
self.assertEqual(g.asWkt(3), 'MultiLineStringM ((179 -80 1, 180 -55.685 2.466),(-180 -55.685 2.466, -179 70 10))')
820-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineStringZM(179 -80 1 -4, -179 70 10 -30)'))
820+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineStringZM(179 -80 1 -4, -179 70 10 -30)'))
821821
self.assertEqual(g.asWkt(3), 'MultiLineStringZM ((179 -80 1 -4, 180 -55.685 2.466 -8.234),(-180 -55.685 2.466 -8.234, -179 70 10 -30))')
822-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('MultiLineStringZ((179 -80 1, -179 70 10),(-170 -5 1, -181 10 5))'))
822+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('MultiLineStringZ((179 -80 1, -179 70 10),(-170 -5 1, -181 10 5))'))
823823
self.assertEqual(g.asWkt(3), 'MultiLineStringZ ((179 -80 1, 180 -55.685 2.466),(-180 -55.685 2.466, -179 70 10),(-170 -5 1, -181 10 5))')
824824

825825
# different ellipsoid - should change intersection latitude
826826
da.setEllipsoid("Phobos2000")
827-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString(179 10, -179 -20)'))
827+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString(179 10, -179 -20)'))
828828
self.assertEqual(g.asWkt(3), 'MultiLineString ((179 10, 180 -5.459),(-180 -5.459, -179 -20))')
829829

830830
# with reprojection
831831
da.setEllipsoid("WGS84")
832832
# with reprojection
833833
da.setSourceCrs(QgsCoordinateReferenceSystem('EPSG:3857'), QgsProject.instance().transformContext())
834834

835-
g = da.splitGeometryAtDateLine(QgsGeometry.fromWkt('LineString( -13536427 14138932, 13760912 -13248201)'))
835+
g = da.splitGeometryAtAntimeridian(QgsGeometry.fromWkt('LineString( -13536427 14138932, 13760912 -13248201)'))
836836
self.assertEqual(g.asWkt(1), 'MultiLineString ((-13536427 14138932, -20037508.3 2933521.7),(20037508.3 2933521.7, 13760912 -13248201))')
837837

838838

0 commit comments

Comments
 (0)
Please sign in to comment.