def _open_wfs(self, name, capabilites_url): # Add new HTTPConnection like in source # https://github.com/qgis/QGIS/blob/master/src/gui/qgsnewhttpconnection.cpp # https://github.com/qgis/QGIS/blob/79616fd8d8285b4eb93adafdfcb97a3e429b832e/src/app/qgisapp.cpp#L3783 self.msg_log(u'add WFS: Name={0}, original URL={1}'.format( name, capabilites_url)) # remove additional url parameters, otherwise adding wfs works the frist time only # https://github.com/qgis/QGIS/blob/9eee12111567a84f4d4de7e020392b3c01c28598/src/gui/qgsnewhttpconnection.cpp#L199-L214 url = QUrl(capabilites_url) url.removeQueryItem('SERVICE') url.removeQueryItem('REQUEST') url.removeQueryItem('FORMAT') url.removeQueryItem('service') url.removeQueryItem('request') url.removeQueryItem('format') #also remove VERSION: shouldn't be necessary, but QGIS sometimes seems to append version=1.0.0 url.removeQueryItem('VERSION') url.removeQueryItem('version') capabilites_url = url.toString() self.msg_log(u'add WFS: Name={0}, base URL={1}'.format( name, capabilites_url)) s = QSettings() self.msg_log(u'existing WFS url: {0}'.format( s.value(u'Qgis/connections-wfs/{0}/url'.format(name), ''))) key_user = u'Qgis/WFS/{0}/username'.format(name) key_pwd = u'Qgis/WFS/{0}/password'.format(name) key_referer = u'Qgis/connections-wfs/{0}/referer'.format(name) key_url = u'Qgis/connections-wfs/{0}/url'.format(name) key_authcfg = u'Qgis/WFS/{0}/authcfg'.format(name) s.remove(key_user) s.remove(key_pwd) s.remove(key_referer) s.remove(key_url) s.sync() s.setValue(key_user, '') s.setValue(key_pwd, '') s.setValue(key_referer, '') s.setValue(key_url, capabilites_url) if self.settings.auth_propagate and self.settings.authcfg: s.setValue(key_authcfg, self.settings.authcfg) s.setValue(u'Qgis/connections-wfs/selected', name) # create new dialog wfs_dlg = QgsProviderRegistry.instance().selectWidget( "WFS", self.main_win) QObject.connect(wfs_dlg, SIGNAL("addWfsLayer( QString, QString )"), self.main_win, SLOT("addWfsLayer( QString, QString )")) wfs_dlg.show()
def _open_wfs(self, name, capabilites_url): # Add new HTTPConnection like in source # https://github.com/qgis/QGIS/blob/master/src/gui/qgsnewhttpconnection.cpp # https://github.com/qgis/QGIS/blob/79616fd8d8285b4eb93adafdfcb97a3e429b832e/src/app/qgisapp.cpp#L3783 self.msg_log(u'add WFS: Name={0}, original URL={1}'.format(name, capabilites_url)) # remove additional url parameters, otherwise adding wfs works the frist time only # https://github.com/qgis/QGIS/blob/9eee12111567a84f4d4de7e020392b3c01c28598/src/gui/qgsnewhttpconnection.cpp#L199-L214 url = QUrl(capabilites_url) url.removeQueryItem('SERVICE') url.removeQueryItem('REQUEST') url.removeQueryItem('FORMAT') url.removeQueryItem('service') url.removeQueryItem('request') url.removeQueryItem('format') #also remove VERSION: shouldn't be necessary, but QGIS sometimes seems to append version=1.0.0 url.removeQueryItem('VERSION') url.removeQueryItem('version') capabilites_url = url.toString() self.msg_log(u'add WFS: Name={0}, base URL={1}'.format(name, capabilites_url)) s = QSettings() self.msg_log(u'existing WFS url: {0}'.format(s.value(u'Qgis/connections-wfs/{0}/url'.format(name), ''))) key_user = u'Qgis/WFS/{0}/username'.format(name) key_pwd = u'Qgis/WFS/{0}/password'.format(name) key_referer = u'Qgis/connections-wfs/{0}/referer'.format(name) key_url = u'Qgis/connections-wfs/{0}/url'.format(name) key_authcfg = u'Qgis/WFS/{0}/authcfg'.format(name) s.remove(key_user) s.remove(key_pwd) s.remove(key_referer) s.remove(key_url) s.sync() s.setValue(key_user, '') s.setValue(key_pwd, '') s.setValue(key_referer, '') s.setValue(key_url, capabilites_url) if self.settings.auth_propagate and self.settings.authcfg: s.setValue(key_authcfg, self.settings.authcfg) s.setValue(u'Qgis/connections-wfs/selected', name) # create new dialog wfs_dlg = QgsProviderRegistry.instance().selectWidget("WFS", self.main_win) QObject.connect( wfs_dlg , SIGNAL("addWfsLayer( QString, QString )") , self.main_win, SLOT("addWfsLayer( QString, QString )") ) wfs_dlg.show()