Eclipse SUMO - Simulation of Urban MObility
NBPTLineCont.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2023 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/****************************************************************************/
19// Container for NBPTLine during netbuild
20/****************************************************************************/
21#include <config.h>
22
23#include <iostream>
28#include "NBPTLineCont.h"
29#include "NBPTStop.h"
30#include "NBEdge.h"
31#include "NBNode.h"
32#include "NBVehicle.h"
33#include "NBPTStopCont.h"
34
35//#define DEBUG_FIND_WAY
36//#define DEBUG_CONSTRUCT_ROUTE
37
38#define DEBUGLINEID "1986097"
39#define DEBUGSTOPID ""
40
41// ===========================================================================
42// static value definitions
43// ===========================================================================
44const int NBPTLineCont::FWD(1);
45const int NBPTLineCont::BWD(-1);
46
47
48// ===========================================================================
49// method definitions
50// ===========================================================================
52 for (auto& myPTLine : myPTLines) {
53 delete myPTLine.second;
54 }
55 myPTLines.clear();
56}
57
58
59bool
61 if (myPTLines.count(ptLine->getLineID()) == 0) {
62 myPTLines[ptLine->getLineID()] = ptLine;
63 return true;
64 }
65 return false;
66}
67
68
69void
71 for (auto& item : myPTLines) {
72 NBPTLine* line = item.second;
73 if (item.second->getWays().size() > 0) {
74 // loaded from OSM rather than ptline input. We can use extra
75 // information to reconstruct route and stops
76 constructRoute(line, ec);
77 if (!routeOnly) {
78 // map stops to ways, using the constructed route for loose stops
79 reviseStops(line, ec, sc);
80 }
81 }
82 line->deleteInvalidStops(ec, sc);
83 //line->deleteDuplicateStops();
84 for (std::shared_ptr<NBPTStop> stop : line->getStops()) {
85 myServedPTStops.insert(stop->getID());
86 }
87 }
88}
89
90
91void
93 const std::vector<std::string>& waysIds = line->getWays();
94 if (waysIds.size() == 1 && line->getStops().size() > 1) {
95 reviseSingleWayStops(line, ec, sc);
96 return;
97 }
98 if (waysIds.size() <= 1) {
99 WRITE_WARNINGF(TL("Cannot revise pt stop localization for pt line '%', which consist of one way only. Ignoring!"), line->getLineID());
100 return;
101 }
102 if (line->getRoute().size() == 0) {
103 WRITE_WARNINGF(TL("Cannot revise pt stop localization for pt line '%', which has no route edges. Ignoring!"), line->getLineID());
104 return;
105 }
106 std::vector<std::shared_ptr<NBPTStop> > stops = line->getStops();
107 for (std::shared_ptr<NBPTStop> stop : stops) {
108 //get the corresponding and one of the two adjacent ways
109 stop = findWay(line, stop, ec, sc);
110 if (stop == nullptr) {
111 // warning already given
112 continue;
113 }
114 auto waysIdsIt = std::find(waysIds.begin(), waysIds.end(), stop->getOrigEdgeId());
115 if (waysIdsIt == waysIds.end()) {
116 // warning already given
117 continue;
118 }
119 // find directional edge (OSM ways are bidirectional)
120 const std::vector<long long int>* const way = line->getWayNodes(stop->getOrigEdgeId());
121 if (way == nullptr) {
122 WRITE_WARNINGF(TL("Cannot assign stop '%' on edge '%' to pt line '%' (wayNodes not found). Ignoring!"),
123 stop->getID(), stop->getOrigEdgeId(), line->getLineID());
124 continue;
125 }
126
127 int dir;
128 const std::vector<long long int>* wayPrev = nullptr;
129 if (waysIdsIt != waysIds.begin()) {
130 wayPrev = line->getWayNodes(*(waysIdsIt - 1));
131 }
132 const std::vector<long long int>* wayNext = nullptr;
133 if (waysIdsIt != (waysIds.end() - 1)) {
134 wayNext = line->getWayNodes(*(waysIdsIt + 1));
135 }
136 if (wayPrev == nullptr && wayNext == nullptr) {
137 WRITE_WARNINGF(TL("Cannot revise pt stop localization for incomplete pt line '%'. Ignoring!"), line->getLineID());
138 continue;
139 }
140 const long long int wayEnds = way->back();
141 const long long int wayBegins = way->front();
142 const long long int wayPrevEnds = wayPrev != nullptr ? wayPrev->back() : 0;
143 const long long int wayPrevBegins = wayPrev != nullptr ? wayPrev->front() : 0;
144 const long long int wayNextEnds = wayNext != nullptr ? wayNext->back() : 0;
145 const long long int wayNextBegins = wayNext != nullptr ? wayNext->front() : 0;
146 if (wayBegins == wayPrevEnds || wayBegins == wayPrevBegins || wayEnds == wayNextBegins || wayEnds == wayNextEnds) {
147 dir = FWD;
148 } else if (wayEnds == wayPrevBegins || wayEnds == wayPrevEnds || wayBegins == wayNextEnds || wayBegins == wayNextBegins) {
149 dir = BWD;
150 } else {
151 WRITE_WARNINGF(TL("Cannot revise pt stop localization for incomplete pt line '%'. Ignoring!"), line->getLineID());
152 continue;
153 }
154
155 std::string edgeId = stop->getEdgeId();
156 NBEdge* current = ec.getByID(edgeId);
157 int assignedTo = edgeId.at(0) == '-' ? BWD : FWD;
158
159 if (dir != assignedTo) {
160 NBEdge* reverse = NBPTStopCont::getReverseEdge(current);
161 if (reverse == nullptr) {
162 WRITE_WARNINGF(TL("Could not re-assign PT stop '%', probably broken osm file."), stop->getID());
163 continue;
164 }
165 if (stop->getLines().size() > 0) {
166 std::shared_ptr<NBPTStop> reverseStop = sc.getReverseStop(stop, ec);
167 sc.insert(reverseStop);
168 line->replaceStop(stop, reverseStop);
169 stop = reverseStop;
170 } else {
171 WRITE_WARNINGF(TL("PT stop '%' has been moved to edge '%'."), stop->getID(), reverse->getID());
172 }
173 stop->setEdgeId(reverse->getID(), ec);
174 }
175 stop->addLine(line->getRef());
176 }
177}
178
179
181 const std::vector<std::string>& waysIds = line->getWays();
182 for (std::shared_ptr<NBPTStop> stop : line->getStops()) {
183 //get the corresponding and one of the two adjacent ways
184 stop = findWay(line, stop, ec, sc);
185 if (stop == nullptr) {
186 // warning already given
187 continue;
188 }
189 auto waysIdsIt = std::find(waysIds.begin(), waysIds.end(), stop->getOrigEdgeId());
190 if (waysIdsIt == waysIds.end()) {
191 // warning already given
192 continue;
193 }
194 stop->addLine(line->getRef());
195 }
196}
197
198
199std::shared_ptr<NBPTStop>
200NBPTLineCont::findWay(NBPTLine* line, std::shared_ptr<NBPTStop> stop, const NBEdgeCont& ec, NBPTStopCont& sc) const {
201 const std::vector<std::string>& waysIds = line->getWays();
202#ifdef DEBUG_FIND_WAY
203 if (stop->getID() == DEBUGSTOPID) {
204 std::cout << " stop=" << stop->getID() << " line=" << line->getLineID() << " edgeID=" << stop->getEdgeId() << " origID=" << stop->getOrigEdgeId() << "\n";
205 }
206#endif
207 if (stop->isLoose()) {
208 // find closest edge in route
209 double minDist = std::numeric_limits<double>::max();
210 NBEdge* best = nullptr;
211 for (NBEdge* edge : line->getRoute()) {
212 const double dist = edge->getLaneShape(0).distance2D(stop->getPosition());
213 if (dist < minDist) {
214 best = edge;
215 minDist = dist;
216 }
217 }
218#ifdef DEBUG_FIND_WAY
219 if (stop->getID() == DEBUGSTOPID) {
220 std::cout << " best=" << Named::getIDSecure(best) << " minDist=" << minDist << " wayID=" << getWayID(best->getID())
221 << " found=" << (std::find(waysIds.begin(), waysIds.end(), getWayID(best->getID())) != waysIds.end())
222 << " wayIDs=" << toString(waysIds) << "\n";
223 }
224#endif
225 if (minDist < OptionsCont::getOptions().getFloat("ptline.match-dist")) {
226 const std::string wayID = getWayID(best->getID());
227 if (stop->getEdgeId() == "") {
228 stop->setEdgeId(best->getID(), ec);
229 stop->setOrigEdgeId(wayID);
230 } else if (stop->getEdgeId() != best->getID()) {
231 // stop is used by multiple lines and mapped to different edges.
232 // check if an alternative stop already exists
233 std::shared_ptr<NBPTStop> newStop = sc.findStop(wayID, stop->getPosition());
234 if (newStop == nullptr) {
235 newStop = std::make_shared<NBPTStop>(stop->getID() + "@" + line->getLineID(), stop->getPosition(), best->getID(), wayID, stop->getLength(), stop->getName(), stop->getPermissions());
236 newStop->setEdgeId(best->getID(), ec); // trigger lane assignment
237 sc.insert(newStop);
238 }
239 line->replaceStop(stop, newStop);
240 stop = newStop;
241 }
242 } else {
243 WRITE_WARNINGF(TL("Could not assign stop '%' to pt line '%' (closest edge '%', distance %). Ignoring!"),
244 stop->getID(), line->getLineID(), Named::getIDSecure(best), minDist);
245 return nullptr;
246 }
247 } else {
248 // if the stop is part of an edge, find that edge among the line edges
249 auto waysIdsIt = waysIds.begin();
250 for (; waysIdsIt != waysIds.end(); waysIdsIt++) {
251 if ((*waysIdsIt) == stop->getOrigEdgeId()) {
252 break;
253 }
254 }
255
256 if (waysIdsIt == waysIds.end()) {
257 // stop edge not found, try additional edges
258 for (auto& edgeCand : stop->getAdditionalEdgeCandidates()) {
259 bool found = false;
260 waysIdsIt = waysIds.begin();
261 for (; waysIdsIt != waysIds.end(); waysIdsIt++) {
262 if ((*waysIdsIt) == edgeCand.first) {
263 if (stop->setEdgeId(edgeCand.second, ec)) {
264 stop->setOrigEdgeId(edgeCand.first);
265 found = true;
266 break;
267 }
268 }
269 }
270 if (found) {
271 break;
272 }
273 }
274 if (waysIdsIt == waysIds.end()) {
275 WRITE_WARNINGF(TL("Cannot assign stop % on edge '%' to pt line '%'. Ignoring!"), stop->getID(), stop->getOrigEdgeId(), line->getLineID());
276 }
277 }
278 }
279 return stop;
280}
281
282
284 std::vector<NBEdge*> edges;
285
286 NBNode* first = nullptr;
287 NBNode* last = nullptr;
288 std::vector<NBEdge*> prevWayEdges;
289 std::vector<NBEdge*> prevWayMinusEdges;
290 prevWayEdges.clear();
291 prevWayMinusEdges.clear();
292 std::vector<NBEdge*> currentWayEdges;
293 std::vector<NBEdge*> currentWayMinusEdges;
294 for (auto it3 = pTLine->getWays().begin(); it3 != pTLine->getWays().end(); it3++) {
295
296 if (cont.retrieve(*it3, false) != nullptr) {
297 currentWayEdges.push_back(cont.retrieve(*it3, false));
298 } else {
299 int i = 0;
300 while (cont.retrieve(*it3 + "#" + std::to_string(i), true) != nullptr) {
301 if (cont.retrieve(*it3 + "#" + std::to_string(i), false)) {
302 currentWayEdges.push_back(cont.retrieve(*it3 + "#" + std::to_string(i), false));
303 }
304 i++;
305 }
306 }
307
308 if (cont.retrieve("-" + *it3, false) != nullptr) {
309 currentWayMinusEdges.push_back(cont.retrieve("-" + *it3, false));
310 } else {
311 int i = 0;
312 while (cont.retrieve("-" + *it3 + "#" + std::to_string(i), true) != nullptr) {
313 if (cont.retrieve("-" + *it3 + "#" + std::to_string(i), false)) {
314 currentWayMinusEdges.insert(currentWayMinusEdges.begin(),
315 cont.retrieve("-" + *it3 + "#" + std::to_string(i), false));
316 }
317 i++;
318 }
319 }
320#ifdef DEBUG_CONSTRUCT_ROUTE
321 if (pTLine->getLineID() == DEBUGLINEID) {
322 std::cout << " way=" << (*it3)
323 << " done=" << toString(edges)
324 << " first=" << Named::getIDSecure(first)
325 << " last=" << Named::getIDSecure(last)
326 << " +=" << toString(currentWayEdges)
327 << " -=" << toString(currentWayMinusEdges)
328 << "\n";
329 }
330#endif
331 if (currentWayEdges.empty()) {
332 continue;
333 }
334 if (last == currentWayEdges.front()->getFromNode() && last != nullptr) {
335 if (!prevWayEdges.empty()) {
336 edges.insert(edges.end(), prevWayEdges.begin(), prevWayEdges.end());
337 prevWayEdges.clear();
338 prevWayMinusEdges.clear();
339 }
340 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
341 last = currentWayEdges.back()->getToNode();
342 } else if (last == currentWayEdges.back()->getToNode() && last != nullptr) {
343 if (!prevWayEdges.empty()) {
344 edges.insert(edges.end(), prevWayEdges.begin(), prevWayEdges.end());
345 prevWayEdges.clear();
346 prevWayMinusEdges.clear();
347 }
348 if (currentWayMinusEdges.empty()) {
349 currentWayEdges.clear();
350 last = nullptr;
351 continue;
352 } else {
353 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
354 last = currentWayMinusEdges.back()->getToNode();
355 }
356 } else if (first == currentWayEdges.front()->getFromNode() && first != nullptr) {
357 edges.insert(edges.end(), prevWayMinusEdges.begin(), prevWayMinusEdges.end());
358 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
359 last = currentWayEdges.back()->getToNode();
360 prevWayEdges.clear();
361 prevWayMinusEdges.clear();
362 } else if (first == currentWayEdges.back()->getToNode() && first != nullptr) {
363 edges.insert(edges.end(), prevWayMinusEdges.begin(), prevWayMinusEdges.end());
364 if (currentWayMinusEdges.empty()) {
365 currentWayEdges.clear();
366 last = nullptr;
367 prevWayEdges.clear();
368 prevWayMinusEdges.clear();
369 continue;
370 } else {
371 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
372 last = currentWayMinusEdges.back()->getToNode();
373 prevWayEdges.clear();
374 prevWayMinusEdges.clear();
375 }
376 } else {
377 if (it3 != pTLine->getWays().begin()) {
378#ifdef DEBUG_CONSTRUCT_ROUTE
379 if (pTLine->getLineID() == DEBUGLINEID) {
380 std::cout << " way " << (*it3)
381 << " is not the start of ptline " << pTLine->getLineID()
382 << " (" + pTLine->getName() + ")\n";
383 }
384#endif
385 } else if (pTLine->getWays().size() == 1) {
386 if (currentWayEdges.size() > 0) {
387 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
388 } else {
389 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
390 }
391 }
392 prevWayEdges = currentWayEdges;
393 prevWayMinusEdges = currentWayMinusEdges;
394 if (!prevWayEdges.empty()) {
395 first = prevWayEdges.front()->getFromNode();
396 last = prevWayEdges.back()->getToNode();
397 } else {
398 first = nullptr;
399 last = nullptr;
400 }
401 }
402 currentWayEdges.clear();
403 currentWayMinusEdges.clear();
404 }
405 pTLine->setEdges(edges);
406}
407
408
409void
410NBPTLineCont::replaceEdge(const std::string& edgeID, const EdgeVector& replacement) {
411 //std::cout << " replaceEdge " << edgeID << " replacement=" << toString(replacement) << "\n";
412 if (myPTLines.size() > 0 && myPTLineLookup.size() == 0) {
413 // init lookup once
414 for (auto& item : myPTLines) {
415 for (const NBEdge* e : item.second->getRoute()) {
416 myPTLineLookup[e->getID()].insert(item.second);
417 }
418 }
419 }
420 for (NBPTLine* line : myPTLineLookup[edgeID]) {
421 line->replaceEdge(edgeID, replacement);
422 for (const NBEdge* e : replacement) {
423 myPTLineLookup[e->getID()].insert(line);
424 }
425 }
426 myPTLineLookup.erase(edgeID);
427}
428
429
430std::set<std::string>&
432 return myServedPTStops;
433}
434
435
436void
438 std::map<std::string, SUMOVehicleClass> types;
439 types["bus"] = SVC_BUS;
440 types["tram"] = SVC_TRAM;
441 types["train"] = SVC_RAIL;
442 types["subway"] = SVC_RAIL_URBAN;
443 types["light_rail"] = SVC_RAIL_URBAN;
444 types["monorail"] = SVC_RAIL_URBAN;
445 types["aerialway"] = SVC_RAIL_URBAN;
446 types["ferry"] = SVC_SHIP;
447
449 ec.getAllRouterEdges(), true, &NBRouterEdge::getTravelTimeStatic, nullptr, true);
450
451 for (auto& item : myPTLines) {
452 NBPTLine* line = item.second;
453 std::vector<std::shared_ptr<NBPTStop> > stops = line->getStops();
454 if (stops.size() < 2) {
455 continue;
456 }
457 if (types.count(line->getType()) == 0) {
458 WRITE_WARNINGF(TL("Could not determine vehicle class for public transport line of type '%'."), line->getType());
459 continue;
460 }
461 NBVehicle veh(line->getRef(), types[line->getType()]);
462 std::vector<std::shared_ptr<NBPTStop> > newStops;
463 std::shared_ptr<NBPTStop> from = nullptr;
464 for (auto it = stops.begin(); it != stops.end(); ++it) {
465 std::shared_ptr<NBPTStop> to = *it;
466 std::shared_ptr<NBPTStop> used = *it;
467 if (to->getBidiStop() != nullptr) {
468 double best = std::numeric_limits<double>::max();
469 std::shared_ptr<NBPTStop> to2 = to->getBidiStop();
470 if (from == nullptr) {
471 if ((it + 1) != stops.end()) {
472 from = to;
473 std::shared_ptr<NBPTStop> from2 = to2;
474 to = *(it + 1);
475 const double c1 = getCost(ec, *router, from, to, &veh);
476 const double c2 = getCost(ec, *router, from2, to, &veh);
477 //std::cout << " from=" << from->getID() << " to=" << to->getID() << " c1=" << MIN2(10000.0, c1) << "\n";
478 //std::cout << " from2=" << from2->getID() << " to=" << to->getID() << " c2=" << MIN2(10000.0, c2) << "\n";
479 best = c1;
480 if (to->getBidiStop() != nullptr) {
481 to2 = to->getBidiStop();
482 const double c3 = getCost(ec, *router, from, to2, &veh);
483 const double c4 = getCost(ec, *router, from2, to2, &veh);
484 //std::cout << " from=" << from->getID() << " to2=" << to2->getID() << " c3=" << MIN2(10000.0, c3) << "\n";
485 //std::cout << " from2=" << from2->getID() << " to2=" << to2->getID() << " c4=" << MIN2(10000.0, c4) << "\n";
486 if (c2 < best) {
487 used = from2;
488 best = c2;
489 }
490 if (c3 < best) {
491 used = from;
492 best = c3;
493 }
494 if (c4 < best) {
495 used = from2;
496 best = c4;
497 }
498 } else {
499 if (c2 < c1) {
500 used = from2;
501 best = c2;
502 } else {
503 best = c1;
504 }
505 }
506 }
507 } else {
508 const double c1 = getCost(ec, *router, from, to, &veh);
509 const double c2 = getCost(ec, *router, from, to2, &veh);
510 //std::cout << " from=" << from->getID() << " to=" << to->getID() << " c1=" << MIN2(10000.0, c1) << "\n";
511 //std::cout << " from=" << from->getID() << " t2o=" << to2->getID() << " c2=" << MIN2(10000.0, c2) << "\n";
512 if (c2 < c1) {
513 used = to2;
514 best = c2;
515 } else {
516 best = c1;
517 }
518
519 }
520 if (best < std::numeric_limits<double>::max()) {
521 from = used;
522 } else {
523 WRITE_WARNINGF(TL("Could not determine direction for line '%' at stop '%'."), line->getLineID(), used->getID());
524 }
525 }
526 from = used;
527 newStops.push_back(used);
528 }
529 assert(stops.size() == newStops.size());
530 line->replaceStops(newStops);
531 }
532 delete router;
533}
534
535
536void
538 for (auto& item : myPTLines) {
539 item.second->removeInvalidEdges(ec);
540 }
541}
542
543
544void
546 for (auto& item : myPTLines) {
547 NBPTLine* line = item.second;
548 const std::vector<NBEdge*>& route = line->getRoute();
549 const SUMOVehicleClass svc = line->getVClass();
550 for (int i = 1; i < (int)route.size(); i++) {
551 NBEdge* e1 = route[i - 1];
552 NBEdge* e2 = route[i];
553 std::vector<NBEdge::Connection> cons = e1->getConnectionsFromLane(-1, e2, -1);
554 if (cons.size() == 0) {
555 //WRITE_WARNINGF(TL("Disconnected ptline '%' between edge '%' and edge '%'"), line->getLineID(), e1->getID(), e2->getID());
556 } else {
557 bool ok = false;
558 for (const auto& c : cons) {
559 if ((e1->getPermissions(c.fromLane) & svc) == svc) {
560 ok = true;
561 break;
562 }
563 }
564 if (!ok) {
565 int lane = cons[0].fromLane;
566 e1->setPermissions(e1->getPermissions(lane) | svc, lane);
567 }
568 }
569 }
570 }
571}
572
573
574double
576 const std::shared_ptr<NBPTStop> from, const std::shared_ptr<NBPTStop> to, const NBVehicle* veh) {
577 NBEdge* fromEdge = ec.getByID(from->getEdgeId());
578 NBEdge* toEdge = ec.getByID(to->getEdgeId());
579 if (fromEdge == nullptr || toEdge == nullptr) {
580 return std::numeric_limits<double>::max();
581 } else if (fromEdge == toEdge) {
582 if (from->getEndPos() <= to->getEndPos()) {
583 return to->getEndPos() - from->getEndPos();
584 } else {
585 return std::numeric_limits<double>::max();
586 }
587 } else if (fromEdge->getBidiEdge() == toEdge) {
588 return std::numeric_limits<double>::max();
589 }
590 std::vector<const NBRouterEdge*> route;
591 router.compute(fromEdge, toEdge, veh, 0, route);
592 if (route.size() == 0) {
593 return std::numeric_limits<double>::max();
594 } else {
595 return router.recomputeCosts(route, veh, 0);
596 }
597}
598
599
600std::string
601NBPTLineCont::getWayID(const std::string& edgeID) {
602 std::size_t found = edgeID.rfind("#");
603 std::string result = edgeID;
604 if (found != std::string::npos) {
605 result = edgeID.substr(0, found);
606 }
607 if (result[0] == '-') {
608 result = result.substr(1);
609 }
610 return result;
611}
612
613
614/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:268
#define TL(string)
Definition: MsgHandler.h:284
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:42
#define DEBUGLINEID
#define DEBUGSTOPID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_SHIP
is an arbitrary ship
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_RAIL_URBAN
vehicle is a city rail
@ SVC_TRAM
vehicle is a light rail
@ SVC_BUS
vehicle is a bus
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
Computes the shortest path through a network using the Dijkstra algorithm.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:279
RouterEdgeVector getAllRouterEdges() const
return all router edges
The representation of a single edge during network building.
Definition: NBEdge.h:92
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:4215
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
Definition: NBEdge.cpp:4178
const std::string & getID() const
Definition: NBEdge.h:1515
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
Definition: NBEdge.cpp:1219
const NBEdge * getBidiEdge() const
Definition: NBEdge.h:1501
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:934
Represents a single node (junction) during network building.
Definition: NBNode.h:66
static double getCost(const NBEdgeCont &ec, SUMOAbstractRouter< NBRouterEdge, NBVehicle > &router, const std::shared_ptr< NBPTStop > from, const std::shared_ptr< NBPTStop > to, const NBVehicle *veh)
void reviseStops(NBPTLine *line, const NBEdgeCont &ec, NBPTStopCont &sc)
find directional edge for all stops of the line
void fixPermissions()
ensure that all turn lanes have sufficient permissions
void process(NBEdgeCont &ec, NBPTStopCont &sc, bool routeOnly=false)
std::set< std::string > myServedPTStops
Definition: NBPTLineCont.h:79
~NBPTLineCont()
destructor
std::map< std::string, NBPTLine * > myPTLines
The map of names to pt lines.
Definition: NBPTLineCont.h:66
std::shared_ptr< NBPTStop > findWay(NBPTLine *line, std::shared_ptr< NBPTStop > stop, const NBEdgeCont &ec, NBPTStopCont &sc) const
void replaceEdge(const std::string &edgeID, const EdgeVector &replacement)
replace the edge with the given edge list in all lines
std::set< std::string > & getServedPTStops()
void constructRoute(NBPTLine *myPTLine, const NBEdgeCont &cont)
bool insert(NBPTLine *ptLine)
insert new line
void removeInvalidEdges(const NBEdgeCont &ec)
filter out edges that were removed due to –geometry.remove
void fixBidiStops(const NBEdgeCont &ec)
select the correct stop on superposed rail edges
static const int BWD
Definition: NBPTLineCont.h:63
static const int FWD
Definition: NBPTLineCont.h:62
static std::string getWayID(const std::string &edgeID)
void reviseSingleWayStops(NBPTLine *line, const NBEdgeCont &ec, NBPTStopCont &sc)
std::map< std::string, std::set< NBPTLine * > > myPTLineLookup
The map of edge ids to lines that use this edge in their route.
Definition: NBPTLineCont.h:87
const std::string & getType() const
Definition: NBPTLine.h:59
void replaceStop(std::shared_ptr< NBPTStop > oldStop, std::shared_ptr< NBPTStop > newStop)
replace the given stop
Definition: NBPTLine.cpp:260
void replaceStops(std::vector< std::shared_ptr< NBPTStop > > stops)
Definition: NBPTLine.h:74
const std::vector< long long int > * getWayNodes(std::string wayId)
Definition: NBPTLine.cpp:123
void deleteInvalidStops(const NBEdgeCont &ec, const NBPTStopCont &sc)
remove invalid stops from the line
Definition: NBPTLine.cpp:288
const std::string & getName() const
Definition: NBPTLine.h:55
const std::string & getLineID() const
Definition: NBPTLine.h:51
SUMOVehicleClass getVClass() const
Definition: NBPTLine.h:89
const std::string & getRef() const
get line reference (not unique)
Definition: NBPTLine.h:70
const std::vector< NBEdge * > & getRoute() const
Definition: NBPTLine.cpp:163
const std::vector< std::string > & getWays() const
Definition: NBPTLine.h:110
const std::vector< std::shared_ptr< NBPTStop > > & getStops()
Definition: NBPTLine.cpp:65
void setEdges(const std::vector< NBEdge * > &edges)
Definition: NBPTLine.cpp:132
Container for public transport stops during the net building process.
Definition: NBPTStopCont.h:44
static NBEdge * getReverseEdge(NBEdge *edge)
std::shared_ptr< NBPTStop > getReverseStop(std::shared_ptr< NBPTStop > pStop, const NBEdgeCont &ec)
std::shared_ptr< NBPTStop > findStop(const std::string &origEdgeID, Position pos, double threshold=1) const
bool insert(std::shared_ptr< NBPTStop > ptStop, bool floating=false)
Inserts a node into the map.
static double getTravelTimeStatic(const NBRouterEdge *const edge, const NBVehicle *const, double)
Definition: NBEdge.h:82
A vehicle as used by router.
Definition: NBVehicle.h:42
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:67
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) 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...
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:21838