Do not use z-coordinate for speed on TRAINLINE or ACCESS

Using the z-coordinate as is is a bad idea. When intersecting, a
new node will be generated. What z-coord should it be? This node
can now be part of two distinct types with different meanings for
it. So we need to implement weight as a path argument.

This commit hardcodes the speed for trains and access pathways as
a temporary workaround.
This commit is contained in:
Markus Koch 2021-03-13 13:02:19 +01:00
parent b12da0e421
commit e01245cb98
2 changed files with 6 additions and 18 deletions

View File

@ -175,11 +175,11 @@ dijkstra_cost dijkstra_get_weight_from_distance(struct dijkstra_node *node_a,
float scale; float scale;
switch (net_type) { switch (net_type) {
case TRAINLINE: // Trainlines and access types use the z-coordinate case TRAINLINE:
case ACCESS: // for cost scaling. scale = 5.0;
scale = (float)node_a->position.z; break;
scale += (float)node_b->position.z; case ACCESS:
scale /= 200; scale = 0.5;
break; break;
default: default:
scale = 1.0; scale = 1.0;

View File

@ -97,19 +97,7 @@ int add_geojson_to_dijkstra(struct dijkstra_solver *solver,
json_reader_read_member(reader, "geometry"); json_reader_read_member(reader, "geometry");
json_reader_read_member(reader, "coordinates"); json_reader_read_member(reader, "coordinates");
switch (net_type) {
case STREET:
z_last = 0; // By default, let's assume height 0 z_last = 0; // By default, let's assume height 0
break;
case TRAINLINE:
z_last = 1000; // By default, let's assume 10x normal speed
break;
case ACCESS:
z_last = 99; // TODO: By default, let's introduce a penalty to get on the train (ACCESS walk 10x slower)
break;
default:
z_last = -1;
}
net_meta = dijkstra_net_meta_new_to_list(solver, net_type, name, access); net_meta = dijkstra_net_meta_new_to_list(solver, net_type, name, access);
if (json_reader_is_array(reader)) { if (json_reader_is_array(reader)) {
j_max = json_reader_count_elements(reader); j_max = json_reader_count_elements(reader);