Git Product home page Git Product logo

movetk / movetk Goto Github PK

View Code? Open in Web Editor NEW
63.0 16.0 15.0 19.14 MB

MoveTK is a library for computational movement analysis written in C++.

Home Page: https://movetk.win.tue.nl/

License: Apache License 2.0

CMake 5.24% Batchfile 0.06% Shell 0.21% Dockerfile 0.10% C++ 79.42% C 0.44% Jupyter Notebook 13.27% Python 1.26%
cpp trajectory-analysis movement-analytics computational-geometry computational-movement-analysis trajectory-clustering trajectory-similarity trajectories trajectory-generation movement-data

movetk's Introduction

MoveTK: the movement toolkit

MoveTK-CI-Ubuntu MoveTK-CI-macOS MoveTK-CI-Windows MoveTK-create-docker-image

MoveTK is a library for computational movement analysis written in C++. The library has been developed as part of a collaboration between HERE Technologies , Eindhoven University of Technology and Utrecht University under the Commit2Data program.

Overview

MoveTK is a reusable, well tested, high performant, feature-rich library that incorporates state of the art algorithms for understanding movement. The library is designed to be extensible such that it can be adapted to various movement analysis tasks. It's design is inspired by the designs of CGAL and GUDHI.

You can use this library to:

  • Develop applications for processing (geo) spatial movement data at scale
  • Create high performance applications for analysis of movement data, using the algorithms available in the library

Some examples are shown below:

movetk_algorithm_visualization

The following table lists some of the algorithms available in MoveTK

Feature Algorithm
Trajectory Segmentation Monotone Segmentation [Buchin et al. 2011, Alewijnse et al. 2014]
Model Based Segmentation [Alewijnse et al. 2018]
Trajectory Simplification Douglas-Peucker Simplification [Hershberger et al. 1992,1998]
Imai-Iri Simplification [Chan et al. 1996]
Agarwal Simplification [Agarwal et al. 2005]
Trajectory Similarity Longest Common Subsequence [Vlachos et al. 2002]
Hausdorff & Fréchet Metric [Eiter et al. 1994, Alt et al. 1995]
Trajectory Outlier Detection Optimal Speed Bounded [Custers et al. 2019]
Greedy / Smart Greedy / Local Greedy [Custers et al. 2019]
Trajectory Clustering Sub-trajectory Clustering [Buchin et al. 2008]
Trajectory Interpolation Kinematic Interpolation [Long 2016]
Random Trajectory Generator [Technitis et al. 2015]

Supported compilers

MoveTK has been tested with

  • MSVC 14.29.30133 (VS2019)
  • GCC 11.3.0

Building MoveTK

MoveTK uses the well-established build tool CMake for generating its build files for different generators and OSes. To download and build MoveTK, follow the below steps:

  1. Clone the repository in your desired directory, let this directory be <movetk_root>
git clone --recursive https://github.com/heremaps/movetk.git
  1. Install the dependencies of MoveTK. The following strategies are supported:
Installing dependencies via apt (Ubuntu 22.04) For Ubuntu, install the following packages using apt
sudo apt install libboost-all-dev libgsl-dev libgslcblas0 gsl-bin libgsl27 

For building the documentation, you also need Doxygen

sudo apt install doxygen

For the CGAL backend, you also need the following dependencies

sudo apt install libmpfr-dev libcgal-dev
Installing dependencies via vcpkg (Windows/Linux)

MoveTK provides a vcpkg.json manifest file for use with vcpkg. To install the dependencies, you can either let vcpkg handle it during the CMake generation step in Step 3., or directly call the following inside <movetk_root>:

vcpkg.exe install 

During the CMake generation step in Step 3, you need to add -DCMAKE_TOOLCHAIN_FILE=<vcpkg_root>/scripts/buildsystems/vcpkg.cmake to the CMake command line arguments, where <vcpkg_root> is the root of your vcpkg installation.

Installing dependencies via conan (Windows/Linux)

MoveTK also provides a conanfile.txt to install its dependencies using Conan. For this, install a conan version less than 2.0 (2.0 is at the time of writing the default version when installed via pip, but the dependencies are not up to speed yet). You need a profile for conan to install packages. This profile can be created via the conan profile subcommands, see https://docs.conan.io/1/reference/commands/misc/profile.html. To install the dependencies, run

conan install <movetk_root>/conanfile.txt -if <installation_folder_for_conan> --build=missing

where <installation_folder_for_conan> is some folder you specify where files for finding the dependencies are written.

Finally, add -DCMAKE_PREFIX_PATH=<installation_folder_for_conan> to the end of the CMake invocation at Step 3. This way, CMake can find the dependencies and link them with MoveTK.

Note: if you use a single configuration generator for CMake, such as Ninja or Make, also add the explicit build type to the invocation at Step 3 using -DCMAKE_BUILD_TYPE=<build_type>, with <build_type a CMake build type such as Release. Make sure to match this build type with a build type that you installed the dependencies for (which is determined by the profile).

Note: the vcpkg and conan installation files contain the dependencies for both the Boost and CGAL backend. If you do not want to use the CGAL backend, you need to manually remove the dependency from the respective dependency file.

  1. Generate the MoveTK build files
cmake -S <movetk_root> -B <build_folder> <dependency_options>

with <build_folder your favourite buildfolder for MoveTK and <dependency_options> any options required by the installation of the dependencies, e.g. -DCMAKE_PREFIX_PATH=<conan_install_folder> for the conan approach.

  1. Build MoveTK. Run the following from the build folder
cmake --build .

Building tests and examples

To build the tests and/or examples, add -DMOVETK_BUILD_TESTS=ON resp. -DMOVETK_MOVETK_BUILD_EXAMPLES to the CMake generation step (Step 3).

Selecting backends

MoveTK currently supplies two geometry backends that you can choose from: one based on Boost geometry and one on CGAL. By default, MoveTK only builds with the Boost backend enable. The CGAL backend can be separately enabled by adding -DMOVETK_WITH_CGAL_BACKEND=ON to the CMake generation step. To disable the Boost backend, you can add -DMOVETK_WITH_BOOST_BACKEND=OFF to the generation step.

Using MoveTK in your App

Please refer to this example for a template on how to use MoveTK in your app

In addition, if you add the MoveTK CMake to your own project via add_subdirectory, all you have to do is link with the movetk target.

Third Party Libraries Included In MoveTK

MoveTK utilizes some open source components including:

  1. Modified version of GsTL (see include/third_party/GsTL-1.3)
  2. TNT (Template Numerical Toolkit) (see [include/third_party/GsTL-1.3] folder)
  3. Selection of headers of Boost version 1.70.0 (see [src/include/third_party/boost_future])
  4. Miniball (see [src/include/third_party/miniball])
  5. rapidjson (see include/third_party/rapidjson) MoveTK

Acknowledgements

This project includes GsTL which is software developed by Stanford University and its contributors.

License

Copyright (C) 2017-2020 HERE Europe B.V.

Unless otherwise noted in LICENSE files for specific files or directories, the LICENSE in the root applies to all content in this repository. Note that CGAL is largely GPL, so choosing the CGAL backend may affect the license under which MoveTK is available.

movetk's People

Contributors

aniketmitra001 avatar bacusters avatar bacusters-tue avatar kabverbeek avatar rkoehn avatar tsteenbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

movetk's Issues

Run unit tests in CI

Currently, we are not running the tests as part of CI, which would help catching errors earlier.

Vanilla Docker image does not build

Vanilla Fedora image does not build.
Python dependency is not part of image.
After skipping this, radpidjson header files are then missing

Docker build fails

The workflow for creation of docker image fails with the following error

/opt/conda/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: warning: libwebp.so.7, needed by /opt/conda/lib/libgdal.so, not found (try using -rpath or -rpath-link)```

Remove commented out code

There is some existing code that is commented out, Usually unused typedefs and cout calls. For code quality, I suggest these be removed.

Build documentation

Currently, the CI documentation build process (in the docs folder) causes problems with merging. Need to figure out a different process.

Renaming CMake variables / preprocessor variables to use common prefix

To avoid possible clashes with other libraries, I think it would be nice if we prefix MoveTk-specific CMake variables/ preprocessor variables with a common suffix such as MOVETK_. For me as a CMake gui user, this has the additional benefit that all MoveTk related CMake variables would be grouped.

Implement a geographic/geodetic kernel?

Would it make sense to construct a geographic/geodetic kernel, where we also support conversion between coordinate systems? We could encapsulate the coordinate transformations there instead of having separate functions that either wrap GeographicLib or perform somewhat simplified conversions. In addition, some algorithms may also work for non-Euclidean space.

CI (Windows): include specific required boost packages

Currently, in our Windows CI, we pull in the entirety of boost, which makes the current Windows CI process quite slow (80+ minutes). I think if we use a more finegrained selection of the boost packages, this should reduce the depedencies download and build time in CI

Naming for geometric objects

In our kernels, we name everything prefixed with Movetk e.g. MovetkPoint, MovetkLine. This prefix, however, does not really add any value. Would it make sense to simply rename them to Point, Line etc.? This makes using movetk with user defined kernels perhaps easier, since they do not need to use the prefix.

In addition, it may be convenient to add aliases for the geometric objects in the movetk::geom namespace, e.g.

template<typename Kernel>
using Point = typename Kernel::Point; //or MovetkPoint, if we decide not to remove the prefix

This makes using these types easier, then you can do movetk::geom::Point<Kernel> instead of typename Kernel::Point. This is similar to how CGAL approaches geometric objects.

Parameterisation of geometry backend for python bindings

MoveTK is a geometry backend agnostic library. This means that the choice of the dimension, coordinate type and geometry library (Boost.Geometry or CGAL) is delegated to the application developer. Since, in the library these types are template parameters, the compiler expects these types to be defined while building the project. While writing python bindings with PyBind11, this means that the types have to be defined in the .cpp file. Therefore in the binding code , we will need to define, BoostGeometryKernel2D, BoostGeometryKernel3D, CGALGeometryKernel2D,... So the user if the python module will be restricted by the choice of the dimension and geometry backend defined in the binding code. Moreover we can limit the number type to long double. So the trade off with ease of use seems to come at the cost of lack of flexibility. We need to check if there can be a workaround to this

Refactor Dockerfile to build MoveTK with cmake and dependencies from Miniconda

The docker file in docker/with_jupyterlab uses the cmake installed from the package manager of fedora to build MoveTK
On the other hand xeus-cling required for running the C++ tutorials in a Jupyter notebook is installed with Miniconda.

This can be confusing. Its better to build MoveTK with cmake and dependencies installed from Miniconda

Make namespace follow folder structure?

Maybe this is more of a stylistic question: currently, our namespaces are all prefixed by movetk_ and do not map directly to the folders that the associated methods/classes are in. I personally prefer to synchronize the names of the folders of the (includable) header files with the namespaces that the objects reside in. Using this guideline, it is easier to see what you need to include from a fully qualified name, e.g. movetk::core::MakePoint<> would then reside in some file in 'movetk/core' in the header include folder. Is this something we would want to pursue?

Use "components" for vcpkg/conan dependency specification

vcpkg supports features out-of-the-box, where we can give names to certain dependency sets( see this). It would be nice to use this to split up the dependencies for the different backends, as well as dependencies for building the examples/tests/documentation?

conan can do something similar via options, but then we have to convert the conanfile.txt to a conanfile.py file and implement it( see this)

std::max_element with boost::make_transform_iterator fails to compile on some version of clang

Hi Bram

wrt the the following changes in Distances.h

//Use std::function, otherwise boost will error when trying to copy the transform_iterator
std::function<NT(const typename Kernel::MovetkPoint &)> transform = [poly_a](const auto &polyBEl) {
                     SqDistance sqDist;
                     return std::sqrt(sqDist(*poly_a, polyBEl));
                 };

auto maxElIt = std::max_element(boost::make_transform_iterator(poly_b, transform), boost::make_transform_iterator(poly_b_beyond, transform));

This fails to compile on some versions of clang as std::max_element expects an iterators that is a model of a ForwardIterator and boost::make_transform_iterator seems to model an InputIterator

Please see this stack overflow discussion.

As suggested in the discussion of SO, we could return by reference from the lambda function but doesn't seem to be advisable. Please see the notes here

For the lack of a better alternative I have had to substitute the above with the following suboptimal piece of code

  std::vector<NT> distances;
                std::transform(poly_b, poly_b_beyond, std::back_insert_iterator(distances),
                               [poly_a](const auto &polyBEl) {
                                   SqDistance sqDist;
                                   return std::sqrt(sqDist(*poly_a, polyBEl));
                               });
                auto maxElIt = std::max_element(std::begin(distances), std::end(distances));

in this commit d0e8b27

Use std::stable_sort in probe deduplication

With the TrajectoryReader we can read trajectories from probes, possibly removing duplicate probes by for example the dates. Should we use a stable sorting algorithm before that to make sure the outcome is the same if we use the same probe data file? We now use std::sort, which does not guarantee this. We maybe could use std::stable_sort instead?

Remove GDAL dependency

GDAL is a heavyweight dependency for MoveTk, and a quick scan of the codebase shows that we only use it for a polygon reader and generic converters for iterators to GDAL data types. It seems to me like a user should be able to decide for themselves whether they want to use GDAL for this functionality, especially since it is heavy weight, hence we could remove the dependency and glue code. Alternatively, we could implement a kernel based on GDAL instead, but I'm not entirely sure this has a lot of added value.

Keep Github Actions cache alive for dependencies

GA automatically deletes the cache if it hasn't been used for a week. Especially for the dependencies, this makes the build times of the CI increase, while our dependencies do not often change. See if we can construct a script that runs once a week to keep this cache alive.

Initial values in movetk_core::get_time_diffs() and movetk_core::get_distances()

Hi Bram

I see that in your latest commits you have disabled the setting of the first value on the output iterator for the above functions

//*iter = 0;

with the following comment

Add a less strict input iterator requirement. Add point iterators to trajectory utils and make some function a bit less strict on the iterators

The idea of setting the first value to zero was to ensure that the size of the output is same as the input, as as we treat the result of movetk_core::get_time_diffs() as a column that can be added to the tabular trajectory data structure , so if the tabular trajectory has size m x n, then the output of movetk_core::get_time_diffs() is m x 1

Not setting the first value to 0 results in an output of size (m - 1) x 1

get_time_diffs and get_distances inconsistent

For N timestamps, get_time_diffs returns n-1 results. Should this be N, with the first value being 0?
For N positions, get_distances returns N results. Neither the first or last distance is 0. One of these should be incorrect.
Both methods should be consistent.

Calculation appears to be difference between N and N +1, hence It appears that the last distance calculation must be incorrect as there is no N + 1

However, a change in behaviour will break existing code, so more clarification in the API documentation is perhaps called for.

Bump Catch2 to version 3

The current version we use does not build anymore on modern Linux due to changes in libstdc++. This is fixed upstream in Catch2, but requires us bumping the version. There are some breaking changes between v2.x and v3.x though, so we need to check what needs to change.

Setup CI for code coverage

We may not want to always run this, but maybe every week/month or something like that. May also be interesting to be able to manually trigger it

Refactor GeoJSONUtil.h

The current GeoJSONUtil.h in movetk/io/ creates the GeoJSON structure by adding to a stream operator and is not very extendable.

MovetkGeometryKernel should have concept-like definitions for the geometric primitives

Reported by @bacusters-tue

At present there are no concept-like definitions for the geometric primitives for the kernel
Right now the problem is lets say we are using the Boost Backend and in the wrapper for boost we have added an interface for adding two points , but for the the CGAL backend we haven’t , so when we parameterise an algorithm that adds two points and use the CGAL backend , we will get a compile time error. So if we define a set of requirements on the MovetkGeometryKernel (/src/include/movetk/geom/GeometryInterface.h) wherein for instance WrapperGeometryKernel::Wrapper_Point should satisfy those requirements, we will in a way be enforcing the homogeneity of the implementation in WrapperGeometryKernel.

Refactor Headers

The examples/include/GeometryBackendTraits.h header file is now supposed to be included in py/movetk_geometry.cpp. Also tutorials/TrivialGeometry.h is similar to examples/include/GeometryBackendTraits.h
So have one copy of GeometryBackendTraits.h and place it under src/include/movetk/utils

While you are at it move Geolife.h, GeolifeProbeTraits.h,GeolifeTrajectoryTraits.h, HereProbeTraits.h, Algorithms.h to src/include/movetk/utils as these are specialisations of various traits classes in the library and are mainly a collection of utility headers for the application developer

Assertion failed in kinematic interpolator

When running the tests in Debug mode on Windows, the assertion at line 285 of movetk/algo/Interpolation.h is triggered:
assert(eps * eps < MOVETK_EPS);

This happens during test case 'kinematic trajectory interpolation 1'. eps is a MovetkVector with coordinates (6.4709688360932933, 5.1473812288972436) for me, which evidently is much larger than MOVETK_EPS when "squared".

I'm not sure whether the assertion is incorrect or the code does something interesting. @aniketmitra001 do you know what causes this issue?

Add clang format and clang tidy files

This way we can enforce some standard on code styling and formatting, and makes it easier for users to contribute. We should decide what kind of code style we want for this.

Map Matching & MoveTK

In the development meeting of October 2nd,2020 the following was suggested:

  • Discussed whether to integrate map matcher into MoveTK, consensus is to add tutorials and/or documentation on how to interface with the most common mapmatchers like grasshopper and Valhalla.
  • Related to map matching, there is a need to provide a network/graph representation for some algorithms into MoveTK.
  • The suggestion was to pick one algorithm as a first use case to guide development, as MoveTK would need to need a proper representation of a network (wherein the graph has a corresponding geometric representation as well). The question is, how can MoveTK have such a data structure?
    • It was suggested that MoveTK could follow a similar design pattern as the existing geometric backend. Provide a generic specification to the graph: in terms of operators/representation as a concept
  • Discussion around which graph library to support as there is some existing support for boost graph, suggestion to look into other libraries such as igraph.

Algorithms in Statistics.h have a tight coupling with TabularTrajectory and ColumnarTrajectory types

The implementation of algorithms in movetk/algo/Statistics.h assumes that the input trajectory is of type TabularTrajectory or ColumnarTrajectory.

However, sometimes the trajectory type may not necessarily be of these two types, for example the return type of Splitter::begin()

So maybe its better to use ``TrajectoryTraitsto infer the type of a particular field instead of usingtypename Trajectory::template FieldType```

Build of Python binding movetk_geometry.cpp fails on Ubuntu 18.04

make fails with the following error

[ 98%] Building CXX object py/CMakeFiles/movetk_geometry.dir/movetk_geometry.cpp.o
/home/runner/work/movetk/movetk/py/movetk_geometry.cpp:44:16: error: expected constructor, destructor, or type conversion before ‘(’ token
 PYBIND11_MODULE(movetk_geometry, m) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.