Only allow to start on streets

This commit is contained in:
Markus Koch 2021-02-26 19:27:26 +01:00
parent a87ca8a949
commit aa7256c12e

View File

@ -512,13 +512,22 @@ inline struct dijkstra_node *dijkstra_node_get_connection(struct dijkstra_node *
struct dijkstra_node *dijkstra_node_find_closest_node(struct dijkstra_solver *solver,
struct position *position) {
GList *l = NULL;
GList *pl = NULL;
struct dijkstra_node *node = NULL;
struct dijkstra_node *closest_node = NULL;
struct dijkstra_path *path = NULL;
float closest_distance;
float distance;
for (l = solver->nodes; l != NULL; l = l->next) {
node = (struct dijkstra_node*) l->data;
for (pl = node->paths; pl != NULL; pl = pl->next) {
path = (struct dijkstra_path*) pl->data;
if (path->net_meta->type == STREET)
break;
}
if (!(path && path->net_meta->type == STREET))
continue; // Only start on nodes that are part of a street
distance = dijkstra_position_get_distance(position, &node->position);
if (!closest_node || distance < closest_distance) {
closest_node = node;