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 NIVissimDistrictConnection.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @date End of 2002
18 : ///
19 : // An edge imported from Vissim together for a container for
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <map>
25 : #include <string>
26 : #include <utils/geom/Position.h>
27 :
28 :
29 : class NBDistrictCont;
30 : class NBEdgeCont;
31 :
32 :
33 : // ===========================================================================
34 : // class definitions
35 : // ===========================================================================
36 : class NIVissimDistrictConnection {
37 : public:
38 : /// Contructor
39 : NIVissimDistrictConnection(int id, const std::string& name,
40 : const std::vector<int>& districts, const std::vector<double>& percentages,
41 : int edgeid, double position,
42 : const std::vector<std::pair<int, int> >& assignedVehicles);
43 :
44 : // Destructor
45 : ~NIVissimDistrictConnection();
46 :
47 : /** @brief Returns the position
48 : The position yields from the edge geometry and the place the connection is plaed at */
49 : Position geomPosition() const;
50 :
51 : /// Returns the id of the connection
52 : int getID() const {
53 0 : return myID;
54 : }
55 :
56 : /// Returns the position of the connection at the edge
57 : double getPosition() const {
58 0 : return myPosition;
59 : }
60 :
61 : double getMeanSpeed() const;
62 :
63 : public:
64 : /// Inserts the connection into the dictionary after building it
65 : static bool dictionary(int id, const std::string& name,
66 : const std::vector<int>& districts, const std::vector<double>& percentages,
67 : int edgeid, double position,
68 : const std::vector<std::pair<int, int> >& assignedVehicles);
69 :
70 : /// Inserts the build connection to the dictionary
71 : static bool dictionary(int id, NIVissimDistrictConnection* o);
72 :
73 : /// Returns the named dictionary
74 : static NIVissimDistrictConnection* dictionary(int id);
75 :
76 : /// Builds the nodes that belong to a district
77 : static void dict_BuildDistrictNodes(NBDistrictCont& dc,
78 : NBNodeCont& nc);
79 :
80 : /// Builds the districts
81 : static void dict_BuildDistricts(NBDistrictCont& dc,
82 : NBEdgeCont& ec, NBNodeCont& nc);
83 :
84 : /** @brief Returns the connection to a district placed at the given node
85 : Yep, there onyl should be one, there is no need to build a single edge as connection between two parking places */
86 : static NIVissimDistrictConnection* dict_findForEdge(int edgeid);
87 :
88 : /// Clears the dictionary
89 : static void clearDict();
90 :
91 : static void dict_BuildDistrictConnections();
92 :
93 : static void dict_CheckEdgeEnds();
94 :
95 :
96 : private:
97 : void checkEdgeEnd();
98 : double getRealSpeed(int distNo) const;
99 :
100 : private:
101 : /// The id of the connections
102 : int myID;
103 :
104 : /// The name of the connections
105 : std::string myName;
106 :
107 : /// The connected districts
108 : std::vector<int> myDistricts;
109 :
110 : /// Definition of a map of how many vehicles should leave to a certain district
111 : typedef std::map<int, double> DistrictPercentages;
112 :
113 : /// A map how many vehicles (key, amount) should leave to a district (key)
114 : DistrictPercentages myPercentages;
115 :
116 : /// The id of the connected edge
117 : int myEdgeID;
118 :
119 : /// The position on the edge
120 : double myPosition;
121 :
122 : /// The vehicles using this connection
123 : std::vector<std::pair<int, int> > myAssignedVehicles;
124 :
125 : private:
126 : /// Definition of a dictionary of district connections
127 : typedef std::map<int, NIVissimDistrictConnection*> DictType;
128 :
129 : /// District connection dictionary
130 : static DictType myDict;
131 :
132 : /// Map from ditricts to connections
133 : static std::map<int, std::vector<int> > myDistrictsConnections;
134 :
135 : };
|