71 std::vector<NBPTStop*> stops = myPTLine->
getStops();
72 for (
auto& stop : stops) {
74 std::string origId = stop->getOrigEdgeId();
76 std::vector<std::string> waysIds = myPTLine->
getMyWays();
77 auto waysIdsIt = waysIds.begin();
78 if (waysIds.size() <= 1) {
80 +
", which consist of one way only. Ignoring!");
83 for (; waysIdsIt != waysIds.end(); waysIdsIt++) {
84 if ((*waysIdsIt) == origId) {
89 if (waysIdsIt == waysIds.end()) {
90 for (
auto& edgeCand : stop->getMyAdditionalEdgeCandidates()) {
92 waysIdsIt = waysIds.begin();
93 for (; waysIdsIt != waysIds.end(); waysIdsIt++) {
94 if ((*waysIdsIt) == edgeCand.first) {
95 if (stop->setEdgeId(edgeCand.second, cont)) {
96 stop->setMyOrigEdgeId(edgeCand.first);
97 origId = edgeCand.first;
110 if (waysIdsIt == waysIds.end()) {
111 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
116 std::vector<long long int>* way = myPTLine->
getWaysNodes(origId);
117 if (way ==
nullptr) {
118 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
125 std::string adjIdPrev;
126 std::string adjIdNext;
127 if (waysIdsIt != waysIds.begin()) {
128 adjIdPrev = *(waysIdsIt - 1);
130 if (waysIdsIt != (waysIds.end() - 1)) {
131 adjIdNext = *(waysIdsIt + 1);
133 std::vector<long long int>* wayPrev = myPTLine->
getWaysNodes(adjIdPrev);
134 std::vector<long long int>* wayNext = myPTLine->
getWaysNodes(adjIdNext);
135 if (wayPrev ==
nullptr && wayNext ==
nullptr) {
136 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
140 long long int wayEnds = *(way->end() - 1);
141 long long int wayBegins = *(way->begin());
142 long long int wayPrevEnds = wayPrev !=
nullptr ? *(wayPrev->end() - 1) : 0;
143 long long int wayPrevBegins = wayPrev !=
nullptr ? *(wayPrev->begin()) : 0;
144 long long int wayNextEnds = wayNext !=
nullptr ? *(wayNext->end() - 1) : 0;
145 long long int wayNextBegins = wayNext !=
nullptr ? *(wayNext->begin()) : 0;
146 if (wayBegins == wayPrevEnds || wayBegins == wayPrevBegins || wayEnds == wayNextBegins
147 || wayEnds == wayNextEnds) {
149 }
else if (wayEnds == wayPrevBegins || wayEnds == wayPrevEnds || wayBegins == wayNextEnds
150 || wayBegins == wayNextBegins) {
153 WRITE_WARNING(
"Cannot revise pt stop localization for incomplete pt line: " + myPTLine->
getName()
158 std::string edgeId = stop->getEdgeId();
160 int assignedTo = edgeId.at(0) ==
'-' ?
BWD :
FWD;
162 if (dir != assignedTo) {
164 if (reverse ==
nullptr) {
165 WRITE_WARNING(
"Could not re-assign PT stop: " + stop->getID() +
" probably broken osm file");
168 stop->setEdgeId(reverse->
getID(), cont);
169 WRITE_WARNING(
"PT stop: " + stop->getID() +
" has been moved to edge: " + reverse->
getID());
172 stop->addLine(myPTLine->
getRef());
178 std::vector<NBEdge*> edges;
182 std::vector<NBEdge*> prevWayEdges;
183 std::vector<NBEdge*> prevWayMinusEdges;
184 prevWayEdges.clear();
185 prevWayMinusEdges.clear();
186 std::vector<NBEdge*> currentWayEdges;
187 std::vector<NBEdge*> currentWayMinusEdges;
188 for (
auto it3 = pTLine->
getMyWays().begin();
189 it3 != pTLine->
getMyWays().end(); it3++) {
191 if (cont.
retrieve(*it3,
false) !=
nullptr) {
192 currentWayEdges.push_back(cont.
retrieve(*it3,
false));
195 while (cont.
retrieve(*it3 +
"#" + std::to_string(i),
false) !=
nullptr) {
196 currentWayEdges.push_back(cont.
retrieve(*it3 +
"#" + std::to_string(i),
false));
201 if (cont.
retrieve(
"-" + *it3,
false) !=
nullptr) {
202 currentWayMinusEdges.push_back(cont.
retrieve(
"-" + *it3,
false));
205 while (cont.
retrieve(
"-" + *it3 +
"#" + std::to_string(i),
false) !=
nullptr) {
206 currentWayMinusEdges.insert(currentWayMinusEdges.begin(),
207 cont.
retrieve(
"-" + *it3 +
"#" + std::to_string(i),
false));
211 if (currentWayEdges.empty()) {
214 if (last == currentWayEdges.front()->getFromNode() && last !=
nullptr) {
215 if (!prevWayEdges.empty()) {
216 edges.insert(edges.end(), prevWayEdges.begin(), prevWayEdges.end());
217 prevWayEdges.clear();
218 prevWayMinusEdges.clear();
220 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
221 last = currentWayEdges.back()->getToNode();
222 }
else if (last == currentWayEdges.back()->getToNode() && last !=
nullptr) {
223 if (!prevWayEdges.empty()) {
224 edges.insert(edges.end(), prevWayEdges.begin(), prevWayEdges.end());
225 prevWayEdges.clear();
226 prevWayMinusEdges.clear();
228 if (currentWayMinusEdges.empty()) {
229 currentWayEdges.clear();
233 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
234 last = currentWayMinusEdges.back()->getToNode();
236 }
else if (first == currentWayEdges.front()->getFromNode() && first !=
nullptr) {
237 edges.insert(edges.end(), prevWayMinusEdges.begin(), prevWayMinusEdges.end());
238 edges.insert(edges.end(), currentWayEdges.begin(), currentWayEdges.end());
239 last = currentWayEdges.back()->getToNode();
240 prevWayEdges.clear();
241 prevWayMinusEdges.clear();
242 }
else if (first == currentWayEdges.back()->getToNode() && first !=
nullptr) {
243 edges.insert(edges.end(), prevWayMinusEdges.begin(), prevWayMinusEdges.end());
244 if (currentWayMinusEdges.empty()) {
245 currentWayEdges.clear();
247 prevWayEdges.clear();
248 prevWayMinusEdges.clear();
251 edges.insert(edges.end(), currentWayMinusEdges.begin(), currentWayMinusEdges.end());
252 last = currentWayMinusEdges.back()->getToNode();
253 prevWayEdges.clear();
254 prevWayMinusEdges.clear();
257 if (it3 != pTLine->
getMyWays().begin()) {
260 prevWayEdges = currentWayEdges;
261 prevWayMinusEdges = currentWayMinusEdges;
262 if (!prevWayEdges.empty()) {
263 first = prevWayEdges.front()->getFromNode();
264 last = prevWayEdges.back()->getToNode();
270 currentWayEdges.clear();
271 currentWayMinusEdges.clear();
274 auto fr = edges.begin();
276 for (; fr != edges.end(); fr++) {
277 if ((*fr)->getID() == frStop->
getEdgeId()) {
283 for (; to != edges.end(); to++) {
284 if ((*to)->getID() == toStop->
getEdgeId()) {
296 if (oc.
isSet(
"ptline-output")) {
298 for (
auto edge : line->getRoute()) {
299 into.insert(edge->getID());
306 std::set<std::string>&
314 std::map<std::string, SUMOVehicleClass> types;
327 std::vector<NBPTStop*> stops = line->getStops();
328 if (stops.size() < 2) {
331 if (types.count(line->getType()) == 0) {
332 WRITE_WARNING(
"Could not determine vehicle class for public transport line of type '" 333 + line->getType() +
"'.");
336 NBVehicle veh(line->getRef(), types[line->getType()]);
337 std::vector<NBPTStop*> newStops;
339 for (
auto it = stops.begin(); it != stops.end(); ++it) {
343 double best = std::numeric_limits<double>::max();
345 if (from ==
nullptr) {
346 if ((it + 1) != stops.end()) {
350 const double c1 =
getCost(ec, *router, from, to, &veh);
351 const double c2 =
getCost(ec, *router, from2, to, &veh);
357 const double c3 =
getCost(ec, *router, from, to2, &veh);
358 const double c4 =
getCost(ec, *router, from2, to2, &veh);
383 const double c1 =
getCost(ec, *router, from, to, &veh);
384 const double c2 =
getCost(ec, *router, from, to2, &veh);
395 if (best < std::numeric_limits<double>::max()) {
398 WRITE_WARNING(
"Could not determine direction for line '" +
toString(line->getLineID()) +
"' at stop '" + used->
getID() +
"'");
402 newStops.push_back(used);
404 assert(stops.size() == newStops.size());
405 line->replaceStops(newStops);
416 if (fromEdge ==
nullptr || toEdge ==
nullptr) {
417 return std::numeric_limits<double>::max();
419 std::vector<const NBEdge*> route;
420 router.
compute(fromEdge, toEdge, veh, 0, route);
421 if (route.size() == 0) {
422 return std::numeric_limits<double>::max();
std::vector< long long int > * getWaysNodes(std::string wayId)
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
void reviseStops(NBPTLine *myPTLine, NBEdgeCont &cont)
vehicle is a not electrified rail
The representation of a single edge during network building.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
NBPTStop * getBidiStop() const
std::string getID() const
const std::string & getID() const
Returns the id.
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)
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()
void insert(NBPTLine *pLine)
insert new line
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Computes the shortest path through a network using the Dijkstra algorithm.
void addEdgeVector(std::vector< NBEdge *>::iterator fr, std::vector< NBEdge *>::iterator to)
static double getCost(const NBEdgeCont &ec, SUMOAbstractRouter< NBEdge, NBVehicle > &router, const NBPTStop *from, const NBPTStop *to, const NBVehicle *veh)
Storage for edges, including some functionality operating on multiple edges.
A vehicle as used by router.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
~NBPTLineCont()
destructor
EdgeVector getAllEdges() const
return all edges
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)
static double getTravelTimeStatic(const NBEdge *const edge, const NBVehicle *const, double)
Represents a single node (junction) during network building.
const std::string & getName() const
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const
std::vector< NBPTStop * > getStops()
void constructRoute(NBPTLine *myPTLine, NBEdgeCont &cont)
NBPTLineCont()
constructor
long long int getLineID() const
static NBEdge * getReverseEdge(NBEdge *edge)
const std::string getEdgeId() const
void setId(long long int id)
std::set< std::string > myServedPTStops
std::vector< NBPTLine * > myPTLines
The map of names to pt lines.