Skip to content

Commit 29583ca

Browse files
committed
Small fixes to accommodate QGIS 2.0 and 1.8
1 parent d853ea6 commit 29583ca

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

gazetteersearch.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
QCoreApplication, Qt, QSizeF)
2525
from PyQt4.QtGui import QDockWidget, QIcon, QAction, QTextDocument, QColor
2626
from gazetteersearchdialog import gazetteerSearchDialog
27-
from qgis.core import (QgsApplication, QgsMessageLog, QgsCoordinateReferenceSystem,
27+
from qgis.core import (QGis, QgsApplication, QgsMessageLog, QgsCoordinateReferenceSystem,
2828
QgsRectangle, QgsCoordinateTransform)
2929
from qgis.gui import QgsVertexMarker, QgsAnnotationItem
3030

@@ -57,9 +57,12 @@ def __init__(self, iface):
5757
# initialize plugin directory
5858
self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/gazetteersearch"
5959
# initialize locale
60+
6061
localePath = ""
61-
locale = QSettings().value("locale/userLocale").toString()[0:2]
62-
62+
if QGis.QGIS_VERSION_INT < 10900:
63+
locale = QSettings().value("locale/userLocale").toString()[0:2]
64+
else:
65+
locale = QSettings().value("locale/userLocale")[0:2]
6366
if QFileInfo(self.plugin_dir).exists():
6467
localePath = self.plugin_dir + "/i18n/gazetteersearch_" + locale + ".qm"
6568

@@ -69,7 +72,7 @@ def __init__(self, iface):
6972

7073
if qVersion() > '4.3.3':
7174
QCoreApplication.installTranslator(self.translator)
72-
75+
7376
def initGui(self):
7477
# Create action that will start plugin configuration
7578
self.action = QAction(QIcon(":/plugins/gazetteersearch/icon.png"), \
@@ -136,8 +139,11 @@ def zoomTo(self, name):
136139
for res in self.results:
137140
if unicode(res.description) == unicode(name):
138141
dest_crs = self.canvas.mapRenderer().destinationCrs()
139-
src_crs = QgsCoordinateReferenceSystem()
140-
src_crs.createFromEpsg(res.epsg)
142+
if QGis.QGIS_VERSION_INT < 10900:
143+
src_crs = QgsCoordinateReferenceSystem()
144+
src_crs.createFromEpsg(res.epsg)
145+
else:
146+
src_crs = QgsCoordinateReferenceSystem(res.epsg, QgsCoordinateReferenceSystem.EpsgCrsId)
141147
transform = QgsCoordinateTransform(src_crs, dest_crs)
142148
new_point = transform.transform(res.x, res.y)
143149
x = new_point.x()

metadata.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[general]
1212
name=Gazetteer Search plugin
1313
qgisMinimumVersion=1.8
14+
qgisMaximumVersion=2.99
1415
description=Gazetteer Search plugin
1516
version=0.1
1617

0 commit comments

Comments
 (0)