예제 #1
0
    def __init__(self, parent=None):
        """
        OsmFileWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Set UI
        self.radioButton_osmConf.setChecked(False)
        self.osm_conf.setEnabled(False)
        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)

        # OSM File
        self.osm_file.setDialogTitle(tr('Select an OSM file'))
        self.osm_file.setFilter('OSM file (*.osm *.pbf)')

        # Set default osm conf
        self.defaultOsmConf = join(
            dirname(dirname(abspath(__file__))), 'osmconf.ini')
        if not isfile(self.defaultOsmConf):
            self.defaultOsmConf = ''
        self.osm_conf.setDialogTitle(tr('Select OSM conf file'))
        self.osm_conf.setFilter('OSM conf (*.ini)')
        self.osm_conf.fileChanged.connect(self.disable_run_button)
        self.pushButton_runQuery.setEnabled(False)

        # Connect
        self.osm_file.fileChanged.connect(self.disable_run_button)
        self.output_directory.fileChanged.connect(self.disable_prefix_file)
        self.radioButton_osmConf.toggled.connect(self.disable_run_button)
        self.pushButton_runQuery.clicked.connect(self.open_file)

        self.disable_run_button()
예제 #2
0
    def __init__(self, parent=None):
        """
        OsmFileWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Set UI
        self.radioButton_osmConf.setChecked(False)
        self.osm_conf.setEnabled(False)
        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)

        # OSM File
        self.osm_file.setDialogTitle(tr('Select an OSM file'))
        self.osm_file.setFilter('OSM file (*.osm *.pbf)')

        # Set default osm conf
        self.defaultOsmConf = join(dirname(dirname(abspath(__file__))),
                                   'osmconf.ini')
        if not isfile(self.defaultOsmConf):
            self.defaultOsmConf = ''
        self.osm_conf.setDialogTitle(tr('Select OSM conf file'))
        self.osm_conf.setFilter('OSM conf (*.ini)')
        self.osm_conf.fileChanged.connect(self.disable_run_button)
        self.pushButton_runQuery.setEnabled(False)

        # Connect
        self.osm_file.fileChanged.connect(self.disable_run_button)
        self.output_directory.fileChanged.connect(self.disable_prefix_file)
        self.radioButton_osmConf.toggled.connect(self.disable_run_button)
        self.pushButton_runQuery.clicked.connect(self.open_file)

        self.disable_run_button()
예제 #3
0
    def __init__(self, parent=None):
        """
        QuickQueryWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Setup UI

        # Query type
        self.cb_query_type.addItem(tr('In'), 'in')
        self.cb_query_type.addItem(tr('Around'), 'around')
        self.cb_query_type.addItem(tr('Canvas Extent'), 'canvas')
        self.cb_query_type.addItem(tr('Layer Extent'), 'layer')
        self.cb_query_type.addItem(tr('Not Spatial'), 'attributes')

        # self.cb_query_type.setItemIcon(0, QIcon(resources_path('in.svg')))
        # self.cb_query_type.setItemIcon(1, QIcon(resources_path('around.svg')))
        # self.cb_query_type.setItemIcon(2, QIcon(resources_path('map_canvas.svg')))
        # self.cb_query_type.setItemIcon(3, QIcon(resources_path('extent.svg')))
        # self.cb_query_type.setItemIcon(4, QIcon(resources_path('mIconTableLayer.svg')))

        self.cb_query_type.currentIndexChanged.connect(self.query_type_updated)

        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)
        # self.activate_extent_layer()

        # connect
        self.pushButton_runQuery.clicked.connect(self.run_query)
        self.pushButton_showQuery.clicked.connect(self.show_query)
        self.comboBox_key.editTextChanged.connect(self.key_edited)
        self.pushButton_mapFeatures.clicked.connect(self.open_map_features)
        self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(
            self.reset_form)

        # Setup auto completion
        map_features_json_file = join(
            dirname(dirname(abspath(__file__))), 'mapFeatures.json')

        if isfile(map_features_json_file):
            with open(map_features_json_file) as f:
                self.osmKeys = load(f)
                keys = list(self.osmKeys.keys())
                keys.append('')  # All keys request #118
                keys.sort()
                keys_completer = QCompleter(keys)
                self.comboBox_key.addItems(keys)
                self.comboBox_key.setCompleter(keys_completer)
                self.comboBox_key.completer().setCompletionMode(
                    QCompleter.PopupCompletion)
                self.comboBox_key.lineEdit().setPlaceholderText(tr('Query on all keys'))

        self.comboBox_value.lineEdit().setPlaceholderText(tr('Query on all values'))
        self.key_edited()

        self.query_type_updated()
        self.init_nominatim_autofill()
예제 #4
0
    def __init__(self, parent=None):
        """
        QuickQueryWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Setup UI

        # Query type
        self.cb_query_type.addItem(tr('In'), 'in')
        self.cb_query_type.addItem(tr('Around'), 'around')
        self.cb_query_type.addItem(tr('Canvas Extent'), 'canvas')
        self.cb_query_type.addItem(tr('Layer Extent'), 'layer')
        self.cb_query_type.addItem(tr('Not Spatial'), 'attributes')

        self.cb_query_type.currentIndexChanged.connect(self.query_type_updated)

        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)
        # self.activate_extent_layer()

        # connect
        self.pushButton_runQuery.clicked.connect(self.run_query)
        self.pushButton_showQuery.clicked.connect(self.show_query)
        self.comboBox_key.editTextChanged.connect(self.key_edited)
        self.pushButton_mapFeatures.clicked.connect(self.open_map_features)
        self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(
            self.reset_form)

        # Setup auto completion
        map_features_json_file = join(dirname(dirname(abspath(__file__))),
                                      'mapFeatures.json')

        if isfile(map_features_json_file):
            with open(map_features_json_file) as f:
                self.osmKeys = load(f)
                keys = list(self.osmKeys.keys())
                keys.append('')  # All keys request #118
                keys.sort()
                keys_completer = QCompleter(keys)
                self.comboBox_key.addItems(keys)
                self.comboBox_key.setCompleter(keys_completer)
                self.comboBox_key.completer().setCompletionMode(
                    QCompleter.PopupCompletion)
                self.comboBox_key.lineEdit().setPlaceholderText(
                    'Query on all keys')

        self.comboBox_value.lineEdit().setPlaceholderText(
            'Query on all values')
        self.key_edited()

        self.query_type_updated()
        self.init_nominatim_autofill()
예제 #5
0
    def __init__(self, parent=None):
        """
        QuickQueryWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Setup UI
        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)
        self.activate_extent_layer()
        self.comboBox_in_around.setDisabled(True)
        self.lineEdit_nominatim.setDisabled(True)
        self.radioButton_extentMapCanvas.setChecked(True)
        self.spinBox_distance_point.setDisabled(True)
        self.label_distance_point.setDisabled(True)

        # Setup in/around combobox
        self.comboBox_in_around.insertItem(0, tr('ui_quick_query', u'In'))
        self.comboBox_in_around.insertItem(1, tr('ui_quick_query', u'Around'))

        # connect
        self.pushButton_runQuery.clicked.connect(self.run_query)
        self.pushButton_showQuery.clicked.connect(self.show_query)
        self.comboBox_key.editTextChanged.connect(self.key_edited)
        self.radioButton_extentLayer.toggled.connect(
            self.allow_nominatim_or_extent)
        self.radioButton_extentMapCanvas.toggled.connect(
            self.allow_nominatim_or_extent)
        self.radioButton_place.toggled.connect(self.allow_nominatim_or_extent)
        self.pushButton_mapFeatures.clicked.connect(self.open_map_features)
        self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(
            self.reset_form)
        self.comboBox_in_around.currentIndexChanged.connect(self.in_or_around)

        # Setup auto completion
        map_features_json_file = join(dirname(dirname(abspath(__file__))),
                                      'mapFeatures.json')

        if isfile(map_features_json_file):
            with open(map_features_json_file) as f:
                self.osmKeys = load(f)
                keys = list(self.osmKeys.keys())
                keys.sort()
                keys_completer = QCompleter(keys)
                self.comboBox_key.addItems(keys)
                self.comboBox_key.setCompleter(keys_completer)
                self.comboBox_key.completer().setCompletionMode(
                    QCompleter.PopupCompletion)
        self.key_edited()

        self.init_nominatim_autofill()
예제 #6
0
    def __init__(self, parent=None):
        """
        MyQueriesWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.current_query = None
        self.config_layer = None

        # Setup UI
        self.label_progress.setText("")
        self.pushButton_runQuery.setDisabled(True)
        self.pushButton_showQuery.setDisabled(True)
        self.groupBox.setDisabled(True)
        self.lineEdit_nominatim.setEnabled(False)
        self.radioButton_extentLayer.setEnabled(False)
        self.radioButton_extentMapCanvas.setEnabled(False)

        # self.activate_extent_layer()
        self.fill_tree()
        self.groupBox.setCollapsed(True)

        # Enable autofill on nominatim
        self.init_nominatim_autofill()

        # Connect
        self.pushButton_runQuery.clicked.connect(self.run_query)
        self.pushButton_showQuery.clicked.connect(self.show_query)
        self.pushButton_browse_output_file.clicked.connect(
            self.set_output_directory_path)
        self.lineEdit_browseDir.textEdited.connect(self.disable_prefix_file)
        self.treeQueries.doubleClicked.connect(self.open_and_run_query)
        self.treeQueries.customContextMenuRequested.connect(
            self.show_popup_menu)
        self.treeQueries.clicked.connect(self.open_query)
        self.lineEdit_search.textChanged.connect(self.text_changed)
        self.radioButton_extentLayer.toggled.connect(self.extent_radio)
예제 #7
0
    def __init__(self, parent=None):
        """
        QueryWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Highlight XML
        self.highlighter = XMLHighlighter(self.textEdit_query.document())

        # QGIS 3
        self.pushButton_saveQuery.setVisible(False)

        # Setup UI
        self.cb_query_type.addItem(tr('Canvas Extent'), 'canvas')
        self.cb_query_type.addItem(tr('Layer Extent'), 'layer')
        self.cb_query_type.currentIndexChanged.connect(self.query_type_updated)

        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)
        self.bbox = None
        # self.activate_extent_layer()
        self.pushButton_overpassTurbo.setIcon(QIcon(resources_path('turbo.png')))
        # Disable buttons
        self.pushButton_generateQuery.setDisabled(True)
        self.pushButton_saveQuery.setDisabled(True)
        self.pushButton_runQuery.setDisabled(True)

        # Setup menu for saving
        popup_menu = QMenu()
        save_final_query_action = QAction(
            tr('Save as final query'), self.pushButton_saveQuery)
        # save_final_query_action.triggered.connect(self.save_final_query)
        popup_menu.addAction(save_final_query_action)
        save_template_query_action = QAction(
            tr('Save as template'), self.pushButton_saveQuery)
        # save_template_query_action.triggered.connect(self.save_template_query)
        popup_menu.addAction(save_template_query_action)
        self.pushButton_saveQuery.setMenu(popup_menu)

        # Setup menu for documentation
        popup_menu = QMenu()
        map_features_action = QAction(
            'Map Features', self.pushButton_documentation)
        map_features_action.triggered.connect(self.open_map_features)
        popup_menu.addAction(map_features_action)
        overpass_action = QAction('Overpass', self.pushButton_documentation)
        overpass_action.triggered.connect(self.open_doc_overpass)
        popup_menu.addAction(overpass_action)
        self.pushButton_documentation.setMenu(popup_menu)

        # Enable autofill on nominatim
        self.init_nominatim_autofill()

        # connect
        self.pushButton_runQuery.clicked.connect(self.run_query)
        self.pushButton_generateQuery.clicked.connect(self.generate_query)
        self.textEdit_query.cursorPositionChanged.connect(
            self.highlighter.rehighlight)
        self.textEdit_query.cursorPositionChanged.connect(
            self.allow_nominatim_or_extent)
        self.pushButton_overpassTurbo.clicked.connect(self.open_overpass_turbo)
        self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(
            self.reset_form)

        self.query_type_updated()
예제 #8
0
    def __init__(self, parent=None):
        """
        QueryWidget constructor
        """
        QuickOSMWidget.__init__(self, parent)
        self.setupUi(self)
        self.init()

        # Highlight XML
        self.highlighter = XMLHighlighter(self.textEdit_query.document())

        # QGIS 3
        self.pushButton_saveQuery.setVisible(False)

        # Setup UI
        self.cb_query_type.addItem(tr('Canvas Extent'), 'canvas')
        self.cb_query_type.addItem(tr('Layer Extent'), 'layer')
        self.cb_query_type.currentIndexChanged.connect(self.query_type_updated)

        self.label_progress.setText("")
        self.lineEdit_filePrefix.setDisabled(True)
        self.bbox = None
        # self.activate_extent_layer()
        self.pushButton_overpassTurbo.setIcon(
            QIcon(resources_path('turbo.png')))
        # Disable buttons
        self.pushButton_generateQuery.setDisabled(True)
        self.pushButton_saveQuery.setDisabled(True)
        self.pushButton_runQuery.setDisabled(True)

        # Setup menu for saving
        popup_menu = QMenu()
        save_final_query_action = QAction(tr('Save as final query'),
                                          self.pushButton_saveQuery)
        # save_final_query_action.triggered.connect(self.save_final_query)
        popup_menu.addAction(save_final_query_action)
        save_template_query_action = QAction(tr('Save as template'),
                                             self.pushButton_saveQuery)
        # save_template_query_action.triggered.connect(self.save_template_query)
        popup_menu.addAction(save_template_query_action)
        self.pushButton_saveQuery.setMenu(popup_menu)

        # Setup menu for documentation
        popup_menu = QMenu()
        map_features_action = QAction('Map Features',
                                      self.pushButton_documentation)
        map_features_action.triggered.connect(open_map_features)
        popup_menu.addAction(map_features_action)
        overpass_action = QAction('Overpass', self.pushButton_documentation)
        overpass_action.triggered.connect(open_doc_overpass)
        popup_menu.addAction(overpass_action)
        self.pushButton_documentation.setMenu(popup_menu)

        # Enable autofill on nominatim
        self.init_nominatim_autofill()

        # connect
        self.pushButton_runQuery.clicked.connect(self.run_query)
        self.pushButton_generateQuery.clicked.connect(self.generate_query)
        self.textEdit_query.cursorPositionChanged.connect(
            self.highlighter.rehighlight)
        self.textEdit_query.cursorPositionChanged.connect(
            self.allow_nominatim_or_extent)
        self.pushButton_overpassTurbo.clicked.connect(open_overpass_turbo)
        self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(
            self.reset_form)

        self.query_type_updated()