39#if POSTGRESQL_VERSION_NUMBER >= 160000
46#include "temporal/doublen.h"
47#include "temporal/meos_catalog.h"
50#define DEFAULT_COLLATION_OID 100
51#define C_COLLATION_OID 950
52#define POSIX_COLLATION_OID 951
57 #define DatumGetTextP(X) ((text *) DatumGetPointer(X))
63#define MEOS_EPSILON 1.0e-06
64#define MEOS_FP_EQ(A, B) (fabs((A)-(B)) <= MEOS_EPSILON)
65#define MEOS_FP_NE(A, B) (fabs((A)-(B)) > MEOS_EPSILON)
66#define MEOS_FP_LT(A, B) (((A) + MEOS_EPSILON) < (B))
67#define MEOS_FP_LE(A, B) (((A) - MEOS_EPSILON) <= (B))
68#define MEOS_FP_GT(A, B) (((A) - MEOS_EPSILON) > (B))
69#define MEOS_FP_GE(A, B) (((A) + MEOS_EPSILON) >= (B))
74#define DIST_EPSILON 1.0e-06
76#define UNUSED __attribute__((unused))
79#define DISCONTINUOUS true
80#define CONTINUOUS false
88#define QUOTES_NO false
92#define SPACES_NO false
96#define INVERT_NO false
100#define REST_MINUS false
103#define BORDER_INC true
104#define BORDER_EXC false
119#define CROSSINGS true
120#define CROSSINGS_NO false
123#define BBOX_TEST true
124#define BBOX_TEST_NO false
128#define MERGE_NO false
130#define NORMALIZE true
131#define NORMALIZE_NO false
138#define VALUE_SEL true
139#define TIME_SEL false
142#define UPPER_EXC true
143#define TIME_SEL false
146#define UNARY_UNION true
147#define UNARY_UNION_NO false
184#if POSTGRESQL_VERSION_NUMBER >= 150000
196#define RTOverBeforeStrategyNumber 28
197#define RTBeforeStrategyNumber 29
198#define RTAfterStrategyNumber 30
199#define RTOverAfterStrategyNumber 31
200#define RTOverFrontStrategyNumber 32
201#define RTFrontStrategyNumber 33
202#define RTBackStrategyNumber 34
203#define RTOverBackStrategyNumber 35
210#define MEOS_WKB_BYTE_SIZE 1
211#define MEOS_WKB_INT2_SIZE 2
212#define MEOS_WKB_INT4_SIZE 4
213#define MEOS_WKB_INT8_SIZE 8
214#define MEOS_WKB_DOUBLE_SIZE 8
215#define MEOS_WKB_DATE_SIZE 4
216#define MEOS_WKB_TIMESTAMP_SIZE 8
227#define MEOS_WKB_LOWER_INC 0x01
228#define MEOS_WKB_UPPER_INC 0x02
242#define MEOS_WKB_ORDERED 0x01
243#define MEOS_WKB_XFLAG 0x01
244#define MEOS_WKB_TFLAG 0x02
245#define MEOS_WKB_INTERPFLAGS 0x0C
246#define MEOS_WKB_ZFLAG 0x10
247#define MEOS_WKB_GEODETICFLAG 0x20
248#define MEOS_WKB_SRIDFLAG 0x40
250#define MEOS_WKB_GET_INTERP(flags) (((flags) & MEOS_WKB_INTERPFLAGS) >> 2)
251#define MEOS_WKB_SET_INTERP(flags, value) ((flags) = (((flags) & ~MEOS_WKB_INTERPFLAGS) | ((value & 0x0003) << 2)))
264#define JAN_3_2000 (2 * USECS_PER_DAY)
265#define DEFAULT_TIME_ORIGIN (JAN_3_2000)
266#define DEFAULT_FLOATSPAN_ORIGIN (0.0)
267#define DEFAULT_INTSPAN_ORIGIN (0)
268#define DEFAULT_BIGINTSPAN_ORIGIN (0)
311#define DatumGetDouble2P(X) ((double2 *) DatumGetPointer(X))
312#define Double2PGetDatum(X) PointerGetDatum(X)
313#define DatumGetDouble3P(X) ((double3 *) DatumGetPointer(X))
314#define Double3PGetDatum(X) PointerGetDatum(X)
315#define DatumGetDouble4P(X) ((double4 *) DatumGetPointer(X))
316#define Double4PGetDatum(X) PointerGetDatum(X)
321 #define DatumGetTemporalP(X) ((Temporal *) DatumGetPointer(X))
322 #define DatumGetTInstantP(X) ((TInstant *) DatumGetPointer(X))
323 #define DatumGetTSequenceP(X) ((TSequence *) DatumGetPointer(X))
324 #define DatumGetTSequenceSetP(X) ((TSequenceSet *) DatumGetPointer(X))
326 #define DatumGetTemporalP(X) ((Temporal *) PG_DETOAST_DATUM(X))
327 #define DatumGetTInstantP(X) ((TInstant *) PG_DETOAST_DATUM(X))
328 #define DatumGetTSequenceP(X) ((TSequence *) PG_DETOAST_DATUM(X))
329 #define DatumGetTSequenceSetP(X) ((TSequenceSet *) PG_DETOAST_DATUM(X))
332#define PG_GETARG_TEMPORAL_P(X) ((Temporal *) PG_GETARG_VARLENA_P(X))
333#define PG_GETARG_TINSTANT_P(X) ((TInstant *) PG_GETARG_VARLENA_P(X))
334#define PG_GETARG_TSEQUENCE_P(X) ((TSequence *) PG_GETARG_VARLENA_P(X))
335#define PG_GETARG_TSEQUENCESET_P(X) ((TSequenceSet *) PG_GETARG_VARLENA_P(X))
337#define PG_RETURN_TEMPORAL_P(X) PG_RETURN_POINTER(X)
338#define PG_RETURN_TINSTANT_P(X) PG_RETURN_POINTER(X)
339#define PG_RETURN_TSEQUENCE_P(X) PG_RETURN_POINTER(X)
340#define PG_RETURN_TSEQUENCESET_P(X) PG_RETURN_POINTER(X)
342#define TemporalPGetDatum(X) PointerGetDatum(X)
343#define TInstantPGetDatum(X) PointerGetDatum(X)
344#define TSequencePGetDatum(X) PointerGetDatum(X)
345#define TSequenceSetPGetDatum(X) PointerGetDatum(X)
347#define DATUM_FREE(value, basetype) \
349 if (! basetype_byvalue(basetype)) \
350 pfree(DatumGetPointer(value)); \
353#define DATUM_FREE_IF_COPY(value, basetype, n) \
355 if (! basetype_byvalue(basetype) && DatumGetPointer(value) != PG_GETARG_POINTER(n)) \
356 pfree(DatumGetPointer(value)); \
365#define PG_FREE_IF_COPY_P(ptrsrc, ptrori) \
367 if ((Pointer) (ptrsrc) != (Pointer) (ptrori)) \
371#define PG_DATUM_NEEDS_DETOAST(datum) \
372 (VARATT_IS_EXTENDED((datum)) || VARATT_IS_EXTERNAL((datum)) || \
373 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:151
@ SYNCHRONIZE_CROSS
Definition: temporal.h:153
@ SYNCHRONIZE_NOCROSS
Definition: temporal.h:152
MEOS_WKB_TSUBTYPE
Definition: temporal.h:220
@ MEOS_WKB_TSEQUENCESET
temporal sequence set subtype
Definition: temporal.h:223
@ MEOS_WKB_TSEQUENCE
temporal sequence subtype
Definition: temporal.h:222
@ MEOS_WKB_TINSTANT
temporal instant subtype
Definition: temporal.h:221
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:298
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
bool ensure_has_not_Z(MeosType type, int16 flags)
Ensure that a MEOS type has not Z dimension.
Definition: temporal.c:110
int(* qsort_comparator)(const void *a, const void *b)
Definition: temporal.h:292
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_has_Z(MeosType type, int16 flags)
Ensure that a MEOS type has Z dimension.
Definition: temporal.c:97
bool ensure_one_true(bool hasshift, bool haswidth)
Ensure that at least one of the values is true.
Definition: temporal.c:161
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 ensure_same_continuous_interp(int16 flags1, int16 flags2)
Ensure that two temporal values have the same continuous interpolation.
Definition: temporal.c:220
bool not_negative_datum(Datum size, MeosType basetype)
Return true if a number is not negative.
Definition: temporal.c:475
Datum(* varfunc)(Datum,...)
Definition: temporal.h:295
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
int(* tpfunc_temp)(Datum, Datum, Datum, Datum, Datum, TimestampTz, TimestampTz, TimestampTz *, TimestampTz *)
Definition: temporal.h:302
bool ensure_continuous(const Temporal *temp)
Ensure that the subtype of temporal type is a sequence (set)
Definition: temporal.c:190
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_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_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 ensure_not_negative_datum(Datum size, MeosType basetype)
Ensure that a number is not negative.
Definition: temporal.c:492
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
datum_func2 round_fn(MeosType basetype)
Return the function for rounding a base type.
Definition: temporal.c:1178
int32 pg_atoi(const char *s, int size, int c)
bool ensure_temporal_isof_subtype(const Temporal *temp, tempSubtype type)
Ensure that a temporal value is of a given subtype.
Definition: temporal.c:323
bool ensure_has_X(MeosType type, int16 flags)
Ensure that a MEOS type has X dimension.
Definition: temporal.c:84
TemporalFamily
Enumeration for the families of temporal types.
Definition: temporal.h:158
@ TSPATIALTYPE
Definition: temporal.h:161
@ TNUMBERTYPE
Definition: temporal.h:160
@ TEMPORALTYPE
Definition: temporal.h:159
bool positive_datum(Datum size, MeosType basetype)
Return true if a number is strictly positive.
Definition: temporal.c:514
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
bool ensure_positive_datum(Datum size, MeosType basetype)
Ensure that a number is strictly positive.
Definition: temporal.c:537
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_has_T(MeosType type, int16 flags)
Ensure that a MEOS type has Z dimension.
Definition: temporal.c:123
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
CompOper
Enumeration for the comparison operations.
Definition: temporal.h:174
@ GT
Definition: temporal.h:179
@ LT
Definition: temporal.h:177
@ NE
Definition: temporal.h:176
@ GE
Definition: temporal.h:180
@ LE
Definition: temporal.h:178
@ EQ
Definition: temporal.h:175
SetOper
Enumeration for the set operations of span and temporal types.
Definition: temporal.h:166
@ UNION
Definition: temporal.h:167
@ INTER
Definition: temporal.h:168
@ MINUS
Definition: temporal.h:169
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_interp(MeosType temptype, interpType interp)
Ensure that an interpolation is valid.
Definition: temporal.c:175
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
tempSubtype
Enumeration that defines the temporal subtypes used in MEOS.
Definition: meos.h:160
interpType
Enumeration that defines the interpolation types used in MEOS.
Definition: meos.h:171
External API of the Mobility Engine Open Source (MEOS) library.
Datum(* datum_func2)(Datum, Datum)
Definition: meos_internal.h:751
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
int32 pg_strtoint32(const char *s)
Definition: postgres_ext_defs.in.h:27
Structure to represent spatiotemporal boxes.
Definition: meos.h:144
Structure to represent sets of values.
Definition: meos.h:90
Structure to represent span sets.
Definition: meos.h:118
Structure to represent spans (a.k.a.
Definition: meos.h:104
Structure to represent temporal boxes.
Definition: meos.h:134
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:183
TBox b
Temporal box.
Definition: temporal.h:280
Span p
Span.
Definition: temporal.h:279
STBox g
Spatiotemporal box.
Definition: temporal.h:281
Structure to represent all types of bounding boxes.
Definition: temporal.h:278