So I'm trying to implement a routing algorithm in my QGIS 3 plugin that I'm writing using Python.
I think I could resolve all the problems concerning the break between QGIS 2 and 3, but my resulting tree gives me for all nodes in it just a -1 value which is for not connected nodes.
If I have for example a project that looks like this:
Where the red Square is my start point and the yellow circle my end point I get back a tree that looks like this [-1,-1,-1]
the code I use is the following:
First I select the Line layer and the startPt and endPt
director = QgsVectorLayerDirector(layer, -1, '', '', '', 3) strategy = QgsNetworkDistanceStrategy() director.addStrategy(strategy) builder = QgsGraphBuilder(crs) #crs = project.crs() which is in this case WGS84 tiedPoints = director.makeGraph(builder, [startPt, endPt]) graph = builder.graph() startVertex = graph.findVertex(startPt) (tree, cost) = QgsGraphAnalyzer.dijkstra(graph, startVertex,0)
I just don't know where it goes wrong.