34 delete myPTStop.second;
42 std::string
id = ptStop->
getID();
63 std::vector<NBPTStop*> reverseStops;
71 if (!platformsDefined) {
74 if (reverseStop !=
nullptr) {
75 reverseStops.push_back(reverseStop);
77 }
else if (multipleStopPositions) {
84 if (additionalStop !=
nullptr) {
85 reverseStops.push_back(additionalStop);
91 for (
auto& reverseStop : reverseStops) {
103 WRITE_WARNING(
"Could not find corresponding edge or compatible lane for pt stop: " + i->second->getName()
104 +
". Thus, it will be removed!");
120 if (reverse !=
nullptr) {
136 bool rightOfEdge =
false;
137 bool leftOfEdge =
false;
154 if (leftOfEdge && rightOfEdge) {
158 }
else if (leftOfEdge) {
160 if (reverse !=
nullptr) {
177 if (reverse !=
nullptr) {
200 if (offset2 < offset) {
207 if (idx1 < 0 || idx1 >= (
int) geom.size() || idx2 < 0 || idx2 >= (int) geom.size()) {
218 double x2 = closestPlatform->
x();
219 double y2 = closestPlatform->
y();
220 double crossProd = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
229 double minSqrDist = std::numeric_limits<double>::max();
236 if (sqrDist < minSqrDist) {
237 minSqrDist = sqrDist;
248 if (edge !=
nullptr) {
264 if (cont.
getByID((*i).second->getEdgeId()) ==
nullptr) {
265 WRITE_WARNING(
"Removing pt stop:" + (*i).first +
" on non existing edge: " + (*i).second->getEdgeId());
277 if (oc.
isSet(
"ptstop-output")) {
279 into.insert(stop.second->getEdgeId());
288 if (usedStops.find(i->second->getID()) == usedStops.end()) {
300 const std::string& stopId = i.second->getID();
301 const char edgeSign = i.second->getEdgeId().at(0);
302 const char stopSign = stopId.at(0);
303 if (edgeSign != stopSign && (edgeSign ==
'-' || stopSign ==
'-')) {
304 if (edgeSign ==
'-') {
305 i.second->setMyPTStopId(
"-" + stopId);
307 i.second->setMyPTStopId(stopId.substr(1, stopId.length()));
318 for (
auto edge : cont) {
319 const Boundary& bound = edge.second->getGeometry().getBoxBoundary();
320 float min[2] = {
static_cast<float>(bound.
xmin()), static_cast<float>(bound.
ymin()) };
321 float max[2] = {
static_cast<float>(bound.
xmax()), static_cast<float>(bound.
ymax()) };
322 r.
Insert(min, max, edge.second);
325 const std::string& stopEdgeID = ptStop.second->getEdgeId();
326 NBEdge* stopEdge = cont.getByID(stopEdgeID);
329 std::set<std::string> ids;
331 const Position& pos = ptStop.second->getPosition();
332 float min[2] = {
static_cast<float>(pos.
x() - maxRadius), static_cast<float>(pos.
y() - maxRadius)};
333 float max[2] = {
static_cast<float>(pos.
x() + maxRadius), static_cast<float>(pos.
y() + maxRadius)};
334 r.
Search(min, max, visitor);
335 std::vector<NBEdge*> edgCants;
336 for (
const auto&
id : ids) {
337 NBEdge* e = cont.getByID(
id);
338 edgCants.push_back(e);
340 std::sort(edgCants.begin(), edgCants.end(), [pos](
NBEdge * a,
NBEdge * b) {
344 for (
auto edge : edgCants) {
346 for (
auto lane : edge->getLanes()) {
348 double offset = lane.shape.nearest_offset_to_point2D(pos,
false);
350 double laneLength = lane.shape.length();
351 ptStop.second->addAccess(edge->getLaneID(laneIdx), offset * finalLength / laneLength);
357 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.
const std::string getName()
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
double ymin() const
Returns minimum y-coordinate.
void reviseStops(NBEdgeCont &cont)
revise pt stops and remove stops on non existing (removed) edges
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
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
void findAccessEdgesForRailStops(NBEdgeCont &cont, double d, int i)
const std::string getEdgeId()
void postprocess(std::set< std::string > &usedStops)
double y() const
Returns the y-position.
NBPTPlatform * getClosestPlatformToPTStopPosition(NBPTStop *pStop)
The representation of a single edge during network building.
A RT-tree for efficient storing of SUMO's Named objects.
double x() const
Returns the x-position.
NBPTStop * assignAndCreatNewPTStopAsNeeded(NBPTStop *pStop, NBEdgeCont &cont)
std::string getID() const
double computeCrossProductEdgePosition(const NBEdge *edge, const Position *closestPlatform) const
const std::string & getID() const
Returns the id.
The representation of a single pt stop.
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
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)
SVCPermissions getPermissions()
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.
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 getIsMultipleStopPositions()
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.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
std::vector< NBPTPlatform > & getPlatformCands()
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) ...
NBPTStop * getReverseStop(NBPTStop *pStop, NBEdgeCont &cont)
double offsetAtIndex2D(int index) const
return the offset at the given index
const Position & getPosition()
NBNode * getFromNode() const
Returns the origin node of the edge.
bool insert(NBPTStop *ptStop)
Inserts a node into the map.
double ymax() const
Returns maximum y-coordinate.
static NBEdge * getReverseEdge(NBEdge *edge)
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.