Using QGIS 2.18.14, I try something around with
qgis.networkanalysis module as described here: https://docs.qgis.org/2.18/en/docs/pyqgis_developer_cookbook/network_analysis.html
director = QgsLineVectorLayerDirector(network, -1, '', '', '', 3) properter = QgsDistanceArcProperter() director.addProperter(properter) crs = network.crs() builder = QgsGraphBuilder(crs) tiedPoints = director.makeGraph(builder, [start_geom] + target_list) # target_list is a list of QgsPoints() # start_point is a QgsPoint() graph = builder.graph()
Everything seems to work so far, tied point are generated correctly, but when I try to find paths from
start_point to the targets by
(tree, cost) = QgsGraphAnalyzer.dijkstra(graph, idSource, 0)
some of the
tied_points cannot be reached in the graph (i.e.
tree[id_target] =-1 for certain point).
My first thought was that there is something wrong with my vector layer but it seems topologically correct (no gaps or duplicate consecutive point e.g.), no matter if LineStrings or MultiLineStrings.
Since I thought that each tied point should be reachable in the graph, what can be the reason for the 'non-reachability' of some points on such? Could this be a problem of LineString directions in the network layer?