Skip to content
Permalink
Browse files

Cleanup QgsCoordinateReferenceSystem WKT enum

- alias WKT_2018* to new WKT_2019* values, since the spec is actually
2019, not 2018
- add WKT_PREFERRED value which currently aliases to WKT2_2019, but
can be changed if/when future bumps to the WKT spec happen
- add WKT_PREFERRED_GDAL which should be used whenever a CRS is
exported to WKT for use with GDAL API. Aliases to WKT2_2019 currently,
but can be changed if/when a new spec is released and GDAL supports it

(cherry picked from commit 34f4bd2)
  • Loading branch information
nyalldawson committed Apr 22, 2020
1 parent 737159e commit e37310d0156dae579678949c022b243d2d179093
Showing with 90 additions and 76 deletions.
  1. +6 −0 python/core/auto_generated/qgscoordinatereferencesystem.sip.in
  2. +1 −1 python/plugins/processing/algs/gdal/GdalUtils.py
  3. +1 −1 src/analysis/raster/qgsalignraster.cpp
  4. +2 −2 src/analysis/raster/qgsrastercalculator.cpp
  5. +1 −1 src/app/dwg/qgsdwgimporter.cpp
  6. +2 −2 src/app/qgsalignrasterdialog.cpp
  7. +10 −10 src/app/qgscustomprojectiondialog.cpp
  8. +1 −1 src/core/expression/qgsexpressioncontextutils.cpp
  9. +1 −1 src/core/layout/qgslayoutexporter.cpp
  10. +1 −1 src/core/layout/qgslayoutitemmap.cpp
  11. +1 −1 src/core/providers/gdal/qgsgdaldataitems.cpp
  12. +1 −1 src/core/providers/gdal/qgsgdalprovider.cpp
  13. +1 −1 src/core/providers/memory/qgsmemoryprovider.cpp
  14. +1 −1 src/core/providers/ogr/qgsogrprovider.cpp
  15. +1 −1 src/core/qgsabstractgeopdfexporter.cpp
  16. +12 −12 src/core/qgscoordinatereferencesystem.cpp
  17. +8 −2 src/core/qgscoordinatereferencesystem.h
  18. +2 −0 src/core/qgscoordinatereferencesystem_p.h
  19. +4 −4 src/core/qgscoordinatetransform.cpp
  20. +1 −1 src/core/qgscoordinatetransformcontext.cpp
  21. +2 −2 src/core/qgsgdalutils.cpp
  22. +2 −2 src/core/qgsmaprenderertask.cpp
  23. +1 −1 src/core/qgsofflineediting.cpp
  24. +1 −1 src/core/qgsvectorfilewriter.cpp
  25. +1 −1 src/core/raster/qgsrasterlayer.cpp
  26. +1 −1 src/gui/qgsnewgeopackagelayerdialog.cpp
  27. +2 −2 src/gui/qgsprojectionselectiontreewidget.cpp
  28. +1 −1 src/gui/qgsprojectionselectionwidget.cpp
  29. +1 −1 src/plugins/georeferencer/qgsimagewarper.cpp
  30. +2 −2 src/providers/db2/qgsdb2provider.cpp
  31. +1 −1 tests/src/analysis/testqgsalignraster.cpp
  32. +17 −17 tests/src/core/testqgscoordinatereferencesystem.cpp
@@ -705,6 +705,12 @@ Returns the ellipsoid acronym for the ellipsoid used by the CRS.
WKT2_2015_SIMPLIFIED,
WKT2_2018,
WKT2_2018_SIMPLIFIED,
WKT2_2019,
WKT2_2019_SIMPLIFIED,

WKT_PREFERRED,
WKT_PREFERRED_SIMPLIFIED,
WKT_PREFERRED_GDAL,
};

QString toWkt( WktVariant variant = WKT1_GDAL, bool multiline = false, int indentationWidth = 4 ) const;
@@ -439,7 +439,7 @@ def gdal_crs_string(crs):

if QgsProjUtils.projVersionMajor() >= 6:
# use WKT
return crs.toWkt(QgsCoordinateReferenceSystem.WKT2_2018)
return crs.toWkt(QgsCoordinateReferenceSystem.WKT_PREFERRED_GDAL)

# fallback to proj4 string, stripping out newline characters
return crs.toProj().replace('\n', ' ').replace('\r', ' ')
@@ -397,7 +397,7 @@ int QgsAlignRaster::suggestedReferenceLayer() const
// would be a better a choice to more accurately compute areas?
// (Why earth is not flat???)
QgsCoordinateReferenceSystem destCRS( QStringLiteral( "EPSG:4326" ) );
QString destWkt = destCRS.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 );
QString destWkt = destCRS.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL );

const auto constMRasters = mRasters;
for ( const Item &raster : constMRasters )
@@ -153,7 +153,7 @@ QgsRasterCalculator::Result QgsRasterCalculator::processCalculation( QgsFeedback
return CreateOutputError;
}

GDALSetProjection( outputDataset.get(), mOutputCrs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ).toLocal8Bit().data() );
GDALSetProjection( outputDataset.get(), mOutputCrs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ).toLocal8Bit().data() );
GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset.get(), 1 );

float outputNodataValue = -FLT_MAX;
@@ -528,7 +528,7 @@ QgsRasterCalculator::Result QgsRasterCalculator::processCalculationGPU( std::uni
return CreateOutputError;
}

GDALSetProjection( outputDataset.get(), mOutputCrs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ).toLocal8Bit().data() );
GDALSetProjection( outputDataset.get(), mOutputCrs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ).toLocal8Bit().data() );


GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset.get(), 1 );
@@ -77,7 +77,7 @@ QgsDwgImporter::QgsDwgImporter( const QString &database, const QgsCoordinateRefe
{
QgsDebugCall;

QString crswkt( crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) );
QString crswkt( crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ) );
mCrsH = OSRNewSpatialReference( crswkt.toLocal8Bit().constData() );
QgsDebugMsg( QStringLiteral( "CRS %1[%2]: %3" ).arg( mCrs ).arg( ( qint64 ) mCrsH, 0, 16 ).arg( crswkt ) );
}
@@ -196,7 +196,7 @@ void QgsAlignRasterDialog::updateParametersFromReferenceLayer()
{
QgsCoordinateReferenceSystem refCRS( refInfo.crs() );
if ( refCRS != mCrsSelector->crs() )
customCRSWkt = mCrsSelector->crs( ).toWkt( QgsCoordinateReferenceSystem::WKT2_2018 );
customCRSWkt = mCrsSelector->crs( ).toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL );
}

if ( mChkCustomCellSize->isChecked() )
@@ -313,7 +313,7 @@ void QgsAlignRasterDialog::referenceLayerChanged()

void QgsAlignRasterDialog::destinationCrsChanged()
{
if ( mCrsSelector->crs().toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) == mAlign->destinationCrs() )
if ( mCrsSelector->crs().toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ) == mAlign->destinationCrs() )
return;

int index = mCboReferenceLayer->currentIndex();
@@ -132,8 +132,8 @@ void QgsCustomProjectionDialog::populateList()
crs.createFromProj( parameters );

mExistingCRSnames[id] = name;
const QString actualWkt = crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, false );
const QString actualWktFormatted = crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, true );
const QString actualWkt = crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, false );
const QString actualWktFormatted = crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true );
const QString actualProj = crs.toProj();
mExistingCRSwkt[id] = wkt.isEmpty() ? QString() : actualWkt;
mExistingCRSproj[id] = wkt.isEmpty() ? actualProj : QString();
@@ -273,7 +273,7 @@ bool QgsCustomProjectionDialog::saveCrs( QgsCoordinateReferenceSystem crs, const
+ ",ellipsoid_acronym=" + ( !ellipsoidAcronym.isEmpty() ? QgsSqliteUtils::quotedString( ellipsoidAcronym ) : QStringLiteral( "''" ) )
+ ",parameters=" + ( !crs.toProj().isEmpty() ? QgsSqliteUtils::quotedString( crs.toProj() ) : QStringLiteral( "''" ) )
+ ",is_geo=0" // <--shamelessly hard coded for now
+ ",wkt=" + ( format == QgsCoordinateReferenceSystem::FormatWkt ? QgsSqliteUtils::quotedString( crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, false ) ) : QStringLiteral( "''" ) )
+ ",wkt=" + ( format == QgsCoordinateReferenceSystem::FormatWkt ? QgsSqliteUtils::quotedString( crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, false ) ) : QStringLiteral( "''" ) )
+ " where srs_id=" + QgsSqliteUtils::quotedString( id )
;
QgsDebugMsgLevel( sql, 4 );
@@ -298,7 +298,7 @@ bool QgsCustomProjectionDialog::saveCrs( QgsCoordinateReferenceSystem crs, const
if ( result != SQLITE_OK )
return false;
}
mExistingCRSwkt[id] = format == QgsCoordinateReferenceSystem::FormatWkt ? crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, false ) : QString();
mExistingCRSwkt[id] = format == QgsCoordinateReferenceSystem::FormatWkt ? crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, false ) : QString();
mExistingCRSproj[id] = format == QgsCoordinateReferenceSystem::FormatProj ? crs.toProj() : QString();
mExistingCRSnames[id] = name;

@@ -426,12 +426,12 @@ void QgsCustomProjectionDialog::pbnCopyCRS_clicked()
}

whileBlocking( mFormatComboBox )->setCurrentIndex( mFormatComboBox->findData( static_cast< int >( QgsCoordinateReferenceSystem::FormatWkt ) ) );
teParameters->setPlainText( srs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, true ) );
mDefinitions[leNameList->currentIndex().row()].wkt = srs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, false );
teParameters->setPlainText( srs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true ) );
mDefinitions[leNameList->currentIndex().row()].wkt = srs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, false );
mDefinitions[leNameList->currentIndex().row()].proj.clear();

leNameList->currentItem()->setText( QgisCrsParametersColumn, srs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, false ) );
leNameList->currentItem()->setData( 0, FormattedWktRole, srs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018, true ) );
leNameList->currentItem()->setText( QgisCrsParametersColumn, srs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, false ) );
leNameList->currentItem()->setData( 0, FormattedWktRole, srs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true ) );
}
}

@@ -491,7 +491,7 @@ void QgsCustomProjectionDialog::buttonBox_accepted()
{
ref = QStringLiteral( "ID[\"%1\",%2]" ).arg( authparts.at( 0 ), authparts.at( 1 ) );
}
if ( !ref.isEmpty() && crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ).contains( ref ) )
if ( !ref.isEmpty() && crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ).contains( ref ) )
{
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
tr( "Cannot save '%1' — the definition is equivalent to %2.\n\n(Try removing \"%3\" from the WKT definition.)" ).arg( def.name, crs.authid(), ref ) );
@@ -727,7 +727,7 @@ void QgsCustomProjectionDialog::formatChanged()
{
const QByteArray multiLineOption = QStringLiteral( "MULTILINE=YES" ).toLocal8Bit();
const char *const options[] = {multiLineOption.constData(), nullptr};
newFormatString = QString( proj_as_wkt( pjContext, crs.get(), PJ_WKT2_2018, options ) );
newFormatString = QString( proj_as_wkt( pjContext, crs.get(), PJ_WKT2_2019, options ) );
}
}
#else
@@ -345,7 +345,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::mapSettingsScope( const Qg
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_acronym" ), mapSettings.destinationCrs().projectionAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_ellipsoid" ), mapSettings.destinationCrs().ellipsoidAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_proj4" ), mapSettings.destinationCrs().toProj(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_wkt" ), mapSettings.destinationCrs().toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_wkt" ), mapSettings.destinationCrs().toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ), true ) );

// IMPORTANT: ANY CHANGES HERE ALSO NEED TO BE MADE TO QgsLayoutItemMap::createExpressionContext()
// (rationale is described in QgsLayoutItemMap::createExpressionContext() )
@@ -1592,7 +1592,7 @@ bool QgsLayoutExporter::georeferenceOutputPrivate( const QString &file, QgsLayou
}

if ( t )
GDALSetProjection( outputDS.get(), map->crs().toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ).toLocal8Bit().constData() );
GDALSetProjection( outputDS.get(), map->crs().toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ).toLocal8Bit().constData() );
}
CPLSetConfigOption( "GDAL_PDF_DPI", nullptr );

@@ -1515,7 +1515,7 @@ QgsExpressionContext QgsLayoutItemMap::createExpressionContext() const
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_acronym" ), mapCrs.projectionAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_ellipsoid" ), mapCrs.ellipsoidAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_proj4" ), mapCrs.toProj(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_wkt" ), mapCrs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_wkt" ), mapCrs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ), true ) );

QVariantList layersIds;
QVariantList layers;
@@ -59,7 +59,7 @@ bool QgsGdalLayerItem::setCrs( const QgsCoordinateReferenceSystem &crs )
if ( !hDS )
return false;

QString wkt = crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 );
QString wkt = crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL );
if ( GDALSetProjection( hDS.get(), wkt.toLocal8Bit().data() ) != CE_None )
{
QgsDebugMsg( QStringLiteral( "Could not set CRS" ) );
@@ -2954,7 +2954,7 @@ QgsGdalProvider *QgsGdalProviderMetadata::createRasterDataProvider(
}

GDALSetGeoTransform( dataset.get(), geoTransform );
GDALSetProjection( dataset.get(), crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ).toLocal8Bit().data() );
GDALSetProjection( dataset.get(), crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ).toLocal8Bit().data() );

QgsDataProvider::ProviderOptions providerOptions;
return new QgsGdalProvider( uri, providerOptions, true, dataset.release() );
@@ -253,7 +253,7 @@ QString QgsMemoryProvider::dataSourceUri( bool expandAuthConfig ) const
}
else
{
crsDef = QStringLiteral( "wkt:%1" ).arg( mCrs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) );
crsDef = QStringLiteral( "wkt:%1" ).arg( mCrs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) );
}
uri.addQueryItem( QStringLiteral( "crs" ), crsDef );
}
@@ -3514,7 +3514,7 @@ bool QgsOgrProviderUtils::createEmptyDataSource( const QString &uri,
mySpatialRefSys.validate();
}

QString myWkt = mySpatialRefSys.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 );
QString myWkt = mySpatialRefSys.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL );

if ( !myWkt.isNull() && myWkt.length() != 0 )
{
@@ -394,7 +394,7 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
}
else
{
srs.appendChild( doc.createTextNode( section.crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) ) );
srs.appendChild( doc.createTextNode( section.crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED_GDAL ) ) );
}
georeferencing.appendChild( srs );
}
@@ -1290,10 +1290,10 @@ QString QgsCoordinateReferenceSystem::userFriendlyIdentifier( IdentifierType typ
return description();
else if ( type == ShortString )
return QObject::tr( "Unknown CRS" );
else if ( !toWkt( WKT2_2018 ).isEmpty() )
else if ( !toWkt( WKT_PREFERRED ).isEmpty() )
return QObject::tr( "Unknown CRS: %1" ).arg(
type == MediumString ? ( toWkt( WKT2_2018 ).left( 50 ) + QString( QChar( 0x2026 ) ) )
: toWkt( WKT2_2018 ) );
type == MediumString ? ( toWkt( WKT_PREFERRED ).left( 50 ) + QString( QChar( 0x2026 ) ) )
: toWkt( WKT_PREFERRED ) );
else if ( !toProj().isEmpty() )
return QObject::tr( "Unknown CRS: %1" ).arg( type == MediumString ? ( toProj().left( 50 ) + QString( QChar( 0x2026 ) ) )
: toProj() );
@@ -1883,7 +1883,7 @@ bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSyste
if ( ( !d->mAuthId.isEmpty() || !srs.d->mAuthId.isEmpty() ) )
return d->mAuthId == srs.d->mAuthId;

return toWkt( WKT2_2018 ) == srs.toWkt( WKT2_2018 );
return toWkt( WKT_PREFERRED ) == srs.toWkt( WKT_PREFERRED );
}

bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &srs ) const
@@ -1911,11 +1911,11 @@ QString QgsCoordinateReferenceSystem::toWkt( WktVariant variant, bool multiline,
case WKT2_2015_SIMPLIFIED:
type = PJ_WKT2_2015_SIMPLIFIED;
break;
case WKT2_2018:
type = PJ_WKT2_2018;
case WKT2_2019:
type = PJ_WKT2_2019;
break;
case WKT2_2018_SIMPLIFIED:
type = PJ_WKT2_2018_SIMPLIFIED;
case WKT2_2019_SIMPLIFIED:
type = PJ_WKT2_2019_SIMPLIFIED;
break;
}

@@ -2043,7 +2043,7 @@ bool QgsCoordinateReferenceSystem::writeXml( QDomNode &node, QDomDocument &doc )
QDomElement srsElement = doc.createElement( QStringLiteral( "spatialrefsys" ) );

QDomElement wktElement = doc.createElement( QStringLiteral( "wkt" ) );
wktElement.appendChild( doc.createTextNode( toWkt( WKT2_2018 ) ) );
wktElement.appendChild( doc.createTextNode( toWkt( WKT_PREFERRED ) ) );
srsElement.appendChild( wktElement );

QDomElement proj4Element = doc.createElement( QStringLiteral( "proj4" ) );
@@ -2183,7 +2183,7 @@ void QgsCoordinateReferenceSystem::debugPrint()
QgsDebugMsg( "* Valid : " + ( d->mIsValid ? QString( "true" ) : QString( "false" ) ) );
QgsDebugMsg( "* SrsId : " + QString::number( d->mSrsId ) );
QgsDebugMsg( "* Proj4 : " + toProj() );
QgsDebugMsg( "* WKT : " + toWkt( WKT2_2018 ) );
QgsDebugMsg( "* WKT : " + toWkt( WKT_PREFERRED ) );
QgsDebugMsg( "* Desc. : " + d->mDescription );
if ( mapUnits() == QgsUnitTypes::DistanceMeters )
{
@@ -2227,7 +2227,7 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name, Format na
{
proj4String = toProj();
}
QString wktString = toWkt( WKT2_2018 );
QString wktString = toWkt( WKT_PREFERRED );

// ellipsoid acroynym column is incorrectly marked as not null in many crs database instances,
// hack around this by using an empty string instead
@@ -3465,7 +3465,7 @@ void QgsCoordinateReferenceSystem::pushRecentCoordinateReferenceSystem( const Qg
{
authids << c.authid();
proj << c.toProj();
wkt << c.toWkt( WKT2_2018 );
wkt << c.toWkt( WKT_PREFERRED );
}

QgsSettings settings;
@@ -658,8 +658,14 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
WKT1_ESRI, //!< WKT1 as traditionally output by ESRI software, deriving from OGC 99-049.
WKT2_2015, //!< Full WKT2 string, conforming to ISO 19162:2015(E) / OGC 12-063r5 with all possible nodes and new keyword names.
WKT2_2015_SIMPLIFIED, //!< Same as WKT2_2015 with the following exceptions: UNIT keyword used. ID node only on top element. No ORDER element in AXIS element. PRIMEM node omitted if it is Greenwich. ELLIPSOID.UNIT node omitted if it is UnitOfMeasure::METRE. PARAMETER.UNIT / PRIMEM.UNIT omitted if same as AXIS. AXIS.UNIT omitted and replaced by a common GEODCRS.UNIT if they are all the same on all axis.
WKT2_2018, //!< Full WKT2 string, conforming to ISO 19162:2018 / OGC 18-010, with all possible nodes and new keyword names. Non-normative list of differences: WKT2_2018 uses GEOGCRS / BASEGEOGCRS keywords for GeographicCRS.
WKT2_2018_SIMPLIFIED, //!< WKT2_2018 with the simplification rule of WKT2_SIMPLIFIED
WKT2_2018, //!< Alias for WKT2_2019
WKT2_2018_SIMPLIFIED, //!< Alias for WKT2_2019_SIMPLIFIED
WKT2_2019 = WKT2_2018, //!< Full WKT2 string, conforming to ISO 19162:2019 / OGC 18-010, with all possible nodes and new keyword names. Non-normative list of differences: WKT2_2019 uses GEOGCRS / BASEGEOGCRS keywords for GeographicCRS.
WKT2_2019_SIMPLIFIED = WKT2_2018_SIMPLIFIED, //!< WKT2_2019 with the simplification rule of WKT2_SIMPLIFIED

WKT_PREFERRED = WKT2_2019, //!< Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019, but may change in future versions.
WKT_PREFERRED_SIMPLIFIED = WKT2_2019_SIMPLIFIED, //!< Preferred simplified format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019_SIMPLIFIED, but may change in future versions.
WKT_PREFERRED_GDAL = WKT2_2019, //!< Preferred format for conversion of CRS to WKT for use with the GDAL library.
};

/**
@@ -178,6 +178,8 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData

mutable QString mProj4;

mutable QString mWkt

//! True if presence of an inverted axis needs to be recalculated
mutable bool mAxisInvertedDirty = false;

@@ -948,9 +948,9 @@ bool QgsCoordinateTransform::setFromCache( const QgsCoordinateReferenceSystem &s
return false;

const QString sourceKey = src.authid().isEmpty() ?
src.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) : src.authid();
src.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : src.authid();
const QString destKey = dest.authid().isEmpty() ?
dest.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) : dest.authid();
dest.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : dest.authid();

if ( sourceKey.isEmpty() || destKey.isEmpty() )
return false;
@@ -1034,9 +1034,9 @@ void QgsCoordinateTransform::addToCache()
return;

const QString sourceKey = d->mSourceCRS.authid().isEmpty() ?
d->mSourceCRS.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) : d->mSourceCRS.authid();
d->mSourceCRS.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : d->mSourceCRS.authid();
const QString destKey = d->mDestCRS.authid().isEmpty() ?
d->mDestCRS.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) : d->mDestCRS.authid();
d->mDestCRS.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : d->mDestCRS.authid();

if ( sourceKey.isEmpty() || destKey.isEmpty() )
return;
@@ -23,7 +23,7 @@

QString crsToKey( const QgsCoordinateReferenceSystem &crs )
{
return crs.authid().isEmpty() ? crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) : crs.authid();
return crs.authid().isEmpty() ? crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : crs.authid();
}

template<>

0 comments on commit e37310d

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