Vérif présence layer OpenStreetMap

This commit is contained in:
Djedouas 2021-03-02 16:24:58 +01:00
parent 85dc227d35
commit 6a59dec2c3

View File

@ -172,7 +172,7 @@ class Orientation:
icon_path = ':/plugins/caliec/icon.png' icon_path = ':/plugins/caliec/icon.png'
self.add_action( self.add_action(
icon_path, icon_path,
text=self.tr(u'Créer le projet'), text=self.tr('Créer le projet'),
callback=self.run, callback=self.run,
parent=self.iface.mainWindow()) parent=self.iface.mainWindow())
@ -184,7 +184,7 @@ class Orientation:
"""Removes the plugin menu item and icon from QGIS GUI.""" """Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions: for action in self.actions:
self.iface.removePluginMenu( self.iface.removePluginMenu(
self.tr(u'&CaLiÉc'), self.tr('CaLiÉc'),
action) action)
self.iface.removeToolBarIcon(action) self.iface.removeToolBarIcon(action)
@ -201,7 +201,6 @@ class Orientation:
tempdir = tempfile.TemporaryDirectory() tempdir = tempfile.TemporaryDirectory()
styles_url = 'https://forge.chapril.org/linux_alpes/caliec/raw/branch/master/styles/' styles_url = 'https://forge.chapril.org/linux_alpes/caliec/raw/branch/master/styles/'
lambert93 = QgsCoordinateReferenceSystem("EPSG:2154") lambert93 = QgsCoordinateReferenceSystem("EPSG:2154")
wgs = QgsCoordinateReferenceSystem("EPSG:4326")
wgspm = QgsCoordinateReferenceSystem("EPSG:3857") wgspm = QgsCoordinateReferenceSystem("EPSG:3857")
scr = wgspm scr = wgspm
project = QgsProject.instance() project = QgsProject.instance()
@ -212,6 +211,10 @@ class Orientation:
context = dataobjects.createContext() context = dataobjects.createContext()
context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck) context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
if len(project.mapLayersByName("OpenStreetMap")) == 0:
QMessageBox.warning(self.iface.mainWindow(), "Attention", "Affichez d'abord un fond Openstreetmap (menu XYZ tiles) et cadrez la zone voulue")
return
# Correspondances des noms des couches et des styles: # Correspondances des noms des couches et des styles:
# "NOM_DE_LA_COUCHE_OSM": ("nom_du_style", "nom_du_layer") # "NOM_DE_LA_COUCHE_OSM": ("nom_du_style", "nom_du_layer")
# Commenter les couches non désirées # Commenter les couches non désirées