39#if POSTGRESQL_VERSION_NUMBER >= 160000
45#include "temporal/doublen.h"
46#include "temporal/meos_catalog.h"
49#define DEFAULT_COLLATION_OID 100
50#define C_COLLATION_OID 950
51#define POSIX_COLLATION_OID 951
56 #define DatumGetTextP(X) ((text *) DatumGetPointer(X))
62#define MEOS_EPSILON 1.0e-06
63#define MEOS_FP_EQ(A, B) (fabs((A)-(B)) <= MEOS_EPSILON)
64#define MEOS_FP_NE(A, B) (fabs((A)-(B)) > MEOS_EPSILON)
65#define MEOS_FP_LT(A, B) (((A) + MEOS_EPSILON) < (B))
66#define MEOS_FP_LE(A, B) (((A) - MEOS_EPSILON) <= (B))
67#define MEOS_FP_GT(A, B) (((A) - MEOS_EPSILON) > (B))
68#define MEOS_FP_GE(A, B) (((A) + MEOS_EPSILON) >= (B))
73#define DIST_EPSILON 1.0e-06
75#define UNUSED __attribute__((unused))
78#define DISCONTINUOUS true
79#define CONTINUOUS false
87#define QUOTES_NO false
91#define SPACES_NO false
95#define INVERT_NO false
99#define REST_MINUS false
102#define BORDER_INC true
103#define BORDER_EXC false
118#define CROSSINGS true
119#define CROSSINGS_NO false
122#define BBOX_TEST true
123#define BBOX_TEST_NO false
127#define MERGE_NO false
129#define NORMALIZE true
130#define NORMALIZE_NO false
137#define VALUE_SEL true
138#define TIME_SEL false
141#define UPPER_EXC true
142#define TIME_SEL false
145#define UNARY_UNION true
146#define UNARY_UNION_NO false
172#if POSTGRESQL_VERSION_NUMBER >= 150000
184#define RTOverBeforeStrategyNumber 28
185#define RTBeforeStrategyNumber 29
186#define RTAfterStrategyNumber 30
187#define RTOverAfterStrategyNumber 31
188#define RTOverFrontStrategyNumber 32
189#define RTFrontStrategyNumber 33
190#define RTBackStrategyNumber 34
191#define RTOverBackStrategyNumber 35
198#define MEOS_WKB_BYTE_SIZE 1
199#define MEOS_WKB_INT2_SIZE 2
200#define MEOS_WKB_INT4_SIZE 4
201#define MEOS_WKB_INT8_SIZE 8
202#define MEOS_WKB_DOUBLE_SIZE 8
203#define MEOS_WKB_DATE_SIZE 4
204#define MEOS_WKB_TIMESTAMP_SIZE 8
215#define MEOS_WKB_LOWER_INC 0x01
216#define MEOS_WKB_UPPER_INC 0x02
230#define MEOS_WKB_ORDERED 0x01
231#define MEOS_WKB_XFLAG 0x01
232#define MEOS_WKB_TFLAG 0x02
233#define MEOS_WKB_INTERPFLAGS 0x0C
234#define MEOS_WKB_ZFLAG 0x10
235#define MEOS_WKB_GEODETICFLAG 0x20
236#define MEOS_WKB_SRIDFLAG 0x40
238#define MEOS_WKB_GET_INTERP(flags) (((flags) & MEOS_WKB_INTERPFLAGS) >> 2)
239#define MEOS_WKB_SET_INTERP(flags, value) ((flags) = (((flags) & ~MEOS_WKB_INTERPFLAGS) | ((value & 0x0003) << 2)))
252#define JAN_3_2000 (2 * USECS_PER_DAY)
253#define DEFAULT_TIME_ORIGIN (JAN_3_2000)
254#define DEFAULT_FLOATSPAN_ORIGIN (0.0)
255#define DEFAULT_INTSPAN_ORIGIN (0)
256#define DEFAULT_BIGINTSPAN_ORIGIN (0)
305#define DatumGetDouble2P(X) ((double2 *) DatumGetPointer(X))
306#define Double2PGetDatum(X) PointerGetDatum(X)
307#define DatumGetDouble3P(X) ((double3 *) DatumGetPointer(X))
308#define Double3PGetDatum(X) PointerGetDatum(X)
309#define DatumGetDouble4P(X) ((double4 *) DatumGetPointer(X))
310#define Double4PGetDatum(X) PointerGetDatum(X)
315 #define DatumGetTemporalP(X) ((Temporal *) DatumGetPointer(X))
317 #define DatumGetTemporalP(X) ((Temporal *) PG_DETOAST_DATUM(X))
320#define PG_GETARG_TEMPORAL_P(X) ((Temporal *) PG_GETARG_VARLENA_P(X))
321#define PG_GETARG_TINSTANT_P(X) ((TInstant *) PG_GETARG_VARLENA_P(X))
322#define PG_GETARG_TSEQUENCE_P(X) ((TSequence *) PG_GETARG_VARLENA_P(X))
323#define PG_GETARG_TSEQUENCESET_P(X) ((TSequenceSet *) PG_GETARG_VARLENA_P(X))
325#define PG_RETURN_TEMPORAL_P(X) PG_RETURN_POINTER(X)
326#define PG_RETURN_TINSTANT_P(X) PG_RETURN_POINTER(X)
327#define PG_RETURN_TSEQUENCE_P(X) PG_RETURN_POINTER(X)
328#define PG_RETURN_TSEQUENCESET_P(X) PG_RETURN_POINTER(X)
330#define TemporalPGetDatum(X) PointerGetDatum(X)
331#define TInstantPGetDatum(X) PointerGetDatum(X)
332#define TSequencePGetDatum(X) PointerGetDatum(X)
333#define TSequenceSetPGetDatum(X) PointerGetDatum(X)
335#define DATUM_FREE(value, basetype) \
337 if (! basetype_byvalue(basetype)) \
338 pfree(DatumGetPointer(value)); \
341#define DATUM_FREE_IF_COPY(value, basetype, n) \
343 if (! basetype_byvalue(basetype) && DatumGetPointer(value) != PG_GETARG_POINTER(n)) \
344 pfree(DatumGetPointer(value)); \
353#define PG_FREE_IF_COPY_P(ptrsrc, ptrori) \
355 if ((Pointer) (ptrsrc) != (Pointer) (ptrori)) \
359#define PG_DATUM_NEEDS_DETOAST(datum) \
360 (VARATT_IS_EXTENDED((datum)) || VARATT_IS_EXTERNAL((datum)) || \
361 VARATT_IS_COMPRESSED((datum)))
char * mobilitydb_full_version(void)
Return the versions of the MobilityDB extension and its dependencies.
Definition: temporal.c:772
char * mobilitydb_version(void)
Return the version of the MobilityDB extension.
Definition: temporal.c:762
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:55
bool ensure_valid_tnumber_tnumber(const Temporal *temp1, const Temporal *temp2)
Ensure that two temporal numbers have the same span type.
Definition: temporal.c:430
SyncMode
Enumeration for the intersection/synchronization functions.
Definition: temporal.h:150
@ SYNCHRONIZE_CROSS
Definition: temporal.h:152
@ SYNCHRONIZE_NOCROSS
Definition: temporal.h:151
MEOS_WKB_TSUBTYPE
Definition: temporal.h:208
@ MEOS_WKB_TSEQUENCESET
temporal sequence set subtype
Definition: temporal.h:211
@ MEOS_WKB_TSEQUENCE
temporal sequence subtype
Definition: temporal.h:210
@ MEOS_WKB_TINSTANT
temporal instant subtype
Definition: temporal.h:209
bool positive_duration(const Interval *duration)
Return true if an interval is a positive duration.
Definition: temporal.c:611
int(* tpfunc_base)(Datum, Datum, Datum, TimestampTz, TimestampTz, TimestampTz *, TimestampTz *)
Definition: temporal.h:286
bool ensure_valid_tnumber_numspan(const Temporal *temp, const Span *s)
Ensure that a temporal number and a span have the same span type.
Definition: temporal.c:339
void * temporal_bbox_ptr(const Temporal *temp)
Return a pointer to the precomputed bounding box of a temporal value.
Definition: temporal.c:650
bool ensure_not_null(void *ptr)
Ensure that the pointer is not null.
Definition: temporal.c:136
int(* qsort_comparator)(const void *a, const void *b)
Definition: temporal.h:280
bool ensure_temporal_isof_type(const Temporal *temp, meosType type)
Ensure that a temporal value is of a temporal type.
Definition: temporal.c:294
bool ensure_one_true(bool hasshift, bool haswidth)
Ensure that at least one of the values is true.
Definition: temporal.c:161
bool ensure_temporal_isof_basetype(const Temporal *temp, meosType basetype)
Ensure that a temporal value has a given base type.
Definition: temporal.c:280
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.
Definition: temporal.c:412
bool ensure_positive_duration(const Interval *duration)
Ensure that an interval is a positive duration.
Definition: temporal.c:626
bool not_negative_datum(Datum size, meosType basetype)
Return true if a number is not negative.
Definition: temporal.c:475
bool ensure_same_continuous_interp(int16 flags1, int16 flags2)
Ensure that two temporal values have the same continuous interpolation.
Definition: temporal.c:220
bool ensure_positive_datum(Datum size, meosType basetype)
Ensure that a number is strictly positive.
Definition: temporal.c:537
bool ensure_has_Z(meosType type, int16 flags)
Ensure that a MEOS type has Z dimension.
Definition: temporal.c:97
Datum(* varfunc)(Datum,...)
Definition: temporal.h:283
bool intersection_temporal_temporal(const Temporal *temp1, const Temporal *temp2, SyncMode mode, Temporal **inter1, Temporal **inter2)
Return the temporal intersection of two temporal values.
Definition: temporal.c:668
bool ensure_valid_day_duration(const Interval *duration)
Ensure that a day interval for binning is valid.
Definition: temporal.c:572
datum_func2 round_fn(meosType basetype)
Return the function for rounding a base type.
Definition: temporal.c:1179
int(* tpfunc_temp)(Datum, Datum, Datum, Datum, Datum, TimestampTz, TimestampTz, TimestampTz *, TimestampTz *)
Definition: temporal.h:290
bool ensure_continuous(const Temporal *temp)
Ensure that the subtype of temporal type is a sequence (set)
Definition: temporal.c:190
bool ensure_valid_temporal_set(const Temporal *temp, const Set *s)
Ensure that a temporal number and a set have the same span type.
Definition: temporal.c:395
bool ensure_not_negative_datum(Datum size, meosType basetype)
Ensure that a number is not negative.
Definition: temporal.c:492
bool ensure_same_temporal_type(const Temporal *temp1, const Temporal *temp2)
Ensure that two temporal values have the same temporal type.
Definition: temporal.c:309
bool ensure_linear_interp(int16 flags)
Ensure that a temporal value has linear interpolation.
Definition: temporal.c:237
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_restrict.c:74
bool ensure_nonlinear_interp(int16 flags)
Ensure that a temporal value does not have linear interpolation.
Definition: temporal.c:250
int32 pg_atoi(const char *s, int size, int c)
bool ensure_has_T(meosType type, int16 flags)
Ensure that a MEOS type has Z dimension.
Definition: temporal.c:123
Datum(* datum_func2)(Datum, Datum)
Definition: temporal.h:296
bool ensure_temporal_isof_subtype(const Temporal *temp, tempSubtype type)
Ensure that a temporal value is of a given subtype.
Definition: temporal.c:323
Datum(* datum_func3)(Datum, Datum, Datum)
Definition: temporal.h:297
bool ensure_valid_interp(meosType temptype, interpType interp)
Ensure that an interpolation is valid.
Definition: temporal.c:175
bool ensure_has_not_Z(meosType type, int16 flags)
Ensure that a MEOS type has not Z dimension.
Definition: temporal.c:110
bool positive_datum(Datum size, meosType basetype)
Return true if a number is strictly positive.
Definition: temporal.c:514
TemporalFamily
Enumeration for the families of temporal types.
Definition: temporal.h:157
@ TSPATIALTYPE
Definition: temporal.h:160
@ TNUMBERTYPE
Definition: temporal.h:159
@ TEMPORALTYPE
Definition: temporal.h:158
bool ensure_one_not_null(void *ptr1, void *ptr2)
Ensure that at least one of the pointers is not null.
Definition: temporal.c:148
bool ensure_common_dimension(int16 flags1, int16 flags2)
Ensure that two temporal values have at least one common dimension.
Definition: temporal.c:263
Datum(* datum_func1)(Datum)
Definition: temporal.h:295
bool ensure_same_interp(const Temporal *temp1, const Temporal *temp2)
Ensure that two temporal values have the same interpolation.
Definition: temporal.c:205
bool ensure_not_negative(int i)
Ensure that a number is positive or zero.
Definition: temporal.c:449
bool ensure_positive(int i)
Ensure that a number is positive.
Definition: temporal.c:462
SetOper
Enumeration for the set operations of span and temporal types.
Definition: temporal.h:165
@ UNION
Definition: temporal.h:166
@ INTER
Definition: temporal.h:167
@ MINUS
Definition: temporal.h:168
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.
Definition: temporal.c:356
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.
Definition: temporal.c:375
bool ensure_has_X(meosType type, int16 flags)
Ensure that a MEOS type has X dimension.
Definition: temporal.c:84
tempSubtype
Enumeration that defines the temporal subtypes used in MEOS.
Definition: meos.h:150
interpType
Enumeration that defines the interpolation types used in MEOS.
Definition: meos.h:161
External API of the Mobility Engine Open Source (MEOS) library.
int32 pg_strtoint32(const char *s)
Return an input string converted to a signed 32 bit integer.
Definition: numutils.c:95
int64 TimestampTz
Definition: postgres_ext_defs.in.h:22
signed short int16
Definition: postgres_ext_defs.in.h:10
uintptr_t Datum
Definition: postgres_ext_defs.in.h:7
signed int int32
Definition: postgres_ext_defs.in.h:11
Definition: postgres_ext_defs.in.h:27
Structure to represent spatiotemporal boxes.
Definition: meos.h:134
Structure to represent sets of values.
Definition: meos.h:80
Structure to represent span sets.
Definition: meos.h:108
Structure to represent spans (a.k.a.
Definition: meos.h:94
Structure to represent temporal boxes.
Definition: meos.h:124
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:173
TBox b
Temporal box.
Definition: temporal.h:268
Span p
Span.
Definition: temporal.h:267
STBox g
Spatiotemporal box.
Definition: temporal.h:269
Structure to represent all types of bounding boxes.
Definition: temporal.h:266