GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-2653d7b383
temporal.h
Go to the documentation of this file.
1 #ifndef GRASS_TEMPORAL_H
2 #define GRASS_TEMPORAL_H
3 
4 #include <grass/datetime.h>
5 #include <grass/gis.h>
6 #include <grass/dbmi.h>
7 
8 #define TGISDB_DEFAULT_DRIVER "sqlite"
9 /* Default path in the current location */
10 #define TGISDB_DEFAULT_SQLITE_PATH "tgis/sqlite.db"
11 
12 int tgis_set_connection(dbConnection *connection);
13 int tgis_get_connection(dbConnection *connection);
14 const char *tgis_get_default_driver_name(void);
16 char *tgis_get_driver_name(void);
17 char *tgis_get_database_name(void);
18 char *tgis_get_mapset_driver_name(const char *);
19 char *tgis_get_mapset_database_name(const char *);
21 
22 /* ALL CODE BELOW THIS COMMENT
23  * IS A PROTOTYPICAL DEFINITION OF THE
24  * FUTURE TEMPORAL GIS C-LIBRARY INTERFACE
25  * AND NOT YET IMPLEMENTED
26  */
27 
28 #define TGIS_TYPE_MAP 0
29 #define TGIS_TYPE_STDS 1
30 
31 #define TGIS_RASTER_MAP 1
32 #define TGIS_RASTER3D_MAP 2
33 #define TGIS_VECTOR_MAP 3
34 #define TGIS_STRDS 4
35 #define TGIS_STR3DS 5
36 #define TGIS_STVDS 6
37 
38 #define TGIS_ABSOLUTE_TIME 0
39 #define TGIS_RELATIVE_TIME 1
40 
41 /*! A simple structure to organize time stamped maps */
42 typedef struct _tgisMap {
43  char *name;
44  char *mapset;
45  struct TimeStamp ts;
47 
48 /*!
49  \brief List of tgisMap struct's
50 
51  This structure is used to store lists of time stamped maps
52  using the tgisMap structure internally.
53  */
54 typedef struct _tgisMapList {
55  /*!
56  \brief Array of tgisMap struct's
57  */
59  /*!
60  \brief Number of tgisMap struct's in the list
61  */
62  int n_values;
63  /*!
64  \brief Allocated space for tgisMap struct's
65  */
68 
69 /* map_list.c */
73 
74 /*! Insert a new map to the map list */
75 void tgis_map_list_insert(tgisMapList *list, char *name, char *mapset,
76  struct TimeStamp *ts);
77 /*! Add a new map to the map list */
79 
80 /*!Spatio temporal extent as double values
81 
82  The spatio temporal extent contains only double values.
83 
84  The unit of start and end time is seconds in case the time is absolute.
85  Reference is Jan. 1. 1900 00:00:00 +00:00 UTC
86 
87  If no end time is present, because its a time instance,
88  then has_end must be 0.
89 
90  */
91 typedef struct _tgisExtent {
92  double start; /*Start time as double value */
93  double end; /*End time as double value */
94  char has_end; /*Set to 1 if the end time exists, 0 otherwise */
95  double north;
96  double south;
97  double east;
98  double west;
99  double top;
100  double bottom;
102 
103 /* Forward declaration */
104 struct _tgisDataset;
105 
106 /*!
107  \brief List of tgisDatasets struct's
108 
109  This structure is used to store lists of dataset (space time datasets or time
110  stamped maps) using the tgisDataset structure internally.
111  */
112 typedef struct _tgisDatasetList {
113  /*!
114  \brief Array of tgisDataset structs
115  */
117  /*!
118  \brief Number of tgisDataset structs in the list
119  */
120  int n_values;
121  /*!
122  \brief Allocated space for tgisDataset structs
123  */
126 
127 /*! A dataset structure to organize time stamped maps and space time datasets
128  and their spatio-temporal topological relations.
129  */
130 typedef struct _tgisDataset {
131  char *name; /* The name of this dataset */
132  char *mapset; /* The mapset of this dataset */
133  char *creator; /* The creator of this dataset */
134  DateTime creation_time; /* The creation time of this dataset */
135  char temporal_type; /* The temporal type of this dataset:
136  TGIS_ABSOLUTE_TIME, TGIS_RELATIVE_TIME */
137  struct TimeStamp ts; /* The timestamp of this dataset */
138  tgisExtent extent; /* This is the spatio-temporal extent represented as
139  double values */
140 
141  void *metadata; /* A pointer to the dataset specific metadata (not used yet)
142  */
143 
144  char dataset_type; /* The type of the dataset: TGIS_RASTER_MAP,
145  TGIS_RASTER3D_MAP, TGIS_VECTOR_MAP, TGIS_STRDS,
146  TGIS_STR3DS, TGIS_STVDS */
147  char is_stds; /* Represent this struct a space time dataset? 1 True, 0 False
148  */
149 
152 
153  /* Temporal topology relations */
165 
166  /* Spatial topology relations */
174 
176 
177 /* dataset_list.c */
181 
182 /*! Insert a new dataset to the dataset list */
185  char temporal_type, struct TimeStamp *ts,
186  tgisExtent *extent, void *metadata,
187  char dataset_type, char is_stds);
188 /*! Add a new dataset to the dataset list */
190 
191 /* topology.c */
192 /*! Build the temporal or spatio-temporal topology of the provided dataset list
193  */
194 int tgis_build_topology(tgisDatasetList *A, char spatial);
195 
196 /*! Build the temporal or spatio-temporal topology between the two dataset list
197  */
199 
200 /*
201  * INTERFACE TO THE TEMPORAL PYTHON FRAMEWORK
202  */
203 
204 /* create.c */
205 /*! Create the new space time dataset */
206 int tgis_create_stds(char *stds_name, char stds_type, char temporal_type,
207  char *title, char *description, char *semantic_type,
208  char *aggregation_type);
209 
210 /*! Modify the metadata of an existing space time dataset */
211 int tgis_modify_stds(char *stds_name, char stds_type, char *title,
212  char *description, char *semantic_type,
213  char *aggregation_type);
214 
215 /* remove.c */
216 /*! Remove a space time dataset and optionally all of its maps */
217 int tgis_remove_stds(char *stds_name, char stds_type, char remove_maps);
218 
219 /* update.c */
220 int tgis_update_stds(char *stds_name, char stds_type);
221 
222 /* register.c */
223 /*! Register a map in the temporal database and optionally in a space time
224  * dataset */
225 int tgis_register_map(tgisMap *map, char map_type, char *stds_name);
226 
227 /*! Unregister a map from the temporal database or optionally from a space time
228  * dataset */
229 int tgis_unregister_map(tgisMap *map, char map_type, char *stds_name);
230 
231 /*! Register maps in the temporal database and optionally in a space time
232  * dataset */
233 int tgis_register_maps(tgisMapList *list, char map_type, char *stds_name);
234 
235 /*! Unregister maps from the temporal database or optionally from a space time
236  * dataset */
237 int tgis_unregister_maps(tgisMapList *list, char map_type, char *stds_name);
238 
239 /*! Get all maps that are registered in a space time dataset */
241  char stds_type, char *order,
242  char *where);
243 
244 /* stds.c */
245 /*! Get all stds from the temporal database */
247  char stds_type, char temporal_type,
248  char *order, char *where);
249 
250 /*! Get the information about a specific space time dataset from the temporal
251  * database */
252 tgisDataset *tgis_get_stds_info(char *stds_name, char *mapset, char stds_type);
253 
254 #endif
int order(int i_x, int i_y, int yNum)
Definition: InterpSpline.c:53
const char * name
Definition: named_colr.c:6
Definition: gis.h:613
List of tgisDatasets struct's.
Definition: temporal.h:112
int alloc_values
Allocated space for tgisDataset structs.
Definition: temporal.h:124
struct _tgisDataset ** values
Array of tgisDataset structs.
Definition: temporal.h:116
int n_values
Number of tgisDataset structs in the list.
Definition: temporal.h:120
tgisDatasetList follows
Definition: temporal.h:155
tgisDatasetList in
Definition: temporal.h:171
DateTime creation_time
Definition: temporal.h:134
tgisDatasetList during
Definition: temporal.h:159
tgisDatasetList equivalent
Definition: temporal.h:167
char * name
Definition: temporal.h:131
void * metadata
Definition: temporal.h:141
struct TimeStamp ts
Definition: temporal.h:137
tgisDatasetList equal
Definition: temporal.h:154
tgisDatasetList cover
Definition: temporal.h:168
tgisDatasetList started
Definition: temporal.h:162
tgisDatasetList overlapped
Definition: temporal.h:158
char temporal_type
Definition: temporal.h:135
tgisDatasetList finished
Definition: temporal.h:164
struct _tgisDataset * next
Definition: temporal.h:150
tgisDatasetList finishes
Definition: temporal.h:163
tgisDatasetList starts
Definition: temporal.h:161
struct _tgisDataset * prev
Definition: temporal.h:151
tgisDatasetList precedes
Definition: temporal.h:156
tgisDatasetList contains
Definition: temporal.h:160
char * creator
Definition: temporal.h:133
tgisExtent extent
Definition: temporal.h:138
char is_stds
Definition: temporal.h:147
tgisDatasetList overlap
Definition: temporal.h:170
tgisDatasetList covered
Definition: temporal.h:169
tgisDatasetList overlaps
Definition: temporal.h:157
tgisDatasetList contain
Definition: temporal.h:172
tgisDatasetList meet
Definition: temporal.h:173
char * mapset
Definition: temporal.h:132
char dataset_type
Definition: temporal.h:144
double west
Definition: temporal.h:98
double start
Definition: temporal.h:92
double north
Definition: temporal.h:95
double east
Definition: temporal.h:97
double top
Definition: temporal.h:99
char has_end
Definition: temporal.h:94
double bottom
Definition: temporal.h:100
double end
Definition: temporal.h:93
double south
Definition: temporal.h:96
List of tgisMap struct's.
Definition: temporal.h:54
tgisMap ** values
Array of tgisMap struct's.
Definition: temporal.h:58
int n_values
Number of tgisMap struct's in the list.
Definition: temporal.h:62
int alloc_values
Allocated space for tgisMap struct's.
Definition: temporal.h:66
char * mapset
Definition: temporal.h:44
char * name
Definition: temporal.h:43
struct TimeStamp ts
Definition: temporal.h:45
Definition: ogsf.h:233
Definition: manage.h:4
tgisDatasetList * tgis_new_dataset_list(void)
struct _tgisMapList tgisMapList
List of tgisMap struct's.
struct _tgisExtent tgisExtent
struct _tgisMap tgisMap
int tgis_update_stds(char *stds_name, char stds_type)
void tgis_init_dataset_list(tgisDatasetList *list)
const char * tgis_get_default_driver_name(void)
Get default TGIS driver name.
int tgis_unregister_maps(tgisMapList *list, char map_type, char *stds_name)
char * tgis_get_mapset_driver_name(const char *)
Get TGIS driver name from a specific mapset.
char * tgis_get_driver_name(void)
Get TGIS driver name.
char * tgis_get_mapset_database_name(const char *)
Get TGIS database name.
char * tgis_get_database_name(void)
Get TGIS database name.
int tgis_register_maps(tgisMapList *list, char map_type, char *stds_name)
int tgis_create_stds(char *stds_name, char stds_type, char temporal_type, char *title, char *description, char *semantic_type, char *aggregation_type)
int tgis_set_connection(dbConnection *connection)
Set Temporal GIS DB connection settings.
int tgis_set_default_connection(void)
Sets up TGIS database connection settings using GRASS default.
struct _tgisDatasetList tgisDatasetList
List of tgisDatasets struct's.
int tgis_modify_stds(char *stds_name, char stds_type, char *title, char *description, char *semantic_type, char *aggregation_type)
tgisDatasetList * tgis_get_registered_stds(char *stds_name, char *mapset, char stds_type, char temporal_type, char *order, char *where)
struct _tgisDataset tgisDataset
char * tgis_get_default_database_name(void)
Get default TGIS database name for the sqlite connection.
tgisMapList * tgis_new_map_list(void)
Return a new integer list.
Definition: map_list.c:54
void tgis_free_map_list(tgisMapList *list)
Free allocated memory of an integer list.
Definition: map_list.c:28
int tgis_register_map(tgisMap *map, char map_type, char *stds_name)
void tgis_init_map_list(tgisMapList *list)
Init a tgisMapList and free allocated memory.
Definition: map_list.c:69
int tgis_remove_stds(char *stds_name, char stds_type, char remove_maps)
int tgis_build_topology2(tgisDatasetList *A, tgisDatasetList *B, char spatial)
void tgis_map_list_add(tgisMapList *list, tgisMap *map)
Add a map to tgisMapList.
Definition: map_list.c:103
int tgis_build_topology(tgisDatasetList *A, char spatial)
void tgis_map_list_insert(tgisMapList *list, char *name, char *mapset, struct TimeStamp *ts)
Insert map information into tgisMapList.
Definition: map_list.c:133
void tgis_dataset_list_insert(tgisDatasetList *list, char *name, char *mapset, char *creator, DateTime *creation_time, char temporal_type, struct TimeStamp *ts, tgisExtent *extent, void *metadata, char dataset_type, char is_stds)
int tgis_get_connection(dbConnection *connection)
Get Temporal GIS DB connection settings.
int tgis_unregister_map(tgisMap *map, char map_type, char *stds_name)
void tgis_dataset_list_add(tgisDataset *dataset)
tgisDatasetList * tgis_get_registered_maps(char *stds_name, char *mapset, char stds_type, char *order, char *where)
void tgis_free_dataset_list(tgisDatasetList *list)
tgisDataset * tgis_get_stds_info(char *stds_name, char *mapset, char stds_type)