97 if (pos2 < 0 || pos1 < 0) {
101 assert(pos1 >= 0 && pos2 >= 0);
109 const std::string& type,
int noLanes,
110 double zuschlag1,
double zuschlag2,
117 assert(noLanes >= 0);
121 for (
int i = 0; i < noLanes; i++) {
137 const std::string& type,
int noLanes,
138 double zuschlag1,
double zuschlag2,
double length,
142 zuschlag2, length, geom, clv);
154 DictType::iterator i =
myDict.find(
id);
166 DictType::iterator i =
myDict.find(
id);
176 const double MAX_CLUSTER_DISTANCE = 10;
179 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
180 int edgeid = (*i).first;
185 if (connectors.size() == 0) {
191 std::vector<int> currentCluster;
192 std::vector<int>::iterator j = connectors.begin();
194 double position = outgoing
203 if (j == connectors.end()) {
206 currentCluster.push_back(*j);
210 double n_position = n_outgoing
213 if (n_outgoing == outgoing && fabs(n_position - position) < MAX_CLUSTER_DISTANCE) {
215 currentCluster.push_back(*(j + 1));
220 currentCluster.clear();
221 currentCluster.push_back(*(j + 1));
223 outgoing = n_outgoing;
224 position = n_position;
227 }
while (j != connectors.end());
229 if (currentCluster.size() > 0) {
240 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
249 DictType::iterator i;
258 for (
int j = 0; j < 3; j++) {
297 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
315 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
328 if (forLanes.size() == 0) {
330 forLanes.push_back((
int) i);
335 for (std::vector<int>::const_iterator i = forLanes.begin(); i < forLanes.end(); i++) {
357 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
386 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
399 std::vector<NIVissimConnection*>
401 std::vector<NIVissimConnection*> ret;
405 if (find(lanes.begin(), lanes.end(), lane) != lanes.end()) {
418 double sameNodesOffset) {
420 std::pair<NIVissimConnectionCluster*, NBNode*> fromInf, toInf;
421 NBNode* fromNode, *toNode;
422 fromNode = toNode =
nullptr;
426 if (tmpClusters.size() != 0) {
432 fromNode = fromInf.second;
436 toNode = toInf.second;
437 if (fromInf.first != 0 && toNode !=
nullptr && fromInf.first->around(toNode->
getPosition())) {
444 if (fromNode == toNode) {
445 std::pair<NBNode*, NBNode*> tmp =
resolveSameNode(nc, sameNodesOffset, fromNode, toNode);
446 if (fromNode != tmp.first) {
449 if (toNode != tmp.second) {
452 fromNode = tmp.first;
458 if (fromNode ==
nullptr) {
462 if (!nc.
insert(fromNode)) {
463 throw ProcessError(
"Could not insert node '" + fromNode->
getID() +
"' to nodes container.");
466 if (toNode ==
nullptr) {
471 throw ProcessError(
"Could not insert node '" + toNode->
getID() +
"' to nodes container.");
488 if (fromNode == toNode) {
494 avgSpeed / (
double) 3.6, myNoLanes, -1,
506 if (tmpClusters.size() > 0) {
508 for (ConnectionClusters::iterator j = tmpClusters.begin(); cont && j != tmpClusters.end(); ++j) {
510 std::string nextID = buildEdge->
getID() +
"[1]";
511 cont = ec.
splitAt(dc, buildEdge, (*j)->getNBNode());
521 std::string
id = toString<int>(distNo);
523 if (dist ==
nullptr) {
524 WRITE_WARNING(
"The referenced speed distribution '" +
id +
"' is not known.");
528 double speed = dist->getMax();
529 if (speed < 0 || speed > 1000) {
530 WRITE_WARNING(
"What about distribution '" + toString<int>(distNo) +
"' ");
573 std::pair<NIVissimConnectionCluster*, NBNode*>
576 const double MAX_DISTANCE = 3.5;
577 assert(clusters.size() >= 1);
581 if (c->
around(beg, MAX_DISTANCE)) {
582 clusters.erase(clusters.begin());
583 return std::pair<NIVissimConnectionCluster*, NBNode*>
609 std::pair<NIVissimConnectionCluster*, NBNode*>
612 if (clusters.size() > 0) {
613 const double MAX_DISTANCE = 10.;
614 assert(clusters.size() >= 1);
617 if (c->around(end, MAX_DISTANCE)) {
618 clusters.erase(clusters.end() - 1);
619 return std::pair<NIVissimConnectionCluster*, NBNode*>(c, c->getNBNode());
656 std::pair<NBNode*, NBNode*>
660 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
670 return std::pair<NBNode*, NBNode*>(newNode, toNode);
677 return std::pair<NBNode*, NBNode*>(fromNode, newNode);
683 std::pair<NBNode*, NBNode*>
695 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
697 if (node ==
nullptr) {
704 return std::pair<NBNode*, NBNode*>(node, prevTo);
708 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
710 if (node ==
nullptr) {
717 return std::pair<NBNode*, NBNode*>(prevFrom, node);
730 toString<int>(
myID) +
"-End",
736 return std::pair<NBNode*, NBNode*>(node, end);
742 toString<int>(
myID) +
"-Begin",
746 std::cout <<
"nope, NIVissimDisturbance" << std::endl;
749 return std::pair<NBNode*, NBNode*>(beg, node);
754 return std::pair<NBNode*, NBNode*>(node, node);
759 return std::pair<NBNode*, NBNode*>(prevFrom, prevTo);
791 ConnectionClusters::iterator i =
806 ConnectionClusters::iterator i =
815 ConnectionClusters::iterator i =
866 for (DictType::iterator i1 =
myDict.begin(); i1 !=
myDict.end(); i1++) {
871 DictType::iterator i2 = i1;
873 for (; i2 !=
myDict.end(); i2++) {
903 if (g1.back().distanceTo(g2.back()) > 10) {
947 std::vector<int>::iterator i;
964 const std::vector<NIVissimEdge*>&
975 std::ostringstream str;
976 str <<
"The following lanes have no explicit speed information:\n ";
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
static int myMaxID
The current maximum id; needed for further id assignment.
NIVissimEdge(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Constructor.
std::vector< double > myDistrictConnections
~NIVissimEdge()
Destructor.
std::string myName
The name of the edge.
const std::vector< int > & getFromLanes() const
NBNode * getNBNode() const
static void dict_checkEdges2Join()
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
std::vector< int > myPatchedSpeeds
std::pair< NBNode *, NBNode * > remapOneOfNodes(NBNodeCont &nc, NIVissimDistrictConnection *d, NBNode *fromNode, NBNode *toNode)
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
The representation of a single edge during network building.
ConnectionClusters myConnectionClusters
List of connection clusters along this edge.
std::vector< double > myLaneSpeeds
A container for districts.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
const PositionVector & getGeometry() const
Position geomPosition() const
Returns the position The position yields from the edge geometry and the place the connection is plaed...
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double offset)
Builds NBEdges from the VissimEdges within the dictionary.
void addToConnectionCluster(NIVissimConnectionCluster *c)
void setNodeCluster(int nodeid)
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
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.
const std::vector< int > & getToLanes() const
static bool dictionary(int id, NIVissimConnection *o)
const std::string & getID() const
Returns the id.
int getID() const
Returns the id of the connection.
NIVissimEdge * getBestIncoming() const
static NIVissimDistrictConnection * dict_findForEdge(int edgeid)
Returns the connection to a district placed at the given node Yep, there onyl should be one...
static const double UNSPECIFIED_WIDTH
unspecified lane width
#define WRITE_WARNING(msg)
double getPositionForEdge(int edgeid) const
static OptionsCont & getOptions()
Retrieves the options.
A temporary storage for edges imported from Vissim.
Position getBegin2D() const
void propagateSpeed(double speed, std::vector< int > forLanes)
NIVissimEdge * getBestOutgoing() const
int getFromEdgeID() const
int myNoLanes
The number of lanes the edge has.
double myZuschlag1
Additional load values for this edge.
double getPosition() const
Returns the position of the connection at the edge.
double getRealSpeed(int distNo)
int operator()(NIVissimConnectionCluster *cc1, NIVissimConnectionCluster *cc2) const
comparing operation
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void setSpeed(int lane, int speedDist)
void addIncomingConnection(int id)
Adds a connection where this edge is the destination.
bool myAmWithinJunction
Information whether this edge was not build due to being within a junction.
static void dict_propagateSpeeds()
int operator()(int c1id, int c2id) const
comparing operation
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position ...
A point in 2D or 3D with translation and scaling methods.
std::vector< int > myIncomingConnections
List of connections incoming to this edge.
double getLength() const
Returns the length of the node.
void checkDistrictConnectionExistanceAt(double pos)
static void removeDouble(std::vector< T > &v)
std::string myType
The type of the edge.
bool around(const Position &p, double offset=0) const
int myEdgeID
The id of the edge.
Storage for edges, including some functionality operating on multiple edges.
connection_cluster_position_sorter(int edgeid)
constructor
connection_position_sorter(int edgeid)
constructor
void checkUnconnectedLaneSpeeds()
void addOutgoingConnection(int id)
Adds a connection where this edge is the source.
void buildNBEdge(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double sameNodesOffset)
Builds the NBEdge from this VissimEdge.
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.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
NIVissimConnection * getConnectionTo(NIVissimEdge *e)
std::pair< NIVissimConnectionCluster *, NBNode * > getToNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the destination node.
double getToPosition() const
static void buildConnectionClusters()
Clusters connections of each edge.
std::vector< NIVissimEdge * > myToTreatAsSame
double length() const
Returns the length.
bool addToTreatAsSame(NIVissimEdge *e)
Position getEnd2D() const
Returns the end position of the edge.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
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
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
const Position & getPosition() const
Represents a single node (junction) during network building.
double getMeanSpeed() const
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
static DictType myDict
The dictionary.
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
Container for nodes during the netbuilding process.
void mergedInto(NIVissimConnectionCluster *old, NIVissimConnectionCluster *act)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
int myEdgeID
The id of the edge.
bool erase(NBNode *node)
Removes the given node, deleting it.
std::vector< int > myOutgoingConnections
List of connections outgoing from this edge.
std::pair< NIVissimConnectionCluster *, NBNode * > getFromNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the origin node.
void removeFromConnectionCluster(NIVissimConnectionCluster *c)
double getFromPosition() const