Skip to content
Permalink
Browse files
Rename to 'toGeographicCrs'
  • Loading branch information
nyalldawson committed Jan 11, 2022
1 parent 20046c5 commit 24a498b57cc39c7ef2ddcb8bf11eaab7c9d05a8e
@@ -995,13 +995,15 @@ definition. FormatWkt is recommended as it is a lossless format.
Since QGIS 3.18, internally this calls :py:func:`QgsCoordinateReferenceSystemRegistry.addUserCrs()`.
%End

QgsCoordinateReferenceSystem toGeodeticCrs() const;
QgsCoordinateReferenceSystem toGeographicCrs() const;
%Docstring
Returns the geodetic CRS associated with this CRS object.
Returns the geographic CRS associated with this CRS object.

May return an invalid CRS if the geodetic CRS could not be determined.
May return an invalid CRS if the geographic CRS could not be determined.

This method will always return a longitude, latitude ordered CRS.
.. note::

This method will always return a longitude, latitude ordered CRS.

.. versionadded:: 3.24
%End
@@ -2608,7 +2608,7 @@ const QHash<long, QgsCoordinateReferenceSystem> &QgsCoordinateReferenceSystem::s
return *sSrsIdCache();
}

QgsCoordinateReferenceSystem QgsCoordinateReferenceSystem::toGeodeticCrs() const
QgsCoordinateReferenceSystem QgsCoordinateReferenceSystem::toGeographicCrs() const
{
if ( isGeographic() )
{
@@ -908,15 +908,15 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
long saveAsUserCrs( const QString &name, Qgis::CrsDefinitionFormat nativeFormat = Qgis::CrsDefinitionFormat::Wkt );

/**
* Returns the geodetic CRS associated with this CRS object.
* Returns the geographic CRS associated with this CRS object.
*
* May return an invalid CRS if the geodetic CRS could not be determined.
* May return an invalid CRS if the geographic CRS could not be determined.
*
* This method will always return a longitude, latitude ordered CRS.
* \note This method will always return a longitude, latitude ordered CRS.
*
* \since QGIS 3.24
*/
QgsCoordinateReferenceSystem toGeodeticCrs() const;
QgsCoordinateReferenceSystem toGeographicCrs() const;

//! Returns auth id of related geographic CRS
QString geographicCrsAuthId() const;
@@ -244,7 +244,7 @@ void QgsCrsDefinitionWidget::pbnCalculate_clicked()
return;
}

const QgsCoordinateTransform transform( target.toGeodeticCrs(), target, QgsCoordinateTransformContext() );
const QgsCoordinateTransform transform( target.toGeographicCrs(), target, QgsCoordinateTransformContext() );
try
{
const QgsPointXY res = transform.transform( QgsPointXY( longitude, latitude ) );
@@ -1693,12 +1693,12 @@ void TestQgsCoordinateReferenceSystem::geographicCrsAuthId()
crs.createFromString( QStringLiteral( "EPSG:4326" ) );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:4326" ) );
QCOMPARE( crs.geographicCrsAuthId(), QStringLiteral( "EPSG:4326" ) );
QCOMPARE( crs.toGeodeticCrs(), crs );
QCOMPARE( crs.toGeographicCrs(), crs );

crs.createFromString( QStringLiteral( "EPSG:3825" ) );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3825" ) );
QCOMPARE( crs.geographicCrsAuthId(), QStringLiteral( "EPSG:3824" ) );
QCOMPARE( crs.toGeodeticCrs().toProj().replace( QStringLiteral( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QStringLiteral( " +type=crs" ), QString() ),
QCOMPARE( crs.toGeographicCrs().toProj().replace( QStringLiteral( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QStringLiteral( " +type=crs" ), QString() ),
QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3824" ) ).toProj().replace( QStringLiteral( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QStringLiteral( " +type=crs" ), QString() ) );
}

0 comments on commit 24a498b

Please sign in to comment.