Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump minimum proj to 8.1 #60330

Merged
merged 11 commits into from
Jan 30, 2025
Merged
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ if(WITH_CORE)
# required
find_package(Proj REQUIRED)
message(STATUS "Found Proj: ${PROJ_VERSION} ${PROJ_DIR}")
if(PROJ_VERSION_MAJOR LESS 8 OR (PROJ_VERSION_MAJOR EQUAL 8 AND (PROJ_VERSION_MINOR LESS 1)))
message(FATAL_ERROR "Cannot build QGIS using Proj older than 8.1")
endif(PROJ_VERSION_MAJOR LESS 8 OR (PROJ_VERSION_MAJOR EQUAL 8 AND (PROJ_VERSION_MINOR LESS 1)))

nyalldawson marked this conversation as resolved.
Show resolved Hide resolved
find_package(GEOS REQUIRED)
message(STATUS "Found Geos: ${GEOS_VERSION} ${GEOS_DIR}")
find_package(GDAL REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Required build tools:
Required build dependencies:

* Qt >= 5.15.2
* Proj >= 7.2.0
* Proj >= 8.2.0
nyalldawson marked this conversation as resolved.
Show resolved Hide resolved
* GEOS >= 3.9
* Sqlite3 >= 3.0.0
* SpatiaLite >= 4.2.0
Expand Down
30 changes: 3 additions & 27 deletions cmake/FindProj.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ if(NOT PROJ_FOUND)
OR NOT CMAKE_FIND_FRAMEWORK)
SET (CMAKE_FIND_FRAMEWORK_save ${CMAKE_FIND_FRAMEWORK} CACHE STRING "" FORCE)
SET (CMAKE_FIND_FRAMEWORK "ONLY" CACHE STRING "" FORCE)
#FIND_PATH(PROJ_INCLUDE_DIR PROJ/proj_api.h)
FIND_LIBRARY(PROJ_LIBRARY PROJ)
IF (PROJ_LIBRARY)
# FIND_PATH doesn't add "Headers" for a framework
Expand All @@ -39,17 +38,11 @@ if(NOT PROJ_FOUND)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
ENDIF (APPLE)
FIND_PATH(PROJ_INCLUDE_DIR proj_api.h

FIND_PATH(PROJ_INCLUDE_DIR proj.h
"$ENV{INCLUDE}"
"$ENV{LIB_DIR}/include"
)
IF (NOT PROJ_INCLUDE_DIR)
FIND_PATH(PROJ_INCLUDE_DIR proj.h
"$ENV{INCLUDE}"
"$ENV{LIB_DIR}/include"
)
ENDIF (NOT PROJ_INCLUDE_DIR)
)

FIND_LIBRARY(PROJ_LIBRARY NAMES proj_i proj PATHS
"$ENV{LIB}"
Expand All @@ -67,23 +60,6 @@ if(NOT PROJ_FOUND)
STRING(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${proj_version}")
STRING(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${proj_version}")
STRING(CONCAT PROJ_VERSION_STR "(" ${PROJ_VERSION_MAJOR} "." ${PROJ_VERSION_MINOR} "." ${PROJ_VERSION_PATCH} ")")
IF ((PROJ_VERSION_MAJOR EQUAL 7) AND ((PROJ_VERSION_MINOR LESS 2) OR (PROJ_VERSION_MAJOR LESS 7)))
MESSAGE (FATAL_ERROR "Cannot build QGIS using Proj ${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH} Use 7.2.0 or higher.")
ENDIF ((PROJ_VERSION_MAJOR EQUAL 7) AND ((PROJ_VERSION_MINOR LESS 2) OR (PROJ_VERSION_MAJOR LESS 7)))
ELSE(EXISTS ${PROJ_INCLUDE_DIR}/proj.h AND EXISTS ${PROJ_INCLUDE_DIR}/proj_experimental.h)
FILE(READ ${PROJ_INCLUDE_DIR}/proj_api.h proj_version)
STRING(REGEX REPLACE "^.*PJ_VERSION ([0-9]+).*$" "\\1" PJ_VERSION "${proj_version}")

# This will break if 4.10.0 ever will be released (highly unlikely)
STRING(REGEX REPLACE "([0-9])([0-9])([0-9])" "\\1" PROJ_VERSION_MAJOR "${PJ_VERSION}")
STRING(REGEX REPLACE "([0-9])([0-9])([0-9])" "\\2" PROJ_VERSION_MINOR "${PJ_VERSION}")
STRING(REGEX REPLACE "([0-9])([0-9])([0-9])" "\\3" PROJ_VERSION_PATCH "${PJ_VERSION}")
STRING(CONCAT PROJ_VERSION_STR "(" ${PROJ_VERSION_MAJOR} "." ${PROJ_VERSION_MINOR} "." ${PROJ_VERSION_PATCH} ")")

# Minimum Proj version required is 4.9.3
IF ((PROJ_VERSION_MAJOR EQUAL 4) AND ((PROJ_VERSION_MINOR LESS 9) OR ((PROJ_VERSION_MINOR EQUAL 9) AND (PROJ_VERSION_PATCH LESS 3))))
MESSAGE(FATAL_ERROR "Found Proj: ${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH}. Cannot build QGIS using Proj older than 4.9.3.")
ENDIF((PROJ_VERSION_MAJOR EQUAL 4) AND ((PROJ_VERSION_MINOR LESS 9) OR ((PROJ_VERSION_MINOR EQUAL 9) AND (PROJ_VERSION_PATCH LESS 3))))
ENDIF(EXISTS ${PROJ_INCLUDE_DIR}/proj.h AND EXISTS ${PROJ_INCLUDE_DIR}/proj_experimental.h)
IF (NOT PROJ_FIND_QUIETLY)
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY} version ${PROJ_VERSION_MAJOR} ${PROJ_VERSION_STR}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,25 +850,13 @@ be returned.

In the case of a compound crs, this method will always return the datum ensemble for the horizontal component.

.. warning::

This method requires PROJ 8.0 or later

:raises QgsNotSupportedException: on QGIS builds based on PROJ 7 or earlier.

.. versionadded:: 3.20
%End

QString celestialBodyName() const;
%Docstring
Attempts to retrieve the name of the celestial body associated with the CRS (e.g. "Earth").

.. warning::

This method requires PROJ 8.1 or later

:raises QgsNotSupportedException: on QGIS builds based on PROJ 8.0 or earlier.

.. versionadded:: 3.20
%End

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ The map keys correspond to PROJ operation IDs.
%Docstring
Returns a list of all known celestial bodies.

.. warning::

This method requires PROJ 8.1 or later

:raises QgsNotSupportedException: on QGIS builds based on PROJ 8.0 or earlier.

.. versionadded:: 3.20
%End

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ plate-fixed.
.. versionadded:: 3.20
%End

QgsDatumEnsemble datumEnsemble() const throw( QgsNotSupportedException );
QgsDatumEnsemble datumEnsemble() const;
%Docstring
Attempts to retrieve datum ensemble details from the CRS.

Expand All @@ -850,25 +850,13 @@ be returned.

In the case of a compound crs, this method will always return the datum ensemble for the horizontal component.

.. warning::

This method requires PROJ 8.0 or later

:raises QgsNotSupportedException: on QGIS builds based on PROJ 7 or earlier.

.. versionadded:: 3.20
%End

QString celestialBodyName() const throw( QgsNotSupportedException );
QString celestialBodyName() const;
%Docstring
Attempts to retrieve the name of the celestial body associated with the CRS (e.g. "Earth").

.. warning::

This method requires PROJ 8.1 or later

:raises QgsNotSupportedException: on QGIS builds based on PROJ 8.0 or earlier.

.. versionadded:: 3.20
%End

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ The map keys correspond to PROJ operation IDs.
%Docstring
Returns a list of all known celestial bodies.

.. warning::

This method requires PROJ 8.1 or later

:raises QgsNotSupportedException: on QGIS builds based on PROJ 8.0 or earlier.

.. versionadded:: 3.20
%End

Expand Down
1 change: 0 additions & 1 deletion resources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ endif()

ADD_QGIS_RESOURCES("${CMAKE_CURRENT_SOURCE_DIR}" resources DEST_RESOURCE_FILES "${RESOURCES_FILES}")

message(STATUS "Using PROJ >= 6 srs database.")
set(SRSDB srs6.db)

add_custom_command(
Expand Down
12 changes: 0 additions & 12 deletions src/core/proj/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,13 +1431,9 @@ QString QgsCoordinateReferenceSystem::celestialBodyName() const
if ( !pj )
return QString();

#if PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR>=1)
PJ_CONTEXT *context = QgsProjContext::get();

return QString( proj_get_celestial_body_name( context, pj ) );
#else
throw QgsNotSupportedException( QObject::tr( "Retrieving celestial body requires a QGIS build based on PROJ 8.1 or later" ) );
#endif
}

void QgsCoordinateReferenceSystem::setCoordinateEpoch( double epoch )
Expand Down Expand Up @@ -1466,7 +1462,6 @@ QgsDatumEnsemble QgsCoordinateReferenceSystem::datumEnsemble() const
if ( !pj )
return res;

#if PROJ_VERSION_MAJOR>=8
PJ_CONTEXT *context = QgsProjContext::get();

QgsProjUtils::proj_pj_unique_ptr ensemble = QgsProjUtils::crsToDatumEnsemble( pj );
Expand Down Expand Up @@ -1498,9 +1493,6 @@ QgsDatumEnsemble QgsCoordinateReferenceSystem::datumEnsemble() const
res.mMembers << details;
}
return res;
#else
throw QgsNotSupportedException( QObject::tr( "Calculating datum ensembles requires a QGIS build based on PROJ 8.0 or later" ) );
#endif
}

QgsProjectionFactors QgsCoordinateReferenceSystem::factors( const QgsPoint &point ) const
Expand Down Expand Up @@ -1688,11 +1680,7 @@ void QgsCoordinateReferenceSystem::setProjString( const QString &proj4String )
{
#ifdef QGISDEBUG
const int errNo = proj_context_errno( ctx );
#if PROJ_VERSION_MAJOR>=8
QgsDebugError( QStringLiteral( "proj string rejected: %1" ).arg( proj_context_errno_string( ctx, errNo ) ) );
#else
QgsDebugError( QStringLiteral( "proj string rejected: %1" ).arg( proj_errno_string( errNo ) ) );
#endif
#endif
d->mIsValid = false;
}
Expand Down
17 changes: 2 additions & 15 deletions src/core/proj/qgscoordinatereferencesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,8 @@ class QgsProjOperation;
struct PJconsts;
typedef struct PJconsts PJ;

#if PROJ_VERSION_MAJOR>=8
struct pj_ctx;
typedef struct pj_ctx PJ_CONTEXT;
#else
struct projCtx_t;
typedef struct projCtx_t PJ_CONTEXT;
#endif
#endif

// forward declaration for sqlite3
Expand Down Expand Up @@ -776,24 +771,16 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
*
* \note In the case of a compound crs, this method will always return the datum ensemble for the horizontal component.
*
* \warning This method requires PROJ 8.0 or later
*
* \throws QgsNotSupportedException on QGIS builds based on PROJ 7 or earlier.
*
* \since QGIS 3.20
*/
QgsDatumEnsemble datumEnsemble() const SIP_THROW( QgsNotSupportedException );
QgsDatumEnsemble datumEnsemble() const;

/**
* Attempts to retrieve the name of the celestial body associated with the CRS (e.g. "Earth").
*
* \warning This method requires PROJ 8.1 or later
*
* \throws QgsNotSupportedException on QGIS builds based on PROJ 8.0 or earlier.
*
* \since QGIS 3.20
*/
QString celestialBodyName() const SIP_THROW( QgsNotSupportedException );
QString celestialBodyName() const;

/**
* Sets the coordinate \a epoch, as a decimal year.
Expand Down
4 changes: 0 additions & 4 deletions src/core/proj/qgscoordinatereferencesystemregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ QMap<QString, QgsProjOperation> QgsCoordinateReferenceSystemRegistry::projOperat

QList< QgsCelestialBody> QgsCoordinateReferenceSystemRegistry::celestialBodies() const
{
#if PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR>=1)
static QList< QgsCelestialBody > sCelestialBodies;
static std::once_flag initialized;
std::call_once( initialized, []
Expand Down Expand Up @@ -409,9 +408,6 @@ QList< QgsCelestialBody> QgsCoordinateReferenceSystemRegistry::celestialBodies()
} );

return sCelestialBodies;
#else
throw QgsNotSupportedException( QObject::tr( "Retrieving celestial bodies requires a QGIS build based on PROJ 8.1 or later" ) );
#endif
}

QSet<QString> QgsCoordinateReferenceSystemRegistry::authorities() const
Expand Down
4 changes: 0 additions & 4 deletions src/core/proj/qgscoordinatereferencesystemregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ class CORE_EXPORT QgsCoordinateReferenceSystemRegistry : public QObject
/**
* Returns a list of all known celestial bodies.
*
* \warning This method requires PROJ 8.1 or later
*
* \throws QgsNotSupportedException on QGIS builds based on PROJ 8.0 or earlier.
*
* \since QGIS 3.20
*/
QList< QgsCelestialBody > celestialBodies() const;
Expand Down
9 changes: 0 additions & 9 deletions src/core/proj/qgscoordinatetransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ bool QgsCoordinateTransform::isTransformationPossible( const QgsCoordinateRefere
if ( !source.isValid() || !destination.isValid() )
return false;

#if PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR>=1)
if ( source.celestialBodyName() != destination.celestialBodyName() )
return false;
#endif

return true;
}
Expand Down Expand Up @@ -788,9 +786,6 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *
#endif

// use proj4 to do the transform

// if the source/destination projection is lat/long, convert the points to radians
// prior to transforming
ProjData projData = d->threadLocalProjData();

int projResult = 0;
Expand Down Expand Up @@ -902,12 +897,8 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *

const QString dir = ( direction == Qgis::TransformDirection::Forward ) ? QObject::tr( "Forward transform" ) : QObject::tr( "Inverse transform" );

#if PROJ_VERSION_MAJOR>=8
PJ_CONTEXT *projContext = QgsProjContext::get();
const QString projError = !errorOccurredDuringFallbackOperation ? QString::fromUtf8( proj_context_errno_string( projContext, projResult ) ) : QObject::tr( "Fallback transform failed" );
#else
const QString projError = !errorOccurredDuringFallbackOperation ? QString::fromUtf8( proj_errno_string( projResult ) ) : QObject::tr( "Fallback transform failed" );
#endif

const QString msg = QObject::tr( "%1 (%2 to %3) of%4%5Error: %6" )
.arg( dir,
Expand Down
8 changes: 0 additions & 8 deletions src/core/proj/qgscoordinatetransform_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,7 @@ ProjData QgsCoordinateTransformPrivate::threadLocalProjData()
const int errNo = proj_context_errno( context );
if ( errNo )
{
#if PROJ_VERSION_MAJOR>=8
nonAvailableError = QString( proj_context_errno_string( context, errNo ) );
#else
nonAvailableError = QString( proj_errno_string( errNo ) );
#endif
}
else
{
Expand Down Expand Up @@ -473,11 +469,7 @@ ProjData QgsCoordinateTransformPrivate::threadLocalProjData()
const QStringList projErrors = errorLogger.errors();
if ( errNo )
{
#if PROJ_VERSION_MAJOR>=8
nonAvailableError = QString( proj_context_errno_string( context, errNo ) );
#else
nonAvailableError = QString( proj_errno_string( errNo ) );
#endif
}
else if ( !projErrors.empty() )
{
Expand Down
2 changes: 0 additions & 2 deletions src/core/proj/qgsellipsoidutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ QList<QgsEllipsoidUtils::EllipsoidDefinition> QgsEllipsoidUtils::definitions()
name.replace( '_', ' ' );
def.description = QStringLiteral( "%1 (%2:%3)" ).arg( name, authority, code );

#if PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR>=1)
def.celestialBodyName = proj_get_celestial_body_name( context, ellipsoid.get() );
#endif

double semiMajor, semiMinor, invFlattening;
int semiMinorComputed = 0;
Expand Down
4 changes: 0 additions & 4 deletions src/core/proj/qgsprojutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::crsToDatumEnsemble( const PJ *crs
if ( !crs )
return nullptr;

#if PROJ_VERSION_MAJOR>=8
PJ_CONTEXT *context = QgsProjContext::get();
QgsProjUtils::proj_pj_unique_ptr candidate = crsToHorizontalCrs( crs );
if ( !candidate ) // purely vertical CRS
Expand All @@ -350,9 +349,6 @@ QgsProjUtils::proj_pj_unique_ptr QgsProjUtils::crsToDatumEnsemble( const PJ *crs
return nullptr;

return QgsProjUtils::proj_pj_unique_ptr( proj_crs_get_datum_ensemble( context, candidate.get() ) );
#else
throw QgsNotSupportedException( QObject::tr( "Calculating datum ensembles requires a QGIS build based on PROJ 8.0 or later" ) );
#endif
}

void QgsProjUtils::proj_collecting_logger( void *user_data, int /*level*/, const char *message )
Expand Down
9 changes: 0 additions & 9 deletions src/core/proj/qgsprojutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ class CORE_EXPORT QgsProjUtils
*
* \note In the case of a compound \a crs, this method will always return the datum ensemble for the horizontal component.
*
* \warning This method requires PROJ 8.0 or later
*
* \throws QgsNotSupportedException on QGIS builds based on PROJ 7 or earlier.
*
* \since QGIS 3.20
*/
static proj_pj_unique_ptr crsToDatumEnsemble( const PJ *crs );
Expand Down Expand Up @@ -270,13 +266,8 @@ class CORE_EXPORT QgsProjUtils

#ifndef SIP_RUN

#if PROJ_VERSION_MAJOR>=8
struct pj_ctx;
typedef struct pj_ctx PJ_CONTEXT;
#else
struct projCtx_t;
typedef struct projCtx_t PJ_CONTEXT;
#endif

/**
* \class QgsProjContext
Expand Down
Loading
Loading