AssembleTrajectories Module
Module contents
-
template<typename TrajectoryT, typename PointIteratorT>
class AssembleTrajectories Assemble time-sorted points into trajectories
We often receive input data as sequences of points sorted by timestamp. In order to manipulate these data sets as trajectories instead of as isolated points we must perform some sort of connect-the-dots operation to group them together. This class implements that operation.
Suppose for the sake of argument that our input is sorted first by object ID and second by increasing timestamp. Now consider the block of points corresponding to a single object ID. We divide that into one or more trajectories as follows:
If too much time (as specified by the separation_time parameter) has elapsed between one point and the next, one trajectory has ended and another begins.
If too much distance (as specifide by the separation_distance parameter) lies between one point and the next, one trajectory has ended and another begins.
We implement AssembleTrajectories as an iterator. It consumes an input stream of points sorted by timestamp (not by object ID) and produces complete trajectories. Internally, it keeps track of all the object IDs seen recently and applies the process above to identify and emit complete trajectories.
We can also set a third parameter (minimum_trajectory_length) that silently rejects trajectories that do not contain enough points to be interesting.
Public Types
-
typedef TrajectoryT trajectory_type
-
typedef trajectory_type::point_type point_type
-
typedef AssembleTrajectoriesIterator<point_type, PointIteratorT, trajectory_type> iterator
Public Functions
-
inline AssembleTrajectories()
Instantiate AssembleTrajectories using the default assembly configuration.
Set the default values for a trajectory
Default configuration is:
SeparationDistance = 100
SeparationTime = Duration(minutes(30))
MinimumTrajectoryLength = 2
CleanupInterval = 10000
-
inline AssembleTrajectories(PointIteratorT rangeBegin, PointIteratorT rangeEnd)
Instantiate AssembleTrajectories from a range of elements and default configuration.
If you have a container of points you can use this constructor to create and populate the tree in one swell foop instead of adding elements one at a time.
Set the default values for a trajectory
Default configuration is:
SeparationDistance = 100
SeparationTime = Duration(minutes(30))
MinimumTrajectoryLength = 2
CleanupInterval = 10000
- Parameters:
range_begin – [in] Iterator pointing to beginning of input points
range_end – [in] Iterator pointing past end of input points
-
inline AssembleTrajectories(AssembleTrajectories const &other)
Copy Constructor, create AssembleTrajectories with trajectory data from another trajectory.
- Parameters:
other – [in] AssembleTrajectories instance
-
inline virtual ~AssembleTrajectories()
Destructor.
-
inline AssembleTrajectories &operator=(AssembleTrajectories const &other)
Assign a AssembleTrajectories to the value of another.
- Parameters:
other – [in] AssembleTrajectories to assign value of
- Returns:
AssembleTrajectories with the new assigned value
-
inline bool operator==(AssembleTrajectories const &other) const
Check whether one AssembleTrajectories is equal to another by comparing the properties.
Two items are equal if all of their properties are equal.
- Parameters:
other – [in] AssembleTrajectories for comparison
- Returns:
Boolean indicating equivalency
-
inline bool operator!=(AssembleTrajectories const &other) const
Check whether two AssembleTrajectories are unequal.
- Parameters:
other – [in] AssembleTrajectories for comparison
- Returns:
Boolean indicating equivalency
-
inline iterator begin()
Return an iterator to the first parsed point.
Note
that any changes you make to the parser configuration will invalidate existing iterators.
- Returns:
Iterator to first parsed point
-
inline iterator end()
Return an iterator to detect when parsing has ended.
This iterator is guaranteed to not point at any valid TrajectoryPoint. The only time when
begin() == end()will be when all points have been parsed from the input stream.- Returns:
Iterator past end of point sequence
-
inline void set_input(PointIteratorT const &forefront, PointIteratorT const &rearguard)
Set the start and end points of the trajectory
- Parameters:
forefront – [in] Start point
rearguard – [in] End point
-
inline void set_separation_time(Duration const &d)
Set the time between each point in the trajectory
- Parameters:
d – [in] Time duration between each point in the trajectory
-
inline void set_separation_distance(double d)
Set the distance between each point in the trajectory
- Parameters:
d – [in] Distance between each point in the trajectory
-
inline void set_minimum_trajectory_length(std::size_t len)
Set the minimum length a trajectory can be
- Parameters:
len – [in] Length of the trajectory
-
inline void set_cleanup_interval(int points_between_cleanup)
Set the interval that the trajectory points will be cleaned up
- Parameters:
points_between_cleanup – [in] Number of points to clean up
-
inline double separation_distance() const
- Returns:
The separation distance of the trajectory points
-
inline std::size_t minimum_trajectory_length() const
- Returns:
The minimum length a trajectory can be
-
inline int cleanup_interval() const
Protected Functions
-
inline virtual void set_default_configuration()
Set the default values for a trajectory
Default configuration is:
SeparationDistance = 100
SeparationTime = Duration(minutes(30))
MinimumTrajectoryLength = 2
CleanupInterval = 10000
Private Members
-
PointIteratorT PointBegin
-
PointIteratorT PointEnd
-
double SeparationDistance
-
std::size_t MinimumTrajectoryLength
-
int CleanupInterval