Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
31a324b
worked on raster store arch
adam-ce Sep 6, 2026
4f730e6
Consolidate envelope implementation into envelope.h
adam-ce Sep 6, 2026
ed0905f
Document raster-store storage design and implementation plan
adam-ce Sep 8, 2026
cac8ff0
Implement persistent raster tile storage and snapshot publication
adam-ce Sep 10, 2026
d3d405e
Implement RF snapshot builder with validity, caching, and progress lo…
adam-ce Sep 10, 2026
8e7fe98
Accelerate RF mask selection with persistent point location and bound…
adam-ce Sep 10, 2026
a7257aa
Parallelize RF tile preparation and configure sanitizer exclusions
adam-ce Sep 11, 2026
d3c021c
Replace GDAL block-cache patch with TSan suppression
adam-ce Sep 11, 2026
cdf4d7e
Address RF record initialization warning and OpenCV UBSan failures
adam-ce Sep 12, 2026
48a8fa4
docs: design RF tile downloader import
adam-ce Sep 12, 2026
98f5584
Disable GCC 16 maybe-uninitialized warning in CI
adam-ce Sep 12, 2026
9bbf43d
Merge commit '327307a'
adam-ce Sep 12, 2026
b4f15b5
Add online tile import to RF builder
adam-ce Sep 12, 2026
3e99416
Add zpp::bits serialization adapters for GLM vectors and matrices
adam-ce Sep 13, 2026
982b56d
Use tile IDs and typed statuses in raster index entries
adam-ce Sep 13, 2026
ba4974c
Return raster storage handles with read-only metadata
adam-ce Sep 15, 2026
e52eedd
Merge raster storage metadata refactor into main
adam-ce Sep 15, 2026
e569459
Document raster scaling API and halo integration
adam-ce Sep 19, 2026
2a879d4
Implement validity-aware raster scaling algorithms
adam-ce Sep 21, 2026
8379540
Add raster views and composable pixel algorithms
adam-ce Sep 22, 2026
48d0616
Refactor raster scaling into view-based single-raster algorithms
adam-ce Sep 22, 2026
855a708
Implement raster tile halo extraction and windowed scaling
adam-ce Sep 22, 2026
e93be05
Fill GDAL RF import gaps with bounded interpolation and Gaussian smoo…
adam-ce Sep 23, 2026
c3bc9b0
Add raster fold and shared image I/O
adam-ce Sep 24, 2026
3918ca3
Use shared raster scaling for RF image fallback
adam-ce Sep 24, 2026
17d7567
Unify raster resampling and add Lanczos halo upscaling
adam-ce Sep 26, 2026
e9c3c1d
Finalize RF merger design and shared-function integration
adam-ce Sep 26, 2026
db134a6
Suppress OpenCV IPP color conversion function-type diagnostic
adam-ce Sep 28, 2026
50fc100
Add RF merger with topology partitioning and statistics
adam-ce Sep 28, 2026
87121c6
Add Error exceptions and port rf-merger to three-tier error handling
adam-ce Sep 29, 2026
f1d9334
Merge RF merger and three-tier error handling into main
adam-ce Sep 29, 2026
d9bb647
Plan envelope content hashes with XXH3-64
adam-ce Sep 30, 2026
451b2d4
Hash envelope payloads with XXH3-64 and expose envelope headers
adam-ce Sep 30, 2026
673f689
Merge envelope content hashes into main
adam-ce Sep 30, 2026
1a7488b
fix copyrights
adam-ce Sep 30, 2026
9c242fc
simplify error handling for TilePool
adam-ce Sep 30, 2026
0afd9bd
Merge branch 't3code/clean-up-rf-builder-errors'
adam-ce Sep 30, 2026
867d6c2
clean up docs
adam-ce Sep 30, 2026
d30576f
removed read with halo, the tools are better off with writing their o…
adam-ce Oct 2, 2026
0908ce7
Merge branch 't3code/assert-bug-unwrapping'
adam-ce Oct 2, 2026
b7ef1fd
update docs
adam-ce Oct 2, 2026
3ff910c
move non-template srs functions into srs.cpp
adam-ce Oct 2, 2026
df181dc
srs: return Expected from transformations instead of throwing
adam-ce Oct 2, 2026
6a414ef
Dataset: return Expected, add geodetic and mercator coverage
adam-ce Oct 2, 2026
2a410ef
remove bounds/switch to coverage, as bounds might break on the antime…
adam-ce Oct 3, 2026
b83dd65
remove more obsolete code
adam-ce Oct 3, 2026
91c51ae
Update Radix dependency
adam-ce Oct 3, 2026
779f315
min_pixel_size for DatasetReader
adam-ce Oct 3, 2026
47a90cf
fix 3d bounds lowest value
adam-ce Oct 4, 2026
d0c5a7a
Rename geodetic to geographic
adam-ce Oct 5, 2026
8e22cb7
Add ECEF-specific bounds coverage
adam-ce Oct 5, 2026
df44e5d
Reject out-of-world Mercator coverage
adam-ce Oct 5, 2026
7557d73
fix datum conversions (e.g. mgi uses a different ellipsoid -> normals…
adam-ce Oct 6, 2026
2f968d6
make sure axis mapping is correct, and degrees are used (no 0-100/400…
adam-ce Oct 6, 2026
e50a332
improve error handling
adam-ce Oct 6, 2026
dbf4ed8
Migrate SF coverage and cache projected bounds transformations
adam-ce Oct 6, 2026
fc82431
port rf-builder to the new coverage api
adam-ce Oct 6, 2026
19fd66a
move RasterTransform::tile_bounds to srs::webmercator_tile_bounds and…
adam-ce Oct 7, 2026
059d98a
remove remaining ctb
adam-ce Oct 7, 2026
d13421f
refactor of dataset Reader part one
adam-ce Oct 9, 2026
9499a09
move rf builder to DatasetReader
adam-ce Oct 11, 2026
4f508d3
move a bunch of stuff to gis:: (clean up)
adam-ce Oct 12, 2026
a6c6436
rename / cleanup the io::byte api
adam-ce Oct 12, 2026
179102d
replace store copy_from with link_from
adam-ce Oct 12, 2026
1c29b65
move CLI helpers to cli_support
adam-ce Oct 12, 2026
19419ec
share snapshot, input record and cache helpers
adam-ce Oct 12, 2026
55d849f
sf-builder: build into .part with cache instead of overwrite
adam-ce Oct 12, 2026
5d70e12
sf-merger: merge and cut into .part, cache instead of resume
adam-ce Oct 12, 2026
9c2cf99
dag-builder: build into .part with cache; remove allow_overwrite
adam-ce Oct 12, 2026
4cd5944
golden-e2e: resume through .part caches
adam-ce Oct 12, 2026
c490e4e
share --verbosity names, log file and assertion logging
adam-ce Oct 12, 2026
04aaba6
trim duplicated snapshot and cache tests
adam-ce Oct 12, 2026
f4c61f0
keep the input record until publication succeeded
adam-ce Oct 12, 2026
0096a6f
sf-merger: poll while linking unchanged subtrees
adam-ce Oct 12, 2026
a862c9e
accept snapshot paths with a trailing separator
adam-ce Oct 12, 2026
00aba65
envelope: rename read_from_path and write_to_path to read and write
adam-ce Oct 12, 2026
a5654f5
io: make the write mode explicit
adam-ce Oct 12, 2026
e0ba0fd
write payloads on the worker threads
adam-ce Oct 12, 2026
efcc45d
gis: new vector_mask API with load, transform and simplify
adam-ce Oct 12, 2026
b40383c
port sf_merger to new vector mask
adam-ce Oct 12, 2026
486dfc6
log: create the logger thread-safely
adam-ce Oct 12, 2026
8be0c92
log: make LOG_WARN_ONCE thread-safe
adam-ce Oct 12, 2026
031fede
log: make LOG_WARN_BACKOFF thread-safe
adam-ce Oct 12, 2026
9ab53a0
dag-builder: stop on write failures instead of exiting
adam-ce Oct 12, 2026
fd0d78b
io: replace index files atomically and durably
adam-ce Oct 12, 2026
1fc49f2
introduce node hashing and put them into the index
adam-ce Oct 13, 2026
fb9a6d9
add jpeg xl encoding (amoit codec), selected automatically for rgb 8 …
adam-ce Oct 13, 2026
30e53cf
Support embedding terrainlib in tile-foundry
adam-ce Oct 13, 2026
5cdca6d
Merge branch 'AlpineMapsOrg:main' into main
adam-ce Oct 13, 2026
95a2e50
Disable libjxl fuzzers and remove obsolete sampling documentation
adam-ce Oct 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
build_type: Release
sanitizer: normal
warnings_as_errors: ON
cmake_flags: ""
cmake_flags: -DCMAKE_CXX_FLAGS=-Wno-maybe-uninitialized
- name: clang-23-asan
cc: clang-23
cxx: clang++-23
Expand Down Expand Up @@ -188,13 +188,14 @@ jobs:
export GDAL_DATA="${{ github.workspace }}/build/alp_external/gdal/share/gdal"
if [[ "${{ matrix.sanitizer }}" == "asan" ]]; then
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-23
export ASAN_OPTIONS="detect_leaks=1:halt_on_error=1"
export UBSAN_OPTIONS="halt_on_error=1:print_stacktrace=1:suppressions=${{ github.workspace }}/misc/suppression/ubsan.txt"
fi
if [[ "${{ matrix.sanitizer }}" == "tsan" ]]; then
export TSAN_OPTIONS="suppressions=${{ github.workspace }}/extern/tbb/cmake/suppressions/tsan.suppressions"
export TSAN_OPTIONS="suppressions=${{ github.workspace }}/misc/suppression/tsan.txt"
fi
status=0
./unittests/unittests_terrainlib "~mesh::clip_on_bounds benchmark" || status=$?
./unittests/unittests_tilebuilder || status=$?
./unittests/unittests_sfbuilder || status=$?
./unittests/unittests_dagbuilder || status=$?
./unittests/unittests_sfmerger || status=$?
Expand Down
94 changes: 12 additions & 82 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,89 +1,19 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.25)

project(alpine-terrain-builder LANGUAGES C CXX)

# Executable targets
option(ALP_BUILD_TILE_BUILDER "Build tile-builder" ON)
option(ALP_BUILD_SF_MERGER "Build sf-merger" ON)
option(ALP_BUILD_SF_BUILDER "Build sf-builder" ON)
option(ALP_BUILD_TILE_DOWNLOADER "Build tile-downloader" ON)
option(ALP_BUILD_MESH_CONVERT "Build mesh-convert" ON)
option(ALP_BUILD_SF_INDEX_BROWSER "Build sf-index-browser" ON)
option(ALP_BUILD_DAG_BUILDER "Build dag-builder" ON)
option(ALP_BUILD_DAG_CONVERT_DEBUG "Build dag-convert-debug" ON)
option(ALP_BUILD_SF_BROWSER "Build sf-browser" ON)
option(ALP_BUILD_UNITTESTS "Build unit tests for enabled components" ON)

# Project configuration
option(ALP_ENABLE_THREAD_SANITIZER "Compile with ThreadSanitizer enabled" OFF)
option(ALP_ENABLE_ADDRESS_SANITIZER "Compile with AddressSanitizer enabled" OFF)
option(ALP_ENABLE_OVERVIEW_READING "Enable GDAL overview reading (broken with newer GDAL versions)" OFF)
option(ALP_ENABLE_UNITY_BUILD "Enable unity (jumbo) builds to speed compilation" OFF)
option(ALP_WARNINGS_AS_ERRORS "Treat first-party compiler warnings as errors" OFF)

set(ALP_ENABLE_ASSERTS_DEFAULT OFF)
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
set(ALP_ENABLE_ASSERTS_DEFAULT ON)
endif()
option(ALP_ENABLE_ASSERTS "Do not define NDEBUG, i.e., enable asserts" ${ALP_ENABLE_ASSERTS_DEFAULT})

set(ALP_UNITY_BUILD_BATCH_SIZE 4 CACHE STRING "Number of source files per unity translation unit")
set(ALP_RELEASE_OPT_LEVEL "3" CACHE STRING "Optimization level (0=O0,1=O1,2=O2,3=O3)")
set(ALP_DEPENDENCIES_N_BUILD_JOBS "" CACHE STRING
"Maximum number of parallel jobs for independently built CMake dependencies")

# Unit-test configuration
option(ALP_UNITTESTS_EXTENDED "Perform extended unit tests (they take long)" OFF)
option(ALP_UNITTESTS_DEBUG_IMAGES "Output debug height images for visual comparison" OFF)
set(ALP_UNITTESTS_AUSTRIA_HIGHRES "" CACHE FILEPATH "Path to the high resolution Austrian terrain dataset")

if(ALP_ENABLE_ADDRESS_SANITIZER AND ALP_ENABLE_THREAD_SANITIZER)
message(FATAL_ERROR "Cannot enable both AddressSanitizer and ThreadSanitizer")
endif()

set(ALP_SANITIZER_FLAGS)
if(ALP_ENABLE_ADDRESS_SANITIZER)
message(STATUS "AddressSanitizer enabled")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(ALP_SANITIZER_FLAGS -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer -g)
add_compile_options(${ALP_SANITIZER_FLAGS})
add_link_options(${ALP_SANITIZER_FLAGS})
else()
message(WARNING "ALP_ENABLE_ADDRESS_SANITIZER set but compiler is not GCC/Clang; ignoring")
endif()
endif()

if(ALP_ENABLE_THREAD_SANITIZER)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
message(WARNING "ThreadSanitizer is not recommended with Release builds. Use Debug or RelWithDebInfo for accurate race detection.")
endif()
message(STATUS "ThreadSanitizer enabled")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(ALP_SANITIZER_FLAGS -fsanitize=thread -fno-omit-frame-pointer -fno-optimize-sibling-calls -g)
add_compile_options(${ALP_SANITIZER_FLAGS})
add_link_options(${ALP_SANITIZER_FLAGS})
else()
message(WARNING "ALP_ENABLE_THREAD_SANITIZER set but compiler is not GCC/Clang; ignoring")
endif()
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Using optimization level ${ALP_RELEASE_OPT_LEVEL}")
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-O${ALP_RELEASE_OPT_LEVEL}>)
endif()

# Compiler launchers must be configured before targets are created.
find_program(SCCACHE_PROGRAM sccache)
find_program(CCACHE_PROGRAM ccache)
if(SCCACHE_PROGRAM)
message(STATUS "Using sccache as compiler launcher: ${SCCACHE_PROGRAM}")
set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
elseif(CCACHE_PROGRAM)
message(STATUS "Using ccache as compiler launcher: ${CCACHE_PROGRAM}")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
option(ALP_BUILD_SF_MERGER "Build sf-merger" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_SF_BUILDER "Build sf-builder" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_TILE_DOWNLOADER "Build tile-downloader" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_MESH_CONVERT "Build mesh-convert" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_SF_INDEX_BROWSER "Build sf-index-browser" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_DAG_BUILDER "Build dag-builder" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_DAG_CONVERT_DEBUG "Build dag-convert-debug" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_SF_BROWSER "Build sf-browser" ${PROJECT_IS_TOP_LEVEL})
option(ALP_BUILD_UNITTESTS "Build unit tests for enabled components" ${PROJECT_IS_TOP_LEVEL})

include(cmake/ConfigureBuild.cmake)

include(cmake/AddRepo.cmake)
include(cmake/SetupCMakeProject.cmake)
Expand Down
45 changes: 0 additions & 45 deletions NOTICE

This file was deleted.

35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# alpine-terrain-builder

See the project [code style](docs/code-style.md) before contributing.

The RF import, merge, and image-export tools live in
[tile-foundry](https://github.com/AlpineMapsOrg/tile-foundry).
This repository provides their `terrainlib` dependency, including raster-store.

When included as a CMake subproject, tools and tests default to disabled.
Enable individual `ALP_BUILD_*` options explicitly when needed.

Sanitizer exclusions are maintained in `misc/suppression/`. CI's ASan job also
enables UBSan and loads [ubsan.txt](misc/suppression/ubsan.txt) for the known CGAL
arrangement downcasts and the ignored old Boolean value in
`set_with_guarantees()`. These exclusions leave those upstream issues unfixed;
address checks, leak detection and unrelated undefined-behavior checks remain
enabled.

To use the same UBSan exclusions locally, set these variables from the repository
root before running an ASan test executable:

```sh
export ASAN_OPTIONS="detect_leaks=1:halt_on_error=1"
export UBSAN_OPTIONS="halt_on_error=1:print_stacktrace=1:suppressions=$PWD/misc/suppression/ubsan.txt"
```

Ensure `llvm-symbolizer` is available on `PATH`, or set `ASAN_SYMBOLIZER_PATH` to
its absolute path, so the function-specific exclusion can match.

CI's TSan job loads [tsan.txt](misc/suppression/tsan.txt), containing the two
oneTBB initialization exclusions and GDAL's unlocked cache-head comparison in
`GDALRasterBlock::Touch()`. The GDAL race is accepted without patching the
dependency; the suppression matches any race with that function in its stack.
For local TSan tests, set this variable from the repository root:

```sh
export TSAN_OPTIONS="suppressions=$PWD/misc/suppression/tsan.txt"
```
70 changes: 70 additions & 0 deletions cmake/ConfigureBuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
include_guard(GLOBAL)

# Project configuration
option(ALP_ENABLE_THREAD_SANITIZER "Compile with ThreadSanitizer enabled" OFF)
option(ALP_ENABLE_ADDRESS_SANITIZER "Compile with AddressSanitizer enabled" OFF)
option(ALP_ENABLE_UNITY_BUILD "Enable unity (jumbo) builds to speed compilation" OFF)
option(ALP_WARNINGS_AS_ERRORS "Treat first-party compiler warnings as errors" OFF)

set(ALP_ENABLE_ASSERTS_DEFAULT OFF)
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
set(ALP_ENABLE_ASSERTS_DEFAULT ON)
endif()
option(ALP_ENABLE_ASSERTS "Do not define NDEBUG, i.e., enable asserts" ${ALP_ENABLE_ASSERTS_DEFAULT})

set(ALP_UNITY_BUILD_BATCH_SIZE 4 CACHE STRING "Number of source files per unity translation unit")
set(ALP_RELEASE_OPT_LEVEL "3" CACHE STRING "Optimization level (0=O0,1=O1,2=O2,3=O3)")
set(ALP_DEPENDENCIES_N_BUILD_JOBS "" CACHE STRING
"Maximum number of parallel jobs for independently built CMake dependencies")

# Unit-test configuration
option(ALP_UNITTESTS_EXTENDED "Perform extended unit tests (they take long)" OFF)
option(ALP_UNITTESTS_DEBUG_IMAGES "Output debug height images for visual comparison" OFF)

if(ALP_ENABLE_ADDRESS_SANITIZER AND ALP_ENABLE_THREAD_SANITIZER)
message(FATAL_ERROR "Cannot enable both AddressSanitizer and ThreadSanitizer")
endif()

set(ALP_SANITIZER_FLAGS)
if(ALP_ENABLE_ADDRESS_SANITIZER)
message(STATUS "AddressSanitizer enabled")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(ALP_SANITIZER_FLAGS -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer -g)
add_compile_options(${ALP_SANITIZER_FLAGS})
add_link_options(${ALP_SANITIZER_FLAGS})
else()
message(WARNING "ALP_ENABLE_ADDRESS_SANITIZER set but compiler is not GCC/Clang; ignoring")
endif()
endif()

if(ALP_ENABLE_THREAD_SANITIZER)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
message(WARNING "ThreadSanitizer is not recommended with Release builds. Use Debug or RelWithDebInfo for accurate race detection.")
endif()
message(STATUS "ThreadSanitizer enabled")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(ALP_SANITIZER_FLAGS -fsanitize=thread -fno-omit-frame-pointer -fno-optimize-sibling-calls -g)
add_compile_options(${ALP_SANITIZER_FLAGS})
add_link_options(${ALP_SANITIZER_FLAGS})
else()
message(WARNING "ALP_ENABLE_THREAD_SANITIZER set but compiler is not GCC/Clang; ignoring")
endif()
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Using optimization level ${ALP_RELEASE_OPT_LEVEL}")
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-O${ALP_RELEASE_OPT_LEVEL}>)
endif()

# Compiler launchers must be configured before targets are created.
find_program(SCCACHE_PROGRAM sccache)
find_program(CCACHE_PROGRAM ccache)
if(SCCACHE_PROGRAM)
message(STATUS "Using sccache as compiler launcher: ${SCCACHE_PROGRAM}")
set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
elseif(CCACHE_PROGRAM)
message(STATUS "Using ccache as compiler launcher: ${CCACHE_PROGRAM}")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
1 change: 1 addition & 0 deletions cmake/SetupGDAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function(alp_setup_gdal)
-DBUILD_CSHARP_BINDINGS=OFF
-DGDAL_USE_ICONV=OFF
-DGDAL_USE_EXTERNAL_LIBS=OFF
-DGDAL_USE_CURL=ON
-DGDAL_USE_GEOS=ON
-DGDAL_USE_SQLITE3=ON
"-DCMAKE_INSTALL_RPATH=\$ORIGIN/../../proj/lib"
Expand Down
59 changes: 59 additions & 0 deletions cmake/SetupJpegXL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#############################################################################
# AlpineMaps.org
# Copyright (C) 2026 Adam Celarek <family name at cg tuwien ac at>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#############################################################################

if(NOT COMMAND alp_setup_cmake_project)
include(${CMAKE_CURRENT_LIST_DIR}/SetupCMakeProject.cmake)
endif()

# libjxl installs only pkg-config files. JpegXL::jxl is therefore defined from
# the static libraries of the install, which also contains highway and brotli.
function(alp_setup_jpegxl version)
alp_setup_cmake_project(libjxl
URL https://github.com/libjxl/libjxl.git COMMITISH ${version}
CMAKE_ARGUMENTS
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DJPEGXL_ENABLE_TOOLS=OFF
-DJPEGXL_ENABLE_FUZZERS=OFF
-DJPEGXL_ENABLE_DOXYGEN=OFF
-DJPEGXL_ENABLE_MANPAGES=OFF
-DJPEGXL_ENABLE_BENCHMARK=OFF
-DJPEGXL_ENABLE_EXAMPLES=OFF
-DJPEGXL_ENABLE_JNI=OFF
-DJPEGXL_ENABLE_SJPEG=OFF
-DJPEGXL_ENABLE_OPENEXR=OFF
-DJPEGXL_ENABLE_TCMALLOC=OFF
-DJPEGXL_BUNDLE_LIBPNG=OFF
)

find_path(_alp_jpegxl_include_dir jxl/decode.h
PATHS "${ALP_libjxl_INSTALL_DIR}/include" NO_DEFAULT_PATH NO_CACHE REQUIRED)
# Static link order: dependents before their dependencies.
set(_alp_jpegxl_libraries)
foreach(_alp_name IN ITEMS jxl jxl_cms hwy brotlidec brotlienc brotlicommon)
find_library(_alp_jpegxl_${_alp_name} NAMES ${_alp_name}
PATHS "${ALP_libjxl_INSTALL_DIR}" PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH NO_CACHE REQUIRED)
list(APPEND _alp_jpegxl_libraries "${_alp_jpegxl_${_alp_name}}")
endforeach()

# Global, because static libraries pass their private link dependencies on to every linking directory.
add_library(JpegXL::jxl INTERFACE IMPORTED GLOBAL)
target_include_directories(JpegXL::jxl INTERFACE "${_alp_jpegxl_include_dir}")
target_compile_definitions(JpegXL::jxl INTERFACE JXL_STATIC_DEFINE JXL_CMS_STATIC_DEFINE)
target_link_libraries(JpegXL::jxl INTERFACE ${_alp_jpegxl_libraries})
endfunction()
2 changes: 1 addition & 1 deletion cmake/SetupOpenCV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function(alp_setup_opencv version)
-DWITH_OPENGL=OFF
-DWITH_GSTREAMER=OFF
-DWITH_FFMPEG=OFF
-DWITH_JPEG=ON -DWITH_PNG=ON -DWITH_TIFF=ON
-DWITH_JPEG=ON -DBUILD_JPEG=ON -DWITH_PNG=ON -DWITH_TIFF=ON
-DWITH_GTK=OFF -DWITH_QT=OFF
-DBUILD_LIST=core,imgproc,imgcodecs
)
Expand Down
16 changes: 16 additions & 0 deletions docs/adr/0001-shared-raster-attribution-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Share an attribution table across raster snapshots

RF snapshots normally share a source-attribution table. A TB receives an
independent copy beside its index with the same attribution numbering. This
allows compatible tiles to be hard-linked across RF and TB roots while the TB
can be transferred as one directory and remains valid after RF removal or
table edits. Lookup checks beside the index, then the index directory's parent
and grandparent, giving the nearest table precedence.

Independent numbering could assign the same index to different sources,
requiring attribution rasters to be rewritten when combining snapshots.
Preserving numbering avoids that rewrite. RF snapshots using a shared table
depend on it; a TB with its local copy is self-contained. Entries are maintained
manually and may be corrected or reused once the user knows that no retained
snapshot using that table refers to them. Removing an entry and shifting later
indices is forbidden. Tools do not edit entries; TB construction copies them.
11 changes: 11 additions & 0 deletions docs/adr/0002-native-raster-pixel-buffers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Store native raster pixel buffers inside the envelope

The first `.amort` format stores dimensions and the native element bytes of
the data and attribution rasters inside `io::envelope`. Supporting only x86
and the project's current unpadded GLM configuration lets one templated codec
preserve payload bits without per-component GLM serializers or an explicit
matrix of type instantiations. This binds the byte encoding to the supported
scalar representations and pixel layouts; it does not promise portability
to other layouts or architectures. Compile-time layout checks and read-time
byte-count checks enforce that representation, while the metadata retains the
payload-type identifier.
Loading