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