Vérif présence layer OpenStreetMap

This commit is contained in:
Djedouas 2021-03-02 16:24:58 +01:00
parent 85dc227d35
commit 6a59dec2c3
1 changed files with 6 additions and 3 deletions

View File

@ -172,7 +172,7 @@ class Orientation:
icon_path = ':/plugins/caliec/icon.png'
self.add_action(
icon_path,
text=self.tr(u'Créer le projet'),
text=self.tr('Créer le projet'),
callback=self.run,
parent=self.iface.mainWindow())
@ -184,7 +184,7 @@ class Orientation:
"""Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions:
self.iface.removePluginMenu(
self.tr(u'&CaLiÉc'),
self.tr('CaLiÉc'),
action)
self.iface.removeToolBarIcon(action)
@ -201,7 +201,6 @@ class Orientation:
tempdir = tempfile.TemporaryDirectory()
styles_url = 'https://forge.chapril.org/linux_alpes/caliec/raw/branch/master/styles/'
lambert93 = QgsCoordinateReferenceSystem("EPSG:2154")
wgs = QgsCoordinateReferenceSystem("EPSG:4326")
wgspm = QgsCoordinateReferenceSystem("EPSG:3857")
scr = wgspm
project = QgsProject.instance()
@ -212,6 +211,10 @@ class Orientation:
context = dataobjects.createContext()
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:
# "NOM_DE_LA_COUCHE_OSM": ("nom_du_style", "nom_du_layer")
# Commenter les couches non désirées