Classes
Below find all the documentation provided for the algorithms implemented and important objects abstractions used in this package.
Calculate Modules
- class calculate.base.BaseAlgorithm(libname: str)
Base class for distance calculation algorithms.
Provides a simple way to load shared libraries (.so files) implemented and built in C.
Parameters
- libnamestr
The library name (i.e.: the file name without the file extension).
Attributes
- libctypes.CDLL
A loaded shared library that implements the algorithm in C.
- class calculate.euclidean.Euclidean(libname='libeuclidean')
An instance for calculating the Euclidean distance between two lists of floats (trajectories).
- Parameters:
libname (str, default "libeuclidean") – The file name of the compiled shared library.
- Example:
Calculating the Euclidean distance between two points:
>>> euclidean = Euclidean() # Initializes object and loads shared library >>> euclidean.distance([(1, 2)], [(3, 4)]) 2.8284271247461903
- class calculate.dtw.DTW(libname='libdtw')
DTW (Dynamic Time Warping) algorithm class for calculating the similarity between two sequences of geographical coordinates.
Inherits from
- BaseAlgorithmstmeasures.calculate.base.BaseAlgorithm
The base class for algorithms in the stmeasures library.
Methods
- distance(seq1, seq2)
Computes the DTW distance between two coordinate sequences.
- class calculate.rdp.RDP(libname='librdp')
An RDP class that implements the Ramer-Douglas-Peucker (RDP) algorithm for simplifying a sequence of coordinates.
- class calculate.lcss.LCSS(libname='liblcss')
A class to compute the Longest Common Subsequences (LCSS) algorithm between two trajectory-like lists of floats.
- Parameters:
libname (str, optional, default is "liblcss") – The file name of the compiled shared library.
- Example:
Calculating the LCSS distance between two points, (1, 2) and (3, 4):
>>> lcss = LCSS() # Initializes object and loads shared library >>> lcss.distance([(1, 2)], [(3, 4)]) 0.5
- class calculate.frechet.Frechet(libname='libfrechet')
A Frechet instance that computes the Frechet distance between two trajectories-like (list[float]).
Parameters
- libnamestr, default: “libfrechet”
The file name of the compiled shared library.
Examples
Calculating the Frechet distance between Point 1 (1, 2) and Point 2 (3, 4)
>>> frechet = Frechet() # Initializes object and loads shared library >>> frechet.distance([1, 2], [3, 4]) 2.0
- class calculate.hausdorff.Hausdorff(libname='libhausdorff')
A Hausdorff instance that computes the Hausdorff distance between two trajectories-like (list[float]).
Parameters
- libnamestr, default: “libhausdorff”
The file name of the compiled shared library.
Examples
Calculating the Hausdorff distance between Point 1 (1, 2) and Point 2 (3, 4)
>>> hausdorff = Hausdorff() # Initializes object and loads shared library >>> hausdorff.distance([1, 2], [3, 4]) 2.0
- class calculate.editdistance.EditDistance(libname='libeditdist')
A class to compute edit distances between two trajectory-like lists of floats.
- Parameters:
libname (str, optional, default is "libeditdist") – The file name of the compiled shared library.
- Example:
Calculating the Edit Distance with Real Penalty between two points, (1, 2) and (3, 4):
>>> editdistance = EditDistance() # Initializes object and loads shared library >>> editdistance.erp([(1, 2)], [(3, 4)]) 4.0
- class calculate.manhattan.Manhattan(libname='libmanhattan')
A manhattan instance that mainly computes the manhattan algorithm between two trajectories-like (list[float]).
Parameters
- libnamestr, default: “libmanhattan”
The file name of the compiled shared library.
Examples
Calculating the manhattan distance of Point 1 (1, 2) and Point 2 (3, 4)
>>> manhattan = Manhattan() # Intializes object and loads shared library >>> manhattan.distance([1, 2], [3, 4]) # |1 - 3| + |2 - 4| = 4 4.0
- class calculate.sad.SAD(libname='libsad')
A class to compute the Spatial Assembling Distance (SAD) algorithm between two trajectory-like lists of floats.
- Parameters:
libname (str, optional, default is "libsad") – The file name of the compiled shared library.
- Example:
Calculating the SAD distance between two trajectories:
>>> sad = SAD() # Initializes object and loads shared library >>> sad.distance([(1, 2), (3, 4)], [(5, 6), (7, 8)], epsilon=1.0) 0.8
Objects
- class objects.cstructures.Point
Represents a geographical point with latitude and longitude coordinates.
Attributes
- latitudectypes.c_double
Latitude of the point.
- longitudectypes.c_double
Longitude of the point.
- class objects.cstructures.Trajectory
Represents a sequence of geographical points.
Attributes
- pointsctypes.POINTER(Point)
A pointer to an array of Point structures.
- sizectypes.c_size_t
The size of the coordinate sequence (number of points).
- class objects.geojson.GeoJSON(data)
Represents a GeoJSON data structure for storing trajectories.
This class is used to load, store, and process GeoJSON data representing multiple trajectories. It can extract relevant features like the trajectory coordinates, IDs, and timestamps from raw GeoJSON data.