LCOV - code coverage report
Current view: top level - src/netimport/vissim/tempstructs - NIVissimEdge.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 1 1
Test Date: 2024-11-22 15:46:21 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    NIVissimEdge.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @date    End of 2002
      18              : ///
      19              : // A temporary storage for edges imported from Vissim
      20              : /****************************************************************************/
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include "NIVissimConnectionCluster.h"
      25              : #include <vector>
      26              : #include <string>
      27              : #include <map>
      28              : #include <netbuild/NBEdge.h>
      29              : #include <utils/geom/PositionVector.h>
      30              : #include <utils/common/UtilExceptions.h>
      31              : #include "NIVissimAbstractEdge.h"
      32              : #include "NIVissimClosedLanesVector.h"
      33              : 
      34              : 
      35              : // ===========================================================================
      36              : // class declarations
      37              : // ===========================================================================
      38              : class NBNode;
      39              : class NBDistrictCont;
      40              : class NIVissimDistrictConnection;
      41              : 
      42              : 
      43              : // ===========================================================================
      44              : // class definitions
      45              : // ===========================================================================
      46              : /**
      47              :  * @class NIVissimEdge
      48              :  * @brief A temporary storage for edges imported from Vissim
      49              :  */
      50              : class NIVissimEdge
      51              :     : public NIVissimAbstractEdge {
      52              : public:
      53              :     /// Constructor
      54              :     NIVissimEdge(int id, const std::string& name,
      55              :                  const std::string& type,
      56              :                  std::vector<double> laneWidths,
      57              :                  double zuschlag1,
      58              :                  double zuschlag2, double length,
      59              :                  const PositionVector& geom,
      60              :                  const NIVissimClosedLanesVector& clv);
      61              : 
      62              :     /// Destructor
      63              :     ~NIVissimEdge();
      64              : 
      65              :     void setNodeCluster(int nodeid);
      66              :     void buildGeom();
      67              : 
      68              :     /// Adds a connection where this edge is the destination
      69              :     void addIncomingConnection(int id);
      70              : 
      71              :     /// Adds a connection where this edge is the source
      72              :     void addOutgoingConnection(int id);
      73              : 
      74              :     /** Returns the begin position of the edge */
      75              :     Position getBegin2D() const;
      76              : 
      77              :     /// Returns the end position of the edge
      78              :     Position getEnd2D() const;
      79              : 
      80              :     /// Returns the length of the node
      81              :     double getLength() const;
      82              : 
      83              :     void checkDistrictConnectionExistanceAt(double pos);
      84              : 
      85              :     void mergedInto(NIVissimConnectionCluster* old,
      86              :                     NIVissimConnectionCluster* act);
      87              : 
      88              :     void removeFromConnectionCluster(NIVissimConnectionCluster* c);
      89              :     void addToConnectionCluster(NIVissimConnectionCluster* c);
      90              :     void setSpeed(int lane, int speedDist);
      91              :     bool addToTreatAsSame(NIVissimEdge* e);
      92              : 
      93              :     NIVissimConnection* getConnectionTo(NIVissimEdge* e);
      94              :     const std::vector<NIVissimEdge*>& getToTreatAsSame() const;
      95              : 
      96              : 
      97              :     /** @brief Returns whether this edge was found to be within a junction
      98              :      * @return Whether this node is assumed to be within a junction
      99              :      */
     100              :     bool wasWithinAJunction() const {
     101         1854 :         return myAmWithinJunction;
     102              :     }
     103              : 
     104              :     NIVissimEdge* getBestIncoming() const;
     105              :     NIVissimEdge* getBestOutgoing() const;
     106              : 
     107              :     friend class NIVissimNodeDef_Edges;
     108              :     friend class NIVissimNodeDef_Poly;
     109              : 
     110              : public:
     111              :     /** @brief Adds the described item to the dictionary
     112              :         Builds the edge first */
     113              :     static bool dictionary(int id, const std::string& name,
     114              :                            const std::string& type, int noLanes, double zuschlag1,
     115              :                            double zuschlag2, double length,
     116              :                            const PositionVector& geom,
     117              :                            const NIVissimClosedLanesVector& clv);
     118              : 
     119              :     /// Adds the edge to the dictionary
     120              :     static bool dictionary(int id, NIVissimEdge* o);
     121              : 
     122              :     /// Returns the named edge from the dictionary
     123              :     static NIVissimEdge* dictionary(int id);
     124              : 
     125              :     /** @brief Clusters connections of each edge
     126              :      *
     127              :      * For every edge stored in this container, its connections are collected and
     128              :      *  joined into "clusters" if they have the same "direction" (incoming/outgoing)
     129              :      *  and are not further than 10m away from each other.
     130              :      *
     131              :      * @todo Probably the distance (MAX_CLUSTER_DISTANCE=10m) should be made variable
     132              :      */
     133              :     static void buildConnectionClusters();
     134              : 
     135              :     /// Builds NBEdges from the VissimEdges within the dictionary
     136              :     static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,
     137              :                                   NBEdgeCont& ec, double offset);
     138              : 
     139              :     static void dict_propagateSpeeds();
     140              : 
     141              :     static void dict_checkEdges2Join();
     142              : 
     143              : 
     144              :     /** @brief Writes edges with unset speeds to the warnings message log instance
     145              :      *
     146              :      * Vissim has no direct speed definition of edges; still, we try to propagate
     147              :      *  speed changes along the streets. If a lane is not covered by such, its id
     148              :      *  is put into the static container "myLanesWithMissingSpeeds".
     149              :      * If the option "vissim.report-unset-speeds" is set, all lane ids stored within
     150              :      *  this container are written.
     151              :      */
     152              :     static void reportUnsetSpeeds();
     153              : 
     154              : 
     155              : private:
     156              :     /// The definition for a container for connection clusters
     157              :     typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
     158              : 
     159              : private:
     160              :     /** @brief Builds the NBEdge from this VissimEdge
     161              :      *
     162              :      * @param[in] dc The district container used if this edge must be split
     163              :      * @param[in] nc The node container used for (optionally) building this edge's nodes
     164              :      * @param[in] ec The edge control to add this edge to
     165              :      * @param[in] sameNodesOffset Offset used to discriminate nodes
     166              :      * @exception ProcessError If one of the built nodes or edges could not be added to the according container
     167              :      */
     168              :     void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,
     169              :                      NBEdgeCont& ec, double sameNodesOffset);
     170              : 
     171              :     /// Returns the origin node
     172              :     std::pair<NIVissimConnectionCluster*, NBNode*>
     173              :     getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);
     174              : 
     175              :     /// Returns the destination node
     176              :     std::pair<NIVissimConnectionCluster*, NBNode*>
     177              :     getToNode(NBNodeCont& nc, ConnectionClusters& clusters);
     178              : 
     179              :     /// Tries to resolve the problem that the same node has been returned as origin and destination node
     180              :     std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,
     181              :             double offset, NBNode* prevFrom, NBNode* prevTo);
     182              : 
     183              : //    double recheckSpeedPatches();
     184              : 
     185              :     std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
     186              : 
     187              :     void propagateSpeed(double speed, std::vector<int> forLanes);
     188              : 
     189              : 
     190              :     void setDistrictSpeed();
     191              :     double getRealSpeed(int distNo);
     192              :     void checkUnconnectedLaneSpeeds();
     193              :     void propagateOwn();
     194              : 
     195              : 
     196              : 
     197              : private:
     198              :     static NBNode* getNodeSecure(int nodeid, const Position& pos,
     199              :                                  const std::string& possibleName);
     200              : 
     201              :     std::pair<NBNode*, NBNode*>
     202              :     remapOneOfNodes(NBNodeCont& nc,
     203              :                     NIVissimDistrictConnection* d,
     204              :                     NBNode* fromNode, NBNode* toNode);
     205              : 
     206              : private:
     207              :     /**
     208              :      * Sorts connections the edge participates in by their position along
     209              :      * the given edge
     210              :      */
     211              :     class connection_position_sorter {
     212              :     public:
     213              :         /// constructor
     214              :         explicit connection_position_sorter(int edgeid);
     215              : 
     216              :         /// comparing operation
     217              :         int operator()(int c1id, int c2id) const;
     218              : 
     219              :     private:
     220              :         /// The id of the edge
     221              :         int myEdgeID;
     222              : 
     223              :     };
     224              : 
     225              : 
     226              :     /**
     227              :      * Sorts connection clusters the edge participates in by their
     228              :      * position along the given edge
     229              :      */
     230              :     class connection_cluster_position_sorter {
     231              :     public:
     232              :         /// constructor
     233              :         explicit connection_cluster_position_sorter(int edgeid);
     234              : 
     235              :         /// comparing operation
     236              :         int operator()(NIVissimConnectionCluster* cc1,
     237              :                        NIVissimConnectionCluster* cc2) const;
     238              : 
     239              :     private:
     240              :         /// The id of the edge
     241              :         int myEdgeID;
     242              : 
     243              :     };
     244              : 
     245              : private:
     246              :     /// The name of the edge
     247              :     std::string myName;
     248              : 
     249              :     /// The type of the edge
     250              :     std::string myType;
     251              : 
     252              :     /// The number of lanes the edge has
     253              :     int myNoLanes;
     254              :     std::vector<double> myLaneWidths;
     255              : 
     256              :     /// Additional load values for this edge
     257              :     double myZuschlag1, myZuschlag2;
     258              : 
     259              :     /// List of lanes closed on this edge
     260              :     NIVissimClosedLanesVector myClosedLanes;
     261              : 
     262              :     /// List of connection clusters along this edge
     263              :     ConnectionClusters myConnectionClusters;
     264              : 
     265              :     /// List of connections incoming to this edge
     266              :     std::vector<int> myIncomingConnections;
     267              : 
     268              :     /// List of connections outgoing from this edge
     269              :     std::vector<int> myOutgoingConnections;
     270              : 
     271              :     std::vector<double> myDistrictConnections;
     272              : 
     273              :     std::vector<int> myPatchedSpeeds;
     274              : 
     275              :     std::vector<double> myLaneSpeeds;
     276              : 
     277              :     std::vector<NIVissimEdge*> myToTreatAsSame;
     278              : 
     279              :     /// @brief Information whether this edge was not build due to being within a junction
     280              :     bool myAmWithinJunction;
     281              : 
     282              : private:
     283              :     /// @brief Definition of the dictionary type
     284              :     typedef std::map<int, NIVissimEdge*> DictType;
     285              : 
     286              :     /// @brief The dictionary
     287              :     static DictType myDict;
     288              : 
     289              :     /// @brief The current maximum id; needed for further id assignment
     290              :     static int myMaxID;
     291              : 
     292              :     static std::vector<std::string> myLanesWithMissingSpeeds;
     293              : 
     294              : };
        

Generated by: LCOV version 2.0-1