Skip to content
Permalink
Browse files
Don't always reset custom crs format to wkt when it was originally
defined using a proj string
  • Loading branch information
nyalldawson committed Jan 13, 2022
1 parent 370bdfd commit 7a7fb285cd40eb9349628c001ea48ae5fb25ba0b
Showing with 29 additions and 5 deletions.
  1. +8 −1 python/gui/auto_generated/qgscrsdefinitionwidget.sip.in
  2. +13 −3 src/gui/qgscrsdefinitionwidget.cpp
  3. +8 −1 src/gui/qgscrsdefinitionwidget.h
@@ -36,7 +36,14 @@ An invalid CRS may be returned if no CRS is defined in the widget.
.. seealso:: :py:func:`setCrs`
%End

void setCrs( const QgsCoordinateReferenceSystem &crs, Qgis::CrsDefinitionFormat nativeFormat = Qgis::CrsDefinitionFormat::Wkt );
void setCrs( const QgsCoordinateReferenceSystem &crs );
%Docstring
Sets the current ``crs`` to display in the widget.

.. seealso:: :py:func:`crs`
%End

void setCrs( const QgsCoordinateReferenceSystem &crs, Qgis::CrsDefinitionFormat nativeFormat );
%Docstring
Sets the current ``crs`` to display in the widget.

@@ -41,15 +41,25 @@ QgsCrsDefinitionWidget::QgsCrsDefinitionWidget( QWidget *parent )

QgsCoordinateReferenceSystem QgsCrsDefinitionWidget::crs() const
{
QgsCoordinateReferenceSystem crs;
switch ( static_cast< Qgis::CrsDefinitionFormat >( mFormatComboBox->currentData().toInt() ) )
{
case Qgis::CrsDefinitionFormat::Wkt:
return QgsCoordinateReferenceSystem::fromWkt( mTextEditParameters->toPlainText() );
crs = QgsCoordinateReferenceSystem::fromWkt( mTextEditParameters->toPlainText() );
break;

case Qgis::CrsDefinitionFormat::Proj:
return QgsCoordinateReferenceSystem::fromProj( mTextEditParameters->toPlainText() );
crs = QgsCoordinateReferenceSystem::fromProj( mTextEditParameters->toPlainText() );
break;
}
BUILTIN_UNREACHABLE

crs.setNativeFormat( format() );
return crs;
}

void QgsCrsDefinitionWidget::setCrs( const QgsCoordinateReferenceSystem &crs )
{
setCrs( crs, crs.nativeFormat() );
}

void QgsCrsDefinitionWidget::setCrs( const QgsCoordinateReferenceSystem &crs, Qgis::CrsDefinitionFormat nativeFormat )
@@ -47,6 +47,13 @@ class GUI_EXPORT QgsCrsDefinitionWidget : public QWidget, private Ui::QgsCrsDefi
*/
QgsCoordinateReferenceSystem crs() const;

/**
* Sets the current \a crs to display in the widget.
*
* \see crs()
*/
void setCrs( const QgsCoordinateReferenceSystem &crs );

/**
* Sets the current \a crs to display in the widget.
*
@@ -55,7 +62,7 @@ class GUI_EXPORT QgsCrsDefinitionWidget : public QWidget, private Ui::QgsCrsDefi
*
* \see crs()
*/
void setCrs( const QgsCoordinateReferenceSystem &crs, Qgis::CrsDefinitionFormat nativeFormat = Qgis::CrsDefinitionFormat::Wkt );
void setCrs( const QgsCoordinateReferenceSystem &crs, Qgis::CrsDefinitionFormat nativeFormat );

/**
* Returns the selected CRS format.

0 comments on commit 7a7fb28

Please sign in to comment.