Installation
The Fields2Cover package has only been tested on Ubuntu and on macOS (Apple Silicon). If you are able to run it in other operative systems, open an issue/PR and it will be added to this guide
System requirements
Some packages are needed before compiling the package:
Note
if your OS is Ubuntu 18.04 or 20.04, you would need to do sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install --no-install-recommends software-properties-common
sudo apt-get install --no-install-recommends build-essential ca-certificates cmake \
doxygen g++ git libboost-dev libeigen3-dev libgdal-dev libpython3-dev python3 python3-pip \
python3-matplotlib python3-tk lcov libgtest-dev libtbb-dev swig libgeos-dev \
gnuplot libtinyxml2-dev nlohmann-json3-dev
python3 -m pip install gcovr
Also, OR-tools for C++ is needed. Follow its installation process.
brew install cmake swig gdal geos or-tools tinyxml2 eigen tbb boost gnuplot googletest
C++
Clone this repository. Then, from the main folder of the project:
mkdir -p build;
cd build;
cmake ..;
make -j$(nproc);
sudo make install;
mkdir -p build;
cd build;
cmake -DCMAKE_PREFIX_PATH="$(brew --prefix)" -DPython_EXECUTABLE="$(which python3)" ..;
make -j$(sysctl -n hw.ncpu);
sudo make install;
To add Fields2Cover into your CMakeLists.txt, it is as easy as:
find_package(Fields2Cover REQUIRED)
target_link_libraries(<your_package> Fields2Cover)
Python
The python module needs CMake >= 3.18 and Python >= 3.9, and the system
requirements above installed — OR-tools must be discoverable through
CMAKE_PREFIX_PATH. Either way the package is compiled on your machine,
including the SWIG bindings; SWIG, CMake and Ninja are fetched into the
isolated build environment, so no system SWIG is needed.
Released versions are on PyPI:
pip install fields2cover
On macOS:
CMAKE_PREFIX_PATH="$(brew --prefix)" pip install fields2cover
Clone this repository. Then, from the main folder of the project:
pip install .
On macOS:
CMAKE_PREFIX_PATH="$(brew --prefix)" pip install .
Alternatively, use the manual cmake route, adjusting the
BUILD_PYTHON option of the existing build:
cd build;
cmake -DBUILD_PYTHON=ON ..;
make -j$(nproc);
sudo make install;
To test if the compilation and installation of the python interface is correct, run:
python3 -c "import fields2cover as f2c; print(f2c.__version__)"
Or run the tests on the main folder:
python3 -m pytest tests/python/