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_WARNING(
"Could not find corresponding edge or compatible lane for pt stop '" + i->first
105 +
"' (" + i->second->getName() +
"). Thus, it will be removed!");
119 std::vector<NBPTStop*> toAdd;
125 assert(bidiEdge != 0);
129 WRITE_WARNING(
"Could not create reverse-direction stop for superposed edge '" + bidiEdge->
getID()
130 +
"' (origStop '" + i->first +
"'). Stop id '" +
id
131 +
"' already in use by stop on edge '" +
myPTStops[
id]->getEdgeId() +
"'.");
143 toAdd.push_back(bidiStop);
155 if (toAdd.size() > 0) {
158 return (
int)toAdd.size();
167 if (reverse !=
nullptr) {
184 bool rightOfEdge =
false;
185 bool leftOfEdge =
false;
199 if (leftOfEdge && rightOfEdge) {
203 }
else if (leftOfEdge) {
205 if (reverse !=
nullptr) {
222 if (reverse !=
nullptr) {
245 if (offset2 < offset) {
252 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (
int) geom.size()) {
263 double x2 = closestPlatform.
x();
264 double y2 = closestPlatform.
y();
265 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
274 double minSqrDist = std::numeric_limits<double>::max();
277 if (sqrDist < minSqrDist) {
278 minSqrDist = sqrDist;
289 if (edge !=
nullptr) {
306 if (cont.
getByID((*i).second->getEdgeId()) ==
nullptr) {
307 WRITE_WARNING(
"Removing pt stop:" + (*i).first +
" on non existing edge: " + (*i).second->getEdgeId());
320 if (oc.
isSet(
"ptstop-output")) {
322 into.insert(stop.second->getEdgeId());
331 if (usedStops.find(i->second->getID()) == usedStops.end()) {
341 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
347 for (
auto& i : stops) {
348 const std::string& stopId = i.second->getID();
349 if (i.second->getEdgeId() ==
"") {
352 const char edgeSign = i.second->getEdgeId().at(0);
353 const char stopSign = stopId.at(0);
354 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
366 for (
auto edge : cont) {
367 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
368 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
369 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
370 r.
Insert(min, max, edge.second);
373 const std::string& stopEdgeID = ptStop.second->getEdgeId();
378 std::set<const Named*> edges;
380 const Position& pos = ptStop.second->getPosition();
381 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
382 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
383 r.
Search(min, max, visitor);
384 std::vector<NBEdge*> edgCants;
385 for (
const Named* namedEdge : edges) {
387 edgCants.push_back(e);
389 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
390 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
393 for (
auto edge : edgCants) {
395 for (
auto lane : edge->getLanes()) {
397 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
398 double finalLength = edge->getFinalLength();
399 double laneLength = lane.shape.length();
400 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
401 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
407 if (cnt == maxCount) {
419 if (item.second->getOrigEdgeId() == origEdgeID &&
420 item.second->getPosition().distanceTo2D(pos) < threshold) {
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(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)
NBPTStop * findStop(const std::string &origEdgeID, Position pos, double threshold=1) const
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
NBPTStop * get(std::string id)
Retrieve a previously inserted pt stop.
std::map< std::string, NBPTStop * > PTStopsCont
Definition of the map of names to pt stops.
PTStopsCont myPTStops
The map of names to pt stops.
const NBPTPlatform * getClosestPlatformToPTStopPosition(NBPTStop *pStop)
void localizePTStops(NBEdgeCont &cont)
NBPTStop * getReverseStop(NBPTStop *pStop, 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)
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 setBidiStop(NBPTStop *bidiStop)
void setMyPTStopLength(double myPTStopLength)
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
double offsetAtIndex2D(int index) const
return the offset at the given index
int indexOfClosest(const Position &p) const
index of the closest position to p