MobilityDB  1.0
Macros | Functions
stbox.c File Reference

Functions for spatiotemporal bounding boxes. More...

#include "point/stbox.h"
#include <assert.h>
#include <utils/builtins.h>
#include "general/period.h"
#include "general/timestampset.h"
#include "general/periodset.h"
#include "general/temporal_util.h"
#include "general/tnumber_mathfuncs.h"
#include "point/tpoint.h"
#include "point/tpoint_parser.h"
#include "point/tpoint_spatialfuncs.h"
Include dependency graph for stbox.c:

Macros

#define MAXSTBOXLEN   256
 

Functions

STBOXstbox_make (bool hasx, bool hasz, bool hast, bool geodetic, int32 srid, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, TimestampTz tmin, TimestampTz tmax)
 Constructs a newly allocated spatiotemporal box. More...
 
void stbox_set (STBOX *box, bool hasx, bool hasz, bool hast, bool geodetic, int32 srid, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, TimestampTz tmin, TimestampTz tmax)
 Set the spatiotemporal box from the argument values. More...
 
STBOXstbox_copy (const STBOX *box)
 Returns a copy of the spatiotemporal box. More...
 
void stbox_expand (STBOX *box1, const STBOX *box2)
 Expand the first spatiotemporal box with the second one. More...
 
void stbox_shift_tscale (STBOX *box, const Interval *start, const Interval *duration)
 Shift and/or scale the time span of the spatiotemporal box by the interval. More...
 
GBOX * gbox_make (bool hasz, bool hasm, bool geodetic, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
 Constructs a newly allocated GBOX. More...
 
void ensure_has_X_stbox (const STBOX *box)
 Ensure that the temporal value has XY dimension. More...
 
void ensure_has_T_stbox (const STBOX *box)
 Ensure that the temporal value has T dimension. More...
 
PGDLLEXPORT Datum stbox_in (PG_FUNCTION_ARGS)
 Input function for spatiotemporal boxes. More...
 
static char * stbox_to_string (const STBOX *box)
 Returns the string representation of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_out (PG_FUNCTION_ARGS)
 Output function for spatiotemporal boxes. More...
 
static Datum stbox_constructor1 (FunctionCallInfo fcinfo, bool hasx, bool hasz, bool hast, bool geodetic)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum stbox_constructor_t (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum stbox_constructor (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum stbox_constructor_z (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum stbox_constructor_zt (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum geodstbox_constructor_t (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum geodstbox_constructor (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum geodstbox_constructor_z (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
PGDLLEXPORT Datum geodstbox_constructor_zt (PG_FUNCTION_ARGS)
 Construct a spatiotemporal box from the arguments. More...
 
GBOX * stbox_to_gbox (const STBOX *box)
 Cast the spatiotemporal box as a GBOX value for PostGIS. More...
 
PGDLLEXPORT Datum stbox_to_period (PG_FUNCTION_ARGS)
 Cast the spatiotemporal box as a period. More...
 
PGDLLEXPORT Datum stbox_to_box2d (PG_FUNCTION_ARGS)
 Cast the spatiotemporal box as a GBOX value for PostGIS. More...
 
BOX3D * stbox_to_box3d_internal (const STBOX *box)
 
PGDLLEXPORT Datum stbox_to_box3d (PG_FUNCTION_ARGS)
 Cast the spatiotemporal box as a BOX3D value for PostGIS. More...
 
PGDLLEXPORT Datum box2d_to_stbox (PG_FUNCTION_ARGS)
 Transform a box2d to a spatiotemporal box. More...
 
PGDLLEXPORT Datum box3d_to_stbox (PG_FUNCTION_ARGS)
 Transform a box3d to a spatiotemporal box. More...
 
bool geo_to_stbox_internal (STBOX *box, const GSERIALIZED *gs)
 Transform a geometry/geography to a spatiotemporal box (internal function) More...
 
PGDLLEXPORT Datum geo_to_stbox (PG_FUNCTION_ARGS)
 Transform a geometry/geography to a spatiotemporal box. More...
 
void timestamp_to_stbox_internal (STBOX *box, TimestampTz t)
 Transform a timestampt to a spatiotemporal box (internal function) More...
 
PGDLLEXPORT Datum timestamp_to_stbox (PG_FUNCTION_ARGS)
 Transform a timestampt to a spatiotemporal box. More...
 
void timestampset_to_stbox_internal (STBOX *box, const TimestampSet *ts)
 Transform a timestamp set to a spatiotemporal box (internal function) More...
 
PGDLLEXPORT Datum timestampset_to_stbox (PG_FUNCTION_ARGS)
 Transform a timestamp set to a spatiotemporal box. More...
 
void period_to_stbox_internal (STBOX *box, const Period *p)
 Transform a period to a spatiotemporal box (internal function) More...
 
PGDLLEXPORT Datum period_to_stbox (PG_FUNCTION_ARGS)
 Transform a period to a spatiotemporal box. More...
 
void periodset_to_stbox_internal (STBOX *box, const PeriodSet *ps)
 Transform a period set to a spatiotemporal box (internal function) More...
 
PGDLLEXPORT Datum periodset_to_stbox (PG_FUNCTION_ARGS)
 Transform a period set to a spatiotemporal box. More...
 
PGDLLEXPORT Datum geo_timestamp_to_stbox (PG_FUNCTION_ARGS)
 Transform a geometry/geography and a timestamp to a spatiotemporal box. More...
 
PGDLLEXPORT Datum geo_period_to_stbox (PG_FUNCTION_ARGS)
 Transform a geometry/geography and a period to a spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_hasx (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal box has X dimension. More...
 
PGDLLEXPORT Datum stbox_hasz (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal box has Z dimension. More...
 
PGDLLEXPORT Datum stbox_hast (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal box has T dimension. More...
 
PGDLLEXPORT Datum stbox_isgeodetic (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal box is geodetic. More...
 
PGDLLEXPORT Datum stbox_xmin (PG_FUNCTION_ARGS)
 Returns the minimum X value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_xmax (PG_FUNCTION_ARGS)
 Returns the maximum X value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_ymin (PG_FUNCTION_ARGS)
 Returns the minimum Y value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_ymax (PG_FUNCTION_ARGS)
 Returns the maximum Y value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_zmin (PG_FUNCTION_ARGS)
 Returns the minimum Z value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_zmax (PG_FUNCTION_ARGS)
 Returns the maximum Z value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_tmin (PG_FUNCTION_ARGS)
 Returns the minimum timestamp value of the spatiotemporal box. More...
 
PGDLLEXPORT Datum stbox_tmax (PG_FUNCTION_ARGS)
 Returns the maximum timestamp value of the spatiotemporal box. More...
 
STBOXstbox_expand_spatial_internal (STBOX *box, double d)
 Expand the spatial dimension of the spatiotemporal box with the double value (internal function) More...
 
PGDLLEXPORT Datum stbox_expand_spatial (PG_FUNCTION_ARGS)
 Expand the spatial dimension of the spatiotemporal box with the double value. More...
 
STBOXstbox_expand_temporal_internal (STBOX *box, Datum interval)
 Expand the temporal dimension of the spatiotemporal box with the interval value (internal function) More...
 
PGDLLEXPORT Datum stbox_expand_temporal (PG_FUNCTION_ARGS)
 Expand the temporal dimension of the spatiotemporal box with the interval value. More...
 
PGDLLEXPORT Datum stbox_set_precision (PG_FUNCTION_ARGS)
 Sets the precision of the coordinates of the spatiotemporal box. More...
 
static void stbox_stbox_flags (const STBOX *box1, const STBOX *box2, bool *hasx, bool *hasz, bool *hast, bool *geodetic)
 Set the ouput variables with the values of the flags of the boxes. More...
 
static void topo_stbox_stbox_init (const STBOX *box1, const STBOX *box2, bool *hasx, bool *hasz, bool *hast, bool *geodetic)
 Verify the conditions and set the ouput variables with the values of the flags of the boxes. More...
 
bool contains_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box contains the second one (internal function) More...
 
PGDLLEXPORT Datum contains_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box contains the second one. More...
 
bool contained_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is contained by the second one (internal function) More...
 
PGDLLEXPORT Datum contained_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is contained by the second one. More...
 
bool overlaps_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the spatiotemporal boxes overlap (internal function) More...
 
PGDLLEXPORT Datum overlaps_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal boxes overlap. More...
 
bool same_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the spatiotemporal boxes are equal on the common dimensions (internal function) More...
 
PGDLLEXPORT Datum same_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal boxes are equal on the common dimensions. More...
 
bool adjacent_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the spatiotemporal boxes are adjacent (internal function) More...
 
PGDLLEXPORT Datum adjacent_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the spatiotemporal boxes are adjacent. More...
 
static void pos_stbox_stbox_test (const STBOX *box1, const STBOX *box2)
 Verify the conditions for a position operator. More...
 
bool left_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly to the left of the second one (internal function) More...
 
PGDLLEXPORT Datum left_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly to the left of the second one. More...
 
bool overleft_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box does not extend to the right of the second one (internal function) More...
 
PGDLLEXPORT Datum overleft_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box does not extend to the right of the second one. More...
 
bool right_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly to the right of the second one (internal function) More...
 
PGDLLEXPORT Datum right_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly to the right of the second one. More...
 
bool overright_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatio temporal box does not extend to the left of the second one (internal function) More...
 
PGDLLEXPORT Datum overright_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatio temporal box does not extend to the left of the second one. More...
 
bool below_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly below of the second one (internal function) More...
 
PGDLLEXPORT Datum below_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly below of the second one. More...
 
bool overbelow_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box does not extend above of the second one (internal function) More...
 
PGDLLEXPORT Datum overbelow_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box does not extend above of the second one. More...
 
bool above_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly above of the second one (internal function) More...
 
PGDLLEXPORT Datum above_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly above of the second one. More...
 
bool overabove_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box does not extend below of the second one (internal function) More...
 
PGDLLEXPORT Datum overabove_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box does not extend below of the second one. More...
 
bool front_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly in front of the second one (internal function) More...
 
PGDLLEXPORT Datum front_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly in front of the second one. More...
 
bool overfront_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box does not extend to the back of the second one (internal function) More...
 
PGDLLEXPORT Datum overfront_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box does not extend to the back of the second one. More...
 
bool back_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly back of the second one (internal function) More...
 
PGDLLEXPORT Datum back_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly back of the second one. More...
 
bool overback_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box does not extend to the front of the second one (internal function) More...
 
PGDLLEXPORT Datum overback_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box does not extend to the front of the second one. More...
 
bool before_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly before the second one (internal function) More...
 
PGDLLEXPORT Datum before_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly before the second one. More...
 
bool overbefore_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first temporal box does not extend after the second one (internal function) More...
 
PGDLLEXPORT Datum overbefore_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first temporal box does not extend after the second one. More...
 
bool after_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first spatiotemporal box is strictly after the second one (internal function) More...
 
PGDLLEXPORT Datum after_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is strictly after the second one. More...
 
bool overafter_stbox_stbox_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the first temporal box does not extend before the second one (internal function) More...
 
PGDLLEXPORT Datum overafter_stbox_stbox (PG_FUNCTION_ARGS)
 Returns true if the first temporal box does not extend before the second one. More...
 
STBOXstbox_union_internal (const STBOX *box1, const STBOX *box2, bool strict)
 Returns the union of the spatiotemporal boxes (internal function) More...
 
PGDLLEXPORT Datum stbox_union (PG_FUNCTION_ARGS)
 Returns the union of the spatiotemporal boxes. More...
 
STBOXstbox_intersection_internal (const STBOX *box1, const STBOX *box2)
 Returns the intersection of the spatiotemporal boxes (internal function) More...
 
PGDLLEXPORT Datum stbox_intersection (PG_FUNCTION_ARGS)
 Returns the intersection of the spatiotemporal boxes. More...
 
PGDLLEXPORT Datum stbox_extent_transfn (PG_FUNCTION_ARGS)
 Transition function for extent aggregation for boxes. More...
 
PGDLLEXPORT Datum stbox_extent_combinefn (PG_FUNCTION_ARGS)
 Combine function for extent aggregation for boxes. More...
 
int stbox_cmp_internal (const STBOX *box1, const STBOX *box2)
 Returns -1, 0, or 1 depending on whether the first spatiotemporal box is less than, equal, or greater than the second one (internal function) More...
 
PGDLLEXPORT Datum stbox_cmp (PG_FUNCTION_ARGS)
 Returns -1, 0, or 1 depending on whether the first spatiotemporal box is less than, equal, or greater than the second one. More...
 
PGDLLEXPORT Datum stbox_lt (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is less than the second one. More...
 
PGDLLEXPORT Datum stbox_le (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is less than or equal to the second one. More...
 
PGDLLEXPORT Datum stbox_ge (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is greater than or equal to the second one. More...
 
PGDLLEXPORT Datum stbox_gt (PG_FUNCTION_ARGS)
 Returns true if the first spatiotemporal box is greater than the second one. More...
 
bool stbox_eq_internal (const STBOX *box1, const STBOX *box2)
 Returns true if the two spatiotemporal boxes are equal (internal function) More...
 
PGDLLEXPORT Datum stbox_eq (PG_FUNCTION_ARGS)
 Returns true if the two spatiotemporal boxes are equal. More...
 
PGDLLEXPORT Datum stbox_ne (PG_FUNCTION_ARGS)
 Returns true if the two spatiotemporal boxes are different. More...
 

Detailed Description

Functions for spatiotemporal bounding boxes.