TrajectoryPoint Module

Module Contents

template<class BasePointT>
class TrajectoryPoint : public BasePointT

Add object ID, timestamp, property map.

This class will add trajectory properties (a timestamp, an object ID and storage for named properties) to any point class.

Timestamp is a tracktable::Timestamp which (under the hood) is a boost::posix_time::ptime. Object ID is stored as a string.

We also include an interface to set, get and enumerate arbitrary named properties. The only restriction is that the types of these properties are limited to timestamps, floating-point numbers and strings. If you need something more flexible than that please consider creating your own alternative point class either by subclassing TrajectoryPoint or by composition.

Note

Named property support is implemented using boost::variant. You can either use boost::get<> to cast it to your desired data type or call one of the (type)_property_value functions to retrieve it with no casting necessary. Take a look at tracktable/Core/Tests/test_trajectory_point_lonlat.cpp (XXX CHECK THIS) for a demonstration.

Public Types

typedef BasePointT Superclass

Public Functions

inline TrajectoryPoint()

Instantiate an uninitialized point.

inline virtual ~TrajectoryPoint()

Destructor for a trajectory point.

inline TrajectoryPoint(TrajectoryPoint const &other)

Copy contructor, create a TrajectoryPoint with a copy of another

Parameters:

other[in] TrajectoryPoint to copy from

inline TrajectoryPoint(Superclass const &other)

Instantiate a TrajectoryPoint with a base point

Parameters:

other[in] Basepoint

inline TrajectoryPoint(const double *coords)

Instantiate TrajectoryPoint using specified coordniates

Parameters:

coords[in] Coordinates to set in point

inline TrajectoryPoint operator=(TrajectoryPoint const &other)

Assign a TrajectoryPoint to the value of another.

Parameters:

other[in] TrajectoryPoint to assign value of

Returns:

TrajectoryPoint with the new assigned value

inline bool operator==(TrajectoryPoint const &other) const

Check two points for equality

Two TrajectoryPoints are equal if and only if they have:

  • the same coordinates (base point)

  • the same object ID

  • the same timestamp

  • the same user-defined properties

Parameters:

other[in] TrajectoryPoint to assign value of

inline bool operator!=(TrajectoryPoint const &other) const

Check whether two TrajectoryPoint are unequal.

Parameters:

other[in] TrajectoryPoint for comparison

Returns:

Boolean indicating equivalency

inline std::string object_id() const
Returns:

This point’s object ID

inline Timestamp timestamp() const
Returns:

This point’s timestamp

inline void set_object_id(std::string const &new_id)

Set this point’s object ID

Parameters:

new_id[in] ID to assign to object

inline void set_timestamp(Timestamp const &ts)

Set this point’s timestamp

Parameters:

ts[in] timestamp to assign to object

inline void set_property(std::string const &name, PropertyValueT const &value)

Set a named property with a variant value (let the caller handle the type)

Parameters:
  • name[in] Name of property

  • name[in] Value to assign to property

inline PropertyValueT property(std::string const &name, bool *ok = 0) const

Retrieve a named property with checking

Parameters:
  • name[in] Name of property to retrieve

  • ok[in] If specified, this will be set to true or false as the property is found/not found

Returns:

Property as a boost::variant

inline PropertyValueT property(std::string const &name, PropertyValueT const &default_value) const

Retrieve a named property or a default value

Parameters:
  • name[in] Name of property to retrieve

  • default_value[in] Value to return if property is not present

Returns:

Property as a boost::variant

inline PropertyValueT property_without_checking(std::string const &name) const

Retrieve a named property without safety checking

It is the caller’s responsibility to know whether the requested property actually exists when using this function.

Parameters:

name[in] Name of property to retrieve

Returns:

Property as a boost::variant

inline std::string string_property(std::string const &name, bool *ok = 0) const

Safely retrieve a named property with a string value

Parameters:
  • name[in] Name of property to retrieve

  • ok[in] If specified, this will be set to true or false as the property is found/not found

Returns:

Property as a std::string

inline double real_property(std::string const &name, bool *ok = 0) const

Safely retrieve a named property with a floating-point value

Parameters:
  • name[in] Name of property to retrieve

  • ok[in] If specified, this will be set to true or false as the property is found/not found

Returns:

Property as a double

inline Timestamp timestamp_property(std::string const &name, bool *ok = 0) const

Safely retrieve a named property with a timestamp value

Parameters:
  • name[in] Name of property to retrieve

  • ok[in] If specified, this will be set to true or false as the property is found/not found

Returns:

Property as a Timestamp

inline std::string string_property_with_default(std::string const &name, std::string const &default_value) const

Safely retrieve a named property with a string value

Parameters:
  • name[in] Name of property to retrieve

  • default_value[in] String value to return if property is not present

Returns:

Property as a std::string

inline double real_property_with_default(std::string const &name, double default_value) const

Safely retrieve a named property with a floating-point value

Parameters:
  • name[in] Name of property to retrieve

  • default_value[in] Double value to return if property is not present

Returns:

Property as a double

inline Timestamp timestamp_property_with_default(std::string const &name, Timestamp const &default_value) const

Safely retrieve a named property with a timestamp value

Parameters:
  • name[in] Name of property to retrieve

  • default_value[in] Timestamp value to return if property is not present

Returns:

Property as a Timestamp

inline bool has_property(std::string const &name) const

Check whether a property is present

Parameters:

name[in] Name of desired property

Returns:

True if present, False if not

inline std::string to_string() const

Convert point to a human-readable string form

Returns:

The string representation of the point

inline double current_length() const

Get length of trajectory up to this point

When we build a trajectory this property will be set to the total length of the trajectory up to this point. This will be 0 at the very first point and some non-negative value thereafter.

The initial value of current_length is -1 to indicate that it is not yet set.

Returns:

Trajectory length so far

inline void set_current_length(double length)

Set length of trajectory up to this point

You will almost certainly not need to call this method yourself. It is the responsibility of the Trajectory class to compute and set the lengths.

Parameters:

length – Length up to this point

inline double current_length_fraction() const

Get fraction of total length of trajectory up to this point

When we build a trajectory this property will be set to the fraction of length of the trajectory up to this point. This will be 0.0 at the very first point and range up to 1.0 thereafter.

The initial value of current_length_fraction is -1.0 to indicate that it is not yet set.

Returns:

fraction of Trajectory length so far

inline void set_current_length_fraction(double fraction)

Set fraction of total length of trajectory up to this point

You will almost certainly not need to call this method yourself. It is the responsibility of the Trajectory class to compute and set the lengths.

Parameters:

fraction – Fraction of Trajectory Length up to this point

inline double current_time_fraction() const

Get fraction of total duration of trajectory up to this point

When we build a trajectory this property will be set to the fraction of duration of the trajectory up to this point. This will be 0.0 at the very first point and range up to 1.0 thereafter.

The initial value of current_time_fraction is -1.0 to indicate that it is not yet set.

Returns:

fraction of Trajectory duration so far

inline void set_current_time_fraction(double fraction)

Set fraction of total duration of trajectory up to this point

You will almost certainly not need to call this method yourself. It is the responsibility of the Trajectory class to compute and set the fractions.

Parameters:

fraction – Fraction of Trajectory Duration up to this point

inline PropertyMap &__non_const_properties()
inline PropertyMap const &__properties() const
inline void __set_properties(PropertyMap const &props)

Protected Attributes

double CurrentLength

Length of trajectory up to this point.

double CurrentLengthFraction

Length fraction of trajectory up to this point.

double CurrentTimeFraction

Duration fraction of trajectory up to this point.

std::string ObjectId

Storage for a point’s object ID.

PropertyMap Properties

Storage for a point’s named properties.

Timestamp UpdateTime

Storage for a point’s timestamp.

Private Functions

template<typename archive_t>
inline void serialize(archive_t &archive, const unsigned int)

Serialize the points and properties to an archive

Parameters:
  • ar[in] Archive to serialize to

  • version[in] Version of the archive

Friends

friend class boost::serialization::access
inline friend std::ostream &operator<<(std::ostream &out, TrajectoryPoint const &point)