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 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 : 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 : 85 : /// @brief add edges that must be kept 86 : void addEdges2Keep(const OptionsCont& oc, std::set<std::string>& into); 87 : 88 : /// @brief replace the edge with the closes edge on the given edge list in all stops 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: 97 : /// @brief Definition of the map of names to pt stops 98 : typedef std::map<std::string, std::shared_ptr<NBPTStop> > PTStopsCont; 99 : 100 : /// @brief The map of names to pt stops 101 : PTStopsCont myPTStops; 102 : 103 : /// @brief The map of edge ids to stops 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 5 : } 125 : 126 : static bool wasIgnored(const std::string& stopID) { 127 1 : return myIgnoredStops.count(stopID) > 0; 128 : } 129 : 130 : void alignIdSigns(); 131 : };