Skip to content

Commit

Permalink
OSM provider ported to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jan 27, 2013
1 parent b16c68e commit 600baca
Show file tree
Hide file tree
Showing 7 changed files with 608 additions and 642 deletions.
17 changes: 7 additions & 10 deletions python/plugins/osm/OsmDatabaseManager.py
Expand Up @@ -323,7 +323,6 @@ def findFeature(self,mapPoint):
lay=self.pointLayers[self.currentKey]
lay.select([],area,True,True)
result=lay.nextFeature(feat)
lay.dataProvider().rewind()

if result:
return (feat,'Point')
Expand All @@ -332,7 +331,6 @@ def findFeature(self,mapPoint):
lay=self.lineLayers[self.currentKey]
lay.select([],area,True,True)
result=lay.nextFeature(feat)
lay.dataProvider().rewind()

if result:
# line vertices
Expand All @@ -341,7 +339,7 @@ def findFeature(self,mapPoint):
,{"minLat":area.yMinimum(),"maxLat":area.yMaximum(),"minLon":area.xMinimum(),"maxLon":area.xMaximum(),"lineId":str(feat.id())})

for rec in c:
feat2=QgsFeature(rec[0],"Point")
feat2=QgsFeature(rec[0])
feat2.setGeometry(QgsGeometry.fromPoint(QgsPoint(rec[2],rec[1])))
# without features' attributes here! we don't need them...
c.close()
Expand All @@ -354,7 +352,6 @@ def findFeature(self,mapPoint):
lay=self.polygonLayers[self.currentKey]
lay.select([],area,True,True)
result=lay.nextFeature(feat)
lay.dataProvider().rewind()

if result:
# polygon vertices
Expand All @@ -363,7 +360,7 @@ def findFeature(self,mapPoint):
,{"minLat":area.yMinimum(),"maxLat":area.yMaximum(),"minLon":area.xMinimum(),"maxLon":area.xMaximum(),"polygonId":str(feat.id())})

for rec in c:
feat2=QgsFeature(rec[0],"Point")
feat2=QgsFeature(rec[0])
feat2.setGeometry(QgsGeometry.fromPoint(QgsPoint(rec[2],rec[1])))
# without features' attributes here! we don't need them...
c.close()
Expand Down Expand Up @@ -416,7 +413,7 @@ def findAllFeatures(self,mapPoint):
,{"minLat":area.yMinimum(),"maxLat":area.yMaximum(),"minLon":area.xMinimum(),"maxLon":area.xMaximum(),"lineId":str(feat.id())})

for rec in c:
feat2=QgsFeature(rec[0],"Point")
feat2=QgsFeature(rec[0])
feat2.setGeometry(QgsGeometry.fromPoint(QgsPoint(rec[2],rec[1])))
# without features' attributes here! we don't need them...
featMap[feat2.id()]=feat2
Expand All @@ -439,7 +436,7 @@ def findAllFeatures(self,mapPoint):
,{"minLat":area.yMinimum(),"maxLat":area.yMaximum(),"minLon":area.xMinimum(),"maxLon":area.xMaximum(),"polygonId":str(feat.id())})

for rec in c:
feat2=QgsFeature(rec[0],"Point")
feat2=QgsFeature(rec[0])
feat2.setGeometry(QgsGeometry.fromPoint(QgsPoint(rec[2],rec[1])))
# without features' attributes here! we don't need them...
featMap[feat2.id()]=feat2
Expand Down Expand Up @@ -471,7 +468,7 @@ def createPoint(self,mapPoint,snapFeat,snapFeatType,doCommit=True):
nodeId=self.__getFreeFeatureId()

affected=set()
feat=QgsFeature(nodeId,"Point")
feat=QgsFeature(nodeId)
feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(mapPoint.x(),mapPoint.y())))

# should snapping be done? if not, everything's easy
Expand Down Expand Up @@ -612,7 +609,7 @@ def createLine(self,mapPoints, doCommit=True):

# finishing...
c.close()
feat=QgsFeature(lineId,"Line")
feat=QgsFeature(lineId)
feat.setGeometry(QgsGeometry.fromPolyline(pline))

if doCommit:
Expand Down Expand Up @@ -691,7 +688,7 @@ def createPolygon(self,mapPoints, doCommit=True):

# finish
c.close()
feat=QgsFeature(polygonId,"Polygon")
feat=QgsFeature(polygonId)
polygon=[]
polygon.append(pline)
feat.setGeometry(QgsGeometry.fromPolygon(polygon))
Expand Down
2 changes: 1 addition & 1 deletion src/providers/CMakeLists.txt
Expand Up @@ -6,7 +6,7 @@ ADD_SUBDIRECTORY(memory)
ADD_SUBDIRECTORY(ogr)
ADD_SUBDIRECTORY(wms)
ADD_SUBDIRECTORY(delimitedtext)
#ADD_SUBDIRECTORY(osm) # TODO: enable when migrated to new api
ADD_SUBDIRECTORY(osm)
#ADD_SUBDIRECTORY(sqlanywhere) # TODO: enable when migrated to new api
ADD_SUBDIRECTORY(gdal)
#ADD_SUBDIRECTORY(mssql) # TODO: enable when migrated to new api
Expand Down
1 change: 1 addition & 0 deletions src/providers/osm/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@
# Files

SET(OSM_SRCS
osmfeatureiterator.cpp
osmhandler.cpp
osmprovider.cpp
osmrenderer.cpp
Expand Down

0 comments on commit 600baca

Please sign in to comment.