Skip to content

Commit dcb4553

Browse files
committed
Port toProj4 to proj 6
1 parent b42b295 commit dcb4553

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/core/qgscoordinatereferencesystem.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -1064,10 +1064,17 @@ QString QgsCoordinateReferenceSystem::toProj4() const
10641064

10651065
if ( d->mProj4.isEmpty() )
10661066
{
1067+
#if PROJ_VERSION_MAJOR>=6
1068+
if ( d->mPj )
1069+
{
1070+
d->mProj4 = QString( proj_as_proj_string( QgsProjContext::get(), d->mPj.get(), PJ_PROJ_4, nullptr ) );
1071+
}
1072+
#else
10671073
char *proj4src = nullptr;
10681074
OSRExportToProj4( d->mCRS, &proj4src );
10691075
d->mProj4 = proj4src;
10701076
CPLFree( proj4src );
1077+
#endif
10711078
}
10721079
// Stray spaces at the end?
10731080
return d->mProj4.trimmed();
@@ -1231,8 +1238,6 @@ void QgsCoordinateReferenceSystem::setMapUnits()
12311238
return;
12321239
}
12331240

1234-
char *unitName = nullptr;
1235-
12361241
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,5,0)
12371242
// Of interest to us is that this call adds in a unit parameter if
12381243
// one doesn't already exist.
@@ -1287,6 +1292,8 @@ void QgsCoordinateReferenceSystem::setMapUnits()
12871292
}
12881293

12891294
#else
1295+
char *unitName = nullptr;
1296+
12901297
if ( OSRIsProjected( d->mCRS ) )
12911298
{
12921299
double toMeter = OSRGetLinearUnits( d->mCRS, &unitName );
@@ -1966,7 +1973,7 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )
19661973

19671974
int QgsCoordinateReferenceSystem::syncDatabase()
19681975
{
1969-
#if 1
1976+
#if 0
19701977
setlocale( LC_ALL, "C" );
19711978
QString dbFilePath = QgsApplication::srsDatabaseFilePath();
19721979
syncDatumTransform( dbFilePath );

0 commit comments

Comments
 (0)