Hanging request
sandboiii opened this issue · 6 comments
Most of my calls execute fast, but I'm currently experience one hanging request. I'm not sure if it's even executes in the end, it surely takes more than 10 minutes and it's bothering me. Version 1.4
router = Router('car')
start = router.findNode(-1.346286, 36.768793)
end = router.findNode(-1.293973, 36.80169)
status, route = router.doRoute(start, end)
This is usually caused because there's no route between start
and end
nodes — A* algorithm used by pyroutelib3 needs to examine the whole graph before concluding that no route exists. And since you're using auto-download, the whole graph means the whole planet. And that, as you might imagine, might take a quite a lot of time to download and process.
(Digression: you'll probably run out of disk space, RAM, or hit a hardcoded limit in pyroutelib3 before seeing "no_route" returned.)
Because of that I actually discourage using the automatic tile downloading: Try routing using the "offline router" (you can export an .osm file from https://www.openstreetmap.org/export) — and then see if the issue still exists.
To add more context: I tried to build routes for this competition. All locations were taken from one city and there surely must be routes between them. After facing this issue I did all my routes via osmx and networkx. Most of locations including my example from above had routes and these routes were found fast. So, your suggestion to use offline router is probably correct, but I didn't try to do it with pyroutelib.
See #11. This would usually happen when start or end nodes end up on a street disconnected from other streets. Still, that's an issue with the graph, not pyroutelib3.
Let me know if you get long doRoute()
calls with offline routing, otherwise imma close this issue.
Closed: no input for over 2 months.
Hello, can someone help me please?
I have a list of destinations and I want to create a route between all of these destinations
@app.route("/trajet", methods=["GET"])
def trajet():
id = request.args.get("idp")
P = Planning.objects.get(idP=id)
c = folium.Map(location=[50.723960, 1.614347], zoom_start=15)
def createroute(x, y):
router = Router("car")
coor_depart = [x[0], x[1]]
coor_arrivee = [y[0], x[1]]
# Create markers !
folium.Marker(coor_depart, popup="Départ").add_to(c)
folium.Marker(coor_arrivee, popup="Arrivée").add_to(c)
# Generate route
dep = router.findNode(coor_depart[0], coor_depart[1])
ar = router.findNode(coor_arrivee[0], coor_arrivee[1])
routeLatLons = [coor_depart, coor_arrivee]
status, route = router.doRoute(dep, ar)
if status == 'success':
print("route trouvé")
routeLatLons = list(map(router.nodeLatLon, route))
else:
print("route pas trouvée!")
for coord in routeLatLons:
coord = list(coord)
folium.CircleMarker(coord, radius=3, weight=2.5, opacity=1).add_to(c)
folium.PolyLine(routeLatLons, color="blue", weight=2.5, opacity=1).add_to(c)
fich = "mapPlan.html"
return fich
fich = createroute(pnt_dep, P.dest[0])
c.save(fich)
for i in range(len(P.dest) - 1):
fich = createroute(P.dest[i], P.dest[i + 1])
c.save(fich)
webbrowser.open(fich)
return make_response("Done", 200)
but I still get the same error : restrType=rel["tag"]["restriction"]
Any other solution?
@ChahedOns Don't revive old issues, especially with unrelated information. You also haven't posted any errors, but judging by the single information it's an issue with an invalid turn restriction — a problem with OSM data, not pyroutelib3.