 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
37 #define DEBUGNODEID "260479469"
38 #define DEBUGCOND(obj) ((obj != 0 && (obj)->getID() == DEBUGNODEID))
53 const bool guessAndAdd = oc.
getBool(
"ramps.guess");
54 double minHighwaySpeed = oc.
getFloat(
"ramps.min-highway-speed");
55 double maxRampSpeed = oc.
getFloat(
"ramps.max-ramp-speed");
56 double rampLength = oc.
getFloat(
"ramps.ramp-length");
57 bool dontSplit = oc.
getBool(
"ramps.no-split");
59 std::set<NBEdge*> incremented;
61 std::set<std::string> noramps;
62 if (oc.
isSet(
"ramps.unset")) {
64 noramps.insert(edges.begin(), edges.end());
68 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
69 it_round != roundabouts.end(); ++it_round) {
70 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
71 noramps.insert((*it_edge)->getID());
80 if (guessAndAdd || oc.
getBool(
"ramps.guess-acceleration-lanes")) {
85 std::set<NBNode*, ComparatorIdLess> potOnRamps;
86 std::set<NBNode*, ComparatorIdLess> potOffRamps;
87 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
89 if (
mayNeedOnRamp(cur, minHighwaySpeed, maxRampSpeed, noramps)) {
90 potOnRamps.insert(cur);
94 potOffRamps.insert(cur);
98 for (std::set<NBNode*, ComparatorIdLess>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
99 buildOnRamp(*i, nc, ec, dc, rampLength, dontSplit || !guessAndAdd, guessAndAdd);
101 for (std::set<NBNode*, 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,
true);
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;
170 std::cout <<
"buildOnRamp cur=" << cur->
getID() <<
" hw=" << potHighway->
getID() <<
" ramp=" << potRamp->
getID() <<
" cont=" << cont->
getID() <<
"\n";
179 std::set<NBEdge*> incremented;
180 if (addLanes && toAdd > 0 && std::find(incremented.begin(), incremented.end(), cont) == incremented.end()) {
181 double currLength = 0;
183 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
188 incremented.insert(curr);
206 }
else if (curr == potHighway || curr == potRamp) {
216 if (curr !=
nullptr && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && std::find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
218 bool wasFirst = first == curr;
221 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
223 std::string name = curr->
getID();
226 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
231 incremented.insert(curr);
242 if (curr == cont && dontSplit && addLanes) {
243 WRITE_WARNING(
"Could not build on-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
248 for (
int i = 0; i < firstLaneNumber - potHighway->
getNumLanes(); ++i) {
271 NBEdge* potHighway, *potRamp, *prev;
275 std::cout <<
"buildOffRamp cur=" << cur->
getID() <<
" hw=" << potHighway->
getID() <<
" ramp=" << potRamp->
getID() <<
" prev=" << prev->
getID() <<
"\n";
284 std::set<NBEdge*> incremented;
285 if (toAdd > 0 && std::find(incremented.begin(), incremented.end(), prev) == incremented.end()) {
286 double currLength = 0;
288 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
293 incremented.insert(curr);
311 }
else if (curr == potHighway || curr == potRamp) {
321 if (curr !=
nullptr && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && std::find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
323 bool wasFirst = first == curr;
327 throw ProcessError(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
329 std::string name = curr->
getID();
332 WRITE_ERROR(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"'!");
335 curr = ec.
retrieve(name +
"-AddedOffRampEdge");
336 incremented.insert(curr);
343 if (curr == prev && dontSplit) {
344 WRITE_WARNING(
"Could not build off-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
368 const double offset = (0.5 * addedLanes *
380 if (fabs((*potHighway)->getSpeed() - (*potRamp)->getSpeed()) < .1) {
383 if ((*potHighway)->getSpeed() < (*potRamp)->getSpeed()) {
384 std::swap(*potHighway, *potRamp);
392 if ((*potHighway)->getNumLanes() == (*potRamp)->getNumLanes()) {
395 if ((*potHighway)->getNumLanes() < (*potRamp)->getNumLanes()) {
396 std::swap(*potHighway, *potRamp);
406 assert(edges.size() == 2);
407 *potHighway = edges[0];
421 std::swap(*potHighway, *potRamp);
430 *potHighway = edges[0];
432 assert(edges.size() == 2);
444 const std::vector<NBEdge*>& edges2 = n->
getEdges();
447 std::cout <<
" edges=" <<
toString(edges) <<
" edges2=" <<
toString(edges2) <<
"\n";
450 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
452 if ((*i) == *potRamp) {
453 std::swap(*potHighway, *potRamp);
466 NBEdge* potHighway,
NBEdge* potRamp,
NBEdge* other,
double minHighwaySpeed,
double maxRampSpeed,
467 const std::set<std::string>& noramps) {
486 if (maxSpeed < minHighwaySpeed) {
520 if (maxRampSpeed > 0 && maxRampSpeed < potRamp->getSpeed()) {
523 if (noramps.find(other->
getID()) != noramps.end()) {
537 for (
int i = 0; i < (int)edge->
getNumLanes(); ++i) {
566 if (firstIndex % 2 == 1) {
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
static const std::string ADDED_ON_RAMP_EDGE
suffix for newly generated on-ramp edges
#define WRITE_WARNING(msg)
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
Storage for edges, including some functionality operating on multiple edges.
Instance responsible for building networks.
EdgeBuildingStep getStep() const
The building step of this edge.
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
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.
static void getOnRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
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.
static void moveRampRight(NBEdge *ramp, int addedLanes)
Moves the ramp to the right, as new lanes were added.
static bool hasWrongMode(NBEdge *edge)
whether the edge has a mode that does not indicate a ramp edge
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static void buildOnRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, double rampLength, bool dontSplit, bool addLanes)
Builds an on-ramp starting at the given node.
SumoXMLNodeType getType() const
Returns the type of this node.
const double SUMO_const_laneWidth
double length() const
Returns the length.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
bool hasDefaultGeometryEndpointAtNode(const NBNode *node) const
Returns whether the geometry is terminated by the node positions This default may be violated by init...
A container for districts.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
static double relAngle(double angle1, double angle2)
computes the relative angle between the two angles
Container for nodes during the netbuilding process.
NBEdgeCont & getEdgeCont()
The representation of a single edge during network building.
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
static bool determinedBySpeed(NBEdge **potHighway, NBEdge **potRamp)
static void buildOffRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, double rampLength, bool dontSplit)
Builds an off-ramp ending at the given node.
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
double getLaneWidth() const
Returns the default width of lanes of this edge.
NBParkingCont & getParkingCont()
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
static bool determinedByLaneNumber(NBEdge **potHighway, NBEdge **potRamp)
vehicle is a passenger car (a "normal" car)
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
int getNumLanes() const
Returns the number of lanes.
A point in 2D or 3D with translation and scaling methods.
A storage for options typed value containers)
static void patchRampGeometry(NBEdge *potRamp, NBEdge *first, NBEdge *potHighway, bool onRamp)
shift ramp geometry to merge smoothly with the motorway
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
static void getOffRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
The connection was computed and validated.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
double getSpeed() const
Returns the speed allowed on this edge.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
static const double UNSPECIFIED_WIDTH
unspecified lane width
bool isMacroscopicConnector() const
Returns whether this edge was marked as a macroscopic connector.
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc)
Computes highway on-/off-ramps (if wished)
void incLaneNo(int by)
increment lane
Represents a single node (junction) during network building.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
const std::string & getID() const
Returns the id.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
NBNode * getFromNode() const
Returns the origin node of the 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 std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
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.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
bool hasDefaultGeometryEndpoints() const
Returns whether the geometry is terminated by the node positions This default may be violated by init...
const std::string & getID() const