Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 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 NBPTStopCont.h
15 : /// @author Gregor Laemmel
16 : /// @date Tue, 20 Mar 2017
17 : ///
18 : // Container for public transport stops during the net building process
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 :
23 : #include <string>
24 : #include <map>
25 :
26 :
27 : // ===========================================================================
28 : // class declarations
29 : // ===========================================================================
30 : class NBEdge;
31 : class NBEdgeCont;
32 : class NBPTPlatform;
33 : class NBPTStop;
34 :
35 :
36 : // ===========================================================================
37 : // class definitions
38 : // ===========================================================================
39 : /**
40 : * @class NBPTStopCont
41 : * @brief Container for public transport stops during the net building process
42 : *
43 : */
44 : class NBPTStopCont {
45 : public:
46 :
47 : ~NBPTStopCont();
48 :
49 : /** @brief Inserts a node into the map
50 : * @param[in] stop The pt stop to insert
51 : * @param[in] floating whether the stop is not referenced by a way or relation
52 : * @return Whether the pt stop could be added
53 : */
54 : bool insert(std::shared_ptr<NBPTStop> ptStop, bool floating = false);
55 :
56 : /// @brief Retrieve a previously inserted pt stop
57 : std::shared_ptr<NBPTStop> get(std::string id) const;
58 :
59 : /** @brief Returns an unmodifiable reference to the stored pt stops
60 : * @return The stored pt stops
61 : */
62 : const std::map<std::string, std::shared_ptr<NBPTStop> >& getStops() const {
63 : return myPTStops;
64 : }
65 :
66 : /** @brief remove stops on non existing (removed) edges
67 : *
68 : * @param cont
69 : */
70 : int cleanupDeleted(NBEdgeCont& cont);
71 :
72 : void assignLanes(NBEdgeCont& cont);
73 :
74 : /// @brief duplicate stops for superposed rail edges and return the number of generated stops
75 : int generateBidiStops(NBEdgeCont& cont);
76 :
77 : /// @brief count number of stop-pairs for superposed rail-edges
78 : int countBidiStops(NBEdgeCont& cont) const;
79 :
80 : void localizePTStops(NBEdgeCont& cont);
81 :
82 : void assignEdgeForFloatingStops(NBEdgeCont& cont, double maxRadius);
83 :
84 : void findAccessEdgesForRailStops(NBEdgeCont& cont, double maxRadius, int maxCount, double accessFactor);
85 :
86 : void postprocess(std::set<std::string>& usedStops);
87 :
88 : /// @brief add edges that must be kept
89 : void addEdges2Keep(const OptionsCont& oc, std::set<std::string>& into);
90 :
91 : /// @brief replace the edge with the closes edge on the given edge list in all stops
92 : void replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
93 :
94 :
95 : std::shared_ptr<NBPTStop> findStop(const std::string& origEdgeID, Position pos, double threshold = 1) const;
96 :
97 : std::shared_ptr<NBPTStop> getReverseStop(std::shared_ptr<NBPTStop> pStop, const NBEdgeCont& ec);
98 :
99 : private:
100 : /// @brief Definition of the map of names to pt stops
101 : typedef std::map<std::string, std::shared_ptr<NBPTStop> > PTStopsCont;
102 :
103 : /// @brief The map of names to pt stops
104 : PTStopsCont myPTStops;
105 :
106 : /// @brief The map of edge ids to stops
107 : std::map<std::string, std::vector<std::shared_ptr<NBPTStop> > > myPTStopLookup;
108 :
109 : std::vector<std::shared_ptr<NBPTStop> > myFloatingStops;
110 :
111 :
112 : void assignPTStopToEdgeOfClosestPlatform(std::shared_ptr<NBPTStop> pStop, NBEdgeCont& cont);
113 : const NBPTPlatform* getClosestPlatformToPTStopPosition(std::shared_ptr<NBPTStop> pStop);
114 : std::shared_ptr<NBPTStop> assignAndCreatNewPTStopAsNeeded(std::shared_ptr<NBPTStop> pStop, NBEdgeCont& cont);
115 : double computeCrossProductEdgePosition(const NBEdge* edge, const Position& closestPlatform) const;
116 :
117 : static std::string getReverseID(const std::string& id);
118 :
119 : static std::set<std::string> myIgnoredStops;
120 :
121 :
122 : public:
123 : static NBEdge* getReverseEdge(NBEdge* edge);
124 :
125 : static void addIgnored(const std::string& stopID) {
126 : myIgnoredStops.insert(stopID);
127 5 : }
128 :
129 : static bool wasIgnored(const std::string& stopID) {
130 : return myIgnoredStops.count(stopID) > 0;
131 : }
132 :
133 : void alignIdSigns();
134 : };
|