Skip to content

Commit

Permalink
improved geometry when building turn-lanes. refs eclipse-sumo#3892
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed May 23, 2018
1 parent 4839066 commit d61ed2a
Show file tree
Hide file tree
Showing 6 changed files with 933 additions and 925 deletions.
8 changes: 5 additions & 3 deletions src/netbuild/NBEdgeCont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,24 +522,26 @@ NBEdgeCont::processSplits(NBEdge* e, std::vector<Split> splits,
for (int lane = 0; lane < (int)e->getNumLanes(); ++lane) {
start.lanes.push_back(lane);
}
start.offset = splits.front().offset;
splits.insert(splits.begin(), start);
}
i = splits.begin();
if (e != 0) {
for (; i != splits.end(); ++i) {
int maxLeft = (*i).lanes.back();
double offset = 0;
double offset = (*i).offset;
if (maxLeft < noLanesMax) {
if (e->getLaneSpreadFunction() == LANESPREAD_RIGHT) {
offset = SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
offset += SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
} else {
offset = SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
offset += SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
}
}
int maxRight = (*i).lanes.front();
if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
offset -= SUMO_const_halfLaneAndOffset * maxRight;
}
//std::cout << " processSplits " << origID << " splitOffset=" << (*i).offset << " offset=" << offset << "\n";
if (offset != 0) {
PositionVector g = e->getGeometry();
g.move2side(offset);
Expand Down
3 changes: 3 additions & 0 deletions src/netbuild/NBEdgeCont.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class NBEdgeCont {
* @brief A structure which describes changes of lane number or speed along the road
*/
struct Split {
Split() : offset(0) {}
/// @brief The lanes after this change
std::vector<int> lanes;
/// @brief The position of this change
Expand All @@ -221,6 +222,8 @@ class NBEdgeCont {
std::string idAfter;
/// @brief the default node id
std::string nameID;
/// @brief lateral offset to edge geometry
double offset;
};

void processSplits(NBEdge* e, std::vector<Split> splits,
Expand Down
5 changes: 4 additions & 1 deletion src/netgen/NGNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ NGNet::toNB() const {
}
// add splits depending on turn-lane options
const int turnLanes = OptionsCont::getOptions().getInt("turn-lanes");
const double turnLaneLength = OptionsCont::getOptions().getFloat("turn-lanes.length");
if (turnLanes > 0) {
const double turnLaneLength = OptionsCont::getOptions().getFloat("turn-lanes.length");
NBEdgeCont& ec = myNetBuilder.getEdgeCont();
EdgeVector allEdges;
for (auto it = ec.begin(); it != ec.end(); ++it) {
Expand All @@ -269,6 +269,9 @@ NGNet::toNB() const {
split.node = new NBNode(e->getID() + "." + toString(split.pos), e->getGeometry().positionAtOffset(split.pos));
split.idBefore = e->getID();
split.idAfter = split.node->getID();
if (turnLaneLength <= e->getLength() / 2 && !e->getFromNode()->geometryLike()) {
split.offset = -0.5 * turnLanes * e->getLaneWidth(0);
}
splits.push_back(split);
ec.processSplits(e, splits,
myNetBuilder.getNodeCont(),
Expand Down
Loading

0 comments on commit d61ed2a

Please sign in to comment.