Eclipse SUMO - Simulation of Urban MObility
NBPTStopCont.h
Go to the documentation of this file.
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 /****************************************************************************/
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 // ===========================================================================
44 class NBPTStopCont {
45 public:
46 
47  ~NBPTStopCont();
48 
54  bool insert(std::shared_ptr<NBPTStop> ptStop, bool floating = false);
55 
57  std::shared_ptr<NBPTStop> get(std::string id) const;
58 
62  const std::map<std::string, std::shared_ptr<NBPTStop> >& getStops() const {
63  return myPTStops;
64  }
65 
70  int cleanupDeleted(NBEdgeCont& cont);
71 
72  void assignLanes(NBEdgeCont& cont);
73 
75  int generateBidiStops(NBEdgeCont& cont);
76 
77  void localizePTStops(NBEdgeCont& cont);
78 
79  void assignEdgeForFloatingStops(NBEdgeCont& cont, double maxRadius);
80 
81  void findAccessEdgesForRailStops(NBEdgeCont& cont, double maxRadius, int maxCount, double accessFactor);
82 
83  void postprocess(std::set<std::string>& usedStops);
84 
86  void addEdges2Keep(const OptionsCont& oc, std::set<std::string>& into);
87 
89  void replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
90 
91 
92  std::shared_ptr<NBPTStop> findStop(const std::string& origEdgeID, Position pos, double threshold = 1) const;
93 
94  std::shared_ptr<NBPTStop> getReverseStop(std::shared_ptr<NBPTStop> pStop, const NBEdgeCont& ec);
95 
96 private:
98  typedef std::map<std::string, std::shared_ptr<NBPTStop> > PTStopsCont;
99 
102 
104  std::map<std::string, std::vector<std::shared_ptr<NBPTStop> > > myPTStopLookup;
105 
106  std::vector<std::shared_ptr<NBPTStop> > myFloatingStops;
107 
108 
109  void assignPTStopToEdgeOfClosestPlatform(std::shared_ptr<NBPTStop> pStop, NBEdgeCont& cont);
110  const NBPTPlatform* getClosestPlatformToPTStopPosition(std::shared_ptr<NBPTStop> pStop);
111  std::shared_ptr<NBPTStop> assignAndCreatNewPTStopAsNeeded(std::shared_ptr<NBPTStop> pStop, NBEdgeCont& cont);
112  double computeCrossProductEdgePosition(const NBEdge* edge, const Position& closestPlatform) const;
113 
114  static std::string getReverseID(const std::string& id);
115 
116  static std::set<std::string> myIgnoredStops;
117 
118 
119 public:
120  static NBEdge* getReverseEdge(NBEdge* edge);
121 
122  static void addIgnored(const std::string& stopID) {
123  myIgnoredStops.insert(stopID);
124  }
125 
126  static bool wasIgnored(const std::string& stopID) {
127  return myIgnoredStops.count(stopID) > 0;
128  }
129 
130  void alignIdSigns();
131 };
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
The representation of a single edge during network building.
Definition: NBEdge.h:92
Container for public transport stops during the net building process.
Definition: NBPTStopCont.h:44
static std::string getReverseID(const std::string &id)
void replaceEdge(const std::string &edgeID, const std::vector< NBEdge * > &replacement)
replace the edge with the closes edge on the given edge list in all stops
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
void assignPTStopToEdgeOfClosestPlatform(std::shared_ptr< NBPTStop > pStop, NBEdgeCont &cont)
static std::set< std::string > myIgnoredStops
Definition: NBPTStopCont.h:116
static NBEdge * getReverseEdge(NBEdge *edge)
double computeCrossProductEdgePosition(const NBEdge *edge, const Position &closestPlatform) const
void postprocess(std::set< std::string > &usedStops)
static void addIgnored(const std::string &stopID)
Definition: NBPTStopCont.h:122
std::map< std::string, std::vector< std::shared_ptr< NBPTStop > > > myPTStopLookup
The map of edge ids to stops.
Definition: NBPTStopCont.h:104
const std::map< std::string, std::shared_ptr< NBPTStop > > & getStops() const
Returns an unmodifiable reference to the stored pt stops.
Definition: NBPTStopCont.h:62
std::shared_ptr< NBPTStop > get(std::string id) const
Retrieve a previously inserted pt stop.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
PTStopsCont myPTStops
The map of names to pt stops.
Definition: NBPTStopCont.h:101
std::vector< std::shared_ptr< NBPTStop > > myFloatingStops
Definition: NBPTStopCont.h:106
void localizePTStops(NBEdgeCont &cont)
static bool wasIgnored(const std::string &stopID)
Definition: NBPTStopCont.h:126
void alignIdSigns()
std::shared_ptr< NBPTStop > getReverseStop(std::shared_ptr< NBPTStop > pStop, const NBEdgeCont &ec)
std::map< std::string, std::shared_ptr< NBPTStop > > PTStopsCont
Definition of the map of names to pt stops.
Definition: NBPTStopCont.h:98
void assignEdgeForFloatingStops(NBEdgeCont &cont, double maxRadius)
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
const NBPTPlatform * getClosestPlatformToPTStopPosition(std::shared_ptr< NBPTStop > pStop)
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops
std::shared_ptr< NBPTStop > findStop(const std::string &origEdgeID, Position pos, double threshold=1) const
void assignLanes(NBEdgeCont &cont)
std::shared_ptr< NBPTStop > assignAndCreatNewPTStopAsNeeded(std::shared_ptr< NBPTStop > pStop, NBEdgeCont &cont)
bool insert(std::shared_ptr< NBPTStop > ptStop, bool floating=false)
Inserts a node into the map.
The representation of a single pt stop.
Definition: NBPTStop.h:45
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37