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());
124 int existingBidiStops = 0;
125 std::vector<std::shared_ptr<NBPTStop> > toAdd;
127 std::shared_ptr<NBPTStop> stop = i->second;
131 assert(bidiEdge != 0);
135 WRITE_WARNINGF(
TL(
"Could not create reverse-direction stop for superposed edge '%' (origStop '%'). Stop id '%' already in use by stop on edge '%'."),
140 std::shared_ptr<NBPTStop> bidiStop = std::make_shared<NBPTStop>(
id,
143 stop->getOrigEdgeId(),
146 stop->getPermissions());
147 if (bidiStop->findLaneAndComputeBusStopExtent(ec)) {
148 toAdd.push_back(bidiStop);
149 stop->setBidiStop(bidiStop);
150 bidiStop->setBidiStop(stop);
155 }
else if (edge !=
nullptr) {
157 if (bidiEdge !=
nullptr) {
165 for (std::shared_ptr<NBPTStop> newStop : toAdd) {
168 if (toAdd.size() > 0) {
171 return (
int)toAdd.size() + existingBidiStops;
177 int existingBidiStops = 0;
179 auto stop = item.second;
183 assert(bidiEdge != 0);
187 if (it !=
myPTStops.end() && it->second->getEdgeId() == bidiEdge->
getID()) {
192 return existingBidiStops;
196std::shared_ptr<NBPTStop>
198 std::string edgeId = pStop->getEdgeId();
201 if (reverse !=
nullptr) {
202 const std::string reverseID =
getReverseID(pStop->getID());
204 return std::make_shared<NBPTStop>(reverseID, pStop->getPosition(), reverse->
getID(), reverse->
getID(),
205 pStop->getLength(), pStop->getName(), pStop->getPermissions());
214std::shared_ptr<NBPTStop>
216 std::string edgeId = pStop->getEdgeId();
218 if (edge ==
nullptr) {
221 bool rightOfEdge =
false;
222 bool leftOfEdge =
false;
224 for (
const NBPTPlatform& platform : pStop->getPlatformCands()) {
232 pStop->setPTStopLength(platform.getLength());
236 if (leftOfEdge && rightOfEdge) {
239 leftStop->setPTStopLength(left->
getLength());
242 }
else if (leftOfEdge) {
244 if (reverse !=
nullptr) {
245 pStop->setEdgeId(reverse->
getID(), cont);
246 pStop->setPTStopLength(left->
getLength());
256 std::string edgeId = pStop->getEdgeId();
260 pStop->setPTStopLength(closestPlatform->
getLength());
261 if (reverse !=
nullptr) {
271 pStop->setEdgeId(reverse->
getID(), cont);
284 if (offset2 < offset) {
291 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (
int) geom.size()) {
302 double x2 = closestPlatform.
x();
303 double y2 = closestPlatform.
y();
304 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
311 Position stopPosition = pStop->getPosition();
313 double minSqrDist = std::numeric_limits<double>::max();
314 for (
const NBPTPlatform& platform : pStop->getPlatformCands()) {
316 if (sqrDist < minSqrDist) {
317 minSqrDist = sqrDist;
328 if (edge !=
nullptr) {
345 if (cont.
getByID(i->second->getEdgeId()) ==
nullptr) {
346 WRITE_WARNINGF(
TL(
"Removing pt stop '%' on non existing edge '%'."), i->first, i->second->getEdgeId());
360 into.insert(stop.second->getEdgeId());
374 const std::vector<std::shared_ptr<NBPTStop> > stops =
myPTStopLookup[edgeID];
375 for (std::shared_ptr<NBPTStop> stop : stops) {
376 if (!stop->replaceEdge(edgeID, replacement)) {
377 WRITE_WARNINGF(
TL(
"Could not re-assign pt stop '%' after replacing edge '%'."), stop->getID(), edgeID);
389 if (usedStops.find(i->second->getID()) == usedStops.end()) {
399 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
405 for (
auto& i : stops) {
406 std::shared_ptr<NBPTStop> s = i.second;
407 const std::string& stopId = s->getID();
408 if (s->getEdgeId() ==
"" || s->wasLoaded()) {
411 const char edgeSign = s->getEdgeId().at(0);
412 const char stopSign = stopId.at(0);
413 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
415 std::shared_ptr<NBPTStop> rs =
get(reverseID);
416 if (rs !=
nullptr && rs->wasLoaded()) {
419 s->setPTStopId(reverseID);
423 rs->setPTStopId(stopId);
434 for (
const auto& item : cont) {
435 NBEdge* edge = item.second;
440 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
441 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
445 std::set<const Named*> edges;
447 const Position& pos = ptStop->getPosition();
448 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
449 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
450 r.
Search(min, max, visitor);
451 std::vector<NBEdge*> nearby;
452 for (
const Named* namedEdge : edges) {
458 std::sort(nearby.begin(), nearby.end(), [pos](
NBEdge * a,
NBEdge * b) {
459 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
462 for (
NBEdge* e : nearby) {
463 ptStop->setEdgeId(e->getID(), cont);
464 if (ptStop->getLaneId() !=
"") {
468 if (ptStop->getLaneId() ==
"") {
469 WRITE_WARNINGF(
TL(
"Could not find corresponding edge or compatible lane for free-floating pt stop '%' (%). Thus, it will be removed!"),
470 ptStop->getID(), ptStop->getName());
479 for (
auto edge : cont) {
480 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
481 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
482 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
483 r.
Insert(min, max, edge.second);
486 const std::string& stopEdgeID = ptStop.second->getEdgeId();
491 std::set<const Named*> edges;
493 const Position& pos = ptStop.second->getPosition();
494 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
495 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
496 r.
Search(min, max, visitor);
497 std::vector<NBEdge*> edgCants;
498 for (
const Named* namedEdge : edges) {
500 edgCants.push_back(e);
502 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
503 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
506 for (
auto edge : edgCants) {
508 for (
auto lane : edge->getLanes()) {
510 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
511 double finalLength = edge->getFinalLength();
512 double laneLength = lane.shape.length();
513 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
514 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
520 if (cnt == maxCount) {
529std::shared_ptr<NBPTStop>
532 if (item.second->getOrigEdgeId() == origEdgeID &&
533 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)
int countBidiStops(NBEdgeCont &cont) const
count number of stop-pairs for superposed rail-edges
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