Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on:
push:
branches:
- main
- master
pull_request:

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux
runner: ubuntu-latest
- name: macOS ARM
runner: macos-14
- name: Windows
runner: windows-latest

steps:
- name: Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: hexer
auto-activate-base: false
channels: conda-forge
channel-priority: strict
miniforge-variant: Miniforge3
miniforge-version: latest
mamba-version: "*"
python-version: "3.12"

- name: Install build dependencies
shell: pwsh
run: mamba install -n hexer -y cmake ninja gdal

- name: Configure
shell: pwsh
run: conda run -n hexer cmake -S . -B build -G Ninja -DWITH_TESTS=ON -DCMAKE_BUILD_TYPE=Release

- name: Build
shell: pwsh
run: conda run -n hexer cmake --build build --parallel

- name: Run tests
shell: pwsh
run: conda run -n hexer ctest --test-dir build --output-on-failure
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################################
# CMake settings
cmake_minimum_required(VERSION 3.5.0)
cmake_minimum_required(VERSION 3.16...4.3)

set(CMAKE_COLOR_MAKEFILE ON)

Expand All @@ -15,6 +15,7 @@ string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
include(${HEXER_SOURCE_DIR}/cmake/hexer_utils.cmake)

set(CMAKE_MODULE_PATH "${HEXER_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)

include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
Expand All @@ -27,11 +28,6 @@ SET(HEXER_LIB_SOVERSION "1.1.0")

set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)

# Path to additional CMake modules
if (CMAKE_MAJOR_VERSION GREATER 2)
cmake_policy(SET CMP0042 NEW) # osx rpath
endif()

###############################################################################
# Platform and compiler specific settings

Expand All @@ -52,7 +48,10 @@ endif()
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)

find_package(GDAL 1.9.0 REQUIRED)
find_package(GDAL CONFIG REQUIRED)
if (GDAL_VERSION VERSION_LESS 1.9.0)
message(FATAL_ERROR "GDAL 1.9.0 or newer is required.")
endif()


###############################################################################
Expand Down Expand Up @@ -82,6 +81,8 @@ endif(WIN32)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(WITH_TESTS "Build the hexer test suite" ON)

set(hexer_defines_h_in "${CMAKE_CURRENT_SOURCE_DIR}/hexer_defines.h.in")
set(hexer_defines_h "${CMAKE_CURRENT_BINARY_DIR}/include/hexer/hexer_defines.h")
include(CheckIncludeFiles)
Expand Down Expand Up @@ -136,15 +137,16 @@ target_include_directories(curse
PRIVATE
${H3_INCLUDE_DIR}
${HEXER_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/include
)
target_link_libraries(curse
PRIVATE
${GDAL_LIBRARY}
GDAL::GDAL
${H3_LIB_NAME}
${HEXER_LIB_NAME}
)

enable_testing()
add_subdirectory(test)
if (WITH_TESTS)
enable_testing()
add_subdirectory(test)
endif()
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ $ curse density mylasfile.las --output myhexagons.shp --edge 100

[map]: http://a.tiles.mapbox.com/v3/hobu.serpent-mound.html#16.00/39.0346/-83.4353

## Building

An example debug build using the `hexer` conda environment is:

```bash
conda run -n hexer ./hobu.sh
```

The `hobu.sh` script configures a Ninja build in `build/`, enables the test
suite, installs against `${CONDA_PREFIX}`, and builds the project. The first
configure will also download GoogleTest from GitHub.
12 changes: 8 additions & 4 deletions hexer/H3grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class H3Grid : public BaseGrid
{
public:
H3Grid(int dense_limit)
: BaseGrid{dense_limit}, m_res{-1}, m_origin{0}
: BaseGrid{dense_limit}, m_res{-1}, m_minI{0}, m_origin{0}
{}
H3Grid(int res, int dense_limit)
: BaseGrid{dense_limit}, m_res{res}, m_origin{0}
: BaseGrid{dense_limit}, m_res{res}, m_minI{0}, m_origin{0}
{}

H3Index ij2h3(HexId ij)
Expand Down Expand Up @@ -70,7 +70,12 @@ class H3Grid : public BaseGrid
// test function: used when inserting pre-defined grids in tests,
// sets origin outside of findHexagon()
void setOrigin(H3Index idx)
{ m_origin = idx; }
{
m_origin = idx;
// local IJ coordinates are relative to the origin, so start one
// column to the left to match the normal findHexagon() setup path.
m_minI = h32ij(idx).i - 1;
}
// test function: used to get grid resolution to run h3 latLngToCell()
int getRes() const
{ return m_res; }
Expand All @@ -89,4 +94,3 @@ class H3Grid : public BaseGrid

} // namepsace hexer


12 changes: 12 additions & 0 deletions hobu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -euo pipefail

: "${CONDA_PREFIX:?Activate the hexer conda environment before running hobu.sh.}"

rm -rf build
cmake -S . -B build -G Ninja \
-DWITH_TESTS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}"
cmake --build build
21 changes: 13 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(GTEST_DIR gtest/gtest-10-06-21)
include(FetchContent)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(googletest)

macro(HEXER_ADD_TEST _name)
add_executable(${_name} ${_name}.cpp ${LIB_SRCS} ${LAZPERF_SRCS})
target_link_libraries(${_name} gtest ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${GDAL_LIBRARY} ${H3_LIB_NAME})
target_include_directories(${_name} PRIVATE ${GDAL_INCLUDE_DIR})
target_include_directories(${_name} PRIVATE ${GTEST_DIR}/include)
target_link_libraries(${_name} PRIVATE GTest::gtest GDAL::GDAL ${H3_LIB_NAME})
target_include_directories(${_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
target_include_directories(${_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
add_test(NAME ${_name} COMMAND ${HEXER_BINARY_DIR}/${_name})
add_test(NAME ${_name} COMMAND $<TARGET_FILE:${_name}>)
endmacro(HEXER_ADD_TEST)

configure_file(test_main.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/test_main.hpp)
configure_file(${hexer_defines_h} ${CMAKE_CURRENT_BINARY_DIR}/hexer/hexer_defines.h)
add_subdirectory(${GTEST_DIR})

HEXER_ADD_TEST(gridtest)
HEXER_ADD_TEST(pathstest)

2 changes: 0 additions & 2 deletions test/gtest/gtest-10-06-21/CMakeLists.txt

This file was deleted.

130 changes: 0 additions & 130 deletions test/gtest/gtest-10-06-21/CONTRIBUTING.md

This file was deleted.

Loading
Loading