Skip to content

Commit

Permalink
Merge pull request #43 from GIScience/feat/reorganize
Browse files Browse the repository at this point in the history
feat: reorganize workspace
  • Loading branch information
aoles committed Mar 22, 2024
2 parents 2c2d6fd + b712abf commit ea8716b
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 54 deletions.
11 changes: 7 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
**/*.tif
**/*.pbf
Dockerfile
.venv*
# Ignore everything
*

# Allow
!CMakeLists.txt
!src
!test
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -G Ninja -B ./cmake-build-test
cmake --build ./cmake-build-test --target test-osm-transform -j 14
./cmake-build-test/test/test-osm-transform
./cmake-build-test/test/test-osm-transform
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ gmted*/*
gmteddata
cmake-build-debug
/cmake-build-release/
/tiffs/
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ add_definitions( -DPROJECT_VERSION="${PROJECT_VERSION}" -DPROJECT_NAME="${PROJEC
add_definitions("-DBOOST_ALLOW_DEPRECATED_HEADERS")

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CONFIGURATION_TYPES "Debug,Release" CACHE STRING "Configuration Types" FORCE)

option(BUILD_TESTING "Build the tests" ON)

# https://cmake.org/cmake/help/git-master/module/FindBoost.html
find_package(Boost REQUIRED regex program_options)
find_package(GDAL REQUIRED)

file(GLOB sources CONFIGURE_DEPENDS *.h *.cpp)
add_executable(${PROJECT_NAME} ${sources})
include_directories(${PROJECT_BINARY_DIR}/src)

set(SOURCE_FILES
location_area_service.cpp
location_elevation_service.cpp
rewrite_handler.cpp
)

add_subdirectory(src)

if (BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE z bz2 expat GDAL::GDAL Boost::regex Boost::program_options)

# unit tests
add_subdirectory(test)
43 changes: 22 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
FROM ubuntu:jammy as build
# For Mac with amd chip use
#FROM --platform=linux/amd64 ubuntu:jammy
FROM debian:bookworm-slim

RUN apt-get -qq update && apt-get -y -qq install apt-utils

RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update && apt-get -qq install \
g++ \
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
g++ \
cmake \
ninja-build \
libgdal-dev \
libproj-dev \
libosmium-dev \
libboost-all-dev

COPY ./test /src/test
COPY *.h *.cpp CMakeLists.txt /src/
WORKDIR /src
libgdal-dev \
libproj-dev \
libosmium-dev \
libboost-regex-dev \
libboost-program-options-dev \
libboost-test-dev \
; \
\
rm -rf /var/lib/apt/lists/*;

COPY . /osm-transform/

RUN set -eux; \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -G Ninja -S /osm-transform -B /osm-transform/cmake-build ; \
cmake --build /osm-transform/cmake-build --target osm-transform ; \
cmake --install /osm-transform/cmake-build

RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -G Ninja -S /src -B /src/cmake-build
RUN cmake --build /src/cmake-build --target osm-transform

RUN mkdir /osm
WORKDIR /osm

ENTRYPOINT ["/src/cmake-build/osm-transform"]
ENTRYPOINT ["/usr/local/bin/osm-transform"]:
2 changes: 1 addition & 1 deletion docker_run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
docker rm -f osm-transform || true
docker build -t osm-transform .
docker run -it -v .:/osm --name osm-transform --user "$(id -u):$(id -g)" osm-transform $@
docker run --rm -it -v .:/osm --name osm-transform --user "$(id -u):$(id -g)" osm-transform $@
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

add_executable(${PROJECT_NAME} osm-transform.cpp ${SOURCE_FILES})

target_link_libraries(${PROJECT_NAME} PRIVATE z bz2 expat GDAL::GDAL Boost::regex Boost::program_options)

install(TARGETS ${PROJECT_NAME} DESTINATION bin)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 15 additions & 14 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
cmake_minimum_required(VERSION 3.22)

find_package(Boost REQUIRED COMPONENTS unit_test_framework regex)
find_package(GDAL REQUIRED)

add_executable(test-osm-transform test-osm-transform.cpp
../location_area_service.cpp
../location_elevation_service.cpp
../rewrite_handler.cpp
test_utils.cpp
test_location_area.cpp
test_location_elevation.cpp
test_firstpass_handler.cpp
test_rewrite_handler.cpp
)
target_link_libraries(test-osm-transform PRIVATE Boost::unit_test_framework Boost::regex GDAL::GDAL)
include_directories(../src)

enable_testing()
set(TEST_FILES
test_utils.cpp
test_location_area.cpp
test_location_elevation.cpp
test_firstpass_handler.cpp
test_rewrite_handler.cpp
)

foreach(file ${SOURCE_FILES})
list(APPEND TEST_FILES "../src/${file}")
endforeach()

add_executable(test-osm-transform test-osm-transform.cpp
${TEST_FILES}
)
target_link_libraries(test-osm-transform PRIVATE Boost::unit_test_framework Boost::regex GDAL::GDAL)
4 changes: 2 additions & 2 deletions test/test_firstpass_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <osmium/visitor.hpp>

#define private public
#include "../firstpass_handler.h"
#include "firstpass_handler.h"
#include "test_utils.h"

BOOST_AUTO_TEST_SUITE( test_first_pass )
Expand Down Expand Up @@ -58,4 +58,4 @@ BOOST_AUTO_TEST_CASE(bla) {

}

BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
4 changes: 2 additions & 2 deletions test/test_location_area.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp>

#include "../location_area_service.h"
#include "location_area_service.h"

BOOST_AUTO_TEST_SUITE( test_locacion_area )
BOOST_AUTO_TEST_CASE( test_location_area_service )
Expand Down Expand Up @@ -30,4 +30,4 @@ BOOST_AUTO_TEST_CASE( test_location_area_service )


}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
4 changes: 2 additions & 2 deletions test/test_location_elevation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp>

#include "../location_elevation_service.h"
#include "location_elevation_service.h"

BOOST_AUTO_TEST_SUITE( test_locacion_elevation )
BOOST_AUTO_TEST_CASE( test_lookup ) {
Expand Down Expand Up @@ -28,4 +28,4 @@ BOOST_AUTO_TEST_CASE( test_interpolate ) {


}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
4 changes: 2 additions & 2 deletions test/test_rewrite_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <osmium/memory/buffer.hpp>
#include <osmium/visitor.hpp>

#include "../rewrite_handler.h"
#include "rewrite_handler.h"

#include "test_utils.h"

Expand Down Expand Up @@ -289,4 +289,4 @@ BOOST_AUTO_TEST_CASE (rewrite_full_pass) {

}

BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()

0 comments on commit ea8716b

Please sign in to comment.