MobilityDB 1.1
Macros | Functions
temporal.c File Reference
#include "general/temporal.h"
#include <assert.h>
#include <geos_c.h>
#include <meos.h>
#include <meos_internal.h>
#include "general/doxygen_libmeos.h"
#include "general/pg_types.h"
#include "general/temporaltypes.h"
#include "general/temporal_boxops.h"
#include "general/tnumber_distance.h"
#include "general/temporal_tile.h"
#include "general/type_parser.h"
#include "general/type_util.h"
#include "point/tpoint_spatialfuncs.h"
Include dependency graph for temporal.c:

Macros

#define MOBDB_INTERPOLATION_STR_MAXLEN   12
 
#define MOBDB_SUBTYPE_STR_MAXLEN   12
 
#define MOBDB_VERSION_STR_MAXLEN   256
 

Functions

void ensure_common_dimension (int16 flags1, int16 flags2)
 Ensure that two temporal values have at least one common dimension based on their flags. More...
 
void ensure_continuous (const Temporal *temp)
 Ensure that the subtype of temporal type is a sequence (set) More...
 
void ensure_continuous_interpolation (int16 flags)
 Ensure that a temporal value has continuous interpolation. More...
 
void ensure_discrete_interpolation (int16 flags)
 Ensure that a temporal value has discrete interpolation. More...
 
void ensure_increasing_timestamps (const TInstant *inst1, const TInstant *inst2, bool merge)
 Ensure that the timestamp of the first temporal instant is smaller (or equal if the merge parameter is true) than the one of the second temporal instant. More...
 
void ensure_nonlinear_interpolation (int16 flags)
 Ensure that a temporal value does not have linear interpolation. More...
 
void ensure_positive_datum (Datum size, meosType basetype)
 Ensure that the number is positive. More...
 
void ensure_same_interpolation (const Temporal *temp1, const Temporal *temp2)
 Ensure that two temporal values have the same interpolation. More...
 
void ensure_same_temptype (const Temporal *temp1, const Temporal *temp2)
 Ensure that two temporal values have the same base type. More...
 
void ensure_tinstarr (const TInstant **instants, int count)
 Ensure that the elements of an array are of instant subtype. More...
 
void ensure_valid_duration (const Interval *duration)
 Ensure that the interval is a positive and absolute duration. More...
 
void ensure_valid_tempsubtype (int16 subtype)
 Basic functions for temporal types of any subtype. More...
 
void ensure_valid_tempsubtype_all (int16 subtype)
 Ensure that the subtype of a temporal value is valid. More...
 
void ensure_valid_tinstarr (const TInstant **instants, int count, bool merge, interpType interp)
 Ensure that all temporal instants of the array have increasing timestamp (or may be equal if the merge parameter is true), and if they are temporal points, have the same srid and the same dimensionality. More...
 
void ensure_valid_tinstarr1 (const TInstant *inst1, const TInstant *inst2, bool merge, interpType interp)
 Ensure that two temporal instants have increasing timestamp (or may be equal if the merge parameter is true), and if they are temporal points, have the same srid and the same dimensionality. More...
 
int * ensure_valid_tinstarr_gaps (const TInstant **instants, int count, bool merge, interpType interp, double maxdist, Interval *maxt, int *countsplits)
 Ensure that all temporal instants of the array have increasing timestamp (or may be equal if the merge parameter is true), and if they are temporal points, have the same srid and the same dimensionality. More...
 
void ensure_valid_tseqarr (const TSequence **sequences, int count)
 Ensure that all temporal instants of the array have increasing timestamp, and if they are temporal points, have the same srid and the same dimensionality. More...
 
bool intersection_temporal_temporal (const Temporal *temp1, const Temporal *temp2, SyncMode mode, Temporal **inter1, Temporal **inter2)
 Temporally intersect the two temporal values. More...
 
char * mobilitydb_full_version (void)
 Versions of the MobilityDB extension and its dependencies. More...
 
char * mobilitydb_version (void)
 Version of the MobilityDB extension. More...
 
bool tbool_always_eq (const Temporal *temp, bool b)
 Return true if a temporal boolean is always equal to a boolean. More...
 
bool tbool_end_value (const Temporal *temp)
 Return the end value of a temporal boolean. More...
 
bool tbool_ever_eq (const Temporal *temp, bool b)
 Return true if a temporal boolean is ever equal to a boolean. More...
 
Temporaltbool_from_base (bool b, const Temporal *temp)
 Construct a temporal boolean from a boolean and the time frame of another temporal value. More...
 
Temporaltbool_in (const char *str)
 Return a temporal boolean from its Well-Known Text (WKT) representation. More...
 
char * tbool_out (const Temporal *temp)
 Return a temporal boolean from its Well-Known Text (WKT) representation. More...
 
bool tbool_start_value (const Temporal *temp)
 Return the start value of a temporal boolean. More...
 
bool * tbool_values (const Temporal *temp, int *count)
 Return the the array of base values of a temporal boolean. More...
 
bool temporal_always_eq (const Temporal *temp, Datum value)
 Return true if a temporal value is always equal to a base value. More...
 
bool temporal_always_le (const Temporal *temp, Datum value)
 Return true if a temporal value is always less than or equal to a base value. More...
 
bool temporal_always_lt (const Temporal *temp, Datum value)
 Return true if a temporal value is always less than a base value. More...
 
Temporaltemporal_append_tinstant (Temporal *temp, const TInstant *inst, bool expand)
 Append an instant to the end of a temporal value. More...
 
Temporaltemporal_append_tsequence (Temporal *temp, const TSequence *seq, bool expand)
 Append a sequence at the end of a temporal value. More...
 
bool temporal_bbox_ev_al_eq (const Temporal *temp, Datum value, bool ever)
 Return true if the bounding box of a temporal value is ever/always equal to a base value. More...
 
bool temporal_bbox_ev_al_lt_le (const Temporal *temp, Datum value, bool ever)
 Return true if the bounding box of a temporal value is ever/always less than or equal to the base value. More...
 
void * temporal_bbox_ptr (const Temporal *temp)
 Return a pointer to the precomputed bounding box of a temporal value. More...
 
bool temporal_bbox_restrict_set (const Temporal *temp, const Set *set)
 Return true if the bounding box of the temporal and the set overlap values. More...
 
bool temporal_bbox_restrict_value (const Temporal *temp, Datum value)
 Return true if the bounding box of a temporal value contains a base value. More...
 
int temporal_cmp (const Temporal *temp1, const Temporal *temp2)
 Return -1, 0, or 1 depending on whether the first temporal value is less than, equal, or greater than the second one. More...
 
Temporaltemporal_compact (const Temporal *temp)
 Compact the temporal value by removing extra storage space. More...
 
static void temporal_convert_same_subtype (const Temporal *temp1, const Temporal *temp2, Temporal **out1, Temporal **out2)
 Convert two temporal values into a common subtype. More...
 
Temporaltemporal_copy (const Temporal *temp)
 Return a copy of a temporal value. More...
 
Temporaltemporal_delete_period (const Temporal *temp, const Span *p, bool connect)
 Delete a period from a temporal value connecting the instants before and after the given timestamp (if any). More...
 
Temporaltemporal_delete_periodset (const Temporal *temp, const SpanSet *ps, bool connect)
 Delete a period set from a temporal value connecting the instants before and after the given timestamp (if any). More...
 
Temporaltemporal_delete_timestamp (const Temporal *temp, TimestampTz t, bool connect)
 Delete a timestamp from a temporal value connecting the instants before and after the given timestamp (if any). More...
 
Temporaltemporal_delete_timestampset (const Temporal *temp, const Set *ts, bool connect)
 Delete a timestamp set from a temporal value connecting the instants before and after the given timestamp (if any). More...
 
Intervaltemporal_duration (const Temporal *temp, bool boundspan)
 Return the duration of a temporal value. More...
 
const TInstanttemporal_end_instant (const Temporal *temp)
 Return the end instant of a temporal value. More...
 
TSequencetemporal_end_sequence (const Temporal *temp)
 Return the end sequence of a temporal sequence (set). More...
 
TimestampTz temporal_end_timestamp (const Temporal *temp)
 Return the end timestamp of a temporal value. More...
 
Datum temporal_end_value (const Temporal *temp)
 Return the end base value of a temporal value. More...
 
bool temporal_eq (const Temporal *temp1, const Temporal *temp2)
 Return true if the temporal values are equal. More...
 
bool temporal_ever_eq (const Temporal *temp, Datum value)
 Return true if a temporal value is ever equal to a base value. More...
 
bool temporal_ever_le (const Temporal *temp, Datum value)
 Return true if a temporal value is ever less than or equal to a base value. More...
 
bool temporal_ever_lt (const Temporal *temp, Datum value)
 Return true if a temporal value is ever less than a base value. More...
 
Temporaltemporal_from_base (Datum value, meosType temptype, const Temporal *temp, interpType interp)
 Construct a temporal value from a base value and the time frame of another temporal value. More...
 
bool temporal_ge (const Temporal *temp1, const Temporal *temp2)
 Return true if the first temporal value is greater than or equal to the second one. More...
 
bool temporal_gt (const Temporal *temp1, const Temporal *temp2)
 Return true if the first temporal value is greater than the second one. More...
 
uint32 temporal_hash (const Temporal *temp)
 Return the 32-bit hash value of a temporal value. More...
 
Temporaltemporal_in (const char *str, meosType temptype)
 Return a temporal value from its Well-Known Text (WKT) representation. More...
 
Temporaltemporal_insert (const Temporal *temp1, const Temporal *temp2, bool connect)
 Insert the second temporal value into the first one. More...
 
const TInstanttemporal_instant_n (const Temporal *temp, int n)
 Return the n-th instant of a temporal value. More...
 
const TInstant ** temporal_instants (const Temporal *temp, int *count)
 Return the array of instants of a temporal value. More...
 
char * temporal_interpolation (const Temporal *temp)
 Return the string representation of the interpolation of a temporal value. More...
 
bool temporal_le (const Temporal *temp1, const Temporal *temp2)
 Return true if the first temporal value is less than or equal to the second one. More...
 
bool temporal_lt (const Temporal *temp1, const Temporal *temp2)
 Return true if the first temporal value is less than the second one. More...
 
const TInstanttemporal_max_instant (const Temporal *temp)
 Return a pointer to the instant with maximum base value of a temporal value. More...
 
Datum temporal_max_value (const Temporal *temp)
 Return a copy of the maximum base value of a temporal value. More...
 
size_t temporal_mem_size (const Temporal *temp)
 Return the size in bytes of a temporal value. More...
 
Temporaltemporal_merge (const Temporal *temp1, const Temporal *temp2)
 Merge two temporal values. More...
 
Temporaltemporal_merge_array (Temporal **temparr, int count)
 Merge an array of temporal values. More...
 
const TInstanttemporal_min_instant (const Temporal *temp)
 Return a pointer to the instant with minimum base value of a temporal value. More...
 
Datum temporal_min_value (const Temporal *temp)
 Return a copy of the minimum base value of a temporal value. More...
 
bool temporal_ne (const Temporal *temp1, const Temporal *temp2)
 Return true if the temporal values are different. More...
 
int temporal_num_instants (const Temporal *temp)
 Return the number of distinct instants of a temporal value. More...
 
int temporal_num_sequences (const Temporal *temp)
 Return the number of sequences of a temporal sequence (set). More...
 
int temporal_num_timestamps (const Temporal *temp)
 Return the number of distinct timestamps of a temporal value. More...
 
char * temporal_out (const Temporal *temp, int maxdd)
 Return the Well-Known Text (WKT) representation of a temporal value. More...
 
Temporaltemporal_restrict_minmax (const Temporal *temp, bool min, bool atfunc)
 Restrict a temporal value to (the complement of) a minimum base value. More...
 
Temporaltemporal_restrict_period (const Temporal *temp, const Span *p, bool atfunc)
 Restrict a temporal value to (the complement of) a period. More...
 
Temporaltemporal_restrict_periodset (const Temporal *temp, const SpanSet *ps, bool atfunc)
 Restrict a temporal value to (the complement of) a period set. More...
 
Temporaltemporal_restrict_timestamp (const Temporal *temp, TimestampTz t, bool atfunc)
 Restrict a temporal value to a timestamp. More...
 
Temporaltemporal_restrict_timestampset (const Temporal *temp, const Set *ts, bool atfunc)
 Restrict a temporal value to (the complement of) a timestamp set. More...
 
Temporaltemporal_restrict_value (const Temporal *temp, Datum value, bool atfunc)
 Restrict a temporal value to (the complement of) a base value. More...
 
Temporaltemporal_restrict_values (const Temporal *temp, const Set *set, bool atfunc)
 Restrict a temporal value to (the complement of) an array of base values. More...
 
TSequence ** temporal_segments (const Temporal *temp, int *count)
 Return the array of segments of a temporal value. More...
 
TSequencetemporal_sequence_n (const Temporal *temp, int i)
 Return the n-th sequence of a temporal sequence (set). More...
 
TSequence ** temporal_sequences (const Temporal *temp, int *count)
 Return the array of sequences of a temporal sequence (set). More...
 
void temporal_set_bbox (const Temporal *temp, void *box)
 Set the second argument to the bounding box of a temporal value. More...
 
void temporal_set_period (const Temporal *temp, Span *p)
 Set a period to the bounding period of a temporal value. More...
 
Temporaltemporal_shift (const Temporal *temp, const Interval *shift)
 
Temporaltemporal_shift_tscale (const Temporal *temp, const Interval *shift, const Interval *duration)
 Return a temporal value shifted and/or scaled by the intervals. More...
 
const TInstanttemporal_start_instant (const Temporal *temp)
 Return the start instant of a temporal value. More...
 
TSequencetemporal_start_sequence (const Temporal *temp)
 Return the start sequence of a temporal sequence (set). More...
 
TimestampTz temporal_start_timestamp (const Temporal *temp)
 Return the start timestamp of a temporal value. More...
 
Datum temporal_start_value (const Temporal *temp)
 Return the start base value of a temporal value. More...
 
Temporaltemporal_step_to_linear (const Temporal *temp)
 Return a temporal value with continuous base type transformed from step to linear interpolation. More...
 
char * temporal_subtype (const Temporal *temp)
 Return the string representation of the subtype of a temporal value. More...
 
SpanSettemporal_time (const Temporal *temp)
 Return the time frame of a temporal value as a period set. More...
 
bool temporal_timestamp_n (const Temporal *temp, int n, TimestampTz *result)
 Return the n-th distinct timestamp of a temporal value. More...
 
TimestampTztemporal_timestamps (const Temporal *temp, int *count)
 Return the array of distinct timestamps of a temporal value. More...
 
Spantemporal_to_period (const Temporal *temp)
 Return the bounding period of a temporal value. More...
 
Temporaltemporal_to_tcontseq (const Temporal *temp)
 Return a temporal value transformed into a temporal sequence with continuous interpolation. More...
 
Temporaltemporal_to_tdiscseq (const Temporal *temp)
 Return a temporal value transformed into a temporal sequence with discrete interpolation. More...
 
Temporaltemporal_to_tinstant (const Temporal *temp)
 Return a temporal value transformed into a temporal instant. More...
 
Temporaltemporal_to_tsequenceset (const Temporal *temp)
 Return a temporal value transformed into a temporal sequence set. More...
 
Temporaltemporal_tprecision (const Temporal *temp, const Interval *duration, TimestampTz torigin)
 Set the precision of a temporal value according to period buckets. More...
 
static Datum temporal_tprecision_agg_values (const Temporal *temp)
 Aggregate the values that are merged due to a temporal granularity change. More...
 
Temporaltemporal_tsample (const Temporal *temp, const Interval *duration, TimestampTz torigin)
 Sample the temporal value according to period buckets. More...
 
Temporaltemporal_tscale (const Temporal *temp, const Interval *duration)
 
Temporaltemporal_update (const Temporal *temp1, const Temporal *temp2, bool connect)
 Update the first temporal value with the second one. More...
 
bool temporal_value_at_timestamp (const Temporal *temp, TimestampTz t, bool strict, Datum *result)
 Return the base value of a temporal value at the timestamp. More...
 
Datumtemporal_values (const Temporal *temp, int *count)
 Return the array of base values of a temporal value. More...
 
static Temporal ** temporalarr_convert_subtype (Temporal **temparr, int count, uint8 subtype, interpType interp)
 Convert the array of temporal values into a common subtype. More...
 
bool tfloat_always_eq (const Temporal *temp, double d)
 Return true if a temporal float is always equal to a float. More...
 
bool tfloat_always_le (const Temporal *temp, double d)
 Return true if a temporal float is always less than or equal to a float. More...
 
bool tfloat_always_lt (const Temporal *temp, double d)
 Return true if a temporal float is always less than a float. More...
 
double tfloat_end_value (const Temporal *temp)
 Return the end value of a temporal float. More...
 
bool tfloat_ever_eq (const Temporal *temp, double d)
 Return true if a temporal float is ever equal to a float. More...
 
bool tfloat_ever_le (const Temporal *temp, double d)
 Return true if a temporal float is ever less than or equal to a float. More...
 
bool tfloat_ever_lt (const Temporal *temp, double d)
 Return true if a temporal float is ever less than a float. More...
 
Temporaltfloat_from_base (double d, const Temporal *temp, interpType interp)
 Construct a temporal float from a float and the time frame of another temporal value. More...
 
Temporaltfloat_in (const char *str)
 Return a temporal float from its Well-Known Text (WKT) representation. More...
 
double tfloat_max_value (const Temporal *temp)
 Return the maximum value of a temporal float. More...
 
double tfloat_min_value (const Temporal *temp)
 Return the minimum value of a temporal float. More...
 
char * tfloat_out (const Temporal *temp, int maxdd)
 Return a temporal float from its Well-Known Text (WKT) representation. More...
 
SpanSettfloat_spanset (const Temporal *temp)
 Return the base values of a temporal float as an array of spans. More...
 
double tfloat_start_value (const Temporal *temp)
 Return the start value of a temporal float. More...
 
Temporaltfloat_to_tint (const Temporal *temp)
 Cast a temporal float to a temporal integer. More...
 
double * tfloat_values (const Temporal *temp, int *count)
 Return the the array of base values of a temporal float. More...
 
Temporaltgeogpoint_from_base (const GSERIALIZED *gs, const Temporal *temp, interpType interp)
 Construct a temporal geographic point from a point and the time frame of another temporal value. More...
 
Temporaltgeogpoint_in (const char *str)
 Return a temporal geographic point from its Well-Known Text (WKT) representation. More...
 
Temporaltgeompoint_from_base (const GSERIALIZED *gs, const Temporal *temp, interpType interp)
 Construct a temporal geometric point from a point and the time frame of another temporal value. More...
 
Temporaltgeompoint_in (const char *str)
 Return a temporal geometric point from its Well-Known Text (WKT) representation. More...
 
TInstanttinstant_tprecision (const TInstant *inst, const Interval *duration, TimestampTz torigin)
 Set the precision of a temporal value according to time buckets. More...
 
TInstanttinstant_tsample (const TInstant *inst, const Interval *duration, TimestampTz torigin)
 Sample the temporal value according to period buckets. More...
 
bool tint_always_eq (const Temporal *temp, int i)
 Return true if a temporal integer is always equal to an integer. More...
 
bool tint_always_le (const Temporal *temp, int i)
 Return true if a temporal integer is always less than or equal to an integer. More...
 
bool tint_always_lt (const Temporal *temp, int i)
 Return true if a temporal integer is always less than an integer. More...
 
int tint_end_value (const Temporal *temp)
 Return the end value of a temporal integer. More...
 
bool tint_ever_eq (const Temporal *temp, int i)
 Return true if a temporal integer is ever equal to an integer. More...
 
bool tint_ever_le (const Temporal *temp, int i)
 Return true if a temporal integer is ever less than or equal to an integer. More...
 
bool tint_ever_lt (const Temporal *temp, int i)
 Return true if a temporal integer is ever less than an integer. More...
 
Temporaltint_from_base (int i, const Temporal *temp)
 Construct a temporal integer from an integer and the time frame of another temporal value. More...
 
Temporaltint_in (const char *str)
 Return a temporal integer from its Well-Known Text (WKT) representation. More...
 
int tint_max_value (const Temporal *temp)
 Return the maximum value of a temporal integer. More...
 
int tint_min_value (const Temporal *temp)
 Return the minimum value of a temporal integer. More...
 
char * tint_out (const Temporal *temp)
 Return a temporal integer from its Well-Known Text (WKT) representation. More...
 
int tint_start_value (const Temporal *temp)
 Return the start value of a temporal integer. More...
 
Temporaltint_to_tfloat (const Temporal *temp)
 Cast a temporal integer to a temporal float. More...
 
int * tint_values (const Temporal *temp, int *count)
 Return the the array of base values of a temporal integer. More...
 
Temporaltnumber_at_tbox (const Temporal *temp, const TBox *box)
 Restrict a temporal number to a temporal box. More...
 
bool tnumber_bbox_restrict_span (const Temporal *temp, const Span *span)
 Return true if the bounding box of the temporal number overlaps the span of base values. More...
 
double tnumber_integral (const Temporal *temp)
 Return the integral (area under the curve) of a temporal number. More...
 
Temporaltnumber_minus_tbox (const Temporal *temp, const TBox *box)
 Restrict a temporal number to the complement of a temporal box. More...
 
Temporaltnumber_restrict_span (const Temporal *temp, const Span *span, bool atfunc)
 Restrict a temporal value to (the complement of) a span of base values. More...
 
Temporaltnumber_restrict_spanset (const Temporal *temp, const SpanSet *ss, bool atfunc)
 Restrict a temporal value to (the complement of) a span set. More...
 
void tnumber_set_span (const Temporal *temp, Span *s)
 Set a span with value span of a temporal number. More...
 
Spantnumber_to_span (const Temporal *temp)
 Return the value span of a temporal number. More...
 
TBoxtnumber_to_tbox (const Temporal *temp)
 Return the bounding box of a temporal number. More...
 
double tnumber_twavg (const Temporal *temp)
 Return the time-weighted average of a temporal number. More...
 
GSERIALIZEDtpoint_end_value (const Temporal *temp)
 Return the end value of a temporal point. More...
 
char * tpoint_out (const Temporal *temp, int maxdd)
 Return a temporal geometric/geographic point from its Well-Known Text (WKT) representation. More...
 
GSERIALIZEDtpoint_start_value (const Temporal *temp)
 Return the start value of a temporal geometric point. More...
 
GSERIALIZED ** tpoint_values (const Temporal *temp, int *count)
 Return the the array of base values of a temporal geometric point. More...
 
TSequencetsequence_tprecision (const TSequence *seq, const Interval *duration, TimestampTz torigin)
 Set the precision of a temporal value according to period buckets. More...
 
TSequencetsequence_tsample (const TSequence *seq, const Interval *duration, TimestampTz torigin)
 Sample the temporal value according to period buckets. More...
 
TSequenceSettsequenceset_tprecision (const TSequenceSet *ss, const Interval *duration, TimestampTz torigin)
 Set the precision of a temporal value according to period buckets. More...
 
TSequenceSettsequenceset_tsample (const TSequenceSet *ss, const Interval *duration, TimestampTz torigin)
 Sample the temporal value according to period buckets. More...
 
bool ttext_always_eq (const Temporal *temp, text *txt)
 Return true if a temporal text is always equal to a text. More...
 
bool ttext_always_le (const Temporal *temp, text *txt)
 Return true if a temporal text is always less than or equal to a text. More...
 
bool ttext_always_lt (const Temporal *temp, text *txt)
 Return true if a temporal text is always less than a text. More...
 
textttext_end_value (const Temporal *temp)
 Return the end value of a temporal text. More...
 
bool ttext_ever_eq (const Temporal *temp, text *txt)
 Return true if a temporal text is ever equal to a text. More...
 
bool ttext_ever_le (const Temporal *temp, text *txt)
 Return true if a temporal text is ever less than or equal to a text. More...
 
bool ttext_ever_lt (const Temporal *temp, text *txt)
 Return true if a temporal text is ever less than a text. More...
 
Temporalttext_from_base (const text *txt, const Temporal *temp)
 Construct a temporal text from a text and the time frame of another temporal value. More...
 
Temporalttext_in (const char *str)
 Return a temporal text from its Well-Known Text (WKT) representation. More...
 
textttext_max_value (const Temporal *temp)
 Return the maximum value of a temporal text. More...
 
textttext_min_value (const Temporal *temp)
 Return the minimum value of a temporal text. More...
 
char * ttext_out (const Temporal *temp)
 Return a temporal text from its Well-Known Text (WKT) representation. More...
 
textttext_start_value (const Temporal *temp)
 Return the start value of a temporal text. More...
 
text ** ttext_values (const Temporal *temp, int *count)
 Return the the array of base values of a temporal text. More...