MobilityDB 1.3
Loading...
Searching...
No Matches
temporal_tile.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2025, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2025, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 *
28 *****************************************************************************/
29
30#ifndef __TEMPORAL_TILE_H__
31#define __TEMPORAL_TILE_H__
32
33/* MEOS */
34#include <meos.h>
35#include "temporal/meos_catalog.h"
36
37#define MAXDIMS 4
38
39/*****************************************************************************/
40
45typedef struct SpanBinState
46{
47 bool done;
49 int i;
53 const void *to_split;
56 int nbins;
58
62typedef struct TboxGridState
63{
64 bool done;
65 int i;
69 const Temporal *temp;
72 int ntiles;
73 int max_coords[2];
74 int coords[2];
76
77/*****************************************************************************/
78
79extern int span_num_bins(const Span *s, Datum size, Datum origin,
80 Datum *start_bin, Datum *end_bin);
81
82extern Span *span_bins(const Span *s, Datum size, Datum origin, int *count);
83extern Span *spanset_bins(const SpanSet *ss, Datum size, Datum origin, int *count);
84
86 const Interval *duration, TimestampTz torigin, int *nbins);
87
89 const TBox *box, Datum vsize, const Interval *duration, Datum xorigin,
90 TimestampTz torigin);
92extern void tbox_tile_state_set(Datum value, TimestampTz t, Datum vsize,
93 int64 tunits, meosType basetype, meosType spantype, TBox *box);
94
95/*****************************************************************************/
96
97extern int64 interval_units(const Interval *interval);
98extern TimestampTz timestamptz_bin_start(TimestampTz timestamp, int64 tunits,
99 TimestampTz torigin);
100extern Datum datum_bin(Datum value, Datum size, Datum offset,
101 meosType basetype);
102
104 Datum vsize, const Interval *duration, Datum vorigin, TimestampTz torigin,
105 int *ntiles);
106extern bool tbox_tile_state_get(TboxGridState *state, TBox *box);
107
108/*****************************************************************************/
109#endif /* __TEMPORAL_TILE_H__ */
110
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:55
External API of the Mobility Engine Open Source (MEOS) library.
int64 TimestampTz
Definition: postgres_ext_defs.in.h:22
uintptr_t Datum
Definition: postgres_ext_defs.in.h:7
unsigned char uint8
Definition: postgres_ext_defs.in.h:14
long int int64
Definition: postgres_ext_defs.in.h:12
Definition: postgres_ext_defs.in.h:27
Datum size
Size of the values.
Definition: temporal_tile.h:50
int nbins
Total number of bins.
Definition: temporal_tile.h:56
const void * to_split
NULL when generating bins, used for splitting span sets or temporal values.
Definition: temporal_tile.h:53
Datum value
Current value.
Definition: temporal_tile.h:55
bool done
True when the state is consumed.
Definition: temporal_tile.h:47
Datum origin
Origin of the values.
Definition: temporal_tile.h:51
Span span
Bounding span.
Definition: temporal_tile.h:52
uint8 basetype
span basetype
Definition: temporal_tile.h:48
int i
Current tile number.
Definition: temporal_tile.h:49
Struct for storing the state that persists across multiple calls generating the bin list.
Definition: temporal_tile.h:46
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
int coords[2]
Coordinates of the current tile.
Definition: temporal_tile.h:74
int max_coords[2]
Maximum coordinates of the tiles.
Definition: temporal_tile.h:73
const Temporal * temp
Optional temporal number to be split.
Definition: temporal_tile.h:69
bool done
True when the state is consumed.
Definition: temporal_tile.h:64
int64 tunits
Time size.
Definition: temporal_tile.h:67
TimestampTz t
Current time.
Definition: temporal_tile.h:71
int i
Current tile number.
Definition: temporal_tile.h:65
Datum value
Current value.
Definition: temporal_tile.h:70
int ntiles
Total number of tiles.
Definition: temporal_tile.h:72
Datum vsize
Value size.
Definition: temporal_tile.h:66
TBox box
Bounding box.
Definition: temporal_tile.h:68
Struct for storing the state for tiling operations.
Definition: temporal_tile.h:63
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:173
Definition: pgtz.h:42
bool tbox_tile_state_get(TboxGridState *state, TBox *box)
Get the current tile of the multidimensional grid.
Definition: temporal_tile.c:725
Span * spanset_bins(const SpanSet *ss, Datum size, Datum origin, int *count)
Return the bins from a span set.
Definition: temporal_tile.c:478
void tbox_tile_state_next(TboxGridState *state)
Increment the current state to the next tile of the multidimensional grid.
Definition: temporal_tile.c:741
SpanBinState * temporal_time_bin_init(const Temporal *temp, const Interval *duration, TimestampTz torigin, int *nbins)
Set the state with a temporal value and a time bin for splitting or obtaining a set of spans.
Definition: temporal_tile.c:610
Datum datum_bin(Datum value, Datum size, Datum offset, meosType basetype)
Return the initial value of the bin that contains a number value.
Definition: temporal_tile.c:339
Span * span_bins(const Span *s, Datum size, Datum origin, int *count)
Return the bins from a span.
Definition: temporal_tile.c:429
TimestampTz timestamptz_bin_start(TimestampTz timestamp, int64 tunits, TimestampTz torigin)
Return the initial timestamp of the bin that contains a timestamptz (internal function)
Definition: temporal_tile.c:260
int span_num_bins(const Span *s, Datum size, Datum origin, Datum *start_bin, Datum *end_bin)
Get the time bins of a temporal value.
Definition: temporal_tile.c:383
TboxGridState * tbox_tile_state_make(const Temporal *temp, const TBox *box, Datum vsize, const Interval *duration, Datum xorigin, TimestampTz torigin)
Create the initial state for tiling operations.
Definition: temporal_tile.c:626
int64 interval_units(const Interval *interval)
Return the interval in the same representation as Postgres timestamps.
Definition: temporal_tile.c:210
TboxGridState * tnumber_value_time_tile_init(const Temporal *temp, Datum vsize, const Interval *duration, Datum vorigin, TimestampTz torigin, int *ntiles)
Set the state with a temporal number and a value and possibly time grid for splitting or obtaining a ...
Definition: temporal_tile.c:862
void tbox_tile_state_set(Datum value, TimestampTz t, Datum vsize, int64 tunits, meosType basetype, meosType spantype, TBox *box)
Generate a tile from the a multidimensional grid.
Definition: temporal_tile.c:693