2016-04-08 06:49:14 -04:00
|
|
|
#include "extractor/guidance/intersection.hpp"
|
|
|
|
|
2016-11-03 05:18:27 -04:00
|
|
|
#include <limits>
|
2016-10-26 17:32:29 -04:00
|
|
|
#include <string>
|
2016-11-03 05:18:27 -04:00
|
|
|
|
2016-12-02 04:53:22 -05:00
|
|
|
using osrm::util::angularDeviation;
|
|
|
|
|
2016-04-08 06:49:14 -04:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
|
2016-11-18 03:38:26 -05:00
|
|
|
bool IntersectionViewData::CompareByAngle(const IntersectionViewData &other) const
|
2016-11-03 05:18:27 -04:00
|
|
|
{
|
2016-11-18 03:38:26 -05:00
|
|
|
return angle < other.angle;
|
2016-11-03 05:18:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ConnectedRoad::compareByAngle(const ConnectedRoad &other) const { return angle < other.angle; }
|
|
|
|
|
|
|
|
void ConnectedRoad::mirror()
|
|
|
|
{
|
|
|
|
const constexpr DirectionModifier::Enum mirrored_modifiers[] = {DirectionModifier::UTurn,
|
|
|
|
DirectionModifier::SharpLeft,
|
|
|
|
DirectionModifier::Left,
|
|
|
|
DirectionModifier::SlightLeft,
|
|
|
|
DirectionModifier::Straight,
|
|
|
|
DirectionModifier::SlightRight,
|
|
|
|
DirectionModifier::Right,
|
|
|
|
DirectionModifier::SharpRight};
|
|
|
|
|
|
|
|
static_assert(sizeof(mirrored_modifiers) / sizeof(DirectionModifier::Enum) ==
|
|
|
|
DirectionModifier::MaxDirectionModifier,
|
|
|
|
"The list of mirrored modifiers needs to match the available modifiers in size.");
|
|
|
|
|
|
|
|
if (angularDeviation(angle, 0) > std::numeric_limits<double>::epsilon())
|
|
|
|
{
|
|
|
|
angle = 360 - angle;
|
|
|
|
instruction.direction_modifier = mirrored_modifiers[instruction.direction_modifier];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectedRoad ConnectedRoad::getMirroredCopy() const
|
2016-04-08 06:49:14 -04:00
|
|
|
{
|
2016-11-03 05:18:27 -04:00
|
|
|
ConnectedRoad copy(*this);
|
|
|
|
copy.mirror();
|
|
|
|
return copy;
|
2016-04-08 06:49:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString(const ConnectedRoad &road)
|
|
|
|
{
|
|
|
|
std::string result = "[connection] ";
|
2016-11-03 05:18:27 -04:00
|
|
|
result += std::to_string(road.eid);
|
2016-04-08 06:49:14 -04:00
|
|
|
result += " allows entry: ";
|
|
|
|
result += std::to_string(road.entry_allowed);
|
|
|
|
result += " angle: ";
|
2016-11-03 05:18:27 -04:00
|
|
|
result += std::to_string(road.angle);
|
2016-08-17 03:49:19 -04:00
|
|
|
result += " bearing: ";
|
2016-11-03 05:18:27 -04:00
|
|
|
result += std::to_string(road.bearing);
|
2016-04-08 06:49:14 -04:00
|
|
|
result += " instruction: ";
|
2016-11-03 05:18:27 -04:00
|
|
|
result += std::to_string(static_cast<std::int32_t>(road.instruction.type)) + " " +
|
|
|
|
std::to_string(static_cast<std::int32_t>(road.instruction.direction_modifier)) + " " +
|
|
|
|
std::to_string(static_cast<std::int32_t>(road.lane_data_id));
|
2016-04-08 06:49:14 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace guidance
|
|
|
|
} // namespace extractor
|
|
|
|
} // namespace osrm
|