32 delete myPTStop.second;
40 std::string
id = ptStop->
getID();
61 std::vector<NBPTStop*> reverseStops;
69 if (!platformsDefined) {
72 if (reverseStop !=
nullptr) {
73 reverseStops.push_back(reverseStop);
75 }
else if (multipleStopPositions) {
82 if (additionalStop !=
nullptr) {
83 reverseStops.push_back(additionalStop);
89 for (
auto& reverseStop : reverseStops) {
101 WRITE_WARNING(
"Could not find corresponding edge or compatible lane for pt stop: " + i->second->getName()
102 +
". Thus, it will be removed!");
116 std::vector<NBPTStop*> toAdd;
122 assert(bidiEdge != 0);
126 WRITE_WARNING(
"Could not create reverse-direction stop for superposed edge '" + bidiEdge->
getID()
127 +
"' (origStop '" + i->first +
"'). Stop id '" +
id 128 +
"' already in use by stop on edge '" +
myPTStops[id]->getEdgeId() +
"'.");
140 toAdd.push_back(bidiStop);
152 if (toAdd.size() > 0) {
155 return (
int)toAdd.size();
164 if (reverse !=
nullptr) {
181 bool rightOfEdge =
false;
182 bool leftOfEdge =
false;
196 if (leftOfEdge && rightOfEdge) {
200 }
else if (leftOfEdge) {
202 if (reverse !=
nullptr) {
219 if (reverse !=
nullptr) {
242 if (offset2 < offset) {
249 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (int) geom.size()) {
260 double x2 = closestPlatform.
x();
261 double y2 = closestPlatform.
y();
262 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
271 double minSqrDist = std::numeric_limits<double>::max();
274 if (sqrDist < minSqrDist) {
275 minSqrDist = sqrDist;
286 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());
315 if (oc.
isSet(
"ptstop-output")) {
317 into.insert(stop.second->getEdgeId());
326 if (usedStops.find(i->second->getID()) == usedStops.end()) {
336 return id.size() > 0 &&
id[0] ==
'-' ?
id.substr(1) :
"-" + id;
342 for (
auto& i : stops) {
343 const std::string& stopId = i.second->getID();
344 const char edgeSign = i.second->getEdgeId().at(0);
345 const char stopSign = stopId.at(0);
346 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
358 for (
auto edge : cont) {
359 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
360 float min[2] = {
static_cast<float>(bound.
xmin()), static_cast<float>(bound.
ymin()) };
361 float max[2] = {
static_cast<float>(bound.
xmax()), static_cast<float>(bound.
ymax()) };
362 r.
Insert(min, max, edge.second);
365 const std::string& stopEdgeID = ptStop.second->getEdgeId();
366 NBEdge* stopEdge = cont.getByID(stopEdgeID);
370 std::set<std::string> ids;
372 const Position& pos = ptStop.second->getPosition();
373 float min[2] = {
static_cast<float>(pos.
x() - maxRadius), static_cast<float>(pos.
y() - maxRadius)};
374 float max[2] = {
static_cast<float>(pos.
x() + maxRadius), static_cast<float>(pos.
y() + maxRadius)};
375 r.
Search(min, max, visitor);
376 std::vector<NBEdge*> edgCants;
377 for (
const auto&
id : ids) {
378 NBEdge* e = cont.getByID(
id);
379 edgCants.push_back(e);
381 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
385 for (
auto edge : edgCants) {
387 for (
auto lane : edge->getLanes()) {
389 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
391 double laneLength = lane.shape.length();
392 double accessLength = pos.
distanceTo2D(lane.shape.positionAtOffset2D(offset)) * accessFactor;
393 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength, accessLength);
399 if (cnt == maxCount) {
bool setEdgeId(std::string edgeId, NBEdgeCont &ec)
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
double ymin() const
Returns minimum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
PTStopsCont myPTStops
The map of names to pt stops.
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops ...
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
void assignPTStopToEdgeOfClosestPlatform(NBPTStop *pStop, NBEdgeCont &cont)
int indexOfClosest(const Position &p) const
index of the closest position to p
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void postprocess(std::set< std::string > &usedStops)
double y() const
Returns the y-position.
The representation of a single edge during network building.
const NBPTPlatform * getClosestPlatformToPTStopPosition(NBPTStop *pStop)
A RT-tree for efficient storing of SUMO's Named objects.
double x() const
Returns the x-position.
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
NBPTStop * assignAndCreatNewPTStopAsNeeded(NBPTStop *pStop, NBEdgeCont &cont)
static std::string getReverseID(const std::string &id)
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
NBEdge * getTurnDestination(bool possibleDestination=false) const
std::string getID() const
const std::string & getID() const
Returns the id.
The representation of a single pt stop.
std::map< std::string, NBPTStop * > PTStopsCont
Definition of the map of names to pt stops.
double computeCrossProductEdgePosition(const NBEdge *edge, const Position &closestPlatform) const
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
SVCPermissions getPermissions() const
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
void localizePTStops(NBEdgeCont &cont)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void assignLanes(NBEdgeCont &cont)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const std::vector< NBPTPlatform > & getPlatformCands()
A point in 2D or 3D with translation and scaling methods.
Storage for edges, including some functionality operating on multiple edges.
double xmin() const
Returns minimum x-coordinate.
const std::string getName() const
void cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
bool getIsMultipleStopPositions() const
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
double getFinalLength() const
get length that will be assigned to the lanes in the final network
bool findLaneAndComputeBusStopExtend(NBEdgeCont &ec)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Allows to store the object; used as context while traveling the rtree in TraCI.
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
A storage for options typed value containers)
NBPTStop * get(std::string id)
Retrieve a previously inserted pt stop.
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions) ...
const std::string getOrigEdgeId() const
NBPTStop * getReverseStop(NBPTStop *pStop, NBEdgeCont &cont)
double offsetAtIndex2D(int index) const
return the offset at the given index
void setBidiStop(NBPTStop *bidiStop)
NBNode * getFromNode() const
Returns the origin node of the edge.
bool insert(NBPTStop *ptStop)
Inserts a node into the map.
const Position & getPosition() const
double ymax() const
Returns maximum y-coordinate.
static NBEdge * getReverseEdge(NBEdge *edge)
#define WRITE_MESSAGE(msg)
const std::string getEdgeId() const
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void setMyPTStopLength(double myPTStopLength)
NBNode * getToNode() const
Returns the destination node of the edge.