Skip to content

Commit aae80cb

Browse files
author
wonder
committed
Update to OSM plugin from Lukas Berka:
-classes and .ui,.py files renamed -bugfixes git-svn-id: http://svn.osgeo.org/qgis/trunk@11378 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 075583b commit aae80cb

26 files changed

+221
-241
lines changed

python/plugins/osm/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
SET (OSM_PLUGIN_DIR ${QGIS_DATA_DIR}/python/plugins/osm)
55

6+
67
FILE (GLOB PYTHON_FILES *.py)
78
FILE (GLOB MAPTOOLS_PYTHON_FILES map_tools/*.py)
89
FILE (GLOB STYLE_FILES styles/*.style)

python/plugins/osm/Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11

2-
GEN_FILES = DlgLoadOSM_ui.py DlgSaveOSM_ui.py DlgDownloadOSM_ui.py DlgUploadOSM_ui.py DockWidget_ui.py DlgAddRelation_ui.py DockUndoRedo_ui.py DlgImport_ui.py resources.py
2+
GEN_FILES = OsmLoadDlg_ui.py OsmSaveDlg_ui.py OsmDownloadDlg_ui.py OsmUploadDlg_ui.py OsmFeatureDW_ui.py OsmAddRelationDlg_ui.py OsmUndoRedoDW_ui.py OsmImportDlg_ui.py resources.py
33

44
all: $(GEN_FILES)
55

6-
DlgLoadOSM_ui.py: ui_files/DlgLoadOSM.ui
7-
pyuic4 -o DlgLoadOSM_ui.py ui_files/DlgLoadOSM.ui
6+
OsmLoadDlg_ui.py: ui_files/OsmLoadDlg.ui
7+
pyuic4 -o OsmLoadDlg_ui.py ui_files/OsmLoadDlg.ui
88

9-
DlgSaveOSM_ui.py: ui_files/DlgSaveOSM.ui
10-
pyuic4 -o DlgSaveOSM_ui.py ui_files/DlgSaveOSM.ui
9+
OsmSaveDlg_ui.py: ui_files/OsmSaveDlg.ui
10+
pyuic4 -o OsmSaveDlg_ui.py ui_files/OsmSaveDlg.ui
1111

12-
DlgDownloadOSM_ui.py: ui_files/DlgDownloadOSM.ui
13-
pyuic4 -o DlgDownloadOSM_ui.py ui_files/DlgDownloadOSM.ui
12+
OsmDownloadDlg_ui.py: ui_files/OsmDownloadDlg.ui
13+
pyuic4 -o OsmDownloadDlg_ui.py ui_files/OsmDownloadDlg.ui
1414

15-
DlgUploadOSM_ui.py: ui_files/DlgUploadOSM.ui
16-
pyuic4 -o DlgUploadOSM_ui.py ui_files/DlgUploadOSM.ui
15+
OsmUploadDlg_ui.py: ui_files/OsmUploadDlg.ui
16+
pyuic4 -o OsmUploadDlg_ui.py ui_files/OsmUploadDlg.ui
1717

18-
DockWidget_ui.py: ui_files/DockWidget.ui
19-
pyuic4 -o DockWidget_ui.py ui_files/DockWidget.ui
18+
OsmFeatureDW_ui.py: ui_files/OsmFeatureDW.ui
19+
pyuic4 -o OsmFeatureDW_ui.py ui_files/OsmFeatureDW.ui
2020

21-
DlgAddRelation_ui.py: ui_files/DlgAddRelation.ui
22-
pyuic4 -o DlgAddRelation_ui.py ui_files/DlgAddRelation.ui
21+
OsmAddRelationDlg_ui.py: ui_files/OsmAddRelationDlg.ui
22+
pyuic4 -o OsmAddRelationDlg_ui.py ui_files/OsmAddRelationDlg.ui
2323

24-
DockUndoRedo_ui.py: ui_files/DockUndoRedo.ui
25-
pyuic4 -o DockUndoRedo_ui.py ui_files/DockUndoRedo.ui
24+
OsmUndoRedoDW_ui.py: ui_files/OsmUndoRedoDW.ui
25+
pyuic4 -o OsmUndoRedoDW_ui.py ui_files/OsmUndoRedoDW.ui
2626

27-
DlgImport_ui.py: ui_files/DlgImport.ui
28-
pyuic4 -o DlgImport_ui.py ui_files/DlgImport.ui
27+
OsmImportDlg_ui.py: ui_files/OsmImportDlg.ui
28+
pyuic4 -o OsmImportDlg_ui.py ui_files/OsmImportDlg.ui
2929

3030
resources.py: resources.qrc
3131
pyrcc4 -o resources.py resources.qrc

python/plugins/osm/DlgAddRelation.py renamed to python/plugins/osm/OsmAddRelationDlg.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
"""@package DlgAddRelation
2-
The main class of this module (DlgAddRelation) is descendant of "Create OSM Relation" dialog.
1+
"""@package OsmAddRelationDlg
2+
The main class of this module (OsmAddRelationDlg) is descendant of "Create OSM Relation" dialog.
33
44
The dialog either shows detail info on existing relation or is empty when no relation id is passed to constructor.
55
In brief this module (and its main class) just provides easy way to create or change OSM relation.
66
...
77
"""
88

99

10-
from DlgAddRelation_ui import Ui_DlgAddRelation
11-
from map_tools.IdentifyMapTool import IdentifyMapTool
10+
from OsmAddRelationDlg_ui import Ui_OsmAddRelationDlg
11+
from map_tools.OsmIdentifyMT import OsmIdentifyMT
1212

1313
from PyQt4.QtCore import *
1414
from PyQt4.QtGui import *
@@ -21,11 +21,11 @@
2121

2222

2323

24-
class DlgAddRelation(QDialog, Ui_DlgAddRelation):
24+
class OsmAddRelationDlg(QDialog, Ui_OsmAddRelationDlg):
2525
"""This class is direct descendant of "Create OSM Relation" dialog. It provides easy way to create
26-
or change OSM relation. Methods of DlgAddRelation class catch signals emitted when changing relations
26+
or change OSM relation. Methods of OsmAddRelationDlg class catch signals emitted when changing relations
2727
type, tags or members, submitting or rejecting the whole dialog. After catching signal, methods must
28-
perform appropriate operation using methods of DatabaseManager. The other methods serve to initialize
28+
perform appropriate operation using methods of OsmDatabaseManager. The other methods serve to initialize
2929
dialog when displaying info on existing relation."""
3030

3131

@@ -208,7 +208,7 @@ def __startIdentifyingMember(self):
208208
"""
209209

210210
if self.chooseMemberButton.isChecked():
211-
self.mapTool=IdentifyMapTool(self.canvas, self.dockWidget, self.dbm)
211+
self.mapTool=OsmIdentifyMT(self.canvas, self.dockWidget, self.dbm)
212212
self.canvas.setMapTool(self.mapTool)
213213
self.canvas.setCursor(QCursor(Qt.ArrowCursor))
214214
self.canvas.setFocus(Qt.OtherFocusReason)

python/plugins/osm/DatabaseManager.py renamed to python/plugins/osm/OsmDatabaseManager.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""@package DatabaseManager
1+
"""@package OsmDatabaseManager
22
This module provides methods to manipulate with database where OSM data are stored.
33
4-
DatabaseManager is the only part of OSM Plugin that has the right to access OSM (sqlite) database.
4+
OsmDatabaseManager is the only part of OSM Plugin that has the right to access OSM (sqlite) database.
55
If any other part of plugin wants to manipulate with OSM data, it is expected to use constructs of this module.
66
77
This module can manage more than one database at a time.
@@ -21,10 +21,10 @@
2121

2222

2323

24-
class DatabaseManager:
25-
"""This is the only class of DatabaseManager module. Its purpose is to manage work with OSM databases.
24+
class OsmDatabaseManager:
25+
"""This is the only class of OsmDatabaseManager module. Its purpose is to manage work with OSM databases.
2626
27-
DatabaseManager class provides method to add new OSM database.
27+
OsmDatabaseManager class provides method to add new OSM database.
2828
2929
It holds all connections to all databases and holds the information
3030
on which database is currently used with all operations.
@@ -38,7 +38,7 @@ class DatabaseManager:
3838
def __init__(self,plugin):
3939
"""The constructor.
4040
41-
Initializes inner structures of DatabaseManager and connect signals to appropriate slots.
41+
Initializes inner structures of OsmDatabaseManager and connect signals to appropriate slots.
4242
"""
4343

4444
self.plugin=plugin
@@ -124,28 +124,19 @@ def layerRemoved(self,layerID):
124124
layerSource=layer.source()
125125
pos=layerSource.lastIndexOf("?")
126126
dbFileName=layerSource.left(pos)+".db"
127+
key=dbFileName.toLatin1().data()
127128

128129
# remove all map layers that belong to dbFileName database
129-
allLayers=QgsMapLayerRegistry.instance().mapLayers()
130-
for ix in allLayers.keys():
131-
l=allLayers[ix] # layer object
132-
if not l:
133-
continue
134-
135-
lSource=l.source()
136-
if not lSource:
137-
continue
138-
139-
p=lSource.lastIndexOf("?")
140-
dbFName=lSource.left(p)+".db"
141-
142-
if dbFName==dbFileName and l.getLayerID()<>layer.getLayerID():
143-
self.removing=True
144-
QgsMapLayerRegistry.instance().removeMapLayer(l.getLayerID(),True)
145-
self.removing=False
130+
self.removing=True
131+
if layer.getLayerID()<>self.pointLayers[key].getLayerID():
132+
QgsMapLayerRegistry.instance().removeMapLayer(self.pointLayers[key].getLayerID(),True)
133+
if layer.getLayerID()<>self.lineLayers[key].getLayerID():
134+
QgsMapLayerRegistry.instance().removeMapLayer(self.lineLayers[key].getLayerID(),True)
135+
if layer.getLayerID()<>self.polygonLayers[key].getLayerID():
136+
QgsMapLayerRegistry.instance().removeMapLayer(self.polygonLayers[key].getLayerID(),True)
137+
self.removing=False
146138

147139
# removed map items of key <dbFileName>
148-
key=dbFileName.toLatin1().data()
149140
del self.dbConns[key]
150141
del self.pointLayers[key]
151142
del self.lineLayers[key]
@@ -156,7 +147,7 @@ def addDatabase(self,dbFileName,pointLayer,lineLayer,polygonLayer):
156147
"""Function provides possibility to add new OSM data.
157148
158149
It's called (mainly) from OSM data loader.
159-
New data (OSM database) is added into inner structures of DatabaseManager.
150+
New data (OSM database) is added into inner structures of OsmDatabaseManager.
160151
New database is automatically considered new current (!) OSM database.
161152
162153
@param dbFileName filename of new OSM database

python/plugins/osm/DlgDownloadOSM.py renamed to python/plugins/osm/OsmDownloadDlg.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""@package DlgDownloadOSM
1+
"""@package OsmDownloadDlg
22
Module provides simple way how to download OSM data.
33
First user is asked to choose download region, output file etc.
44
@@ -12,7 +12,7 @@
1212
"""
1313

1414

15-
from DlgDownloadOSM_ui import Ui_DlgDownloadOSM
15+
from OsmDownloadDlg_ui import Ui_OsmDownloadDlg
1616
from PyQt4.QtCore import *
1717
from PyQt4.QtGui import *
1818
from PyQt4.QtNetwork import *
@@ -21,7 +21,7 @@
2121
from qgis.core import *
2222

2323

24-
class DlgDownloadOSM(QDialog, Ui_DlgDownloadOSM):
24+
class OsmDownloadDlg(QDialog, Ui_OsmDownloadDlg):
2525
"""This is the main class of this module.
2626
It's direct descendant of "OSM Download" dialog.
2727
@@ -57,7 +57,11 @@ def __init__(self, plugin):
5757
self.downloadButton.setEnabled(False)
5858

5959
# determining default area for download
60-
currentExtent=plugin.canvas.extent()
60+
if QgsMapLayerRegistry.instance().count()>0:
61+
currentExtent=plugin.canvas.extent()
62+
else:
63+
# if no layer is loaded default download extent is "part of the Prague city center" :-D
64+
currentExtent=QgsRectangle(14.4271398308,50.0768156358,14.4324358906,50.0812613868)
6165

6266
# check whether the extent needs to be projected back to WGS84
6367
mapRenderer = plugin.canvas.mapRenderer()
@@ -67,7 +71,6 @@ def __init__(self, plugin):
6771
xform=QgsCoordinateTransform(crsMap, crsWgs84)
6872
currentExtent=xform.transformBoundingBox(currentExtent)
6973

70-
7174
self.latFromLineEdit.setText(QString("%1").arg(currentExtent.yMinimum(),0,'f',10))
7275
self.latToLineEdit.setText(QString("%1").arg(currentExtent.yMaximum(),0,'f',10))
7376
self.lonFromLineEdit.setText(QString("%1").arg(currentExtent.xMinimum(),0,'f',10))

0 commit comments

Comments
 (0)