56 double minHighwaySpeed = oc.
getFloat(
"ramps.min-highway-speed");
57 double maxRampSpeed = oc.
getFloat(
"ramps.max-ramp-speed");
58 double rampLength = oc.
getFloat(
"ramps.ramp-length");
59 bool dontSplit = oc.
getBool(
"ramps.no-split");
61 std::set<NBEdge*> incremented;
63 std::set<std::string> noramps;
64 if (oc.
isSet(
"ramps.unset")) {
66 noramps.insert(edges.begin(), edges.end());
70 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
71 it_round != roundabouts.end(); ++it_round) {
72 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
73 noramps.insert((*it_edge)->getID());
82 if (oc.
getBool(
"ramps.guess")) {
87 std::set<NBNode*, Named::ComparatorIdLess> potOnRamps;
88 std::set<NBNode*, Named::ComparatorIdLess> potOffRamps;
89 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
91 if (
mayNeedOnRamp(cur, minHighwaySpeed, maxRampSpeed, noramps)) {
92 potOnRamps.insert(cur);
95 potOffRamps.insert(cur);
98 for (std::set<NBNode*, Named::ComparatorIdLess>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
101 for (std::set<NBNode*, Named::ComparatorIdLess>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) {
106 if (oc.
isSet(
"ramps.set")) {
111 for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) {
113 if (noramps.count(*i) != 0) {
114 WRITE_WARNING(
"Can not build ramp on edge '" + *i +
"' - the edge is unsuitable.");
118 WRITE_WARNING(
"Can not build on ramp on edge '" + *i +
"' - the edge is not known.");
123 buildOnRamp(from, nc, ec, dc, rampLength, dontSplit);
128 WRITE_WARNING(
"Can not build off ramp on edge '" + *i +
"' - the edge is not known.");
145 NBEdge* potHighway, *potRamp, *cont;
158 NBEdge* potHighway, *potRamp, *prev;
166 NBEdge* potHighway, *potRamp, *cont;
174 std::set<NBEdge*> incremented;
175 if (toAdd > 0 && find(incremented.begin(), incremented.end(), cont) == incremented.end()) {
176 double currLength = 0;
178 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
183 incremented.insert(curr);
201 }
else if (curr == potHighway || curr == potRamp) {
211 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
213 bool wasFirst = first == curr;
216 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
218 std::string name = curr->
getID();
221 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
226 incremented.insert(curr);
237 if (curr == cont && dontSplit) {
238 WRITE_WARNING(
"Could not build on-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
243 for (
int i = 0; i < firstLaneNumber - potHighway->
getNumLanes(); ++i) {
269 NBEdge* potHighway, *potRamp, *prev;
277 std::set<NBEdge*> incremented;
278 if (toAdd > 0 && find(incremented.begin(), incremented.end(), prev) == incremented.end()) {
279 double currLength = 0;
281 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
286 incremented.insert(curr);
304 }
else if (curr == potHighway || curr == potRamp) {
314 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
316 bool wasFirst = first == curr;
320 throw ProcessError(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
322 std::string name = curr->
getID();
325 WRITE_ERROR(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"'!");
328 curr = ec.
retrieve(name +
"-AddedOffRampEdge");
329 incremented.insert(curr);
336 if (curr == prev && dontSplit) {
337 WRITE_WARNING(
"Could not build off-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
364 const double offset = (0.5 * addedLanes *
376 if (fabs((*potHighway)->getSpeed() - (*potRamp)->getSpeed()) < .1) {
379 if ((*potHighway)->getSpeed() < (*potRamp)->getSpeed()) {
380 std::swap(*potHighway, *potRamp);
388 if ((*potHighway)->getNumLanes() == (*potRamp)->getNumLanes()) {
391 if ((*potHighway)->getNumLanes() < (*potRamp)->getNumLanes()) {
392 std::swap(*potHighway, *potRamp);
402 assert(edges.size() == 2);
403 *potHighway = edges[0];
417 std::swap(*potHighway, *potRamp);
426 *potHighway = edges[0];
428 assert(edges.size() == 2);
440 const std::vector<NBEdge*>& edges2 = n->
getEdges();
441 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
443 if ((*i) == *potRamp) {
444 std::swap(*potHighway, *potRamp);
457 NBEdge* potHighway,
NBEdge* potRamp,
NBEdge* other,
double minHighwaySpeed,
double maxRampSpeed,
458 const std::set<std::string>& noramps) {
473 if (maxSpeed < minHighwaySpeed) {
506 if (maxRampSpeed > 0 && maxRampSpeed < potRamp->getSpeed()) {
509 if (noramps.find(other->
getID()) != noramps.end()) {
523 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)
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
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.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
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.
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
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.
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
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)
NBParkingCont & getParkingCont()
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 addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
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.