def _run(self): properties = self.gather_values() if properties['load_only']: # Legacy, waiting to remove the OsmParser for QGIS >= 3.6 # Change in osm_file_dialog.py L131 too output_geom_legacy = [ layer.value.lower() for layer in properties['outputs'] ] osm_parser = OsmParser(properties['osm_file'], load_only=True, osm_conf=properties['osm_conf'], layers=output_geom_legacy) layers = osm_parser.parse() for item in layers.values(): # noinspection PyArgumentList QgsProject.instance().addMapLayer(item) else: open_file(dialog=self.dialog, osm_file=properties['osm_file'], output_geom_types=properties['outputs'], output_dir=properties['output_directory'], prefix_file=properties['prefix_file']) self.dialog.display_message_bar(tr('Successful query'), level=Qgis.Success, duration=5)
def open_file(self): """Open the osm file with the osmconf.""" try: self._start_process() p = self.gather_values() if p['load_only']: # Legacy, waiting to remove the OsmParser for QGIS >= 3.6 # Change in osm_file_dialog.py L131 too output_geom_legacy = [l.value.lower() for l in p['outputs']] osm_parser = OsmParser(p['osm_file'], load_only=True, osm_conf=p['osm_conf'], layers=output_geom_legacy) layers = osm_parser.parse() for item in layers.values(): QgsProject.instance().addMapLayer(item) else: open_file(dialog=self, osm_file=p['osm_file'], output_geom_types=p['outputs'], output_dir=p['output_directory'], prefix_file=p['prefix_file']) self.display_message_bar(tr('Successful query'), level=Qgis.Success, duration=5) except QuickOsmException as e: self.display_geo_algorithm_exception(e) except Exception as e: self.display_exception(e) finally: self._end_process()
def open_file(self): """ Open the osm file with the osmconf """ QApplication.setOverrideCursor(Qt.WaitCursor) self.start_process() QApplication.processEvents() # Get fields osm_file = self.osm_file.filePath() osm_conf = self.osm_conf.filePath() output_directory = self.output_directory.filePath() prefix_file = self.lineEdit_filePrefix.text() load_only = self.radioButton_osmConf.isChecked() # Which geometry at the end ? output_geometry_types = self.get_output_geometry_types() try: if not output_geometry_types: raise OutPutGeomTypesException if not isfile(osm_file): raise FileDoesntExistException(suffix="*.osm or *.pbf") if load_only: if not isfile(osm_conf): raise FileDoesntExistException(suffix="*.ini") if output_directory and not isdir(output_directory): raise DirectoryOutPutException if load_only: osm_parser = OsmParser(osm_file, load_only=True, osm_conf=osm_conf, layers=output_geometry_types) layers = osm_parser.parse() for item in list(layers.values()): QgsProject.instance().addMapLayer(item) else: open_file(dialog=self, osm_file=osm_file, output_geom_types=output_geometry_types, output_dir=output_directory, prefix_file=prefix_file) display_message_bar(tr('QuickOSM', u'Successful query !'), level=Qgis.Success, duration=5) except QuickOsmException as e: self.display_geo_algorithm_exception(e) except Exception as e: # pylint: disable=broad-except self.display_exception(e) finally: QApplication.restoreOverrideCursor() self.end_process() QApplication.processEvents()
def open_file(self): """ Open the osm file with the osmconf """ QApplication.setOverrideCursor(Qt.WaitCursor) self.start_process() QApplication.processEvents() # Get fields osm_file = self.osm_file.filePath() osm_conf = self.osm_conf.filePath() output_directory = self.output_directory.filePath() prefix_file = self.lineEdit_filePrefix.text() load_only = self.radioButton_osmConf.isChecked() # Which geometry at the end ? output_geometry_types = self.get_output_geometry_types() try: if not output_geometry_types: raise OutPutGeomTypesException if not isfile(osm_file): raise FileDoesntExistException(suffix="*.osm or *.pbf") if load_only: if not isfile(osm_conf): raise FileDoesntExistException(suffix="*.ini") if output_directory and not isdir(output_directory): raise DirectoryOutPutException if load_only: # Legacy, waiting to remove the OsmParser for QGIS >= 3.6 # Change in osm_file_dialog.py L131 too output_geom_legacy = [ l.value.lower() for l in output_geometry_types] osm_parser = OsmParser( osm_file, load_only=True, osm_conf=osm_conf, layers=output_geom_legacy) layers = osm_parser.parse() for item in list(layers.values()): QgsProject.instance().addMapLayer(item) else: open_file( dialog=self, osm_file=osm_file, output_geom_types=output_geometry_types, output_dir=output_directory, prefix_file=prefix_file) display_message_bar( tr('Successful query'), level=Qgis.Success, duration=5) except QuickOsmException as e: self.display_geo_algorithm_exception(e) except Exception as e: # pylint: disable=broad-except self.display_exception(e) finally: QApplication.restoreOverrideCursor() self.end_process() QApplication.processEvents()