44 delete myPTStop.second;
52 std::string
id = ptStop->
getID();
76 std::vector<NBPTStop*> reverseStops;
79 NBPTStop*
const stop = ptStopIt.second;
82 if (!platformsDefined) {
85 if (reverseStop !=
nullptr) {
86 reverseStops.push_back(reverseStop);
88 }
else if (multipleStopPositions) {
95 if (additionalStop !=
nullptr) {
96 reverseStops.push_back(additionalStop);
101 for (
NBPTStop*
const reverseStop : reverseStops) {
113 WRITE_WARNINGF(
TL(
"Could not find corresponding edge or compatible lane for pt stop '%' (%). Thus, it will be removed!"),
114 i->first, i->second->getName());
128 int existingBidiStops = 0;
129 std::vector<NBPTStop*> toAdd;
135 assert(bidiEdge != 0);
139 WRITE_WARNINGF(
TL(
"Could not create reverse-direction stop for superposed edge '%' (origStop '%'). Stop id '%' already in use by stop on edge '%'."),
152 toAdd.push_back(bidiStop);
159 }
else if (edge !=
nullptr) {
161 if (bidiEdge !=
nullptr) {
172 if (toAdd.size() > 0) {
175 return (
int)toAdd.size() + existingBidiStops;
184 if (reverse !=
nullptr) {
201 if (edge ==
nullptr) {
204 bool rightOfEdge =
false;
205 bool leftOfEdge =
false;
219 if (leftOfEdge && rightOfEdge) {
225 }
else if (leftOfEdge) {
227 if (reverse !=
nullptr) {
244 if (reverse !=
nullptr) {
267 if (offset2 < offset) {
274 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (
int) geom.size()) {
285 double x2 = closestPlatform.
x();
286 double y2 = closestPlatform.
y();
287 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
296 double minSqrDist = std::numeric_limits<double>::max();
299 if (sqrDist < minSqrDist) {
300 minSqrDist = sqrDist;
311 if (edge !=
nullptr) {
328 if (cont.
getByID(i->second->getEdgeId()) ==
nullptr) {
329 WRITE_WARNINGF(
TL(
"Removing pt stop '%' on non existing edge '%'."), i->first, i->second->getEdgeId());
343 into.insert(stop.second->getEdgeId());
359 if (!stop->replaceEdge(edgeID, replacement)) {
360 WRITE_WARNINGF(
TL(
"Could not re-assign pt stop '%' after replacing edge '%'."), stop->getID(), edgeID);
372 if (usedStops.find(i->second->getID()) == usedStops.end()) {
382 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
388 for (
auto& i : stops) {
390 const std::string& stopId = s->
getID();
394 const char edgeSign = s->
getEdgeId().at(0);
395 const char stopSign = stopId.at(0);
396 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
414 for (
const auto& item : cont) {
415 NBEdge* edge = item.second;
420 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
421 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
425 std::set<const Named*> edges;
427 const Position& pos = ptStop->getPosition();
428 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
429 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
430 r.
Search(min, max, visitor);
431 std::vector<NBEdge*> nearby;
432 for (
const Named* namedEdge : edges) {
438 std::sort(nearby.begin(), nearby.end(), [pos](
NBEdge * a,
NBEdge * b) {
439 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
442 for (
NBEdge* e : nearby) {
443 ptStop->setEdgeId(e->getID(), cont);
444 if (ptStop->getLaneId() !=
"") {
448 if (ptStop->getLaneId() ==
"") {
449 WRITE_WARNINGF(
TL(
"Could not find corresponding edge or compatible lane for free-floating pt stop '%' (%). Thus, it will be removed!"),
450 ptStop->getID(), ptStop->getName());
459 for (
auto edge : cont) {
460 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
461 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
462 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
463 r.
Insert(min, max, edge.second);
466 const std::string& stopEdgeID = ptStop.second->getEdgeId();
471 std::set<const Named*> edges;
473 const Position& pos = ptStop.second->getPosition();
474 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
475 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
476 r.
Search(min, max, visitor);
477 std::vector<NBEdge*> edgCants;
478 for (
const Named* namedEdge : edges) {
480 edgCants.push_back(e);
482 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
483 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
486 for (
auto edge : edgCants) {
488 for (
auto lane : edge->getLanes()) {
490 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
491 double finalLength = edge->getFinalLength();
492 double laneLength = lane.shape.length();
493 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
494 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
500 if (cnt == maxCount) {
512 if (item.second->getOrigEdgeId() == origEdgeID &&
513 item.second->getPosition().distanceTo2D(pos) < threshold) {
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
@ 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
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
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)
bool insert(NBPTStop *ptStop, bool floating=false)
Inserts a node into the map.
static std::string getReverseID(const std::string &id)
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
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< NBPTStop * > > myPTStopLookup
The map of edge ids to stops.
NBPTStop * findStop(const std::string &origEdgeID, Position pos, double threshold=1) const
void replaceEdge(const std::string &edgeID, const EdgeVector &replacement)
replace the edge with the closes edge on the given edge list in all stops
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
std::map< std::string, NBPTStop * > PTStopsCont
Definition of the map of names to pt stops.
NBPTStop * get(std::string id) const
Retrieve a previously inserted pt stop.
PTStopsCont myPTStops
The map of names to pt stops.
NBPTStop * getReverseStop(NBPTStop *pStop, const NBEdgeCont &ec)
const NBPTPlatform * getClosestPlatformToPTStopPosition(NBPTStop *pStop)
void localizePTStops(NBEdgeCont &cont)
void assignEdgeForFloatingStops(NBEdgeCont &cont, double maxRadius)
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops
void assignLanes(NBEdgeCont &cont)
void assignPTStopToEdgeOfClosestPlatform(NBPTStop *pStop, NBEdgeCont &cont)
std::vector< NBPTStop * > myFloatingStops
NBPTStop * assignAndCreatNewPTStopAsNeeded(NBPTStop *pStop, NBEdgeCont &cont)
The representation of a single pt stop.
bool findLaneAndComputeBusStopExtent(const NBEdgeCont &ec)
void setPTStopLength(double ptStopLength)
bool setEdgeId(std::string edgeId, const NBEdgeCont &ec)
std::string getID() const
bool getIsMultipleStopPositions() const
const std::vector< NBPTPlatform > & getPlatformCands()
void setPTStopId(std::string id)
void setBidiStop(NBPTStop *bidiStop)
SVCPermissions getPermissions() const
const std::string & getEdgeId() const
const Position & getPosition() const
const std::string getOrigEdgeId() const
const std::string getName() const
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