![]() |
MobilityDB 1.3
|
General functions for temporal sequences. More...
#include "temporal/tsequence.h"
#include <assert.h>
#include <math.h>
#include <postgres.h>
#include <utils/float.h>
#include <utils/timestamp.h>
#include <common/hashfn.h>
#include <meos.h>
#include <meos_internal.h>
#include <meos_internal_geo.h>
#include "temporal/doublen.h"
#include "temporal/postgres_types.h"
#include "temporal/set.h"
#include "temporal/span.h"
#include "temporal/spanset.h"
#include "temporal/temporal.h"
#include "temporal/tinstant.h"
#include "temporal/temporal_boxops.h"
#include "temporal/type_util.h"
#include "temporal/type_parser.h"
#include "geo/tgeo_spatialfuncs.h"
#include "geo/tspatial_parser.h"
Functions | |
void | bbox_expand (const void *box1, void *box2, meosType temptype) |
Expand the second bounding box with the first one. More... | |
static bool | datum_collinear (Datum value1, Datum value2, Datum value3, meosType basetype, TimestampTz t1, TimestampTz t2, TimestampTz t3) |
Return true if the three values are collinear. More... | |
Datum | datumsegm_interpolate (Datum start, Datum end, meosType temptype, long double ratio) |
Return base value interpolated from a base segment with respect to a fraction of its total length. More... | |
long double | datumsegm_locate (Datum value1, Datum value2, Datum value, meosType basetype) |
Return a float value in (0,1) if a segment of base values intersects a base value, return -1.0 otherwise. More... | |
bool | 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... | |
bool | ensure_valid_tinstarr (const TInstant **instants, int count, bool merge, interpType interp UNUSED) |
Ensure that all temporal instants of the array are valid. More... | |
bool | ensure_valid_tinstarr_common (const TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp) |
Ensure the validity of the arguments when creating a temporal sequence. More... | |
bool | float_collinear (double x1, double x2, double x3, double ratio) |
Return true if the three values are collinear. More... | |
double | floatsegm_interpolate (double start, double end, long double ratio) |
Return a float interpolated from a float segment with respect to a fraction of its total length. More... | |
long double | floatsegm_locate (double start, double end, double value) |
Return a float in (0,1) if a float segment intersects a float with respect to an epsilon value, return -1.0 if the value is not located in the segment or if it is approximately equal to the start or the end value. More... | |
bool | intersection_tcontseq_tdiscseq (const TSequence *seq1, const TSequence *seq2, TSequence **inter1, TSequence **inter2) |
Temporally intersect two temporal sequences. More... | |
bool | intersection_tdiscseq_tcontseq (const TSequence *seq1, const TSequence *seq2, TSequence **inter1, TSequence **inter2) |
Temporally intersect two temporal values. More... | |
bool | intersection_tdiscseq_tdiscseq (const TSequence *seq1, const TSequence *seq2, TSequence **inter1, TSequence **inter2) |
Temporally intersect two temporal discrete sequences. More... | |
bool | intersection_tinstant_tsequence (const TInstant *inst, const TSequence *seq, TInstant **inter1, TInstant **inter2) |
Temporally intersect two temporal values. More... | |
bool | intersection_tsequence_tinstant (const TSequence *seq, const TInstant *inst, TInstant **inter1, TInstant **inter2) |
Temporally intersect two temporal sequences. More... | |
bool | synchronize_tsequence_tsequence (const TSequence *seq1, const TSequence *seq2, TSequence **sync1, TSequence **sync2, bool crossings) |
Synchronize two temporal sequences. More... | |
int | tcontseq_find_timestamptz (const TSequence *seq, TimestampTz t) |
Return the index of the segment of a temporal continuous sequence containing a timestamp using binary search. More... | |
TSequence * | tcontseq_to_discrete (const TSequence *seq) |
Return a temporal sequence transformed into discrete interpolation. More... | |
Temporal * | tcontseq_to_linear (const TSequence *seq) |
Return a temporal sequence transformed to linear interpolation. More... | |
TSequence * | tcontseq_to_step (const TSequence *seq) |
Return a temporal sequence transformed to step interpolation. More... | |
int | tdiscseq_find_timestamptz (const TSequence *seq, TimestampTz t) |
Return the index of a timestamp in a temporal discrete sequence value using binary search. More... | |
Temporal * | tdiscseq_set_interp (const TSequence *seq, interpType interp) |
Transform a temporal discrete sequence to a given interpolation. More... | |
int | tfloatsegm_intersection_value (Datum start, Datum end, Datum value, TimestampTz lower, TimestampTz upper, TimestampTz *t) |
Return true if the segment of a temporal number intersects the base value at a timestamptz. More... | |
TSequence * | tinstant_to_tsequence (const TInstant *inst, interpType interp) |
Return a temporal instant transformed into a temporal sequence. More... | |
TSequence * | tinstant_to_tsequence_free (TInstant *inst, interpType interp) |
Return a temporal instant transformed into a temporal sequence. More... | |
TInstant ** | tinstarr_normalize (const TInstant **instants, interpType interp, int count, int *newcount) |
Normalize the array of temporal instants. More... | |
int | tnumbersegm_intersection (Datum start1, Datum end1, Datum start2, Datum end2, meosType basetype, TimestampTz lower, TimestampTz upper, TimestampTz *t1, TimestampTz *t2) |
Compute the intersection, if any, of two segments of temporal sequences. More... | |
double | tnumberseq_cont_twavg (const TSequence *seq) |
Return the time-weighted average of a temporal sequence number. More... | |
double | tnumberseq_disc_twavg (const TSequence *seq) |
Return the time-weighted average of a temporal discrete sequence number. More... | |
double | tnumberseq_integral (const TSequence *seq) |
Return the integral (area under the curve) of a temporal sequence number. More... | |
TSequence * | tnumberseq_shift_scale_value (const TSequence *seq, Datum shift, Datum width, bool hasshift, bool haswidth) |
Return a temporal sequence whose value dimension is shifted and/or scaled by two values. More... | |
void | tnumberseq_shift_scale_value_iter (TSequence *seq, Datum origin, Datum delta, bool hasdelta, double scale) |
Shift and/or scale the values of the instants of a temporal sequence (iterator function) More... | |
double | tnumberseq_twavg (const TSequence *seq) |
Return the time-weighted average of a temporal sequence number. More... | |
SpanSet * | tnumberseq_valuespans (const TSequence *seq) |
Return the base values of a temporal number sequence as a span set. More... | |
TSequence * | tpointseq_make_coords (const double *xcoords, const double *ycoords, const double *zcoords, const TimestampTz *times, int count, int32 srid, bool geodetic, bool lower_inc, bool upper_inc, interpType interp, bool normalize) |
Return a temporal sequence from arrays of coordinates, one per dimension, and timestamps. More... | |
int | tsegment_intersection (Datum start1, Datum end1, Datum start2, Datum end2, meosType temptype, TimestampTz lower, TimestampTz upper, TimestampTz *t1, TimestampTz *t2) |
Return 1 or 2 if two temporal segments intersect during the period defined by the output timestamps, return 0 otherwise. More... | |
int | tsegment_intersection_value (Datum start, Datum end, Datum value, meosType temptype, TimestampTz lower, TimestampTz upper, TimestampTz *t1, TimestampTz *t2) |
Return 1 or 2 if a temporal segment intersects a base value during the period defined by the output timestamps, return 0 otherwise. More... | |
Datum | tsegment_value_at_timestamptz (Datum start, Datum end, meosType temptype, TimestampTz lower, TimestampTz upper, TimestampTz t) |
Return the base value of the segment of a temporal sequence at a timestamptz. More... | |
TSequence ** | tseqarr2_to_tseqarr (TSequence ***sequences, int *countseqs, int count, int totalseqs) |
Return an array of temporal sequences converted from an array of arrays of temporal sequences. More... | |
int | tsequence_cmp (const TSequence *seq1, const TSequence *seq2) |
Return -1, 0, or 1 depending on whether the first temporal sequence is less than, equal, or greater than the second one. More... | |
TSequence * | tsequence_compact (const TSequence *seq) |
Return a copy of a temporal sequence without any extra storage space. More... | |
TSequence * | tsequence_copy (const TSequence *seq) |
Return a copy of a temporal sequence. More... | |
Interval * | tsequence_duration (const TSequence *seq) |
Return the duration of a temporal sequence. More... | |
TimestampTz | tsequence_end_timestamptz (const TSequence *seq) |
Return the end timestamptz of a temporal sequence. More... | |
bool | tsequence_eq (const TSequence *seq1, const TSequence *seq2) |
Return true if two temporal sequences are equal. More... | |
TSequence * | tsequence_from_base_tstzset (Datum value, meosType temptype, const Set *s) |
Return a temporal discrete sequence from a base value and a timestamptz set. More... | |
TSequence * | tsequence_from_base_tstzspan (Datum value, meosType temptype, const Span *s, interpType interp) |
Return a temporal sequence from a base value and a timestamptz span. More... | |
uint32 | tsequence_hash (const TSequence *seq) |
Return the 32-bit hash value of a temporal sequence. More... | |
TSequence * | tsequence_in (const char *str, meosType temptype, interpType interp) |
Return a temporal sequence from its Well-Known Text (WKT) representation. More... | |
const TInstant ** | tsequence_insts_p (const TSequence *seq) |
Return the array of pointers to distinct instants of a temporal sequence. More... | |
TSequence * | tsequence_join (const TSequence *seq1, const TSequence *seq2, bool removelast, bool removefirst) |
Join two temporal sequences. More... | |
bool | tsequence_join_test (const TSequence *seq1, const TSequence *seq2, bool *removelast, bool *removefirst) |
Test whether two sequences can be joined during normalization. More... | |
TSequence * | tsequence_make (const TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp, bool normalize) |
Return a temporal sequence from an array of temporal instants. More... | |
TSequence * | tsequence_make_exp (const TInstant **instants, int count, int maxcount, bool lower_inc, bool upper_inc, interpType interp, bool normalize) |
Return a temporal sequence from an array of temporal instants enabling the data structure to expand. More... | |
TSequence * | tsequence_make_exp1 (const TInstant **instants, int count, int maxcount, bool lower_inc, bool upper_inc, interpType interp, bool normalize, void *bbox) |
Return a temporal sequence from an array of temporal instants. More... | |
TSequence * | tsequence_make_free (TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp, bool normalize) |
Return a temporal sequence from an array of temporal instants and free the array and the instants after the creation. More... | |
TSequence * | tsequence_make_free_exp (TInstant **instants, int count, int maxcount, bool lower_inc, bool upper_inc, interpType interp, bool normalize) |
Return a temporal sequence from an array of temporal instants and free the array and the instants after the creation. More... | |
bool | tsequence_make_valid (const TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp) |
Ensure the validity of the arguments when creating a temporal sequence. More... | |
const TInstant * | tsequence_max_inst (const TSequence *seq) |
Return a pointer to the instant with minimum base value of a temporal sequence. More... | |
Datum | tsequence_max_val (const TSequence *seq) |
Return (a pointer to) the maximum base value of a temporal sequence. More... | |
const TInstant * | tsequence_min_inst (const TSequence *seq) |
Return a pointer to the instant with minimum base value of a temporal sequence. More... | |
Datum | tsequence_min_val (const TSequence *seq) |
Return (a pointer to) the minimum base value of a temporal sequence. More... | |
const TInstant * | tsequence_minmax_inst (const TSequence *seq, bool(*func)(Datum, Datum, meosType)) |
Return a pointer to the instant with minimum base value of a temporal sequence. More... | |
bool | tsequence_norm_test (Datum value1, Datum value2, Datum value3, meosType basetype, interpType interp, TimestampTz t1, TimestampTz t2, TimestampTz t3) |
Test whether we can remove the middle instant among 3 consecutive ones during normalization. More... | |
char * | tsequence_out (const TSequence *seq, int maxdd) |
Return the Well-Known Text (WKT) representation of a temporal sequence. More... | |
void | tsequence_restart (TSequence *seq, int count) |
Return a temporal sequence restarted by keeping only the last n instants. More... | |
TSequence ** | tsequence_segments (const TSequence *seq, int *count) |
Return the array of segments of a temporal sequence. More... | |
int | tsequence_segments_iter (const TSequence *seq, TSequence **result) |
Return the array of segments of a temporal sequence (iterator function) More... | |
const TSequence ** | tsequence_seqs (const TSequence *seq, int *count) |
Return a singleton array of pointers to the sequence of a temporal sequence. More... | |
Temporal * | tsequence_set_interp (const TSequence *seq, interpType interp) |
Return a temporal value transformed to the given interpolation. More... | |
void | tsequence_set_tstzspan (const TSequence *seq, Span *s) |
Return in the last argument the time span of a temporal sequence. More... | |
TSequence * | tsequence_shift_scale_time (const TSequence *seq, const Interval *shift, const Interval *duration) |
Return a temporal sequence shifted and/or scaled by two intervals. More... | |
void | tsequence_shift_scale_time_iter (TSequence *seq, TimestampTz delta, double scale) |
Shift and/or scale the timestamps of the instants of a temporal sequence (iterator function) More... | |
TimestampTz | tsequence_start_timestamptz (const TSequence *seq) |
Return the start timestamptz of a temporal sequence. More... | |
TSequence * | tsequence_subseq (const TSequence *seq, int from, int to, bool lower_inc, bool upper_inc) |
Return a subsequence of a temporal sequence specified by two instants. More... | |
SpanSet * | tsequence_time (const TSequence *seq) |
Return the time frame of a temporal sequence as a span set. More... | |
TimestampTz * | tsequence_timestamps (const TSequence *seq, int *count) |
Return the array of timestamps of a temporal sequence. More... | |
int | tsequence_timestamps_iter (const TSequence *seq, TimestampTz *times) |
Return the array of timestamptz values of a temporal sequence (iterator function) More... | |
char * | tsequence_to_string (const TSequence *seq, int maxdd, bool component, outfunc value_out) |
Return the Well-Known Text (WKT) representation of a temporal sequence. More... | |
bool | tsequence_value_at_timestamptz (const TSequence *seq, TimestampTz t, bool strict, Datum *result) |
Return in the last argument a copy of the value of a temporal sequence at a timestamptz. More... | |
Datum * | tsequence_values_p (const TSequence *seq, int *count) |
Return the array of (pointer to the) distinct values of a temporal sequence. More... | |
TSequenceSet * | tstepseq_to_linear (const TSequence *seq) |
Return a temporal sequence with continuous base type transformed from step to linear interpolation. More... | |
int | tstepseq_to_linear_iter (const TSequence *seq, TSequence **result) |
Return a temporal sequence with continuous base type transformed from step to linear interpolation (iterator function) More... | |
General functions for temporal sequences.