Skip to content

Commit

Permalink
Merge pull request #4373 from rouault/EMBED_RESOURCE_DIRECTORY
Browse files Browse the repository at this point in the history
Rename EMBED_GRIDS_DIRECTORY to EMBED_RESOURCE_DIRECTORY, and also embed .pol files
  • Loading branch information
rouault authored Jan 9, 2025
2 parents 081d12a + f509b3f commit f30c6a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/fedora_rawhide/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ CC=clang CXX=clang++ cmake .. \
make -j$(nproc)
ctest -j$(nproc)

# Try EMBED_GRIDS_DIRECTORY option
# Try EMBED_RESOURCE_DIRECTORY option
wget https://raw.githubusercontent.com/OSGeo/PROJ-data/refs/heads/master/us_nga/us_nga_egm96_15.tif
mkdir grids
mv us_nga_egm96_15.tif grids
echo "Build with -DEMBED_RESOURCE_FILES=ON -DEMBED_GRIDS_DIRECTORY=$PWD/grids"
CC=clang CXX=clang++ cmake .. -DEMBED_GRIDS_DIRECTORY=$PWD/grids
echo "Build with -DEMBED_RESOURCE_FILES=ON -DEMBED_RESOURCE_DIRECTORY=$PWD/grids"
CC=clang CXX=clang++ cmake .. -DEMBED_RESOURCE_DIRECTORY=$PWD/grids
make -j$(nproc)
rm -rf data
echo 49 2 0 | bin/cs2cs "WGS84 + EGM96 height" EPSG:4979
echo 49 2 0 | bin/cs2cs "WGS84 + EGM96 height" EPSG:4979 | grep 44.643 >/dev/null || (echo "Expected 49dN 2dE 44.643 as a result" && /bin/false)
echo 0 0 0 | bin/cct +init=ITRF2000:ITRF96
echo 0 0 0 | bin/cct +init=ITRF2000:ITRF96 | grep 0.0067 >/dev/null || (echo "Expected 0.0067 0.0061 -0.0185 as a result" && /bin/false)

echo "Build with -DEMBED_RESOURCE_FILES=ON -DEMBED_GRIDS_DIRECTORY=$PWD/grids -DUSE_ONLY_EMBEDDED_RESOURCE_FILES=ON"
CC=clang CXX=clang++ cmake .. -DEMBED_GRIDS_DIRECTORY=$PWD/grids -DUSE_ONLY_EMBEDDED_RESOURCE_FILES=ON
echo "Build with -DEMBED_RESOURCE_FILES=ON -DEMBED_RESOURCE_DIRECTORY=$PWD/grids -DUSE_ONLY_EMBEDDED_RESOURCE_FILES=ON"
CC=clang CXX=clang++ cmake .. -DEMBED_RESOURCE_DIRECTORY=$PWD/grids -DUSE_ONLY_EMBEDDED_RESOURCE_FILES=ON
make -j$(nproc)
rm -rf data
echo 49 2 0 | bin/cs2cs "WGS84 + EGM96 height" EPSG:4979
Expand Down
4 changes: 2 additions & 2 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ All cached entries can be viewed using ``cmake -LAH`` from a build directory.
Default is OFF for shared library builds (BUILD_SHARED_LIBS=ON), and ON
for static library builds (BUILD_SHARED_LIBS=OFF).

.. option:: EMBED_GRIDS_DIRECTORY=<directory>
.. option:: EMBED_RESOURCE_DIRECTORY=<directory>

.. versionadded:: 9.6

Embed files from <directory> ending with .tif or .json in the PROJ library itself.
Embed files from <directory> ending with .tif, .json or .pol in the PROJ library itself.

The pointed directory can potentially be the full PROJ-data package (uncompressed).
In that case, about 6 GB of free disk and 16 GB of RAM are required to build PROJ.
Expand Down
14 changes: 7 additions & 7 deletions src/lib_proj.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -430,20 +430,20 @@ if (EMBED_RESOURCE_FILES)
endif()
endif()

set(EMBED_GRIDS_DIRECTORY "" CACHE PATH "Directory that contains .tif and .json files to embed into libproj")
set(EMBED_RESOURCE_DIRECTORY "" CACHE PATH "Directory that contains .tif, .json or .pol files to embed into libproj")
set(FILES_TO_EMBED)
if (EMBED_GRIDS_DIRECTORY)
if (EMBED_RESOURCE_DIRECTORY)
if (NOT EMBED_RESOURCE_FILES)
message(FATAL_ERROR "EMBED_RESOURCE_FILES should be set to ON when EMBED_GRIDS_DIRECTORY is set")
message(FATAL_ERROR "EMBED_RESOURCE_FILES should be set to ON when EMBED_RESOURCE_DIRECTORY is set")
endif()

if (NOT IS_DIRECTORY ${EMBED_GRIDS_DIRECTORY})
message(FATAL_ERROR "${EMBED_GRIDS_DIRECTORY} is not a valid directory")
if (NOT IS_DIRECTORY ${EMBED_RESOURCE_DIRECTORY})
message(FATAL_ERROR "${EMBED_RESOURCE_DIRECTORY} is not a valid directory")
endif()

file(GLOB FILES_TO_EMBED "${EMBED_GRIDS_DIRECTORY}/*.tif" "${EMBED_GRIDS_DIRECTORY}/*.json")
file(GLOB FILES_TO_EMBED "${EMBED_RESOURCE_DIRECTORY}/*.tif" "${EMBED_RESOURCE_DIRECTORY}/*.json" "${EMBED_RESOURCE_DIRECTORY}/*.pol")
if (NOT FILES_TO_EMBED)
message(FATAL_ERROR "No .tif or .json files found in ${EMBED_GRIDS_DIRECTORY}")
message(FATAL_ERROR "No .tif, .json or .pol files found in ${EMBED_RESOURCE_DIRECTORY}")
endif()
endif()

Expand Down

0 comments on commit f30c6a4

Please sign in to comment.