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

Remove support for the legacy Proj interface (Proj 4) #2162

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/build-and-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ runs:
else
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_LUAJIT=${LUAJIT_OPTION}"
fi
if [ -n "$USE_PROJ_LIB" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DUSE_PROJ_LIB=$USE_PROJ_LIB"
if [ -n "$WITH_PROJ" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_PROJ=$WITH_PROJ"
fi
if [ -n "$CPP_VERSION" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_CXX_STANDARD=$CPP_VERSION"
Expand Down
28 changes: 3 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,6 @@ jobs:
- uses: ./.github/actions/ubuntu-prerequisites
- uses: ./.github/actions/build-and-test

ubuntu20-pg15-clang10-proj6:
runs-on: ubuntu-20.04

env:
CC: clang-10
CXX: clang++-10
LUA_VERSION: 5.3
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 15
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/ubuntu-prerequisites
- uses: ./.github/actions/build-and-test

ubuntu20-pg15-clang10-noproj:
runs-on: ubuntu-20.04

Expand All @@ -186,7 +167,7 @@ jobs:
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 15
POSTGIS_VERSION: 3
USE_PROJ_LIB: off
WITH_PROJ: OFF
BUILD_TYPE: Debug
PSYCOPG: 2

Expand All @@ -205,7 +186,6 @@ jobs:
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 16
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

Expand Down Expand Up @@ -266,7 +246,7 @@ jobs:
- uses: ./.github/actions/ubuntu-prerequisites
- uses: ./.github/actions/build-and-test

ubuntu22-pg16-clang14-proj6:
ubuntu22-pg16-clang14-proj:
runs-on: ubuntu-22.04

env:
Expand All @@ -276,7 +256,6 @@ jobs:
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 16
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

Expand All @@ -295,7 +274,7 @@ jobs:
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 16
POSTGIS_VERSION: 3
USE_PROJ_LIB: off
WITH_PROJ: OFF
BUILD_TYPE: Debug
PSYCOPG: 2

Expand All @@ -314,7 +293,6 @@ jobs:
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 15
POSTGIS_VERSION: 3
USE_PROJ_LIB: 6
BUILD_TYPE: Debug
PSYCOPG: 2

Expand Down
43 changes: 9 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option(BUILD_TESTS "Build test suite" OFF)
option(BUILD_COVERAGE "Build with coverage" OFF)
option(WITH_LUA "Build with Lua support" ON)
option(WITH_LUAJIT "Build with LuaJIT support" OFF)
option(WITH_PROJ "Build with Projection support" ON)

if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed, please use a separate build directory like `mkdir build && cd build && cmake ..`")
Expand Down Expand Up @@ -57,8 +58,6 @@ option(EXTERNAL_PROTOZERO "Do not use the bundled protozero" OFF)
option(EXTERNAL_FMT "Do not use the bundled fmt" OFF)
option(EXTERNAL_CLI11 "Do not use the bundled CLI11" OFF)

set(USE_PROJ_LIB "auto" CACHE STRING "Which version of PROJ API to use: ('4', '6', 'off', or 'auto')")

if (NOT WIN32 AND NOT APPLE)
# No need for this path, just a workaround to make cmake work on all systems.
# Without this we need the PostgreSQL server libraries installed.
Expand Down Expand Up @@ -222,42 +221,18 @@ find_package(OpenCV QUIET OPTIONAL_COMPONENTS core imgcodecs imgproc)

set(LIBS ${Boost_LIBRARIES} ${PostgreSQL_LIBRARY} ${OSMIUM_LIBRARIES})

if (USE_PROJ_LIB STREQUAL "off")
message(STATUS "Proj library disabled (because USE_PROJ_LIB is set to 'off').")
else()
find_path(PROJ4_INCLUDE_DIR proj_api.h)
if (PROJ4_INCLUDE_DIR AND NOT USE_PROJ_LIB STREQUAL "6")
message(STATUS "Found proj_api.h")
find_library(PROJ_LIBRARY NAMES proj)
message(STATUS "Found Proj [API 4] ${PROJ_LIBRARY}")
add_definitions(-DHAVE_GENERIC_PROJ=4)
set(HAVE_PROJ4 1)
if (WITH_PROJ)
find_path(PROJ6_INCLUDE_DIR proj.h)
find_library(PROJ_LIBRARY NAMES proj)
if (PROJ_LIBRARY)
message(STATUS "Found Proj ${PROJ_LIBRARY}")
add_definitions(-DHAVE_GENERIC_PROJ=6)
set(HAVE_PROJ6 1)
list(APPEND LIBS ${PROJ_LIBRARY})
include_directories(SYSTEM ${PROJ4_INCLUDE_DIR})
elseif (NOT USE_PROJ_LIB STREQUAL "4")
find_path(PROJ6_INCLUDE_DIR proj.h)
find_library(PROJ_LIBRARY NAMES proj)
if (PROJ_LIBRARY)
message(STATUS "Found Proj [API 6] ${PROJ_LIBRARY}")
add_definitions(-DHAVE_GENERIC_PROJ=6)
set(HAVE_PROJ6 1)
list(APPEND LIBS ${PROJ_LIBRARY})
include_directories(SYSTEM ${PROJ6_INCLUDE_DIR})
else()
message(STATUS "Proj library not found.")
message(STATUS " Only Mercartor and WGS84 projections will be available.")
endif()
include_directories(SYSTEM ${PROJ6_INCLUDE_DIR})
endif()
endif()

if (USE_PROJ_LIB STREQUAL "4" AND NOT HAVE_PROJ4)
message(FATAL_ERROR "USE_PROJ_LIB was set to '4', but PROJ version 4 API not found")
endif()

if (USE_PROJ_LIB STREQUAL "6" AND NOT HAVE_PROJ6)
message(FATAL_ERROR "USE_PROJ_LIB was set to '6', but PROJ version 6 API not found")
endif()

if (LUAJIT_FOUND)
list(APPEND LIBS ${LUAJIT_LIBRARIES})
elseif (LUA_FOUND)
Expand Down
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,9 @@ Note that `Debug` builds will be much slower than release build. For production
### Using the PROJ library

Osm2pgsql has builtin support for the Latlong (WGS84, EPSG:4326) and the
WebMercator (EPSG:3857) projection. If you need other projections you have to
compile with the PROJ library.

Both the older API (PROJ version 4) and the newer API (PROJ version 6.1 and
above) are supported. Usually the CMake configuration will find a suitable
version and use it automatically, but you can set the `USE_PROJ_LIB` CMake
cache variable to choose between the following behaviours:

* `4`: Look for PROJ library with API version 4. If it is not found, stop with
error.
* `6`: Look for PROJ library with API version 6. If it is not found, stop with
error.
* `off`: Build without PROJ library.
* `auto`: Choose API 4 if available, otherwise API 6. If both are not available
build without PROJ library. (This is the default.)
WebMercator (EPSG:3857) projection. Other projections are supported through
the [Proj library](https://proj.org/) which is used by default. Set the CMake
option `WITH_PROJ` to `OFF` to disable use of that library.

## Using LuaJIT

Expand Down
8 changes: 1 addition & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ endif()

target_sources(osm2pgsql_lib PRIVATE ${PROJECT_BINARY_DIR}/src/version.cpp)

if (HAVE_PROJ4)
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj4.cpp)
if (NOT MSVC)
set_source_files_properties(reprojection-generic-proj4.cpp
PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
endif()
elseif(HAVE_PROJ6)
if (HAVE_PROJ6)
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj6.cpp)
else()
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-none.cpp)
Expand Down
77 changes: 0 additions & 77 deletions src/reprojection-generic-proj4.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/reprojection-generic-proj6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@ std::shared_ptr<reprojection> reprojection::make_generic_projection(int srs)

std::string get_proj_version()
{
return fmt::format("[API 6] {}", proj_info().version);
return fmt::format("{}", proj_info().version);
}