pax_global_header 0000666 0000000 0000000 00000000064 15203707011 0014506 g ustar 00root root 0000000 0000000 52 comment=1b536c34225191ba24a75a840f634d4a48c3b206
h3-4.5.0/ 0000775 0000000 0000000 00000000000 15203707011 0012026 5 ustar 00root root 0000000 0000000 h3-4.5.0/.clang-format 0000664 0000000 0000000 00000000133 15203707011 0014376 0 ustar 00root root 0000000 0000000 BasedOnStyle: Google
IndentWidth: 4
DerivePointerAlignment: false
PointerAlignment: Right
h3-4.5.0/.clang-tidy 0000664 0000000 0000000 00000002157 15203707011 0014067 0 ustar 00root root 0000000 0000000 ---
Checks: 'clang-diagnostic-*,clang-analyzer-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: isaachier
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
h3-4.5.0/.cmake-format.yaml 0000664 0000000 0000000 00000000030 15203707011 0015327 0 ustar 00root root 0000000 0000000 format:
tab_size: 4
h3-4.5.0/.github/ 0000775 0000000 0000000 00000000000 15203707011 0013366 5 ustar 00root root 0000000 0000000 h3-4.5.0/.github/workflows/ 0000775 0000000 0000000 00000000000 15203707011 0015423 5 ustar 00root root 0000000 0000000 h3-4.5.0/.github/workflows/cifuzz.yml 0000664 0000000 0000000 00000001231 15203707011 0017455 0 ustar 00root root 0000000 0000000 name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'h3'
dry-run: false
language: c
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'h3'
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v6
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
h3-4.5.0/.github/workflows/deploy-website.yml 0000664 0000000 0000000 00000001505 15203707011 0021103 0 ustar 00root root 0000000 0000000 name: deploy-website
on:
push:
branches:
- master
permissions:
contents: write
# This job installs dependencies, builds the website, and pushes it to `gh-pages`
jobs:
deploy-website:
name: Deploy website
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6.2.0
with:
node-version: '16'
- name: Website Build
working-directory: website
env:
MapboxAccessToken: ${{ secrets.MapboxAccessToken }}
run: |
yarn
yarn build
# Deploy the book's HTML to gh-pages branch
- name: GitHub Pages action
uses: peaceiris/actions-gh-pages@v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: website/build
cname: h3geo.org
h3-4.5.0/.github/workflows/test-bench.yml 0000664 0000000 0000000 00000001236 15203707011 0020204 0 ustar 00root root 0000000 0000000 name: test-bench
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
tests:
name: Benchmark ${{ matrix.compiler }}
runs-on: ubuntu-latest
env:
CC: ${{ matrix.compiler }}
strategy:
matrix:
compiler: [clang, gcc]
steps:
- uses: actions/checkout@v6
- name: Configure build
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_COUNTRY_BENCHMARKS=ON ..
- name: Build
run: |
cd build
make
- name: Run benchmarks
run: |
cd build
make benchmarks
h3-4.5.0/.github/workflows/test-fuzzer.yml 0000664 0000000 0000000 00000002654 15203707011 0020457 0 ustar 00root root 0000000 0000000 name: test-fuzzer
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
afl-tests:
name: AFL Fuzzer ${{ matrix.compiler }}
runs-on: ubuntu-latest
env:
CC: ${{ matrix.compiler }}
strategy:
matrix:
compiler: [clang, gcc]
steps:
- uses: actions/checkout@v6
- name: Configure build
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
- name: Build
run: |
cd build
make fuzzers
- name: Run fuzzers once
run: |
cd build
for fuzzer in bin/fuzzer*; do
echo $fuzzer
$fuzzer --generate inputData
$fuzzer inputData
done
libfuzzer-test:
name: LibFuzzer ${{ matrix.compiler }}
runs-on: ubuntu-latest
env:
CC: ${{ matrix.compiler }}
strategy:
matrix:
compiler: [clang]
steps:
- uses: actions/checkout@v6
- name: Configure build
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_LIBFUZZER=ON ..
- name: Build
run: |
cd build
make fuzzers
- name: Run fuzzers once
run: |
cd build
for fuzzer in bin/fuzzer*; do
echo $fuzzer
$fuzzer -runs=100000 -max_total_time=60 -timeout=300
done
h3-4.5.0/.github/workflows/test-linux.yml 0000664 0000000 0000000 00000012065 15203707011 0020266 0 ustar 00root root 0000000 0000000 name: test-linux
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
cmake:
name: CMake correctness checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Configure build
run: cmake -DAUDIT_SOURCE_FILE_LIST=ON .
gcc-tests:
name: gcc ${{ matrix.build_type }} ${{ matrix.runs_on }}
runs-on: ${{ matrix.runs_on }}
env:
CC: gcc
strategy:
matrix:
build_type: ["Debug", "Release"]
runs_on: ["ubuntu-latest", "ubuntu-22.04-arm"]
steps:
- uses: actions/checkout@v6
- name: Install Doxygen
run: |
sudo apt update
sudo apt-get install doxygen graphviz clang-format-14
- name: Configure build
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DWARNINGS_AS_ERRORS=ON .
- name: Formatting check
working-directory: build
run: |
clang-format-14 --version
make format
git diff --exit-code
- name: Build
working-directory: build
run: make
- name: binding-functions
working-directory: build
run: |
make binding-functions
test -s binding-functions
- name: Tests
working-directory: build
run: |
make test
sudo make install
# Note the packages aren't used to test the examples below
- name: Test packaging
working-directory: build
run: cpack -D CPACK_PACKAGE_CONTACT="Test build in CI"
- name: Examples
run: |
mkdir build/examples
cd build/examples
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../../examples
make
env CTEST_OUTPUT_ON_FAILURE=1 make test
clang-tests:
name: clang ${{ matrix.build_type }} ${{ matrix.runs_on }} ${{ matrix.compile_opt }}
runs-on: ${{ matrix.runs_on }}
env:
CC: clang
strategy:
matrix:
# See Clang docs for more information on the sanitizers:
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
compile_opt: ["", "-fsanitize=undefined,float-divide-by-zero -fno-sanitize-recover=undefined,float-divide-by-zero", "-fsanitize=memory -fno-sanitize-recover=memory", "-fsanitize=address -fno-sanitize-recover=address"]
build_type: ["Debug", "Release"]
runs_on: ["ubuntu-latest", "ubuntu-22.04-arm"]
exclude:
# TODO: Include msan on arm
- runs_on: ubuntu-22.04-arm
compile_opt: "-fsanitize=memory -fno-sanitize-recover=memory"
steps:
- uses: actions/checkout@v6
- name: Install Doxygen
run: |
sudo apt update
sudo apt-get install doxygen graphviz clang-format-14
- name: Configure build
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DWARNINGS_AS_ERRORS=ON -DCMAKE_C_FLAGS="${{ matrix.compile_opt }}" .
- name: Formatting check
working-directory: build
run: |
clang-format-14 --version
make format
git diff --exit-code
- name: Build
working-directory: build
run: make
- name: binding-functions
working-directory: build
run: |
make binding-functions
test -s binding-functions
- name: Tests
working-directory: build
run: |
make CTEST_OUTPUT_ON_FAILURE=1 test
sudo make install
# Note the packages aren't used to test the examples below
- name: Test packaging
working-directory: build
run: cpack -D CPACK_PACKAGE_CONTACT="Test build in CI"
- name: Examples
run: |
mkdir build/examples
cd build/examples
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_FLAGS="${{ matrix.compile_opt }}" ../../examples
make
env CTEST_OUTPUT_ON_FAILURE=1 make test
valgrind-tests:
name: Valgrind
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Valgrind
run: |
sudo apt update
sudo apt-get install valgrind
- name: Configure build
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DWRAP_VALGRIND=ON .
- name: Build
working-directory: build
run: make
- name: Tests
working-directory: build
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: make test-fast
coverage-tests:
name: Coverage
runs-on: ubuntu-latest
env:
CC: gcc
steps:
- uses: actions/checkout@v6
- name: Install lcov
run: |
sudo apt update
sudo apt-get install lcov
- name: Configure build
run: cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON -DWARNINGS_AS_ERRORS=ON -DH3_PREFIX=testprefix_ .
- name: Build
run: make
- name: Tests
run: make coverage
- uses: coverallsapp/github-action@master
with:
path-to-lcov: ./coverage.cleaned.info
github-token: ${{ secrets.GITHUB_TOKEN }}
h3-4.5.0/.github/workflows/test-macos.yml 0000664 0000000 0000000 00000002031 15203707011 0020221 0 ustar 00root root 0000000 0000000 name: test-macos
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
tests:
name: ${{ matrix.build_type }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-14, macos-15, macos-latest]
build_type: ["Debug", "Release"]
steps:
- uses: actions/checkout@v6
- name: Configure build
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} -DWARNINGS_AS_ERRORS=ON .
- name: Build
working-directory: build
run: make
- name: binding-functions
working-directory: build
run: |
make binding-functions
test -s binding-functions
- name: Tests
working-directory: build
run: |
make test
sudo make install
- name: Examples
run: |
mkdir build/examples
cd build/examples
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} ../../examples
make
make test
h3-4.5.0/.github/workflows/test-pkg-config.yml 0000664 0000000 0000000 00000002357 15203707011 0021156 0 ustar 00root root 0000000 0000000 name: test-pkg-config
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
pkg-config:
name: pkg-config on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Build and install
run: |
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release .
cmake --build build
sudo cmake --install build
- name: Validate h3.pc
run: |
pkg-config --validate h3
pkg-config --exists h3
pkg-config --modversion h3
- name: Write test program
run: |
cat > /tmp/test_h3.c << 'CEOF'
#include
#include
int main() {
printf("H3 %d.%d.%d\n", H3_VERSION_MAJOR, H3_VERSION_MINOR, H3_VERSION_PATCH);
return isValidCell(0) != 0;
}
CEOF
- name: Verify compilation fails without pkg-config
run: |
! cc /tmp/test_h3.c
- name: Compile and run with pkg-config
run: |
cc $(pkg-config --cflags h3) /tmp/test_h3.c $(pkg-config --libs h3) -o /tmp/test_h3
/tmp/test_h3
h3-4.5.0/.github/workflows/test-website.yml 0000664 0000000 0000000 00000001636 15203707011 0020573 0 ustar 00root root 0000000 0000000 name: test-website
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
tests:
name: Test Website and FOSSA
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6.2.0
with:
node-version: '16'
- name: Install FOSSA
run: |
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash
- name: Test Website Build
working-directory: website
env:
MapboxAccessToken: ${{ secrets.MapboxAccessToken }}
run: |
yarn
yarn build
- name: Formatting check
working-directory: website
run: |
yarn format
git diff --exit-code
- name: Submit FOSSA report
run: if [ -n "${{ secrets.FOSSA_API_KEY }}" ]; then fossa; fi
h3-4.5.0/.github/workflows/test-windows.yml 0000664 0000000 0000000 00000003752 15203707011 0020624 0 ustar 00root root 0000000 0000000 name: test-windows
on:
push:
branches: [master, stable-*]
pull_request:
branches: [master, stable-*]
jobs:
tests:
name: ${{ matrix.config }} ${{ matrix.arch }}
runs-on: windows-latest
env:
CC: cl.exe
CXX: cl.exe
strategy:
matrix:
config: [Release, Debug]
arch: [Win32, x64]
steps:
- uses: actions/checkout@v6
- uses: tlylt/install-graphviz@v1.0.0
- name: Configure build
shell: cmd
run: cmake -Bbuild -A ${{ matrix.arch }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} -DWARNINGS_AS_ERRORS=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON .
- name: Build
working-directory: build
run: cmake --build . --config ${{ matrix.config }}
- name: binding-functions
working-directory: build
run: |
cmake --build . --config ${{ matrix.config }} --target binding-functions
if ((Get-Item "binding-functions").Length -lt 10) { $host.SetShouldExit(1) }
- name: Tests
working-directory: build
shell: cmd
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest -C ${{ matrix.config }}
dllcompile:
name: DLL ${{ matrix.config }} ${{ matrix.arch }}
runs-on: windows-latest
env:
CC: cl.exe
CXX: cl.exe
strategy:
matrix:
config: [Release, Debug]
arch: [Win32, x64]
steps:
- uses: actions/checkout@v6
- uses: tlylt/install-graphviz@v1.0.0
- name: Configure build
shell: cmd
run: cmake -Bbuild -A ${{ matrix.arch }} -DWARNINGS_AS_ERRORS=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF .
- name: Build
working-directory: build
run: cmake --build . --config ${{ matrix.config }}
- name: binding-functions
working-directory: build
run: |
cmake --build . --config ${{ matrix.config }} --target binding-functions
if ((Get-Item "binding-functions").Length -lt 10) { $host.SetShouldExit(1) }
h3-4.5.0/.gitignore 0000664 0000000 0000000 00000002660 15203707011 0014022 0 ustar 00root root 0000000 0000000 # vi swap files
.*.swp
.cache/
# make depends files
*.depends
# built binaries
/bin/
/examples/bin/
/lib/
# Travis CI build directory
/build/
/build*/
# Local build directories
/Debug/
/Release/
# random temp files
.DS_Store
*.bak
### example C.gitignore ###
# Object files
*.o
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
# Docs builds
dev-docs/_build/
env_docs/
node_modules/
website/dist/
website/package-lock.json
website/.cache/
website/public/
# Generated Doxyfile
dev-docs/Doxyfile
# CMake generated
CMakeFiles
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
Makefile
cmake_install.cmake
install_manifest.txt
cmake-build-debug/
generated/
h3Config.cmake
h3ConfigVersion.cmake
CMakeDoxyfile.in
CMakeDoxygenDefaults.cmake
DartConfiguration.tcl
compile_commands.json
RunCoverage.cmake
# Generated coverage runner
scripts/coverage.sh
# CTest / coverage
CTestTestfile.cmake
Testing/
coverage/
coverage.info
coverage.cleaned.info
# IDEs (CodeBlocks/CLion/VSCode)
*.cbp
.idea
.vscode
.ipynb_checkpoints
.claude
# Generated by `make binding-functions`
binding-functions
# These KML files are generated by `make kml`
KML/res*cells.kml
KML/res*centers.kml
# Generated files
src/h3lib/include/h3api.h
src/apps/benchmarks/benchmarkCountries.c
h3-prof.trace
h3-4.5.0/CHANGELOG.md 0000664 0000000 0000000 00000037631 15203707011 0013651 0 ustar 00root root 0000000 0000000 # Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The public API of this library consists of the functions declared in file
[h3api.h.in](./src/h3lib/include/h3api.h.in).
## [Unreleased]
## [4.5.0] - 2026-05-21
### Added
- `cellsToMultiPolygon` function (#1104, #1113)
- Internal for now, will be added to the public API in a future release
- `destroyGeoMultiPolygon` function (#1104)
- (internal) `geoLoopArea` function (#1101)
- `reverseDirectedEdge` function (#1098)
- Bidirectional `gridPathCells` (#1111)
- `h3.pc` pkg-config file (#1115)
### Changed
- `cellsToLinkedMultiPolygon` now uses `cellsToMultiPolygon` internally (#1126, #1133, #1136)
- `cellsToLinkedMultiPolygon` (and `cellsToMultiPolygon`) now return errors for invalid cells (`E_CELL_INVALID`), mixed resolutions (`E_RES_MISMATCH`), and duplicate cells (`E_DOMAIN`) instead of producing undefined output
- `cellAreaRads2` uses `geoLoopArea` (#1101)
- Refactor of indexing code to use Vec3d (#1145, #1155)
- Refactor of CoordIJK code to be inlineable (#1154)
### Fixed
- CLI handling of invalid cell input (#1125, #1124)
- `destroyLinkedMultiPolygon` is now idempotent (safe to call twice) (#1136)
## [4.4.1] - 2025-11-11
### Fixed
- Proper version set in `VERSION` file (#1091)
## [4.4.0] - 2025-11-06
### Added
- `getIndexDigit` function for inspecting specific index digits of an H3 index. (#1024, #1042)
- `isValidIndex` function (#1056, #1079)
- `constructCell` function (#1063, #1074, #1078)
- New `H3_INDEX_INVALID`, `E_BASE_CELL_DOMAIN`, `E_DIGIT_DOMAIN`, `E_DELETED_DIGIT` error codes and `H3_ERROR_END` (#1063, #1064, #1065)
### Changed
- Updated minimum version of macOS in CI. (#1069)
## [4.3.0] - 2025-06-17
### Added
- Added `gridRing` function, that works even if encountering pentagon distortion. (#1011, #1013, #1015)
## [4.2.1] - 2025-03-10
### Fixed
- Fixed MSVC/WIN32 checks in CMake. (#981)
- Fixed potential memory leak in `polygonStringToGeoPolygon` (#976)
### Changed
- Added arm64 tests in CI. (#975, #974)
- Faster `isValidCell` (#968)
- Moved `ContainmentMode` enum for `polygonToCellsExperimental` to `h3api.h`. (#958)
## [4.2.0] - 2024-12-04
### Added
- Added experimental new algorithm for `polygonToCells`, called `polygonToCellsExperimental`, that supports more containment flags and is more memory-efficient (#785, #800, #947)
- `h3` binary for shell scripts ready for use (#818, #826, #846, #923, #924, #931, #933)
### Fixed
- Fixed compacting all or many resolution 1 cells (#919)
### Changed
- `compactCells` internally uses int64 for array indexing. (#920)
- Reorganize tests into public / internal. (#762)
- Performance enhancement for aarch64, may improve other platforms (#790, #792, #852, #905, #913)
- `clang-format` upgraded to version 14. (#834)
- Fixed tests that incorrectly did not test resolution 15. (#820)
- Use `CMAKE_INSTALL_LIBDIR` when choosing where to install library files. (#819)
## [4.1.0] - 2023-01-18
### Added
- Functions for `cellToChildPos` and `childPosToCell` (#719)
### Fixed
- Fixed possible signed integer overflow in `h3NeighborRotations` (#707)
- Fixed possible signed integer overflow in `localIjToCell` (#706, #735)
### Changed
- `assert` on defensive code blocks that are not already covered. (#720)
- `clang-format` upgraded to version 11. (#734)
## [4.0.1] - 2022-09-15
### Fixed
- Changing an internal `float` to `double` improves the precision of geographic coordinate output (#652)
- Fixed compacting all children of a resolution 0 cell (#679)
- Fixed possible signed integer overflow in `maxGridDiskSize` (#686)
- Fixed possible use of uninitialized values in `cellToVertex` (#683, #690)
- Fixed possible out of bounds read in `localIjToCell` (#684)
- Fixed possible memory leak in `compactCells` (#685)
- Fixed possible out of bounds read in `areNeighborCells` (#677)
- Fixed possible memory leak in `cellsToLinkedMultiPolygon` (#673)
### Changed
- Build script does not use toolchain file (#641)
- Removed a duplicated include preprocessor directive (#682)
- Improvements to the fuzzer suite and their automatic runs in CI (#671, #674, #687)
- Increased test coverage (#642)
- Added a fuzzer targetting internal `algos.c` functions (#675)
## [4.0.0] - 2022-08-23
### Breaking changes
- Rename functions according to the terminology RFC (#622, #586, #571, #403, #466, #495, #466)
- Functions that can experience errors now have an `H3Error` return value. (#617, #586, #581, #551, #550, #509, #505, #507, #508, #503, #478, #468, #436, #359)
- Cell count parameters use `int64_t` instead of `int`.
- `polygonToCells` (previously `polyfill`) accepts a flags argument for future expansion. (#570)
- `cellToLocalIj` and `localIjToCell` accept a mode argument for future expansion. (#586)
- `exactEdgeLength` functions renamed to `edgeLength` (#639)
### Fixed
- Fix polyfill bug when vertex latitude exactly matches cell center. (#603)
- A number of issues detected via unit tests and fuzzers were fixed. (#568, #562, #558, #559, #560, #430)
- `polygonToCells` returns an error if Infinity is passed in. (#636)
### Changed
- The file `CMakeTests.cmake` is no longer included if `ENABLE_TESTING` is off. (#609)
### Added
- Vertex mode and associated functions: (#422, #420, #417)
- `cellToVertex(cell, vertexNum)`
- `cellToVertexes(cell, out)`
- `vertexToLatLng(vertex, out)`
- `isValidVertex(vertex)`
- `h3` CLI application. (#556, #497)
### Other changes
- Generally use `lng` instead of `lon`
- Closed-form implementation of `numHexagons`
- A number of fuzzer harnesses are now included in the H3 core library. (#557, #553, #545, #433)
- Additional benchmarks are added and benchmarks are regularly run in CI. (#524, #518)
## [4.0.0-rc5] - 2022-08-16
### Breaking changes
- `exactEdgeLength` functions renamed to `edgeLength` (#639)
### Fixed
- `polygonToCells` returns an error if Infinity is passed in. (#636)
## [4.0.0-rc4] - 2022-07-25
### Breaking changes
- `distance*` functions (`distanceKm`, etc) renamed to `greatCircleDistance*`. (#622)
- Error code `E_MEMORY` renamed to `E_MEMORY_ALLOC`. (#617)
## [4.0.0-rc3] - 2022-06-03
### Fixed
- Fix polyfill bug when vertex latitude exactly matches cell center. (#603)
### Changed
- The file `CMakeTests.cmake` is no longer included if `ENABLE_TESTING` is off. (#609)
## [4.0.0-rc2] - 2022-03-16
### Breaking changes
- `experimentalH3ToLocalIj` and `experimentalLocalIjToH3` renamed to `cellToLocalIj` and `localIjToCell` respectively. (#586)
- `cellToLocalIj` and `localIjToCell` accept a mode argument for future expansion. (#586)
- `cellToCenterChild` (previously `h3ToCenterChild`) returns an error code. (#581)
### Added
- `E_OPTION_INVALID` error code added. (#586)
## [4.0.0-rc1] - 2022-02-07
### Breaking changes
- Rename functions according to the terminology RFC (#571, #403, #466, #495, #466)
- Functions that can experience errors now have an `H3Error` return value. (#551, #550, #509, #505, #507, #508, #503, #478, #468, #436, #359)
- Cell count parameters use `int64_t` instead of `int`.
- `polygonToCells` (previously `polyfill`) accepts a flags argument for future expansion. (#570)
### Added
- Vertex mode and associated functions: (#422, #420, #417)
- `cellToVertex(cell, vertexNum)`
- `cellToVertexes(cell, out)`
- `vertexToLatLng(vertex, out)`
- `isValidVertex(vertex)`
- `h3` CLI application. (#556, #497)
### Fixed
- A number of issues detected via unit tests and fuzzers were fixed. (#568, #562, #558, #559, #560, #430)
### Other changes
- Generally use `lng` instead of `lon`
- Closed-form implementation of `numHexagons`
- A number of fuzzer harnesses are now included in the H3 core library. (#557, #553, #545, #433)
- Additional benchmarks are added and benchmarks are regularly run in CI. (#524, #518)
## [3.7.2] - 2021-07-15
### Fixed
- `gridDisk` of invalid indexes should not crash. (#498)
## [3.7.1] - 2020-10-05
### Fixed
- Finding invalid edge boundaries should not crash. (#399)
- Build fixes for FreeBSD. (#397)
## [3.7.0] - 2020-09-28
### Added
- Area and haversine distance functions (#377):
- `cellAreaRads2`
- `cellAreaKm2`
- `cellAreaM2`
- `pointDistRads`
- `pointDistKm`
- `pointDistM`
- `exactEdgeLengthRads`
- `exactEdgeLengthKm`
- `exactEdgeLengthM`
- Refactor `getH3UnidirectionalEdgeBoundary` for accuracy at small resolutions. (#391)
- Speeds up `getH3UnidirectionalEdgeBoundary` by about 3x.
- Implement core logic for future vertex mode.
### Fixed
- Fixed building the library with custom memory allocation functions on Mac OSX. (#362)
- The installed H3 CMake target should have include directories specified. (#381)
### Changed
- Tests now use `bash` on Windows. (#381)
## [3.6.4] - 2020-06-19
### Added
- `H3_MEMORY_PREFIX` CMake option for replacing the memory management functions used in H3. (#317)
- Support for building Debian packages of H3. (#352)
### Fixed
- Removed duplicate include statements. (#333)
- Fixed macro `H3_DIGIT_MASK_NEGATIVE`. (#329)
## Changed
- Again implement new `polyfill` algorithm. (#313)
## [3.6.3] - 2020-01-21
### Fixed
- `compact` detects and fails on cases with duplicated input indexes. (#299)
### Changed
- `h3IsValid` returns false for indexes that have non-zero reserved bits. (#300)
- `h3IsValid` and `h3UnidirectionalEdgeIsValid` return false for indexes with the high bit set. (#300)
## [3.6.2] - 2019-12-9
- Revert new `polyfill` algorithm until reported issues are fixed. (#293)
## [3.6.1] - 2019-11-11
### Fixed
- `compact` handles zero length input correctly. (#278)
- `bboxHexRadius` scaling factor adjusted to guarantee containment for `polyfill`. (#279)
- `polyfill` new algorithm for up to 3x perf boost. (#282)
- Fix CMake targets for KML generation. (#285)
## [3.6.0] - 2019-08-12
### Added
- `h3ToCenterChild` function to find center child at given resolution (#267)
- `getPentagonIndexes` (and `pentagonIndexCount`) function to find pentagons at given resolution (#267)
### Fixed
- Fix bounds check for local IJ coordinates (#271)
## [3.5.0] - 2019-07-22
### Added
- CMake options for excluding filter applications or benchmarks from the build. (#247)
- `h3GetFaces` function to find icosahedron faces for an index, and helper function `maxFaceCount` (#253)
### Changed
- Argument parsing for all filter applications is more flexible. (#238)
### Fixed
- Fix printing program name in `h3ToHier` error messages. (#254)
## [3.4.4] - 2019-05-30
### Changed
- Local coordinate spaces cannot cross more than one icosahedron edge. (#234)
- All dynamic internal memory allocations happen on the heap instead of the stack. (#235)
- Argument parsing for `h3ToGeo`, `geoToH3`, and `h3ToGeoBoundary` is more flexible. (#227)
## [3.4.3] - 2019-05-02
### Added
- `localIjToH3` filter application (#222)
- An option to print distances in the `kRing` filter application (#222)
### Changed
- Arguments parsing for `kRing` filter application is more flexible. (#224)
### Fixed
- `benchmarkPolyfill` allocates its memory on the heap (#198)
- Fixed constraints of vertex longitudes (#213)
- Zero only input to `uncompact` does not produce an error (#223)
## [3.4.2] - 2019-02-21
### Changed
- `binding-functions` build target generates an ASCII file on Windows (#193)
## [3.4.1] - 2019-02-15
### Fixed
- `binding-functions` build target fixed when running the build out of source (#188)
## [3.4.0] - 2019-01-23
### Added
- `getRes0Indexes` function for getting all base cells, and helper function `res0IndexCount` (#174)
- Include defined constants for current library version (#173)
## [3.3.0] - 2018-12-25
### Added
- `h3Line` and `h3LineSize` functions for getting the line of indexes between some start and end (inclusive) (#165)
### Changed
- Indexes in deleted pentagon subsequences are not considered valid.
## [3.2.0] - 2018-10-04
### Added
- `experimentalH3ToLocalIj` function for getting local coordinates for an index. (#102)
- `experimentalLocalIjToH3` function for getting an index from local coordinates. (#102)
- Benchmarks for the kRing method for k's of size 10, 20, 30, and 40. (#142, #144)
### Changed
- Internal `h3ToIjk` function renamed to `h3ToLocalIjk`. (#102)
- `h3ToIjk` filter application replaced with `h3ToLocalIj`. (#102)
### Fixed
- Added `#include ` to `benchmark.h` (#142)
## [3.1.1] - 2018-08-29
### Fixed
- Fixed bounding box bug for polygons crossing the antimeridian (#130)
- Normalize output of h3SetToMultiPolygon to align with the GeoJSON spec, ensuring that each polygon has only one outer loop, followed by holes (#131)
### Changed
- Longitude outputs are now guaranteed to be in the range [-Pi, Pi]. (#93)
- Implemented closed form formula for maxKringSize. Source: https://oeis.org/A003215 (#138)
- Improved test and benchmark harnesses (#126, #128)
## [3.1.0] - 2018-08-03
### Added
- `h3Distance` function for determining the grid distance between H3 indexes (#83)
- Internal `h3ToIjk` function for getting IJK+ coordinates from an index (#83)
- Internal `ijkDistance` function for determining the grid distance between IJK+ coordinates (#83)
- `h3ToIjk` filter application for experimenting with `h3ToIjk` (#83)
### Fixed
- Don't require a C++ compiler (#107)
### Changed
- Most dynamic internal memory allocations happen on the heap instead of the stack (#100)
## [3.0.8] - 2018-07-18
### Added
- Added Direction enum, replacing int and defined constants (#77)
### Fixed
- Ensured unused memory is cleared for pentagon children. (#84)
- Fixed compiler warnings in `h3ToGeoHier` and `h3ToGeoBoundaryHier`. (#90)
- Fixed a segfault in `h3SetToLinkedGeo` (#94)
### Changed
- Warnings are not errors by default. (#90)
## [3.0.7] - 2018-06-08
### Added
- Generator for the faceCenterPoint table (#67)
- Generator for number of indexes per resolution (#69)
- Added CMake `WARNINGS_AS_ERRORS` option, default on, for Clang and GCC (#70)
- Added CMake `TEST_WRAPPER` setting when `WRAP_VALGRIND` is on (#66)
### Changed
- Moved Vec3d structure to `vec3d.h` (#67)
- Added input validation when getting the origin or destination of an edge (#74)
## [3.0.6] - 2018-06-01
### Changed
- Changed signature of internal function h3NeighborRotations.
- Do not require support for `hexRange`, `hexRanges`, or `hexRangeDistances` in the bindings. These functions may be deprecated in the public API in future releases; consumers should use `kRing` and `kRingDistances` instead.
- Performance improvement in core indexing logic for `geoToH3` (thanks @wewei!)
## [3.0.5] - 2018-04-27
### Fixed
- Fixed duplicate vertex in h3ToGeoBoundary for certain class III hexagons (#46)
### Added
- Release guide
## [3.0.4] - 2018-04-16
### Added
- Assertions when allocating memory on the heap.
### Changed
- Most internal memory allocations happen on the stack instead of the heap.
## [3.0.3] - 2018-03-19
### Added
- CMake config installation to ease use of h3 from CMake projects.
- Add CMake toolchain file to set build options upfront.
- Add CMake `C_CLANG_TIDY` property to integrate clang-tidy checks during build.
- YouCompleteMe completion support.
### Changed
- Improved resilience to out of range inputs.
- Minimum CMake version to 3.1.
- Set `CMAKE_C_STANDARD` to `11` instead of using compiler flag `-std=c1x`.
- Use `CMAKE_POSITION_INDEPENDENT_CODE` instead of using compiler flag `-fPIC`.
- Rename library target from `h3.1` to `h3` with `SONAME` property of 1.
### Removed
- CMake `H3_COMPILER` option in favor of built-in `CMAKE_C_COMPILER`.
- CMake `BUILD_STATIC` option in favor of built-in `BUILD_SHARED_LIBS`.
- CMake `ENABLE_TESTS` option in favor of built-in `BUILD_TESTING`.
- File globbing in CMake in favor of listing source files.
## [3.0.2] - 2018-01-24
### Removed
- Removed the `H3IndexFat` internal structure.
### Changed
- Simplified build process on Windows.
### Fixed
- Fixed an issue where tests would fail on ARM systems.
## [3.0.1] - 2018-01-18
### Added
- Added a `make install` target.
### Changed
- Improved compatability with building on Windows.
- Fixed various cases where the test suite could crash or not compile.
## [3.0.0] - 2018-01-08
### Added
- First public release.
h3-4.5.0/CMakeLists.txt 0000664 0000000 0000000 00000076010 15203707011 0014572 0 ustar 00root root 0000000 0000000 # Copyright 2017-2022 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
cmake_minimum_required(VERSION 3.20) # Due to dependency on CMP0115
# Do not try to append extensions to source files
cmake_policy(SET CMP0115 NEW)
file(READ VERSION H3_VERSION LIMIT_COUNT 1)
# Clean any newlines
string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}")
# Remove any trailing qualifier
string(REGEX REPLACE "-.*$" "" H3_VERSION "${H3_VERSION}")
project(
h3
LANGUAGES C
VERSION ${H3_VERSION})
set(H3_PREFIX
""
CACHE STRING "Prefix for exported symbols")
set(H3_ALLOC_PREFIX
""
CACHE STRING "Prefix for allocation functions")
# Needed due to CMP0042
set(CMAKE_MACOSX_RPATH 1)
# YCM needs compilation database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Some misc apps do not work with shared libraries on Windows because they
# require access to internal H3 functions. Build these using either static
# libraries or an option to expose all function symbols.
if(NOT (WIN32 AND BUILD_SHARED_LIBS))
set(ENABLE_REQUIRES_ALL_SYMBOLS ON)
else()
set(ENABLE_REQUIRES_ALL_SYMBOLS OFF)
endif()
option(ENABLE_COVERAGE "Enable compiling tests with coverage." OFF)
option(BUILD_BENCHMARKS "Build benchmarking applications." ON)
option(ENABLE_COUNTRY_BENCHMARKS
"Build benchmarking applications with Natural Earth geometries." OFF)
option(BUILD_FUZZERS "Build fuzzer applications (for use with afl)." ON)
option(BUILD_FILTERS "Build filter applications." ON)
option(BUILD_GENERATORS "Build code generation applications." ON)
# If ON, libfuzzer settings are used to build the fuzzer harnesses. If OFF, a
# frontend for afl++ is provided instead.
option(ENABLE_LIBFUZZER "Build fuzzers with libFuzzer support." OFF)
# These options exist for integration with OSS-Fuzz, so that the fuzzer options
# can be passed through only to the fuzzer executables but not the H3 library,
# since passing those options to the library too may result in too many
# implementations of main in the fuzzer executables.
option(H3_FUZZER_NO_MAIN "Build fuzzers with no main." OFF)
mark_as_advanced(H3_FUZZER_NO_MAIN)
set(H3_FUZZER_EXTRA_OPTIONS
""
CACHE STRING "Extra compilation options for fuzzers particularly.")
mark_as_advanced(H3_FUZZER_EXTRA_OPTIONS)
if(WIN32)
# Use bash (usually from Git for Windows) for piping results
set(SHELL bash -c)
set(EXECUTABLE_OUTPUT_PATH bin)
set(LIBRARY_OUTPUT_PATH bin)
else()
set(SHELL sh -c)
set(EXECUTABLE_OUTPUT_PATH bin)
set(LIBRARY_OUTPUT_PATH lib)
endif()
string(REPLACE "." ";" H3_VERSION_LIST "${H3_VERSION}")
list(GET H3_VERSION_LIST 0 H3_VERSION_MAJOR)
list(GET H3_VERSION_LIST 1 H3_VERSION_MINOR)
list(GET H3_VERSION_LIST 2 H3_VERSION_PATCH)
set(H3_SOVERSION 1)
# Detect if someone else is including the package
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(H3_IS_ROOT_PROJECT ON)
endif()
set(H3_COMPILE_FLAGS "")
set(H3_LINK_FLAGS "")
option(ENABLE_WARNINGS "Enables compiler warnings" ON)
if(ENABLE_WARNINGS)
if(MSVC)
list(APPEND H3_COMPILE_FLAGS /W2)
else()
list(APPEND H3_COMPILE_FLAGS -Wall)
endif()
endif()
if(NOT MSVC)
# Compiler options are set only on non-Windows, since these options are not
# correct for MSVC.
list(
APPEND
H3_COMPILE_FLAGS
$<$:-gdwarf-2
-g3
-O0
-fno-inline
-fno-eliminate-unused-debug-types>)
if(ENABLE_COVERAGE)
list(APPEND H3_COMPILE_FLAGS $<$:--coverage>)
# --coverage is not passed to the linker, so this option is needed to
# fully enable coverage.
list(APPEND H3_LINK_FLAGS $<$:--coverage>)
endif()
if(ENABLE_LIBFUZZER)
list(APPEND H3_COMPILE_FLAGS -fsanitize=fuzzer,address,undefined)
list(APPEND H3_LINK_FLAGS -fsanitize=fuzzer,address,undefined)
endif()
endif()
option(WARNINGS_AS_ERRORS "Warnings are treated as errors" OFF)
if(WARNINGS_AS_ERRORS)
if(MSVC)
list(APPEND H3_COMPILE_FLAGS /WX)
else()
list(APPEND H3_COMPILE_FLAGS -Werror)
endif()
endif()
include(CMakeDependentOption)
include(CheckIncludeFile)
if(H3_IS_ROOT_PROJECT)
include(CTest)
endif()
set(LIB_SOURCE_FILES
src/h3lib/include/h3Assert.h
src/h3lib/include/alloc.h
src/h3lib/include/bbox.h
src/h3lib/include/polygon.h
src/h3lib/include/polygonAlgos.h
src/h3lib/include/polyfill.h
src/h3lib/include/h3Index.h
src/h3lib/include/directedEdge.h
src/h3lib/include/latLng.h
src/h3lib/include/vec2d.h
src/h3lib/include/vec3d.h
src/h3lib/include/linkedGeo.h
src/h3lib/include/localij.h
src/h3lib/include/baseCells.h
src/h3lib/include/faceijk.h
src/h3lib/include/vertex.h
src/h3lib/include/mathExtensions.h
src/h3lib/include/iterators.h
src/h3lib/include/constants.h
src/h3lib/include/coordijk.h
src/h3lib/include/algos.h
src/h3lib/include/adder.h
src/h3lib/include/area.h
src/h3lib/include/cellsToMultiPoly.h
src/h3lib/lib/h3Assert.c
src/h3lib/lib/algos.c
src/h3lib/lib/bbox.c
src/h3lib/lib/polygon.c
src/h3lib/lib/polyfill.c
src/h3lib/lib/h3Index.c
src/h3lib/lib/vec2d.c
src/h3lib/lib/vertex.c
src/h3lib/lib/linkedGeo.c
src/h3lib/lib/localij.c
src/h3lib/lib/latLng.c
src/h3lib/lib/directedEdge.c
src/h3lib/lib/mathExtensions.c
src/h3lib/lib/iterators.c
src/h3lib/lib/faceijk.c
src/h3lib/lib/baseCells.c
src/h3lib/lib/area.c
src/h3lib/lib/cellsToMultiPoly.c)
set(APP_SOURCE_FILES
src/apps/applib/include/kml.h
src/apps/applib/include/benchmark.h
src/apps/applib/include/utility.h
src/apps/applib/include/args.h
src/apps/applib/include/aflHarness.h
src/apps/applib/lib/kml.c
src/apps/applib/lib/utility.c
src/apps/applib/lib/args.c)
set(TEST_APP_SOURCE_FILES src/apps/applib/include/test.h
src/apps/applib/lib/test.c)
set(EXAMPLE_SOURCE_FILES
examples/index.c examples/distance.c examples/neighbors.c
examples/compactCells.c examples/edge.c)
set(H3_BIN_SOURCE_FILES src/apps/filters/h3.c)
set(OTHER_SOURCE_FILES
src/apps/filters/cellToLatLng.c
src/apps/filters/cellToLocalIj.c
src/apps/filters/localIjToCell.c
src/apps/filters/h3ToComponents.c
src/apps/filters/latLngToCell.c
src/apps/filters/cellToBoundary.c
src/apps/filters/gridDisk.c
src/apps/filters/gridDiskUnsafe.c
src/apps/testapps/testBaseCells.c
src/apps/testapps/testBaseCellsInternal.c
src/apps/testapps/testCompactCells.c
src/apps/testapps/testPolygonToCells.c
src/apps/testapps/testPolygonToCellsExperimental.c
src/apps/testapps/testPolygonToCellsReported.c
src/apps/testapps/testPolygonToCellsReportedExperimental.c
src/apps/testapps/testPentagonIndexes.c
src/apps/testapps/testGridDisk.c
src/apps/testapps/testGridDiskInternal.c
src/apps/testapps/testCellToBoundary.c
src/apps/testapps/testCellToBoundaryEdgeCases.c
src/apps/testapps/testCellToParent.c
src/apps/testapps/testH3Index.c
src/apps/testapps/testH3IndexInternal.c
src/apps/testapps/mkRandGeoBoundary.c
src/apps/testapps/testLatLngToCell.c
src/apps/testapps/testH3NeighborRotations.c
src/apps/testapps/testCellToChildrenSize.c
src/apps/testapps/testGridDisksUnsafe.c
src/apps/testapps/testCellToLatLng.c
src/apps/testapps/testCellToCenterChild.c
src/apps/testapps/testCellToChildren.c
src/apps/testapps/testCellToBBoxExhaustive.c
src/apps/testapps/testCellToChildPos.c
src/apps/testapps/testGetIcosahedronFaces.c
src/apps/testapps/testLatLng.c
src/apps/testapps/testLatLngInternal.c
src/apps/testapps/testGridRing.c
src/apps/testapps/testGridRingInternal.c
src/apps/testapps/testGridRingUnsafe.c
src/apps/testapps/testBBoxInternal.c
src/apps/testapps/testVertex.c
src/apps/testapps/testVertexInternal.c
src/apps/testapps/testVertexExhaustive.c
src/apps/testapps/testPolygonInternal.c
src/apps/testapps/testPolyfillInternal.c
src/apps/testapps/testVec2dInternal.c
src/apps/testapps/testVec3dInternal.c
src/apps/testapps/testVec3.c
src/apps/testapps/testDirectedEdge.c
src/apps/testapps/testDirectedEdgeExhaustive.c
src/apps/testapps/testLinkedGeoInternal.c
src/apps/testapps/testLinkedGeoConvert.c
src/apps/testapps/mkRandGeo.c
src/apps/testapps/testH3Api.c
src/apps/testapps/testIndexDigits.c
src/apps/testapps/testConstructCell.c
src/apps/testapps/testCellsToLinkedMultiPolygon.c
src/apps/testapps/testCellsToMultiPoly.c
src/apps/testapps/testCellsToMultiPolyInternal.c
src/apps/testapps/testCellToLocalIj.c
src/apps/testapps/testCellToLocalIjInternal.c
src/apps/testapps/testCellToLocalIjExhaustive.c
src/apps/testapps/testGridDistance.c
src/apps/testapps/testGridDistanceInternal.c
src/apps/testapps/testGridDistanceExhaustive.c
src/apps/testapps/testGridPathCells.c
src/apps/testapps/testGridPathCellsExhaustive.c
src/apps/testapps/testH3CellArea.c
src/apps/testapps/testH3CellAreaExhaustive.c
src/apps/testapps/testCoordIjInternal.c
src/apps/testapps/testCoordIjkInternal.c
src/apps/testapps/testH3Memory.c
src/apps/testapps/testH3IteratorsInternal.c
src/apps/testapps/testMathExtensionsInternal.c
src/apps/testapps/testDescribeH3Error.c
src/apps/testapps/testGeoLoopArea.c
src/apps/miscapps/cellToBoundaryHier.c
src/apps/miscapps/cellToLatLngHier.c
src/apps/miscapps/generateBaseCellNeighbors.c
src/apps/miscapps/generatePentagonDirectionFaces.c
src/apps/miscapps/generateFaceCenterPoint.c
src/apps/miscapps/h3ToHier.c
src/apps/fuzzers/fuzzerLatLngToCell.c
src/apps/fuzzers/fuzzerCellToLatLng.c
src/apps/fuzzers/fuzzerGridDisk.c
src/apps/fuzzers/fuzzerCellsToMultiPolygon.c
src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c
src/apps/fuzzers/fuzzerDistances.c
src/apps/fuzzers/fuzzerCellArea.c
src/apps/fuzzers/fuzzerEdgeLength.c
src/apps/fuzzers/fuzzerCellProperties.c
src/apps/fuzzers/fuzzerIndexIO.c
src/apps/fuzzers/fuzzerConstructCell.c
src/apps/fuzzers/fuzzerResolutions.c
src/apps/fuzzers/fuzzerHierarchy.c
src/apps/fuzzers/fuzzerVertexes.c
src/apps/fuzzers/fuzzerCompact.c
src/apps/fuzzers/fuzzerDirectedEdge.c
src/apps/fuzzers/fuzzerLocalIj.c
src/apps/fuzzers/fuzzerPolygonToCells.c
src/apps/fuzzers/fuzzerPolygonToCellsExperimental.c
src/apps/fuzzers/fuzzerPolygonToCellsNoHoles.c
src/apps/fuzzers/fuzzerPolygonToCellsExperimentalNoHoles.c
src/apps/fuzzers/fuzzerCellToChildPos.c
src/apps/fuzzers/fuzzerInternalAlgos.c
src/apps/fuzzers/fuzzerInternalCoordIjk.c
src/apps/benchmarks/benchmarkPolygonToCells.c
src/apps/benchmarks/benchmarkPolygonToCellsExperimental.c
src/apps/benchmarks/benchmarkPolygon.c
src/apps/benchmarks/benchmarkCellsToPolyAlgos.c
src/apps/benchmarks/benchmarkCellToChildren.c
src/apps/benchmarks/benchmarkGridDiskCells.c
src/apps/benchmarks/benchmarkGridPathCells.c
src/apps/benchmarks/benchmarkDirectedEdge.c
src/apps/benchmarks/benchmarkVertex.c
src/apps/benchmarks/benchmarkIsValidCell.c
src/apps/benchmarks/benchmarkH3Api.c
src/apps/benchmarks/benchmarkArea.c)
set(ALL_SOURCE_FILES
${LIB_SOURCE_FILES} ${APP_SOURCE_FILES} ${TEST_APP_SOURCE_FILES}
${H3_BIN_SOURCE_FILES} ${OTHER_SOURCE_FILES})
# This is done for quality control purposes (to detect if any source files are
# missing from our list), but is not done as the authoritative list as per CMake
# developer recommendations. See
# https://cmake.org/cmake/help/latest/command/file.html#glob-recurse
option(AUDIT_SOURCE_FILE_LIST
"Compare source file list against glob expression" OFF)
if(AUDIT_SOURCE_FILE_LIST)
file(
GLOB_RECURSE QA_SRC_SOURCE_FILES
RELATIVE "${CMAKE_SOURCE_DIR}"
"src/*.c" "src/*.h")
file(
GLOB_RECURSE QA_EXAMPLE_SOURCE_FILES
RELATIVE "${CMAKE_SOURCE_DIR}"
"examples/*.c" "examples/*.h")
foreach(QA_FILE IN LISTS QA_SRC_SOURCE_FILES)
if(NOT QA_FILE IN_LIST ALL_SOURCE_FILES)
message(FATAL_ERROR "${QA_FILE} not in ALL_SOURCE_FILES")
endif()
endforeach()
foreach(QA_FILE IN LISTS QA_EXAMPLE_SOURCE_FILES)
if(NOT QA_FILE IN_LIST EXAMPLE_SOURCE_FILES)
message(FATAL_ERROR "${QA_FILE} not in EXAMPLE_SOURCE_FILES")
endif()
endforeach()
endif()
set(UNCONFIGURED_API_HEADER src/h3lib/include/h3api.h.in)
set(CONFIGURED_API_HEADER src/h3lib/include/h3api.h)
configure_file(${UNCONFIGURED_API_HEADER} ${CONFIGURED_API_HEADER})
set(INSTALL_TARGETS)
function(add_h3_library name h3_alloc_prefix_override)
add_library(${name} ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER})
target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS})
target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS})
target_compile_features(${name} PUBLIC c_std_99)
find_library(M_LIB m)
if(NOT(M_LIB))
find_library(M_LIB m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
endif()
if(M_LIB)
target_link_libraries(${name} PUBLIC ${M_LIB})
endif()
if(BUILD_SHARED_LIBS)
set_target_properties(${name} PROPERTIES SOVERSION ${H3_SOVERSION})
target_compile_definitions(${name} PRIVATE BUILD_SHARED_LIBS=1)
endif()
if(ENABLE_COVERAGE)
target_compile_definitions(${name} PRIVATE H3_COVERAGE_TEST=1)
endif()
target_compile_definitions(${name} PUBLIC H3_PREFIX=${H3_PREFIX})
target_compile_definitions(${name} PRIVATE BUILDING_H3=1)
set(has_alloc_prefix NO)
if(h3_alloc_prefix_override)
set(has_alloc_prefix YES)
target_compile_definitions(
${name} PUBLIC H3_ALLOC_PREFIX=${h3_alloc_prefix_override})
elseif(H3_ALLOC_PREFIX)
set(has_alloc_prefix YES)
target_compile_definitions(${name}
PUBLIC H3_ALLOC_PREFIX=${H3_ALLOC_PREFIX})
endif()
# Mac OSX defaults to not looking up undefined symbols dynamically, so
# enable that explicitly. Windows needs something similar.
if(has_alloc_prefix AND APPLE)
target_link_libraries(${name} PRIVATE "-undefined dynamic_lookup")
elseif(has_alloc_prefix AND MSVC)
set(TARGET ${name} PROPERTY APPEND LINK_FLAGS "/FORCE:UNRESOLVED")
endif()
if(have_alloca)
target_compile_definitions(${name} PUBLIC H3_HAVE_ALLOCA)
endif()
if(have_vla)
target_compile_definitions(${name} PUBLIC H3_HAVE_VLA)
endif()
target_include_directories(
${name}
PUBLIC $
$)
endfunction()
# Build the H3 library
add_h3_library(h3 "")
# Automatic code formatting Give preference to clang-format-14
find_program(CLANG_FORMAT_PATH NAMES clang-format-14 clang-format)
cmake_dependent_option(
ENABLE_FORMAT "Enable running clang-format before compiling" ON
"CLANG_FORMAT_PATH" OFF)
if(ENABLE_FORMAT)
# Format
add_custom_target(
format
COMMAND ${CLANG_FORMAT_PATH} -style=file -i ${ALL_SOURCE_FILES}
${EXAMPLE_SOURCE_FILES} ${UNCONFIGURED_API_HEADER}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Formatting sources")
# Always do formatting
add_dependencies(h3 format)
elseif(NOT CLANG_FORMAT_PATH)
message(WARNING "clang-format was not detected, "
"so automatic source code reformatting is disabled")
endif()
option(ENABLE_LINTING "Run clang-tidy on source files" ON)
find_program(CLANG_TIDY_PATH "clang-tidy")
cmake_dependent_option(
ENABLE_LINTING "Enable running clang-tidy on sources during compilation" ON
"CLANG_TIDY_PATH" OFF)
if(ENABLE_LINTING)
set_target_properties(h3 PROPERTIES C_CLANG_TIDY "${CLANG_TIDY_PATH}")
elseif(NOT CLANG_TIDY_PATH)
message(WARNING "clang-tidy was not detected, "
"so source code linting is disabled")
endif()
# Docs
find_package(Doxygen)
option(ENABLE_DOCS "Enable building documentation." ON)
if(DOXYGEN_FOUND AND ENABLE_DOCS)
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_BINARY_DIR}/dev-docs/_build")
configure_file(dev-docs/Doxyfile.in dev-docs/Doxyfile ESCAPE_QUOTES)
add_custom_target(
docs ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/dev-docs/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dev-docs
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
else()
add_custom_target(
docs
echo
"Doxygen was not installed when CMake was run or ENABLE_DOCS was OFF. Check that Doxygen is installed and rerun `cmake .`"
VERBATIM)
endif()
# Metadata for bindings
if(WIN32)
add_custom_target(
binding-functions
COMMAND PowerShell -ExecutionPolicy Bypass -File
${CMAKE_CURRENT_SOURCE_DIR}/scripts/binding_functions.ps1
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_custom_target(
binding-functions
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/binding_functions.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
# Release publishing
add_custom_target(
update-version
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/update_version.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Link all executables against H3
macro(add_h3_executable name)
# invoke built-in add_executable
add_executable(${ARGV})
if(TARGET ${name})
target_link_libraries(${name} PUBLIC h3)
target_include_directories(
${name}
PUBLIC
$
)
target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS})
target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS})
if(ENABLE_COVERAGE)
target_compile_definitions(${name} PRIVATE H3_COVERAGE_TEST=1)
endif()
endif()
endmacro()
if(BUILD_FILTERS)
macro(add_h3_filter name)
add_h3_executable(${ARGV})
list(APPEND INSTALL_TARGETS ${name})
endmacro()
add_h3_filter(h3_bin src/apps/filters/h3.c ${APP_SOURCE_FILES})
set_target_properties(
h3_bin PROPERTIES OUTPUT_NAME h3) # Special logic for the `h3`
# executable
add_h3_filter(latLngToCell src/apps/filters/latLngToCell.c
${APP_SOURCE_FILES})
add_h3_filter(h3ToComponents src/apps/filters/h3ToComponents.c
${APP_SOURCE_FILES})
add_h3_filter(cellToLatLng src/apps/filters/cellToLatLng.c
${APP_SOURCE_FILES})
add_h3_filter(cellToLocalIj src/apps/filters/cellToLocalIj.c
${APP_SOURCE_FILES})
add_h3_filter(localIjToCell src/apps/filters/localIjToCell.c
${APP_SOURCE_FILES})
add_h3_filter(cellToBoundary src/apps/filters/cellToBoundary.c
${APP_SOURCE_FILES})
add_h3_filter(gridDiskUnsafe src/apps/filters/gridDiskUnsafe.c
${APP_SOURCE_FILES})
add_h3_filter(gridDisk src/apps/filters/gridDisk.c ${APP_SOURCE_FILES})
add_h3_filter(cellToBoundaryHier src/apps/miscapps/cellToBoundaryHier.c
${APP_SOURCE_FILES})
add_h3_filter(cellToLatLngHier src/apps/miscapps/cellToLatLngHier.c
${APP_SOURCE_FILES})
add_h3_filter(h3ToHier src/apps/miscapps/h3ToHier.c ${APP_SOURCE_FILES})
# Generate KML files for visualizing the H3 grid
add_custom_target(create-kml-dir COMMAND ${CMAKE_COMMAND} -E make_directory
KML)
add_custom_target(kml)
# Only the first 3 resolution grids are generated. The others can be
# generated, but the file sizes would be very, very large.
foreach(resolution RANGE 3)
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"KML/res${resolution}cells.kml")
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"KML/res${resolution}centers.kml")
add_custom_target(
kml_cells_${resolution}
COMMAND
${SHELL}
"$ -r ${resolution} | $ --kml --kml-name res${resolution}cells.kml --kml-description \"Res ${resolution} Cells\" > KML/res${resolution}cells.kml"
VERBATIM
DEPENDS create-kml-dir)
add_custom_target(
kml_centers_${resolution}
COMMAND
${SHELL}
"$ -r ${resolution} | $ --kml --kml-name res${resolution}centers.kml --kml-description \"Res ${resolution} Centers\" > KML/res${resolution}centers.kml"
VERBATIM
DEPENDS create-kml-dir)
add_dependencies(kml kml_cells_${resolution} kml_centers_${resolution})
endforeach()
endif()
if(BUILD_GENERATORS AND ENABLE_REQUIRES_ALL_SYMBOLS)
# Code generation
add_h3_executable(
generateBaseCellNeighbors src/apps/miscapps/generateBaseCellNeighbors.c
${APP_SOURCE_FILES})
add_h3_executable(
generateFaceCenterPoint src/apps/miscapps/generateFaceCenterPoint.c
${APP_SOURCE_FILES})
add_h3_executable(
generatePentagonDirectionFaces
src/apps/miscapps/generatePentagonDirectionFaces.c ${APP_SOURCE_FILES})
# Miscellaneous testing applications - generating random data
add_h3_executable(mkRandGeo src/apps/testapps/mkRandGeo.c
${APP_SOURCE_FILES})
add_h3_executable(mkRandGeoBoundary src/apps/testapps/mkRandGeoBoundary.c
${APP_SOURCE_FILES})
endif()
if(H3_IS_ROOT_PROJECT AND BUILD_TESTING)
include(CMakeTests.cmake)
endif()
if(BUILD_FUZZERS)
add_custom_target(fuzzers)
macro(add_h3_fuzzer name srcfile)
add_h3_executable(${name} ${srcfile} ${APP_SOURCE_FILES})
if(ENABLE_LIBFUZZER OR H3_FUZZER_NO_MAIN)
target_compile_definitions(${name} PRIVATE H3_USE_LIBFUZZER)
endif()
if(H3_FUZZER_EXTRA_OPTIONS)
target_compile_options(${name} PRIVATE ${H3_FUZZER_EXTRA_OPTIONS})
endif()
add_dependencies(fuzzers ${name})
endmacro()
add_h3_fuzzer(fuzzerLatLngToCell src/apps/fuzzers/fuzzerLatLngToCell.c)
add_h3_fuzzer(fuzzerCellToLatLng src/apps/fuzzers/fuzzerCellToLatLng.c)
add_h3_fuzzer(fuzzerGridDisk src/apps/fuzzers/fuzzerGridDisk.c)
add_h3_fuzzer(fuzzerCellsToMultiPolygon
src/apps/fuzzers/fuzzerCellsToMultiPolygon.c)
add_h3_fuzzer(fuzzerCellsToLinkedMultiPolygon
src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c)
add_h3_fuzzer(fuzzerDistances src/apps/fuzzers/fuzzerDistances.c)
add_h3_fuzzer(fuzzerCellArea src/apps/fuzzers/fuzzerCellArea.c)
add_h3_fuzzer(fuzzerEdgeLength src/apps/fuzzers/fuzzerEdgeLength.c)
add_h3_fuzzer(fuzzerCellProperties src/apps/fuzzers/fuzzerCellProperties.c)
add_h3_fuzzer(fuzzerIndexIO src/apps/fuzzers/fuzzerIndexIO.c)
add_h3_fuzzer(fuzzerConstructCell src/apps/fuzzers/fuzzerConstructCell.c)
add_h3_fuzzer(fuzzerResolutions src/apps/fuzzers/fuzzerResolutions.c)
add_h3_fuzzer(fuzzerHierarchy src/apps/fuzzers/fuzzerHierarchy.c)
add_h3_fuzzer(fuzzerVertexes src/apps/fuzzers/fuzzerVertexes.c)
add_h3_fuzzer(fuzzerCompact src/apps/fuzzers/fuzzerCompact.c)
add_h3_fuzzer(fuzzerDirectedEdge src/apps/fuzzers/fuzzerDirectedEdge.c)
add_h3_fuzzer(fuzzerLocalIj src/apps/fuzzers/fuzzerLocalIj.c)
add_h3_fuzzer(fuzzerPolygonToCells src/apps/fuzzers/fuzzerPolygonToCells.c)
add_h3_fuzzer(fuzzerPolygonToCellsExperimental
src/apps/fuzzers/fuzzerPolygonToCellsExperimental.c)
add_h3_fuzzer(fuzzerPolygonToCellsNoHoles
src/apps/fuzzers/fuzzerPolygonToCellsNoHoles.c)
add_h3_fuzzer(fuzzerPolygonToCellsExperimentalNoHoles
src/apps/fuzzers/fuzzerPolygonToCellsExperimentalNoHoles.c)
add_h3_fuzzer(fuzzerCellToChildPos src/apps/fuzzers/fuzzerCellToChildPos.c)
if(ENABLE_REQUIRES_ALL_SYMBOLS)
add_h3_fuzzer(fuzzerInternalAlgos
src/apps/fuzzers/fuzzerInternalAlgos.c)
add_h3_fuzzer(fuzzerInternalCoordIjk
src/apps/fuzzers/fuzzerInternalCoordIjk.c)
endif()
endif()
if(BUILD_BENCHMARKS)
# Benchmarks
add_custom_target(benchmarks)
macro(add_h3_benchmark name srcfile)
add_h3_executable(${name} ${srcfile} ${APP_SOURCE_FILES})
add_custom_target(bench_${name} COMMAND ${TEST_WRAPPER}
$)
add_dependencies(benchmarks bench_${name})
endmacro()
add_h3_benchmark(benchmarkH3Api src/apps/benchmarks/benchmarkH3Api.c)
add_h3_benchmark(benchmarkGridDiskCells
src/apps/benchmarks/benchmarkGridDiskCells.c)
add_h3_benchmark(benchmarkGridPathCells
src/apps/benchmarks/benchmarkGridPathCells.c)
add_h3_benchmark(benchmarkDirectedEdge
src/apps/benchmarks/benchmarkDirectedEdge.c)
add_h3_benchmark(benchmarkVertex src/apps/benchmarks/benchmarkVertex.c)
add_h3_benchmark(benchmarkIsValidCell
src/apps/benchmarks/benchmarkIsValidCell.c)
add_h3_benchmark(benchmarkCellsToPolyAlgos
src/apps/benchmarks/benchmarkCellsToPolyAlgos.c)
add_h3_benchmark(benchmarkCellToChildren
src/apps/benchmarks/benchmarkCellToChildren.c)
add_h3_benchmark(benchmarkPolygonToCells
src/apps/benchmarks/benchmarkPolygonToCells.c)
add_h3_benchmark(benchmarkPolygonToCellsExperimental
src/apps/benchmarks/benchmarkPolygonToCellsExperimental.c)
add_h3_benchmark(benchmarkArea
src/apps/benchmarks/benchmarkArea.c)
if(ENABLE_REQUIRES_ALL_SYMBOLS)
add_h3_benchmark(benchmarkPolygon
src/apps/benchmarks/benchmarkPolygon.c)
endif()
if(ENABLE_COUNTRY_BENCHMARKS)
# Country benchmark: Downloads country geometry and generates the
# benchmark file
add_custom_command(
OUTPUT src/apps/benchmarks/benchmarkCountries.c
COMMAND
node ${CMAKE_CURRENT_SOURCE_DIR}/scripts/make_countries.js
${CMAKE_CURRENT_BINARY_DIR}/src/apps/benchmarks/benchmarkCountries.c
)
add_h3_benchmark(
benchmarkCountries
${CMAKE_CURRENT_BINARY_DIR}/src/apps/benchmarks/benchmarkCountries.c
)
# add_dependencies(bench_benchmarkCountries )
endif()
endif()
# Installation (https://github.com/forexample/package-example)
# Layout. This works for all platforms: *
# //cmake/ *
# // * /include/
include(GNUInstallDirs)
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(include_install_dir "include")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# TODO: Unclear why this is needed to get the libh3 Debian package to build
# correctly with shared libraries.
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "libh3")
# Include module with fuction 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Configure 'ConfigVersion.cmake' Use: * PROJECT_VERSION
write_basic_package_version_file("${version_config}"
COMPATIBILITY SameMajorVersion)
# Configure 'Config.cmake' Use variables: * TARGETS_EXPORT_NAME *
# PROJECT_NAME
configure_package_config_file("cmake/Config.cmake.in" "${project_config}"
INSTALL_DESTINATION "${config_install_dir}")
# Targets: * //libh3.so * header location after
# install: /include/h3/h3api.h * headers can be included by C++ code
# `#include ` Installing the library and filters system-wide.
install(
TARGETS ${INSTALL_TARGETS}
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "bin"
COMPONENT h3)
install(
TARGETS h3
EXPORT "${TARGETS_EXPORT_NAME}"
COMPONENT libh3
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "bin"
INCLUDES
DESTINATION "${include_install_dir}")
# Headers: * src/h3lib/include/h3api.h -> /include/h3/h3api.h Only the
# h3api.h header is needed by applications using H3.
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/include/h3api.h"
DESTINATION "${include_install_dir}/h3"
COMPONENT libh3-dev)
# Config * //cmake/h3/h3Config.cmake *
# //cmake/h3/h3ConfigVersion.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
COMPONENT libh3-dev)
# Config * //cmake/h3/h3Targets.cmake
install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
COMPONENT libh3-dev)
# Debian package build
set(CPACK_DEB_COMPONENT_INSTALL 1)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
# set(CPACK_DEBIAN_PACKAGE_MAINTAINER "TEST PACKAGE") # Required
set(CPACK_PACKAGE_HOMEPAGE_URL "https://www.h3geo.org")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_DEBIAN_LIBH3_PACKAGE_DEPENDS "libc6 (>= 2.27)")
set(CPACK_DEBIAN_LIBH3-DEV_PACKAGE_DEPENDS "libh3 (= ${H3_VERSION})")
set(CPACK_DEBIAN_H3_PACKAGE_DEPENDS "libc6 (>= 2.27), libh3 (= ${H3_VERSION})")
set(CPACK_DEBIAN_LIBH3_DESCRIPTION
"Library files for the H3 hexagonal discrete global grid system.")
set(CPACK_DEBIAN_LIBH3-DEV_DESCRIPTION
"Development files and headers for the H3 hexagonal discrete global grid system."
)
set(CPACK_DEBIAN_H3_DESCRIPTION
"UNIX style filter (command line) tools for the H3 hexagonal discrete global grid system."
)
set(CPACK_DEBIAN_LIBH3_PACKAGE_NAME "libh3")
set(CPACK_DEBIAN_LIBH3-DEV_PACKAGE_NAME "libh3-dev")
set(CPACK_DEBIAN_H3_PACKAGE_NAME "h3")
set(CPACK_DEBIAN_LIBH3_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_LIBH3-DEV_PACKAGE_SECTION "libdevel")
set(CPACK_DEBIAN_H3_PACKAGE_SECTION "science")
include(CPack)
configure_file(h3.pc.in ${CMAKE_BINARY_DIR}/h3.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/h3.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
h3-4.5.0/CMakeTests.cmake 0000664 0000000 0000000 00000030124 15203707011 0015033 0 ustar 00root root 0000000 0000000 # Copyright 2017-2022, 2024 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# Test code for H3
option(BUILD_ALLOC_TESTS "Build tests for custom allocation functions" ON)
option(PRINT_TEST_FILES "Print which test files correspond to which tests" OFF)
include(TestWrapValgrind)
enable_testing()
# Macros and support code needed to build and add the tests
set(test_number 0)
if(ENABLE_COVERAGE)
file(
GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$/scripts/coverage.sh"
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/coverage.sh.in")
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "coverage.info")
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "coverage.cleaned.info")
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "coverage")
add_custom_target(
coverage
COMMAND
bash "${CMAKE_CURRENT_BINARY_DIR}/$/scripts/coverage.sh"
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(
clean-coverage
# Before running coverage, clear all counters
COMMAND lcov --rc branch_coverage=1 --directory
'${CMAKE_CURRENT_BINARY_DIR}' --zerocounters
COMMENT "Zeroing counters")
endif()
macro(add_h3_memory_test name srcfile)
# Like other test code, but these need to be linked against a different copy
# of the H3 library which has known intercepted allocator functions.
add_executable(${ARGV} ${APP_SOURCE_FILES} ${TEST_APP_SOURCE_FILES})
if(TARGET ${name})
target_link_libraries(${name} PUBLIC h3WithTestAllocators)
target_include_directories(
${name}
PUBLIC
$
)
target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS})
target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS})
endif()
math(EXPR test_number "${test_number}+1")
add_test(NAME ${name}_test${test_number} COMMAND ${TEST_WRAPPER}
"$")
if(ENABLE_COVERAGE)
add_custom_target(
${name}_coverage${test_number}
COMMAND ${name} > /dev/null
COMMENT "Running ${name}_coverage${test_number}")
add_dependencies(coverage ${name}_coverage${test_number})
add_dependencies(${name}_coverage${test_number} clean-coverage)
endif()
endmacro()
macro(add_h3_test_common name srcfile)
# need to actually make the test target
if(NOT TARGET ${name})
add_h3_executable(${name} ${srcfile} ${APP_SOURCE_FILES}
${TEST_APP_SOURCE_FILES})
endif()
math(EXPR test_number "${test_number}+1")
endmacro()
macro(add_h3_test name srcfile)
add_h3_test_common(${name} ${srcfile})
add_test(NAME ${name}_test${test_number} COMMAND ${TEST_WRAPPER}
"$")
if(ENABLE_COVERAGE)
add_custom_target(
${name}_coverage${test_number}
COMMAND ${name} > /dev/null
COMMENT "Running ${name}_coverage${test_number}")
add_dependencies(coverage ${name}_coverage${test_number})
add_dependencies(${name}_coverage${test_number} clean-coverage)
endif()
endmacro()
macro(add_h3_test_with_file name srcfile argfile)
add_h3_test_common(${name} ${srcfile})
# add a special command (so we don't need to read the test file from the
# test program)
set(dump_command "cat")
add_test(
NAME ${name}_test${test_number}
COMMAND
${SHELL}
"${dump_command} ${argfile} | ${TEST_WRAPPER_STR} $"
)
if(PRINT_TEST_FILES)
message("${name}_test${test_number} - ${argfile}")
endif()
if(ENABLE_COVERAGE)
add_custom_target(
${name}_coverage${test_number}
COMMAND ${name} < ${argfile} > /dev/null
COMMENT "Running ${name}_coverage${test_number}")
add_dependencies(coverage ${name}_coverage${test_number})
add_dependencies(${name}_coverage${test_number} clean-coverage)
endif()
endmacro()
macro(add_h3_cli_test name h3_args expect_string)
add_test(
NAME ${name}_test${test_number}
COMMAND
${SHELL}
"test \"`$ ${h3_args}`\" = '${expect_string}'")
if(PRINT_TEST_FILES)
message("${name}_test${test_number} - ${h3_args} - ${expect_string}")
endif()
# TODO: Build a coverage-enabled variant of the h3 cli app to enable
# coverage
endmacro()
macro(add_h3_test_with_arg name srcfile arg)
add_h3_test_common(${name} ${srcfile})
add_test(NAME ${name}_test${test_number}
COMMAND ${TEST_WRAPPER} $ ${arg})
if(PRINT_TEST_FILES)
message("${name}_test${test_number} - ${arg}")
endif()
if(ENABLE_COVERAGE)
add_custom_target(
${name}_coverage${test_number}
COMMAND ${name} ${arg}
COMMENT "Running ${name}_coverage${test_number}")
add_dependencies(coverage ${name}_coverage${test_number})
add_dependencies(${name}_coverage${test_number} clean-coverage)
endif()
endmacro()
# Add each individual test
file(GLOB all_centers tests/inputfiles/bc*centers.txt)
foreach(file ${all_centers})
add_h3_test_with_file(testLatLngToCell src/apps/testapps/testLatLngToCell.c
${file})
endforeach()
file(GLOB all_ic_files tests/inputfiles/res*ic.txt)
foreach(file ${all_ic_files})
add_h3_test_with_file(testCellToLatLng src/apps/testapps/testCellToLatLng.c
${file})
endforeach()
file(GLOB all_centers tests/inputfiles/rand*centers.txt)
foreach(file ${all_centers})
add_h3_test_with_file(testLatLngToCell src/apps/testapps/testLatLngToCell.c
${file})
endforeach()
file(GLOB all_cells tests/inputfiles/*cells.txt)
foreach(file ${all_cells})
add_h3_test_with_file(testCellToBoundary
src/apps/testapps/testCellToBoundary.c ${file})
endforeach()
add_h3_test(testCellToBoundaryEdgeCases
src/apps/testapps/testCellToBoundaryEdgeCases.c)
add_h3_test(testCompactCells src/apps/testapps/testCompactCells.c)
add_h3_test(testGridDisk src/apps/testapps/testGridDisk.c)
add_h3_test(testGridDiskInternal src/apps/testapps/testGridDiskInternal.c)
add_h3_test(testGridRing src/apps/testapps/testGridRing.c)
add_h3_test(testGridRingInternal src/apps/testapps/testGridRingInternal.c)
add_h3_test(testGridRingUnsafe src/apps/testapps/testGridRingUnsafe.c)
add_h3_test(testGridDisksUnsafe src/apps/testapps/testGridDisksUnsafe.c)
add_h3_test(testCellToParent src/apps/testapps/testCellToParent.c)
add_h3_test(testCellToCenterChild src/apps/testapps/testCellToCenterChild.c)
add_h3_test(testCellToChildren src/apps/testapps/testCellToChildren.c)
add_h3_test(testCellToChildPos src/apps/testapps/testCellToChildPos.c)
add_h3_test(testGetIcosahedronFaces src/apps/testapps/testGetIcosahedronFaces.c)
add_h3_test(testCellToChildrenSize src/apps/testapps/testCellToChildrenSize.c)
add_h3_test(testH3Index src/apps/testapps/testH3Index.c)
add_h3_test(testH3IndexInternal src/apps/testapps/testH3IndexInternal.c)
add_h3_test(testH3Api src/apps/testapps/testH3Api.c)
add_h3_test(testIndexDigits src/apps/testapps/testIndexDigits.c)
add_h3_test(testConstructCell src/apps/testapps/testConstructCell.c)
add_h3_test(testCellsToLinkedMultiPolygon
src/apps/testapps/testCellsToLinkedMultiPolygon.c)
add_h3_test(testCellsToMultiPoly src/apps/testapps/testCellsToMultiPoly.c)
add_h3_test(testCellsToMultiPolyInternal src/apps/testapps/testCellsToMultiPolyInternal.c)
add_h3_test(testLinkedGeoInternal src/apps/testapps/testLinkedGeoInternal.c)
add_h3_test(testLinkedGeoConvert src/apps/testapps/testLinkedGeoConvert.c)
add_h3_test(testPolygonToCells src/apps/testapps/testPolygonToCells.c)
add_h3_test(testPolygonToCellsExperimental
src/apps/testapps/testPolygonToCellsExperimental.c)
add_h3_test(testPolygonToCellsReported
src/apps/testapps/testPolygonToCellsReported.c)
add_h3_test(testPolygonToCellsReportedExperimental
src/apps/testapps/testPolygonToCellsReportedExperimental.c)
add_h3_test(testDirectedEdge src/apps/testapps/testDirectedEdge.c)
add_h3_test(testLatLng src/apps/testapps/testLatLng.c)
add_h3_test(testLatLngInternal src/apps/testapps/testLatLngInternal.c)
add_h3_test(testBBoxInternal src/apps/testapps/testBBoxInternal.c)
add_h3_test(testVertex src/apps/testapps/testVertex.c)
add_h3_test(testVertexInternal src/apps/testapps/testVertexInternal.c)
add_h3_test(testPolygonInternal src/apps/testapps/testPolygonInternal.c)
add_h3_test(testPolyfillInternal src/apps/testapps/testPolyfillInternal.c)
add_h3_test(testVec2dInternal src/apps/testapps/testVec2dInternal.c)
add_h3_test(testVec3dInternal src/apps/testapps/testVec3dInternal.c)
add_h3_test(testVec3 src/apps/testapps/testVec3.c)
add_h3_test(testCellToLocalIj src/apps/testapps/testCellToLocalIj.c)
add_h3_test(testCellToLocalIjInternal
src/apps/testapps/testCellToLocalIjInternal.c)
add_h3_test(testGridDistance src/apps/testapps/testGridDistance.c)
add_h3_test(testGridDistanceInternal
src/apps/testapps/testGridDistanceInternal.c)
add_h3_test(testGridPathCells src/apps/testapps/testGridPathCells.c)
add_h3_test(testH3CellArea src/apps/testapps/testH3CellArea.c)
add_h3_test(testCoordIjInternal src/apps/testapps/testCoordIjInternal.c)
add_h3_test(testCoordIjkInternal src/apps/testapps/testCoordIjkInternal.c)
add_h3_test(testBaseCells src/apps/testapps/testBaseCells.c)
add_h3_test(testBaseCellsInternal src/apps/testapps/testBaseCellsInternal.c)
add_h3_test(testPentagonIndexes src/apps/testapps/testPentagonIndexes.c)
add_h3_test(testH3IteratorsInternal src/apps/testapps/testH3IteratorsInternal.c)
add_h3_test(testMathExtensionsInternal
src/apps/testapps/testMathExtensionsInternal.c)
add_h3_test(testDescribeH3Error src/apps/testapps/testDescribeH3Error.c)
add_h3_test(testGeoLoopArea src/apps/testapps/testGeoLoopArea.c)
add_h3_test_with_arg(testH3NeighborRotations
src/apps/testapps/testH3NeighborRotations.c 0)
add_h3_test_with_arg(testH3NeighborRotations
src/apps/testapps/testH3NeighborRotations.c 1)
add_h3_test_with_arg(testH3NeighborRotations
src/apps/testapps/testH3NeighborRotations.c 2)
# The "Exhaustive" part of the test name is used by the test-fast to exclude
# these files. test-fast exists so that Travis CI can run Valgrind on tests
# without taking a very long time.
add_h3_test(testDirectedEdgeExhaustive
src/apps/testapps/testDirectedEdgeExhaustive.c)
add_h3_test(testVertexExhaustive src/apps/testapps/testVertexExhaustive.c)
add_h3_test(testCellToLocalIjExhaustive
src/apps/testapps/testCellToLocalIjExhaustive.c)
add_h3_test(testGridPathCellsExhaustive
src/apps/testapps/testGridPathCellsExhaustive.c)
add_h3_test(testGridDistanceExhaustive
src/apps/testapps/testGridDistanceExhaustive.c)
add_h3_test(testH3CellAreaExhaustive
src/apps/testapps/testH3CellAreaExhaustive.c)
add_h3_test(testCellToBBoxExhaustive
src/apps/testapps/testCellToBBoxExhaustive.c)
file(GLOB cli_tests tests/cli/*.txt)
foreach(file ${cli_tests})
include(${file})
endforeach()
if(BUILD_ALLOC_TESTS)
add_h3_library(h3WithTestAllocators test_prefix_)
add_h3_memory_test(testH3Memory src/apps/testapps/testH3Memory.c)
endif()
add_custom_target(test-fast COMMAND ctest -E Exhaustive)
h3-4.5.0/CONTRIBUTING.md 0000664 0000000 0000000 00000002616 15203707011 0014264 0 ustar 00root root 0000000 0000000 # Contributing to the H3 project
Pull requests and Github issues are welcome!
Planned improvements and changes are discussed in Github issues. Feel free to open a discussion proposing a new one.
## Pull requests
* Please include tests that show the bug is fixed or feature works as intended.
* Please include fuzzer tests for public API functions.
* Please add a description of your change to the Unreleased section of the [changelog](./CHANGELOG.md).
* Please open issues to discuss large features or changes which would break compatibility, before submitting pull requests.
* Please keep H3 compatible with major C compilers, such as GCC, Clang, and MSVC. We use clang-format-14 for source code formatting, if you have another version the CI job may error on formatting differences.
* Please keep code coverage of the core H3 library at 100%.
Before we can merge your changes, you must agree to the [Uber Contributor License Agreement](https://cla-assistant.io/uber/h3).
## Other ways to contribute
In addition to making pull requests and Github issues on the @uber/h3 repository, there are other ways you can contribute. Here are some suggestions:
* Writing and updating the [documentation website](./website/docs/).
* Writing [bindings](./website/docs/community/bindings.md) for your preferred language.
* Writing components so that your preferred GIS, mapping, or visualization system can display H3 indexes.
h3-4.5.0/KML/ 0000775 0000000 0000000 00000000000 15203707011 0012451 5 ustar 00root root 0000000 0000000 h3-4.5.0/KML/icosa.kml 0000664 0000000 0000000 00000016673 15203707011 0014271 0 ustar 00root root 0000000 0000000
Dymaxion Icosahedron
Spherical Icosahedron with Dymaxion Orientation
0
#lineStyle1
1
10.536199,64.700000,0.0
58.157706,10.447345,0.0
122.300000,39.100000,0.0
10.536199,64.700000,0.0
1
#lineStyle1
1
10.536199,64.700000,0.0
122.300000,39.100000,0.0
-143.478490,50.103201,0.0
10.536199,64.700000,0.0
2
#lineStyle1
1
10.536199,64.700000,0.0
-143.478490,50.103201,0.0
-67.132326,23.717925,0.0
10.536199,64.700000,0.0
3
#lineStyle1
1
10.536199,64.700000,0.0
-67.132326,23.717925,0.0
-5.245390,2.300882,0.0
10.536199,64.700000,0.0
4
#lineStyle1
1
10.536199,64.700000,0.0
-5.245390,2.300882,0.0
58.157706,10.447345,0.0
10.536199,64.700000,0.0
5
#lineStyle1
1
112.867674,-23.717925,0.0
122.300000,39.100000,0.0
58.157706,10.447345,0.0
112.867674,-23.717925,0.0
6
#lineStyle1
1
174.754610,-2.300882,0.0
-143.478490,50.103201,0.0
122.300000,39.100000,0.0
174.754610,-2.300882,0.0
7
#lineStyle1
1
-121.842294,-10.447345,0.0
-67.132326,23.717925,0.0
-143.478490,50.103201,0.0
-121.842294,-10.447345,0.0
8
#lineStyle1
1
-57.700000,-39.100000,0.0
-5.245390,2.300882,0.0
-67.132326,23.717925,0.0
-57.700000,-39.100000,0.0
9
#lineStyle1
1
36.521510,-50.103201,0.0
58.157706,10.447345,0.0
-5.245390,2.300882,0.0
36.521510,-50.103201,0.0
10
#lineStyle1
1
122.300000,39.100000,0.0
112.867674,-23.717925,0.0
174.754610,-2.300882,0.0
122.300000,39.100000,0.0
11
#lineStyle1
1
-143.478490,50.103201,0.0
174.754610,-2.300882,0.0
-121.842294,-10.447345,0.0
-143.478490,50.103201,0.0
12
#lineStyle1
1
-67.132326,23.717925,0.0
-121.842294,-10.447345,0.0
-57.700000,-39.100000,0.0
-67.132326,23.717925,0.0
13
#lineStyle1
1
-5.245390,2.300882,0.0
-57.700000,-39.100000,0.0
36.521510,-50.103201,0.0
-5.245390,2.300882,0.0
14
#lineStyle1
1
58.157706,10.447345,0.0
36.521510,-50.103201,0.0
112.867674,-23.717925,0.0
58.157706,10.447345,0.0
15
#lineStyle1
1
-169.463801,-64.700000,0.0
174.754610,-2.300882,0.0
112.867674,-23.717925,0.0
-169.463801,-64.700000,0.0
16
#lineStyle1
1
-169.463801,-64.700000,0.0
-121.842294,-10.447345,0.0
174.754610,-2.300882,0.0
-169.463801,-64.700000,0.0
17
#lineStyle1
1
-169.463801,-64.700000,0.0
-57.700000,-39.100000,0.0
-121.842294,-10.447345,0.0
-169.463801,-64.700000,0.0
18
#lineStyle1
1
-169.463801,-64.700000,0.0
36.521510,-50.103201,0.0
-57.700000,-39.100000,0.0
-169.463801,-64.700000,0.0
19
#lineStyle1
1
-169.463801,-64.700000,0.0
112.867674,-23.717925,0.0
36.521510,-50.103201,0.0
-169.463801,-64.700000,0.0
h3-4.5.0/LICENSE 0000664 0000000 0000000 00000026135 15203707011 0013042 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
h3-4.5.0/NOTICE 0000664 0000000 0000000 00000001070 15203707011 0012730 0 ustar 00root root 0000000 0000000 Copyright 2017-2021 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
h3-4.5.0/README.md 0000664 0000000 0000000 00000017260 15203707011 0013313 0 ustar 00root root 0000000 0000000
# H3: A Hexagonal Hierarchical Geospatial Indexing System
[](https://github.com/uber/h3/actions)
[](https://github.com/uber/h3/actions)
[](https://github.com/uber/h3/actions)
[](https://github.com/uber/h3/actions)
[](https://coveralls.io/github/uber/h3?branch=master)
[](LICENSE)
H3 is a geospatial indexing system using a hexagonal grid that can be (approximately) subdivided into finer and finer hexagonal grids, combining the benefits of a hexagonal grid with [S2](https://code.google.com/archive/p/s2-geometry-library/)'s hierarchical subdivisions.
Documentation is available at [https://h3geo.org/](https://h3geo.org/). Developer documentation in Markdown format is available under the [dev-docs](./dev-docs/) directory.
* Post **bug reports or feature requests** to the [GitHub Issues page](https://github.com/uber/h3/issues)
* Ask **questions** by posting to the [H3 tag on StackOverflow](https://stackoverflow.com/questions/tagged/h3)
* There is also an [H3 Slack workspace](https://join.slack.com/t/h3-core/shared_invite/zt-g6u5r1hf-W_~uVJmfeiWtMQuBGc1NNg)
## Installing
We recommend using prebuilt bindings if they are available for your programming language. Bindings for [Java](https://github.com/uber/h3-java), [JavaScript](https://github.com/uber/h3-js), [Python](https://github.com/uber/h3-py), and [others](https://h3geo.org/docs/community/bindings) are available.
On macOS, you can install H3 using `brew`:
```
brew install h3
```
Otherwise, to build H3 from source, please see the following instructions.
### Building from source
Still here? To build the H3 C library, you'll need a C compiler (tested with `gcc` and `clang`), [CMake](https://cmake.org/), and [Make](https://www.gnu.org/software/make/). If you intend to contribute to H3, you must have [clang-format](https://clang.llvm.org/docs/ClangFormat.html) installed and we recommend installing [ccmake](https://cmake.org/cmake/help/v3.0/manual/ccmake.1.html) and [LCOV](https://github.com/linux-test-project/lcov) to configure the `cmake` arguments to build and run the tests and generate the code coverage report. We also recommend using `gcc` for the code coverage as some versions of `clang` generate annotations that aren't compatible with `lcov`. [Doxygen](https://www.doxygen.nl/index.html) is needed to build the API documentation.
#### Install build-time dependencies
* Alpine
```
# Installing the bare build requirements
apk add cmake make gcc libtool musl-dev
```
* Debian/Ubuntu
```
# Installing the bare build requirements
sudo apt install cmake make gcc libtool
# Installing useful tools for development
sudo apt install clang-format cmake-curses-gui lcov doxygen
```
* macOS (using `brew`)
First make sure you [have the developer tools installed](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/) and then
```
# Installing the bare build requirements
brew install cmake
# Installing useful tools for development
brew install clang-format lcov doxygen
```
* Windows (Visual Studio)
You will need to install CMake and Visual Studio, including the Visual C++ compiler. For building on Windows, please follow the [Windows build instructions](dev-docs/build_windows.md).
* FreeBSD
```
# Installing the build requirements
sudo pkg install bash cmake gmake doxygen lcov
```
#### Compilation
When checking out the H3 Git repository, by default you will check out the latest
development version of H3. When using H3 in an application, you will want to check
out the most recently released version:
```
git checkout v$(