tracktable.source package

Submodules

tracktable.source.combine module

tracktable.source.combine.interleave_points_by_timestamp(*point_sources)[source]

From a series of point sources, generate a new sequence sorted by timestamp.

Given one or more point sources that are themselves sorted by timestamp, generate a new sequence containing all of the points from all sources, again sorted by increasing timestamp.

Note that this function reads all the points into memory in order to build a priority queue. If you’re feeling ambitious, feel free to write a new version that keeps only a single point in memory from each source at any time.

Parameters

*point_sources (iterables) – One or more iterables of points

Yields

TrajectoryPoint instances sorted by increasing timestamp

tracktable.source.path_point_source module

tracktable.source.path_point_source - Generate points along a path

class tracktable.source.path_point_source.TrajectoryPointSource[source]

Bases: object

Generate points interpolated between start and finish.

start_point

Location for first point

Type

TrajectoryPoint

end_point

Location for last point

Type

TrajectoryPoint

num_points

Number of points in the path (at least 2)

Type

integer

points()[source]

Return an iterable containing the generated points in the trajectory.

Longitude, latitude, altitude (if present) and time will be interpolated evenly from start_point to end_point and start_time to end_time. Each point will have the object ID specified in self.object_id.

Returns

An iterable of TrajectoryPoint instances

Raises

ValueError – impossible / illegal values specified for one or more parameters

tracktable.source.trajectory module

tracktable.source.trajectory - Sources that turn a sequence of points into a sequence of trajectories

class tracktable.source.trajectory.AssembleTrajectoryFromPoints[source]

Bases: object

Turn a sequence of points into a set of trajectories

We begin with an input sequence of TrajectoryPoints sorted by increasing timestamp. As we iterate over that sequence, we separate points by their object IDs and build up a new trajectory for each object ID. When we see a gap of duration ‘separation_time’ or distance ‘separation_distance’ between the previous and latest point for a given object ID, we package up the points so far, emit a new trajectory and use the latest point to start a new one.

input

Sequence of TrajectoryPoint objects sorted by timestamp

Type

iterable

separation_time

Maximum permissible time (in MINUTES) difference between adjacent points in a trajectory

Type

datetime.timedelta

separation_distance

Maximum permissible geographic distance (in KM) between adjacent points in a trajectory

Type

float

minimum_length

Complete trajectories with fewer than this many points will be discarded

Type

integer

Example

p_source = SomePointSource() (configure point source here)

t_source = AssembleTrajectoryFromPoints() t_source.input = p_source.points() t_source.separation_time = datetime.timedelta(minutes=30) t_source.separation_distance = 100 t_source.minimum_length = 10

for trajectory in t_source.trajectories():

(do whatever you want)

trajectories()[source]

Return trajectories assembled from input points.

Once you have supplied a point source in the ‘input’ attribute (which can be any iterable but is commonly the output of a PointSource) you can call trajectories() to get an iterable of trajectories. All the computation happens on demand so the execution time between getting one trajectory and getting the next one is unpredictable.

There are only loose guarantees on the order in which trajectories become available. Given trajectories A and B, if timestamp(A.end) < timestamp(B.end) then A will come up before B.

The input sequence of trajectories will only be traversed once.

Yields

Trajectories built from input points

Module contents

tracktable.source - Point/trajectory sources for Tracktable trajectories

This module contains Sources. A Source is an object that produces points or trajectories. These can come from anywhere else, whether loaded from a file, extracted from a database or created algorithmically.