Compare commits

..

No commits in common. "f1868aba04117f2c5d0cdc1d5f3e80b4f823bd6b" and "6ffee116c7a651205c1699a96e354f48f8b0a699" have entirely different histories.

3 changed files with 11 additions and 30 deletions

View File

@ -12,7 +12,6 @@ int dijkstra_node_same (struct dijkstra_node *node_a,
int same = 1;
// Not the proper way to do it, but it works for now.
same &= (node_a->net_meta == node_b->net_meta);
same &= (fabs(node_a->position.x - node_b->position.x) < FP_THRESHOLD);
same &= (fabs(node_a->position.y - node_b->position.y) < FP_THRESHOLD);
same &= (node_a->position.z == node_b->position.z);
@ -29,8 +28,7 @@ int dijkstra_node_same (struct dijkstra_node *node_a,
struct dijkstra_node *dijkstra_node_new(float x,
float y,
int z,
int uid,
struct dijkstra_net_meta *net_meta)
int uid)
{
struct dijkstra_node *node;
@ -40,7 +38,6 @@ struct dijkstra_node *dijkstra_node_new(float x,
node->position.y = y;
node->position.z = z;
node->uid = uid;
node->net_meta = net_meta;
node->paths = NULL;
}
@ -74,8 +71,7 @@ struct dijkstra_node *dijkstra_node_exists(GList *list,
struct dijkstra_node *dijkstra_node_new_to_list(GList **list,
float x,
float y,
int z,
struct dijkstra_net_meta *net_meta)
int z)
{
struct dijkstra_node *node;
struct dijkstra_node *found;
@ -83,7 +79,7 @@ struct dijkstra_node *dijkstra_node_new_to_list(GList **list,
uid = g_list_length(*list);
node = dijkstra_node_new(x, y, z, uid, net_meta);
node = dijkstra_node_new(x, y, z, uid);
if (!node)
return NULL;
@ -324,9 +320,6 @@ int dijkstra_path_intersect(struct dijkstra_solver *solver,
return 0; // Never intersect trainlines (apart from with access types)
}
if (!target_path)
target_path = path_b; // Needed for net_meta selection below
// Check height
p0_z = path_a->source->position.z;
p1_z = path_a->destination->position.z;
@ -363,7 +356,7 @@ int dijkstra_path_intersect(struct dijkstra_solver *solver,
i_y = p0_y + (t * s1_y);
i_z = p0_z; // They must all on the same height when intersecting, so we can pick whichever.
node_new = dijkstra_node_new_to_list(&solver->nodes, i_x, i_y, i_z, target_path->source->net_meta);
node_new = dijkstra_node_new_to_list(&solver->nodes, i_x, i_y, i_z);
if (node_new != path_a->source && node_new != path_a->destination) {
path_new = dijkstra_path_dup_shallow(path_a);
solver->paths = g_list_append(solver->paths, (gpointer) path_new);
@ -381,7 +374,8 @@ int dijkstra_path_intersect(struct dijkstra_solver *solver,
path_new->destination,
path_new->net_meta->type);
dijkstra_path_intersect_all(solver, path_b, path_new); // Since straight paths can only cross once, we don't need to check any newly created entries.
// TODO: I don't have to iterate over the *entire* array here, it should be enough to only iterate over the entries after path_b.
dijkstra_path_intersect_all(solver, path_new, path_new); // Since straight paths can only cross once, we don't need to check any newly created entries.
}
// Now do the same thing for path b
@ -400,8 +394,6 @@ int dijkstra_path_intersect(struct dijkstra_solver *solver,
path_new->weight = dijkstra_get_weight_from_distance(path_new->source,
path_new->destination,
path_new->net_meta->type);
dijkstra_path_intersect_all(solver, path_a, path_new);
}
// In case neither if matches that means we are on the corner where two paths intersect at their ends.
@ -444,8 +436,8 @@ struct dijkstra_path *dijkstra_path_new_to_list(struct dijkstra_solver *solver,
GList *l_last;
struct dijkstra_path *path_last = NULL;
n1 = dijkstra_node_new_to_list(&solver->nodes, x1, y1, z1, net_meta);
n2 = dijkstra_node_new_to_list(&solver->nodes, x2, y2, z2, net_meta);
n1 = dijkstra_node_new_to_list(&solver->nodes, x1, y1, z1);
n2 = dijkstra_node_new_to_list(&solver->nodes, x2, y2, z2);
path = dijkstra_path_new(name, n1, n2, weight, net_meta);
l_last = g_list_last(solver->paths);

View File

@ -39,7 +39,6 @@ struct dijkstra_path {
struct dijkstra_node {
struct position position;
struct dijkstra_net_meta *net_meta;
GList *paths;
@ -78,7 +77,6 @@ struct dijkstra_net_meta *dijkstra_net_meta_new_to_list(struct dijkstra_solver *
struct dijkstra_node *dijkstra_node_new_to_list(GList **list,
float x,
float y,
int z,
struct dijkstra_net_meta *net_meta);
int z);
#endif // DIJKSTRAGRAPH_H

View File

@ -63,7 +63,6 @@ int add_geojson_to_dijkstra(struct dijkstra_solver *solver,
arr = json_node_get_array(root);
if (arr) {
i_max = json_array_get_length(arr);
net_meta = NULL;
for (i = 0; i < i_max; i++)
{
node = json_array_get_element(arr, i);
@ -80,12 +79,7 @@ int add_geojson_to_dijkstra(struct dijkstra_solver *solver,
json_reader_end_member(reader); // name
json_reader_end_member(reader); // properties
switch (net_type) {
case STREET:
if (!net_meta)
net_meta = dijkstra_net_meta_new_to_list(solver, net_type, NULL, NULL);
break;
case ACCESS:
if (net_type == ACCESS) {
access = name;
name = strchr(name, ':');
if (name == NULL) {
@ -99,15 +93,12 @@ int add_geojson_to_dijkstra(struct dijkstra_solver *solver,
do
name++;
while (*name == ' ' && *name != '\0');
G_GNUC_FALLTHROUGH;
case TRAINLINE:
net_meta = dijkstra_net_meta_new_to_list(solver, net_type, name, access);
break;
}
json_reader_read_member(reader, "geometry");
json_reader_read_member(reader, "coordinates");
z_last = 0; // By default, let's assume height 0
net_meta = dijkstra_net_meta_new_to_list(solver, net_type, name, access);
if (json_reader_is_array(reader)) {
j_max = json_reader_count_elements(reader);
for (j = 0; j < j_max; j++) {