MobilityDB  1.0
temporal_boxops.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * This MobilityDB code is provided under The PostgreSQL License.
4  *
5  * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
6  * contributors
7  *
8  * MobilityDB includes portions of PostGIS version 3 source code released
9  * under the GNU General Public License (GPLv2 or later).
10  * Copyright (c) 2001-2021, PostGIS contributors
11  *
12  * Permission to use, copy, modify, and distribute this software and its
13  * documentation for any purpose, without fee, and without a written
14  * agreement is hereby granted, provided that the above copyright notice and
15  * this paragraph and the following two paragraphs appear in all copies.
16  *
17  * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
18  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
19  * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
20  * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
21  * OF SUCH DAMAGE.
22  *
23  * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
26  * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
27  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
28  *
29  *****************************************************************************/
30 
36 #ifndef __TEMPORAL_BOXOPS_H__
37 #define __TEMPORAL_BOXOPS_H__
38 
39 #include <postgres.h>
40 #include <catalog/pg_type.h>
41 #include <utils/rangetypes.h>
42 
43 #include "temporal.h"
44 #include "tbox.h"
45 
46 /*****************************************************************************/
47 
48 /* Functions on generic bounding boxes of temporal types */
49 
50 extern bool temporal_bbox_eq(const void *box1, const void *box2, Oid basetypid);
51 extern int temporal_bbox_cmp(const void *box1, const void *box2, Oid basetypid);
52 extern void temporal_bbox_expand(void *box1, const void *box2, Oid basetypid);
53 extern void temporal_bbox_shift_tscale(void *box, const Interval *start,
54  const Interval *duration, Oid basetypid);
55 
56 /* Compute the bounding box at the creation of temporal values */
57 
58 extern void tinstant_make_bbox(void *bbox, const TInstant *inst);
59 extern void tinstantset_make_bbox(void *bbox, const TInstant **inst, int count);
60 extern void tsequence_make_bbox(void *bbox, const TInstant** inst, int count,
61  bool lower_inc, bool upper_inc);
62 extern void tsequenceset_make_bbox(void *bbox, const TSequence **seqs, int count);
63 
64 /* Restriction at/minus tbox */
65 
66 extern Datum tnumber_at_tbox(PG_FUNCTION_ARGS);
67 extern Datum tnumber_minus_tbox(PG_FUNCTION_ARGS);
68 
69 extern Temporal *tnumber_at_tbox_internal(const Temporal *temp, const TBOX *box);
70 extern Temporal *tnumber_minus_tbox_internal(const Temporal *temp, const TBOX *box);
71 
72 /* Bounding box operators for temporal types */
73 
74 extern Datum contains_bbox_period_temporal(PG_FUNCTION_ARGS);
75 extern Datum contains_bbox_temporal_period(PG_FUNCTION_ARGS);
76 extern Datum contains_bbox_temporal_temporal(PG_FUNCTION_ARGS);
77 
78 extern Datum contained_bbox_period_temporal(PG_FUNCTION_ARGS);
79 extern Datum contained_bbox_temporal_period(PG_FUNCTION_ARGS);
80 extern Datum contained_bbox_temporal_temporal(PG_FUNCTION_ARGS);
81 
82 extern Datum overlaps_bbox_period_temporal(PG_FUNCTION_ARGS);
83 extern Datum overlaps_bbox_temporal_period(PG_FUNCTION_ARGS);
84 extern Datum overlaps_bbox_temporal_temporal(PG_FUNCTION_ARGS);
85 
86 extern Datum same_bbox_period_temporal(PG_FUNCTION_ARGS);
87 extern Datum same_bbox_temporal_period(PG_FUNCTION_ARGS);
88 extern Datum same_bbox_temporal_temporal(PG_FUNCTION_ARGS);
89 
90 extern Datum overlaps_bbox_range_tnumber(PG_FUNCTION_ARGS);
91 extern Datum overlaps_bbox_tbox_tnumber(PG_FUNCTION_ARGS);
92 extern Datum overlaps_bbox_tnumber_range(PG_FUNCTION_ARGS);
93 extern Datum overlaps_bbox_tnumber_tbox(PG_FUNCTION_ARGS);
94 extern Datum overlaps_bbox_tnumber_tnumber(PG_FUNCTION_ARGS);
95 
96 extern Datum contains_bbox_range_tnumber(PG_FUNCTION_ARGS);
97 extern Datum contains_bbox_tbox_tnumber(PG_FUNCTION_ARGS);
98 extern Datum contains_bbox_tnumber_range(PG_FUNCTION_ARGS);
99 extern Datum contains_bbox_tnumber_tbox(PG_FUNCTION_ARGS);
100 extern Datum contains_bbox_tnumber_tnumber(PG_FUNCTION_ARGS);
101 
102 extern Datum contained_bbox_range_tnumber(PG_FUNCTION_ARGS);
103 extern Datum contained_bbox_tbox_tnumber(PG_FUNCTION_ARGS);
104 extern Datum contained_bbox_tnumber_range(PG_FUNCTION_ARGS);
105 extern Datum contained_bbox_tnumber_tbox(PG_FUNCTION_ARGS);
106 extern Datum contained_bbox_tnumber_tnumber(PG_FUNCTION_ARGS);
107 
108 extern Datum same_bbox_range_tnumber(PG_FUNCTION_ARGS);
109 extern Datum same_bbox_tbox_tnumber(PG_FUNCTION_ARGS);
110 extern Datum same_bbox_tnumber_range(PG_FUNCTION_ARGS);
111 extern Datum same_bbox_tnumber_tbox(PG_FUNCTION_ARGS);
112 extern Datum same_bbox_tnumber_tnumber(PG_FUNCTION_ARGS);
113 
114 extern Datum boxop_period_temporal(FunctionCallInfo fcinfo,
115  bool (*func)(const Period *, const Period *));
116 extern Datum boxop_temporal_period(FunctionCallInfo fcinfo,
117  bool (*func)(const Period *, const Period *));
118 extern Datum boxop_temporal_temporal(FunctionCallInfo fcinfo,
119  bool (*func)(const Period *, const Period *));
120 
121 extern Datum boxop_range_tnumber(FunctionCallInfo fcinfo,
122  bool (*func)(const TBOX *, const TBOX *));
123 extern Datum boxop_tnumber_range(FunctionCallInfo fcinfo,
124  bool (*func)(const TBOX *, const TBOX *));
125 extern Datum boxop_tbox_tnumber(FunctionCallInfo fcinfo,
126  bool (*func)(const TBOX *, const TBOX *));
127 extern Datum boxop_tnumber_tbox(FunctionCallInfo fcinfo,
128  bool (*func)(const TBOX *, const TBOX *));
129 extern Datum boxop_tnumber_tnumber(FunctionCallInfo fcinfo,
130  bool (*func)(const TBOX *, const TBOX *));
131 
132 /*****************************************************************************/
133 
134 #endif
Datum same_bbox_tnumber_tbox(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number and the temporal box are equal in the common ...
Definition: temporal_boxops.c:928
Structure to represent periods.
Definition: timetypes.h:52
int temporal_bbox_cmp(const void *box1, const void *box2, Oid basetypid)
Returns -1, 0, or 1 depending on whether the first bounding box is less than, equal, or greater than the second one.
Definition: temporal_boxops.c:105
Datum overlaps_bbox_tnumber_tbox(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number and the temporal box overlap.
Definition: temporal_boxops.c:872
Datum overlaps_bbox_tnumber_tnumber(PG_FUNCTION_ARGS)
Returns true if the bounding boxes of the temporal numbers overlap.
Definition: temporal_boxops.c:882
Datum contains_bbox_range_tnumber(PG_FUNCTION_ARGS)
Returns true if the range contains the bounding box of the temporal number.
Definition: temporal_boxops.c:729
Datum boxop_range_tnumber(FunctionCallInfo fcinfo, bool(*func)(const TBOX *, const TBOX *))
Generic bounding box operator for a range and a temporal number.
Definition: temporal_boxops.c:602
Datum boxop_temporal_temporal(FunctionCallInfo fcinfo, bool(*func)(const Period *, const Period *))
Generic bounding box operator for two temporal values.
Definition: temporal_boxops.c:390
Datum boxop_tnumber_tbox(FunctionCallInfo fcinfo, bool(*func)(const TBOX *, const TBOX *))
Generic bounding box operator for a temporal number and a temporal box.
Definition: temporal_boxops.c:684
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: temporal.h:241
Datum contains_bbox_tnumber_range(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number contains the range.
Definition: temporal_boxops.c:739
Datum overlaps_bbox_period_temporal(PG_FUNCTION_ARGS)
Returns true if the period and the bounding period of the temporal value overlap. ...
Definition: temporal_boxops.c:488
Datum tnumber_minus_tbox(PG_FUNCTION_ARGS)
Restricts the temporal value to the complement of the temporal box.
Definition: temporal.c:3997
Datum same_bbox_tbox_tnumber(PG_FUNCTION_ARGS)
Returns true if the temporal box and the bounding box of the temporal number are equal in the common ...
Definition: temporal_boxops.c:917
Datum contains_bbox_tnumber_tnumber(PG_FUNCTION_ARGS)
Returns true if the bounding box of the first temporal number contains the one of the second temporal...
Definition: temporal_boxops.c:771
Datum contains_bbox_tbox_tnumber(PG_FUNCTION_ARGS)
Returns true if the temporal box contains the bounding box of the temporal number.
Definition: temporal_boxops.c:750
Datum contained_bbox_range_tnumber(PG_FUNCTION_ARGS)
Returns true if the range is contained in the bounding box of the temporal number.
Definition: temporal_boxops.c:783
Temporal * tnumber_at_tbox_internal(const Temporal *temp, const TBOX *box)
Restrict the temporal number to the temporal box (internal function)
Definition: temporal.c:3881
Datum contains_bbox_tnumber_tbox(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number contains the temporal box.
Definition: temporal_boxops.c:760
Datum overlaps_bbox_tnumber_range(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number and the the range overlap.
Definition: temporal_boxops.c:850
Basic functions for temporal types of any subtype.
Datum overlaps_bbox_range_tnumber(PG_FUNCTION_ARGS)
Returns true if the range and the bounding box of the temporal number overlap.
Definition: temporal_boxops.c:839
Datum overlaps_bbox_temporal_period(PG_FUNCTION_ARGS)
Returns true if the bounding period of the temporal value and the period overlap. ...
Definition: temporal_boxops.c:500
Datum boxop_tbox_tnumber(FunctionCallInfo fcinfo, bool(*func)(const TBOX *, const TBOX *))
Generic bounding box operator for a temporal box and a temporal number.
Definition: temporal_boxops.c:664
Datum contained_bbox_tnumber_tbox(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number is contained in the temporal box...
Definition: temporal_boxops.c:816
Datum contains_bbox_period_temporal(PG_FUNCTION_ARGS)
Returns true if the period contains the bounding period of the temporal value.
Definition: temporal_boxops.c:413
Datum overlaps_bbox_tbox_tnumber(PG_FUNCTION_ARGS)
Returns true if the temporal box and the bounding box of the temporal number overlap.
Definition: temporal_boxops.c:861
void temporal_bbox_expand(void *box1, const void *box2, Oid basetypid)
void tinstantset_make_bbox(void *bbox, const TInstant **inst, int count)
Set the bounding box from the array of temporal instant values (dispatch function) ...
Definition: temporal_boxops.c:226
Datum contains_bbox_temporal_period(PG_FUNCTION_ARGS)
Returns true if the bounding period of the temporal value contains the period.
Definition: temporal_boxops.c:424
Structure to represent temporal boxes.
Definition: tbox.h:53
Datum same_bbox_period_temporal(PG_FUNCTION_ARGS)
Returns true if the period and the bounding period of the temporal value are equal.
Definition: temporal_boxops.c:525
Datum boxop_period_temporal(FunctionCallInfo fcinfo, bool(*func)(const Period *, const Period *))
Generic bounding box operator for a period and a temporal value.
Definition: temporal_boxops.c:352
Datum contained_bbox_tnumber_range(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number is contained in the range.
Definition: temporal_boxops.c:794
Datum same_bbox_temporal_temporal(PG_FUNCTION_ARGS)
Returns true if the bounding periods of the temporal values are equal.
Definition: temporal_boxops.c:548
Datum contained_bbox_temporal_period(PG_FUNCTION_ARGS)
Returns true if the bounding period of the temporal value is contained in the period.
Definition: temporal_boxops.c:462
Functions for temporal bounding boxes.
void tinstant_make_bbox(void *bbox, const TInstant *inst)
Set the bounding box from a temporal instant value.
Definition: temporal_boxops.c:155
void temporal_bbox_shift_tscale(void *box, const Interval *start, const Interval *duration, Oid basetypid)
Shift and/or scale the time span of the bounding box with the two intervals.
Definition: temporal_boxops.c:127
Datum contained_bbox_temporal_temporal(PG_FUNCTION_ARGS)
Returns true if the bounding period of the first temporal value is contained in the bounding period o...
Definition: temporal_boxops.c:474
Datum contained_bbox_period_temporal(PG_FUNCTION_ARGS)
Returns true if the period is contained the bounding period of the temporal value.
Definition: temporal_boxops.c:450
Datum contained_bbox_tnumber_tnumber(PG_FUNCTION_ARGS)
Returns true if the bounding box of the first temporal number is contained in the one of the second t...
Definition: temporal_boxops.c:827
Temporal * tnumber_minus_tbox_internal(const Temporal *temp, const TBOX *box)
Restrict the temporal number to the complement of the temporal box (internal function).
Definition: temporal.c:3940
Datum overlaps_bbox_temporal_temporal(PG_FUNCTION_ARGS)
Returns true if the bounding periods of the temporal values overlap.
Definition: temporal_boxops.c:511
Datum boxop_tnumber_range(FunctionCallInfo fcinfo, bool(*func)(const TBOX *, const TBOX *))
Generic bounding box operator for a temporal number and a range.
Definition: temporal_boxops.c:633
Datum same_bbox_temporal_period(PG_FUNCTION_ARGS)
Returns true if the bounding period of the temporal value and the period are equal.
Definition: temporal_boxops.c:537
Datum boxop_tnumber_tnumber(FunctionCallInfo fcinfo, bool(*func)(const TBOX *, const TBOX *))
Generic bounding box operator for two temporal numbers.
Definition: temporal_boxops.c:704
Datum tnumber_at_tbox(PG_FUNCTION_ARGS)
Restricts the temporal value to the temporal box.
Definition: temporal.c:3987
Datum contained_bbox_tbox_tnumber(PG_FUNCTION_ARGS)
Returns true if the temporal box is contained in the bounding box of the temporal number...
Definition: temporal_boxops.c:805
bool upper_inc(RangeType *range)
Returns true if the upper bound of the range value is inclusive.
Definition: rangetypes_ext.c:104
void tsequenceset_make_bbox(void *bbox, const TSequence **seqs, int count)
Set the bounding box from the array of temporal sequence values (dispatch function) ...
Definition: temporal_boxops.c:322
Datum same_bbox_tnumber_range(PG_FUNCTION_ARGS)
Returns true if the bounding box of the temporal number and the the range are equal on the common dim...
Definition: temporal_boxops.c:906
Datum contains_bbox_temporal_temporal(PG_FUNCTION_ARGS)
Returns true if the bounding period of the first temporal value contains the bounding period of the s...
Definition: temporal_boxops.c:436
Datum same_bbox_tnumber_tnumber(PG_FUNCTION_ARGS)
Returns true if the bounding boxes of the temporal numbers are equal in the common dimensions...
Definition: temporal_boxops.c:939
void tsequence_make_bbox(void *bbox, const TInstant **inst, int count, bool lower_inc, bool upper_inc)
Set the bounding box from the array of temporal instant values (dispatch function) ...
Definition: temporal_boxops.c:254
bool lower_inc(RangeType *range)
Returns true if the lower bound of the range value is inclusive.
Definition: rangetypes_ext.c:91
Datum same_bbox_range_tnumber(PG_FUNCTION_ARGS)
Returns true if the range and the bounding box of the temporal number are equal on the common dimensi...
Definition: temporal_boxops.c:895
Datum boxop_temporal_period(FunctionCallInfo fcinfo, bool(*func)(const Period *, const Period *))
Generic bounding box operator for a temporal value and a period.
Definition: temporal_boxops.c:371
Structure to represent temporal values of sequence subtype.
Definition: temporal.h:279
bool temporal_bbox_eq(const void *box1, const void *box2, Oid basetypid)
Returns true if the bounding boxes are equal.
Definition: temporal_boxops.c:78
Structure to represent temporal values of instant subtype.
Definition: temporal.h:253