Skip to content

Commit 3bab21d

Browse files
committed
Fix crs export to wkt on proj 6
1 parent aa21d55 commit 3bab21d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/core/qgscoordinatereferencesystem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,12 +1369,21 @@ QString QgsCoordinateReferenceSystem::toWkt() const
13691369
{
13701370
if ( d->mWkt.isEmpty() )
13711371
{
1372+
#if PROJ_VERSION_MAJOR>=6
1373+
// TODO QGIS 4.0 - upgrade to wkt2 (this would be an API break).
1374+
if ( d->mPj )
1375+
{
1376+
const char *const options[] = {"MULTILINE=NO", "INDENTATION_WIDTH=0", nullptr};
1377+
d->mWkt = QString( proj_as_wkt( QgsProjContext::get(), d->mPj.get(), PJ_WKT1_GDAL, options ) );
1378+
}
1379+
#else
13721380
char *wkt = nullptr;
13731381
if ( OSRExportToWkt( d->mCRS, &wkt ) == OGRERR_NONE )
13741382
{
13751383
d->mWkt = wkt;
13761384
CPLFree( wkt );
13771385
}
1386+
#endif
13781387
}
13791388
return d->mWkt;
13801389
}

0 commit comments

Comments
 (0)