#pragma once
#include <config.h>
#include <memory>
#include <map>
#include <string>
#include <vector>
class OutputDevice;
class NBEdge;
class NBEdgeCont;
class NBPTStop;
class NBPTStopCont;
class NBPTLine {
public:
NBPTLine(const std::string& id, const std::string& name,
const std::string& type, const std::string& ref, int interval, const std::string& nightService,
SUMOVehicleClass vClass, RGBColor color);
void addPTStop(std::shared_ptr<NBPTStop> pStop);
const std::string& getLineID() const {
return myPTLineId;
}
const std::string& getName() const {
return myName;
}
const std::string& getType() const {
return myType;
}
const std::vector<std::shared_ptr<NBPTStop> >& getStops();
void write(OutputDevice& device);
void addWayNode(long long int way, long long int node);
void setNumOfStops(int numStops, int missingBefore, int missingAfter);
const std::string& getRef() const {
return myRef;
}
void replaceStops(std::vector<std::shared_ptr<NBPTStop> > stops) {
myPTStops = stops;
}
void setRevised(std::vector<bool> stopsRevised) {
myStopsRevised = stopsRevised;
}
struct PTStopInfo {
PTStopInfo(NBEdge* _edge, const std::string& _stopID, double _pos, bool _revised):
edge(_edge), stopID(_stopID), pos(_pos), revised(_revised) {}
NBEdge* edge;
std::string stopID;
double pos;
bool revised;
};
std::vector<PTStopInfo> getStopEdges(const NBEdgeCont& ec) const;
NBEdge* getRouteStart(const NBEdgeCont& ec) const;
NBEdge* getRouteEnd(const NBEdgeCont& ec) const;
bool isConsistent(std::vector<NBEdge*> stops) const;
SUMOVehicleClass getVClass() const {
return myVClass;
}
void replaceStop(std::shared_ptr<NBPTStop> oldStop, std::shared_ptr<NBPTStop> newStop);
void replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
void deleteInvalidStops(const NBEdgeCont& ec, const NBPTStopCont& sc);
void deleteDuplicateStops();
void removeInvalidEdges(const NBEdgeCont& ec);
void setName(const std::string& name) {
myName = name;
}
void setRef(const std::string& line) {
myRef = line;
}
void setPeriod(int intervalS) {
myInterval = intervalS / 60;
}
inline const std::vector<std::string>& getWays() const {
return myWays;
}
const std::vector<long long int>* getWayNodes(std::string wayId);
const EdgeVector& getEdges() const {
return myRoute;
}
private:
std::string myName;
std::string myType;
std::vector<std::shared_ptr<NBPTStop> > myPTStops;
std::vector<bool> myStopsRevised;
std::map<std::string, std::vector<long long int> > myWayNodes;
std::vector<std::string> myWays;
std::string myCurrentWay;
std::string myPTLineId;
std::string myRef;
RGBColor myColor;
int myInterval;
std::string myNightService;
SUMOVehicleClass myVClass;
public:
void setEdges(const std::vector<NBEdge*>& edges);
private:
std::vector<NBEdge*> myRoute;
public:
const std::vector<NBEdge*>& getRoute() const;
private:
int myNumOfStops;
int myMissingStopsBefore;
int myMissingStopsAfter;
};