 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
96 if (pos2 < 0 || pos1 < 0) {
100 assert(pos1 >= 0 && pos2 >= 0);
108 const std::string& type,
109 std::vector<double> laneWidths,
110 double zuschlag1,
double zuschlag2,
139 const std::string& type,
int noLanes,
140 double zuschlag1,
double zuschlag2,
double length,
144 zuschlag1, zuschlag2, length, geom, clv);
156 DictType::iterator i =
myDict.find(
id);
168 DictType::iterator i =
myDict.find(
id);
178 const double MAX_CLUSTER_DISTANCE = 10;
181 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
182 int edgeid = (*i).first;
187 if (connectors.size() == 0) {
193 std::vector<int> currentCluster;
194 std::vector<int>::iterator j = connectors.begin();
196 double position = outgoing
205 if (j == connectors.end()) {
208 currentCluster.push_back(*j);
212 double n_position = n_outgoing
215 if (n_outgoing == outgoing && fabs(n_position - position) < MAX_CLUSTER_DISTANCE) {
217 currentCluster.push_back(*(j + 1));
222 currentCluster.clear();
223 currentCluster.push_back(*(j + 1));
225 outgoing = n_outgoing;
226 position = n_position;
229 }
while (j != connectors.end());
231 if (currentCluster.size() > 0) {
242 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
251 DictType::iterator i;
260 for (
int j = 0; j < 3; j++) {
299 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
317 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
330 if (forLanes.size() == 0) {
332 forLanes.push_back((
int) i);
337 for (std::vector<int>::const_iterator i = forLanes.begin(); i < forLanes.end(); i++) {
359 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
388 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
401 std::vector<NIVissimConnection*>
403 std::vector<NIVissimConnection*> ret;
407 if (find(lanes.begin(), lanes.end(), lane) != lanes.end()) {
420 double sameNodesOffset) {
422 std::pair<NIVissimConnectionCluster*, NBNode*> fromInf, toInf;
423 NBNode* fromNode, *toNode;
424 fromNode = toNode =
nullptr;
428 if (tmpClusters.size() != 0) {
434 fromNode = fromInf.second;
438 toNode = toInf.second;
439 if (fromInf.first != 0 && toNode !=
nullptr && fromInf.first->around(toNode->
getPosition())) {
446 if (fromNode == toNode) {
447 std::pair<NBNode*, NBNode*> tmp =
resolveSameNode(nc, sameNodesOffset, fromNode, toNode);
448 if (fromNode != tmp.first) {
451 if (toNode != tmp.second) {
454 fromNode = tmp.first;
460 if (fromNode ==
nullptr) {
464 if (!nc.
insert(fromNode)) {
465 throw ProcessError(
"Could not insert node '" + fromNode->
getID() +
"' to nodes container.");
468 if (toNode ==
nullptr) {
473 throw ProcessError(
"Could not insert node '" + toNode->
getID() +
"' to nodes container.");
490 if (fromNode == toNode) {
509 if (tmpClusters.size() > 0) {
511 for (ConnectionClusters::iterator j = tmpClusters.begin(); cont && j != tmpClusters.end(); ++j) {
513 std::string nextID = buildEdge->
getID() +
"[1]";
514 cont = ec.
splitAt(dc, buildEdge, (*j)->getNBNode());
524 std::string
id = toString<int>(distNo);
526 if (dist ==
nullptr) {
527 WRITE_WARNING(
"The referenced speed distribution '" +
id +
"' is not known.");
531 double speed = dist->
getMax();
532 if (speed < 0 || speed > 1000) {
533 WRITE_WARNING(
"What about distribution '" + toString<int>(distNo) +
"' ");
576 std::pair<NIVissimConnectionCluster*, NBNode*>
579 const double MAX_DISTANCE = 3.5;
580 assert(clusters.size() >= 1);
584 if (c->
around(beg, MAX_DISTANCE)) {
585 clusters.erase(clusters.begin());
586 return std::pair<NIVissimConnectionCluster*, NBNode*>
612 std::pair<NIVissimConnectionCluster*, NBNode*>
615 if (clusters.size() > 0) {
616 const double MAX_DISTANCE = 10.;
617 assert(clusters.size() >= 1);
620 if (c->
around(end, MAX_DISTANCE)) {
621 clusters.erase(clusters.end() - 1);
622 return std::pair<NIVissimConnectionCluster*, NBNode*>(c, c->
getNBNode());
659 std::pair<NBNode*, NBNode*>
663 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
673 return std::pair<NBNode*, NBNode*>(newNode, toNode);
680 return std::pair<NBNode*, NBNode*>(fromNode, newNode);
686 std::pair<NBNode*, NBNode*>
698 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
700 if (node ==
nullptr) {
707 return std::pair<NBNode*, NBNode*>(node, prevTo);
711 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
713 if (node ==
nullptr) {
720 return std::pair<NBNode*, NBNode*>(prevFrom, node);
733 toString<int>(
myID) +
"-End",
739 return std::pair<NBNode*, NBNode*>(node, end);
745 toString<int>(
myID) +
"-Begin",
749 std::cout <<
"nope, NIVissimDisturbance" << std::endl;
752 return std::pair<NBNode*, NBNode*>(beg, node);
757 return std::pair<NBNode*, NBNode*>(node, node);
762 return std::pair<NBNode*, NBNode*>(prevFrom, prevTo);
794 ConnectionClusters::iterator i =
809 ConnectionClusters::iterator i =
818 ConnectionClusters::iterator i =
869 for (DictType::iterator i1 =
myDict.begin(); i1 !=
myDict.end(); i1++) {
874 DictType::iterator i2 = i1;
876 for (; i2 !=
myDict.end(); i2++) {
906 if (g1.back().distanceTo(g2.back()) > 10) {
950 std::vector<int>::iterator i;
967 const std::vector<NIVissimEdge*>&
978 std::ostringstream str;
979 str <<
"The following lanes have no explicit speed information:\n ";
std::vector< double > myLaneWidths
double getPosition() const
Returns the position of the connection at the edge.
Position getBegin2D() const
static void removeDouble(std::vector< T > &v)
static const double UNSPECIFIED_OFFSET
unspecified lane offset
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position
NBNode * getNBNode() const
static void buildConnectionClusters()
Clusters connections of each edge.
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
#define WRITE_WARNING(msg)
static bool dictionary(const std::string &type, const std::string &id, Distribution *d)
Adds a distribution of the given type and name to the container.
Storage for edges, including some functionality operating on multiple edges.
A temporary storage for edges imported from Vissim.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
void propagateSpeed(double speed, std::vector< int > forLanes)
NIVissimEdge(int id, const std::string &name, const std::string &type, std::vector< double > laneWidths, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Constructor.
void addIncomingConnection(int id)
Adds a connection where this edge is the destination.
static DictType myDict
The dictionary.
double getToPosition() const
double getRealSpeed(int distNo)
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
std::string myType
The type of the edge.
void setSpeed(int lane, int speedDist)
bool myAmWithinJunction
Information whether this edge was not build due to being within a junction.
std::pair< NIVissimConnectionCluster *, NBNode * > getFromNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the origin node.
void addOutgoingConnection(int id)
Adds a connection where this edge is the source.
static OptionsCont & getOptions()
Retrieves the options.
void buildNBEdge(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double sameNodesOffset)
Builds the NBEdge from this VissimEdge.
void mergedInto(NIVissimConnectionCluster *old, NIVissimConnectionCluster *act)
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
double length() const
Returns the length.
virtual double getMax() const =0
Returns the maximum value of this distribution.
std::vector< int > myOutgoingConnections
List of connections outgoing from this edge.
void checkDistrictConnectionExistanceAt(double pos)
double getPositionForEdge(int edgeid) const
A container for districts.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
int operator()(NIVissimConnectionCluster *cc1, NIVissimConnectionCluster *cc2) const
comparing operation
void checkUnconnectedLaneSpeeds()
Container for nodes during the netbuilding process.
bool erase(NBNode *node)
Removes the given node, deleting it.
The representation of a single edge during network building.
std::vector< double > myDistrictConnections
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
bool addToTreatAsSame(NIVissimEdge *e)
int getID() const
Returns the id of the connection.
const Position & getPosition() const
std::string myName
The name of the edge.
connection_position_sorter(int edgeid)
constructor
bool around(const Position &p, double offset=0) const
std::vector< NIVissimEdge * > myToTreatAsSame
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
void setNodeCluster(int nodeid)
A point in 2D or 3D with translation and scaling methods.
double getFromPosition() const
std::pair< NBNode *, NBNode * > resolveSameNode(NBNodeCont &nc, double offset, NBNode *prevFrom, NBNode *prevTo)
Tries to resolve the problem that the same node has been returned as origin and destination node.
static std::vector< std::string > myLanesWithMissingSpeeds
const PositionVector & getGeometry() const
static NIVissimDistrictConnection * dict_findForEdge(int edgeid)
Returns the connection to a district placed at the given node Yep, there onyl should be one,...
NIVissimEdge * getBestIncoming() const
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double offset)
Builds NBEdges from the VissimEdges within the dictionary.
void removeFromConnectionCluster(NIVissimConnectionCluster *c)
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Position geomPosition() const
Returns the position The position yields from the edge geometry and the place the connection is plaed...
NIVissimEdge * getBestOutgoing() const
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int operator()(int c1id, int c2id) const
comparing operation
double myZuschlag1
Additional load values for this edge.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
connection_cluster_position_sorter(int edgeid)
constructor
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
static void dict_propagateSpeeds()
const std::vector< int > & getToLanes() const
int myNoLanes
The number of lanes the edge has.
static const double UNSPECIFIED_WIDTH
unspecified lane width
const std::vector< int > & getFromLanes() const
static void dict_checkEdges2Join()
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
static int myMaxID
The current maximum id; needed for further id assignment.
double getLength() const
Returns the length of the node.
std::vector< int > myPatchedSpeeds
std::pair< NBNode *, NBNode * > remapOneOfNodes(NBNodeCont &nc, NIVissimDistrictConnection *d, NBNode *fromNode, NBNode *toNode)
static bool dictionary(int id, NIVissimConnection *o)
ConnectionClusters myConnectionClusters
List of connection clusters along this edge.
~NIVissimEdge()
Destructor.
int getFromEdgeID() const
Represents a single node (junction) during network building.
std::vector< int > myIncomingConnections
List of connections incoming to this edge.
double getMeanSpeed() const
void addToConnectionCluster(NIVissimConnectionCluster *c)
std::pair< NIVissimConnectionCluster *, NBNode * > getToNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the destination node.
const std::string & getID() const
Returns the id.
std::vector< double > myLaneSpeeds
Position getEnd2D() const
Returns the end position of the edge.
NIVissimConnection * getConnectionTo(NIVissimEdge *e)
const std::string & getID() const