50 std::string
id = ptStop->getID();
63std::shared_ptr<NBPTStop>
74 std::vector<std::shared_ptr<NBPTStop> > reverseStops;
77 std::shared_ptr<NBPTStop>
const stop = ptStopIt.second;
78 bool multipleStopPositions = stop->getIsMultipleStopPositions();
79 bool platformsDefined = !stop->getPlatformCands().empty();
80 if (!platformsDefined) {
82 std::shared_ptr<NBPTStop> reverseStop =
getReverseStop(stop, cont);
83 if (reverseStop !=
nullptr) {
84 reverseStops.push_back(reverseStop);
86 }
else if (multipleStopPositions) {
92 if (additionalStop !=
nullptr) {
93 reverseStops.push_back(additionalStop);
98 for (std::shared_ptr<NBPTStop>& reverseStop : reverseStops) {
108 std::shared_ptr<NBPTStop> stop = i->second;
109 if (!stop->findLaneAndComputeBusStopExtent(cont)) {
110 WRITE_WARNINGF(
TL(
"Could not find corresponding edge or compatible lane for pt stop '%' (%). Thus, it will be removed!"),
111 i->first, i->second->getName());
125 int existingBidiStops = 0;
126 std::vector<std::shared_ptr<NBPTStop> > toAdd;
128 std::shared_ptr<NBPTStop> stop = i->second;
132 assert(bidiEdge != 0);
136 WRITE_WARNINGF(
TL(
"Could not create reverse-direction stop for superposed edge '%' (origStop '%'). Stop id '%' already in use by stop on edge '%'."),
141 std::shared_ptr<NBPTStop> bidiStop = std::make_shared<NBPTStop>(
id,
144 stop->getOrigEdgeId(),
147 stop->getPermissions());
148 if (bidiStop->findLaneAndComputeBusStopExtent(ec)) {
149 toAdd.push_back(bidiStop);
150 stop->setBidiStop(bidiStop);
151 bidiStop->setBidiStop(stop);
156 }
else if (edge !=
nullptr) {
158 if (bidiEdge !=
nullptr) {
166 for (std::shared_ptr<NBPTStop> newStop : toAdd) {
169 if (toAdd.size() > 0) {
172 return (
int)toAdd.size() + existingBidiStops;
176std::shared_ptr<NBPTStop>
178 std::string edgeId = pStop->getEdgeId();
181 if (reverse !=
nullptr) {
182 const std::string reverseID =
getReverseID(pStop->getID());
184 return std::make_shared<NBPTStop>(reverseID, pStop->getPosition(), reverse->
getID(), reverse->
getID(),
185 pStop->getLength(), pStop->getName(), pStop->getPermissions());
194std::shared_ptr<NBPTStop>
196 std::string edgeId = pStop->getEdgeId();
198 if (edge ==
nullptr) {
201 bool rightOfEdge =
false;
202 bool leftOfEdge =
false;
204 for (
const NBPTPlatform& platform : pStop->getPlatformCands()) {
212 pStop->setPTStopLength(platform.getLength());
216 if (leftOfEdge && rightOfEdge) {
219 leftStop->setPTStopLength(left->
getLength());
222 }
else if (leftOfEdge) {
224 if (reverse !=
nullptr) {
225 pStop->setEdgeId(reverse->
getID(), cont);
226 pStop->setPTStopLength(left->
getLength());
236 std::string edgeId = pStop->getEdgeId();
240 pStop->setPTStopLength(closestPlatform->
getLength());
241 if (reverse !=
nullptr) {
251 pStop->setEdgeId(reverse->
getID(), cont);
264 if (offset2 < offset) {
271 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (
int) geom.size()) {
282 double x2 = closestPlatform.
x();
283 double y2 = closestPlatform.
y();
284 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
291 Position stopPosition = pStop->getPosition();
293 double minSqrDist = std::numeric_limits<double>::max();
294 for (
const NBPTPlatform& platform : pStop->getPlatformCands()) {
296 if (sqrDist < minSqrDist) {
297 minSqrDist = sqrDist;
308 if (edge !=
nullptr) {
325 if (cont.
getByID(i->second->getEdgeId()) ==
nullptr) {
326 WRITE_WARNINGF(
TL(
"Removing pt stop '%' on non existing edge '%'."), i->first, i->second->getEdgeId());
340 into.insert(stop.second->getEdgeId());
354 const std::vector<std::shared_ptr<NBPTStop> > stops =
myPTStopLookup[edgeID];
355 for (std::shared_ptr<NBPTStop> stop : stops) {
356 if (!stop->replaceEdge(edgeID, replacement)) {
357 WRITE_WARNINGF(
TL(
"Could not re-assign pt stop '%' after replacing edge '%'."), stop->getID(), edgeID);
369 if (usedStops.find(i->second->getID()) == usedStops.end()) {
379 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
385 for (
auto& i : stops) {
386 std::shared_ptr<NBPTStop> s = i.second;
387 const std::string& stopId = s->getID();
388 if (s->getEdgeId() ==
"") {
391 const char edgeSign = s->getEdgeId().at(0);
392 const char stopSign = stopId.at(0);
393 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
395 std::shared_ptr<NBPTStop> rs =
get(reverseID);
396 s->setPTStopId(reverseID);
400 rs->setPTStopId(stopId);
411 for (
const auto& item : cont) {
412 NBEdge* edge = item.second;
417 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
418 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
422 std::set<const Named*> edges;
424 const Position& pos = ptStop->getPosition();
425 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
426 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
427 r.
Search(min, max, visitor);
428 std::vector<NBEdge*> nearby;
429 for (
const Named* namedEdge : edges) {
435 std::sort(nearby.begin(), nearby.end(), [pos](
NBEdge * a,
NBEdge * b) {
436 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
439 for (
NBEdge* e : nearby) {
440 ptStop->setEdgeId(e->getID(), cont);
441 if (ptStop->getLaneId() !=
"") {
445 if (ptStop->getLaneId() ==
"") {
446 WRITE_WARNINGF(
TL(
"Could not find corresponding edge or compatible lane for free-floating pt stop '%' (%). Thus, it will be removed!"),
447 ptStop->getID(), ptStop->getName());
456 for (
auto edge : cont) {
457 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
458 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
459 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
460 r.
Insert(min, max, edge.second);
463 const std::string& stopEdgeID = ptStop.second->getEdgeId();
468 std::set<const Named*> edges;
470 const Position& pos = ptStop.second->getPosition();
471 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
472 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
473 r.
Search(min, max, visitor);
474 std::vector<NBEdge*> edgCants;
475 for (
const Named* namedEdge : edges) {
477 edgCants.push_back(e);
479 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
480 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
483 for (
auto edge : edgCants) {
485 for (
auto lane : edge->getLanes()) {
487 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
488 double finalLength = edge->getFinalLength();
489 double laneLength = lane.shape.length();
490 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
491 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
497 if (cnt == maxCount) {
506std::shared_ptr<NBPTStop>
509 if (item.second->getOrigEdgeId() == origEdgeID &&
510 item.second->getPosition().distanceTo2D(pos) < threshold) {
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_RAIL_URBAN
vehicle is a city rail
@ SVC_TRAM
vehicle is a light rail
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
Storage for edges, including some functionality operating on multiple edges.
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
The representation of a single edge during network building.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
const std::string & getID() const
NBNode * getFromNode() const
Returns the origin node of the edge.
NBEdge * getTurnDestination(bool possibleDestination=false) const
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
static std::string getReverseID(const std::string &id)
void replaceEdge(const std::string &edgeID, const std::vector< NBEdge * > &replacement)
replace the edge with the closes edge on the given edge list in all stops
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
void assignPTStopToEdgeOfClosestPlatform(std::shared_ptr< NBPTStop > pStop, NBEdgeCont &cont)
static std::set< std::string > myIgnoredStops
static NBEdge * getReverseEdge(NBEdge *edge)
double computeCrossProductEdgePosition(const NBEdge *edge, const Position &closestPlatform) const
void postprocess(std::set< std::string > &usedStops)
std::map< std::string, std::vector< std::shared_ptr< NBPTStop > > > myPTStopLookup
The map of edge ids to stops.
std::shared_ptr< NBPTStop > get(std::string id) const
Retrieve a previously inserted pt stop.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
PTStopsCont myPTStops
The map of names to pt stops.
std::vector< std::shared_ptr< NBPTStop > > myFloatingStops
void localizePTStops(NBEdgeCont &cont)
std::shared_ptr< NBPTStop > getReverseStop(std::shared_ptr< NBPTStop > pStop, const NBEdgeCont &ec)
std::map< std::string, std::shared_ptr< NBPTStop > > PTStopsCont
Definition of the map of names to pt stops.
void assignEdgeForFloatingStops(NBEdgeCont &cont, double maxRadius)
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
const NBPTPlatform * getClosestPlatformToPTStopPosition(std::shared_ptr< NBPTStop > pStop)
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops
std::shared_ptr< NBPTStop > findStop(const std::string &origEdgeID, Position pos, double threshold=1) const
void assignLanes(NBEdgeCont &cont)
std::shared_ptr< NBPTStop > assignAndCreatNewPTStopAsNeeded(std::shared_ptr< NBPTStop > pStop, NBEdgeCont &cont)
bool insert(std::shared_ptr< NBPTStop > ptStop, bool floating=false)
Inserts a node into the map.
Allows to store the object; used as context while traveling the rtree in TraCI.
Base class for objects which have an id.
A RT-tree for efficient storing of SUMO's Named objects.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
A storage for options typed value containers)
A point in 2D or 3D with translation and scaling methods.
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
double y() const
Returns the y-position.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double offsetAtIndex2D(int index) const
return the offset at the given index