42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
63 bool dontSplit = oc.
getBool(
"ramps.no-split");
64 std::set<NBEdge*> incremented;
66 if (oc.
getBool(
"ramps.guess")) {
70 std::set<NBNode*> potOnRamps;
71 std::set<NBNode*> potOffRamps;
72 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
75 potOnRamps.insert(cur);
78 potOffRamps.insert(cur);
81 for (std::set<NBNode*>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
82 buildOnRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented);
84 for (std::set<NBNode*>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) {
85 buildOffRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented);
89 if (oc.
isSet(
"ramps.set")) {
94 for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) {
97 WRITE_WARNING(
"Can not build on ramp on edge '" + *i +
"' - the edge is not known.");
102 buildOnRamp(from, nc, ec, dc, rampLength, dontSplit, incremented);
107 WRITE_WARNING(
"Can not build off ramp on edge '" + *i +
"' - the edge is not known.");
112 buildOffRamp(to, nc, ec, dc, rampLength, dontSplit, incremented);
124 NBEdge* potHighway, *potRamp, *cont;
137 NBEdge* potHighway, *potRamp, *prev;
145 NBEdge* potHighway, *potRamp, *cont;
148 const unsigned int firstLaneNumber = cont->
getNumLanes();
153 if (toAdd > 0 && find(incremented.begin(), incremented.end(), cont) == incremented.end()) {
156 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
159 incremented.insert(curr);
173 }
else if (curr == potHighway || curr == potRamp) {
183 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
185 bool wasFirst = first == curr;
188 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
190 std::string name = curr->
getID();
193 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
198 incremented.insert(curr);
205 if (curr == cont && dontSplit) {
206 WRITE_WARNING(
"Could not build on-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
227 NBEdge* potHighway, *potRamp, *prev;
230 const unsigned int firstLaneNumber = prev->
getNumLanes();
235 if (toAdd > 0 && find(incremented.begin(), incremented.end(), prev) == incremented.end()) {
238 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
241 incremented.insert(curr);
255 }
else if (curr == potHighway || curr == potRamp) {
265 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
267 bool wasFirst = first == curr;
271 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
273 std::string name = curr->
getID();
276 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
279 curr = ec.
retrieve(name +
"-AddedOffRampEdge");
280 incremented.insert(curr);
287 if (curr == prev && dontSplit) {
288 WRITE_WARNING(
"Could not build off-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
314 const SUMOReal offset = (0.5 * addedLanes *
326 if (fabs((*potHighway)->getSpeed() - (*potRamp)->getSpeed()) < .1) {
329 if ((*potHighway)->getSpeed() < (*potRamp)->getSpeed()) {
330 std::swap(*potHighway, *potRamp);
338 if ((*potHighway)->getNumLanes() == (*potRamp)->getNumLanes()) {
341 if ((*potHighway)->getNumLanes() < (*potRamp)->getNumLanes()) {
342 std::swap(*potHighway, *potRamp);
352 assert(edges.size() == 2);
353 *potHighway = edges[0];
366 const std::vector<NBEdge*>& edges2 = n->
getEdges();
367 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
369 if ((*i) == *potHighway) {
370 std::swap(*potHighway, *potRamp);
379 *potHighway = edges[0];
381 assert(edges.size() == 2);
393 const std::vector<NBEdge*>& edges2 = n->
getEdges();
394 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
396 if ((*i) == *potRamp) {
397 std::swap(*potHighway, *potRamp);
419 if (maxSpeed < minHighwaySpeed) {
442 if (maxRampSpeed > 0 && maxRampSpeed < potRamp->getSpeed()) {
void invalidateConnections(bool reallowSetting=false)
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
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.
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
const SUMOReal SUMO_const_laneWidth
static bool determinedBySpeed(NBEdge **potHighway, NBEdge **potRamp)
static bool mayNeedOnRamp(NBNode *cur, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed)
Determines whether the given node may be an on-ramp begin.
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.
void incLaneNo(unsigned int by)
A container for districts.
bool addLane2LaneConnections(unsigned int fromLane, NBEdge *dest, unsigned int toLane, unsigned int no, Lane2LaneInfoType type, bool invalidatePrevious=false, bool mayDefinitelyPass=false)
Builds no connections starting at the given lanes.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
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.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
#define WRITE_WARNING(msg)
static void buildOnRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, SUMOReal rampLength, bool dontSplit, std::set< NBEdge * > &incremented)
Builds an on-ramp starting at the given node.
The connection was computed and validated.
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.
const std::string & getID() const
Returns the id.
static void buildOffRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, SUMOReal rampLength, bool dontSplit, std::set< NBEdge * > &incremented)
Builds an off-ramp ending at the given node.
A point in 2D or 3D with translation and scaling methods.
Position pop_front()
Removes and returns the position at the fron of the list.
NBEdgeCont & getEdgeCont()
Returns the edge container.
void push_front(const Position &p)
Puts the given position at the front of the list.
unsigned int getNumLanes() const
Returns the number of lanes.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
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.
static bool mayNeedOffRamp(NBNode *cur, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed)
Determines whether the given node may be an off-ramp end.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
SUMOReal length() const
Returns the length.
static bool fulfillsRampConstraints(NBEdge *potHighway, NBEdge *potRamp, NBEdge *other, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed)
Checks whether an on-/off-ramp can be bult here.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
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)
NBNodeCont & getNodeCont()
Returns 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)
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)
void move2side(SUMOReal amount)
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Container for nodes during the netbuilding process.
NBDistrictCont & getDistrictCont()
Returns the districts container.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
SUMOReal getLength() const
Returns the computed length of the edge.
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.