Make intersection backwards compatible

For `depart` and `arrive` `step.intersections[0].{bearings|entry}` will have
only one entry.
This commit is contained in:
Patrick Niklaus
2016-05-18 17:53:05 +02:00
parent 3b37769624
commit 95af72c70c
10 changed files with 272 additions and 235 deletions
+8
View File
@@ -89,6 +89,14 @@ inline bool CheckInBounds(const int A, const int B, const int range)
return normalized_B - range <= normalized_A && normalized_A <= normalized_B + range;
}
}
inline double reverseBearing(const double bearing)
{
if (bearing >= 180)
return bearing - 180.;
return bearing + 180;
}
}
}
}
-30
View File
@@ -49,36 +49,6 @@ inline extractor::guidance::DirectionModifier getTurnDirection(const double angl
return extractor::guidance::DirectionModifier::UTurn;
}
inline engine::guidance::Intersection
setIntersectionClasses(engine::guidance::Intersection intersection,
const engine::PhantomNode &phantom)
{
BOOST_ASSERT(intersection.bearing_before == 0 || intersection.bearing_after == 0);
const double bearing = std::max(intersection.bearing_before, intersection.bearing_after);
intersection.bearing_class = {};
intersection.entry_class = {};
if (bearing >= 180.)
{
intersection.bearing_class.add(std::round(bearing - 180.));
if (phantom.forward_segment_id.id != SPECIAL_SEGMENTID &&
phantom.reverse_segment_id.id != SPECIAL_SEGMENTID)
intersection.entry_class.activate(0);
intersection.bearing_class.add(std::round(bearing));
intersection.entry_class.activate(1);
}
else
{
intersection.bearing_class.add(std::round(bearing));
intersection.entry_class.activate(0);
intersection.bearing_class.add(std::round(bearing + 180.));
if (phantom.forward_segment_id.id != SPECIAL_SEGMENTID &&
phantom.reverse_segment_id.id != SPECIAL_SEGMENTID)
intersection.entry_class.activate(1);
}
return intersection;
}
} // namespace guidance
} // namespace util
} // namespace osrm