 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
31 delete myPTStop.second;
39 std::string
id = ptStop->
getID();
60 std::vector<NBPTStop*> reverseStops;
68 if (!platformsDefined) {
71 if (reverseStop !=
nullptr) {
72 reverseStops.push_back(reverseStop);
74 }
else if (multipleStopPositions) {
81 if (additionalStop !=
nullptr) {
82 reverseStops.push_back(additionalStop);
88 for (
auto& reverseStop : reverseStops) {
100 WRITE_WARNING(
"Could not find corresponding edge or compatible lane for pt stop '" + i->first
101 +
"' (" + i->second->getName() +
"). Thus, it will be removed!");
115 std::vector<NBPTStop*> toAdd;
121 assert(bidiEdge != 0);
125 WRITE_WARNING(
"Could not create reverse-direction stop for superposed edge '" + bidiEdge->
getID()
126 +
"' (origStop '" + i->first +
"'). Stop id '" +
id
127 +
"' already in use by stop on edge '" +
myPTStops[
id]->getEdgeId() +
"'.");
139 toAdd.push_back(bidiStop);
151 if (toAdd.size() > 0) {
154 return (
int)toAdd.size();
163 if (reverse !=
nullptr) {
180 bool rightOfEdge =
false;
181 bool leftOfEdge =
false;
195 if (leftOfEdge && rightOfEdge) {
199 }
else if (leftOfEdge) {
201 if (reverse !=
nullptr) {
218 if (reverse !=
nullptr) {
241 if (offset2 < offset) {
248 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (
int) geom.size()) {
259 double x2 = closestPlatform.
x();
260 double y2 = closestPlatform.
y();
261 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
270 double minSqrDist = std::numeric_limits<double>::max();
273 if (sqrDist < minSqrDist) {
274 minSqrDist = sqrDist;
285 if (edge !=
nullptr) {
302 if (cont.
getByID((*i).second->getEdgeId()) ==
nullptr) {
303 WRITE_WARNING(
"Removing pt stop:" + (*i).first +
" on non existing edge: " + (*i).second->getEdgeId());
316 if (oc.
isSet(
"ptstop-output")) {
318 into.insert(stop.second->getEdgeId());
327 if (usedStops.find(i->second->getID()) == usedStops.end()) {
337 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
343 for (
auto& i : stops) {
344 const std::string& stopId = i.second->getID();
345 if (i.second->getEdgeId() ==
"") {
348 const char edgeSign = i.second->getEdgeId().at(0);
349 const char stopSign = stopId.at(0);
350 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
362 for (
auto edge : cont) {
363 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
364 float min[2] = {
static_cast<float>(bound.
xmin()),
static_cast<float>(bound.
ymin()) };
365 float max[2] = {
static_cast<float>(bound.
xmax()),
static_cast<float>(bound.
ymax()) };
366 r.
Insert(min, max, edge.second);
369 const std::string& stopEdgeID = ptStop.second->getEdgeId();
370 NBEdge* stopEdge = cont.getByID(stopEdgeID);
374 std::set<std::string> ids;
376 const Position& pos = ptStop.second->getPosition();
377 float min[2] = {
static_cast<float>(pos.
x() - maxRadius),
static_cast<float>(pos.
y() - maxRadius)};
378 float max[2] = {
static_cast<float>(pos.
x() + maxRadius),
static_cast<float>(pos.
y() + maxRadius)};
379 r.
Search(min, max, visitor);
380 std::vector<NBEdge*> edgCants;
381 for (
const auto&
id : ids) {
382 NBEdge* e = cont.getByID(
id);
383 edgCants.push_back(e);
385 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
386 return a->getLaneShape(0).distance2D(pos, false) < b->getLaneShape(0).distance2D(pos, false);
389 for (
auto edge : edgCants) {
391 for (
auto lane : edge->getLanes()) {
393 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
394 double finalLength = edge->getFinalLength();
395 double laneLength = lane.shape.length();
396 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
397 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
403 if (cnt == maxCount) {
415 if (item.second->getOrigEdgeId() == origEdgeID &&
416 item.second->getPosition().distanceTo2D(pos) < threshold) {
void setBidiStop(NBPTStop *bidiStop)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
@ SVC_PEDESTRIAN
pedestrian
#define WRITE_WARNING(msg)
Storage for edges, including some functionality operating on multiple edges.
void localizePTStops(NBEdgeCont &cont)
double ymin() const
Returns minimum y-coordinate.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
SVCPermissions getPermissions() const
Allows to store the object; used as context while traveling the rtree in TraCI.
void setMyPTStopLength(double myPTStopLength)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
double xmax() const
Returns maximum x-coordinate.
std::string getID() const
const std::vector< NBPTPlatform > & getPlatformCands()
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
const std::string getOrigEdgeId() const
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
static NBEdge * getReverseEdge(NBEdge *edge)
double computeCrossProductEdgePosition(const NBEdge *edge, const Position &closestPlatform) const
double offsetAtIndex2D(int index) const
return the offset at the given index
const std::string getEdgeId() const
The representation of a single edge during network building.
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
double xmin() const
Returns minimum x-coordinate.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
bool getIsMultipleStopPositions() const
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
A class that stores a 2D geometrical boundary.
NBPTStop * assignAndCreatNewPTStopAsNeeded(NBPTStop *pStop, NBEdgeCont &cont)
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
A storage for options typed value containers)
int indexOfClosest(const Position &p) const
index of the closest position to p
NBPTStop * getReverseStop(NBPTStop *pStop, NBEdgeCont &cont)
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
NBPTStop * findStop(const std::string &origEdgeID, Position pos, double threshold=1) const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const Position & getPosition() const
std::map< std::string, NBPTStop * > PTStopsCont
Definition of the map of names to pt stops.
double y() const
Returns the y-position.
PTStopsCont myPTStops
The map of names to pt stops.
void assignPTStopToEdgeOfClosestPlatform(NBPTStop *pStop, NBEdgeCont &cont)
const std::string getName() const
NBPTStop * get(std::string id)
Retrieve a previously inserted pt stop.
A RT-tree for efficient storing of SUMO's Named objects.
bool findLaneAndComputeBusStopExtent(const NBEdgeCont &ec)
void assignLanes(NBEdgeCont &cont)
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
static std::string getReverseID(const std::string &id)
bool insert(NBPTStop *ptStop)
Inserts a node into the map.
void postprocess(std::set< std::string > &usedStops)
bool setEdgeId(std::string edgeId, const NBEdgeCont &ec)
The representation of a single pt stop.
const NBPTPlatform * getClosestPlatformToPTStopPosition(NBPTStop *pStop)
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
NBNode * getFromNode() const
Returns the origin node of the edge.
#define WRITE_MESSAGE(msg)
double ymax() const
Returns maximum y-coordinate.
NBEdge * getTurnDestination(bool possibleDestination=false) const
const std::string & getID() const