@@ -543,14 +543,15 @@ def get_available_temporal_mapsets():
543543###############################################################################
544544
545545
546- def init (raise_fatal_error : bool = False , skip_db_version_check : bool = False ):
547- """This function set the correct database backend from GRASS environmental
548- variables and creates the grass temporal database structure for raster,
549- vector and raster3d maps as well as for the space-time datasets strds,
550- str3ds and stvds in case it does not exist.
546+ def init (
547+ raise_fatal_error : bool = False ,
548+ skip_db_version_check : bool = False ,
549+ skip_db_init : bool = False ,
550+ ):
551+ """Initialize the temporal GIS system.
551552
552- Several global variables are initiated and the messenger and C-library
553- interface subprocesses are spawned .
553+ This function sets several global variables and spawns the messenger and
554+ C-library interface subprocesses.
554555
555556 Re-run this function in case the following GRASS variables change while
556557 the process runs:
@@ -572,7 +573,14 @@ def init(raise_fatal_error: bool = False, skip_db_version_check: bool = False):
572573 - GRASS_TGIS_PROFILE (True, False, 1, 0)
573574 - GRASS_TGIS_RAISE_ON_ERROR (True, False, 1, 0)
574575
575- .. warning::
576+ If not otherwise requested (skip_db_init), this function will check for
577+ the existence of a temporal database and its version in the current mapset.
578+ If the database does not exist, it will be created, using the database
579+ backend from GRASS environment variables, with the GRASS temporal database
580+ structure for raster, vector and raster3d maps as well as for the space-time
581+ dataset types strds, str3ds and stvds.
582+
583+ .. warning::
576584
577585 This functions must be called before any spatio-temporal processing
578586 can be started
@@ -588,6 +596,14 @@ def init(raise_fatal_error: bool = False, skip_db_version_check: bool = False):
588596 database version check.
589597 Recommended to be used only for
590598 upgrade_temporal_database().
599+ :param skip_db_init: Set this True to allow init() to complete
600+ without initializing, (version) checking or creating
601+ a temporal database in the current mapset.
602+ Use this when the calling process only needs the
603+ global TGIS state (backend, mapset, interfaces)
604+ but does not require a temporal database in the
605+ current mapset for operations (like listing
606+ datasets, getting metainformation, ...).
591607 """
592608 # We need to set the correct database backend and several global variables
593609 # from the GRASS mapset specific environment variables of g.gisenv and t.connect
@@ -600,9 +616,6 @@ def init(raise_fatal_error: bool = False, skip_db_version_check: bool = False):
600616
601617 raise_on_error = raise_fatal_error
602618
603- # We must run t.connect at first to create the temporal database and to
604- # get the environmental variables
605- gs .run_command ("t.connect" , flags = "c" )
606619 grassenv = gs .gisenv ()
607620
608621 new_mapset = grassenv ["MAPSET" ]
@@ -647,14 +660,11 @@ def init(raise_fatal_error: bool = False, skip_db_version_check: bool = False):
647660 # Start the C-library interface server
648661 _init_tgis_c_library_interface ()
649662 msgr = get_tgis_message_interface ()
650- msgr .debug (1 , "Initiate the temporal database" )
651663
652664 msgr .debug (1 , ("Raise on error id: %s" % str (raise_on_error )))
653665
654666 ciface = get_tgis_c_library_interface ()
655667 current_mapset = decode (gs .gisenv ().get ("MAPSET" ))
656- driver_string = ciface .get_driver_name (current_mapset )
657- database_string = ciface .get_database_name (current_mapset )
658668
659669 # Set the mapset check and the timestamp write
660670 if "TGIS_DISABLE_MAPSET_CHECK" in grassenv :
@@ -673,6 +683,17 @@ def init(raise_fatal_error: bool = False, skip_db_version_check: bool = False):
673683 enable_timestamp_write = False
674684 msgr .warning ("TGIS_DISABLE_TIMESTAMP_WRITE is True" )
675685
686+ if skip_db_init :
687+ return
688+
689+ msgr .debug (1 , "Initiate the temporal database" )
690+ # We must run t.connect at first to create the temporal database and to
691+ # get the environmental variables
692+ gs .run_command ("t.connect" , flags = "c" )
693+
694+ driver_string = ciface .get_driver_name (current_mapset )
695+ database_string = ciface .get_database_name (current_mapset )
696+
676697 if driver_string is not None and driver_string != "" :
677698 driver_string = decode (driver_string )
678699 if driver_string == "sqlite" :
0 commit comments