40 #ifdef CHECK_MEMORY_LEAKS
42 #endif // CHECK_MEMORY_LEAKS
61 bool dontSplit = oc.
getBool(
"ramps.no-split");
62 std::set<NBEdge*> incremented;
64 if (oc.
getBool(
"ramps.guess")) {
68 std::set<NBNode*> potOnRamps;
69 std::set<NBNode*> potOffRamps;
70 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
73 potOnRamps.insert(cur);
76 potOffRamps.insert(cur);
79 for (std::set<NBNode*>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
80 buildOnRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented);
82 for (std::set<NBNode*>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) {
83 buildOffRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented);
87 if (oc.
isSet(
"ramps.set")) {
92 for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) {
95 WRITE_WARNING(
"Can not build on ramp on edge '" + *i +
"' - the edge is not known.");
100 buildOnRamp(from, nc, ec, dc, rampLength, dontSplit, incremented);
105 WRITE_WARNING(
"Can not build off ramp on edge '" + *i +
"' - the edge is not known.");
110 buildOffRamp(to, nc, ec, dc, rampLength, dontSplit, incremented);
122 NBEdge* potHighway, *potRamp, *cont;
135 NBEdge* potHighway, *potRamp, *prev;
143 NBEdge* potHighway, *potRamp, *cont;
146 const unsigned int firstLaneNumber = potHighway->
getNumLanes();
151 if (toAdd > 0 && find(incremented.begin(), incremented.end(), cont) == incremented.end()) {
154 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
157 incremented.insert(curr);
175 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
177 bool wasFirst = first == curr;
180 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
182 std::string name = curr->
getID();
185 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
191 incremented.insert(curr);
198 if (curr == cont && dontSplit) {
199 WRITE_WARNING(
"Could not build on-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
228 NBEdge* potHighway, *potRamp, *prev;
231 const unsigned int firstLaneNumber = potHighway->
getNumLanes();
236 if (toAdd > 0 && find(incremented.begin(), incremented.end(), prev) == incremented.end()) {
239 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
242 incremented.insert(curr);
260 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
262 bool wasFirst = first == curr;
266 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
268 std::string name = curr->
getID();
271 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
274 curr = ec.
retrieve(name +
"-AddedOffRampEdge");
276 incremented.insert(curr);
283 if (curr == prev && dontSplit) {
284 WRITE_WARNING(
"Could not build off-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
329 if (fabs((*potHighway)->getSpeed() - (*potRamp)->getSpeed()) < .1) {
332 if ((*potHighway)->getSpeed() < (*potRamp)->getSpeed()) {
333 std::swap(*potHighway, *potRamp);
341 if ((*potHighway)->getNumLanes() == (*potRamp)->getNumLanes()) {
344 if ((*potHighway)->getNumLanes() < (*potRamp)->getNumLanes()) {
345 std::swap(*potHighway, *potRamp);
355 assert(edges.size() == 2);
356 *potHighway = edges[0];
369 const std::vector<NBEdge*>& edges2 = n->
getEdges();
370 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
372 if ((*i) == *potHighway) {
373 std::swap(*potHighway, *potRamp);
382 *potHighway = edges[0];
384 assert(edges.size() == 2);
396 const std::vector<NBEdge*>& edges2 = n->
getEdges();
397 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
399 if ((*i) == *potRamp) {
400 std::swap(*potHighway, *potRamp);
423 if (maxSpeed < minHighwaySpeed) {
432 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.
bool insert(const std::string &id, const Position &position, NBDistrict *district)
Inserts a node into the map.
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
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.
const SUMOReal SUMO_const_halfLaneAndOffset
const SUMOReal SUMO_const_laneWidthAndOffset
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.
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.
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)
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.