Abstracts away over differences in IntersectionView and Intersection.

Usage:

    struct MyIntersection : EnableIntersectionOps<MyIntersection> {

    };

Done.

We require MyIntersection having at least the member attributes from
IntersectionViewData but don't enforce a inheritance hierarchy.
This commit is contained in:
Daniel J. Hofmann
2016-12-02 12:02:42 +01:00
committed by Moritz Kobitzsch
parent 928a6f0c7d
commit 9d8b92f418
5 changed files with 47 additions and 62 deletions
+3 -1
View File
@@ -14,7 +14,9 @@ IntersectionPrinter::IntersectionPrinter(
const std::vector<extractor::QueryNode> &node_coordinates,
const extractor::guidance::CoordinateExtractor &coordinate_extractor)
: node_based_graph(node_based_graph), node_coordinates(node_coordinates),
coordinate_extractor(coordinate_extractor){};
coordinate_extractor(coordinate_extractor)
{
}
util::json::Array IntersectionPrinter::
operator()(const NodeID intersection_node,
@@ -55,7 +55,7 @@ double GetOffsetCorrectionFactor(const RoadClassification &road_classification)
default:
return 1.0;
};
};
}
}
CoordinateExtractor::CoordinateExtractor(
-33
View File
@@ -70,39 +70,6 @@ std::string toString(const ConnectedRoad &road)
return result;
}
IntersectionView::Base::iterator IntersectionView::findClosestTurn(double angle)
{
// use the const operator to avoid code duplication
return begin() +
std::distance(cbegin(),
static_cast<const IntersectionView *>(this)->findClosestTurn(angle));
}
IntersectionView::Base::const_iterator IntersectionView::findClosestTurn(double angle) const
{
return std::min_element(
begin(), end(), [angle](const IntersectionViewData &lhs, const IntersectionViewData &rhs) {
return util::guidance::angularDeviation(lhs.angle, angle) <
util::guidance::angularDeviation(rhs.angle, angle);
});
}
Intersection::Base::iterator Intersection::findClosestTurn(double angle)
{
// use the const operator to avoid code duplication
return begin() +
std::distance(cbegin(), static_cast<const Intersection *>(this)->findClosestTurn(angle));
}
Intersection::Base::const_iterator Intersection::findClosestTurn(double angle) const
{
return std::min_element(
begin(), end(), [angle](const ConnectedRoad &lhs, const ConnectedRoad &rhs) {
return util::guidance::angularDeviation(lhs.angle, angle) <
util::guidance::angularDeviation(rhs.angle, angle);
});
}
bool Intersection::valid() const
{
return !empty() &&