[QGIS Commit] r11603 - in trunk/qgis: python/plugins/osm python/plugins/osm/images python/plugins/osm/styles python/plugins/osm/ui_files src/providers/osm src/python

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Sep 9 08:16:25 EDT 2009


Author: jef
Date: 2009-09-09 08:16:24 -0400 (Wed, 09 Sep 2009)
New Revision: 11603

Added:
   trunk/qgis/python/plugins/osm/images/osm_clearUndoRedo.png
   trunk/qgis/python/plugins/osm/images/osm_generateTags.png
   trunk/qgis/python/plugins/osm/images/osm_removeFeat.png
   trunk/qgis/python/plugins/osm/images/osm_removeMember.png
   trunk/qgis/python/plugins/osm/images/osm_removeTag.png
Modified:
   trunk/qgis/python/plugins/osm/OsmAddRelationDlg.py
   trunk/qgis/python/plugins/osm/OsmDatabaseManager.py
   trunk/qgis/python/plugins/osm/OsmFeatureDW.py
   trunk/qgis/python/plugins/osm/OsmLoadDlg.py
   trunk/qgis/python/plugins/osm/OsmPlugin.py
   trunk/qgis/python/plugins/osm/OsmSaveDlg.py
   trunk/qgis/python/plugins/osm/OsmUndoRedoDW.py
   trunk/qgis/python/plugins/osm/OsmUploadDlg.py
   trunk/qgis/python/plugins/osm/__init__.py
   trunk/qgis/python/plugins/osm/images/osm_identify.png
   trunk/qgis/python/plugins/osm/images/osm_move.png
   trunk/qgis/python/plugins/osm/images/osm_questionMark.png
   trunk/qgis/python/plugins/osm/images/osm_urDetails.png
   trunk/qgis/python/plugins/osm/resources.qrc
   trunk/qgis/python/plugins/osm/styles/big_scale.style
   trunk/qgis/python/plugins/osm/styles/medium_scale.style
   trunk/qgis/python/plugins/osm/styles/small_scale.style
   trunk/qgis/python/plugins/osm/ui_files/OsmAddRelationDlg.ui
   trunk/qgis/python/plugins/osm/ui_files/OsmFeatureDW.ui
   trunk/qgis/src/providers/osm/osmhandler.cpp
   trunk/qgis/src/providers/osm/osmprovider.cpp
   trunk/qgis/src/providers/osm/osmprovider.h
   trunk/qgis/src/python/qgspythonutilsimpl.cpp
Log:
OSM plugin & provider update from Lukas Berka:
- new OSM style files !! map looks pretty good now... (finally)
- new icons !
- some texts on dialogs were changed and completed
- "Saving OSM into file" functionality was improved a little...
- now OSM Plugin verify if osm provider is available...
- fixed some problems with encoding... ascii --> utf-8
- removing all OSM layers automatically after disabling OSM plugin in plugin manager
- some dialogs has been renamed
- other small bugfixes ...

Thanks.



Modified: trunk/qgis/python/plugins/osm/OsmAddRelationDlg.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmAddRelationDlg.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmAddRelationDlg.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -18,6 +18,7 @@
 from qgis.gui import *
 
 import sqlite3
+import unicodedata
 
 
 
@@ -47,9 +48,9 @@
 
         # set icons for tool buttons (identify,move,createPoint,createLine,createPolygon)
         self.chooseMemberButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_identify.png"))
-        self.removeMemberButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_remove.png"))
-        self.removeTagButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_remove.png"))
-        self.loadStandardTagsButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_star.png"))
+        self.removeMemberButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_removeMember.png"))
+        self.removeTagButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_removeTag.png"))
+        self.loadStandardTagsButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_generateTags.png"))
         self.typeInfoButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_questionMark.png"))
 
         self.info = dict()
@@ -101,6 +102,7 @@
         self.relTagsTable.setSelectionMode(QAbstractItemView.ExtendedSelection)
         self.relMembersTable.setSelectionBehavior(QAbstractItemView.SelectRows)
         self.relTagsTable.setSelectionBehavior(QAbstractItemView.SelectRows)
+        self.typeInfoButton.setEnabled(False)
 
 
     def connectDlgSignals(self):
@@ -283,6 +285,11 @@
 
             # adding new tag to table
             if column==0:
+
+                # only ascii keys are allowed
+                nkfd_form=unicodedata.normalize('NFKD', unicode(key.toUtf8(),'utf-8'))
+                key_only_ascii=nkfd_form.encode('ASCII', 'ignore')
+
                 newLastRow = row+1
                 self.relTagsTable.setRowCount(row+2)
                 self.relTagsTable.setItem(newLastRow,0,QTableWidgetItem(self.newTagLabel))
@@ -292,6 +299,7 @@
 
                 self.relTagsTable.item(row,0).setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
                 self.relTagsTable.item(row,1).setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
+                self.relTagsTable.item(row,0).setText(QString(key_only_ascii))
 
 
     def __onMembersCellChanged(self,row,column):
@@ -426,8 +434,10 @@
         # if non-standard typename was set up, loadStandardTagsButton is useless
         if typeName.toAscii().data() in self.relationTypes:
             self.loadStandardTagsButton.setEnabled(True)
+            self.typeInfoButton.setEnabled(True)
         else:
             self.loadStandardTagsButton.setEnabled(False)
+            self.typeInfoButton.setEnabled(False)
 
 
     def determineSuitableMemberRoles(self,relType):

Modified: trunk/qgis/python/plugins/osm/OsmDatabaseManager.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmDatabaseManager.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmDatabaseManager.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -40,7 +40,6 @@
 
         Initializes inner structures of OsmDatabaseManager and connect signals to appropriate slots.
         """
-
         self.plugin=plugin
         self.canvas=plugin.canvas
 
@@ -50,6 +49,7 @@
         self.polygonLayers={}
         self.currentKey=None
         self.removing=False
+        self.mapReg=QgsMapLayerRegistry.instance()
 
         QObject.connect(self.plugin.iface,SIGNAL("currentLayerChanged(QgsMapLayer*)"),self.currLayerChanged)
         QObject.connect(QgsMapLayerRegistry.instance(),SIGNAL("layerWillBeRemoved(QString)"),self.layerRemoved)
@@ -72,14 +72,18 @@
         # set new currentKey and tell all other plugin components
         if not layer:
             self.currentKey=None
-            self.plugin.undoredo.databaseChanged(None)
-            self.plugin.dockWidget.databaseChanged(None)
+            if self.plugin.undoredo<>None:
+                self.plugin.undoredo.databaseChanged(None)
+            if self.plugin.dockWidget<>None:
+                self.plugin.dockWidget.databaseChanged(None)
             return
 
         if layer.type() != QgsMapLayer.VectorLayer or layer.dataProvider().name()<>"osm":
             self.currentKey=None
-            self.plugin.undoredo.databaseChanged(None)
-            self.plugin.dockWidget.databaseChanged(None)
+            if self.plugin.undoredo<>None:
+                self.plugin.undoredo.databaseChanged(None)
+            if self.plugin.dockWidget<>None:
+                self.plugin.dockWidget.databaseChanged(None)
             return
 
         # find out filename of new current database
@@ -89,12 +93,18 @@
 
         if dbFileName not in self.dbConns.keys():
             self.currentKey=None
+            if self.plugin.undoredo<>None:
+                self.plugin.undoredo.databaseChanged(None)
+            if self.plugin.dockWidget<>None:
+                self.plugin.dockWidget.databaseChanged(None)
             return
 
         if dbFileName.toLatin1().data()<>self.currentKey:
             self.currentKey=dbFileName.toLatin1().data()
-            self.plugin.undoredo.databaseChanged(self.currentKey)
-            self.plugin.dockWidget.databaseChanged(self.currentKey)
+            if self.plugin.undoredo<>None:
+                self.plugin.undoredo.databaseChanged(self.currentKey)
+            if self.plugin.dockWidget<>None:
+                self.plugin.dockWidget.databaseChanged(self.currentKey)
 
 
     def layerRemoved(self,layerID):
@@ -112,7 +122,7 @@
             return
 
         # get appropriate qgsvectorlayer object
-        layer=QgsMapLayerRegistry.instance().mapLayer(layerID)
+        layer=self.mapReg.mapLayer(layerID)
 
         if not layer:
             return            # strange situation
@@ -126,23 +136,51 @@
         dbFileName=layerSource.left(pos)+".db"
         key=dbFileName.toLatin1().data()
 
-        # remove all map layers that belong to dbFileName database
+        # remove map layers that belong to dbFileName database
+        if key in self.lineLayers.keys() and layer.getLayerID()==self.lineLayers[key].getLayerID():
+            del self.lineLayers[key]
+
+        elif key in self.pointLayers.keys() and layer.getLayerID()==self.pointLayers[key].getLayerID():
+            del self.pointLayers[key]
+            if key in self.lineLayers.keys():
+                if self.lineLayers[key]:
+                    lineLayID=self.lineLayers[key].getLayerID()
+                    self.mapReg.removeMapLayer(lineLayID,True)
+
+        elif key in self.polygonLayers.keys() and layer.getLayerID()==self.polygonLayers[key].getLayerID():
+            del self.polygonLayers[key]
+            if key in self.pointLayers.keys():
+                if self.pointLayers[key]:
+                    pointLayID=self.pointLayers[key].getLayerID()
+                    self.mapReg.removeMapLayer(pointLayID,True)
+
+        if key in self.dbConns.keys():
+            del self.dbConns[key]
+
+
+    def removeAllOsmLayers(self):
+
+        # remove all map layers with osm provider set
         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)
+        allLayers=QgsMapLayerRegistry.instance().mapLayers()
+
+        for ix in allLayers.keys():
+
+            layer=allLayers[ix]    # layer object
+            if not layer:
+                continue
+
+            if layer.type()==QgsMapLayer.VectorLayer and layer.dataProvider().name()=="osm":
+                QgsMapLayerRegistry.instance().removeMapLayer(layer.getLayerID(),True)
+
+        self.dbConns={}    # map dbFileName->sqlite3ConnectionObject
+        self.pointLayers={}
+        self.lineLayers={}
+        self.polygonLayers={}
+        self.currentKey=None
         self.removing=False
 
-        # removed map items of key <dbFileName>
-        del self.dbConns[key]
-        del self.pointLayers[key]
-        del self.lineLayers[key]
-        del self.polygonLayers[key]
 
-
     def addDatabase(self,dbFileName,pointLayer,lineLayer,polygonLayer):
         """Function provides possibility to add new OSM data.
 
@@ -1661,7 +1699,7 @@
                 ,{"objId":str(featId),"objType":str(osmType)})
 
         for tagRec in c:
-            tags.append((tagRec[0],tagRec[1]))
+            tags.append((tagRec[0],tagRec[1].encode('utf-8')))
 
         c.close()
         return tags
@@ -1709,7 +1747,7 @@
         c=self.getConnection().cursor()
 
         c.execute("update tag set val=:tagVal where object_id=:objId and object_type=:objType and key=:tagKey and u=1"
-                ,{"tagVal":tagValue,"objId":str(featId),"objType":osmType,"tagKey":tagKey})
+                ,{"tagVal":unicode(tagValue,'utf-8'),"objId":str(featId),"objType":osmType,"tagKey":tagKey})
 
         for rec in c:
             val=rec[0]
@@ -1889,7 +1927,7 @@
         osmType=self.convertToOsmType(featType)
         c=self.getConnection().cursor()
         c.execute("update tag set val=:val where object_id=:objId and object_type=:objType and key=:key and u=1"
-                 ,{"val":value,"objId":str(featId),"objType":osmType,"key":key})
+                 ,{"val":unicode(value,'utf-8'),"objId":str(featId),"objType":osmType,"key":str(key)})
         c.close()
         self.commit()
 
@@ -1902,6 +1940,11 @@
         @return True if given tag already exists for given feature; False otherwise
         """
 
+        if key==None:
+            return False
+        if len(key)==0:
+            return False
+
         tagEx=False
         osmType=self.convertToOsmType(featType)
         c=self.getConnection().cursor()
@@ -1990,10 +2033,14 @@
         @param doCommit if True then commit is performed after tag insertion
         """
 
+        val=''
+        if value<>None:
+            val=unicode(value,'utf-8')
+
         osmType=self.convertToOsmType(featType)
         c=self.getConnection().cursor()
         c.execute("insert into tag (object_id, object_type, key, val) values (:objId, :objType, :key, :val)"
-                 ,{"objId":str(featId),"objType":osmType,"key":key,"val":value})
+                 ,{"objId":str(featId),"objType":osmType,"key":str(key),"val":val})
         c.close()
         if doCommit:
           self.commit()
@@ -2029,7 +2076,7 @@
         osmType=self.convertToOsmType(featType)
         c=self.getConnection().cursor()
         c.execute("delete from tag where object_id=:objId and object_type=:objType and key=:key and u=1"
-                ,{"objId":str(featId),"objType":osmType,"key":key})
+                ,{"objId":str(featId),"objType":osmType,"key":str(key)})
         c.close()
         self.commit()
 

Modified: trunk/qgis/python/plugins/osm/OsmFeatureDW.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmFeatureDW.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmFeatureDW.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-99
 """@package OsmFeatureDW
 This module is descendant of "OSM Feature" dockable widget and makes user able
 to view and edit information on selected OSM feature.
@@ -24,6 +25,7 @@
 from map_tools.OsmCreatePolygonMT import OsmCreatePolygonMT
 from map_tools.OsmMoveMT import OsmMoveMT
 from map_tools.OsmIdentifyMT import OsmIdentifyMT
+import unicodedata
 
 
 class OsmFeatureDW(QDockWidget, Ui_OsmFeatureDW,  object):
@@ -54,8 +56,8 @@
         self.createLineButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_createLine.png"))
         self.createPolygonButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_createPolygon.png"))
         self.createRelationButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_createRelation.png"))
-        self.removeButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_remove.png"))
-        self.deleteTagsButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_remove.png"))
+        self.removeButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_removeFeat.png"))
+        self.deleteTagsButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_removeTag.png"))
         self.undoButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_undo.png"))
         self.redoButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_redo.png"))
         self.addRelationButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_addRelation.png"))
@@ -432,7 +434,7 @@
 
             # store tag's change into database
             self.plugin.undoredo.startAction("Change tag value.")
-            self.plugin.dbm.changeTagValue(self.feature.id(),self.featureType,key.toUtf8().data(),value.toUtf8().data())
+            self.plugin.dbm.changeTagValue(self.feature.id(),self.featureType,key.toAscii().data(),value.toUtf8())
         else:
             key = self.tagTable.item(row,0).text()
             if key=="" or key==self.newTagLabel:
@@ -441,23 +443,28 @@
             # adding new tag and setting its key
             if column==0:
 
+                # only ascii keys are allowed
+                nkfd_form=unicodedata.normalize('NFKD', unicode(key.toUtf8(),'utf-8'))
+                key_only_ascii=nkfd_form.encode('ASCII', 'ignore')
+
                 # store it into database
-                isAlreadyDef=self.plugin.dbm.isTagDefined(self.feature.id(),self.featureType,key.toUtf8().data())
+                isAlreadyDef=self.plugin.dbm.isTagDefined(self.feature.id(),self.featureType,key_only_ascii)
                 if isAlreadyDef:
                     # such a key already exists for this relation
                     self.tagTable.setItem(row,0,QTableWidgetItem(self.newTagLabel))
                     QMessageBox.information(self, self.tr("OSM Feature Dock Widget")
-                        ,self.tr("Property '%1' cannot be added twice.").arg(key.toUtf8().data()))
+                        ,self.tr(QString("Property '").append(key_only_ascii).append("' cannot be added twice.")))
                     return
 
                 # well, insert new tag into database
                 self.plugin.undoredo.startAction("Insert new tag.")
-                self.plugin.dbm.insertTag(self.feature.id(),self.featureType,key.toUtf8().data(),'')
+                self.plugin.dbm.insertTag(self.feature.id(),self.featureType,key_only_ascii,None)
 
                 self.__tagsLoaded=False
 
                 self.tagTable.item(row,0).setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
                 self.tagTable.item(row,1).setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
+                self.tagTable.item(row,0).setText(QString(key_only_ascii))
 
                 newLastRow = row+1
                 self.tagTable.setRowCount(row+2)
@@ -488,7 +495,8 @@
         self.plugin.dbm.recacheAffectedNow(affected)
 
         # refresh map canvas so that changes take effect
-        self.plugin.canvas.refresh()
+        if column==1:
+            self.plugin.canvas.refresh()
 
 
     def __onTagsItemDoubleClicked(self,item):
@@ -1236,7 +1244,7 @@
                 self.plugin.dbm.changeRelationStatus(self.feature.id(),'N','U')
 
             # perform tag removing 
-            self.plugin.dbm.removeTag(self.feature.id(),self.featureType,key.toUtf8().data())
+            self.plugin.dbm.removeTag(self.feature.id(),self.featureType,key.toAscii().data())
 
             self.tagTable.removeRow(ix)
 
@@ -1425,8 +1433,8 @@
         self.tagTable.setHorizontalHeaderItem(1,QTableWidgetItem("Value"))
 
         for i in range(0,rowCount):
-            self.tagTable.setItem(i,0,QTableWidgetItem(tableData[i][0]))
-            self.tagTable.setItem(i,1,QTableWidgetItem(tableData[i][1]))
+            self.tagTable.setItem(i,0,QTableWidgetItem(QString.fromUtf8(tableData[i][0])))
+            self.tagTable.setItem(i,1,QTableWidgetItem(QString.fromUtf8(tableData[i][1])))
             self.tagTable.item(i,0).setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
             self.tagTable.item(i,1).setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
 

Modified: trunk/qgis/python/plugins/osm/OsmLoadDlg.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmLoadDlg.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmLoadDlg.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -214,11 +214,9 @@
 
             st=self.styles[self.styleCombo.currentIndex()]
             if st=="Small scale":
-                rect=QgsRectangle(midX-rX/6,midY-rY/6,midX+rX/6,midY+rY/6)
+                rect=QgsRectangle(midX-rX/5,midY-rY/5,midX+rX/5,midY+rY/5)
             elif st=="Medium scale":
-                rect=QgsRectangle(midX-rX/3,midY-rY/3,midX+rX/3,midY+rY/3)
-            else:
-               rect=QgsRectangle(midX-rX/1.2,midY-rY/1.2,midX+rX/1.2,midY+rY/1.2)
+                rect=QgsRectangle(midX-rX/2,midY-rY/2,midX+rX/2,midY+rY/2)
 
         self.canvas.setExtent(rect)
         self.canvas.refresh()
@@ -310,6 +308,7 @@
                     self.progress = None
                     QMessageBox.information(self,"Error",QString("Failed to load layers: %1")
                             .arg(self.property("osm_failure").toString()))
+                    self.buttonBox.setEnabled(True)
 
             qApp.processEvents()
         return QDialog.event(self,e)

Modified: trunk/qgis/python/plugins/osm/OsmPlugin.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmPlugin.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmPlugin.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -34,6 +34,15 @@
 
 
 
+def versionNumber():
+    """Returns current version number of OpenStreetMap plugin.
+
+    @return current version number of the plugin
+    """
+    return "0.5"
+
+
+
 class OsmPlugin:
     """OsmPlugin is the main class OSM Plugin module.
 
@@ -164,11 +173,16 @@
 
         del self.dockWidget
         del self.undoredo
+        self.dockWidget=None
+        self.undoredo=None
 
         # remove toolbar
         del self.toolBar
 
+        # w/o osm plugin we don't need osm layers
+        self.dbm.removeAllOsmLayers()
 
+
     def loadOsmFromFile(self):
         """Function shows up the "Load OSM from file" dialog.
 
@@ -206,6 +220,10 @@
         according to dialog's return code.
         """
 
+        if 'osm' not in QgsProviderRegistry.instance().providerList():
+            QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
+            return
+
         if not self.dbm.currentKey:
             QMessageBox.information(QWidget(), QString("OSM Save to file")
                 ,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
@@ -227,6 +245,10 @@
         according to dialog's return code.
         """
 
+        if 'osm' not in QgsProviderRegistry.instance().providerList():
+            QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
+            return
+
         self.dlgDownload=OsmDownloadDlg(self)
         self.dlgDownload.exec_()
         if not self.dlgDownload.httpSuccess:
@@ -270,6 +292,10 @@
         according to dialog's return code.
         """
 
+        if 'osm' not in QgsProviderRegistry.instance().providerList():
+            QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
+            return
+
         # first check if there are some data; if not upload doesn't have sense
         if not self.dbm.currentKey:
             QMessageBox.information(QWidget(), QString("OSM Upload")
@@ -288,6 +314,10 @@
         according to dialog's return code.
         """
 
+        if 'osm' not in QgsProviderRegistry.instance().providerList():
+            QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
+            return
+
         if self.dbm.currentKey is None:
             QMessageBox.information(self.iface.mainWindow(), "OSM Import"
                 ,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \

Modified: trunk/qgis/python/plugins/osm/OsmSaveDlg.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmSaveDlg.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmSaveDlg.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -14,7 +14,6 @@
 from PyQt4 import *
 from sip import unwrapinstance
 from qgis.core import QgsVectorLayer, QgsMapLayerRegistry
-#from sip import *
 
 import sqlite3
 
@@ -44,6 +43,10 @@
         self.progressDialog.setModal(True)
         self.progressDialog.setAutoClose(False)
 
+        # variables for identifiers of all objects that will be saved to output file
+        self.nodeIds=set()
+
+        # connecting dialog and progressbar signals
         QObject.connect(self.browseOSMButton,SIGNAL("clicked()"),self.showSaveFileDialog)
         QObject.connect(self.buttonBox,SIGNAL("accepted()"),self.onOK)
         QObject.connect(self.progressDialog, SIGNAL("canceled()"), self.cancelSaving)
@@ -62,15 +65,10 @@
         self.outFile.remove()
         self.outFile=None
 
-#        if self.xml.device().isOpen():
-#            self.xml.device().close()
-
         # close the whole Save OSM dialog
         self.close()
 
-        # todo: segfault... why????
 
-
     def showSaveFileDialog(self):
         """Function opens dialog for selecting XML file.
 
@@ -98,7 +96,8 @@
         It performs all actions neccessary for OSM data saving.
         """
 
-        # after closing a dialog, we want to save data into osm
+        # prepare data
+
         self.fname=self.OSMFileEdit.text()
         self.outFile=QFile(self.fname)
 
@@ -118,8 +117,7 @@
         self.xml.setCodec(QTextCodec.codecForName("utf-8"))
         self.xml.setAutoFormatting(True)
 
-        self.dbConnection=sqlite3.connect(self.plugin.dbFileName.toLatin1().data())
-        c=self.dbConnection.cursor()
+        c=self.dbm.getConnection().cursor()
 
         cntPoints=cntLines=cntPolys=cntRels=0
         c.execute("select count(*) from node")
@@ -146,23 +144,36 @@
         self.progressDialog.setValue(0)
         self.progressDialog.show()
 
-        # todo: <bounds> element?
-        # todo: and what about uid? changeset? are they compulsory?
+        # <bounds> element
+        dataExtent=self.plugin.canvas.extent()
+        self.xml.writeEmptyElement("bounds")
+        self.xml.writeAttribute("minlat",str(dataExtent.yMinimum()))
+        self.xml.writeAttribute("minlon",str(dataExtent.xMinimum()))
+        self.xml.writeAttribute("maxlat",str(dataExtent.yMaximum()))
+        self.xml.writeAttribute("maxlon",str(dataExtent.xMaximum()))
 
+        # todo: uid and changeset attributes are not compulsory! support for them in future!
+
         if points:
             self.progressDialog.setLabelText(self.tr("Saving nodes..."))
             self.progressDialog.setMaximum(cntPoints)
             self.progressDialog.setValue(0)
             i=0
 
-            c.execute("select n.id,n.lat,n.lon,v.version_id,n.user,n.timestamp from \
-                       node n,version v where v.object_id=n.id and v.object_type='node'")
-            for rec in c:
+            c.execute("select n.id,n.lat,n.lon,v.version_id,n.user,n.timestamp from node n, version v \
+                       where n.status<>'R' and n.u=1 and v.object_id=n.id and v.object_type='node' \
+                       and n.lat>=:minLat AND n.lat<=:maxLat AND n.lon>=:minLon AND n.lon<=:maxLon"
+                       ,{"minLat":dataExtent.yMinimum(),"maxLat":dataExtent.yMaximum()
+                        ,"minLon":dataExtent.xMinimum(),"maxLon":dataExtent.xMaximum()})
+
+            for (nid,lat,lon,ver,usr,tms) in c:
                 anyTags=False
                 tagList=[]
 
+                self.nodeIds.add(nid)
+
                 if tags:
-                    tagList=self.dbm.getFeatureTags(rec[0],'Point')
+                    tagList=self.dbm.getFeatureTags(nid,'Point')
                     if len(tagList)>0:
                         anyTags=True
 
@@ -171,22 +182,22 @@
                 else:
                     self.xml.writeEmptyElement("node")
 
-                self.xml.writeAttribute("id",str(rec[0]))
-                self.xml.writeAttribute("lat",str(rec[1]))
-                self.xml.writeAttribute("lon",str(rec[2]))
-                self.xml.writeAttribute("version",str(rec[3]))
-                self.xml.writeAttribute("user",rec[4])
+                self.xml.writeAttribute("id",str(nid))
+                self.xml.writeAttribute("lat",str(lat))
+                self.xml.writeAttribute("lon",str(lon))
+                self.xml.writeAttribute("version",str(ver))
+                if usr<>"":
+                    self.xml.writeAttribute("user",usr)
                 self.xml.writeAttribute("visible","true")
-                self.xml.writeAttribute("timestamp",rec[5])
+                self.xml.writeAttribute("timestamp",tms)
 
                 if anyTags:
                     for r in tagList:
                         self.xml.writeEmptyElement("tag")
                         self.xml.writeAttribute("k",r[0])
                         self.xml.writeAttribute("v",r[1])
+                    self.xml.writeEndElement()
 
-                if anyTags:
-                    self.xml.writeEndElement()
                 i=i+1
                 self.progressDialog.setValue(i)
 
@@ -197,31 +208,90 @@
             i=0
 
             c.execute("select w.id,v.version_id,w.user,w.timestamp from way w,version v \
-                       where w.closed=0 and v.object_id=w.id and v.object_type='way'")
-            for rec in c:
+                       where w.closed=0 and w.status<>'R' and w.u=1 and v.object_id=w.id and v.object_type='way' \
+                       and (((w.max_lat between :minLat and :maxLat) or (w.min_lat between :minLat and :maxLat) or (w.min_lat<:minLat and w.max_lat>:maxLat)) \
+                         and ((w.max_lon between :minLon and :maxLon) or (w.min_lon between :minLon and :maxLon) or (w.min_lon<:minLon and w.max_lon>:maxLon)))"
+                       ,{"minLat":dataExtent.yMinimum(),"maxLat":dataExtent.yMaximum()
+                        ,"minLon":dataExtent.xMinimum(),"maxLon":dataExtent.xMaximum()})
+
+            for (lid,ver,usr,tms) in c:
+
+                geom=self.dbm.getFeatureGeometry(lid,'Line')
+                if not geom.intersects(dataExtent):
+                    continue
+
                 self.xml.writeStartElement("way")
-                self.xml.writeAttribute("id",str(rec[0]))
+                self.xml.writeAttribute("id",str(lid))
                 self.xml.writeAttribute("visible","true")
-                self.xml.writeAttribute("timestamp",rec[3])
-                self.xml.writeAttribute("version",str(rec[1]))
-                self.xml.writeAttribute("user",rec[2])
+                self.xml.writeAttribute("timestamp",tms)
+                self.xml.writeAttribute("version",str(ver))
+                if usr<>"":
+                    self.xml.writeAttribute("user",usr)
 
-                d=self.dbConnection.cursor()
-                d.execute("select node_id from way_member where way_id=:wayId",{"wayId":rec[0]})
+                d=self.dbm.getConnection().cursor()
+                d.execute("select node_id from way_member where way_id=:wayId",{"wayId":lid})
                 for r in d:
-                    self.xml.writeStartElement("nd")
+                    self.xml.writeEmptyElement("nd")
                     self.xml.writeAttribute("ref",str(r[0]))
-                    self.xml.writeEndElement()
                 d.close()
 
                 if tags:
-                    tagList=self.dbm.getFeatureTags(rec[0],'Line')
+                    tagList=self.dbm.getFeatureTags(lid,'Line')
                     for r in tagList:
                         self.xml.writeEmptyElement("tag")
                         self.xml.writeAttribute("k",r[0])
                         self.xml.writeAttribute("v",r[1])
 
                 self.xml.writeEndElement()
+
+                d=self.dbm.getConnection().cursor()
+                d.execute("select node_id from way_member where way_id=:wayId",{"wayId":lid})
+                for r in d:
+                    if r[0] not in self.nodeIds:
+
+                        e=self.dbm.getConnection().cursor()
+                        e.execute("select n.id,n.lat,n.lon,v.version_id,n.user,n.timestamp from node n, version v \
+                                   where n.id=:nid",{"nid":r[0]})
+                        for nodeRec in e:
+                            nid=nodeRec[0]
+                            lat=nodeRec[1]
+                            lon=nodeRec[2]
+                            ver=nodeRec[3]
+                            usr=nodeRec[4]
+                            tms=nodeRec[5]
+                        e.close()
+
+                        anyTags=False
+                        tagList=[]
+                        self.nodeIds.add(nid)
+
+                        if tags:
+                            tagList=self.dbm.getFeatureTags(nid,'Point')
+                            if len(tagList)>0:
+                                anyTags=True
+
+                        if anyTags:
+                            self.xml.writeStartElement("node")
+                        else:
+                            self.xml.writeEmptyElement("node")
+
+                        self.xml.writeAttribute("id",str(nid))
+                        self.xml.writeAttribute("lat",str(lat))
+                        self.xml.writeAttribute("lon",str(lon))
+                        self.xml.writeAttribute("version",str(ver))
+                        if usr<>"":
+                            self.xml.writeAttribute("user",usr)
+                        self.xml.writeAttribute("visible","true")
+                        self.xml.writeAttribute("timestamp",tms)
+
+                        if anyTags:
+                            for r in tagList:
+                                self.xml.writeEmptyElement("tag")
+                                self.xml.writeAttribute("k",r[0])
+                                self.xml.writeAttribute("v",r[1])
+                            self.xml.writeEndElement()
+
+                d.close()
                 i=i+1
                 self.progressDialog.setValue(i)
 
@@ -232,32 +302,95 @@
             i=0
 
             c.execute("select w.id,v.version_id,w.user,w.timestamp from way w,version v \
-                       where w.closed=1 and v.object_id=w.id and v.object_type='way'")
-            for rec in c:
+                       where w.closed=1 and w.status<>'R' and w.u=1 and v.object_id=w.id and v.object_type='way' \
+                       and (((w.max_lat between :minLat and :maxLat) or (w.min_lat between :minLat and :maxLat) or (w.min_lat<:minLat and w.max_lat>:maxLat)) \
+                         and ((w.max_lon between :minLon and :maxLon) or (w.min_lon between :minLon and :maxLon) or (w.min_lon<:minLon and w.max_lon>:maxLon)))"
+                       ,{"minLat":dataExtent.yMinimum(),"maxLat":dataExtent.yMaximum()
+                        ,"minLon":dataExtent.xMinimum(),"maxLon":dataExtent.xMaximum()})
+
+            for (pid,ver,usr,tms) in c:
+
+                geom=self.dbm.getFeatureGeometry(pid,'Polygon')
+                if not geom.intersects(dataExtent):
+                    continue
+
                 self.xml.writeStartElement("way")
-                self.xml.writeAttribute("id",str(rec[0]))
+                self.xml.writeAttribute("id",str(pid))
                 self.xml.writeAttribute("visible","true")
-                self.xml.writeAttribute("timestamp",rec[3])
-                self.xml.writeAttribute("version",str(rec[1]))
-                self.xml.writeAttribute("user",rec[2])
+                self.xml.writeAttribute("timestamp",tms)
+                self.xml.writeAttribute("version",str(ver))
+                if usr<>"":
+                    self.xml.writeAttribute("user",usr)
 
-                d=self.dbConnection.cursor()
-                d.execute("select node_id from way_member where way_id=:wayId",{"wayId":rec[0]})
+                d=self.dbm.getConnection().cursor()
+                d.execute("select node_id from way_member where way_id=:wayId",{"wayId":pid})
+                first=None
                 for r in d:
-                    self.xml.writeStartElement("nd")
+                    self.xml.writeEmptyElement("nd")
                     self.xml.writeAttribute("ref",str(r[0]))
-                    self.xml.writeEndElement()
-
+                    if first==None:
+                        first=r[0]
                 d.close()
+                self.xml.writeEmptyElement("nd")
+                self.xml.writeAttribute("ref",str(first))
 
                 if tags:
-                    tagList=self.dbm.getFeatureTags(rec[0],'Polygon')
+                    tagList=self.dbm.getFeatureTags(pid,'Polygon')
                     for r in tagList:
                         self.xml.writeEmptyElement("tag")
                         self.xml.writeAttribute("k",r[0])
                         self.xml.writeAttribute("v",r[1])
 
                 self.xml.writeEndElement()
+
+                d=self.dbm.getConnection().cursor()
+                d.execute("select node_id from way_member where way_id=:wayId",{"wayId":pid})
+                for r in d:
+                    if r[0] not in self.nodeIds:
+
+                        e=self.dbm.getConnection().cursor()
+                        e.execute("select n.id,n.lat,n.lon,v.version_id,n.user,n.timestamp from node n, version v \
+                                   where n.id=:nid",{"nid":r[0]})
+                        for nodeRec in e:
+                            nid=nodeRec[0]
+                            lat=nodeRec[1]
+                            lon=nodeRec[2]
+                            ver=nodeRec[3]
+                            usr=nodeRec[4]
+                            tms=nodeRec[5]
+                        e.close()
+
+                        anyTags=False
+                        tagList=[]
+                        self.nodeIds.add(nid)
+
+                        if tags:
+                            tagList=self.dbm.getFeatureTags(nid,'Point')
+                            if len(tagList)>0:
+                                anyTags=True
+
+                        if anyTags:
+                            self.xml.writeStartElement("node")
+                        else:
+                            self.xml.writeEmptyElement("node")
+
+                        self.xml.writeAttribute("id",str(nid))
+                        self.xml.writeAttribute("lat",str(lat))
+                        self.xml.writeAttribute("lon",str(lon))
+                        self.xml.writeAttribute("version",str(ver))
+                        if usr<>"":
+                            self.xml.writeAttribute("user",usr)
+                        self.xml.writeAttribute("visible","true")
+                        self.xml.writeAttribute("timestamp",tms)
+
+                        if anyTags:
+                            for r in tagList:
+                                self.xml.writeEmptyElement("tag")
+                                self.xml.writeAttribute("k",r[0])
+                                self.xml.writeAttribute("v",r[1])
+                            self.xml.writeEndElement()
+
+                d.close()
                 i=i+1
                 self.progressDialog.setValue(i)
 
@@ -268,36 +401,52 @@
             i=0
 
             c.execute("select r.id,v.version_id,r.user,r.timestamp from relation r,version v \
-                       where v.object_id=r.id and v.object_type='relation'")
-            for rec in c:
+                       where r.status<>'R' and r.u=1 and v.object_id=r.id and v.object_type='relation' \
+                       and ( \
+                           exists ( \
+                               select 1 from node n, relation_member rm \
+                               where rm.relation_id=r.id and n.status<>'R' and n.u=1 and rm.member_id=n.id and rm.member_type='node' \
+                               and n.lat>=:minLat and n.lat<=:maxLat and n.lon>=:minLon and n.lon<=:maxLon ) \
+                           or exists ( \
+                               select 1 from way w, relation_member rm \
+                               where rm.relation_id=r.id and w.status<>'R' and w.u=1 and rm.member_id=w.id and rm.member_type='way' \
+                               and (((w.max_lat between :minLat and :maxLat) or (w.min_lat between :minLat and :maxLat) or (w.min_lat<:minLat and w.max_lat>:maxLat)) \
+                                 and ((w.max_lon between :minLon and :maxLon) or (w.min_lon between :minLon and :maxLon) or (w.min_lon<:minLon and w.max_lon>:maxLon))) \
+                                  ))"
+                       ,{"minLat":dataExtent.yMinimum(),"maxLat":dataExtent.yMaximum()
+                        ,"minLon":dataExtent.xMinimum(),"maxLon":dataExtent.xMaximum()})
+
+            for (rid,ver,usr,tms) in c:
+
                 self.xml.writeStartElement("relation")
-                self.xml.writeAttribute("id",str(rec[0]))
+                self.xml.writeAttribute("id",str(rid))
                 self.xml.writeAttribute("visible","true")
-                self.xml.writeAttribute("timestamp",rec[3])
-                self.xml.writeAttribute("version",str(rec[1]))
-                self.xml.writeAttribute("user",rec[2])
+                self.xml.writeAttribute("timestamp",tms)
+                self.xml.writeAttribute("version",str(ver))
+                if usr<>"":
+                    self.xml.writeAttribute("user",usr)
 
-                d=self.dbConnection.cursor()
-                d.execute("select member_id,member_type,role from relation_member where relation_id=:relId",{"relId":rec[0]})
+                d=self.dbm.getConnection().cursor()
+                d.execute("select member_id,member_type,role from relation_member where relation_id=:relId",{"relId":rid})
                 for r in d:
-                    self.xml.writeStartElement("member")
+                    self.xml.writeEmptyElement("member")
                     self.xml.writeAttribute("type",r[1])
                     self.xml.writeAttribute("ref",str(r[0]))
                     self.xml.writeAttribute("role",r[2])
-                    self.xml.writeEndElement()
                 d.close()
 
                 if tags:
-                    tagList=self.dbm.getFeatureTags(rec[0],'Relation')
+                    tagList=self.dbm.getFeatureTags(rid,'Relation')
                     for r in tagList:
                         self.xml.writeEmptyElement("tag")
                         self.xml.writeAttribute("k",r[0])
                         self.xml.writeAttribute("v",r[1])
+                self.xml.writeEndElement()
 
-                self.xml.writeEndElement()
                 i=i+1
                 self.progressDialog.setValue(i)
 
+
         self.xml.writeEndElement()    # osm
         self.xml.writeEndDocument()
 

Modified: trunk/qgis/python/plugins/osm/OsmUndoRedoDW.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmUndoRedoDW.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmUndoRedoDW.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -43,7 +43,7 @@
 
         self.undoButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_undo.png"))
         self.redoButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_redo.png"))
-        self.clearButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_remove.png"))
+        self.clearButton.setIcon(QIcon(":/plugins/osm_plugin/images/osm_clearUndoRedo.png"))
 
         self.canvas=plugin.canvas
         self.iface=plugin.iface

Modified: trunk/qgis/python/plugins/osm/OsmUploadDlg.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmUploadDlg.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/OsmUploadDlg.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -16,6 +16,7 @@
 
 
 from ui_OsmUploadDlg import Ui_OsmUploadDlg
+import OsmPlugin
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
@@ -24,7 +25,6 @@
 from sys import *
 
 
-
 class OsmUploadDlg(QDialog, Ui_OsmUploadDlg):
     """Class provides simple way of uploading current OSM data.
 
@@ -917,7 +917,7 @@
         userCommentBytes=userComment.toUtf8()
 
         # create http request's body (create XML with info about uploaded way)
-        requestXml=QString("<osm>\n<changeset>\n<tag k=\"created_by\" v=\"QGIS OSM v0.5\"/>\n<tag k=\"comment\" v=\""+userCommentBytes.data()+"\"/>\n</changeset>\n</osm>")
+        requestXml=QString("<osm>\n<changeset>\n<tag k=\"created_by\" v=\"QGIS OSM v"+OsmPlugin.versionNumber()+"\"/>\n<tag k=\"comment\" v=\""+userCommentBytes.data()+"\"/>\n</changeset>\n</osm>")
 
         # send prepared request
         requestBytes=requestXml.toAscii()

Modified: trunk/qgis/python/plugins/osm/__init__.py
===================================================================
--- trunk/qgis/python/plugins/osm/__init__.py	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/__init__.py	2009-09-09 12:16:24 UTC (rev 11603)
@@ -38,10 +38,10 @@
 
     @return version of this plugin
     """
+    from OsmPlugin import versionNumber
+    return "Version "+versionNumber()
 
-    return "Version 0.5"
 
-
 def qgisMinimumVersion():
     """Function returns information on what minimum version
     of Quantum GIS this plugin works with.
@@ -58,7 +58,6 @@
     @return instance of OSM Plugin
     """
 
-    # load TestPlugin class from file testplug.py
     from OsmPlugin import OsmPlugin
     # return object of our plugin with reference to QGIS interface as the only argument
     return OsmPlugin(iface) 

Added: trunk/qgis/python/plugins/osm/images/osm_clearUndoRedo.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/python/plugins/osm/images/osm_clearUndoRedo.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/qgis/python/plugins/osm/images/osm_generateTags.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/python/plugins/osm/images/osm_generateTags.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/qgis/python/plugins/osm/images/osm_identify.png
===================================================================
(Binary files differ)

Modified: trunk/qgis/python/plugins/osm/images/osm_move.png
===================================================================
(Binary files differ)

Modified: trunk/qgis/python/plugins/osm/images/osm_questionMark.png
===================================================================
(Binary files differ)

Added: trunk/qgis/python/plugins/osm/images/osm_removeFeat.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/python/plugins/osm/images/osm_removeFeat.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/qgis/python/plugins/osm/images/osm_removeMember.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/python/plugins/osm/images/osm_removeMember.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/qgis/python/plugins/osm/images/osm_removeTag.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/python/plugins/osm/images/osm_removeTag.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/qgis/python/plugins/osm/images/osm_urDetails.png
===================================================================
(Binary files differ)

Modified: trunk/qgis/python/plugins/osm/resources.qrc
===================================================================
--- trunk/qgis/python/plugins/osm/resources.qrc	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/resources.qrc	2009-09-09 12:16:24 UTC (rev 11603)
@@ -51,9 +51,18 @@
         <file>images/osm_remove.png</file>
     </qresource>
     <qresource prefix="/plugins/osm_plugin" >
-        <file>images/osm_star.png</file>
+        <file>images/osm_removeFeat.png</file>
     </qresource>
     <qresource prefix="/plugins/osm_plugin" >
+        <file>images/osm_removeTag.png</file>
+    </qresource>
+    <qresource prefix="/plugins/osm_plugin" >
+        <file>images/osm_removeMember.png</file>
+    </qresource>
+    <qresource prefix="/plugins/osm_plugin" >
+        <file>images/osm_generateTags.png</file>
+    </qresource>
+    <qresource prefix="/plugins/osm_plugin" >
         <file>images/osm_questionMark.png</file>
     </qresource>
     <qresource prefix="/plugins/osm_plugin" >
@@ -62,4 +71,7 @@
     <qresource prefix="/plugins/osm_plugin" >
         <file>images/osm_redo.png</file>
     </qresource>
+    <qresource prefix="/plugins/osm_plugin" >
+        <file>images/osm_clearUndoRedo.png</file>
+    </qresource>
 </RCC>

Modified: trunk/qgis/python/plugins/osm/styles/big_scale.style
===================================================================
--- trunk/qgis/python/plugins/osm/styles/big_scale.style	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/styles/big_scale.style	2009-09-09 12:16:24 UTC (rev 11603)
@@ -1,34 +1,62 @@
 #LINE
-highway trunk 3 1 150,0,0
-highway primary 2 1 219,112,147
-highway secondary 1 1 255,120,0
-highway tertiary 0 0 238,230,133
-highway pedestrian 0 0 255,255,0
-highway residential 0 0 100,100,100
-highway footway 0 0 170,170,170
-highway * 1 1 210,200,210
-railway subway 1 2 131,111,255
-railway rail 1 4 0,0,0
-railway * 1 0 0,0,0
+highway trunk 1.3 1 170,221,170
+highway trunk_link 1.3 1 170,221,170
+highway primary 1.2 1 219,112,147
+highway secondary 1.2 1 255,221,170
+highway tertiary 1 1 238,230,133
+highway pedestrian 0.02 1 230,214,182
+highway residential 0.02 1 100,100,100
+highway living_street 0.05 1 207,207,190
+highway cycleway 0.05 3 0,115,255
+highway construction 0.05 2 204,238,221
+tracktype grade2 0.05 3 0,115,255
+highway track 0.04 2 181,164,130
+highway unsurfaced 0.08 2 230,214,182
+railway subway 0.01 2 187,187,187
+railway rail 0.01 4 120,120,120
+railway tram 0.01 1 119,136,119
+railway preserved 0.05 2 187,187,187
 boundary administrative 1 3 85,26,139
-power line 1 0 139,139,131
+waterway drain 0.2 1 135,206,255
+power line 0.1 1 139,139,131
 #POLYGON
-leisure park 0 1 0,0,0 88,245,168
-leisure garden 0 1 0,0,0 88,245,168
-landuse forest 0 1 0,0,0 88,245,168
-landuse allotments 0 1 0,0,0 222,184,135
-tourism zoo 0 1 0,0,0 108,255,185
-building yes 0 1 0,0,0 226,226,226
-natural water 0 1 0,0,0 135,206,255
-waterway riverbank 0 1 0,0,0 135,206,255
-place island 0 1 0,0,0 255,255,255
-highway trunk 3 1 150,0,0 255,255,255
-highway primary 2 1 219,112,147 255,255,255
-highway secondary 1 1 255,120,0 255,255,255
-highway tertiary 0 0 238,230,133 255,255,255
-highway pedestrian 0 0 255,255,0 255,255,255
-highway residential 0 0 100,100,100 255,255,255
-highway footway 0 0 170,170,170 255,255,255
-* * 1 1 0,0,255 255,255,255
+leisure park 0 0 0,0,0 88,245,168
+leisure garden 0 0 0,0,0 88,245,168
+leisure pitch 0 0 0,0,0 136,204,170
+leisure track 0 0 0,0,0 119,221,187
+leisure playground 0 0 0,0,0 221,255,255
+leisure golf_course 0 0 0,0,0 187,221,187
+leisure stadium 0 0 0,0,0 102,204,170
+landuse forest 0 0 0,0,0 139,207,102
+landuse allotments 0 0 0,0,0 222,184,135
+landuse construction 0 0 0,0,0 153,153,102
+landuse cemetery 0 0 0,0,0 170,204,170
+landuse brownfield 0 0 0,0,0 153,153,102
+landuse village_green 0 0 0,0,0 204,238,170
+landuse industrial 0 0 0,0,0 221,221,238
+landuse recreation_ground 0 0 0,0,0 204,238,170
+tourism zoo 0 0 0,0,0 180,238,180
+natural water 0 0 0,0,0 135,206,255
+natural wood 0.1 1 40,40,40 170,204,153
+natural land 0 0 0,0,0 170,170,170
+waterway riverbank 0 0 0,0,0 135,206,255
+place island 0.2 1 0,0,0 255,255,255
+highway trunk 3 1 150,0,0 170,221,170
+highway primary 3 1 219,112,147 255,255,255
+highway secondary 1.5 1 255,120,0 255,255,255
+highway tertiary 2 1 238,230,133 255,255,255
+highway pedestrian 0.8 1 230,214,182 255,255,255
+highway residential 1 1 100,100,100 235,235,235
+highway service 1 1 100,100,100 235,235,235
+highway footway 1.4 3 255,160,140 255,255,255
+amenity place_of_worship 0 0 0,0,0 123,140,123
+amenity grave_yard 0 0 0,0,0 157,191,157
+amenity school 0 0 0,0,0 221,221,170
+power station 0 0 0,0,0 187,187,187
+area yes 0.2 1 100,100,100 235,235,235
+building yes 0 0 0,0,0 204,153,153
+amenity parking 0 0 0,0,0 255,255,153
+boundary administrative 0.8 3 85,26,139 255,255,255
+* * 0.01 1 40,40,40 255,255,255
 #POINT
 amenity hospital emergency/amenity=hospital.svg 6

Modified: trunk/qgis/python/plugins/osm/styles/medium_scale.style
===================================================================
--- trunk/qgis/python/plugins/osm/styles/medium_scale.style	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/styles/medium_scale.style	2009-09-09 12:16:24 UTC (rev 11603)
@@ -1,45 +1,70 @@
 #LINE
-highway trunk 6 1 150,0,0
-highway primary 6 1 219,112,147
-highway secondary 4.5 1 255,120,0
-highway tertiary 3 1 238,230,133
-highway pedestrian 1 1 255,255,0
-highway residential 1 1 100,100,100
-highway footway 2 3 170,170,170
-highway * 1 1 0,255,0
-railway subway 1 2 131,111,255
-railway rail 2 4 0,0,0
-railway * 1 0 0,0,0
-boundary administrative 2 3 85,26,139
-power line 2 1 139,139,131
+highway trunk 2.7 1 170,221,170
+highway trunk_link 2.7 1 170,221,170
+highway primary 2.5 1 219,112,147
+highway secondary 2.3 1 255,221,170
+highway tertiary 2.0 1 238,230,133
+highway pedestrian 0.25 1 230,214,182
+highway residential 0.25 1 100,100,100
+highway unclassified 0.25 1 100,100,100
+highway service 0.25 1 100,100,100
+highway footway 0.15 3 255,160,140
+highway path 0.15 3 255,160,140
+highway steps 0.15 3 255,160,140
+highway living_street 0.8 1 207,207,190
+highway cycleway 0.8 3 0,115,255
+highway construction 0.5 2 204,238,221
+tracktype grade2 0.8 3 0,115,255
+highway track 1.4 2 181,164,130
+highway unsurfaced 0.8 2 230,214,182
+highway * 0.5 1 0,255,0
+railway subway 0.1 2 187,187,187
+railway rail 0.01 4 120,120,120
+railway tram 0.1 1 119,136,119
+railway preserved 0.05 2 187,187,187
+railway * 0.1 0 0,0,0
+boundary administrative 1 3 85,26,139
+waterway drain 0.5 1 135,206,255
+power line 1.4 1 139,139,131
+* * 1 1 200,200,200
 #POLYGON
-leisure park 0 1 0,0,0 88,245,168
-leisure garden 0 1 0,0,0 88,245,168
-landuse forest 0 1 0,0,0 88,245,168
+leisure park 0 0 0,0,0 88,245,168
+leisure garden 0 0 0,0,0 88,245,168
+leisure pitch 0 0 0,0,0 136,204,170
+leisure track 0.05 1 40,40,40 119,221,187
+leisure playground 0.05 1 40,40,40 221,255,255
+leisure golf_course 0 0 0,0,0 187,221,187
+leisure stadium 0 0 0,0,0 102,204,170
+landuse forest 0 0 0,0,0 139,207,102
 landuse allotments 0 1 0,0,0 222,184,135
-tourism zoo 0 1 0,0,0 108,255,
-building yes 0.01 1 0,0,0 226,226,226
-natural water 0 1 0,0,0 135,206,255
-waterway riverbank 0 1 0,0,0 135,206,255
+landuse construction 0 0 0,0,0 153,153,102
+landuse cemetery 0 0 0,0,0 170,204,170
+landuse brownfield 0 0 0,0,0 153,153,102
+landuse village_green 0 0 0,0,0 204,238,170
+landuse industrial 0 0 0,0,0 221,221,238
+landuse recreation_ground 0 0 0,0,0 204,238,170
+tourism zoo 0 0 0,0,0 180,238,180
+natural water 0 0 0,0,0 135,206,255
+natural wood 0.1 1 40,40,40 170,204,153
+natural land 0 0 0,0,0 170,170,170
+waterway riverbank 0 0 0,0,0 135,206,255
 place island 1 1 0,0,0 255,255,255
-highway trunk 6 1 150,0,0 255,255,255
+highway trunk 6 1 150,0,0 170,221,170
 highway primary 6 1 219,112,147 255,255,255
 highway secondary 4.5 1 255,120,0 255,255,255
 highway tertiary 3 1 238,230,133 255,255,255
-highway pedestrian 1 1 255,255,0 255,255,255
-highway residential 1 1 100,100,100 255,255,255
-highway footway 2 3 170,170,170 255,255,255
-* * 1 1 0,0,255 255,255,255
+highway pedestrian 0.8 1 230,214,182 255,255,255
+highway residential 1 1 100,100,100 235,235,235
+highway service 1 1 100,100,100 235,235,235
+highway footway 1.4 3 255,160,140 255,255,255
+amenity place_of_worship 0.02 1 0,0,0 123,140,123
+amenity grave_yard 0 0 0,0,0 157,191,157
+amenity school 0.05 1 160,160,110 221,221,170
+power station 0.05 1 170,170,170 187,187,187
+area yes 0.2 1 100,100,100 235,235,235
+building yes 0 0 0,0,0 204,153,153
+amenity parking 0 0 0,0,0 255,255,153
+boundary administrative 1 3 85,26,139 255,255,255
+* * 0.01 1 40,40,40 255,255,255
 #POINT
-source:addr uir_adr gpsicons/house.svg 15
-power tower symbol/Cross4.svg 15
-amenity hospital emergency/amenity=hospital.svg 15
-amenity parking transport/amenity=parking.svg 15
-amenity bus_station transport/highway=bus_stop.svg 15
-amenity restaurant entertainment/amenity=restaurant.svg 15
-amenity theatre entertainment/amenity=theatre.svg 15
-amenity pub entertainment/amenity=pub.svg 15
-amenity fast_food entertainment/amenity=fast_food.svg 15
-amenity cinema entertainment/amenity=cinema.svg 15
-amenity cafe entertainment/amenity=cafe.svg 15
-amenity bar entertainment/amenity=bar.svg 15
+amenity hospital emergency/amenity=hospital.svg 6

Modified: trunk/qgis/python/plugins/osm/styles/small_scale.style
===================================================================
--- trunk/qgis/python/plugins/osm/styles/small_scale.style	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/styles/small_scale.style	2009-09-09 12:16:24 UTC (rev 11603)
@@ -1,41 +1,74 @@
 #LINE
-highway trunk 4.3 1 150,0,0
+highway trunk 4.6 1 170,221,170
+highway trunk_link 4.6 1 170,221,170
 highway primary 4.3 1 219,112,147
-highway secondary 3.5 1 255,120,0
-highway tertiary 2.2 1 238,230,133
-highway pedestrian 0.8 1 255,255,0
+highway secondary 4 1 255,221,170
+highway tertiary 2.8 1 238,230,133
+highway pedestrian 0.8 1 230,214,182
 highway residential 0.8 1 100,100,100
-highway footway 1.4 3 170,170,170
+highway unclassified 0.8 1 100,100,100
+highway service 0.8 1 100,100,100
+highway footway 1.4 3 255,160,140
+highway path 1.4 3 255,160,140
+highway steps 1.4 3 255,160,140
+highway living_street 2.2 1 207,207,190
+highway cycleway 2 3 0,115,255
+highway construction 3 2 204,238,221
+tracktype grade2 2 3 0,115,255
+highway track 2 2 181,164,130
+highway unsurfaced 2 2 230,214,182
 highway * 1 1 0,255,0
-railway subway 0.7 2 131,111,255
+railway subway 1.5 2 187,187,187
 railway rail 1 4 0,0,0
-railway tram 1 4 175,0,0
+railway tram 1.5 1 119,136,119
+railway preserved 1.5 2 187,187,187
 railway * 0.7 0 0,0,0
 boundary administrative 2 3 85,26,139
+waterway drain 1 1 135,206,255
 power line 2 1 139,139,131
 * * 1 1 200,200,200
 #POLYGON
-leisure park 0 1 0,0,0 88,245,168
-leisure garden 0 1 0,0,0 88,245,168
-landuse forest 0 1 0,0,0 88,245,168
+leisure park 0 0 0,0,0 88,245,168
+leisure garden 0 0 0,0,0 88,245,168
+leisure pitch 0 0 0,0,0 136,204,170
+leisure track 0.05 1 40,40,40 119,221,187
+leisure playground 0.05 1 40,40,40 221,255,255
+leisure golf_course 0 0 0,0,0 187,221,187
+leisure stadium 0 0 0,0,0 102,204,170
+landuse forest 0 0 0,0,0 139,207,102
 landuse allotments 0 1 0,0,0 222,184,135
-tourism zoo 0 1 0,0,0 108,255,185
-building yes 0.01 1 0,0,0 226,226,226
-natural water 0 1 0,0,0 135,206,255
-waterway riverbank 0 1 0,0,0 135,206,255
+landuse construction 0 0 0,0,0 153,153,102
+landuse cemetery 0 0 0,0,0 170,204,170
+landuse brownfield 0 0 0,0,0 153,153,102
+landuse village_green 0 0 0,0,0 204,238,170
+landuse industrial 0 0 0,0,0 221,221,238
+landuse recreation_ground 0 0 0,0,0 204,238,170
+tourism zoo 0 0 0,0,0 180,238,180
+natural water 0 0 0,0,0 135,206,255
+natural wood 0.1 1 40,40,40 170,204,153
+natural land 0 0 0,0,0 170,170,170
+waterway riverbank 0 0 0,0,0 135,206,255
 place island 1 1 0,0,0 255,255,255
-highway trunk 6 1 150,0,0 255,255,255
+highway trunk 6 1 150,0,0 170,221,170
 highway primary 6 1 219,112,147 255,255,255
 highway secondary 4.5 1 255,120,0 255,255,255
 highway tertiary 3 1 238,230,133 255,255,255
-highway pedestrian 1 1 255,255,0 255,255,255
-highway residential 1 1 100,100,100 255,255,255
-highway footway 2 3 170,170,170 255,255,255
+highway pedestrian 0.8 1 230,214,182 255,255,255
+highway residential 1 1 100,100,100 235,235,235
+highway service 1 1 100,100,100 235,235,235
+highway footway 1.4 3 255,160,140 255,255,255
+amenity place_of_worship 0.1 1 0,0,0 123,140,123
+amenity grave_yard 0 0 0,0,0 157,191,157
+amenity school 0.05 1 160,160,110 221,221,170
+power station 0.05 1 170,170,170 187,187,187
+area yes 1 1 100,100,100 235,235,235
+building yes 0 0 0,0,0 204,153,153
+amenity parking 0 0 0,0,0 255,255,153
 * * 1 1 0,0,255 255,255,255
 #POINT
-source:addr uir_adr gpsicons/point.svg 7
 power tower symbol/Cross4.svg 10
 amenity hospital emergency/amenity=hospital.svg 10
+amenity police emergency/amenity=police.svg 10
 amenity parking transport/amenity=parking.svg 10
 amenity bus_station transport/highway=bus_stop.svg 10
 amenity restaurant entertainment/amenity=restaurant.svg 10
@@ -45,4 +78,11 @@
 amenity cinema entertainment/amenity=cinema.svg 10
 amenity cafe entertainment/amenity=cafe.svg 10
 amenity bar entertainment/amenity=bar.svg 10
-* * gpsicons/point.svg 7
\ No newline at end of file
+amenity pharmacy services/amenity=pharmacy.svg 10
+amenity telephone services/amenity=telephone.svg 10
+amenity atm services/amenity=atm.svg 10
+amenity bank gpsicons/bank.svg 10
+amenity post_box services/amenity=post_box.svg 10
+tourism hostel services/tourism=hotel.svg 10
+source:addr uir_adr gpsicons/point.svg 5
+* * gpsicons/point.svg 5

Modified: trunk/qgis/python/plugins/osm/ui_files/OsmAddRelationDlg.ui
===================================================================
--- trunk/qgis/python/plugins/osm/ui_files/OsmAddRelationDlg.ui	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/ui_files/OsmAddRelationDlg.ui	2009-09-09 12:16:24 UTC (rev 11603)
@@ -39,7 +39,7 @@
        <property name="sizeType" >
         <enum>QSizePolicy::Fixed</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0" >
         <size>
          <width>24</width>
          <height>20</height>
@@ -74,6 +74,15 @@
      </item>
      <item>
       <widget class="QToolButton" name="typeInfoButton" >
+       <property name="toolTip" >
+        <string>Show type description</string>
+       </property>
+       <property name="statusTip" >
+        <string>Shows brief description of selected relation type.</string>
+       </property>
+       <property name="whatsThis" >
+        <string>Shows brief description of selected relation type.</string>
+       </property>
        <property name="text" >
         <string>...</string>
        </property>
@@ -84,7 +93,7 @@
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0" >
         <size>
          <width>40</width>
          <height>20</height>
@@ -112,7 +121,7 @@
            <property name="orientation" >
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0" >
             <size>
              <width>40</width>
              <height>20</height>
@@ -122,6 +131,15 @@
          </item>
          <item>
           <widget class="QToolButton" name="loadStandardTagsButton" >
+           <property name="toolTip" >
+            <string>Generate tags</string>
+           </property>
+           <property name="statusTip" >
+            <string>Fills tag table with tags that are typical for relation of specified type.</string>
+           </property>
+           <property name="whatsThis" >
+            <string>Fills tag table with tags that are typical for relation of specified type.</string>
+           </property>
            <property name="text" >
             <string>...</string>
            </property>
@@ -129,6 +147,15 @@
          </item>
          <item>
           <widget class="QToolButton" name="removeTagButton" >
+           <property name="toolTip" >
+            <string>Remove all selected tags</string>
+           </property>
+           <property name="statusTip" >
+            <string>Removes all selected tags.</string>
+           </property>
+           <property name="whatsThis" >
+            <string>Removes all selected tags.</string>
+           </property>
            <property name="text" >
             <string>...</string>
            </property>
@@ -164,7 +191,7 @@
            <property name="orientation" >
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0" >
             <size>
              <width>40</width>
              <height>20</height>
@@ -174,6 +201,15 @@
          </item>
          <item>
           <widget class="QToolButton" name="chooseMemberButton" >
+           <property name="toolTip" >
+            <string>Select member on map</string>
+           </property>
+           <property name="statusTip" >
+            <string>Starts process of selecting next relation member on map.</string>
+           </property>
+           <property name="whatsThis" >
+            <string>Starts process of selecting next relation member on map.</string>
+           </property>
            <property name="text" >
             <string>...</string>
            </property>
@@ -184,6 +220,15 @@
          </item>
          <item>
           <widget class="QToolButton" name="removeMemberButton" >
+           <property name="toolTip" >
+            <string>Remove all selected members</string>
+           </property>
+           <property name="statusTip" >
+            <string>Removes all selected members.</string>
+           </property>
+           <property name="whatsThis" >
+            <string>Removes all selected members.</string>
+           </property>
            <property name="text" >
             <string>...</string>
            </property>
@@ -234,7 +279,7 @@
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0" >
         <size>
          <width>40</width>
          <height>20</height>

Modified: trunk/qgis/python/plugins/osm/ui_files/OsmFeatureDW.ui
===================================================================
--- trunk/qgis/python/plugins/osm/ui_files/OsmFeatureDW.ui	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/python/plugins/osm/ui_files/OsmFeatureDW.ui	2009-09-09 12:16:24 UTC (rev 11603)
@@ -37,6 +37,14 @@
    <string>OSM Feature</string>
   </property>
   <widget class="QWidget" name="dockWidgetContents" >
+   <property name="geometry" >
+    <rect>
+     <x>0</x>
+     <y>21</y>
+     <width>265</width>
+     <height>715</height>
+    </rect>
+   </property>
    <layout class="QVBoxLayout" >
     <item>
      <layout class="QHBoxLayout" >
@@ -89,13 +97,13 @@
          <enum>Qt::NoFocus</enum>
         </property>
         <property name="toolTip" >
-         <string>Identify object</string>
+         <string>Identify feature</string>
         </property>
         <property name="statusTip" >
-         <string>Identify object</string>
+         <string>Identify feature</string>
         </property>
         <property name="whatsThis" >
-         <string>Identify object</string>
+         <string>Identify feature</string>
         </property>
         <property name="text" >
          <string>...</string>
@@ -123,8 +131,14 @@
          <enum>Qt::NoFocus</enum>
         </property>
         <property name="toolTip" >
-         <string>Move object</string>
+         <string>Move feature</string>
         </property>
+        <property name="statusTip" >
+         <string>Move feature</string>
+        </property>
+        <property name="whatsThis" >
+         <string>Move feature</string>
+        </property>
         <property name="text" >
          <string>...</string>
         </property>
@@ -348,12 +362,9 @@
        </property>
        <item>
         <layout class="QGridLayout" >
-         <property name="horizontalSpacing" >
+         <property name="spacing" >
           <number>0</number>
          </property>
-         <property name="verticalSpacing" >
-          <number>0</number>
-         </property>
          <item row="0" column="0" >
           <widget class="QLabel" name="label" >
            <property name="text" >
@@ -405,13 +416,13 @@
             </size>
            </property>
            <property name="toolTip" >
-            <string>Remove feature</string>
+            <string>Remove this feature</string>
            </property>
            <property name="statusTip" >
-            <string>Remove feature</string>
+            <string>Remove this feature</string>
            </property>
            <property name="whatsThis" >
-            <string>Remove feature</string>
+            <string>Remove this feature</string>
            </property>
            <property name="text" >
             <string>...</string>
@@ -456,6 +467,14 @@
        <number>1</number>
       </property>
       <widget class="QWidget" name="Properties" >
+       <property name="geometry" >
+        <rect>
+         <x>0</x>
+         <y>0</y>
+         <width>640</width>
+         <height>320</height>
+        </rect>
+       </property>
        <attribute name="title" >
         <string>Properties</string>
        </attribute>
@@ -492,7 +511,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>40</width>
               <height>20</height>
@@ -521,6 +540,14 @@
        </layout>
       </widget>
       <widget class="QWidget" name="Relations" >
+       <property name="geometry" >
+        <rect>
+         <x>0</x>
+         <y>0</y>
+         <width>243</width>
+         <height>534</height>
+        </rect>
+       </property>
        <attribute name="title" >
         <string>Relations</string>
        </attribute>
@@ -607,7 +634,7 @@
               <property name="sizeType" >
                <enum>QSizePolicy::Minimum</enum>
               </property>
-              <property name="sizeHint" >
+              <property name="sizeHint" stdset="0" >
                <size>
                 <width>26</width>
                 <height>0</height>

Modified: trunk/qgis/src/providers/osm/osmhandler.cpp
===================================================================
--- trunk/qgis/src/providers/osm/osmhandler.cpp	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/src/providers/osm/osmhandler.cpp	2009-09-09 12:16:24 UTC (rev 11603)
@@ -90,6 +90,9 @@
 OsmHandler::~OsmHandler()
 {
   sqlite3_finalize( mStmtInsertTag );
+  sqlite3_finalize( mStmtInsertNode );
+  sqlite3_finalize( mStmtInsertWay );
+  sqlite3_finalize( mStmtInsertWayMember );
   sqlite3_finalize( mStmtInsertRelation );
   sqlite3_finalize( mStmtInsertRelationMember );
   sqlite3_finalize( mStmtInsertVersion );
@@ -170,11 +173,6 @@
   }
   else if ( name == "way" )
   {
-    if ( mObjectType != "way" )
-    {
-      sqlite3_finalize( mStmtInsertNode );
-    }
-
     mObjectId = pAttrs.value( "id" );
     mObjectType = "way";
     mPosId = 1;
@@ -227,12 +225,6 @@
   }
   else if ( name == "relation" )
   {
-    if ( mObjectType != "relation" )
-    {
-      sqlite3_finalize( mStmtInsertWay );
-      sqlite3_finalize( mStmtInsertWayMember );
-    }
-
     mObjectId = pAttrs.value( "id" );
     mRelationType = "";
     mObjectType = "relation";
@@ -305,7 +297,6 @@
   else if ( name == "bounds" )
   {
     // e.g. <bounds minlat="41.388625" minlon="2.15426" maxlat="41.391732" maxlon="2.158192"/>
-    // notice: getting boundaries from OSM file <bounds> tag was not correct for some maps - cannot be used
 
     // xMin = pAttrs.value("minlon").toDouble();
     // xMax = pAttrs.value("maxlon").toDouble();

Modified: trunk/qgis/src/providers/osm/osmprovider.cpp
===================================================================
--- trunk/qgis/src/providers/osm/osmprovider.cpp	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/src/providers/osm/osmprovider.cpp	2009-09-09 12:16:24 UTC (rev 11603)
@@ -27,7 +27,9 @@
 #include <QDateTime>
 #include <QByteArray>
 
+using namespace std;
 
+
 static const QString TEXT_PROVIDER_KEY = "osm";
 static const QString TEXT_PROVIDER_DESCRIPTION = "Open Street Map data provider";
 static const QString DATE_TIME_FMT = "dd.MM.yyyy HH:mm:ss";
@@ -142,8 +144,11 @@
   // flag determining if OSM file parsing is neccessary
   bool shouldParse = true;
 
+  if ( mFeatureType != PolygonType )
+    shouldParse = false;
+
   // test if db file that belongs to source OSM file already exists and if it has the right version
-  if ( databaseExists && isDatabaseCompatibleWithInput( mFileName ) && isDatabaseCompatibleWithPlugin() )
+  if ( shouldParse && databaseExists && isDatabaseCompatibleWithInput( mFileName ) && isDatabaseCompatibleWithProvider() )
     shouldParse = false;
 
   if ( shouldParse )
@@ -178,16 +183,16 @@
     // no OSM file parsing was done, we must find out default area boundaries from database meta information
     char sqlSelectBoundary[] = "SELECT val FROM meta WHERE key='default-area-boundaries';";
     sqlite3_stmt *stmtSelectBoundary;
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectBoundary, sizeof(sqlSelectBoundary), &stmtSelectBoundary, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectBoundary, sizeof( sqlSelectBoundary ), &stmtSelectBoundary, 0 ) != SQLITE_OK )
     {
       QgsDebugMsg( "Getting default area boundary failed." );
       // don't worry, we just let default values in xMax, yMax, xMin and yMin variables
     }
     else
     {
-      if (sqlite3_step( stmtSelectBoundary ) != SQLITE_ROW)
+      if ( sqlite3_step( stmtSelectBoundary ) != SQLITE_ROW )
       {
-        QgsDebugMsg("Getting default area boundary failed.");
+        QgsDebugMsg( "Getting default area boundary failed." );
         // don't worry again, we just let default values in boundary variables
       }
       else
@@ -213,35 +218,35 @@
 
   // prepare statement for tag retrieval
   char sqlSelectTags[] = "SELECT key, val FROM tag WHERE object_id=? AND object_type=?";
-  int rc = sqlite3_prepare_v2( mDatabase, sqlSelectTags, sizeof(sqlSelectTags), &mTagsStmt, 0 );
+  int rc = sqlite3_prepare_v2( mDatabase, sqlSelectTags, sizeof( sqlSelectTags ), &mTagsStmt, 0 );
   if ( rc != SQLITE_OK )
   {
-    QgsDebugMsg("sqlite3 statement for feature tags selection - prepare failed.");
+    QgsDebugMsg( "sqlite3 statement for feature tags selection - prepare failed." );
     return;
   }
 
   char sqlSelectTagValue[] = "SELECT val FROM tag WHERE object_id=? AND object_type=? AND key=?";
-  rc = sqlite3_prepare_v2( mDatabase, sqlSelectTagValue, sizeof(sqlSelectTagValue), &mCustomTagsStmt, 0 );
+  rc = sqlite3_prepare_v2( mDatabase, sqlSelectTagValue, sizeof( sqlSelectTagValue ), &mCustomTagsStmt, 0 );
   if ( rc != SQLITE_OK )
   {
-    QgsDebugMsg("sqlite3 statement for tag value selection - prepare failed.");
+    QgsDebugMsg( "sqlite3 statement for tag value selection - prepare failed." );
     return;
   }
 
   // prepare statements for feature retrieval
   char sqlSelectWay[] = "SELECT id, wkb, timestamp, user FROM way WHERE id=? AND status<>'R' AND u=1";
-  rc = sqlite3_prepare_v2( mDatabase, sqlSelectWay, sizeof(sqlSelectWay), &mWayStmt, 0 );
+  rc = sqlite3_prepare_v2( mDatabase, sqlSelectWay, sizeof( sqlSelectWay ), &mWayStmt, 0 );
   if ( rc != SQLITE_OK )
   {
-    QgsDebugMsg("sqlite3 statement for way retrieval - prepare failed.");
+    QgsDebugMsg( "sqlite3 statement for way retrieval - prepare failed." );
     return;
   }
 
   char sqlSelectNode[] = "SELECT id, lat, lon, timestamp, user FROM node WHERE id=? AND usage=0 AND status<>'R' AND u=1";
-  rc = sqlite3_prepare_v2( mDatabase, sqlSelectNode, sizeof(sqlSelectNode), &mNodeStmt, 0 );
+  rc = sqlite3_prepare_v2( mDatabase, sqlSelectNode, sizeof( sqlSelectNode ), &mNodeStmt, 0 );
   if ( rc != SQLITE_OK )
   {
-    QgsDebugMsg("sqlite3 statement for node retrieval - prepare failed.");
+    QgsDebugMsg( "sqlite3 statement for node retrieval - prepare failed." );
     return;
   }
 
@@ -251,14 +256,14 @@
     char sqlSelectPointsIn[] = "SELECT id, lat, lon, timestamp, user FROM node WHERE usage=0 AND status<>'R' AND u=1 \
                                 AND lat>=? AND lat<=? AND lon>=? AND lon<=?";
 
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPoints, sizeof(sqlSelectPoints), &mSelectFeatsStmt, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPoints, sizeof( sqlSelectPoints ), &mSelectFeatsStmt, 0 ) != SQLITE_OK )
     {
-      QgsDebugMsg("sqlite3 statement for points retrieval - prepare failed.");
+      QgsDebugMsg( "sqlite3 statement for points retrieval - prepare failed." );
       return;
     }
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPointsIn, sizeof(sqlSelectPointsIn), &mSelectFeatsInStmt, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPointsIn, sizeof( sqlSelectPointsIn ), &mSelectFeatsInStmt, 0 ) != SQLITE_OK )
     {
-      QgsDebugMsg("sqlite3 statement for points in boundary retrieval - prepare failed.");
+      QgsDebugMsg( "sqlite3 statement for points in boundary retrieval - prepare failed." );
       return;
     }
   }
@@ -267,16 +272,16 @@
     char sqlSelectLines[] = "SELECT w.id, w.wkb, w.timestamp, w.user FROM way w WHERE w.closed=0 AND w.status<>'R' AND w.u=1";
     char sqlSelectLinesIn[] = "SELECT w.id, w.wkb, w.timestamp, w.user FROM way w WHERE w.closed=0 AND w.status<>'R' AND w.u=1 \
                                AND (((w.max_lat between ? AND ?) OR (w.min_lat between ? AND ?) OR (w.min_lat<? AND w.max_lat>?)) \
-                               OR ((w.max_lon between ? AND ?) OR (w.min_lon between ? AND ?) OR (w.min_lon<? AND w.max_lon>?)))";
+                               AND ((w.max_lon between ? AND ?) OR (w.min_lon between ? AND ?) OR (w.min_lon<? AND w.max_lon>?)))";
 
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectLines, sizeof(sqlSelectLines), &mSelectFeatsStmt, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectLines, sizeof( sqlSelectLines ), &mSelectFeatsStmt, 0 ) != SQLITE_OK )
     {
-      QgsDebugMsg("sqlite3 statement for lines retrieval - prepare failed.");
+      QgsDebugMsg( "sqlite3 statement for lines retrieval - prepare failed." );
       return;
     }
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectLinesIn, sizeof(sqlSelectLinesIn), &mSelectFeatsInStmt, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectLinesIn, sizeof( sqlSelectLinesIn ), &mSelectFeatsInStmt, 0 ) != SQLITE_OK )
     {
-      QgsDebugMsg("sqlite3 statement for lines in boundary retrieval - prepare failed.");
+      QgsDebugMsg( "sqlite3 statement for lines in boundary retrieval - prepare failed." );
       return;
     }
   }
@@ -285,16 +290,16 @@
     char sqlSelectPolys[] = "SELECT w.id, w.wkb, w.timestamp, w.user FROM way w WHERE w.closed=1 AND w.status<>'R' AND w.u=1";
     char sqlSelectPolysIn[] = "SELECT w.id, w.wkb, w.timestamp, w.user FROM way w WHERE w.closed=1 AND w.status<>'R' AND w.u=1 \
                                AND (((w.max_lat between ? AND ?) OR (w.min_lat between ? AND ?) OR (w.min_lat<? AND w.max_lat>?)) \
-                               OR ((w.max_lon between ? AND ?) OR (w.min_lon between ? AND ?) OR (w.min_lon<? AND w.max_lon>?)))";
+                               AND ((w.max_lon between ? AND ?) OR (w.min_lon between ? AND ?) OR (w.min_lon<? AND w.max_lon>?)))";
 
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPolys, sizeof(sqlSelectPolys), &mSelectFeatsStmt, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPolys, sizeof( sqlSelectPolys ), &mSelectFeatsStmt, 0 ) != SQLITE_OK )
     {
-      QgsDebugMsg("sqlite3 statement for polygons retrieval - prepare failed.");
+      QgsDebugMsg( "sqlite3 statement for polygons retrieval - prepare failed." );
       return;
     }
-    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPolysIn, sizeof(sqlSelectPolysIn), &mSelectFeatsInStmt, 0 ) != SQLITE_OK )
+    if ( sqlite3_prepare_v2( mDatabase, sqlSelectPolysIn, sizeof( sqlSelectPolysIn ), &mSelectFeatsInStmt, 0 ) != SQLITE_OK )
     {
-      QgsDebugMsg("sqlite3 statement for polygons in boundary retrieval - prepare failed.");
+      QgsDebugMsg( "sqlite3 statement for polygons in boundary retrieval - prepare failed." );
       return;
     }
   }
@@ -318,7 +323,10 @@
   sqlite3_finalize( mSelectFeatsInStmt );
 
   // close opened sqlite3 database
-  closeDatabase();
+  if ( mDatabase )
+  {
+    closeDatabase();
+  }
 }
 
 
@@ -331,9 +339,9 @@
   char sqlSelectLastModif[] = "SELECT val FROM meta WHERE key='osm-file-last-modified';";
   sqlite3_stmt *stmtSelectLastModif;
 
-  if ( sqlite3_prepare_v2( mDatabase, sqlSelectLastModif, sizeof(sqlSelectLastModif), &stmtSelectLastModif, 0 ) == SQLITE_OK )
+  if ( sqlite3_prepare_v2( mDatabase, sqlSelectLastModif, sizeof( sqlSelectLastModif ), &stmtSelectLastModif, 0 ) == SQLITE_OK )
   {
-    if ( sqlite3_step(stmtSelectLastModif) == SQLITE_ROW )
+    if ( sqlite3_step( stmtSelectLastModif ) == SQLITE_ROW )
     {
       QString oldOsmLastModifString = ( const char * ) sqlite3_column_text( stmtSelectLastModif, 0 );
       QDateTime oldOsmFileLastModif = QDateTime::fromString( oldOsmLastModifString, DATE_TIME_FMT );
@@ -354,28 +362,28 @@
 }
 
 
-bool QgsOSMDataProvider::isDatabaseCompatibleWithPlugin()
+bool QgsOSMDataProvider::isDatabaseCompatibleWithProvider()
 {
-  char sqlSelectPluginVer[] = "SELECT val FROM meta WHERE key='osm-plugin-version';";
-  sqlite3_stmt *stmtSelectPluginVer;
+  char sqlSelectProviderVer[] = "SELECT val FROM meta WHERE key='osm-provider-version';";
+  sqlite3_stmt *stmtSelectProviderVer;
 
-  if ( sqlite3_prepare_v2( mDatabase, sqlSelectPluginVer, sizeof(sqlSelectPluginVer), &stmtSelectPluginVer, 0 ) == SQLITE_OK )
+  if ( sqlite3_prepare_v2( mDatabase, sqlSelectProviderVer, sizeof( sqlSelectProviderVer ), &stmtSelectProviderVer, 0 ) == SQLITE_OK )
   {
-    if ( sqlite3_step( stmtSelectPluginVer ) == SQLITE_ROW )
+    if ( sqlite3_step( stmtSelectProviderVer ) == SQLITE_ROW )
     {
-      QString osmPluginVersion = ( const char * ) sqlite3_column_text( stmtSelectPluginVer, 0 );
+      QString osmProviderVersion = ( const char * ) sqlite3_column_text( stmtSelectProviderVer, 0 );
 
       // each OSM database schema carry info on version of QGIS OSM plugin from which database was created;
       // this provider must be of the same version to be able to manage OSM data correctly
-      if ( osmPluginVersion == PROVIDER_VERSION )
+      if ( osmProviderVersion == PROVIDER_VERSION )
       {
-        sqlite3_finalize( stmtSelectPluginVer );
+        sqlite3_finalize( stmtSelectProviderVer );
         return true;
       }
     }
   }
   // destroy database statement
-  sqlite3_finalize( stmtSelectPluginVer );
+  sqlite3_finalize( stmtSelectProviderVer );
   return false;
 }
 
@@ -470,7 +478,7 @@
   char sqlWayMemberCnt[] = "SELECT count(n.id) FROM way_member wm, node n WHERE wm.way_id=? AND wm.node_id=n.id AND wm.u=1 AND n.u=1;";
   sqlite3_stmt *stmtWayMemberCnt;
 
-  if ( sqlite3_prepare_v2( mDatabase, sqlWayMemberCnt, sizeof(sqlWayMemberCnt), &stmtWayMemberCnt, 0 ) != SQLITE_OK )
+  if ( sqlite3_prepare_v2( mDatabase, sqlWayMemberCnt, sizeof( sqlWayMemberCnt ), &stmtWayMemberCnt, 0 ) != SQLITE_OK )
   {
     QgsDebugMsg( "sqlite3 statement for selecting waymember count - prepare failed." );
     sqlite3_finalize( stmtWayMemberCnt );
@@ -579,11 +587,11 @@
   if ( fetchGeometry )
   {
     char* geo = new char[21];
-    memset( geo, 0, 21 );
+    std::memset( geo, 0, 21 );
     geo[0] = QgsApplication::endian();
     geo[geo[0] == QgsApplication::NDR ? 1 : 4] = QGis::WKBPoint;
-    memcpy( geo + 5, &selLon, sizeof( double ) );
-    memcpy( geo + 13, &selLat, sizeof( double ) );
+    std::memcpy( geo + 5, &selLon, sizeof( double ) );
+    std::memcpy( geo + 13, &selLat, sizeof( double ) );
     feature.setGeometryAndOwnership(( unsigned char * )geo, 24 );    // 24 is size of wkb point structure!
   }
 
@@ -1009,11 +1017,11 @@
     ( *geo ) = new char[9 + 16 * memberCnt];
     ( *geolen ) = 9 + 16 * memberCnt;
 
-    memset(( *geo ), 0, 9 + 16 * memberCnt );
+    std::memset(( *geo ), 0, 9 + 16 * memberCnt );
 
     ( *geo )[0] = QgsApplication::endian();
     ( *geo )[( *geo )[0] == QgsApplication::NDR ? 1 : 4] = QGis::WKBLineString;
-    memcpy(( *geo ) + 5, &memberCnt, 4 );
+    std::memcpy(( *geo ) + 5, &memberCnt, 4 );
 
     sqlite3_bind_int( stmtSelectMembers, 1, wayId );
 
@@ -1035,8 +1043,8 @@
       if ( selLat > maxLat ) maxLat = selLat;
       if ( selLon > maxLon ) maxLon = selLon;
 
-      memcpy(( *geo ) + 9 + 16 * i, &selLon, sizeof( double ) );
-      memcpy(( *geo ) + 9 + 16 * i + 8, &selLat, sizeof( double ) );
+      std::memcpy(( *geo ) + 9 + 16 * i, &selLon, sizeof( double ) );
+      std::memcpy(( *geo ) + 9 + 16 * i + 8, &selLat, sizeof( double ) );
       i++;
     }
 
@@ -1049,11 +1057,11 @@
     memberCnt++;
     ( *geo ) = new char[13 + 16 * memberCnt];
     ( *geolen ) = 13 + 16 * memberCnt;
-    memset(( *geo ), 0, 13 + 16 * memberCnt );
+    std::memset(( *geo ), 0, 13 + 16 * memberCnt );
     ( *geo )[0] = QgsApplication::endian();
     ( *geo )[( *geo )[0] == QgsApplication::NDR ? 1 : 4] = QGis::WKBPolygon;
-    memcpy(( *geo ) + 5, &ringsCnt, 4 );
-    memcpy(( *geo ) + 9, &memberCnt, 4 );
+    std::memcpy(( *geo ) + 5, &ringsCnt, 4 );
+    std::memcpy(( *geo ) + 9, &memberCnt, 4 );
 
     sqlite3_bind_int( stmtSelectMembers, 1, wayId );
 
@@ -1077,8 +1085,8 @@
       if ( selLat > maxLat ) maxLat = selLat;
       if ( selLon > maxLon ) maxLon = selLon;
 
-      memcpy(( *geo ) + 13 + 16 * i, &selLon, sizeof( double ) );
-      memcpy(( *geo ) + 13 + 16 * i + 8, &selLat, sizeof( double ) );
+      std::memcpy(( *geo ) + 13 + 16 * i, &selLon, sizeof( double ) );
+      std::memcpy(( *geo ) + 13 + 16 * i + 8, &selLat, sizeof( double ) );
 
       if ( firstLat == -1000.0 )
         firstLat = selLat;
@@ -1087,8 +1095,8 @@
       i++;
     }
     // add last polygon line
-    memcpy(( *geo ) + 13 + 16 * i, &firstLon, sizeof( double ) );
-    memcpy(( *geo ) + 13 + 16 * i + 8, &firstLat, sizeof( double ) );
+    std::memcpy(( *geo ) + 13 + 16 * i, &firstLon, sizeof( double ) );
+    std::memcpy(( *geo ) + 13 + 16 * i + 8, &firstLat, sizeof( double ) );
 
     sqlite3_bind_blob( stmtUpdateWay, 1, ( *geo ), 13 + 16 * memberCnt, SQLITE_TRANSIENT );
   }
@@ -1360,17 +1368,17 @@
 
   if ( sqlite3_exec( mDatabase, ptr, 0, 0, 0 ) != SQLITE_OK )
   {
-    QgsDebugMsg("Storing osm-file-last-modified info into database failed.");
+    cout << "Storing osm-file-last-modified info into database failed." << endl;
     // its not fatal situation, lets continue..
   }
 
-  QString cmd2 = "INSERT INTO meta ( key, val ) VALUES ('osm-plugin-version','" + PROVIDER_VERSION + "');";
+  QString cmd2 = "INSERT INTO meta ( key, val ) VALUES ('osm-provider-version','" + PROVIDER_VERSION + "');";
   QByteArray cmd_bytes2  = cmd2.toAscii();
   const char *ptr2 = cmd_bytes2.data();
 
   if ( sqlite3_exec( mDatabase, ptr2, 0, 0, 0 ) != SQLITE_OK )
   {
-    QgsDebugMsg("Storing osm-plugin-version info into database failed.");
+    cout << "Storing osm-provider-version info into database failed." << endl;
     return false;
   }
 
@@ -1388,7 +1396,7 @@
 
   if ( sqlite3_exec( mDatabase, ptr3, 0, 0, 0 ) != SQLITE_OK )
   {
-    QgsDebugMsg("Storing default area boundaries information into database failed.");
+    cout << "Storing default area boundaries information into database failed." << endl;
     // its not critical situation
   }
 
@@ -1655,6 +1663,7 @@
     mError = ( char * ) "Closing SQLite3 database failed.";
     return false;
   }
+  mDatabase = NULL;
   return true;
 };
 

Modified: trunk/qgis/src/providers/osm/osmprovider.h
===================================================================
--- trunk/qgis/src/providers/osm/osmprovider.h	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/src/providers/osm/osmprovider.h	2009-09-09 12:16:24 UTC (rev 11603)
@@ -24,6 +24,7 @@
 class QgsOSMDataProvider: public QgsVectorDataProvider
 {
     Q_OBJECT
+
   private:
 
     //! provider manages features with one of three geometry types; variable determines feature type of this provider
@@ -237,17 +238,17 @@
 
   private:
     /**
-     * Finds out if database (provider is connected to) belongs to (was created from) specified input file.
+     * Finds out if current database belongs to (was created from) specified input file.
      * @param mFileName name of input OSM file
      * @return answer to that question
      */
     bool isDatabaseCompatibleWithInput( QString mFileName );
 
     /**
-     * Finds out if database and provider versions are compatible.
+     * Finds out if current database and provider versions are compatible.
      * @return answer to that question
      */
-    bool isDatabaseCompatibleWithPlugin();
+    bool isDatabaseCompatibleWithProvider();
 
     /**
      * Creates Open Street Map database schema, using c++ library for attempt to sqlite database.

Modified: trunk/qgis/src/python/qgspythonutilsimpl.cpp
===================================================================
--- trunk/qgis/src/python/qgspythonutilsimpl.cpp	2009-09-09 09:20:05 UTC (rev 11602)
+++ trunk/qgis/src/python/qgspythonutilsimpl.cpp	2009-09-09 12:16:24 UTC (rev 11603)
@@ -16,6 +16,11 @@
 
 // python should be first include
 // otherwise issues some warnings
+#ifdef _MSC_VER
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+#endif
 #include <Python.h>
 
 #include "qgspythonutilsimpl.h"



More information about the QGIS-commit mailing list