Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to QGIS 2.0 API compatibility #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions datasets/osm_mapquest_open.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-20037508.34</UpperLeftX>
<UpperLeftY>20037508.34</UpperLeftY>
<LowerRightX>20037508.34</LowerRightX>
<LowerRightY>-20037508.34</LowerRightY>
<TileLevel>18</TileLevel>
<TileCountX>1</TileCountX>
<TileCountY>1</TileCountY>
<YOrigin>top</YOrigin>
</DataWindow>
<Projection>EPSG:900913</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
<BandsCount>3</BandsCount>
<Cache />
</GDAL_WMS>
4 changes: 2 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

[general]
name=Tile Map Scale Plugin
qgisMinimumVersion=1.8
qgisMinimumVersion=2.0
description=Set the scale to the next matching Tile Map Scale. Otherwise tiled datasets will be fuzzy. Works best with Google Mercator Projection.
version=0.3
version=0.4
author=Matthias Ludwig - Datalyze Solutions
email=development@datalyze-solutions.com

Expand Down
10 changes: 7 additions & 3 deletions tilemapscalelevels.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, iface):

# initialize locale
localePath = ""
locale = QSettings().value("locale/userLocale").toString()[0:2]
locale = QSettings().value("locale/userLocale")[0:2]

if QFileInfo(self.workingDir).exists():
localePath = self.workingDir + "/i18n/tilemapscalelevels_" + locale + ".qm"
Expand Down Expand Up @@ -87,6 +87,7 @@ def initGui(self):
self.dock.checkBoxUseOnTheFlyTransformation.stateChanged.connect(self.useOnTheFlyTransformation)
#QObject.connect(self.dock.buttonLoadOSM, SIGNAL("clicked()"), self.loadOSM)
self.dock.buttonLoadOSM.clicked.connect(self.loadOSM)
self.dock.buttonLoadMapQuest.clicked.connect(self.loadMapQuest)
self.dock.buttonLoadGoogleSatellite.clicked.connect(self.loadGoogleSatellite)
self.dock.buttonLoadGoogleMaps.clicked.connect(self.loadGoogleMaps)

Expand Down Expand Up @@ -122,6 +123,9 @@ def setScaleWithSpinBox(self):
def loadOSM(self):
self.iface.addRasterLayer(os.path.join(self.workingDir, "datasets", "osm_mapnik.xml"), "raster")

def loadMapQuest(self):
self.iface.addRasterLayer(os.path.join(self.workingDir, "datasets", "osm_mapquest_open.xml"), "raster")

def loadGoogleSatellite(self):
self.iface.addRasterLayer(os.path.join(self.workingDir, "datasets", "google_satellite.xml"), "raster")

Expand Down Expand Up @@ -175,7 +179,7 @@ def storeStatus(self):

def readStatus(self):
s = QSettings()
isActive = s.value("tilemapscalelevels/active", True).toBool()
isActive = s.value("tilemapscalelevels/active", True, type=bool)
self.dock.checkBoxIsActive.setChecked(isActive)


Expand All @@ -195,4 +199,4 @@ def getScale(self, zoomlevel):

def getZoomlevel(self, scale):
if scale <> 0:
return int(round(math.log( ((self.dpi * self.inchesPerMeter * self.maxScalePerPixel) / scale), 2 ), 0))
return int(round(math.log( ((self.dpi * self.inchesPerMeter * self.maxScalePerPixel) / scale), 2 ), 0))
66 changes: 40 additions & 26 deletions ui_tilemapscalelevels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Form implementation generated from reading ui file 'ui_tilemapscalelevels.ui'
#
# Created: Mon Jun 10 17:52:01 2013
# by: PyQt4 UI code generator 4.9.1
# Created: Wed Jul 24 09:51:11 2013
# by: PyQt4 UI code generator 4.10.2
#
# WARNING! All changes made in this file will be lost!

Expand All @@ -12,13 +12,22 @@
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_DockWidgetTileMapScaleLevels(object):
def setupUi(self, DockWidgetTileMapScaleLevels):
DockWidgetTileMapScaleLevels.setObjectName(_fromUtf8("DockWidgetTileMapScaleLevels"))
DockWidgetTileMapScaleLevels.resize(261, 309)
DockWidgetTileMapScaleLevels.setMinimumSize(QtCore.QSize(0, 0))
DockWidgetTileMapScaleLevels.setMinimumSize(QtCore.QSize(255, 291))
DockWidgetTileMapScaleLevels.setMaximumSize(QtCore.QSize(524287, 309))
DockWidgetTileMapScaleLevels.setFloating(False)
self.dockWidgetContents = QtGui.QWidget()
Expand Down Expand Up @@ -71,9 +80,7 @@ def setupUi(self, DockWidgetTileMapScaleLevels):
self.verticalLayout_2.addWidget(self.groupBox)
self.groupBoxDatasets = QtGui.QGroupBox(self.dockWidgetContents)
self.groupBoxDatasets.setObjectName(_fromUtf8("groupBoxDatasets"))
self.verticalLayout_3 = QtGui.QVBoxLayout(self.groupBoxDatasets)
self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.groupBoxDatasets)
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.buttonLoadOSM = QtGui.QToolButton(self.groupBoxDatasets)
icon = QtGui.QIcon()
Expand All @@ -82,6 +89,11 @@ def setupUi(self, DockWidgetTileMapScaleLevels):
self.buttonLoadOSM.setIconSize(QtCore.QSize(32, 32))
self.buttonLoadOSM.setObjectName(_fromUtf8("buttonLoadOSM"))
self.horizontalLayout_2.addWidget(self.buttonLoadOSM)
self.buttonLoadMapQuest = QtGui.QToolButton(self.groupBoxDatasets)
self.buttonLoadMapQuest.setIcon(icon)
self.buttonLoadMapQuest.setIconSize(QtCore.QSize(32, 32))
self.buttonLoadMapQuest.setObjectName(_fromUtf8("buttonLoadMapQuest"))
self.horizontalLayout_2.addWidget(self.buttonLoadMapQuest)
self.buttonLoadGoogleMaps = QtGui.QToolButton(self.groupBoxDatasets)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/icons/icons/googlemaps.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Expand All @@ -96,9 +108,8 @@ def setupUi(self, DockWidgetTileMapScaleLevels):
self.buttonLoadGoogleSatellite.setIconSize(QtCore.QSize(32, 32))
self.buttonLoadGoogleSatellite.setObjectName(_fromUtf8("buttonLoadGoogleSatellite"))
self.horizontalLayout_2.addWidget(self.buttonLoadGoogleSatellite)
spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
spacerItem2 = QtGui.QSpacerItem(54, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem2)
self.verticalLayout_3.addLayout(self.horizontalLayout_2)
self.verticalLayout_2.addWidget(self.groupBoxDatasets)
DockWidgetTileMapScaleLevels.setWidget(self.dockWidgetContents)

Expand All @@ -108,22 +119,25 @@ def setupUi(self, DockWidgetTileMapScaleLevels):
QtCore.QMetaObject.connectSlotsByName(DockWidgetTileMapScaleLevels)

def retranslateUi(self, DockWidgetTileMapScaleLevels):
DockWidgetTileMapScaleLevels.setWindowTitle(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Tile Map Scale Levels", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxIsActive.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Active", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Current Zoomlevel:", None, QtGui.QApplication.UnicodeUTF8))
self.labelCurrentZoomlevel.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "0", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxUseMercator.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Use World Mercator System", None, QtGui.QApplication.UnicodeUTF8))
self.checkBoxUseOnTheFlyTransformation.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Use \'On-The-Fly\' Transformation", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Zoomlevel", None, QtGui.QApplication.UnicodeUTF8))
self.groupBoxDatasets.setTitle(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Datasets", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadOSM.setToolTip(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadOSM.setStatusTip(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadOSM.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "OSM", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadGoogleMaps.setToolTip(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadGoogleMaps.setStatusTip(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadGoogleMaps.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "OSM", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadGoogleSatellite.setToolTip(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadGoogleSatellite.setStatusTip(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None, QtGui.QApplication.UnicodeUTF8))
self.buttonLoadGoogleSatellite.setText(QtGui.QApplication.translate("DockWidgetTileMapScaleLevels", "OSM", None, QtGui.QApplication.UnicodeUTF8))
DockWidgetTileMapScaleLevels.setWindowTitle(_translate("DockWidgetTileMapScaleLevels", "Tile Map Scale Levels", None))
self.checkBoxIsActive.setText(_translate("DockWidgetTileMapScaleLevels", "Active", None))
self.label.setText(_translate("DockWidgetTileMapScaleLevels", "Current Zoomlevel:", None))
self.labelCurrentZoomlevel.setText(_translate("DockWidgetTileMapScaleLevels", "0", None))
self.checkBoxUseMercator.setText(_translate("DockWidgetTileMapScaleLevels", "Use World Mercator System", None))
self.checkBoxUseOnTheFlyTransformation.setText(_translate("DockWidgetTileMapScaleLevels", "Use \'On-The-Fly\' Transformation", None))
self.groupBox.setTitle(_translate("DockWidgetTileMapScaleLevels", "Zoomlevel", None))
self.groupBoxDatasets.setTitle(_translate("DockWidgetTileMapScaleLevels", "Datasets", None))
self.buttonLoadOSM.setToolTip(_translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None))
self.buttonLoadOSM.setStatusTip(_translate("DockWidgetTileMapScaleLevels", "Load OSM Layer", None))
self.buttonLoadOSM.setText(_translate("DockWidgetTileMapScaleLevels", "OSM", None))
self.buttonLoadMapQuest.setToolTip(_translate("DockWidgetTileMapScaleLevels", "Load MapQuest Layer", None))
self.buttonLoadMapQuest.setStatusTip(_translate("DockWidgetTileMapScaleLevels", "Load MapQuest Layer", None))
self.buttonLoadMapQuest.setText(_translate("DockWidgetTileMapScaleLevels", "OSM", None))
self.buttonLoadGoogleMaps.setToolTip(_translate("DockWidgetTileMapScaleLevels", "Load Google Maps Layer", None))
self.buttonLoadGoogleMaps.setStatusTip(_translate("DockWidgetTileMapScaleLevels", "Load Google Maps Layer", None))
self.buttonLoadGoogleMaps.setText(_translate("DockWidgetTileMapScaleLevels", "OSM", None))
self.buttonLoadGoogleSatellite.setToolTip(_translate("DockWidgetTileMapScaleLevels", "Load Google Satellite Layer", None))
self.buttonLoadGoogleSatellite.setStatusTip(_translate("DockWidgetTileMapScaleLevels", "Load Google Satellite Layer", None))
self.buttonLoadGoogleSatellite.setText(_translate("DockWidgetTileMapScaleLevels", "OSM", None))

import resources_rc
193 changes: 106 additions & 87 deletions ui_tilemapscalelevels.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>255</width>
<height>291</height>
</size>
</property>
<property name="maximumSize">
Expand Down Expand Up @@ -153,92 +153,111 @@
<property name="title">
<string>Datasets</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="buttonLoadOSM">
<property name="toolTip">
<string>Load OSM Layer</string>
</property>
<property name="statusTip">
<string>Load OSM Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/osm.png</normaloff>:/icons/icons/osm.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLoadGoogleMaps">
<property name="toolTip">
<string>Load OSM Layer</string>
</property>
<property name="statusTip">
<string>Load OSM Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/googlemaps.png</normaloff>:/icons/icons/googlemaps.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLoadGoogleSatellite">
<property name="toolTip">
<string>Load OSM Layer</string>
</property>
<property name="statusTip">
<string>Load OSM Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/google_earth.png</normaloff>:/icons/icons/google_earth.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QToolButton" name="buttonLoadOSM">
<property name="toolTip">
<string>Load OSM Layer</string>
</property>
<property name="statusTip">
<string>Load OSM Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/osm.png</normaloff>:/icons/icons/osm.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLoadMapQuest">
<property name="toolTip">
<string>Load MapQuest Layer</string>
</property>
<property name="statusTip">
<string>Load MapQuest Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/osm.png</normaloff>:/icons/icons/osm.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLoadGoogleMaps">
<property name="toolTip">
<string>Load Google Maps Layer</string>
</property>
<property name="statusTip">
<string>Load Google Maps Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/googlemaps.png</normaloff>:/icons/icons/googlemaps.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonLoadGoogleSatellite">
<property name="toolTip">
<string>Load Google Satellite Layer</string>
</property>
<property name="statusTip">
<string>Load Google Satellite Layer</string>
</property>
<property name="text">
<string>OSM</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/google_earth.png</normaloff>:/icons/icons/google_earth.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>54</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
Expand Down