MobilityDB 1.1
tsequence.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2023, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
27 *
28 *****************************************************************************/
29
34#ifndef __TSEQUENCE_H__
35#define __TSEQUENCE_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39/* MEOS */
40#include "general/temporal.h"
41#include "general/span.h"
42
43/*****************************************************************************/
44
45/* General functions */
46
47extern int tcontseq_find_timestamp(const TSequence *seq, TimestampTz t);
48extern int tdiscseq_find_timestamp(const TSequence *seq, TimestampTz t);
49extern void tsequence_make_valid1(const TInstant **instants, int count,
50 bool lower_inc, bool upper_inc, interpType interp);
51extern TSequence *tsequence_make1(const TInstant **instants, int count,
52 bool lower_inc, bool upper_inc, interpType interp, bool normalize);
53extern TSequence **tseqarr2_to_tseqarr(TSequence ***sequences,
54 int *countseqs, int count, int totalseqs);
55
56/* Append and merge functions */
57
58extern bool tsequence_join_test(const TSequence *seq1, const TSequence *seq2,
59 bool *removelast, bool *removefirst);
60extern TSequence *tsequence_join(const TSequence *seq1, const TSequence *seq2,
61 bool removelast, bool removefirst);
62extern TSequence **tseqarr_normalize(const TSequence **sequences, int count,
63 int *newcount);
64extern TSequence **tsequence_merge_array1(const TSequence **sequences,
65 int count, int *totalcount);
66
67/* Synchronization functions */
68
69extern bool synchronize_tsequence_tsequence(const TSequence *seq1,
70 const TSequence *seq2, TSequence **sync1, TSequence **sync2,
71 bool interpoint);
72
73/* Intersection functions */
74
75extern bool tlinearsegm_intersection_value(const TInstant *inst1,
76 const TInstant *inst2, Datum value, meosType basetype, Datum *inter,
77 TimestampTz *t);
78extern bool tsegment_intersection(const TInstant *start1,
79 const TInstant *end1, bool linear1, const TInstant *start2,
80 const TInstant *end2, bool linear2, Datum *inter1, Datum *inter2,
81 TimestampTz *t);
82
83extern bool intersection_tdiscseq_tdiscseq(const TSequence *is1,
84 const TSequence *is2, TSequence **inter1, TSequence **inter2);
85extern bool intersection_tcontseq_tdiscseq(const TSequence *seq1,
86 const TSequence *seq2, TSequence **inter1, TSequence **inter2);
87extern bool intersection_tdiscseq_tcontseq(const TSequence *is,
88 const TSequence *seq2, TSequence **inter1, TSequence **inter2);
89
90extern bool intersection_tsequence_tinstant(const TSequence *seq,
91 const TInstant *inst, TInstant **inter1, TInstant **inter2);
92extern bool intersection_tinstant_tsequence(const TInstant *inst,
93 const TSequence *seq, TInstant **inter1, TInstant **inter2);
94
95/* Input/output functions */
96
97extern char *tsequence_to_string(const TSequence *seq, int maxdd,
98 bool component, outfunc value_out);
99
100/* Transformation functions */
101
102extern int tstepseq_tlinearseq1(const TSequence *seq, TSequence **result);
103
104/* Accessor functions */
105
106extern int tfloatseq_spans(const TSequence *seq, Span **result);
107extern int tsequence_segments1(const TSequence *seq, TSequence **result);
108extern int tsequence_timestamps1(const TSequence *seq, TimestampTz *result);
109extern int tsequence_values1(const TSequence *seq, Datum *result);
110extern Datum tsegment_value_at_timestamp(const TInstant *inst1,
111 const TInstant *inst2, bool linear, TimestampTz t);
112
113/* Restriction Functions */
114
115extern int tcontseq_restrict_value1(const TSequence *seq, Datum value,
116 bool atfunc, TSequence **result);
117extern int tsequence_at_values1(const TSequence *seq, const Set *set,
118 TSequence **result);
119extern int tnumbercontseq_restrict_span2(const TSequence *seq,
120 const Span *span, bool atfunc, TSequence **result);
121extern int tnumbercontseq_restrict_spanset1(const TSequence *seq,
122 const SpanSet *ss, bool atfunc, TSequence **result);
123extern TInstant *tsegment_at_timestamp(const TInstant *inst1,
124 const TInstant *inst2, bool linear, TimestampTz t);
125extern int tcontseq_minus_timestamp1(const TSequence *seq, TimestampTz t,
126 TSequence **result);
127extern int tcontseq_minus_timestampset1(const TSequence *seq, const Set *s,
128 TSequence **result);
129extern int tcontseq_minus_period1(const TSequence *seq, const Span *p,
130 TSequence **result);
131extern int tcontseq_at_periodset1(const TSequence *seq, const SpanSet *ps,
132 TSequence **result);
133extern int tcontseq_minus_periodset1(const TSequence *seq, const SpanSet *ps,
134 int from, TSequence **result);
135
136/*****************************************************************************/
137
138#endif
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:53
char *(* outfunc)(Datum value, meosType type, int maxdd)
Definition: temporal.h:358
int tcontseq_minus_timestamp1(const TSequence *seq, TimestampTz t, TSequence **result)
Restrict a temporal sequence to the complement of a timestamp.
Definition: tsequence.c:4689
TSequence * tsequence_make1(const TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp, bool normalize)
Construct a temporal sequence from an array of temporal instants.
Definition: tsequence.c:899
int tnumbercontseq_restrict_spanset1(const TSequence *seq, const SpanSet *ss, bool atfunc, TSequence **result)
Restrict a temporal number to (the complement of) an array of spans of base values.
Definition: tsequence.c:4205
TSequence ** tseqarr2_to_tseqarr(TSequence ***sequences, int *countseqs, int count, int totalseqs)
Convert an array of arrays of temporal sequences into an array of temporal sequences.
Definition: tsequence.c:530
bool tsequence_join_test(const TSequence *seq1, const TSequence *seq2, bool *removelast, bool *removefirst)
Test whether two sequences can be joined during normalization.
Definition: tsequence.c:304
int tcontseq_minus_periodset1(const TSequence *seq, const SpanSet *ps, int from, TSequence **result)
Restrict a temporal sequence to the complement of a period set.
Definition: tsequence.c:5188
bool intersection_tdiscseq_tdiscseq(const TSequence *is1, const TSequence *is2, TSequence **inter1, TSequence **inter2)
Temporally intersect two temporal discrete sequences.
Definition: tsequence.c:2735
int tdiscseq_find_timestamp(const TSequence *seq, TimestampTz t)
Return the index of a timestamp in a temporal discrete sequence value using binary search.
Definition: tsequence.c:495
int tcontseq_minus_period1(const TSequence *seq, const Span *p, TSequence **result)
Restrict a temporal sequence to the complement of a period.
Definition: tsequence.c:5076
TSequence ** tsequence_merge_array1(const TSequence **sequences, int count, int *totalcount)
Merge an array of temporal sequences.
Definition: tsequence.c:1648
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.
Definition: tsequence.c:667
void tsequence_make_valid1(const TInstant **instants, int count, bool lower_inc, bool upper_inc, interpType interp)
Ensure the validity of the arguments when creating a temporal sequence.
Definition: tsequence.c:718
bool intersection_tinstant_tsequence(const TInstant *inst, const TSequence *seq, TInstant **inter1, TInstant **inter2)
Temporally intersect two temporal values.
Definition: tsequence.c:3071
int tstepseq_tlinearseq1(const TSequence *seq, TSequence **result)
bool intersection_tdiscseq_tcontseq(const TSequence *is, const TSequence *seq2, TSequence **inter1, TSequence **inter2)
Temporally intersect two temporal values.
Definition: tsequence.c:2822
int tsequence_values1(const TSequence *seq, Datum *result)
bool synchronize_tsequence_tsequence(const TSequence *seq1, const TSequence *seq2, TSequence **sync1, TSequence **sync2, bool interpoint)
Synchronize two temporal sequences.
Definition: tsequence.c:2600
bool tlinearsegm_intersection_value(const TInstant *inst1, const TInstant *inst2, Datum value, meosType basetype, Datum *inter, TimestampTz *t)
Return true if the segment of a temporal sequence intersects the base value at the timestamp.
Definition: tsequence.c:2894
int tnumbercontseq_restrict_span2(const TSequence *seq, const Span *span, bool atfunc, TSequence **result)
Restrict a temporal number to (the complement of) a span.
Definition: tsequence.c:4113
int tsequence_segments1(const TSequence *seq, TSequence **result)
Return the array of segments of a temporal sequence.
Definition: tsequence.c:2310
TInstant * tsegment_at_timestamp(const TInstant *inst1, const TInstant *inst2, bool linear, TimestampTz t)
Restrict the segment of a temporal sequence to a timestamp.
Definition: tsequence.c:4625
TSequence ** tseqarr_normalize(const TSequence **sequences, int count, int *newcount)
Normalize the array of temporal sequences.
Definition: tsequence.c:1605
int tsequence_timestamps1(const TSequence *seq, TimestampTz *result)
Return the array of timestamps of a temporal sequence.
Definition: tsequence.c:2416
int tsequence_at_values1(const TSequence *seq, const Set *set, TSequence **result)
Restrict a temporal sequence to an array of base values.
Definition: tsequence.c:3688
TSequence * tsequence_join(const TSequence *seq1, const TSequence *seq2, bool removelast, bool removefirst)
Join two temporal sequences.
Definition: tsequence.c:402
int tcontseq_at_periodset1(const TSequence *seq, const SpanSet *ps, TSequence **result)
Restrict a temporal sequence to a period set.
Definition: tsequence.c:5136
int tcontseq_restrict_value1(const TSequence *seq, Datum value, bool atfunc, TSequence **result)
Restrict a temporal sequence to (the complement of) a base value.
Definition: tsequence.c:3602
bool intersection_tsequence_tinstant(const TSequence *seq, const TInstant *inst, TInstant **inter1, TInstant **inter2)
Temporally intersect two temporal sequences.
Definition: tsequence.c:3051
int tcontseq_find_timestamp(const TSequence *seq, TimestampTz t)
Basic functions for temporal sequences.
Definition: tsequence.c:449
Datum tsegment_value_at_timestamp(const TInstant *inst1, const TInstant *inst2, bool linear, TimestampTz t)
Return the base value of the segment of a temporal sequence at a timestamp.
Definition: tsequence.c:2453
int tfloatseq_spans(const TSequence *seq, Span **result)
Return the float spans of a temporal float.
Definition: tsequence.c:2078
int tcontseq_minus_timestampset1(const TSequence *seq, const Set *s, TSequence **result)
Restrict a temporal sequence to the complement of a timestamp set.
Definition: tsequence.c:4855
bool tsegment_intersection(const TInstant *start1, const TInstant *end1, bool linear1, const TInstant *start2, const TInstant *end2, bool linear2, Datum *inter1, Datum *inter2, TimestampTz *t)
Return true if two segments of a temporal sequence intersect at a timestamp.
Definition: tsequence.c:3000
bool intersection_tcontseq_tdiscseq(const TSequence *seq1, const TSequence *seq2, TSequence **inter1, TSequence **inter2)
Temporally intersect two temporal sequences.
Definition: tsequence.c:2781
interpType
Enumeration that defines the interpolation types used in MobilityDB.
Definition: meos.h:124
set(MOBILITYDB_MODULE_PATHNAME "$libdir/lib${MOBILITYDB_LIB_NAME}") set(extschema "@extschema@") configure_file(mobilitydb.control $
Definition: CMakeLists.txt:1
int64 TimestampTz
Definition: pg_ext_defs.in.h:19
uintptr_t Datum
Definition: pg_ext_defs.in.h:4
API of the Mobility Engine Open Source (MEOS) library.
Definition: meos.h:56
Structure to represent span sets.
Definition: meos.h:83
Structure to represent spans (a.k.a.
Definition: meos.h:70
Structure to represent temporal values of instant subtype.
Definition: meos.h:148
Structure to represent temporal values of instant set or sequence subtype.
Definition: meos.h:165