57 double minHighwaySpeed = oc.
getFloat(
"ramps.min-highway-speed");
58 double maxRampSpeed = oc.
getFloat(
"ramps.max-ramp-speed");
59 double rampLength = oc.
getFloat(
"ramps.ramp-length");
60 bool dontSplit = oc.
getBool(
"ramps.no-split");
61 std::set<NBEdge*> incremented;
63 if (oc.
getBool(
"ramps.guess")) {
68 std::set<std::string> noramps;
69 if (oc.
isSet(
"ramps.unset")) {
71 noramps.insert(edges.begin(), edges.end());
75 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
76 it_round != roundabouts.end(); ++it_round) {
77 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
78 noramps.insert((*it_edge)->getID());
82 std::set<NBNode*, Named::ComparatorIdLess> potOnRamps;
83 std::set<NBNode*, Named::ComparatorIdLess> potOffRamps;
84 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
86 if (
mayNeedOnRamp(cur, minHighwaySpeed, maxRampSpeed, noramps)) {
87 potOnRamps.insert(cur);
90 potOffRamps.insert(cur);
93 for (std::set<NBNode*, Named::ComparatorIdLess>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
96 for (std::set<NBNode*, Named::ComparatorIdLess>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) {
101 if (oc.
isSet(
"ramps.set")) {
106 for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) {
109 WRITE_WARNING(
"Can not build on ramp on edge '" + *i +
"' - the edge is not known.");
114 buildOnRamp(from, nc, ec, dc, rampLength, dontSplit);
119 WRITE_WARNING(
"Can not build off ramp on edge '" + *i +
"' - the edge is not known.");
136 NBEdge* potHighway, *potRamp, *cont;
149 NBEdge* potHighway, *potRamp, *prev;
157 NBEdge* potHighway, *potRamp, *cont;
165 std::set<NBEdge*> incremented;
166 if (toAdd > 0 && find(incremented.begin(), incremented.end(), cont) == incremented.end()) {
167 double currLength = 0;
169 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
174 incremented.insert(curr);
192 }
else if (curr == potHighway || curr == potRamp) {
202 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
204 bool wasFirst = first == curr;
207 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
209 std::string name = curr->
getID();
212 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
217 incremented.insert(curr);
228 if (curr == cont && dontSplit) {
229 WRITE_WARNING(
"Could not build on-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
234 for (
int i = 0; i < firstLaneNumber - potHighway->
getNumLanes(); ++i) {
260 NBEdge* potHighway, *potRamp, *prev;
268 std::set<NBEdge*> incremented;
269 if (toAdd > 0 && find(incremented.begin(), incremented.end(), prev) == incremented.end()) {
270 double currLength = 0;
272 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
277 incremented.insert(curr);
295 }
else if (curr == potHighway || curr == potRamp) {
305 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
307 bool wasFirst = first == curr;
311 throw ProcessError(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
313 std::string name = curr->
getID();
316 WRITE_ERROR(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"'!");
319 curr = ec.
retrieve(name +
"-AddedOffRampEdge");
320 incremented.insert(curr);
327 if (curr == prev && dontSplit) {
328 WRITE_WARNING(
"Could not build off-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
355 const double offset = (0.5 * addedLanes *
367 if (fabs((*potHighway)->getSpeed() - (*potRamp)->getSpeed()) < .1) {
370 if ((*potHighway)->getSpeed() < (*potRamp)->getSpeed()) {
371 std::swap(*potHighway, *potRamp);
379 if ((*potHighway)->getNumLanes() == (*potRamp)->getNumLanes()) {
382 if ((*potHighway)->getNumLanes() < (*potRamp)->getNumLanes()) {
383 std::swap(*potHighway, *potRamp);
393 assert(edges.size() == 2);
394 *potHighway = edges[0];
408 std::swap(*potHighway, *potRamp);
417 *potHighway = edges[0];
419 assert(edges.size() == 2);
431 const std::vector<NBEdge*>& edges2 = n->
getEdges();
432 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
434 if ((*i) == *potRamp) {
435 std::swap(*potHighway, *potRamp);
448 NBEdge* potHighway,
NBEdge* potRamp,
NBEdge* other,
double minHighwaySpeed,
double maxRampSpeed,
449 const std::set<std::string>& noramps) {
464 if (maxSpeed < minHighwaySpeed) {
497 if (maxRampSpeed > 0 && maxRampSpeed < potRamp->getSpeed()) {
500 if (noramps.find(other->
getID()) != noramps.end()) {
514 for (
int i = 0; i < (int)edge->
getNumLanes(); ++i) {
static double relAngle(double angle1, double angle2)
computes the relative angle between the two angles
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
static bool determinedBySpeed(NBEdge **potHighway, NBEdge **potRamp)
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
const double SUMO_const_laneWidth
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
A container for districts.
double getSpeed() const
Returns the speed allowed on this edge.
static bool mayNeedOffRamp(NBNode *cur, double minHighwaySpeed, double maxRampSpeed, const std::set< std::string > &noramps)
Determines whether the given node may be an off-ramp end.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
static void moveRampRight(NBEdge *ramp, int addedLanes)
Moves the ramp to the right, as new lanes were added.
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
static const double UNSPECIFIED_WIDTH
unspecified lane width
#define WRITE_WARNING(msg)
The connection was computed and validated.
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
static bool determinedByLaneNumber(NBEdge **potHighway, NBEdge **potRamp)
static const std::string ADDED_ON_RAMP_EDGE
suffix for newly generated on-ramp edges
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
const std::string & getID() const
Returns the id.
void incLaneNo(int by)
increment lane
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
double getLaneWidth() const
Returns the default width of lanes of this edge.
static bool fulfillsRampConstraints(NBEdge *potHighway, NBEdge *potRamp, NBEdge *other, double minHighwaySpeed, double maxRampSpeed, const std::set< std::string > &noramps)
Checks whether an on-/off-ramp can be bult here.
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
bool addLane2LaneConnections(int fromLane, NBEdge *dest, int toLane, int no, Lane2LaneInfoType type, bool invalidatePrevious=false, bool mayDefinitelyPass=false)
Builds no connections starting at the given lanes.
int getNumLanes() const
Returns the number of lanes.
EdgeBuildingStep getStep() const
The building step of this edge.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
static bool mayNeedOnRamp(NBNode *cur, double minHighwaySpeed, double maxRampSpeed, const std::set< std::string > &noramps)
Determines whether the given node may be an on-ramp begin.
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
double length() const
Returns the length.
Storage for edges, including some functionality operating on multiple edges.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
void move2side(double amount)
move position vector to side using certain ammount
vehicle is a passenger car (a "normal" car)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
NBNode * getToNode() const
Returns the destination node of the edge.
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc)
Computes highway on-/off-ramps (if wished)
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
static void getOffRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
static void buildOffRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, double rampLength, bool dontSplit)
Builds an off-ramp ending at the given node.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Instance responsible for building networks.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
bool isMacroscopicConnector() const
Returns whether this edge was marked as a macroscopic connector.
A storage for options typed value containers)
static void buildOnRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, double rampLength, bool dontSplit)
Builds an on-ramp starting at the given node.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Represents a single node (junction) during network building.
static void getOnRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
static bool hasWrongMode(NBEdge *edge)
whether the edge has a mode that does not indicate a ramp edge
Container for nodes during the netbuilding process.
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
NBNode * getFromNode() const
Returns the origin node of the edge.