MobilityDB 1.3
Loading...
Searching...
No Matches
Macros | Functions
temporal_analytics.c File Reference

Analytics function for temporal types. More...

#include "temporal/temporal_analytics.h"
#include <assert.h>
#include <math.h>
#include <float.h>
#include <postgres.h>
#include <utils/timestamp.h>
#include <liblwgeom_internal.h>
#include <meos.h>
#include <meos_internal.h>
#include <meos_internal_geo.h>
#include "temporal/postgres_types.h"
#include "temporal/set.h"
#include "temporal/span.h"
#include "temporal/spanset.h"
#include "temporal/temporal_tile.h"
#include "temporal/tsequence.h"
#include "temporal/type_util.h"
#include "geo/tgeo_distance.h"
#include "geo/tgeo_spatialfuncs.h"

Macros

#define DP_STACK_SIZE   256
 
#define MAX_MATRIX_LEN   65536
 

Functions

static double dist2d_pt_pt (POINT2D *p1, POINT2D *p2)
 Return the 2D distance between the points. More...
 
static double dist2d_pt_seg (POINT2D *p, POINT2D *A, POINT2D *B)
 Return the 2D distance between the point the segment. More...
 
static double dist3d_pt_pt (POINT3DZ *p1, POINT3DZ *p2)
 Return the 3D distance between the points. More...
 
static double dist3d_pt_seg (POINT3DZ *p, POINT3DZ *A, POINT3DZ *B)
 Return the 3D distance between the point the segment. More...
 
static int int_cmp (const void *a, const void *b)
 Return a negative or a positive value depending on whether the first number is less than or greater than the second one. More...
 
double temporal_dyntimewarp_distance (const Temporal *temp1, const Temporal *temp2)
 Return the Dynamic Time Warp distance between two temporal values. More...
 
Matchtemporal_dyntimewarp_path (const Temporal *temp1, const Temporal *temp2, int *count)
 Return the Dynamic Time Warp distance between two temporal values. More...
 
double temporal_frechet_distance (const Temporal *temp1, const Temporal *temp2)
 Return the Frechet distance between two temporal values. More...
 
Matchtemporal_frechet_path (const Temporal *temp1, const Temporal *temp2, int *count)
 Return the Frechet distance between two temporal values. More...
 
double temporal_hausdorff_distance (const Temporal *temp1, const Temporal *temp2)
 Return the Hausdorf distance between two temporal values. More...
 
double temporal_similarity (const Temporal *temp1, const Temporal *temp2, SimFunc simfunc)
 Return the similarity distance between two temporal values. More...
 
Matchtemporal_similarity_path (const Temporal *temp1, const Temporal *temp2, int *count, SimFunc simfunc)
 Return the similarity path between two temporal values. More...
 
Temporaltemporal_simplify_dp (const Temporal *temp, double dist, bool syncdist)
 Return a temporal float/point simplified using the Douglas-Peucker line simplification algorithm. More...
 
Temporaltemporal_simplify_max_dist (const Temporal *temp, double dist, bool syncdist)
 Return a temporal float/point simplified using a single-pass Douglas-Peucker line simplification algorithm. More...
 
Temporaltemporal_simplify_min_dist (const Temporal *temp, double dist)
 Return a temporal float/point sequence simplified ensuring that consecutive values are at least a given distance apart. More...
 
Temporaltemporal_simplify_min_tdelta (const Temporal *temp, const Interval *mint)
 Return a temporal float/point sequence simplified ensuring that consecutive values are at least a certain time interval apart. More...
 
Temporaltemporal_tprecision (const Temporal *temp, const Interval *duration, TimestampTz torigin)
 Return a temporal value with the precision set to time bins. More...
 
Temporaltemporal_tsample (const Temporal *temp, const Interval *duration, TimestampTz torigin, interpType interp)
 Return a temporal value sampled according to time bins. More...
 
static void tfloatseq_findsplit (const TSequence *seq, int i1, int i2, int *split, double *dist)
 Find a split when simplifying the temporal float sequence using the Douglas-Peucker line simplification algorithm. More...
 
TimestampTz timestamptz_tprecision (TimestampTz t, const Interval *duration, TimestampTz torigin)
 Return a timestamptz with the precision set to a time bin. More...
 
double tinstant_distance (const TInstant *inst1, const TInstant *inst2, datum_func2 func)
 Return the distance between two temporal instants. More...
 
TInstanttinstant_tprecision (const TInstant *inst, const Interval *duration, TimestampTz torigin)
 Return a temporal instant with the precision set to a time bin. More...
 
TInstanttinstant_tsample (const TInstant *inst, const Interval *duration, TimestampTz torigin)
 Return a temporal value sampled at time bins. More...
 
static double tinstarr_hausdorff_distance (const TInstant **instants1, int count1, const TInstant **instants2, int count2)
 Return the discrete Hausdorff distance between two temporal values. More...
 
static double tinstarr_similarity (const TInstant **instants1, int count1, const TInstant **instants2, int count2, SimFunc simfunc)
 Linear space computation of the similarity distance between two temporal values. More...
 
static double tinstarr_similarity1 (double *dist, const TInstant **instants1, int count1, const TInstant **instants2, int count2, SimFunc simfunc)
 Linear space computation of the similarity distance between two temporal values. More...
 
static Matchtinstarr_similarity_matrix (const TInstant **instants1, int count1, const TInstant **instants2, int count2, SimFunc simfunc, int *count)
 Return the similarity distance between two temporal values. More...
 
static void tinstarr_similarity_matrix1 (const TInstant **instants1, int count1, const TInstant **instants2, int count2, SimFunc simfunc, double *dist)
 Return the similarity distance between two temporal values using a full matrix. More...
 
static Matchtinstarr_similarity_path (double *dist, int count1, int count2, int *count)
 Return the similarity path between two temporal values based on the distance matrix. More...
 
static void tpointseq_findsplit (const TSequence *seq, int i1, int i2, bool syncdist, int *split, double *dist)
 Find a split when simplifying the temporal point sequence using the Douglas-Peucker line simplification algorithm. More...
 
static TSequencetsequence_simplify_dp (const TSequence *seq, double dist, bool syncdist, uint32_t minpts)
 Return a temporal float sequence set/point simplified using the Douglas-Peucker line simplification algorithm. More...
 
TSequencetsequence_simplify_max_dist (const TSequence *seq, double dist, bool syncdist, uint32_t minpts)
 Return a temporal float/point sequence simplified using a single-pass implementation of the Douglas-Peucker line simplification algorithm that checks whether the provided distance threshold is exceeded. More...
 
TSequencetsequence_simplify_min_dist (const TSequence *seq, double dist)
 Return a temporal float/point sequence simplified ensuring that consecutive values are at least a given distance apart. More...
 
TSequencetsequence_simplify_min_tdelta (const TSequence *seq, const Interval *mint)
 Return a temporal float/point sequence simplified ensuring that consecutive values are at least a certain time interval apart. More...
 
TSequencetsequence_tprecision (const TSequence *seq, const Interval *duration, TimestampTz torigin)
 Return a temporal sequence with the precision set to a time bin. More...
 
TSequencetsequence_tsample (const TSequence *seq, const Interval *duration, TimestampTz torigin, interpType interp)
 Return a temporal value sampled according to time bins. More...
 
int tsequence_tsample_iter (const TSequence *seq, TimestampTz lower_bin, TimestampTz upper_bin, int64 tunits, TInstant **result)
 Return a temporal value sampled according to time bins. More...
 
TSequenceSettsequenceset_cont_tsample (const TSequenceSet *ss, const Interval *duration, TimestampTz torigin, interpType interp)
 Return a temporal value sampled according to time bins. More...
 
TSequencetsequenceset_disc_tsample (const TSequenceSet *ss, const Interval *duration, TimestampTz torigin)
 Return a temporal value sampled according to time bins. More...
 
static TSequenceSettsequenceset_simplify_dp (const TSequenceSet *ss, double dist, bool syncdist, uint32_t minpts)
 Return a temporal float sequence set/point simplified using the Douglas-Peucker line simplification algorithm. More...
 
static TSequenceSettsequenceset_simplify_max_dist (const TSequenceSet *ss, double dist, bool syncdist, uint32_t minpts)
 Return a temporal float sequence set/point simplified using a single-pass Douglas-Peucker line simplification algorithm. More...
 
TSequenceSettsequenceset_simplify_min_dist (const TSequenceSet *ss, double dist)
 Return a temporal float/point sequence simplified ensuring that consecutive values are at least a given distance apart. More...
 
TSequenceSettsequenceset_simplify_min_tdelta (const TSequenceSet *ss, const Interval *mint)
 Return a temporal float/point sequence simplified ensuring that consecutive values are at least a certain time interval apart. More...
 
TSequenceSettsequenceset_tprecision (const TSequenceSet *ss, const Interval *duration, TimestampTz torigin)
 Return a temporal sequence set with the precision set to a time bin. More...
 
Temporaltsequenceset_tsample (const TSequenceSet *ss, const Interval *duration, TimestampTz torigin, interpType interp)
 Return a temporal value sampled according to time bins. More...
 
Settstzset_tprecision (const Set *s, const Interval *duration, TimestampTz torigin)
 Return a timestamptz set with the precision set to a time bin. More...
 
Spantstzspan_tprecision (const Span *s, const Interval *duration, TimestampTz torigin)
 Return a timestamptz span with the precision set to a time bin. More...
 
SpanSettstzspanset_tprecision (const SpanSet *ss, const Interval *duration, TimestampTz torigin)
 Return a timestamptz span set with the precision set to a time bin. More...
 

Detailed Description

Analytics function for temporal types.