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

Basic functions for temporal types of any subtype. More...

#include "temporal/temporal.h"
#include <assert.h>
#include <float.h>
#include <geos_c.h>
#include <limits.h>
#include <meos.h>
#include <meos_internal.h>
#include <meos_internal_geo.h>
#include "temporal/doxygen_meos.h"
#include "temporal/lifting.h"
#include "temporal/postgres_types.h"
#include "temporal/temporal_boxops.h"
#include "temporal/temporal_tile.h"
#include "temporal/tinstant.h"
#include "temporal/tsequence.h"
#include "temporal/tsequenceset.h"
#include "temporal/type_parser.h"
#include "temporal/type_util.h"
#include "geo/tgeo.h"
#include "geo/tgeo_spatialfuncs.h"

Macros

#define MEOS_INTERP_STR_MAXLEN   9
 
#define MOBDB_VERSION_STR_MAXLEN   256
 

Functions

static Datum datum_bool_to_int (Datum d)
 Convert a Boolean into an integer. More...
 
Datum datum_ceil (Datum value)
 Return a number rounded up to the nearest integer. More...
 
Datum datum_degrees (Datum value, Datum normalize)
 Return a double converted from radians to degrees. More...
 
Datum datum_float_round (Datum value, Datum size)
 Return a float number rounded to a given number of decimal places. More...
 
static Datum datum_float_to_int (Datum d)
 Convert a float into an integer. More...
 
Datum datum_floor (Datum value)
 Return a number rounded down to the nearest integer. More...
 
static Datum datum_int_to_float (Datum d)
 Convert an integer into a float. More...
 
Datum datum_radians (Datum value)
 Return a double converted from degrees to radians. More...
 
bool ensure_common_dimension (int16 flags1, int16 flags2)
 Ensure that two temporal values have at least one common dimension. More...
 
bool ensure_continuous (const Temporal *temp)
 Ensure that the subtype of temporal type is a sequence (set) More...
 
bool ensure_has_not_Z (meosType type, int16 flags)
 Ensure that a MEOS type has not Z dimension. More...
 
bool ensure_has_T (meosType type, int16 flags)
 Ensure that a MEOS type has Z dimension. More...
 
bool ensure_has_X (meosType type, int16 flags)
 Ensure that a MEOS type has X dimension. More...
 
bool ensure_has_Z (meosType type, int16 flags)
 Ensure that a MEOS type has Z dimension. More...
 
bool ensure_linear_interp (int16 flags)
 Ensure that a temporal value has linear interpolation. More...
 
bool ensure_nonlinear_interp (int16 flags)
 Ensure that a temporal value does not have linear interpolation. More...
 
bool ensure_not_month_duration (const Interval *duration)
 Ensure that an interval does not have a month component. More...
 
bool ensure_not_negative (int i)
 Ensure that a number is positive or zero. More...
 
bool ensure_not_negative_datum (Datum d, meosType basetype)
 Ensure that a number is not negative. More...
 
bool ensure_not_null (void *ptr)
 Ensure that the pointer is not null. More...
 
bool ensure_one_not_null (void *ptr1, void *ptr2)
 Ensure that at least one of the pointers is not null. More...
 
bool ensure_one_true (bool hasshift, bool haswidth)
 Ensure that at least one of the values is true. More...
 
bool ensure_positive (int i)
 Ensure that a number is positive. More...
 
bool ensure_positive_datum (Datum d, meosType basetype)
 Ensure that a number is strictly positive. More...
 
bool ensure_positive_duration (const Interval *duration)
 Ensure that an interval is a positive duration. More...
 
bool ensure_same_continuous_interp (int16 flags1, int16 flags2)
 Ensure that two temporal values have the same continuous interpolation. More...
 
bool ensure_same_interp (const Temporal *temp1, const Temporal *temp2)
 Ensure that two temporal values have the same interpolation. More...
 
bool ensure_same_temporal_type (const Temporal *temp1, const Temporal *temp2)
 Ensure that two temporal values have the same temporal type. More...
 
bool ensure_temporal_isof_basetype (const Temporal *temp, meosType basetype)
 Ensure that a temporal value has a given base type. More...
 
bool ensure_temporal_isof_subtype (const Temporal *temp, tempSubtype subtype)
 Ensure that a temporal value is of a given subtype. More...
 
bool ensure_temporal_isof_type (const Temporal *temp, meosType temptype)
 Ensure that a temporal value is of a temporal type. More...
 
bool ensure_valid_day_duration (const Interval *duration)
 Ensure that a day interval for binning is valid. More...
 
bool ensure_valid_interp (meosType temptype, interpType interp)
 Ensure that an interpolation is valid. More...
 
bool ensure_valid_temporal_set (const Temporal *temp, const Set *s)
 Ensure that a temporal number and a set have the same span type. More...
 
bool ensure_valid_temporal_temporal (const Temporal *temp1, const Temporal *temp2)
 Ensure that a temporal number and a temporal box have the same span type. More...
 
bool ensure_valid_tnumber_numspan (const Temporal *temp, const Span *s)
 Ensure that a temporal number and a span have the same span type. More...
 
bool ensure_valid_tnumber_numspanset (const Temporal *temp, const SpanSet *ss)
 Ensure that a temporal number and a span set have the same span type. More...
 
bool ensure_valid_tnumber_tbox (const Temporal *temp, const TBox *box)
 Ensure that a temporal number and a temporal box have the same span type. More...
 
bool ensure_valid_tnumber_tnumber (const Temporal *temp1, const Temporal *temp2)
 Ensure that two temporal numbers have the same span type. More...
 
double float_degrees (double value, bool normalize)
 Return a float converted from radians to degrees. More...
 
double float_round (double d, int maxdd)
 Return a float number rounded to a given number of decimal places. More...
 
bool intersection_temporal_temporal (const Temporal *temp1, const Temporal *temp2, SyncMode mode, Temporal **inter1, Temporal **inter2)
 Return the temporal intersection of two temporal values. More...
 
char * mobilitydb_full_version (void)
 Return the versions of the MobilityDB extension and its dependencies. More...
 
char * mobilitydb_version (void)
 Return the version of the MobilityDB extension. More...
 
static double mrr_distance_scalar (const TSequence *seq, int start, int end)
 Return the length of the minimum bounding interval of a sequence between the given start and end instants. More...
 
bool not_negative_datum (Datum d, meosType basetype)
 Return true if a number is not negative. More...
 
bool positive_datum (Datum d, meosType basetype)
 Return true if a number is strictly positive. More...
 
bool positive_duration (const Interval *duration)
 Return true if an interval is a positive duration. More...
 
datum_func2 round_fn (meosType basetype)
 Return the function for rounding a base type. More...
 
Temporaltbool_to_tint (const Temporal *temp)
 Convert a temporal Boolean into a temporal integer. More...
 
static TSequencetdiscseq_from_base_temp (Datum value, meosType temptype, const TSequence *seq)
 Return a temporal discrete sequence from a base value and time frame of another temporal discrete sequence. More...
 
char ** temparr_out (const Temporal **temparr, int count, int maxdd)
 Return the Well-Known Text (WKT) representation of an array of temporal values. More...
 
Temporal ** temparr_round (const Temporal **temparr, int count, int maxdd)
 Return an array of temporal floats with the precision of the coordinates set to a number of decimal places. More...
 
void * temporal_bbox_ptr (const Temporal *temp)
 Return a pointer to the precomputed bounding box of a temporal 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)
 Return a copy of a temporal value without any extra storage space. More...
 
Temporaltemporal_copy (const Temporal *temp)
 Return a copy of a temporal value. More...
 
Intervaltemporal_duration (const Temporal *temp, bool boundspan)
 Return the duration of a temporal value. More...
 
const TInstanttemporal_end_inst (const Temporal *temp)
 Return a pointer to the end instant of a temporal value. More...
 
TInstanttemporal_end_instant (const Temporal *temp)
 Return a copy of the end instant of a temporal value. More...
 
TSequencetemporal_end_sequence (const Temporal *temp)
 Return a copy of the end sequence of a temporal sequence (set) More...
 
TimestampTz temporal_end_timestamptz (const Temporal *temp)
 Return the end timestamptz of a temporal value. More...
 
Datum temporal_end_value (const Temporal *temp)
 Return a copy of the end base value of a temporal value. More...
 
bool temporal_eq (const Temporal *temp1, const Temporal *temp2)
 Return true if two temporal values are equal. More...
 
Temporaltemporal_from_base_temp (Datum value, meosType temptype, const Temporal *temp)
 Return 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...
 
const TInstanttemporal_inst_n (const Temporal *temp, int n)
 Return a pointer to the n-th instant of a temporal value. More...
 
TInstanttemporal_instant_n (const Temporal *temp, int n)
 Return a copy of the n-th instant of a temporal value. More...
 
TInstant ** temporal_instants (const Temporal *temp, int *count)
 Return a copy of the distinct instants of a temporal value. More...
 
const TInstant ** temporal_instants_p (const Temporal *temp, int *count)
 Return an array of pointers to the distinct instants of a temporal value. More...
 
const char * temporal_interp (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_lower_inc (const Temporal *temp)
 Return true if the start instant of a temporal value is inclusive. More...
 
bool temporal_lt (const Temporal *temp1, const Temporal *temp2)
 Return true if the first temporal value is less than the second one. More...
 
TInstanttemporal_max_instant (const Temporal *temp)
 Return a copy of 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...
 
const TInstanttemporal_min_inst (const Temporal *temp)
 Return a pointer to the instant with minimum base value of a temporal value. More...
 
TInstanttemporal_min_instant (const Temporal *temp)
 Return a copy of 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 two 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...
 
void temporal_restart (Temporal *temp, int count)
 Return a temporal sequence (set) that keepsg only the last n instants or sequences. More...
 
Temporaltemporal_round (const Temporal *temp, int maxdd)
 Return a temporal value rounded to a given number of decimal places. More...
 
Temporaltemporal_scale_time (const Temporal *temp, const Interval *duration)
 Return a temporal value scaled by an interval. 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 n)
 Return a copy of the n-th sequence of a temporal sequence (set) More...
 
TSequence ** temporal_sequences (const Temporal *temp, int *count)
 Return an array of copies of the sequences of a temporal sequence (set) More...
 
const TSequence ** temporal_sequences_p (const Temporal *temp, int *count)
 Return an array of pointers to the sequences of a temporal sequence (set) More...
 
void temporal_set_bbox (const Temporal *temp, void *box)
 Return in the last argument the bounding box of a temporal value. More...
 
Temporaltemporal_set_interp (const Temporal *temp, interpType interp)
 Return a temporal value transformed to an interpolation. More...
 
void temporal_set_tstzspan (const Temporal *temp, Span *s)
 Return in the last argument the time span of a temporal value. More...
 
Temporaltemporal_shift_scale_time (const Temporal *temp, const Interval *shift, const Interval *duration)
 Return a temporal value shifted and/or scaled by two intervals. More...
 
Temporaltemporal_shift_time (const Temporal *temp, const Interval *shift)
 Return a temporal value shifted by an interval. More...
 
const TInstanttemporal_start_inst (const Temporal *temp)
 Return a pointer to the start instant of a temporal value. More...
 
TInstanttemporal_start_instant (const Temporal *temp)
 Return a copy of the start instant of a temporal value. More...
 
TSequencetemporal_start_sequence (const Temporal *temp)
 Return a copy of the start sequence of a temporal sequence (set) More...
 
TimestampTz temporal_start_timestamptz (const Temporal *temp)
 Return the start timestamptz of a temporal value. More...
 
Datum temporal_start_value (const Temporal *temp)
 Return a copy of the start base value of a temporal value. More...
 
TSequenceSettemporal_stops (const Temporal *temp, double maxdist, const Interval *minduration)
 Return the subsequences where a temporal value stays within a given distance for at least a given duration. More...
 
const 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 span set. More...
 
TimestampTztemporal_timestamps (const Temporal *temp, int *count)
 Return the array of distinct timestamps of a temporal value. More...
 
bool temporal_timestamptz_n (const Temporal *temp, int n, TimestampTz *result)
 Return in last argument the n-th distinct timestamptz of a temporal value. More...
 
TInstanttemporal_to_tinstant (const Temporal *temp)
 Return a temporal value transformed to a temporal instant. More...
 
TSequencetemporal_to_tsequence (const Temporal *temp, interpType interp)
 Return a temporal value transformed to a temporal sequence. More...
 
TSequenceSettemporal_to_tsequenceset (const Temporal *temp, interpType interp)
 Return a temporal value transformed to a temporal sequence set. More...
 
Spantemporal_to_tstzspan (const Temporal *temp)
 Return the bounding period of a temporal value. More...
 
TSequencetemporal_tsequence (const Temporal *temp, interpType interp)
 Return a temporal value transformed to a temporal sequence. More...
 
TSequenceSettemporal_tsequenceset (const Temporal *temp, interpType interp)
 Return a temporal value transformed to a temporal sequence set. More...
 
bool temporal_upper_inc (const Temporal *temp)
 Return true if the end instant of a temporal value is inclusive. More...
 
bool temporal_value_n (const Temporal *temp, int n, Datum *result)
 Return in the last argument a copy of the n-th value of a temporal value. More...
 
Datumtemporal_values (const Temporal *temp, int *count)
 Return the array of copies of the distinct base values of a temporal value. More...
 
Datumtemporal_values_p (const Temporal *temp, int *count)
 Return the array of pointers to the base values of a temporal value. More...
 
Temporaltfloat_ceil (const Temporal *temp)
 Return a temporal float rounded up to the nearest temporal integer. More...
 
Temporaltfloat_degrees (const Temporal *temp, bool normalize)
 Return a temporal float transformed from radians to degrees. More...
 
Temporaltfloat_floor (const Temporal *temp)
 Return a temporal float rounded down to the nearest temporal integer. More...
 
Temporaltfloat_radians (const Temporal *temp)
 Return a temporal float transformed from degrees to radians. More...
 
Temporaltfloat_to_tint (const Temporal *temp)
 Convert a temporal float into a temporal integer. More...
 
static int tfloatseq_stops_iter (const TSequence *seq, double maxdist, int64 mintunits, TSequence **result)
 Return the subsequences where the temporal value stays within a given distance for at least a given duration (iterator function) More...
 
Temporaltint_to_tfloat (const Temporal *temp)
 Convert a temporal integer into a temporal float. More...
 
double tnumber_integral (const Temporal *temp)
 Return the integral (area under the curve) of a temporal number. More...
 
void tnumber_set_span (const Temporal *temp, Span *s)
 Return in the last argument the value span of a temporal number. More...
 
Temporaltnumber_shift_scale_value (const Temporal *temp, Datum shift, Datum width, bool hasshift, bool haswidth)
 Return a temporal number with the value dimension shifted and/or scaled by two values. More...
 
Spantnumber_to_span (const Temporal *temp)
 Return the value span of a temporal number. More...
 
TBoxtnumber_to_tbox (const Temporal *temp)
 Convert a temporal number into a temporal box. More...
 
double tnumber_twavg (const Temporal *temp)
 Return the time-weighted average of a temporal number. More...
 
SpanSettnumber_valuespans (const Temporal *temp)
 Return the base values of a temporal number as a span set. More...
 
TSequencetsequence_from_base_temp (Datum value, meosType temptype, const TSequence *seq)
 Return a temporal sequence from a base value and the time frame of another temporal sequence. More...
 
TSequenceSettsequence_stops (const TSequence *seq, double maxdist, int64 mintunits)
 Return the subsequences where the temporal value stays within a given distance for at least a given duration. More...
 
TSequenceSettsequenceset_from_base_temp (Datum value, meosType temptype, const TSequenceSet *ss)
 Return a temporal sequence set from a base value and the time frame of another temporal sequence set. More...
 
TSequenceSettsequenceset_stops (const TSequenceSet *ss, double maxdist, int64 mintunits)
 Return the subsequences where the temporal value stays within a given distance for at least a given duration. More...
 

Detailed Description

Basic functions for temporal types of any subtype.