35 delete myPTStop.second;
43 std::string
id = ptStop->
getID();
64 std::vector<NBPTStop*> reverseStops;
72 if (!platformsDefined) {
75 if (reverseStop !=
nullptr) {
76 reverseStops.push_back(reverseStop);
78 }
else if (multipleStopPositions) {
85 if (additionalStop !=
nullptr) {
86 reverseStops.push_back(additionalStop);
92 for (
auto& reverseStop : reverseStops) {
104 WRITE_WARNINGF(
"Could not find corresponding edge or compatible lane for pt stop '%' (%). Thus, it will be removed!",
105 i->first, i->second->getName());
119 std::vector<NBPTStop*> toAdd;
125 assert(bidiEdge != 0);
129 WRITE_WARNINGF(
"Could not create reverse-direction stop for superposed edge '%' (origStop '%'). Stop id '%' already in use by stop on edge '%'.",
142 toAdd.push_back(bidiStop);
154 if (toAdd.size() > 0) {
157 return (
int)toAdd.size();
166 if (reverse !=
nullptr) {
183 bool rightOfEdge =
false;
184 bool leftOfEdge =
false;
198 if (leftOfEdge && rightOfEdge) {
202 }
else if (leftOfEdge) {
204 if (reverse !=
nullptr) {
221 if (reverse !=
nullptr) {
244 if (offset2 < offset) {
251 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (
int) geom.size()) {
262 double x2 = closestPlatform.
x();
263 double y2 = closestPlatform.
y();
264 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
273 double minSqrDist = std::numeric_limits<double>::max();
276 if (sqrDist < minSqrDist) {
277 minSqrDist = sqrDist;
288 if (edge !=
nullptr) {
305 if (cont.
getByID(i->second->getEdgeId()) ==
nullptr) {
306 WRITE_WARNINGF(
"Removing pt stop '%' on non existing edge '%'.", i->first, i->second->getEdgeId());
319 if (oc.
isSet(
"ptstop-output")) {
321 into.insert(stop.second->getEdgeId());
338 if (!stop->replaceEdge(edgeID, replacement)) {
339 WRITE_WARNINGF(
"Could not re-assign pt stop '%' after replacing edge '%'.", stop->getID(), edgeID);
351 if (usedStops.find(i->second->getID()) == usedStops.end()) {
361 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
367 for (
auto& i : stops) {
369 const std::string& stopId = s->
getID();
373 const char edgeSign = s->
getEdgeId().at(0);
374 const char stopSign = stopId.at(0);
375 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
393 for (
auto edge : cont) {
394 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
395 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
396 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
397 r.
Insert(min, max, edge.second);
400 const std::string& stopEdgeID = ptStop.second->getEdgeId();
405 std::set<const Named*> edges;
407 const Position& pos = ptStop.second->getPosition();
408 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
409 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
410 r.
Search(min, max, visitor);
411 std::vector<NBEdge*> edgCants;
412 for (
const Named* namedEdge : edges) {
414 edgCants.push_back(e);
416 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
417 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
420 for (
auto edge : edgCants) {
422 for (
auto lane : edge->getLanes()) {
424 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
425 double finalLength = edge->getFinalLength();
426 double laneLength = lane.shape.length();
427 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
428 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
434 if (cnt == maxCount) {
446 if (item.second->getOrigEdgeId() == origEdgeID &&
447 item.second->getPosition().distanceTo2D(pos) < threshold) {
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
@ 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.
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
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
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
const std::string & getID() const
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
NBEdge * getTurnDestination(bool possibleDestination=false) const
NBNode * getFromNode() const
Returns the origin node of the edge.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
bool insert(NBPTStop *ptStop)
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 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 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)
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)
const std::string getEdgeId() const
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 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)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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
double offsetAtIndex2D(int index) const
return the offset at the given index