I am attempting to implement a feature in Experimental whereby the costs of maintaining diagonal ways are divided by 1.4 of that of standard ways, to give, with some degree of approximation, a scaled effect to match the fact that the revenues are calculated using the Euclidean distance rather than the Manhattan distance. One issue that I have yet to resolve, and on which I should appreciate some guidance from those who know the code better than I do, is how effectively to check whether a way is diagonal.
I did find some code in Standard that appeared to do that (looking a bit like this:
switch(ribi) {
case ribi_t::nordost:
if(from->get_neighbour(to, get_waytype(), koord::ost))
r1 = to->get_weg_ribi_unmasked(get_waytype());
if(from->get_neighbour(to, get_waytype(), koord::nord))
r2 = to->get_weg_ribi_unmasked(get_waytype());
diagonal =
(r1 == ribi_t::suedwest || r2 == ribi_t::suedwest) &&
r1 != ribi_t::nordwest &&
r2 != ribi_t::suedost;
break;
case ribi_t::suedost:
if(from->get_neighbour(to, get_waytype(), koord::ost))
r1 = to->get_weg_ribi_unmasked(get_waytype());
if(from->get_neighbour(to, get_waytype(), koord::sued))
r2 = to->get_weg_ribi_unmasked(get_waytype());
diagonal =
(r1 == ribi_t::nordwest || r2 == ribi_t::nordwest) &&
r1 != ribi_t::suedwest &&
r2 != ribi_t::nordost;
break;
case ribi_t::nordwest:
if(from->get_neighbour(to, get_waytype(), koord::west))
r1 = to->get_weg_ribi_unmasked(get_waytype());
if(from->get_neighbour(to, get_waytype(), koord::nord))
r2 = to->get_weg_ribi_unmasked(get_waytype());
diagonal =
(r1 == ribi_t::suedost || r2 == ribi_t::suedost) &&
r1 != ribi_t::nordost &&
r2 != ribi_t::suedwest;
break;
case ribi_t::suedwest:
if(from->get_neighbour(to, get_waytype(), koord::west))
r1 = to->get_weg_ribi_unmasked(get_waytype());
if(from->get_neighbour(to, get_waytype(), koord::sued))
r2 = to->get_weg_ribi_unmasked(get_waytype());
diagonal =
(r1 == ribi_t::nordost || r2 == ribi_t::nordost) &&
r1 != ribi_t::suedost &&
r2 != ribi_t::nordwest;
break;
), which I broke out into its own method and made "diagonal" a member of the cl****, but I could not get "ribi" to be anything other than 0 when called; it is also a little difficult to know when to call this method (calling it in "init()" makes for excessive loading times, and "ribi" is not intialised at that stage in any case). Does anyone have any thoughts on how to approach this? Any input would be much appreciated.