40#include "general/meos_catalog.h"
41#include "general/span.h"
51#define DEFAULT_COLLATION_OID 100
52#define C_COLLATION_OID 950
53#define POSIX_COLLATION_OID 951
58 #define DatumGetTextP(X) ((text *) DatumGetPointer(X))
64#define MOBDB_EPSILON 1.0e-06
65#define MOBDB_FP_EQ(A, B) (fabs((A)-(B)) <= MOBDB_EPSILON)
66#define MOBDB_FP_NE(A, B) (fabs((A)-(B)) > MOBDB_EPSILON)
67#define MOBDB_FP_LT(A, B) (((A) + MOBDB_EPSILON) < (B))
68#define MOBDB_FP_LE(A, B) (((A) - MOBDB_EPSILON) <= (B))
69#define MOBDB_FP_GT(A, B) (((A) - MOBDB_EPSILON) > (B))
70#define MOBDB_FP_GE(A, B) (((A) + MOBDB_EPSILON) >= (B))
75#define DIST_EPSILON 1.0e-06
78#define DISCONTINUOUS true
79#define CONTINUOUS false
83#define ORDERED_NO false
87#define QUOTES_NO false
91#define SPACES_NO false
95#define INVERT_NO false
99#define REST_MINUS false
102#define UPPER_INC true
103#define UPPER_EXC false
114#define CROSSINGS true
115#define CROSSINGS_NO false
118#define BBOX_TEST true
119#define BBOX_TEST_NO false
123#define MERGE_NO false
125#define NORMALIZE true
126#define NORMALIZE_NO false
137#define VALUE_SEL true
138#define TIME_SEL false
142#define SPAN_ROUNDOFF false
175#define ANYTEMPSUBTYPE 0
178#define TSEQUENCESET 3
199#define MOBDB_FLAG_BYVAL 0x0001
201#define MOBDB_FLAG_ORDERED 0x0002
203#define MOBDB_FLAG_CONTINUOUS 0x0002
205#define MOBDB_FLAGS_INTERP 0x000C
207#define MOBDB_FLAG_X 0x0010
208#define MOBDB_FLAG_Z 0x0020
209#define MOBDB_FLAG_T 0x0040
210#define MOBDB_FLAG_GEODETIC 0x0080
212#define MOBDB_FLAGS_GET_BYVAL(flags) ((bool) (((flags) & MOBDB_FLAG_BYVAL)))
213#define MOBDB_FLAGS_GET_ORDERED(flags) ((bool) (((flags) & MOBDB_FLAG_ORDERED)>>1))
214#define MOBDB_FLAGS_GET_CONTINUOUS(flags) ((bool) (((flags) & MOBDB_FLAG_CONTINUOUS)>>1))
215#define MOBDB_FLAGS_GET_X(flags) ((bool) (((flags) & MOBDB_FLAG_X)>>4))
216#define MOBDB_FLAGS_GET_Z(flags) ((bool) (((flags) & MOBDB_FLAG_Z)>>5))
217#define MOBDB_FLAGS_GET_T(flags) ((bool) (((flags) & MOBDB_FLAG_T)>>6))
218#define MOBDB_FLAGS_GET_GEODETIC(flags) ((bool) (((flags) & MOBDB_FLAG_GEODETIC)>>7))
220#define MOBDB_FLAGS_SET_BYVAL(flags, value) \
221 ((flags) = (value) ? ((flags) | MOBDB_FLAG_BYVAL) : ((flags) & ~MOBDB_FLAG_BYVAL))
222#define MOBDB_FLAGS_SET_ORDERED(flags, value) \
223 ((flags) = (value) ? ((flags) | MOBDB_FLAG_ORDERED) : ((flags) & ~MOBDB_FLAG_ORDERED))
224#define MOBDB_FLAGS_SET_CONTINUOUS(flags, value) \
225 ((flags) = (value) ? ((flags) | MOBDB_FLAG_CONTINUOUS) : ((flags) & ~MOBDB_FLAG_CONTINUOUS))
226#define MOBDB_FLAGS_SET_X(flags, value) \
227 ((flags) = (value) ? ((flags) | MOBDB_FLAG_X) : ((flags) & ~MOBDB_FLAG_X))
228#define MOBDB_FLAGS_SET_Z(flags, value) \
229 ((flags) = (value) ? ((flags) | MOBDB_FLAG_Z) : ((flags) & ~MOBDB_FLAG_Z))
230#define MOBDB_FLAGS_SET_T(flags, value) \
231 ((flags) = (value) ? ((flags) | MOBDB_FLAG_T) : ((flags) & ~MOBDB_FLAG_T))
232#define MOBDB_FLAGS_SET_GEODETIC(flags, value) \
233 ((flags) = (value) ? ((flags) | MOBDB_FLAG_GEODETIC) : ((flags) & ~MOBDB_FLAG_GEODETIC))
235#define MOBDB_FLAGS_GET_INTERP(flags) (((flags) & MOBDB_FLAGS_INTERP) >> 2)
236#define MOBDB_FLAGS_SET_INTERP(flags, value) ((flags) = (((flags) & ~MOBDB_FLAGS_INTERP) | ((value & 0x0003) << 2)))
238#define MOBDB_FLAGS_GET_DISCRETE(flags) ((bool) (MOBDB_FLAGS_GET_INTERP((flags)) == DISCRETE))
239#define MOBDB_FLAGS_GET_STEP(flags) ((bool) (MOBDB_FLAGS_GET_INTERP((flags)) == STEP))
240#define MOBDB_FLAGS_GET_LINEAR(flags) ((bool) (MOBDB_FLAGS_GET_INTERP((flags)) == LINEAR))
247#define MOBDB_WKB_TIMESTAMP_SIZE 8
248#define MOBDB_WKB_DOUBLE_SIZE 8
249#define MOBDB_WKB_INT2_SIZE 2
250#define MOBDB_WKB_INT4_SIZE 4
251#define MOBDB_WKB_INT8_SIZE 8
252#define MOBDB_WKB_BYTE_SIZE 1
263#define MOBDB_WKB_LOWER_INC 0x01
264#define MOBDB_WKB_UPPER_INC 0x02
278#define MOBDB_WKB_ORDERED 0x01
279#define MOBDB_WKB_XFLAG 0x01
280#define MOBDB_WKB_TFLAG 0x02
281#define MOBDB_WKB_INTERPFLAGS 0x0C
282#define MOBDB_WKB_ZFLAG 0x10
283#define MOBDB_WKB_GEODETICFLAG 0x20
284#define MOBDB_WKB_SRIDFLAG 0x40
286#define MOBDB_WKB_GET_INTERP(flags) (((flags) & MOBDB_WKB_INTERPFLAGS) >> 2)
287#define MOBDB_WKB_SET_INTERP(flags, value) ((flags) = (((flags) & ~MOBDB_WKB_INTERPFLAGS) | ((value & 0x0003) << 2)))
300#define JAN_3_2000 (2 * USECS_PER_DAY)
301#define DEFAULT_TIME_ORIGIN (JAN_3_2000)
302#define DEFAULT_FLOATSPAN_ORIGIN (0.0)
303#define DEFAULT_INTSPAN_ORIGIN (0)
304#define DEFAULT_BIGINTSPAN_ORIGIN (0)
376#define DatumGetDouble2P(X) ((double2 *) DatumGetPointer(X))
377#define Double2PGetDatum(X) PointerGetDatum(X)
378#define DatumGetDouble3P(X) ((double3 *) DatumGetPointer(X))
379#define Double3PGetDatum(X) PointerGetDatum(X)
380#define DatumGetDouble4P(X) ((double4 *) DatumGetPointer(X))
381#define Double4PGetDatum(X) PointerGetDatum(X)
386 #define DatumGetTemporalP(X) ((Temporal *) DatumGetPointer(X))
388 #define DatumGetTemporalP(X) ((Temporal *) PG_DETOAST_DATUM(X))
391#define PG_GETARG_TEMPORAL_P(X) ((Temporal *) PG_GETARG_VARLENA_P(X))
392#define PG_GETARG_TINSTANT_P(X) ((TInstant *) PG_GETARG_VARLENA_P(X))
393#define PG_GETARG_TSEQUENCE_P(X) ((TSequence *) PG_GETARG_VARLENA_P(X))
394#define PG_GETARG_TSEQUENCESET_P(X) ((TSequenceSet *) PG_GETARG_VARLENA_P(X))
396#define DATUM_FREE(value, basetype) \
398 if (! basetype_byvalue(basetype)) \
399 pfree(DatumGetPointer(value)); \
402#define DATUM_FREE_IF_COPY(value, basetype, n) \
404 if (! basetype_byvalue(basetype) && DatumGetPointer(value) != PG_GETARG_POINTER(n)) \
405 pfree(DatumGetPointer(value)); \
414#define PG_FREE_IF_COPY_P(ptrsrc, ptrori) \
416 if ((Pointer) (ptrsrc) != (Pointer) (ptrori)) \
420#define PG_DATUM_NEEDS_DETOAST(datum) \
421 (VARATT_IS_EXTENDED((datum)) || VARATT_IS_EXTERNAL((datum)) || \
422 VARATT_IS_COMPRESSED((datum)))
428#define DatumGetGserializedP(X) ((GSERIALIZED *) DatumGetPointer(X))
448 const TInstant *inst2,
bool strict);
482 const Datum *values,
int count,
int *newcount);
Temporal * temporal_restrict_minmax(const Temporal *temp, bool min, bool atfunc)
Restrict a temporal value to (the complement of) a minimum base value.
Definition: temporal.c:3336
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.
Definition: temporal.c:3184
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:53
signed short int16
Functions for building a cache of temporal types and operators.
Definition: meos_catalog.h:41
SyncMode
Enumeration for the intersection/synchronization functions.
Definition: temporal.h:146
@ SYNCHRONIZE_CROSS
Definition: temporal.h:148
@ SYNCHRONIZE_NOCROSS
Definition: temporal.h:147
union bboxunion bboxunion
Structure to represent all types of bounding boxes.
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 merg...
Definition: temporal.c:277
void ensure_tinstarr(const TInstant **instants, int count)
Ensure that the elements of an array are of instant subtype.
Definition: temporal.c:101
void * temporal_bbox_ptr(const Temporal *temp)
Return a pointer to the precomputed bounding box of a temporal value.
Definition: temporal.c:425
void temporal_bbox_slice(Datum tempdatum, void *box)
Peak into a temporal datum to find the bounding box.
Definition: temporal.c:347
int(* qsort_comparator)(const void *a, const void *b)
Definition: temporal.h:361
void ensure_valid_tempsubtype_all(int16 type)
Ensure that the subtype of a temporal value is valid.
Definition: temporal.c:78
void ensure_same_temptype(const Temporal *temp1, const Temporal *temp2)
Ensure that two temporal values have the same base type.
Definition: temporal.c:161
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 merg...
Definition: temporal.c:249
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 po...
Definition: temporal.c:347
Datum(* varfunc)(Datum,...)
Definition: temporal.h:364
void ensure_valid_duration(const Interval *duration)
Ensure that the interval is a positive and absolute duration.
Definition: temporal.c:402
bool intersection_temporal_temporal(const Temporal *temp1, const Temporal *temp2, SyncMode mode, Temporal **inter1, Temporal **inter2)
Temporally intersect the two temporal values.
Definition: temporal.c:444
Datum * temporal_bbox_restrict_values(const Temporal *temp, const Datum *values, int count, int *newcount)
void ensure_positive_datum(Datum size, meosType basetype)
Ensure that the number is positive.
Definition: temporal.c:374
char * mobilitydb_full_version(void)
Versions of the MobilityDB extension and its dependencies.
Definition: temporal.c:545
bool temporal_bbox_restrict_value(const Temporal *temp, Datum value)
Return true if the bounding box of a temporal value contains a base value.
Definition: temporal.c:3089
text * cstring_to_text(const char *s)
Basic functions for temporal types of any subtype.
MOBDB_WKB_TSUBTYPE
Definition: temporal.h:256
@ MOBDB_WKB_TSEQUENCESET
temporal sequence set subtype
Definition: temporal.h:259
@ MOBDB_WKB_TINSTANT
temporal instant subtype
Definition: temporal.h:257
@ MOBDB_WKB_TSEQUENCE
temporal sequence subtype
Definition: temporal.h:258
void ensure_continuous_interpolation(int16 flags)
Ensure that a temporal value has continuous interpolation.
Definition: temporal.c:126
char * mobilitydb_version(void)
Version of the MobilityDB extension.
Definition: temporal.c:535
void ensure_common_dimension(int16 flags1, int16 flags2)
Ensure that two temporal values have at least one common dimension based on their flags.
Definition: temporal.c:149
Datum(* datum_func2)(Datum, Datum)
Definition: temporal.h:367
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.
Definition: temporal.c:2695
Datum(* datum_func3)(Datum, Datum, Datum)
Definition: temporal.h:368
void ensure_discrete_interpolation(int16 flags)
Ensure that a temporal value has discrete interpolation.
Definition: temporal.c:115
void ensure_same_interpolation(const Temporal *temp1, const Temporal *temp2)
Ensure that two temporal values have the same interpolation.
Definition: temporal.c:172
TemporalFamily
Enumeration for the families of temporal types.
Definition: temporal.h:153
@ TNPOINTTYPE
Definition: temporal.h:157
@ TNUMBERTYPE
Definition: temporal.h:155
@ TPOINTTYPE
Definition: temporal.h:156
@ TEMPORALTYPE
Definition: temporal.h:154
void ensure_nonlinear_interpolation(int16 flags)
Ensure that a temporal value does not have linear interpolation.
Definition: temporal.c:137
void ensure_continuous(const Temporal *temp)
Ensure that the subtype of temporal type is a sequence (set)
Definition: temporal.c:90
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 val...
Definition: temporal.c:2742
void ensure_increasing_timestamps(const TInstant *inst1, const TInstant *inst2, bool strict)
Ensure that the timestamp of the first temporal instant is smaller (or equal if the merge parameter i...
Definition: temporal.c:191
SetOper
Enumeration for the set operations of span and temporal types.
Definition: temporal.h:162
@ UNION
Definition: temporal.h:163
@ INTER
Definition: temporal.h:164
@ MINUS
Definition: temporal.h:165
void ensure_valid_tempsubtype(int16 type)
Basic functions for temporal types of any subtype.
Definition: temporal.c:66
char * text_to_cstring(const text *t)
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
uintptr_t Datum
Definition: pg_ext_defs.in.h:4
Definition: pg_ext_defs.in.h:24
Structure to represent spatiotemporal boxes.
Definition: meos.h:107
API of the Mobility Engine Open Source (MEOS) library.
Definition: meos.h:56
Structure to represent spans (a.k.a.
Definition: meos.h:70
Structure to represent temporal boxes.
Definition: meos.h:97
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
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:136
double b
Definition: temporal.h:327
double a
Definition: temporal.h:326
Structure to represent values of the internal type for computing aggregates for temporal number types...
Definition: temporal.h:325
double a
Definition: temporal.h:336
double b
Definition: temporal.h:337
double c
Definition: temporal.h:338
Structure to represent values of the internal type for computing aggregates for 2D temporal point typ...
Definition: temporal.h:335
double c
Definition: temporal.h:349
double d
Definition: temporal.h:350
double a
Definition: temporal.h:347
double b
Definition: temporal.h:348
Structure to represent values of the internal type for computing aggregates for 3D temporal point typ...
Definition: temporal.h:346
Definition: pg_ext_defs.in.h:31
TBox b
Temporal box.
Definition: temporal.h:316
Span p
Span.
Definition: temporal.h:315
STBox g
Spatiotemporal box.
Definition: temporal.h:317
Structure to represent all types of bounding boxes.
Definition: temporal.h:314