def test_switch_env(self): libgis.G_setenv_nogisrc("TEST", "SWITCH") libgis.G_setenv_nogisrc2("TEST", "SWITCH2", libgis.G_VAR_MAPSET) # Create alternative env libgis.G_create_alt_env() libgis.G_setenv_nogisrc("TEST", "TARGET") libgis.G_setenv_nogisrc2("TEST", "TARGET2", libgis.G_VAR_MAPSET) value = libgis.G_getenv("TEST") self.assertEqual(value, "TARGET") value = libgis.G_getenv2("TEST", libgis.G_VAR_MAPSET) self.assertEqual(value, "TARGET2") # Switch back to orig env libgis.G_switch_env() value = libgis.G_getenv("TEST") self.assertEqual(value, "SWITCH") value = libgis.G_getenv2("TEST", libgis.G_VAR_MAPSET) self.assertEqual(value, "SWITCH2")
def test_gisrc(self): # File access libgis.G_setenv("TEST", "A") value = libgis.G_getenv("TEST") self.assertEqual(value, "A") value = libgis.G_getenv2("TEST", libgis.G_VAR_GISRC) self.assertEqual(value, "A") # In memory management libgis.G_setenv_nogisrc("TEST", "B") value = libgis.G_getenv_nofatal("TEST") self.assertEqual(value, "B") value = libgis.G_getenv_nofatal2("TEST", libgis.G_VAR_GISRC) self.assertEqual(value, "B") # Force reading libgis.G__read_gisrc_env() value = libgis.G_getenv("TEST") self.assertEqual(value, "A") value = libgis.G_getenv2("TEST", libgis.G_VAR_GISRC) self.assertEqual(value, "A")
def is_current(self): """Check if the MAPSET is the working MAPSET""" return (self.name == libgis.G_getenv('MAPSET') and self.location == libgis.G_getenv('LOCATION_NAME') and self.gisdbase == libgis.G_getenv('GISDBASE'))