Only allow to start on streets
This commit is contained in:
parent
a87ca8a949
commit
aa7256c12e
@ -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 dijkstra_node *dijkstra_node_find_closest_node(struct dijkstra_solver *solver,
|
||||||
struct position *position) {
|
struct position *position) {
|
||||||
GList *l = NULL;
|
GList *l = NULL;
|
||||||
|
GList *pl = NULL;
|
||||||
struct dijkstra_node *node = NULL;
|
struct dijkstra_node *node = NULL;
|
||||||
struct dijkstra_node *closest_node = NULL;
|
struct dijkstra_node *closest_node = NULL;
|
||||||
|
struct dijkstra_path *path = NULL;
|
||||||
float closest_distance;
|
float closest_distance;
|
||||||
float distance;
|
float distance;
|
||||||
|
|
||||||
for (l = solver->nodes; l != NULL; l = l->next) {
|
for (l = solver->nodes; l != NULL; l = l->next) {
|
||||||
node = (struct dijkstra_node*) l->data;
|
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);
|
distance = dijkstra_position_get_distance(position, &node->position);
|
||||||
if (!closest_node || distance < closest_distance) {
|
if (!closest_node || distance < closest_distance) {
|
||||||
closest_node = node;
|
closest_node = node;
|
||||||
|
Loading…
Reference in New Issue
Block a user