Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/r-barnes/richdem
Browse files Browse the repository at this point in the history
  • Loading branch information
r-barnes committed May 7, 2022
2 parents 46aa3a1 + 3313b29 commit 6173d98
Show file tree
Hide file tree
Showing 83 changed files with 6,546 additions and 18,571 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ a.out
travis.log
build/
.vscode/
.log
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2022-02-11 (2.3.1)
==================

Fix pyrichdem to import all cpp source files correctly
Clean up pyrichdem setup.py
Add .log files to .gitignore

2022-02-09 (2.3.0)
==================

Drop PyBind11 in favour of using pypi's version
Update to doctest v2.4.8

2018-07-13 (2.2.9)
==================

Expand Down
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ project(richdem
LANGUAGES CXX
)

cmake_policy(SET CMP0077 NEW)

find_package(GDAL)
find_package(OpenMP)
find_package(OpenMP REQUIRED)
find_package(MPI)

set(CMAKE_MACOSX_RPATH 1)
set(BUILD_SHARED_LIBS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

add_subdirectory(apps)

if(MPI_CXX_FOUND)
Expand All @@ -18,9 +25,9 @@ if(MPI_CXX_FOUND)
else()
message(WARNING "MPI not found; will not compile parallel programs for large-scale datasets.")
endif()
# add_subdirectory(tests)
add_subdirectory(tests)

option(USE_GDAL "Whether or not to compile with GDAL.")
option(USE_GDAL "Whether or not to compile with GDAL." ON)
option(RICHDEM_NO_PROGRESS "Whether or not to show progress bars." OFF)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
Expand All @@ -38,10 +45,6 @@ add_library(richdem
src/terrain_generation/PerlinNoise.cpp
)

if(NOT OpenMP_CXX_FOUND)
message(WARNING "Compiling without OpenMP!")
endif()

# set_target_properties(richdem PROPERTIES VERSION ${PROJECT_VERSION})
# set_target_properties(richdem PROPERTIES SOVERSION 2)

Expand All @@ -54,7 +57,7 @@ target_include_directories(richdem
target_compile_features(richdem
PUBLIC
cxx_auto_type
cxx_std_11
cxx_std_17
)

if(OpenMP_CXX_FOUND)
Expand Down Expand Up @@ -87,4 +90,13 @@ add_executable(richdem_unittests
tests/tests.cpp
)
target_link_libraries(richdem_unittests PRIVATE richdem)
target_compile_features(richdem_unittests PRIVATE cxx_std_17)
target_compile_features(richdem_unittests PRIVATE cxx_std_17)


install(
TARGETS richdem
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
RUNTIME DESTINATION "bin"
)
install(DIRECTORY include/richdem DESTINATION include)
54 changes: 45 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,33 @@ A typical academic citation might read as follows:


Compilation
-------------------
-----------

To compile, first acquire the source code:

git clone --recursive https://github.com/r-barnes/richdem

You will need a C++ compiler, *cmake*, and, optionally, *libgdal*. If you are
using *conda*, you can install these requirements in a new environment with
the following commands:

$ conda create -n richdem
$ conda activate richdem
$ conda install --file=requirements.txt -c conda-forge

Then compile using the standard `cmake` sequence:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release .. # Without GDAL
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_GDAL=ON .. # With GDAL
make -j 6 # Adjust to use more or fewer processors
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
$ make -j 6 # Adjust to use more or fewer processors

If you do not want to build *richdem* with *gdal*, use the `-DUSE_GDAL=OFF`
option. To install *richdem*:

$ cmake --install . --prefix /my/install/prefix

If you are using *conda*, `/my/install/prefix` should be `$CONDA_PREFIX`.

RichDEM includes some programs to process extremely large digital elevation
models, as well as for handling many DEM formats. Special prerequisites,
Expand All @@ -88,17 +102,39 @@ Boost. To install these on a Debian machine use:
As A Python Package
-------------------

### From source

After installing the *richdem* library (as described above), you can build
*richdem* as a Python package. To do this, you will of course need Python
(3.7+), which you can install with *conda*,

$ conda install python

You can now build the *richdem* Python package,

$ cd wrappers/pyrichdem
$ pip install -e .

### From conda

To install a pre-built version of *richdem* using *conda*,

$ conda install richdem -c conda-forge


### From PyPI using pip

Get the package with:

pip3 install richdem
$ pip install richdem

And use:

import richdem
>>> import richdem

The command:

help(richdem)
>>> help(richdem)

provides all the relevant documentation.

Expand Down
6 changes: 3 additions & 3 deletions apps/rd_loop_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ void FollowPath(
if(flowdirs.isNoData(x,y) || n==NO_FLOW)
return;

const int nx = x+dx[n]; //Get neighbour's x-coordinate.
const int ny = y+dy[n]; //Get neighbour's y-coordinate.
const int nx = x+d8x[n]; //Get neighbour's x-coordinate.
const int ny = y+d8y[n]; //Get neighbour's y-coordinate.

if(!flowdirs.inGrid(nx,ny))
return;
Expand Down Expand Up @@ -62,7 +62,7 @@ int PerformAlgorithm(Array2D<T> inp){

int main(int argc, char **argv){
std::string analysis = PrintRichdemHeader(argc,argv);

int32_t total_height;
int32_t total_width;
GDALDataType file_type;
Expand Down
3 changes: 2 additions & 1 deletion docs/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Geotransform
-----------------------------------

A **geotransform** is a six element array which determines where in a
projection a RichDEM array's data is located, as well as the cell sizes.
projection a RichDEM array's data is located, as well as the cell sizes. In
python, the geotransform must be a 6 element tuple.

Typically, the geotransform is an affine transform consisting of six
coefficients which map pixel/line coordinates into a georeferenced space using
Expand Down
5 changes: 2 additions & 3 deletions docs/using_it.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ Setting up compilation works like this:

.. code-block:: bash
CXXFLAGS="--std=c++11 -g -O3 -Wall -Wno-unknown-pragmas -Irichdem/include"
CXXFLAGS="--std=c++17 -g -O3 -Wall -Wno-unknown-pragmas -Irichdem/include"
CXXFLAGS="$CXXFLAGS -DRICHDEM_LOGGING"
C++11 or higher is necessary to compile. Include other RichDEM flags as desired.
C++17 or higher is necessary to compile. Include other RichDEM flags as desired.
Note that the `-g` flag doesn't slow things down, though it does increase the
size of your executable somewhat. It's inclusion is always recommended for
anything other than distributed production code because it makes debugging much
Expand Down Expand Up @@ -142,4 +142,3 @@ The `programs` directory contains several programs which have not been converted
to libraries. This is usually because their functionality is specific and they
are unlikely to be useful as a library. Each directory contains a makefile and a
readme explaining the purpose of the program.

Loading

0 comments on commit 6173d98

Please sign in to comment.