From c16c2adeda3d907e8de45d9adf048f1318aeab94 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Thu, 27 Sep 2012 14:55:48 +0200 Subject: [PATCH] Fixes cucumber test features/bad.feature:15 --- DataStructures/Coordinate.h | 4 +++- DataStructures/PhantomNodes.h | 8 ++++++++ RoutingAlgorithms/AlternativePathRouting.h | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DataStructures/Coordinate.h b/DataStructures/Coordinate.h index 21b43ed8f..d7995fbe2 100644 --- a/DataStructures/Coordinate.h +++ b/DataStructures/Coordinate.h @@ -42,7 +42,9 @@ struct _Coordinate { } return true; } - + bool operator==(const _Coordinate & other) const { + return lat == other.lat && lon == other.lon; + } }; inline std::ostream & operator<<(std::ostream & out, const _Coordinate & c){ diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index 461dfdf08..2827d7a91 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -45,6 +45,10 @@ struct PhantomNode { bool isValid(const unsigned numberOfNodes) const { return location.isValid() && (edgeBasedNode < numberOfNodes) && (weight1 != INT_MAX) && (ratio >= 0.) && (ratio <= 1.) && (nodeBasedEdgeNameID != UINT_MAX); } + + bool operator==(const PhantomNode & other) const { + return location == other.location; + } }; struct PhantomNodes { @@ -62,6 +66,10 @@ struct PhantomNodes { bool AtLeastOnePhantomNodeIsUINTMAX() const { return !(startPhantom.edgeBasedNode == UINT_MAX || targetPhantom.edgeBasedNode == UINT_MAX); } + + bool PhantomNodesHaveEqualLocation() const { + return startPhantom == targetPhantom; + } }; inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn){ diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index dd4e63273..2f07f33ad 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -52,10 +52,11 @@ public: ~AlternativeRouting() {} void operator()(const PhantomNodes & phantomNodePair, RawRouteData & rawRouteData) { - if(!phantomNodePair.AtLeastOnePhantomNodeIsUINTMAX()) { + if(!phantomNodePair.AtLeastOnePhantomNodeIsUINTMAX() || phantomNodePair.PhantomNodesHaveEqualLocation()) { rawRouteData.lengthOfShortestPath = rawRouteData.lengthOfAlternativePath = INT_MAX; return; } + std::vector alternativePath; std::vector viaNodeCandidates; std::deque packedShortestPath;