Skip to content

Commit

Permalink
speedup for countrywide release
Browse files Browse the repository at this point in the history
  • Loading branch information
anitagraser committed Jan 6, 2016
1 parent ca8218c commit fdcdbce
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions qgis2/scripts/ogd/idf_router.py
Expand Up @@ -7,7 +7,9 @@ def __init__(self,idf_file):
""" for the basic network """
self.nodes = {}
self.links = {}

self.node_features = []
self.link_features = []

""" for the routing graph """
self.use_to_link = {}
self.graph = QgsGraph()
Expand Down Expand Up @@ -61,10 +63,12 @@ def read_idf(self,idf_file):
self.nodes[id] = QgsPoint(x,y)
fet.setGeometry(QgsGeometry.fromPoint(QgsPoint(x,y)))
fet.setAttributes(line[1:])
node_pr.addFeatures([fet])
self.node_features.append(fet)

""" LINK """
if status == "Link" and line[0] == "atr":
node_pr.addFeatures(self.node_features)
self.node_features = []
attribute_names = line[1:]
if status == "Link" and line[0] == "frm":
link_layer = QgsVectorLayer(
Expand Down Expand Up @@ -104,17 +108,20 @@ def read_idf(self,idf_file):
pass

if status == "TurnEdge" and line[0] == "atr":
""" prepare the links and return the layers """
""" prepare the links """
for id,[attrs,line] in self.links.iteritems():
fet = QgsFeature()
fet.setGeometry(QgsGeometry.fromPolyline(line))
fet.setAttributes(attrs)
link_pr.addFeatures([fet])
self.link_features.append(fet)

""" create routing graph entry """
vertex_id = self.graph.addVertex(QgsGeometry.fromPolyline(line).centroid().asPoint())
self.link_to_vertex[id] = vertex_id
self.vertex_to_link[vertex_id] = id

link_pr.addFeatures(self.link_features)
self.link_features = []

if status == "TurnEdge" and line[0] == "rec":
""" create routing graph entry """
Expand Down Expand Up @@ -174,9 +181,9 @@ def computeRoute(self,from_link,to_link,vehicle_type):

route_layer.updateExtents()
QgsMapLayerRegistry.instance().addMapLayer(route_layer)
idf_file = "C:/Users/anita/Documents/GitHub/QGIS-resources/qgis2/scripts/ogd/Routingexport_Wien_OGD.txt"
#idf_file = "C:/Users/anita/Documents/GitHub/QGIS-resources/qgis2/scripts/ogd/Routingexport_Klagenfurt_OGD.txt"

#idf_file = "C:/Users/anita/Documents/GitHub/QGIS-resources/qgis2/scripts/ogd/Routingexport_Wien_OGD.txt"
idf_file = "C:/Users/anita/Downloads/3_routingexport_ogd/3_routingexport_ogd.txt"

router = IDFRouter(idf_file)

Expand All @@ -185,4 +192,4 @@ def computeRoute(self,from_link,to_link,vehicle_type):
# 2 ... car

router.computeRoute(33000844,33114053,2)
#router.computeRoute(601297920,601206884,2)
router.computeRoute(23077740,901392332,2)

0 comments on commit fdcdbce

Please sign in to comment.