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 C++/Core/Tests/test_trajectory_point.cpp (XXX CHECK THIS) for a demonstration.

Public Types

typedef BasePointT Superclass

Public Functions

TrajectoryPoint()

Instantiate an uninitialized point.

virtual ~TrajectoryPoint()
TrajectoryPoint(TrajectoryPoint const &other)

Initialize a TrajectoryPoint as a copy of an existing point.

TrajectoryPoint(Superclass const &other)

Initialize with coordinates from a base point.

TrajectoryPoint(const double *coords)
TrajectoryPoint operator=(TrajectoryPoint const &other)

Make this TrajectoryPoint a copy of an existing point.

bool operator==(TrajectoryPoint const &other) const

Check two points for equality.

bool operator!=(TrajectoryPoint const &other) const

Check two points for inequality.

std::string object_id() const

Return this point’s object ID.

Timestamp timestamp() const

Return this point’s timestamp.

void set_object_id(std::string const &new_id)

Set this point’s object ID.

void set_timestamp(Timestamp const &ts)

Set this point’s timestamp.

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

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

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

Retrieve a named property with checking.

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

Retrieve a named property or a default value.

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

Retrieve a named property without safety checking.

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

Safely retrieve a named property with a string value.

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

Safely retrieve a named property with a floating-point value.

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

Safely retrieve a named property with a timestamp value.

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.

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

Safely retrieve a named property with a floating-point value.

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

Safely retrieve a named property with a timestamp value.

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

Check whether a property is present.

std::string to_string() const

Convert point to a human-readable string form.

double current_length() const

Get length of trajectory up to this point.

void set_current_length(double length)

Set length of trajectory up to this point.

double current_length_fraction() const

Get fraction of total length of trajectory up to this point.

void set_current_length_fraction(double fraction)

Set fraction of total length of trajectory up to this point.

double current_time_fraction() const

Get fraction of total duration of trajectory up to this point.

void set_current_time_fraction(double fraction)

Set fraction of total duration of trajectory up to this point.

PropertyMap &__non_const_properties()

INTERNAL METHOD.

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

INTERNAL METHOD.

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>
void serialize(archive_t &archive, const unsigned int version)

Friends

std::ostream &operator<<(std::ostream &out, TrajectoryPoint const &point)