def make_keywordless_layer(): """Helper function that returns a single predefined keywordless layer.""" path = 'keywordless_layer.tif' base_path = test_data_path('hazard') full_path = os.path.abspath(os.path.join(base_path, path)) title = 'Keywordless Layer' layer = QgsRasterLayer(full_path, title) if qgis_version() >= 10800: # 1.8 or newer # noinspection PyArgumentList QgsMapLayerRegistry.instance().addMapLayers([layer]) else: # noinspection PyArgumentList QgsMapLayerRegistry.instance().addMapLayers([layer]) return layer
def make_keywordless_layer(): """Helper function that returns a single predefined keywordless layer""" myFile = 'keywordless_layer.tif' myBasePath = test_data_path('hazard') myPath = os.path.abspath(os.path.join(myBasePath, myFile)) myTitle = 'Keywordless Layer' myLayer = QgsRasterLayer(myPath, myTitle) if qgis_version() >= 10800: # 1.8 or newer # noinspection PyArgumentList QgsMapLayerRegistry.instance().addMapLayers([myLayer]) else: # noinspection PyArgumentList QgsMapLayerRegistry.instance().addMapLayer(myLayer) return myLayer
def make_keywordless_layer(): """Helper function that returns a single predefined keywordless layer.""" path = 'keywordless_layer.tif' base_path = test_data_path('hazard') full_path = os.path.abspath(os.path.join(base_path, path)) title = 'Keywordless Layer' layer = QgsRasterLayer(full_path, title) if qgis_version() >= 10800: # 1.8 or newer # noinspection PyArgumentList QgsMapLayerRegistry.instance().addMapLayers([layer]) else: # noinspection PyArgumentList QgsMapLayerRegistry.instance().addMapLayer(layer) return layer
def test_issue230(self): """Verify that we give informative errors when style is not correct .. seealso:: https://github.com/AIFDR/inasafe/issues/230 """ myPath = test_data_path('impact') myVectorLayer, myType = load_layer('polygons_for_styling.shp', myPath) del myType myStyle = {'legend_title': u'Population Count', 'target_field': 'population', 'style_classes': [{'transparency': 0, 'min': [0], # <-- intentionally broken list not number! 'max': 139904.08186340332, 'colour': '#FFFFFF', 'size': 1, 'label': u'Nil'}, {'transparency': 0, 'min': 139904.08186340332, 'max': 279808.16372680664, 'colour': '#38A800', 'size': 1, 'label': u'Low'}, {'transparency': 0, 'min': 279808.16372680664, 'max': 419712.24559020996, 'colour': '#79C900', 'size': 1, 'label': u'Low'}, {'transparency': 0, 'min': 419712.24559020996, 'max': 559616.32745361328, 'colour': '#CEED00', 'size': 1, 'label': u'Low'}, {'transparency': 0, 'min': 559616.32745361328, 'max': 699520.4093170166, 'colour': '#FFCC00', 'size': 1, 'label': u'Medium'}, {'transparency': 0, 'min': 699520.4093170166, 'max': 839424.49118041992, 'colour': '#FF6600', 'size': 1, 'label': u'Medium'}, {'transparency': 0, 'min': 839424.49118041992, 'max': 979328.57304382324, 'colour': '#FF0000', 'size': 1, 'label': u'Medium'}, {'transparency': 0, 'min': 979328.57304382324, 'max': 1119232.6549072266, 'colour': '#7A0000', 'size': 1, 'label': u'High'}]} try: set_vector_graduated_style(myVectorLayer, myStyle) except StyleError: # Exactly what should have happened return except Exception, e: print str(e)