Skip to content

Commit

Permalink
Merge pull request #4226 from tomkralidis/metasearch-fixes-master
Browse files Browse the repository at this point in the history
MetaSearch: minor fixes for QGIS 3 compat
  • Loading branch information
tomkralidis authored Mar 6, 2017
2 parents c2b365c + 6ce208c commit b9a0ba1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def manageGui(self):
self.populate_connection_list()
self.btnCapabilities.setEnabled(False)
self.spnRecords.setValue(
self.settings.value('/MetaSearch/returnRecords', 10, int))
int(self.settings.value('/MetaSearch/returnRecords', 10)))

key = '/MetaSearch/%s' % self.cmbConnectionsSearch.currentText()
self.catalog_url = self.settings.value('%s/url' % key)
Expand Down Expand Up @@ -380,7 +380,7 @@ def set_ows_save_temp_name(self):
def set_bbox_from_map(self):
"""set bounding box from map extent"""

crs = self.map.mapRenderer().destinationCrs()
crs = self.map.mapSettings().destinationCrs()
crsid = int(crs.authid().split(':')[1])

extent = self.map.extent()
Expand Down
36 changes: 22 additions & 14 deletions python/plugins/MetaSearch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from pygments import highlight
from pygments.lexers import XmlLexer
from pygments.formatters import HtmlFormatter
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtCore import QUrl, QUrlQuery
from qgis.PyQt.QtWidgets import QMessageBox
from qgis.PyQt.uic import loadUiType

Expand Down Expand Up @@ -110,14 +110,17 @@ def get_connections_from_file(parent, filename):
def prettify_xml(xml):
"""convenience function to prettify XML"""

if xml.count('\n') > 5: # likely already pretty printed
if isinstance(xml, bytes):
xml = xml.decode('utf-8')

if xml.count('\n') > 20: # likely already pretty printed
return xml

# check if it's a GET request
if xml.startswith('http'):
return xml
else:
# check if it's a GET request
if xml.startswith('http'):
return xml
else:
return parseString(xml).toprettyxml()
return parseString(xml).toprettyxml()


def highlight_xml(context, xml):
Expand All @@ -138,7 +141,7 @@ def get_help_url():
"""return QGIS MetaSearch help documentation link"""

locale_name = QgsSettings().value('locale/userLocale')[0:2]
major, minor = QGis.QGIS_VERSION.split('.')[:2]
major, minor = Qgis.QGIS_VERSION.split('.')[:2]

if minor == '99': # master
version = 'testing'
Expand Down Expand Up @@ -182,10 +185,15 @@ def serialize_string(input_string):
def clean_ows_url(url):
"""clean an OWS URL of added basic service parameters"""

url2 = QUrl(url)
url2.removeEncodedQueryItem('service')
url2.removeEncodedQueryItem('SERVICE')
url2.removeEncodedQueryItem('request')
url2.removeEncodedQueryItem('REQUEST')
url = QUrl(url)
query_string = url.query()

if query_string:
query_string = QUrlQuery(query_string)
query_string.removeQueryItem('service')
query_string.removeQueryItem('SERVICE')
query_string.removeQueryItem('request')
query_string.removeQueryItem('REQUEST')
url.setQuery(query_string)

return url2.toString()
return url.toString()

0 comments on commit b9a0ba1

Please sign in to comment.