Path: blob/main/src/netimport/vissim/tempstructs/NIVissimEdge.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NIVissimEdge.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date End of 200217///18// A temporary storage for edges imported from Vissim19/****************************************************************************/20#pragma once21#include <config.h>2223#include "NIVissimConnectionCluster.h"24#include <vector>25#include <string>26#include <map>27#include <netbuild/NBEdge.h>28#include <utils/geom/PositionVector.h>29#include <utils/common/UtilExceptions.h>30#include "NIVissimAbstractEdge.h"31#include "NIVissimClosedLanesVector.h"323334// ===========================================================================35// class declarations36// ===========================================================================37class NBNode;38class NBDistrictCont;39class NIVissimDistrictConnection;404142// ===========================================================================43// class definitions44// ===========================================================================45/**46* @class NIVissimEdge47* @brief A temporary storage for edges imported from Vissim48*/49class NIVissimEdge50: public NIVissimAbstractEdge {51public:52/// Constructor53NIVissimEdge(int id, const std::string& name,54const std::string& type,55std::vector<double> laneWidths,56double zuschlag1,57double zuschlag2, double length,58const PositionVector& geom,59const NIVissimClosedLanesVector& clv);6061/// Destructor62~NIVissimEdge();6364void setNodeCluster(int nodeid);65void buildGeom();6667/// Adds a connection where this edge is the destination68void addIncomingConnection(int id);6970/// Adds a connection where this edge is the source71void addOutgoingConnection(int id);7273/** Returns the begin position of the edge */74Position getBegin2D() const;7576/// Returns the end position of the edge77Position getEnd2D() const;7879/// Returns the length of the node80double getLength() const;8182void checkDistrictConnectionExistanceAt(double pos);8384void mergedInto(NIVissimConnectionCluster* old,85NIVissimConnectionCluster* act);8687void removeFromConnectionCluster(NIVissimConnectionCluster* c);88void addToConnectionCluster(NIVissimConnectionCluster* c);89void setSpeed(int lane, int speedDist);90bool addToTreatAsSame(NIVissimEdge* e);9192NIVissimConnection* getConnectionTo(NIVissimEdge* e);93const std::vector<NIVissimEdge*>& getToTreatAsSame() const;949596/** @brief Returns whether this edge was found to be within a junction97* @return Whether this node is assumed to be within a junction98*/99bool wasWithinAJunction() const {100return myAmWithinJunction;101}102103NIVissimEdge* getBestIncoming() const;104NIVissimEdge* getBestOutgoing() const;105106friend class NIVissimNodeDef_Edges;107friend class NIVissimNodeDef_Poly;108109public:110/** @brief Adds the described item to the dictionary111Builds the edge first */112static bool dictionary(int id, const std::string& name,113const std::string& type, int noLanes, double zuschlag1,114double zuschlag2, double length,115const PositionVector& geom,116const NIVissimClosedLanesVector& clv);117118/// Adds the edge to the dictionary119static bool dictionary(int id, NIVissimEdge* o);120121/// Returns the named edge from the dictionary122static NIVissimEdge* dictionary(int id);123124/** @brief Clusters connections of each edge125*126* For every edge stored in this container, its connections are collected and127* joined into "clusters" if they have the same "direction" (incoming/outgoing)128* and are not further than 10m away from each other.129*130* @todo Probably the distance (MAX_CLUSTER_DISTANCE=10m) should be made variable131*/132static void buildConnectionClusters();133134/// Builds NBEdges from the VissimEdges within the dictionary135static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,136NBEdgeCont& ec, double offset);137138static void dict_propagateSpeeds();139140static void dict_checkEdges2Join();141142143/** @brief Writes edges with unset speeds to the warnings message log instance144*145* Vissim has no direct speed definition of edges; still, we try to propagate146* speed changes along the streets. If a lane is not covered by such, its id147* is put into the static container "myLanesWithMissingSpeeds".148* If the option "vissim.report-unset-speeds" is set, all lane ids stored within149* this container are written.150*/151static void reportUnsetSpeeds();152153154private:155/// The definition for a container for connection clusters156typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;157158private:159/** @brief Builds the NBEdge from this VissimEdge160*161* @param[in] dc The district container used if this edge must be split162* @param[in] nc The node container used for (optionally) building this edge's nodes163* @param[in] ec The edge control to add this edge to164* @param[in] sameNodesOffset Offset used to discriminate nodes165* @exception ProcessError If one of the built nodes or edges could not be added to the according container166*/167void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,168NBEdgeCont& ec, double sameNodesOffset);169170/// Returns the origin node171std::pair<NIVissimConnectionCluster*, NBNode*>172getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);173174/// Returns the destination node175std::pair<NIVissimConnectionCluster*, NBNode*>176getToNode(NBNodeCont& nc, ConnectionClusters& clusters);177178/// Tries to resolve the problem that the same node has been returned as origin and destination node179std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,180double offset, NBNode* prevFrom, NBNode* prevTo);181182// double recheckSpeedPatches();183184std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;185186void propagateSpeed(double speed, std::vector<int> forLanes);187188189void setDistrictSpeed();190double getRealSpeed(int distNo);191void checkUnconnectedLaneSpeeds();192void propagateOwn();193194195196private:197static NBNode* getNodeSecure(int nodeid, const Position& pos,198const std::string& possibleName);199200std::pair<NBNode*, NBNode*>201remapOneOfNodes(NBNodeCont& nc,202NIVissimDistrictConnection* d,203NBNode* fromNode, NBNode* toNode);204205private:206/**207* Sorts connections the edge participates in by their position along208* the given edge209*/210class connection_position_sorter {211public:212/// constructor213explicit connection_position_sorter(int edgeid);214215/// comparing operation216int operator()(int c1id, int c2id) const;217218private:219/// The id of the edge220int myEdgeID;221222};223224225/**226* Sorts connection clusters the edge participates in by their227* position along the given edge228*/229class connection_cluster_position_sorter {230public:231/// constructor232explicit connection_cluster_position_sorter(int edgeid);233234/// comparing operation235int operator()(NIVissimConnectionCluster* cc1,236NIVissimConnectionCluster* cc2) const;237238private:239/// The id of the edge240int myEdgeID;241242};243244private:245/// The name of the edge246std::string myName;247248/// The type of the edge249std::string myType;250251/// The number of lanes the edge has252int myNoLanes;253std::vector<double> myLaneWidths;254255/// Additional load values for this edge256double myZuschlag1, myZuschlag2;257258/// List of lanes closed on this edge259NIVissimClosedLanesVector myClosedLanes;260261/// List of connection clusters along this edge262ConnectionClusters myConnectionClusters;263264/// List of connections incoming to this edge265std::vector<int> myIncomingConnections;266267/// List of connections outgoing from this edge268std::vector<int> myOutgoingConnections;269270std::vector<double> myDistrictConnections;271272std::vector<int> myPatchedSpeeds;273274std::vector<double> myLaneSpeeds;275276std::vector<NIVissimEdge*> myToTreatAsSame;277278/// @brief Information whether this edge was not build due to being within a junction279bool myAmWithinJunction;280281private:282/// @brief Definition of the dictionary type283typedef std::map<int, NIVissimEdge*> DictType;284285/// @brief The dictionary286static DictType myDict;287288/// @brief The current maximum id; needed for further id assignment289static int myMaxID;290291static std::vector<std::string> myLanesWithMissingSpeeds;292293};294295296