Skip to content

Commit

Permalink
Update to OSM plugin from Lukas Berka:
Browse files Browse the repository at this point in the history
-classes and .ui,.py files renamed
-bugfixes


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11378 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Aug 14, 2009
1 parent 9327027 commit 405c748
Show file tree
Hide file tree
Showing 26 changed files with 221 additions and 241 deletions.
1 change: 1 addition & 0 deletions python/plugins/osm/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@

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


FILE (GLOB PYTHON_FILES *.py)
FILE (GLOB MAPTOOLS_PYTHON_FILES map_tools/*.py)
FILE (GLOB STYLE_FILES styles/*.style)
Expand Down
34 changes: 17 additions & 17 deletions python/plugins/osm/Makefile
@@ -1,31 +1,31 @@

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
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

all: $(GEN_FILES)

DlgLoadOSM_ui.py: ui_files/DlgLoadOSM.ui
pyuic4 -o DlgLoadOSM_ui.py ui_files/DlgLoadOSM.ui
OsmLoadDlg_ui.py: ui_files/OsmLoadDlg.ui
pyuic4 -o OsmLoadDlg_ui.py ui_files/OsmLoadDlg.ui

DlgSaveOSM_ui.py: ui_files/DlgSaveOSM.ui
pyuic4 -o DlgSaveOSM_ui.py ui_files/DlgSaveOSM.ui
OsmSaveDlg_ui.py: ui_files/OsmSaveDlg.ui
pyuic4 -o OsmSaveDlg_ui.py ui_files/OsmSaveDlg.ui

DlgDownloadOSM_ui.py: ui_files/DlgDownloadOSM.ui
pyuic4 -o DlgDownloadOSM_ui.py ui_files/DlgDownloadOSM.ui
OsmDownloadDlg_ui.py: ui_files/OsmDownloadDlg.ui
pyuic4 -o OsmDownloadDlg_ui.py ui_files/OsmDownloadDlg.ui

DlgUploadOSM_ui.py: ui_files/DlgUploadOSM.ui
pyuic4 -o DlgUploadOSM_ui.py ui_files/DlgUploadOSM.ui
OsmUploadDlg_ui.py: ui_files/OsmUploadDlg.ui
pyuic4 -o OsmUploadDlg_ui.py ui_files/OsmUploadDlg.ui

DockWidget_ui.py: ui_files/DockWidget.ui
pyuic4 -o DockWidget_ui.py ui_files/DockWidget.ui
OsmFeatureDW_ui.py: ui_files/OsmFeatureDW.ui
pyuic4 -o OsmFeatureDW_ui.py ui_files/OsmFeatureDW.ui

DlgAddRelation_ui.py: ui_files/DlgAddRelation.ui
pyuic4 -o DlgAddRelation_ui.py ui_files/DlgAddRelation.ui
OsmAddRelationDlg_ui.py: ui_files/OsmAddRelationDlg.ui
pyuic4 -o OsmAddRelationDlg_ui.py ui_files/OsmAddRelationDlg.ui

DockUndoRedo_ui.py: ui_files/DockUndoRedo.ui
pyuic4 -o DockUndoRedo_ui.py ui_files/DockUndoRedo.ui
OsmUndoRedoDW_ui.py: ui_files/OsmUndoRedoDW.ui
pyuic4 -o OsmUndoRedoDW_ui.py ui_files/OsmUndoRedoDW.ui

DlgImport_ui.py: ui_files/DlgImport.ui
pyuic4 -o DlgImport_ui.py ui_files/DlgImport.ui
OsmImportDlg_ui.py: ui_files/OsmImportDlg.ui
pyuic4 -o OsmImportDlg_ui.py ui_files/OsmImportDlg.ui

resources.py: resources.qrc
pyrcc4 -o resources.py resources.qrc
Expand Down
@@ -1,14 +1,14 @@
"""@package DlgAddRelation
The main class of this module (DlgAddRelation) is descendant of "Create OSM Relation" dialog.
"""@package OsmAddRelationDlg
The main class of this module (OsmAddRelationDlg) is descendant of "Create OSM Relation" dialog.
The dialog either shows detail info on existing relation or is empty when no relation id is passed to constructor.
In brief this module (and its main class) just provides easy way to create or change OSM relation.
...
"""


from DlgAddRelation_ui import Ui_DlgAddRelation
from map_tools.IdentifyMapTool import IdentifyMapTool
from OsmAddRelationDlg_ui import Ui_OsmAddRelationDlg
from map_tools.OsmIdentifyMT import OsmIdentifyMT

from PyQt4.QtCore import *
from PyQt4.QtGui import *
Expand All @@ -21,11 +21,11 @@



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


Expand Down Expand Up @@ -208,7 +208,7 @@ def __startIdentifyingMember(self):
"""

if self.chooseMemberButton.isChecked():
self.mapTool=IdentifyMapTool(self.canvas, self.dockWidget, self.dbm)
self.mapTool=OsmIdentifyMT(self.canvas, self.dockWidget, self.dbm)
self.canvas.setMapTool(self.mapTool)
self.canvas.setCursor(QCursor(Qt.ArrowCursor))
self.canvas.setFocus(Qt.OtherFocusReason)
Expand Down
@@ -1,7 +1,7 @@
"""@package DatabaseManager
"""@package OsmDatabaseManager
This module provides methods to manipulate with database where OSM data are stored.
DatabaseManager is the only part of OSM Plugin that has the right to access OSM (sqlite) database.
OsmDatabaseManager is the only part of OSM Plugin that has the right to access OSM (sqlite) database.
If any other part of plugin wants to manipulate with OSM data, it is expected to use constructs of this module.
This module can manage more than one database at a time.
Expand All @@ -21,10 +21,10 @@



class DatabaseManager:
"""This is the only class of DatabaseManager module. Its purpose is to manage work with OSM databases.
class OsmDatabaseManager:
"""This is the only class of OsmDatabaseManager module. Its purpose is to manage work with OSM databases.
DatabaseManager class provides method to add new OSM database.
OsmDatabaseManager class provides method to add new OSM database.
It holds all connections to all databases and holds the information
on which database is currently used with all operations.
Expand All @@ -38,7 +38,7 @@ class DatabaseManager:
def __init__(self,plugin):
"""The constructor.
Initializes inner structures of DatabaseManager and connect signals to appropriate slots.
Initializes inner structures of OsmDatabaseManager and connect signals to appropriate slots.
"""

self.plugin=plugin
Expand Down Expand Up @@ -124,28 +124,19 @@ def layerRemoved(self,layerID):
layerSource=layer.source()
pos=layerSource.lastIndexOf("?")
dbFileName=layerSource.left(pos)+".db"
key=dbFileName.toLatin1().data()

# remove all map layers that belong to dbFileName database
allLayers=QgsMapLayerRegistry.instance().mapLayers()
for ix in allLayers.keys():
l=allLayers[ix] # layer object
if not l:
continue

lSource=l.source()
if not lSource:
continue

p=lSource.lastIndexOf("?")
dbFName=lSource.left(p)+".db"

if dbFName==dbFileName and l.getLayerID()<>layer.getLayerID():
self.removing=True
QgsMapLayerRegistry.instance().removeMapLayer(l.getLayerID(),True)
self.removing=False
self.removing=True
if layer.getLayerID()<>self.pointLayers[key].getLayerID():
QgsMapLayerRegistry.instance().removeMapLayer(self.pointLayers[key].getLayerID(),True)
if layer.getLayerID()<>self.lineLayers[key].getLayerID():
QgsMapLayerRegistry.instance().removeMapLayer(self.lineLayers[key].getLayerID(),True)
if layer.getLayerID()<>self.polygonLayers[key].getLayerID():
QgsMapLayerRegistry.instance().removeMapLayer(self.polygonLayers[key].getLayerID(),True)
self.removing=False

# removed map items of key <dbFileName>
key=dbFileName.toLatin1().data()
del self.dbConns[key]
del self.pointLayers[key]
del self.lineLayers[key]
Expand All @@ -156,7 +147,7 @@ def addDatabase(self,dbFileName,pointLayer,lineLayer,polygonLayer):
"""Function provides possibility to add new OSM data.
It's called (mainly) from OSM data loader.
New data (OSM database) is added into inner structures of DatabaseManager.
New data (OSM database) is added into inner structures of OsmDatabaseManager.
New database is automatically considered new current (!) OSM database.
@param dbFileName filename of new OSM database
Expand Down
@@ -1,4 +1,4 @@
"""@package DlgDownloadOSM
"""@package OsmDownloadDlg
Module provides simple way how to download OSM data.
First user is asked to choose download region, output file etc.
Expand All @@ -12,7 +12,7 @@
"""


from DlgDownloadOSM_ui import Ui_DlgDownloadOSM
from OsmDownloadDlg_ui import Ui_OsmDownloadDlg
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtNetwork import *
Expand All @@ -21,7 +21,7 @@
from qgis.core import *


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

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

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


self.latFromLineEdit.setText(QString("%1").arg(currentExtent.yMinimum(),0,'f',10))
self.latToLineEdit.setText(QString("%1").arg(currentExtent.yMaximum(),0,'f',10))
self.lonFromLineEdit.setText(QString("%1").arg(currentExtent.xMinimum(),0,'f',10))
Expand Down

0 comments on commit 405c748

Please sign in to comment.