temporal.h 7.9 KB

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