45 delete myPTLine.second;
63 std::vector<NBPTStop*> stops = myPTLine->
getStops();
64 for (
auto& stop : stops) {
66 std::string origId = stop->getOrigEdgeId();
68 std::vector<std::string> waysIds = myPTLine->
getMyWays();
69 auto waysIdsIt = waysIds.begin();
70 if (waysIds.size() <= 1) {
72 +
", which consist of one way only. Ignoring!");
75 for (; waysIdsIt != waysIds.end(); waysIdsIt++) {
76 if ((*waysIdsIt) == origId) {
81 if (waysIdsIt == waysIds.end()) {
82 for (
auto& edgeCand : stop->getMyAdditionalEdgeCandidates()) {
84 waysIdsIt = waysIds.begin();
85 for (; waysIdsIt != waysIds.end(); waysIdsIt++) {
86 if ((*waysIdsIt) == edgeCand.first) {
87 if (stop->setEdgeId(edgeCand.second, cont)) {
88 stop->setMyOrigEdgeId(edgeCand.first);
89 origId = edgeCand.first;
102 if (waysIdsIt == waysIds.end()) {
103 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
108 std::vector<long long int>* way = myPTLine->
getWaysNodes(origId);
109 if (way ==
nullptr) {
110 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
117 std::string adjIdPrev;
118 std::string adjIdNext;
119 if (waysIdsIt != waysIds.begin()) {
120 adjIdPrev = *(waysIdsIt - 1);
122 if (waysIdsIt != (waysIds.end() - 1)) {
123 adjIdNext = *(waysIdsIt + 1);
125 std::vector<long long int>* wayPrev = myPTLine->
getWaysNodes(adjIdPrev);
126 std::vector<long long int>* wayNext = myPTLine->
getWaysNodes(adjIdNext);
127 if (wayPrev ==
nullptr && wayNext ==
nullptr) {
128 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
132 long long int wayEnds = *(way->end() - 1);
133 long long int wayBegins = *(way->begin());
134 long long int wayPrevEnds = wayPrev !=
nullptr ? *(wayPrev->end() - 1) : 0;
135 long long int wayPrevBegins = wayPrev !=
nullptr ? *(wayPrev->begin()) : 0;
136 long long int wayNextEnds = wayNext !=
nullptr ? *(wayNext->end() - 1) : 0;
137 long long int wayNextBegins = wayNext !=
nullptr ? *(wayNext->begin()) : 0;
138 if (wayBegins == wayPrevEnds || wayBegins == wayPrevBegins || wayEnds == wayNextBegins
139 || wayEnds == wayNextEnds) {
141 }
else if (wayEnds == wayPrevBegins || wayEnds == wayPrevEnds || wayBegins == wayNextEnds
142 || wayBegins == wayNextBegins) {
145 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
150 std::string edgeId = stop->getEdgeId();
152 int assignedTo = edgeId.at(0) ==
'-' ?
BWD :
FWD;
154 if (dir != assignedTo) {
156 if (reverse ==
nullptr) {
157 WRITE_WARNING(
"Could not re-assign PT stop: " + stop->getID() +
" probably broken osm file");
160 stop->setEdgeId(reverse->
getID(), cont);
161 WRITE_WARNING(
"PT stop: " + stop->getID() +
" has been moved to edge: " + reverse->
getID());
164 stop->addLine(myPTLine->
getRef());
170 std::vector<NBEdge*> edges;
174 std::vector<NBEdge*> prevWayEdges;
175 std::vector<NBEdge*> prevWayMinusEdges;
176 prevWayEdges.clear();
177 prevWayMinusEdges.clear();
178 std::vector<NBEdge*> currentWayEdges;
179 std::vector<NBEdge*> currentWayMinusEdges;
180 for (
auto it3 = pTLine->
getMyWays().begin();
181 it3 != pTLine->
getMyWays().end(); it3++) {
183 if (cont.
retrieve(*it3,
false) !=
nullptr) {
184 currentWayEdges.push_back(cont.
retrieve(*it3,
false));
187 while (cont.
retrieve(*it3 +
"#" + std::to_string(i),
false) !=
nullptr) {
188 currentWayEdges.push_back(cont.
retrieve(*it3 +
"#" + std::to_string(i),
false));
193 if (cont.
retrieve(
"-" + *it3,
false) !=
nullptr) {
194 currentWayMinusEdges.push_back(cont.
retrieve(
"-" + *it3,
false));
197 while (cont.
retrieve(
"-" + *it3 +
"#" + std::to_string(i),
false) !=
nullptr) {
198 currentWayMinusEdges.insert(currentWayMinusEdges.begin(),
199 cont.
retrieve(
"-" + *it3 +
"#" + std::to_string(i),
false));
203 if (currentWayEdges.empty()) {
206 if (last == currentWayEdges.front()->getFromNode() && last !=
nullptr) {
207 if (!prevWayEdges.empty()) {
208 edges.insert(edges.end(), prevWayEdges.begin(), prevWayEdges.end());
209 prevWayEdges.clear();
210 prevWayMinusEdges.clear();
212 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
213 last = currentWayEdges.back()->getToNode();
214 }
else if (last == currentWayEdges.back()->getToNode() && last !=
nullptr) {
215 if (!prevWayEdges.empty()) {
216 edges.insert(edges.end(), prevWayEdges.begin(), prevWayEdges.end());
217 prevWayEdges.clear();
218 prevWayMinusEdges.clear();
220 if (currentWayMinusEdges.empty()) {
221 currentWayEdges.clear();
225 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
226 last = currentWayMinusEdges.back()->getToNode();
228 }
else if (first == currentWayEdges.front()->getFromNode() && first !=
nullptr) {
229 edges.insert(edges.end(), prevWayMinusEdges.begin(), prevWayMinusEdges.end());
230 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
231 last = currentWayEdges.back()->getToNode();
232 prevWayEdges.clear();
233 prevWayMinusEdges.clear();
234 }
else if (first == currentWayEdges.back()->getToNode() && first !=
nullptr) {
235 edges.insert(edges.end(), prevWayMinusEdges.begin(), prevWayMinusEdges.end());
236 if (currentWayMinusEdges.empty()) {
237 currentWayEdges.clear();
239 prevWayEdges.clear();
240 prevWayMinusEdges.clear();
243 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
244 last = currentWayMinusEdges.back()->getToNode();
245 prevWayEdges.clear();
246 prevWayMinusEdges.clear();
249 if (it3 != pTLine->
getMyWays().begin()) {
252 prevWayEdges = currentWayEdges;
253 prevWayMinusEdges = currentWayMinusEdges;
254 if (!prevWayEdges.empty()) {
255 first = prevWayEdges.front()->getFromNode();
256 last = prevWayEdges.back()->getToNode();
262 currentWayEdges.clear();
263 currentWayMinusEdges.clear();
266 auto fr = edges.begin();
268 for (; fr != edges.end(); fr++) {
269 if ((*fr)->getID() == frStop->
getEdgeId()) {
275 for (; to != edges.end(); to++) {
276 if ((*to)->getID() == toStop->
getEdgeId()) {
288 if (oc.
isSet(
"ptline-output")) {
290 for (
auto edge : item.second->getRoute()) {
291 into.insert(edge->getID());
298 std::set<std::string>&
306 std::map<std::string, SUMOVehicleClass> types;
320 std::vector<NBPTStop*> stops = line->
getStops();
321 if (stops.size() < 2) {
324 if (types.count(line->
getType()) == 0) {
325 WRITE_WARNING(
"Could not determine vehicle class for public transport line of type '" 330 std::vector<NBPTStop*> newStops;
332 for (
auto it = stops.begin(); it != stops.end(); ++it) {
336 double best = std::numeric_limits<double>::max();
338 if (from ==
nullptr) {
339 if ((it + 1) != stops.end()) {
343 const double c1 =
getCost(ec, *router, from, to, &veh);
344 const double c2 =
getCost(ec, *router, from2, to, &veh);
350 const double c3 =
getCost(ec, *router, from, to2, &veh);
351 const double c4 =
getCost(ec, *router, from2, to2, &veh);
376 const double c1 =
getCost(ec, *router, from, to, &veh);
377 const double c2 =
getCost(ec, *router, from, to2, &veh);
388 if (best < std::numeric_limits<double>::max()) {
395 newStops.push_back(used);
397 assert(stops.size() == newStops.size());
409 if (fromEdge ==
nullptr || toEdge ==
nullptr) {
410 return std::numeric_limits<double>::max();
412 std::vector<const NBRouterEdge*> route;
413 router.
compute(fromEdge, toEdge, veh, 0, route);
414 if (route.size() == 0) {
415 return std::numeric_limits<double>::max();
static double getCost(const NBEdgeCont &ec, SUMOAbstractRouter< NBRouterEdge, NBVehicle > &router, const NBPTStop *from, const NBPTStop *to, const NBVehicle *veh)
std::vector< long long int > * getWaysNodes(std::string wayId)
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
const std::string & getType() const
void reviseStops(NBPTLine *myPTLine, NBEdgeCont &cont)
vehicle is a not electrified rail
The representation of a single edge during network building.
NBPTStop * getBidiStop() const
std::string getID() const
The representation of a single pt stop.
#define WRITE_WARNING(msg)
const std::vector< std::string > & getMyWays() const
void fixBidiStops(const NBEdgeCont &ec)
select the correct stop on superposed rail edges
void process(NBEdgeCont &cont)
RouterEdgeVector getAllRouterEdges() const
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const std::string & getRef() const
get line reference (not unique)
std::set< std::string > & getServedPTStops()
const std::string & getName() const
static double getTravelTimeStatic(const NBRouterEdge *const edge, const NBVehicle *const, double)
void replaceStops(std::vector< NBPTStop *> stops)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Computes the shortest path through a network using the Dijkstra algorithm.
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
void addEdgeVector(std::vector< NBEdge *>::iterator fr, std::vector< NBEdge *>::iterator to)
const std::string & getID() const
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
Storage for edges, including some functionality operating on multiple edges.
const std::string & getLineID() const
std::map< std::string, NBPTLine * > myPTLines
The map of names to pt lines.
void insert(NBPTLine *ptLine)
insert new line
A vehicle as used by router.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
~NBPTLineCont()
destructor
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
A storage for options typed value containers)
Represents a single node (junction) during network building.
std::vector< NBPTStop * > getStops()
void constructRoute(NBPTLine *myPTLine, NBEdgeCont &cont)
NBPTLineCont()
constructor
static NBEdge * getReverseEdge(NBEdge *edge)
const std::string getEdgeId() const
std::set< std::string > myServedPTStops