Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netbuild/NBPTLineCont.h
169666 views
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 NBPTLineCont.h
15
/// @author Gregor Laemmel
16
/// @date Tue, 20 Mar 2017
17
///
18
// Container for NBPTLine during netbuild
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <vector>
24
#include "utils/router/SUMOAbstractRouter.h"
25
#include "NBEdgeCont.h"
26
#include "NBPTLine.h"
27
#include "NBVehicle.h"
28
29
30
// ===========================================================================
31
// class definitions
32
// ===========================================================================
33
class NBPTLineCont {
34
public:
35
/// @brief destructor
36
~NBPTLineCont();
37
38
/// @brief insert new line
39
bool insert(NBPTLine* ptLine);
40
41
NBPTLine* retrieve(const std::string& lineID);
42
43
const std::map<std::string, NBPTLine*>& getLines() const {
44
return myPTLines;
45
}
46
47
void process(NBEdgeCont& ec, NBPTStopCont& sc, bool routeOnly = false);
48
49
/// @brief replace the edge with the given edge list in all lines
50
void replaceEdge(const std::string& edgeID, const EdgeVector& replacement);
51
52
/// @brief select the correct stop on superposed rail edges
53
void fixBidiStops(const NBEdgeCont& ec);
54
55
/// @brief filter out edges that were removed due to --geometry.remove
56
void removeInvalidEdges(const NBEdgeCont& ec);
57
58
/// @brief ensure that all turn lanes have sufficient permissions
59
void fixPermissions();
60
61
std::set<std::string> getServedPTStops();
62
private:
63
64
static const int FWD;
65
static const int BWD;
66
67
/// @brief The map of names to pt lines
68
std::map<std::string, NBPTLine*> myPTLines;
69
70
/// @brief find directional edge for all stops of the line
71
void reviseStops(NBPTLine* line, const NBEdgeCont& ec, NBPTStopCont& sc);
72
73
void reviseSingleWayStops(NBPTLine* line, const NBEdgeCont& ec, NBPTStopCont& sc);
74
75
/* @brief find way element corresponding to the stop
76
* @note: if the edge id is updated, the stop extent is recomputed */
77
std::shared_ptr<NBPTStop> findWay(NBPTLine* line, std::shared_ptr<NBPTStop> stop, const NBEdgeCont& ec, NBPTStopCont& sc) const;
78
79
void constructRoute(NBPTLine* myPTLine, const NBEdgeCont& cont);
80
81
static double getCost(const NBEdgeCont& ec, SUMOAbstractRouter<NBRouterEdge, NBVehicle>& router,
82
const std::shared_ptr<NBPTStop> from, const std::shared_ptr<NBPTStop> to, const NBVehicle* veh);
83
84
static std::string getWayID(const std::string& edgeID);
85
86
/// @brief The map of edge ids to lines that use this edge in their route
87
std::map<std::string, std::set<NBPTLine*> > myPTLineLookup;
88
};
89
90