Skip to content

Commit 4b7af3a

Browse files
committed
avoid sorting by pointer (to simplify debugging). refs #16954
1 parent bc0f278 commit 4b7af3a

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

src/netbuild/NBNodeShapeComputer.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ NBNodeShapeComputer::computeNodeShapeDefault(bool simpleContinuation) {
155155
// initialise
156156
EdgeVector::const_iterator i;
157157
// edges located in the value-vector have the same direction as the key edge
158-
std::map<NBEdge*, std::set<NBEdge*> > same;
158+
std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> > same;
159159
// the counter-clockwise boundary of the edge regarding possible same-direction edges
160160
GeomsMap geomsCCW;
161161
// the clockwise boundary of the edge regarding possible same-direction edges
@@ -548,7 +548,7 @@ NBNodeShapeComputer::closestIntersection(const PositionVector& geom1, const Posi
548548

549549
bool
550550
NBNodeShapeComputer::needsLargeTurn(NBEdge* e1, NBEdge* e2,
551-
std::map<NBEdge*, std::set<NBEdge*> >& same) const {
551+
std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> >& same) const {
552552
const SVCPermissions p1 = e1->getPermissions();
553553
const SVCPermissions p2 = e2->getPermissions();
554554
if ((p1 & p2 & SVC_LARGE_TURN) != 0) {
@@ -694,7 +694,7 @@ NBNodeShapeComputer::computeEdgeBoundaries(const EdgeVector& edges,
694694
}
695695

696696
void
697-
NBNodeShapeComputer::joinSameDirectionEdges(const EdgeVector& edges, std::map<NBEdge*, std::set<NBEdge*> >& same, bool useEndpoints) {
697+
NBNodeShapeComputer::joinSameDirectionEdges(const EdgeVector& edges, std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> >& same, bool useEndpoints) {
698698
// compute same (edges where an intersection doesn't work well
699699
// (always check an edge and its cw neighbor)
700700
const double angleChangeLookahead = 35; // distance to look ahead for a misleading angle
@@ -732,6 +732,7 @@ NBNodeShapeComputer::joinSameDirectionEdges(const EdgeVector& edges, std::map<NB
732732
#ifdef DEBUG_NODE_SHAPE
733733
if (DEBUGCOND) {
734734
std::cout << " checkSameDirection " << (*i)->getID() << " " << (*j)->getID()
735+
<< " sameGeom=" << sameGeom
735736
<< " diffDirs=" << differentDirs
736737
<< " isOpposite=" << (differentDirs && foundOpposite.count(*i) == 0)
737738
<< " angleDiff=" << angleDiff
@@ -834,7 +835,7 @@ NBNodeShapeComputer::badIntersection(const NBEdge* e1, const NBEdge* e2, double
834835
EdgeVector
835836
NBNodeShapeComputer::computeUniqueDirectionList(
836837
const EdgeVector& all,
837-
std::map<NBEdge*, std::set<NBEdge*> >& same,
838+
std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> >& same,
838839
GeomsMap& geomsCCW,
839840
GeomsMap& geomsCW) {
840841
// store relationships
@@ -1098,7 +1099,7 @@ NBNodeShapeComputer::getDefaultRadius(const OptionsCont& oc) {
10981099

10991100

11001101
bool
1101-
NBNodeShapeComputer::isDivided(const NBEdge* e, std::set<NBEdge*> same, const PositionVector& ccw, const PositionVector& cw) const {
1102+
NBNodeShapeComputer::isDivided(const NBEdge* e, std::set<NBEdge*, ComparatorIdLess> same, const PositionVector& ccw, const PositionVector& cw) const {
11021103
if (same.size() < 2) {
11031104
return false;
11041105
}
@@ -1138,7 +1139,7 @@ NBNodeShapeComputer::getExtraWidth(const NBEdge* e, SVCPermissions exclude) {
11381139

11391140

11401141
double
1141-
NBNodeShapeComputer::divisionWidth(const NBEdge* e, std::set<NBEdge*> same, const Position& p, const Position& p2) {
1142+
NBNodeShapeComputer::divisionWidth(const NBEdge* e, std::set<NBEdge*, ComparatorIdLess> same, const Position& p, const Position& p2) {
11421143
double result = p.distanceTo2D(p2);
11431144
result -= e->getTotalWidth();
11441145
for (NBEdge* e2 : same) {

src/netbuild/NBNodeShapeComputer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class NBNodeShapeComputer {
9292
* all edges within the value-vector which direction at the node differs
9393
* less than 1 from the key-edge's direction.
9494
*/
95-
void joinSameDirectionEdges(const EdgeVector& edges, std::map<NBEdge*, std::set<NBEdge*> >& same, bool useEndpoints);
95+
void joinSameDirectionEdges(const EdgeVector& edges, std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> >& same, bool useEndpoints);
9696

9797
/** @brief Joins edges
9898
*
@@ -102,7 +102,7 @@ class NBNodeShapeComputer {
102102
*/
103103
EdgeVector computeUniqueDirectionList(
104104
const EdgeVector& all,
105-
std::map<NBEdge*, std::set<NBEdge*> >& same,
105+
std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> >& same,
106106
GeomsMap& geomsCCW,
107107
GeomsMap& geomsCW);
108108

@@ -143,20 +143,20 @@ class NBNodeShapeComputer {
143143

144144
/// @brief whether the given edges (along with those in the same direction) requires a large turning radius
145145
bool needsLargeTurn(NBEdge* e1, NBEdge* e2,
146-
std::map<NBEdge*, std::set<NBEdge*> >& same) const;
146+
std::map<NBEdge*, std::set<NBEdge*, ComparatorIdLess> >& same) const;
147147

148148
/// @brief determine the default radius appropriate for the current junction
149149
double getDefaultRadius(const OptionsCont& oc);
150150

151151
void computeSameEnd(PositionVector& l1, PositionVector& l2);
152152

153-
bool isDivided(const NBEdge* e, std::set<NBEdge*> same, const PositionVector& ccw, const PositionVector& cw) const;
153+
bool isDivided(const NBEdge* e, std::set<NBEdge*, ComparatorIdLess> same, const PositionVector& ccw, const PositionVector& cw) const;
154154

155155
/// @brief compute with of rightmost lanes that exlude the given permissions
156156
static double getExtraWidth(const NBEdge* e, SVCPermissions exclude);
157157

158158
/// @brief compute the width of the divider space for divided roads
159-
static double divisionWidth(const NBEdge* e, std::set<NBEdge*> same, const Position& p, const Position& p2);
159+
static double divisionWidth(const NBEdge* e, std::set<NBEdge*, ComparatorIdLess> same, const Position& p, const Position& p2);
160160

161161
private:
162162
/// The node to compute the geometry for

src/utils/common/ToString.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ inline std::string joinNamedToStringSorting(const std::set<T*>& ns, const T_BETW
312312
return joinToStringSorting(ids, between);
313313
}
314314

315+
template <typename T, typename T_BETWEEN>
316+
inline std::string joinNamedToStringSorting(const std::set<T*, ComparatorIdLess>& ns, const T_BETWEEN& between) {
317+
std::vector<std::string> ids;
318+
for (T* n : ns) {
319+
ids.push_back(Named::getIDSecure(n));
320+
}
321+
return joinToStringSorting(ids, between);
322+
}
323+
315324

316325
template <typename T, typename C, typename T_BETWEEN>
317326
inline std::string joinNamedToString(const std::set<T*, C>& ns, const T_BETWEEN& between) {

0 commit comments

Comments
 (0)