95 if (pos2 < 0 || pos1 < 0) {
99 assert(pos1 >= 0 && pos2 >= 0);
107 const std::string& type,
108 std::vector<double> laneWidths,
109 double zuschlag1,
double zuschlag2,
138 const std::string& type,
int noLanes,
139 double zuschlag1,
double zuschlag2,
double length,
143 zuschlag1, zuschlag2, length, geom, clv);
155 DictType::iterator i =
myDict.find(
id);
167 DictType::iterator i =
myDict.find(
id);
177 const double MAX_CLUSTER_DISTANCE = 10;
180 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
181 int edgeid = (*i).first;
186 if (connectors.size() == 0) {
192 std::vector<int> currentCluster;
193 std::vector<int>::iterator j = connectors.begin();
195 double position = outgoing
204 if (j == connectors.end()) {
207 currentCluster.push_back(*j);
211 double n_position = n_outgoing
214 if (n_outgoing == outgoing && fabs(n_position - position) < MAX_CLUSTER_DISTANCE) {
216 currentCluster.push_back(*(j + 1));
221 currentCluster.clear();
222 currentCluster.push_back(*(j + 1));
224 outgoing = n_outgoing;
225 position = n_position;
228 }
while (j != connectors.end());
230 if (currentCluster.size() > 0) {
241 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); i++) {
250 DictType::iterator i;
259 for (
int j = 0; j < 3; j++) {
298 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
316 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
329 if (forLanes.size() == 0) {
331 forLanes.push_back((
int) i);
336 for (std::vector<int>::const_iterator i = forLanes.begin(); i < forLanes.end(); i++) {
358 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
387 for (std::vector<NIVissimConnection*>::iterator j = connected.begin(); j != connected.end(); j++) {
400std::vector<NIVissimConnection*>
402 std::vector<NIVissimConnection*> ret;
406 if (find(lanes.begin(), lanes.end(), lane) != lanes.end()) {
419 double sameNodesOffset) {
421 std::pair<NIVissimConnectionCluster*, NBNode*> fromInf, toInf;
422 NBNode* fromNode, *toNode;
423 fromNode = toNode =
nullptr;
427 if (tmpClusters.size() != 0) {
433 fromNode = fromInf.second;
437 toNode = toInf.second;
438 if (fromInf.first != 0 && toNode !=
nullptr && fromInf.first->around(toNode->
getPosition())) {
445 if (fromNode == toNode) {
446 std::pair<NBNode*, NBNode*> tmp =
resolveSameNode(nc, sameNodesOffset, fromNode, toNode);
447 if (fromNode != tmp.first) {
450 if (toNode != tmp.second) {
453 fromNode = tmp.first;
459 if (fromNode ==
nullptr) {
463 if (!nc.
insert(fromNode)) {
467 if (toNode ==
nullptr) {
489 if (fromNode == toNode) {
508 if (tmpClusters.size() > 0) {
510 for (ConnectionClusters::iterator j = tmpClusters.begin(); cont && j != tmpClusters.end(); ++j) {
512 std::string nextID = buildEdge->
getID() +
"[1]";
513 cont = ec.
splitAt(dc, buildEdge, (*j)->getNBNode());
523 std::string
id = toString<int>(distNo);
525 if (dist ==
nullptr) {
526 WRITE_WARNINGF(
TL(
"The referenced speed distribution '%' is not known."),
id);
530 double speed = dist->
getMax();
531 if (speed < 0 || speed > 1000) {
575std::pair<NIVissimConnectionCluster*, NBNode*>
578 const double MAX_DISTANCE = 3.5;
579 assert(clusters.size() >= 1);
583 if (c->
around(beg, MAX_DISTANCE)) {
584 clusters.erase(clusters.begin());
585 return std::pair<NIVissimConnectionCluster*, NBNode*>
611std::pair<NIVissimConnectionCluster*, NBNode*>
614 if (clusters.size() > 0) {
615 const double MAX_DISTANCE = 10.;
616 assert(clusters.size() >= 1);
619 if (c->
around(end, MAX_DISTANCE)) {
620 clusters.erase(clusters.end() - 1);
621 return std::pair<NIVissimConnectionCluster*, NBNode*>(c, c->
getNBNode());
658std::pair<NBNode*, NBNode*>
662 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
672 return std::pair<NBNode*, NBNode*>(newNode, toNode);
679 return std::pair<NBNode*, NBNode*>(fromNode, newNode);
685std::pair<NBNode*, NBNode*>
697 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
699 if (node ==
nullptr) {
706 return std::pair<NBNode*, NBNode*>(node, prevTo);
710 std::string nid =
"ParkingPlace" + toString<int>(d->
getID());
712 if (node ==
nullptr) {
719 return std::pair<NBNode*, NBNode*>(prevFrom, node);
732 toString<int>(
myID) +
"-End",
738 return std::pair<NBNode*, NBNode*>(node, end);
744 toString<int>(
myID) +
"-Begin",
748 std::cout <<
"nope, NIVissimDisturbance" << std::endl;
751 return std::pair<NBNode*, NBNode*>(beg, node);
756 return std::pair<NBNode*, NBNode*>(node, node);
761 return std::pair<NBNode*, NBNode*>(prevFrom, prevTo);
793 ConnectionClusters::iterator i =
808 ConnectionClusters::iterator i =
817 ConnectionClusters::iterator i =
868 for (DictType::iterator i1 =
myDict.begin(); i1 !=
myDict.end(); i1++) {
873 DictType::iterator i2 = i1;
875 for (; i2 !=
myDict.end(); i2++) {
905 if (g1.back().distanceTo(g2.back()) > 10) {
949 std::vector<int>::iterator i;
966const std::vector<NIVissimEdge*>&
977 std::ostringstream str;
978 str <<
"The following lanes have no explicit speed information:\n ";
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.
virtual double getMax() const =0
Returns the maximum value of this distribution.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
A container for districts.
Storage for edges, including some functionality operating on multiple edges.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
The representation of a single edge during network building.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
static const double UNSPECIFIED_FRICTION
unspecified lane friction
const std::string & getID() const
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
static const double UNSPECIFIED_WIDTH
unspecified lane width
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Container for nodes during the netbuilding process.
bool erase(NBNode *node)
Removes the given node, deleting it.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Represents a single node (junction) during network building.
const Position & getPosition() const
const PositionVector & getGeometry() const
bool around(const Position &p, double offset=0) const
NBNode * getNBNode() const
double getPositionForEdge(int edgeid) const
const std::vector< int > & getFromLanes() const
double getFromPosition() const
const std::vector< int > & getToLanes() const
int getFromEdgeID() const
static bool dictionary(int id, NIVissimConnection *o)
double getToPosition() const
double getMeanSpeed() const
static NIVissimDistrictConnection * dict_findForEdge(int edgeid)
Returns the connection to a district placed at the given node Yep, there onyl should be one,...
Position geomPosition() const
Returns the position The position yields from the edge geometry and the place the connection is plaed...
double getPosition() const
Returns the position of the connection at the edge.
int getID() const
Returns the id of the connection.
int operator()(NIVissimConnectionCluster *cc1, NIVissimConnectionCluster *cc2) const
comparing operation
connection_cluster_position_sorter(int edgeid)
constructor
int operator()(int c1id, int c2id) const
comparing operation
connection_position_sorter(int edgeid)
constructor
A temporary storage for edges imported from Vissim.
void checkDistrictConnectionExistanceAt(double pos)
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.
void mergedInto(NIVissimConnectionCluster *old, NIVissimConnectionCluster *act)
void propagateSpeed(double speed, std::vector< int > forLanes)
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
static int myMaxID
The current maximum id; needed for further id assignment.
NIVissimClosedLanesVector myClosedLanes
List of lanes closed on this edge.
static std::vector< std::string > myLanesWithMissingSpeeds
std::string myName
The name of the edge.
NIVissimEdge * getBestOutgoing() const
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 DictType myDict
The dictionary.
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
std::map< int, NIVissimEdge * > DictType
Definition of the dictionary type.
double getRealSpeed(int distNo)
std::vector< double > myDistrictConnections
NIVissimEdge * getBestIncoming() const
~NIVissimEdge()
Destructor.
void addOutgoingConnection(int id)
Adds a connection where this edge is the source.
std::vector< double > myLaneSpeeds
std::vector< NIVissimConnectionCluster * > ConnectionClusters
The definition for a container for connection clusters.
double getLength() const
Returns the length of the node.
void addToConnectionCluster(NIVissimConnectionCluster *c)
void setSpeed(int lane, int speedDist)
std::pair< NIVissimConnectionCluster *, NBNode * > getFromNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the origin node.
std::vector< NIVissimEdge * > myToTreatAsSame
void removeFromConnectionCluster(NIVissimConnectionCluster *c)
static void dict_checkEdges2Join()
static void buildConnectionClusters()
Clusters connections of each edge.
Position getBegin2D() const
std::vector< NIVissimConnection * > getOutgoingConnected(int lane) const
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double offset)
Builds NBEdges from the VissimEdges within the dictionary.
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 checkUnconnectedLaneSpeeds()
double myZuschlag1
Additional load values for this edge.
static void dict_propagateSpeeds()
std::pair< NIVissimConnectionCluster *, NBNode * > getToNode(NBNodeCont &nc, ConnectionClusters &clusters)
Returns the destination node.
std::vector< double > myLaneWidths
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.
std::string myType
The type of the edge.
void buildNBEdge(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double sameNodesOffset)
Builds the NBEdge from this VissimEdge.
std::vector< int > myOutgoingConnections
List of connections outgoing from this edge.
Position getEnd2D() const
Returns the end position of the edge.
bool addToTreatAsSame(NIVissimEdge *e)
int myNoLanes
The number of lanes the edge has.
void setNodeCluster(int nodeid)
NIVissimConnection * getConnectionTo(NIVissimEdge *e)
std::vector< int > myPatchedSpeeds
std::pair< NBNode *, NBNode * > remapOneOfNodes(NBNodeCont &nc, NIVissimDistrictConnection *d, NBNode *fromNode, NBNode *toNode)
ConnectionClusters myConnectionClusters
List of connection clusters along this edge.
std::vector< int > myIncomingConnections
List of connections incoming to this edge.
const std::string & getID() const
Returns the id.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
A point in 2D or 3D with translation and scaling methods.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position
double length() const
Returns the length.
static void removeDouble(std::vector< T > &v)