def setUp(self): """Fixture run before all tests""" register_impact_functions() self.dock.show_only_visible_layers_flag = True load_standard_layers(self.dock) self.dock.cboHazard.setCurrentIndex(1) self.dock.cboExposure.setCurrentIndex(0) self.dock.cboFunction.setCurrentIndex(0) self.dock.run_in_thread_flag = False self.dock.show_only_visible_layers_flag = False self.dock.set_layer_from_title_flag = False self.dock.zoom_to_impact_flag = False self.dock.hide_exposure_flag = False self.dock.show_intermediate_layers = False self.dock.user_extent = None self.dock.user_extent_crs = None # For these tests we will generally use explicit overlap # between hazard, exposure and view, so make that default # see also safe/test/utilities.py where this is globally # set to HazardExposure settings = QtCore.QSettings() settings.setValue( 'inasafe/analysis_extents_mode', 'HazardExposureView')
def setUp(self): """Fixture run before all tests""" register_impact_functions() self.maxDiff = None # show full diff for assert errors os.environ['LANG'] = 'en' self.DOCK.show_only_visible_layers_flag = True load_standard_layers(self.DOCK) self.DOCK.cboHazard.setCurrentIndex(0) self.DOCK.cboExposure.setCurrentIndex(0) self.DOCK.cboFunction.setCurrentIndex(0) self.DOCK.run_in_thread_flag = False self.DOCK.show_only_visible_layers_flag = False self.DOCK.set_layer_from_title_flag = False self.DOCK.zoom_to_impact_flag = False self.DOCK.hide_exposure_flag = False self.DOCK.show_intermediate_layers = False set_jakarta_extent() self._keywordIO = KeywordIO() self._defaults = get_defaults() # Set extent as Jakarta extent geo_crs = QgsCoordinateReferenceSystem() geo_crs.createFromSrid(4326) self.extent = extent_to_geo_array(CANVAS.extent(), geo_crs)
def setUp(self): """Fixture run before all tests. These tests require that you manually load the layers you need. """ register_impact_functions() self.dock.show_only_visible_layers_flag = True self.dock.cboHazard.setCurrentIndex(0) self.dock.cboExposure.setCurrentIndex(0) self.dock.cboFunction.setCurrentIndex(0) self.dock.run_in_thread_flag = False self.dock.show_only_visible_layers_flag = False self.dock.set_layer_from_title_flag = False self.dock.zoom_to_impact_flag = False self.dock.hide_exposure_flag = False self.dock.show_intermediate_layers = False self.dock.user_extent = None self.dock.user_extent_crs = None # For these tests we will generally use explicit overlap # between hazard, exposure and view, so make that default # see also safe/test/utilities.py where this is globally # set to HazardExposure settings = QtCore.QSettings() settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure') QgsMapLayerRegistry.instance().removeAllMapLayers() self.dock.cboHazard.clear() self.dock.cboExposure.clear()
def setUp(self): """Fixture run before all tests""" os.environ['LANG'] = 'en' self.DOCK.show_only_visible_layers_flag = True load_standard_layers(self.DOCK) self.DOCK.cboHazard.setCurrentIndex(0) self.DOCK.cboExposure.setCurrentIndex(0) self.DOCK.cboFunction.setCurrentIndex(0) self.DOCK.run_in_thread_flag = False self.DOCK.show_only_visible_layers_flag = False self.DOCK.set_layer_from_title_flag = False self.DOCK.zoom_to_impact_flag = False self.DOCK.hide_exposure_flag = False self.DOCK.show_intermediate_layers = False set_jakarta_extent() register_impact_functions()
def setUp(self): """Fixture run before all tests.""" os.environ['LANG'] = 'en' self.DOCK.show_only_visible_layers_flag = True load_standard_layers(self.DOCK) self.DOCK.cboHazard.setCurrentIndex(0) self.DOCK.cboExposure.setCurrentIndex(0) self.DOCK.cboFunction.setCurrentIndex(0) self.DOCK.run_in_thread_flag = False self.DOCK.show_only_visible_layers_flag = False self.DOCK.set_layer_from_title_flag = False self.DOCK.zoom_to_impact_flag = False self.DOCK.hide_exposure_flag = False self.DOCK.show_intermediate_layers = False # Create scenario dialog self.save_scenario_dialog = SaveScenarioDialog(IFACE, self.DOCK) # register impact functions register_impact_functions() self.impact_function_manager = ImpactFunctionManager()
def __init__(self, iface): """Class constructor. On instantiation, the plugin instance will be assigned a copy of the QGIS iface object which will allow this plugin to access and manipulate the running QGIS instance that spawned it. :param iface:Quantum GIS iface instance. This instance is automatically passed to the plugin by QGIS when it loads the plugin. :type iface: QGisAppInterface """ # Register all the impact functions register_impact_functions() # Save reference to the QGIS interface self.iface = iface self.dock_widget = None self.action_import_dialog = None self.action_save_scenario = None self.action_batch_runner = None self.action_shake_converter = None self.action_minimum_needs = None self.action_minimum_needs_config = None self.key_action = None self.action_options = None self.action_keywords_wizard = None self.action_function_centric_wizard = None self.action_extent_selector = None self.translator = None self.toolbar = None self.wizard = None self.actions = [] # list of all QActions we create for InaSAFE self.action_dock = None self.action_toggle_rubberbands = None self.message_bar_item = None # Flag indicating if toolbar should show only common icons or not self.full_toolbar = False # print self.tr('InaSAFE') # For enable/disable the keyword editor icon self.iface.currentLayerChanged.connect(self.layer_changed)
def setUp(self): register_impact_functions()
def setUp(self): # register impact functions register_impact_functions()
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFload_standard_layersACE, PARENT) If QGIS is already running the handle to that app will be returned. """ global QGIS_APP, PARENT, IFACE, CANVAS # pylint: disable=W0603 if iface: from qgis.core import QgsApplication QGIS_APP = QgsApplication CANVAS = iface.mapCanvas() PARENT = iface.mainWindow() IFACE = iface return QGIS_APP, CANVAS, IFACE, PARENT try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from safe.gis.qgis_interface import QgisInterface except ImportError: return None, None, None, None if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming if 'argv' in dir(sys): QGIS_APP = QgsApplication(sys.argv, gui_flag) else: QGIS_APP = QgsApplication([], gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 settings.setValue('inasafe/show_extent_confirmations', False) settings.setValue('inasafe/show_extent_warnings', False) settings.setValue('inasafe/showRubberBands', True) settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure') if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) # Note(IS): I put here since it needs QGIS apps instance first from safe.impact_functions.loader import register_impact_functions register_impact_functions() return QGIS_APP, CANVAS, IFACE, PARENT
def setUp(self): register_impact_functions() self.dock = get_dock()
print "" try: # Parse arguments, use usage.txt as syntax definition. LOGGER.debug('Parse argument') shell_arguments = docopt(usage) LOGGER.debug('Parse done') except DocoptExit as exc: print exc.message try: arguments = CommandLineArguments(shell_arguments) LOGGER.debug(shell_arguments) if arguments.show_list is True: # setup functions register_impact_functions() show_impact_function_names(get_impact_function_list(arguments)) elif arguments.version is True: print "QGIS VERSION: " + str(qgis_version()).replace('0', '.') # user is only interested in doing a download elif arguments.download is True and\ arguments.exposure is None and\ arguments.hazard is None: print "downloading ..." download_exposure(arguments) elif (arguments.hazard is not None) and\ (arguments.output_file is not None): # first do download if necessary if arguments.exposure is None and arguments.download is True: download_exposure(arguments)
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFload_standard_layersACE, PARENT) If QGIS is already running the handle to that app will be returned. """ global QGIS_APP, PARENT, IFACE, CANVAS # pylint: disable=W0603 if iface: from qgis.core import QgsApplication QGIS_APP = QgsApplication CANVAS = iface.mapCanvas() PARENT = iface.mainWindow() IFACE = iface return QGIS_APP, CANVAS, IFACE, PARENT try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from safe.gis.qgis_interface import QgisInterface except ImportError: return None, None, None, None if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName("QGIS") # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain("qgis.org") # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName("QGIS2InaSAFETesting") # noinspection PyPep8Naming if "argv" in dir(sys): QGIS_APP = QgsApplication(sys.argv, gui_flag) else: QGIS_APP = QgsApplication([], gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue("locale/overrideFlag", True) settings.setValue("locale/userLocale", "en_US") # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 settings.setValue("inasafe/show_extent_confirmations", False) settings.setValue("inasafe/show_extent_warnings", False) settings.setValue("inasafe/showRubberBands", True) settings.setValue("inasafe/analysis_extents_mode", "HazardExposure") if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) # Note(IS): I put here since it needs QGIS apps instance first from safe.impact_functions.loader import register_impact_functions register_impact_functions() return QGIS_APP, CANVAS, IFACE, PARENT