/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NBPTLine.h14/// @author Gregor Laemmel15/// @author Nikita Cherednychek16/// @date Tue, 20 Mar 201717///18// The representation of one direction of a single pt line19/****************************************************************************/20#pragma once21#include <config.h>2223#include <memory>24#include <map>25#include <string>26#include <vector>272829// ===========================================================================30// class declarations31// ===========================================================================32class OutputDevice;33class NBEdge;34class NBEdgeCont;35class NBPTStop;36class NBPTStopCont;373839// ===========================================================================40// class definitions41// ===========================================================================42class NBPTLine {43public:44NBPTLine(const std::string& id, const std::string& name,45const std::string& type, const std::string& ref, int interval, const std::string& nightService,46SUMOVehicleClass vClass, RGBColor color);4748void addPTStop(std::shared_ptr<NBPTStop> pStop);4950const std::string& getLineID() const {51return myPTLineId;52}5354const std::string& getName() const {55return myName;56}5758const std::string& getType() const {59return myType;60}6162const std::vector<std::shared_ptr<NBPTStop> >& getStops();63void write(OutputDevice& device);64void addWayNode(long long int way, long long int node);6566void setNumOfStops(int numStops, int missingBefore, int missingAfter);6768/// @brief get line reference (not unique)69const std::string& getRef() const {70return myRef;71}7273void replaceStops(std::vector<std::shared_ptr<NBPTStop> > stops) {74myPTStops = stops;75}76/// @brief get stop edges and stop ids77std::vector<std::pair<NBEdge*, std::string> > getStopEdges(const NBEdgeCont& ec) const;7879/// @brief return first valid edge of myRoute (if it doest not lie after the first stop)80NBEdge* getRouteStart(const NBEdgeCont& ec) const;8182/// @brief return last valid edge of myRoute (if it doest not lie before the last stop)83NBEdge* getRouteEnd(const NBEdgeCont& ec) const;8485/// @brief return whether the mentioned edges appear in that order in the route86bool isConsistent(std::vector<NBEdge*> stops) const;8788SUMOVehicleClass getVClass() const {89return myVClass;90}9192/// @brief replace the given stop93void replaceStop(std::shared_ptr<NBPTStop> oldStop, std::shared_ptr<NBPTStop> newStop);9495/// @brief replace the edge with the given edge list96void replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);9798/// @brief remove invalid stops from the line99void deleteInvalidStops(const NBEdgeCont& ec, const NBPTStopCont& sc);100void deleteDuplicateStops();101102/// @brief remove invalid edges from the line103void removeInvalidEdges(const NBEdgeCont& ec);104105void setName(const std::string& name) {106myName = name;107}108109void setRef(const std::string& line) {110myRef = line;111}112113void setPeriod(int intervalS) {114myInterval = intervalS / 60;115}116117inline const std::vector<std::string>& getWays() const {118return myWays;119}120121const std::vector<long long int>* getWayNodes(std::string wayId);122123private:124std::string myName;125std::string myType;126std::vector<std::shared_ptr<NBPTStop> > myPTStops;127std::map<std::string, std::vector<long long int> > myWayNodes;128std::vector<std::string> myWays;129std::string myCurrentWay;130std::string myPTLineId;131std::string myRef;132// official line color133RGBColor myColor;134135// @brief the service interval in minutes136int myInterval;137138std::string myNightService;139SUMOVehicleClass myVClass;140141public:142void setEdges(const std::vector<NBEdge*>& edges);143private:144// route of ptline145std::vector<NBEdge*> myRoute;146public:147const std::vector<NBEdge*>& getRoute() const;148private:149150int myNumOfStops;151int myMissingStopsBefore;152int myMissingStopsAfter;153};154155156