Skip to content

Commit

Permalink
Misc QGIS3 fixes. Fixes #17. Fixes #24.
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 25, 2018
1 parent 53f7db6 commit ec62d32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Discovery/config_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from PyQt5.QtCore import QSettings, Qt, QUrl
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QDialogButtonBox
from PyQt5.QtWidgets import QApplication, QDialogButtonBox
from PyQt5 import uic

from . import dbutils
Expand Down
14 changes: 9 additions & 5 deletions Discovery/discoveryplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from PyQt5.QtCore import QModelIndex, QSettings, QTimer, QVariant, Qt
from PyQt5.QtGui import QColor, QIcon
from PyQt5.QtWidgets import QAction, QCompleter
from PyQt5.QtWidgets import QAction, QComboBox, QCompleter

import time
import os.path
Expand All @@ -24,6 +24,7 @@
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsExpression,
QgsExpressionContext,
QgsFeature,
QgsField,
QgsFields,
Expand All @@ -46,7 +47,7 @@ def eval_expression(expr_text, extra_data, default=None):
return default

flds = QgsFields()
for extra_col, extra_value in extra_data.iteritems():
for extra_col, extra_value in extra_data.items():
if isinstance(extra_value, int):
t = QVariant.Int
elif isinstance(extra_value, float):
Expand All @@ -55,10 +56,12 @@ def eval_expression(expr_text, extra_data, default=None):
t = QVariant.String
flds.append(QgsField(extra_col, t))
f = QgsFeature(flds)
for extra_col, extra_value in extra_data.iteritems():
for extra_col, extra_value in extra_data.items():
f[extra_col] = extra_value
expr = QgsExpression(expr_text)
res = expr.evaluate(f)
ctx = QgsExpressionContext()
ctx.setFeature(f)
res = expr.evaluate(ctx)
return default if expr.hasEvalError() else res


Expand Down Expand Up @@ -310,7 +313,8 @@ def select_result(self, result_data):
canvas = self.iface.mapCanvas()
dst_srid = canvas.mapSettings().destinationCrs().authid()
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem(src_epsg),
QgsCoordinateReferenceSystem(dst_srid))
QgsCoordinateReferenceSystem(dst_srid),
canvas.mapSettings().transformContext())
# Ensure the geometry from the DB is reprojected to the same SRID as the map canvas
location_geom.transform(transform)
location_centroid = location_geom.centroid().asPoint()
Expand Down
3 changes: 3 additions & 0 deletions Discovery/locator_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def __init__(self, plugin):
QgsLocatorFilter.__init__(self, None)
self.plugin = plugin

def clone(self):
return DiscoveryLocatorFilter(self.plugin)

def name(self):
return "discovery"

Expand Down
2 changes: 1 addition & 1 deletion Discovery/metadata.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
name=Discovery
qgisMinimumVersion=2.99
qgisMinimumVersion=3.0
qgisMaximumVersion=3.99
description=Provides search / gazetteer functionality in QGIS using PostGIS-based data
version=2.1.0
Expand Down

0 comments on commit ec62d32

Please sign in to comment.