Skip to content
Open
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
78 changes: 65 additions & 13 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: CI

on:
Expand All @@ -7,38 +6,91 @@ on:
pull_request:
branches: [ master ]

env:
REGISTRY: ghcr.io
RASPUTIN_DATA_DIR: examples/example_data

jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
run_job: ${{ steps.check_dockerfile.outputs.run_job }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Check Dockerfile
id: check_dockerfile
run: |
if git diff --name-only HEAD^ HEAD | grep -q "^Dockerfile$"; then
echo "run_job=true" >> "$GITHUB_OUTPUT"
else
echo "run_job=false" >> "$GITHUB_OUTPUT"
fi

build-and-push-image:
runs-on: ubuntu-latest
needs: check_changes
if: ${{ needs.check_changes.outputs.run_job == 'true' }}
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3

- name: Login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}_${{ github.ref_name }}
tags: |
type=raw,value=latest,enable=true

- name: Build and Push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build:
runs-on: ubuntu-latest
needs: [check_changes, build-and-push-image]
if: ${{ !failure() && !cancelled() }}
container:
image: dnumgis/rasputin:latest
image: ghcr.io/${{ github.repository }}_${{ github.ref_name }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Copy dependencies
run: |
cp -rf /root/lib/* lib/

- name: Install
run: |
python3 setup.py install

- name: Set Data Dir
run: |
echo "::set-env name=RASPUTIN_DATA_DIR::/__w/rasputin/rasputin/examples/example_data"
pip -v install -e .

- name: Rasputin Store
run: |
rasputin_store -x 24.015 24.035 24.035 24.015 -y 71.085 71.085 71.07 71.07 -ratio 1.0 -land-type-partition corine ingoya_test

- name: Rasputin Web
run: |
rasputin_web -output examples/example_data/web/ingoya_test -material examples/example_data/materials/material.yaml ingoya_test
rasputin_web -output examples/example_data/web/ingoya_test -material examples/example_data/materials/material.yaml ingoya_test

- name: Run tests
run: |
pytest tests/test_mesh.py
pytest tests/test_polygons.py
pytest tests/test_read_raster_file.py
pytest tests/test_tin_repository.py
pytest tests
./build/test_sun_position
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ cmake-*
.idea
.env
*.swp
lib/CGAL*
lib/pybind11
lib/armadillo*
src/rasputin/*so
src/rasputin.egg-info
lib/**/*
**/*.egg-info
**/*.so
__pycache__
build
dist
.DS_Store
lib/boo*
lib/geometry
lib/build_*
.envrc
compile_commands.json
.cache/
.python-version
*.eggs
46 changes: 28 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ project (Rasputin)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall")

set(ENABLE_TESTS ON)
if (DEFINED ENV{ENABLE_TESTS})
if ($ENV{ENABLE_TESTS} STREQUAL "ON")
set(ENABLE_TESTS ON)
else()
set(ENABLE_TESTS OFF)
endif()
endif()

# Default location for dependencies
set(RASPUTIN_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
Expand Down Expand Up @@ -40,15 +47,15 @@ add_definitions(-DHAS_BOOST)
# date
# ----
# TODO: Check CXX version if this is really needed?
if (EXISTS "${RASPUTIN_LIB_DIR}/date")
add_library(date INTERFACE)
target_include_directories(date INTERFACE
"${RASPUTIN_LIB_DIR}/date/include")
else()
find_package(date REQUIRED)
add_library(date INTERFACE IMPORTED)
endif()
list(APPEND RASPUTIN_DEPENDENCIES date)
# if (EXISTS "${RASPUTIN_LIB_DIR}/date")
# add_library(date INTERFACE)
# target_include_directories(date INTERFACE
# "${RASPUTIN_LIB_DIR}/date/include")
# else()
# find_package(date REQUIRED)
# add_library(date INTERFACE IMPORTED)
# endif()
# list(APPEND RASPUTIN_DEPENDENCIES date)


# CGAL
Expand Down Expand Up @@ -83,21 +90,24 @@ find_package(LAPACK)

# Header-only Rasputin library
# ----------------------------
set(RASPUTIN_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/rasputin")
set(RASPUTIN_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/rasputin/cpp")
add_library(rasputin INTERFACE)
target_include_directories(rasputin PRIVATE INTERFACE ${RASPUTIN_SOURCE})

if (ENABLE_TESTS)
add_subdirectory(cpp_test)
endif()


# Python bindnigs
# ---------------
# Use pybind11 as a system library to avoid problems with include order
pybind11_add_module(triangulate_dem MODULE SYSTEM
"${RASPUTIN_SOURCE}/bindings.cpp")
file(GLOB RASPUTIN_SOURCES ${RASPUTIN_SOURCE}/*.cpp)
pybind11_add_module(triangulate_dem MODULE SYSTEM ${RASPUTIN_SOURCES})
# Need to link BLAS for header-only Aramdillo
target_link_libraries(triangulate_dem PRIVATE
${RASPUTIN_DEPENDENCIES}
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})

if (ENABLE_TESTS)
enable_testing()
add_subdirectory(lib/Catch2)
add_executable(test_sun_position cpp_test/test_sun_position.cpp)
target_link_libraries(test_sun_position PRIVATE rasputin Catch2::Catch2WithMain ${RASPUTIN_DEPENDENCIES})
endif()
41 changes: 25 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

WORKDIR /root

# Fetch packages Dependancies
ENV DEBIAN_FRONTEND=noninteractive

# Fetch packages Dependencies
RUN apt-get update &&\
apt-get upgrade -y &&\
apt-get install -y\
Expand All @@ -17,32 +19,39 @@ RUN apt-get update &&\
liblapack-dev \
libatlas3-base \
libatlas-base-dev \
python3.6 \
python3-pip \
git \
pybind11-dev \
libarmadillo-dev \
libcgal-dev \
python3-pip \
libcurl4 \
libssl-dev \
libcurl4-openssl-dev &&\
libcurl4-openssl-dev \
libtinfo5 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Python Depndancies
RUN pip3 install numpy pyproj Pillow h5py lxml shapely descartes meshio pytest setuptools pipenv pyyaml requests
# Python Dependencies
RUN python3 -m pip install numpy pyproj Pillow h5py lxml shapely descartes meshio pytest setuptools pipenv pyyaml requests

# Cmake
RUN wget https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5.tar.gz \
&& tar -zxvf cmake-3.16.5.tar.gz \
&& rm cmake-3.16.5.tar.gz \
&& cd cmake-3.16.5 \
&& ./bootstrap \
&& make \
&& make install
RUN wget https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-x86_64.tar.gz \
&& tar -zxf cmake-3.25.2-linux-x86_64.tar.gz \
&& rm cmake-3.25.2-linux-x86_64.tar.gz \
&& cp -R cmake-3.25.2-linux-x86_64/* /usr/ \
&& rm -r cmake-3.25.2-linux-x86_64

# clang+llvm 16
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz \
&& tar -xf clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz \
&& rm clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz \
&& cp -R clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/* /usr/ \
&& rm -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04

ENV CXX=/usr/bin/clang++

# Github resources
RUN mkdir lib && cd lib && \
git clone https://github.com/boostorg/geometry.git --branch=boost-1.71.0 &&\
git clone https://github.com/HowardHinnant/date.git &&\
git clone https://github.com/catchorg/Catch2.git --branch=v2.10.2 catch2
git clone https://github.com/boostorg/geometry.git --branch=boost-1.81.0 --depth=1 &&\
git clone https://github.com/catchorg/Catch2.git --branch=v3.3.1 --depth=1
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ Installing Rasputin is easy, as the C++ dependencies are header only. Simply, ei
For examaple, in some location where you have your source code, type:

```
git clone https://github.com/pybind/pybind11.git
git clone https://gitlab.com/conradsnicta/armadillo-code.git
git clone https://github.com/boostorg/geometry.git
git clone https://github.com/catchorg/Catch2.git
git clone https://github.com/CGAL/cgal.git
git clone https://github.com/pybind/pybind11.git
git clone https://gitlab.com/conradsnicta/armadillo-code.git
git clone https://github.com/boostorg/geometry.git
git clone https://github.com/catchorg/Catch2.git
git clone https://github.com/CGAL/cgal.git
```
For Howard Hinnant's `date` library to work, enter the rasputin source root directory and checkout the source under the `lib` folder:
```
cd lib
git clone https://github.com/HowardHinnant/date.git
git clone https://github.com/HowardHinnant/date.git
```

Rasputin does not aim at being backwards compatible with older compilers.
Expand Down Expand Up @@ -108,11 +108,11 @@ from rasputin.reader import Rasterdata
from rasputin.mesh import Mesh

def construct_rasterdata():
raster = np.array([0, 0, 0,
0, 1, 0,
raster = np.array([0, 0, 0,
0, 1, 0,
0, 0, 0], dtype=np.float32).reshape(3,3)
cs = pyproj.CRS.from_epsg(32633)
return Rasterdata(shape=(raster.shape[1], raster.shape[0]), x_min=0,
return Rasterdata(shape=(raster.shape[1], raster.shape[0]), x_min=0,
y_max=20, delta_x=10, delta_y=10, array=raster,
coordinate_system=cs.to_proj4(), info={})

Expand Down Expand Up @@ -179,9 +179,9 @@ Choose "Nedlasting" from the left hand side of the map, and choose "Landsdekkend
and finally click DTM10. Download and unpack in, for instance, `$HOME/rasputin_data/dem_archive`, and
`export RASPUTIN_DATA_DIR=$HOME/rasputin_data`.

It is possible to include land cover types in your triangulation, through the
[GlobCover dataset](http://due.esrin.esa.int/page_globcover.php) from ESA. It is a raster based
300m (approx) resolution data set that contains 23 different land cover types.
It is possible to include land cover types in your triangulation, through the
[GlobCover dataset](http://due.esrin.esa.int/page_globcover.php) from ESA. It is a raster based
300m (approx) resolution data set that contains 23 different land cover types.
Download the data set and unpack it in `$RASPUTIN_DATA_DIR/globcov` to access the land types using
the `rasputin.globcov_repository.GlobCovRepository` class.

Expand Down
10 changes: 0 additions & 10 deletions cpp_test/CMakeLists.txt

This file was deleted.

Loading