Skip to content

Commit a4f723b

Browse files
committed
Remove support for the legacy Proj interface (Proj 4)
All major distributions have switched to newer versiosn long ago.
1 parent 8fd3324 commit a4f723b

File tree

7 files changed

+19
-161
lines changed

7 files changed

+19
-161
lines changed

.github/actions/build-and-test/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ runs:
2222
else
2323
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_LUAJIT=${LUAJIT_OPTION}"
2424
fi
25-
if [ -n "$USE_PROJ_LIB" ]; then
26-
CMAKE_OPTIONS="$CMAKE_OPTIONS -DUSE_PROJ_LIB=$USE_PROJ_LIB"
25+
if [ -n "$WITH_PROJ" ]; then
26+
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_PROJ=$WITH_PROJ"
2727
fi
2828
if [ -n "$CPP_VERSION" ]; then
2929
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_CXX_STANDARD=$CPP_VERSION"

.github/workflows/ci.yml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,6 @@ jobs:
157157
- uses: ./.github/actions/ubuntu-prerequisites
158158
- uses: ./.github/actions/build-and-test
159159

160-
ubuntu20-pg15-clang10-proj6:
161-
runs-on: ubuntu-20.04
162-
163-
env:
164-
CC: clang-10
165-
CXX: clang++-10
166-
LUA_VERSION: 5.3
167-
LUAJIT_OPTION: OFF
168-
POSTGRESQL_VERSION: 15
169-
POSTGIS_VERSION: 3
170-
USE_PROJ_LIB: 6
171-
BUILD_TYPE: Debug
172-
PSYCOPG: 2
173-
174-
steps:
175-
- uses: actions/checkout@v4
176-
- uses: ./.github/actions/ubuntu-prerequisites
177-
- uses: ./.github/actions/build-and-test
178-
179160
ubuntu20-pg15-clang10-noproj:
180161
runs-on: ubuntu-20.04
181162

@@ -186,7 +167,7 @@ jobs:
186167
LUAJIT_OPTION: OFF
187168
POSTGRESQL_VERSION: 15
188169
POSTGIS_VERSION: 3
189-
USE_PROJ_LIB: off
170+
WITH_PROJ: OFF
190171
BUILD_TYPE: Debug
191172
PSYCOPG: 2
192173

@@ -205,7 +186,6 @@ jobs:
205186
LUAJIT_OPTION: OFF
206187
POSTGRESQL_VERSION: 16
207188
POSTGIS_VERSION: 3
208-
USE_PROJ_LIB: 6
209189
BUILD_TYPE: Debug
210190
PSYCOPG: 2
211191

@@ -266,7 +246,7 @@ jobs:
266246
- uses: ./.github/actions/ubuntu-prerequisites
267247
- uses: ./.github/actions/build-and-test
268248

269-
ubuntu22-pg16-clang14-proj6:
249+
ubuntu22-pg16-clang14-proj:
270250
runs-on: ubuntu-22.04
271251

272252
env:
@@ -276,7 +256,6 @@ jobs:
276256
LUAJIT_OPTION: OFF
277257
POSTGRESQL_VERSION: 16
278258
POSTGIS_VERSION: 3
279-
USE_PROJ_LIB: 6
280259
BUILD_TYPE: Debug
281260
PSYCOPG: 2
282261

@@ -295,7 +274,7 @@ jobs:
295274
LUAJIT_OPTION: OFF
296275
POSTGRESQL_VERSION: 16
297276
POSTGIS_VERSION: 3
298-
USE_PROJ_LIB: off
277+
WITH_PROJ: OFF
299278
BUILD_TYPE: Debug
300279
PSYCOPG: 2
301280

@@ -314,7 +293,6 @@ jobs:
314293
LUAJIT_OPTION: OFF
315294
POSTGRESQL_VERSION: 15
316295
POSTGIS_VERSION: 3
317-
USE_PROJ_LIB: 6
318296
BUILD_TYPE: Debug
319297
PSYCOPG: 2
320298

CMakeLists.txt

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ option(BUILD_TESTS "Build test suite" OFF)
3030
option(BUILD_COVERAGE "Build with coverage" OFF)
3131
option(WITH_LUA "Build with Lua support" ON)
3232
option(WITH_LUAJIT "Build with LuaJIT support" OFF)
33+
option(WITH_PROJ "Build with Projection support" ON)
3334

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

60-
set(USE_PROJ_LIB "auto" CACHE STRING "Which version of PROJ API to use: ('4', '6', 'off', or 'auto')")
61-
6261
if (NOT WIN32 AND NOT APPLE)
6362
# No need for this path, just a workaround to make cmake work on all systems.
6463
# Without this we need the PostgreSQL server libraries installed.
@@ -222,42 +221,18 @@ find_package(OpenCV QUIET OPTIONAL_COMPONENTS core imgcodecs imgproc)
222221

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

225-
if (USE_PROJ_LIB STREQUAL "off")
226-
message(STATUS "Proj library disabled (because USE_PROJ_LIB is set to 'off').")
227-
else()
228-
find_path(PROJ4_INCLUDE_DIR proj_api.h)
229-
if (PROJ4_INCLUDE_DIR AND NOT USE_PROJ_LIB STREQUAL "6")
230-
message(STATUS "Found proj_api.h")
231-
find_library(PROJ_LIBRARY NAMES proj)
232-
message(STATUS "Found Proj [API 4] ${PROJ_LIBRARY}")
233-
add_definitions(-DHAVE_GENERIC_PROJ=4)
234-
set(HAVE_PROJ4 1)
224+
if (WITH_PROJ)
225+
find_path(PROJ6_INCLUDE_DIR proj.h)
226+
find_library(PROJ_LIBRARY NAMES proj)
227+
if (PROJ_LIBRARY)
228+
message(STATUS "Found Proj ${PROJ_LIBRARY}")
229+
add_definitions(-DHAVE_GENERIC_PROJ=6)
230+
set(HAVE_PROJ6 1)
235231
list(APPEND LIBS ${PROJ_LIBRARY})
236-
include_directories(SYSTEM ${PROJ4_INCLUDE_DIR})
237-
elseif (NOT USE_PROJ_LIB STREQUAL "4")
238-
find_path(PROJ6_INCLUDE_DIR proj.h)
239-
find_library(PROJ_LIBRARY NAMES proj)
240-
if (PROJ_LIBRARY)
241-
message(STATUS "Found Proj [API 6] ${PROJ_LIBRARY}")
242-
add_definitions(-DHAVE_GENERIC_PROJ=6)
243-
set(HAVE_PROJ6 1)
244-
list(APPEND LIBS ${PROJ_LIBRARY})
245-
include_directories(SYSTEM ${PROJ6_INCLUDE_DIR})
246-
else()
247-
message(STATUS "Proj library not found.")
248-
message(STATUS " Only Mercartor and WGS84 projections will be available.")
249-
endif()
232+
include_directories(SYSTEM ${PROJ6_INCLUDE_DIR})
250233
endif()
251234
endif()
252235

253-
if (USE_PROJ_LIB STREQUAL "4" AND NOT HAVE_PROJ4)
254-
message(FATAL_ERROR "USE_PROJ_LIB was set to '4', but PROJ version 4 API not found")
255-
endif()
256-
257-
if (USE_PROJ_LIB STREQUAL "6" AND NOT HAVE_PROJ6)
258-
message(FATAL_ERROR "USE_PROJ_LIB was set to '6', but PROJ version 6 API not found")
259-
endif()
260-
261236
if (LUAJIT_FOUND)
262237
list(APPEND LIBS ${LUAJIT_LIBRARIES})
263238
elseif (LUA_FOUND)

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,9 @@ Note that `Debug` builds will be much slower than release build. For production
171171
### Using the PROJ library
172172

173173
Osm2pgsql has builtin support for the Latlong (WGS84, EPSG:4326) and the
174-
WebMercator (EPSG:3857) projection. If you need other projections you have to
175-
compile with the PROJ library.
176-
177-
Both the older API (PROJ version 4) and the newer API (PROJ version 6.1 and
178-
above) are supported. Usually the CMake configuration will find a suitable
179-
version and use it automatically, but you can set the `USE_PROJ_LIB` CMake
180-
cache variable to choose between the following behaviours:
181-
182-
* `4`: Look for PROJ library with API version 4. If it is not found, stop with
183-
error.
184-
* `6`: Look for PROJ library with API version 6. If it is not found, stop with
185-
error.
186-
* `off`: Build without PROJ library.
187-
* `auto`: Choose API 4 if available, otherwise API 6. If both are not available
188-
build without PROJ library. (This is the default.)
174+
WebMercator (EPSG:3857) projection. Other projections are supported through
175+
the [Proj library](https://proj.org/) which is used by default. Set the CMake
176+
option `WITH_PROJ` to `OFF` to disable use of that library.
189177

190178
## Using LuaJIT
191179

src/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,7 @@ endif()
7272

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

75-
if (HAVE_PROJ4)
76-
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj4.cpp)
77-
if (NOT MSVC)
78-
set_source_files_properties(reprojection-generic-proj4.cpp
79-
PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
80-
endif()
81-
elseif(HAVE_PROJ6)
75+
if (HAVE_PROJ6)
8276
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj6.cpp)
8377
else()
8478
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-none.cpp)

src/reprojection-generic-proj4.cpp

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/reprojection-generic-proj6.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ std::shared_ptr<reprojection> reprojection::make_generic_projection(int srs)
119119

120120
std::string get_proj_version()
121121
{
122-
return fmt::format("[API 6] {}", proj_info().version);
122+
return fmt::format("{}", proj_info().version);
123123
}
124124

0 commit comments

Comments
 (0)