SUMO - Simulation of Urban MObility
NBPTStopCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Container for pt stops during the netbuilding process
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
23 #include "NBPTStopCont.h"
24 #include "NBEdgeCont.h"
25 #include "NBEdge.h"
26 
28  std::string id = ptStop->getID();
29  PTStopsCont::iterator i = myPTStops.find(id);
30  if (i != myPTStops.end()) {
31  return false;
32  }
33  myPTStops[id] = ptStop;
34  return true;
35 }
37 
38  for (PTStopsCont::iterator i = myPTStops.begin(); i != myPTStops.end();) {
39  std::string edgeId = i->second->getEdgeId();
40  NBEdge* edge = cont.getByID(edgeId);
41 
42  if (edge != 0) {
43  const std::string& lane = edge->getLaneID(0);
44  i->second->setLaneID(lane);
45  const PositionVector& shape = edge->getLaneShape(0);
46  double offset = shape.nearest_offset_to_point2D(i->second->getPosition(), true);
47  i->second->computExtent(offset, edge->getLength());
48  i++;
49  } else {
50  WRITE_WARNING("Could not find corresponding edge for pt stop: " + i->second->getName() + ". Thus, it will be removed!");
51  EdgeVector edgeVector = cont.getGeneratedFrom((*i).second->getOrigEdgeId());
52  //std::cout << edgeVector.size() << std::endl;
53  myPTStops.erase(i++);
54  }
55 
56  }
57 
58 }
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:481
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
Definition: NBEdgeCont.cpp:830
PTStopsCont myPTStops
The map of names to pt stops.
Definition: NBPTStopCont.h:67
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
Definition: NBEdgeCont.cpp:879
The representation of a single edge during network building.
Definition: NBEdge.h:71
std::string getID() const
Definition: NBPTStop.cpp:50
The representation of a single pt stop.
Definition: NBPTStop.h:49
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:2679
A list of positions.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
void process(NBEdgeCont &cont)
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:757
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:41
bool insert(NBPTStop *ptStop)
Inserts a node into the map.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D