Eclipse SUMO - Simulation of Urban MObility
GUILane.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Representation of a lane in the micro simulation (gui-version)
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include <string>
25 #include <utility>
26 #include <fx.h>
27 #include <utils/geom/GeomHelper.h>
28 #include <utils/geom/Position.h>
32 #include <utils/common/StdDefs.h>
33 #include <utils/geom/GeomHelper.h>
34 #include <utils/gui/div/GLHelper.h>
40 #include <microsim/MSGlobals.h>
41 #include <microsim/MSLane.h>
45 #include <microsim/MSNet.h>
48 #include <mesosim/MELoop.h>
49 #include <mesosim/MESegment.h>
50 #include "GUILane.h"
51 #include "GUIEdge.h"
52 #include "GUIVehicle.h"
53 #include "GUINet.h"
55 
56 #ifdef HAVE_OSG
57 #ifdef _MSC_VER
58 #pragma warning(push)
59 #pragma warning(disable: 4275) // do not warn about the DLL interface for OSG
60 #endif
61 #include <osg/Geometry>
62 #ifdef _MSC_VER
63 #pragma warning(pop)
64 #endif
65 #endif
66 
67 //#define GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
68 //#define GUILane_DEBUG_DRAW_VERTICES
69 //#define GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
70 
71 // ===========================================================================
72 // static member declaration
73 // ===========================================================================
74 const RGBColor GUILane::MESO_USE_LANE_COLOR(0, 0, 0, 0);
75 
76 
77 // ===========================================================================
78 // method definitions
79 // ===========================================================================
80 GUILane::GUILane(const std::string& id, double maxSpeed, double length,
81  MSEdge* const edge, int numericalID,
82  const PositionVector& shape, double width,
83  SVCPermissions permissions, int index, bool isRampAccel,
84  const std::string& type) :
85  MSLane(id, maxSpeed, length, edge, numericalID, shape, width, permissions, index, isRampAccel, type),
86  GUIGlObject(GLO_LANE, id),
87 #ifdef HAVE_OSG
88  myGeom(0),
89 #endif
90  myAmClosed(false),
91  myLock(true) {
93  myShape = splitAtSegments(shape);
94  assert(fabs(myShape.length() - shape.length()) < POSITION_EPS);
95  assert(myShapeSegments.size() == myShape.size());
96  }
97  myShapeRotations.reserve(myShape.size() - 1);
98  myShapeLengths.reserve(myShape.size() - 1);
99  myShapeColors.reserve(myShape.size() - 1);
100  int e = (int) myShape.size() - 1;
101  for (int i = 0; i < e; ++i) {
102  const Position& f = myShape[i];
103  const Position& s = myShape[i + 1];
104  myShapeLengths.push_back(f.distanceTo2D(s));
105  myShapeRotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
106  }
107  //
108  myHalfLaneWidth = myWidth / 2.;
110 }
111 
112 
114  // just to quit cleanly on a failure
115  if (myLock.locked()) {
116  myLock.unlock();
117  }
118 }
119 
120 
121 // ------ Vehicle insertion ------
122 void
123 GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
124  const MSLane::VehCont::iterator& at,
125  MSMoveReminder::Notification notification) {
126  FXMutexLock locker(myLock);
127  MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
128 }
129 
130 
131 // ------ Access to vehicles ------
132 const MSLane::VehCont&
134  myLock.lock();
135  return myVehicles;
136 }
137 
138 
139 void
141  myLock.unlock();
142 }
143 
144 
145 void
147  FXMutexLock locker(myLock);
149 }
150 
151 void
153  FXMutexLock locker(myLock);
155 }
156 
157 
158 void
160  FXMutexLock locker(myLock);
162 }
163 
164 
165 MSVehicle*
166 GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
167  FXMutexLock locker(myLock);
168  return MSLane::removeVehicle(remVehicle, notification, notify);
169 }
170 
171 
172 void
174  FXMutexLock locker(myLock);
175  return MSLane::removeParking(remVehicle);
176 }
177 
178 
179 void
181  FXMutexLock locker(myLock);
183 }
184 
185 
186 void
188  FXMutexLock locker(myLock);
190 }
191 
192 
193 void
194 GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
195  FXMutexLock locker(myLock);
196  MSLane::detectCollisions(timestep, stage);
197 }
198 
199 
200 double
202  FXMutexLock locker(myLock);
204 }
205 
206 
207 void
209  FXMutexLock locker(myLock);
211 }
212 
213 
214 // ------ Drawing methods ------
215 void
217  int noLinks = (int)myLinks.size();
218  if (noLinks == 0) {
219  return;
220  }
221  // draw all links
222  if (getEdge().isCrossing()) {
223  // draw indices at the start and end of the crossing
224  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
225  PositionVector shape = getShape();
226  shape.extrapolate(0.5); // draw on top of the walking area
229  return;
230  }
231  // draw all links
232  double w = myWidth / (double) noLinks;
233  double x1 = myHalfLaneWidth;
234  for (int i = noLinks; --i >= 0;) {
235  double x2 = x1 - (double)(w / 2.);
237  x1 -= w;
238  }
239 }
240 
241 
242 void
244  int noLinks = (int)myLinks.size();
245  if (noLinks == 0) {
246  return;
247  }
248  if (getEdge().isCrossing()) {
249  // draw indices at the start and end of the crossing
250  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
251  int linkNo = net.getLinkTLIndex(link);
252  // maybe the reverse link is controlled separately
253  int linkNo2 = net.getLinkTLIndex(myLinks.front());
254  // otherwise, use the same index as the forward link
255  if (linkNo2 < 0) {
256  linkNo2 = linkNo;
257  }
258  if (linkNo >= 0) {
259  PositionVector shape = getShape();
260  shape.extrapolate(0.5); // draw on top of the walking area
261  GLHelper::drawTextAtEnd(toString(linkNo2), shape, 0, s.drawLinkTLIndex, s.scale);
262  GLHelper::drawTextAtEnd(toString(linkNo), shape.reverse(), 0, s.drawLinkTLIndex, s.scale);
263  }
264  return;
265  }
266  // draw all links
267  double w = myWidth / (double) noLinks;
268  double x1 = myHalfLaneWidth;
269  for (int i = noLinks; --i >= 0;) {
270  double x2 = x1 - (double)(w / 2.);
271  int linkNo = net.getLinkTLIndex(myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i]);
272  if (linkNo < 0) {
273  continue;
274  }
276  x1 -= w;
277  }
278 }
279 
280 
281 void
283  int noLinks = (int)myLinks.size();
284  if (noLinks == 0) {
285  drawLinkRule(s, net, nullptr, getShape(), 0, 0);
286  return;
287  }
288  if (getEdge().isCrossing()) {
289  // draw rules at the start and end of the crossing
290  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
291  const MSLink* link2 = myLinks.front();
292  if (link2->getTLLogic() == nullptr) {
293  link2 = link;
294  }
295  PositionVector shape = getShape();
296  shape.extrapolate(0.5); // draw on top of the walking area
297  drawLinkRule(s, net, link2, shape, 0, myWidth);
298  drawLinkRule(s, net, link, shape.reverse(), 0, myWidth);
299  return;
300  }
301  // draw all links
302  const double w = myWidth / (double) noLinks;
303  double x1 = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL ? -myWidth * 0.5 : 0;
304  for (int i = 0; i < noLinks; ++i) {
305  double x2 = x1 + w;
306  drawLinkRule(s, net, myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i], getShape(), x1, x2);
307  x1 = x2;
308  }
309  // draw stopOffset for passenger cars
310  if (myStopOffsets.size() != 0 && (myStopOffsets.begin()->first & SVC_PASSENGER) != 0) {
311  const double stopOffsetPassenger = myStopOffsets.begin()->second;
312  const Position& end = myShape.back();
313  const Position& f = myShape[-2];
314  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
316  glPushMatrix();
317  glTranslated(end.x(), end.y(), 0);
318  glRotated(rot, 0, 0, 1);
319  glTranslated(0, stopOffsetPassenger, 0);
320  glBegin(GL_QUADS);
321  glVertex2d(-myHalfLaneWidth, 0.0);
322  glVertex2d(-myHalfLaneWidth, 0.2);
323  glVertex2d(myHalfLaneWidth, 0.2);
324  glVertex2d(myHalfLaneWidth, 0.0);
325  glEnd();
326  glPopMatrix();
327  }
328 }
329 
330 
331 void
332 GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link, const PositionVector& shape, double x1, double x2) const {
333  const Position& end = shape.back();
334  const Position& f = shape[-2];
335  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
336  if (link == nullptr) {
337  if (static_cast<GUIEdge*>(myEdge)->showDeadEnd()) {
339  } else {
341  }
342  glPushMatrix();
343  glTranslated(end.x(), end.y(), 0);
344  glRotated(rot, 0, 0, 1);
345  glBegin(GL_QUADS);
346  glVertex2d(-myHalfLaneWidth, 0.0);
347  glVertex2d(-myHalfLaneWidth, 0.5);
348  glVertex2d(myHalfLaneWidth, 0.5);
349  glVertex2d(myHalfLaneWidth, 0.0);
350  glEnd();
351  glPopMatrix();
352  } else {
353  glPushMatrix();
354  glTranslated(end.x(), end.y(), 0);
355  glRotated(rot, 0, 0, 1);
356  // select glID
357  switch (link->getState()) {
360  case LINKSTATE_TL_RED:
366  glPushName(net.getLinkTLID(link));
367  break;
368  case LINKSTATE_MAJOR:
369  case LINKSTATE_MINOR:
370  case LINKSTATE_EQUAL:
371  default:
372  glPushName(getGlID());
373  break;
374  }
376  if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
377  // the white bar should be the default for most railway
378  // links and looks ugly so we do not draw it
379  double scale = isInternal() ? 0.5 : 1;
381  scale *= MAX2(s.laneWidthExaggeration, s.junctionSize.getExaggeration(s, this, 10));
382  }
383  glScaled(scale, scale, 1);
384  glBegin(GL_QUADS);
385  glVertex2d(x1 - myHalfLaneWidth, 0.0);
386  glVertex2d(x1 - myHalfLaneWidth, 0.5);
387  glVertex2d(x2 - myHalfLaneWidth, 0.5);
388  glVertex2d(x2 - myHalfLaneWidth, 0.0);
389  glEnd();
390  }
391  glPopName();
392  glPopMatrix();
393  }
394 }
395 
396 void
398  if (myLinks.size() == 0) {
399  return;
400  }
401  // draw all links
402  const Position& end = getShape().back();
403  const Position& f = getShape()[-2];
404  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
405  glPushMatrix();
406  glColor3d(1, 1, 1);
407  glTranslated(end.x(), end.y(), 0);
408  glRotated(rot, 0, 0, 1);
410  glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
411  }
412  for (const MSLink* const link : myLinks) {
413  LinkDirection dir = link->getDirection();
414  LinkState state = link->getState();
415  if (state == LINKSTATE_DEADEND || dir == LinkDirection::NODIR) {
416  continue;
417  }
418  switch (dir) {
420  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
421  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
422  break;
423  case LinkDirection::TURN:
424  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
425  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
426  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
427  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
428  break;
430  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
431  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
432  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
433  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
434  break;
435  case LinkDirection::LEFT:
436  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
437  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
438  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
439  break;
441  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
442  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
443  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
444  break;
446  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
447  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
448  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
449  break;
451  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
452  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
453  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
454  break;
455  default:
456  break;
457  }
458  }
459  glPopMatrix();
460 }
461 
462 
463 void
464 GUILane::drawLane2LaneConnections(double exaggeration) const {
465  Position centroid;
466  if (exaggeration > 1) {
467  centroid = myEdge->getToJunction()->getShape().getCentroid();
468  }
469  for (const MSLink* const link : myLinks) {
470  const MSLane* connected = link->getLane();
471  if (connected == nullptr) {
472  continue;
473  }
475  glBegin(GL_LINES);
477  Position p2 = connected->getEdge().isWalkingArea() ? connected->getShape().getCentroid() : connected->getShape()[0];
478  if (exaggeration > 1) {
479  p1 = centroid + ((p1 - centroid) * exaggeration);
480  p2 = centroid + ((p2 - centroid) * exaggeration);
481  }
482  glVertex2d(p1.x(), p1.y());
483  glVertex2d(p2.x(), p2.y());
484  glEnd();
485  GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
486  }
487 }
488 
489 
490 void
492  glPushMatrix();
493  glPushName(getGlID());
494  const bool isCrossing = myEdge->isCrossing();
495  const bool isWalkingArea = myEdge->isWalkingArea();
496  const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
497  bool mustDrawMarkings = false;
498  double exaggeration = s.laneWidthExaggeration;
500  GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
501  exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s.edgeScaler.getActive()));
502  } else {
504  }
505  const bool hasRailSignal = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL;
506  const bool detailZoom = s.scale * exaggeration > 5;
507  const bool drawDetails = (detailZoom || s.junctionSize.minSize == 0 || hasRailSignal) && !s.drawForRectangleSelection;
508  const bool drawRails = drawAsRailway(s);
509  if (isCrossing || isWalkingArea) {
510  // draw internal lanes on top of junctions
511  glTranslated(0, 0, GLO_JUNCTION + 0.1);
512  } else if (isWaterway(myPermissions)) {
513  // draw waterways below normal roads
514  glTranslated(0, 0, getType() - 0.2);
515  } else {
516  glTranslated(0, 0, getType());
517  }
518  // set lane color
519  const RGBColor color = setColor(s);
521  myShapeColors.clear();
522  const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
523  if (segmentColors.size() > 0) {
524  // apply segment specific shape colors
525  //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
526  for (int ii = 0; ii < (int)myShape.size() - 1; ++ii) {
527  myShapeColors.push_back(segmentColors[myShapeSegments[ii]]);
528  }
529  }
530  }
531  // recognize full transparency and simply don't draw
532  bool hiddenBidi = myEdge->getBidiEdge() != nullptr && myEdge->getNumericalID() > myEdge->getBidiEdge()->getNumericalID();
533  if (color.alpha() != 0 && s.scale * exaggeration > s.laneMinSize) {
534  // scale tls-controlled lane2lane-arrows along with their junction shapes
535  double junctionExaggeration = 1;
536  if (!isInternal
539  junctionExaggeration = MAX2(1.001, s.junctionSize.getExaggeration(s, this, 4));
540  }
541  // draw lane
542  // check whether it is not too small
543  if (s.scale * exaggeration < 1. && junctionExaggeration == 1 && s.junctionSize.minSize != 0) {
544  if (!isInternal || hasRailSignal) {
545  if (myShapeColors.size() > 0) {
547  } else {
549  }
550  }
551  glPopMatrix();
552  } else {
553  GUINet* net = (GUINet*) MSNet::getInstance();
554  const bool spreadSuperposed = s.spreadSuperposed && myEdge->getBidiEdge() != nullptr && drawRails;
555  if (hiddenBidi && !spreadSuperposed) {
556  // do not draw shape
557  } else if (drawRails) {
558  // draw as railway: assume standard gauge of 1435mm when lane width is not set
559  // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
560  // assume crosstie length of 181% gauge (2600mm for standard gauge)
561  PositionVector shape = myShape;
562  const double width = myWidth;
563  double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * exaggeration;
564  if (spreadSuperposed) {
565  try {
566  shape.move2side(halfGauge * 0.8);
567  } catch (InvalidArgument&) {}
568  halfGauge *= 0.4;
569  }
570  const double halfInnerFeetWidth = halfGauge - 0.039 * exaggeration;
571  const double halfRailWidth = detailZoom ? (halfInnerFeetWidth + 0.15 * exaggeration) : SUMO_const_halfLaneWidth;
572  const double halfCrossTieWidth = halfGauge * 1.81;
573  if (myShapeColors.size() > 0) {
575  } else {
577  }
578  // Draw white on top with reduced width (the area between the two tracks)
579  if (detailZoom) {
580  glColor3d(1, 1, 1);
581  glTranslated(0, 0, .1);
582  GLHelper::drawBoxLines(shape, myShapeRotations, myShapeLengths, halfInnerFeetWidth);
583  setColor(s);
584  GLHelper::drawCrossTies(shape, myShapeRotations, myShapeLengths, 0.26 * exaggeration, 0.6 * exaggeration, halfCrossTieWidth, s.drawForRectangleSelection);
585  }
586  } else if (isCrossing) {
587  if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
588  glTranslated(0, 0, .2);
590  glTranslated(0, 0, -.2);
591  }
592  } else if (isWalkingArea) {
593  if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
594  glTranslated(0, 0, .2);
595  if (s.scale * exaggeration < 20.) {
597  } else {
599  }
600  glTranslated(0, 0, -.2);
601 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
603 #endif
604  }
605  } else {
606  // we draw the lanes with reduced width so that the lane markings below are visible
607  // (this avoids artifacts at geometry corners without having to
608  // compute lane-marking intersection points)
609  const double halfWidth = isInternal ? myQuarterLaneWidth : (myHalfLaneWidth - SUMO_const_laneMarkWidth / 2);
610  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
611  const int cornerDetail = drawDetails && !isInternal ? (int)(s.scale * exaggeration) : 0;
612  const double offset = halfWidth * MAX2(0., (exaggeration - 1)) * (MSGlobals::gLefthand ? -1 : 1);
613  if (myShapeColors.size() > 0) {
614  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myShapeColors, halfWidth * exaggeration, cornerDetail, offset);
615  } else {
616  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfWidth * exaggeration, cornerDetail, offset);
617  }
618  }
619 #ifdef GUILane_DEBUG_DRAW_VERTICES
621 #endif
622 #ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
625  }
626 #endif
627  glPopMatrix();
628  // draw details
629  if ((!isInternal || isCrossing || !s.drawJunctionShape) && (drawDetails || s.drawForRectangleSelection || junctionExaggeration > 1)) {
630  glPushMatrix();
631  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
632  glTranslated(0, 0, .5);
633  if (drawDetails) {
634  if (s.showLaneDirection) {
635  if (drawRails) {
636  // improve visibility of superposed rail edges
637  GLHelper::setColor(setColor(s).changedBrightness(100));
638  } else {
639  glColor3d(0.3, 0.3, 0.3);
640  }
641  if (!isCrossing || s.drawCrossingsAndWalkingareas) {
642  drawDirectionIndicators(exaggeration, spreadSuperposed);
643  }
644  }
645  if (!isInternal || isCrossing
646  // controlled internal junction
647  || (getLinkCont().size() != 0 && getLinkCont()[0]->isInternalJunctionLink() && getLinkCont()[0]->getTLLogic() != nullptr)) {
648  if (MSGlobals::gLateralResolution > 0 && s.showSublanes && !hiddenBidi && (myPermissions & ~(SVC_PEDESTRIAN | SVC_RAIL_CLASSES)) != 0) {
649  // draw sublane-borders
650  const double offsetSign = MSGlobals::gLefthand ? -1 : 1;
652  for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
653  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, 0.01, 0, -offset * offsetSign);
654  }
655  }
656  if (s.showLinkDecals && !drawRails && !drawAsWaterway(s) && myPermissions != SVC_PEDESTRIAN) {
657  drawArrows();
658  }
659  glTranslated(0, 0, 1000);
660  if (s.drawLinkJunctionIndex.show) {
661  drawLinkNo(s);
662  }
663  if (s.drawLinkTLIndex.show) {
664  drawTLSLinkNo(s, *net);
665  }
666  glTranslated(0, 0, -1000);
667  }
668  glTranslated(0, 0, .1);
669  }
670  // make sure link rules are drawn so tls can be selected via right-click
671  if (s.showLinkRules && (drawDetails || s.drawForRectangleSelection)
672  && !isWalkingArea
673  && (!myEdge->isInternal() || (getLinkCont().size() > 0 && getLinkCont()[0]->isInternalJunctionLink()))) {
674  drawLinkRules(s, *net);
675  }
676  if ((drawDetails || junctionExaggeration > 1) && s.showLane2Lane) {
677  // draw from end of first to the begin of second but respect junction scaling
678  drawLane2LaneConnections(junctionExaggeration);
679  }
680  glPopMatrix();
681  }
682  }
683  if (mustDrawMarkings && drawDetails && s.laneShowBorders && !hiddenBidi) { // needs matrix reset
684  drawMarkings(s, exaggeration);
685  }
686  if (drawDetails && isInternal && s.showBikeMarkings && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi) {
688  }
689  } else {
690  glPopMatrix();
691  }
692  // draw vehicles
693  if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
694  // retrieve vehicles from lane; disallow simulation
695  const MSLane::VehCont& vehicles = getVehiclesSecure();
696  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
697  if ((*v)->getLane() == this) {
698  static_cast<const GUIVehicle*>(*v)->drawGL(s);
699  } // else: this is the shadow during a continuous lane change
700  }
701  // draw parking vehicles
702  for (std::set<const MSVehicle*>::const_iterator v = myParkingVehicles.begin(); v != myParkingVehicles.end(); ++v) {
703  static_cast<const GUIVehicle*>(*v)->drawGL(s);
704  }
705  // allow lane simulation
706  releaseVehicles();
707  }
708  glPopName();
709 }
710 
711 
712 void
713 GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale) const {
714  glPushMatrix();
715  glTranslated(0, 0, GLO_EDGE);
716  setColor(s);
717  // optionally draw inverse markings
718  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
719  double mw = (myHalfLaneWidth + SUMO_const_laneMarkWidth) * scale;
720  double mw2 = (myHalfLaneWidth - SUMO_const_laneMarkWidth) * scale;
721  if (MSGlobals::gLefthand) {
722  mw *= -1;
723  mw2 *= -1;
724  }
725  int e = (int) getShape().size() - 1;
726  for (int i = 0; i < e; ++i) {
727  glPushMatrix();
728  glTranslated(getShape()[i].x(), getShape()[i].y(), 2.1);
729  glRotated(myShapeRotations[i], 0, 0, 1);
730  for (double t = 0; t < myShapeLengths[i]; t += 6) {
731  const double length = MIN2((double)3, myShapeLengths[i] - t);
732  glBegin(GL_QUADS);
733  glVertex2d(-mw, -t);
734  glVertex2d(-mw, -t - length);
735  glVertex2d(-mw2, -t - length);
736  glVertex2d(-mw2, -t);
737  glEnd();
738  }
739  glPopMatrix();
740  }
741  }
742  // draw white boundings and white markings
743  glColor3d(1, 1, 1);
745  getShape(),
747  getShapeLengths(),
749  glPopMatrix();
750 }
751 
752 
753 void
755  // draw bike lane markings onto the intersection
756  glColor3d(1, 1, 1);
757  const int e = (int) getShape().size() - 1;
758  const double markWidth = 0.1;
759  const double mw = myHalfLaneWidth;
760  for (int i = 0; i < e; ++i) {
761  glPushMatrix();
762  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.4);
763  glRotated(myShapeRotations[i], 0, 0, 1);
764  for (double t = 0; t < myShapeLengths[i]; t += 0.5) {
765  // left and right marking
766  for (int side = -1; side <= 1; side += 2) {
767  glBegin(GL_QUADS);
768  glVertex2d(side * mw, -t);
769  glVertex2d(side * mw, -t - 0.35);
770  glVertex2d(side * (mw + markWidth), -t - 0.35);
771  glVertex2d(side * (mw + markWidth), -t);
772  glEnd();
773  }
774  }
775  glPopMatrix();
776  }
777 }
778 
779 void
780 GUILane::drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const {
781  glPushMatrix();
782  glTranslated(0, 0, GLO_EDGE);
783  int e = (int) getShape().size() - 1;
784  const double widthFactor = spreadSuperposed ? 0.4 : 1;
785  const double w = MAX2(POSITION_EPS, myWidth * widthFactor);
786  const double w2 = MAX2(POSITION_EPS, myHalfLaneWidth * widthFactor);
787  const double w4 = MAX2(POSITION_EPS, myQuarterLaneWidth * widthFactor);
788  const double sideOffset = spreadSuperposed ? w * -0.5 : 0;
789  for (int i = 0; i < e; ++i) {
790  glPushMatrix();
791  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
792  glRotated(myShapeRotations[i], 0, 0, 1);
793  for (double t = 0; t < myShapeLengths[i]; t += w) {
794  const double length = MIN2(w2, myShapeLengths[i] - t) * exaggeration;
795  glBegin(GL_TRIANGLES);
796  glVertex2d(sideOffset, -t - length);
797  glVertex2d(sideOffset - w4 * exaggeration, -t);
798  glVertex2d(sideOffset + w4 * exaggeration, -t);
799  glEnd();
800  }
801  glPopMatrix();
802  }
803  glPopMatrix();
804 }
805 
806 
807 void
809  glPushMatrix();
810  glColor3d(1.0, 0.3, 0.3);
811  const double orthoLength = 0.5;
812  const MSLink* link = getLinkCont().front();
813  const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
814  const std::vector<std::pair<double, double> >& lengthsBehind = link->getLengthsBehindCrossing();
815  if (foeLanes.size() == lengthsBehind.size()) {
816  for (int i = 0; i < (int)foeLanes.size(); ++i) {
817  const MSLane* l = foeLanes[i];
818  Position pos = l->geometryPositionAtOffset(l->getLength() - lengthsBehind[i].second);
819  PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
820  if (ortho.length() < orthoLength) {
821  ortho.extrapolate(orthoLength - ortho.length(), false, true);
822  }
823  GLHelper::drawLine(ortho);
824  //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - lengthsBehind[i].second << " pos=" << pos << "\n";
825  }
826  }
827  glPopMatrix();
828 }
829 
830 
831 // ------ inherited from GUIGlObject
834  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
835  buildPopupHeader(ret, app);
837  //
838  GUIDesigns::buildFXMenuCommand(ret, "Copy edge name to clipboard", nullptr, ret, MID_COPY_EDGE_NAME);
841  //
842  buildShowParamsPopupEntry(ret, false);
844  const double height = myShape.positionAtOffset(pos).z();
845  GUIDesigns::buildFXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), nullptr, nullptr, 0);
846  new FXMenuSeparator(ret);
847  buildPositionCopyEntry(ret, false);
848  new FXMenuSeparator(ret);
849  if (myAmClosed) {
850  if (myPermissionChanges.empty()) {
851  GUIDesigns::buildFXMenuCommand(ret, "Reopen lane", nullptr, &parent, MID_CLOSE_LANE);
852  GUIDesigns::buildFXMenuCommand(ret, "Reopen edge", nullptr, &parent, MID_CLOSE_EDGE);
853  } else {
854  GUIDesigns::buildFXMenuCommand(ret, "Reopen lane (override rerouter)", nullptr, &parent, MID_CLOSE_LANE);
855  GUIDesigns::buildFXMenuCommand(ret, "Reopen edge (override rerouter)", nullptr, &parent, MID_CLOSE_EDGE);
856  }
857  } else {
858  GUIDesigns::buildFXMenuCommand(ret, "Close lane", nullptr, &parent, MID_CLOSE_LANE);
859  GUIDesigns::buildFXMenuCommand(ret, "Close edge", nullptr, &parent, MID_CLOSE_EDGE);
860  }
861  GUIDesigns::buildFXMenuCommand(ret, "Add rerouter", nullptr, &parent, MID_ADD_REROUTER);
862  new FXMenuSeparator(ret);
863  // reachability menu
864  FXMenuPane* reachableByClass = new FXMenuPane(ret);
865  ret->insertMenuPaneChild(reachableByClass);
866  new FXMenuCascade(ret, "Select reachable", GUIIconSubSys::getIcon(GUIIcon::FLAG), reachableByClass);
867  for (auto i : SumoVehicleClassStrings.getStrings()) {
868  GUIDesigns::buildFXMenuCommand(reachableByClass, i.c_str(), nullptr, &parent, MID_REACHABILITY);
869  }
870  return ret;
871 }
872 
873 
876  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
877  // add items
878  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
879  ret->mkItem("length [m]", false, myLength);
880  ret->mkItem("width [m]", false, myWidth);
881  ret->mkItem("street name", false, myEdge->getStreetName());
882  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
883  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
884  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
885  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
886  ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
887  ret->mkItem("pending insertions [#]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getPendingEmits));
888  ret->mkItem("edge type", false, myEdge->getEdgeType());
889  ret->mkItem("type", false, myLaneType);
890  ret->mkItem("priority", false, myEdge->getPriority());
891  ret->mkItem("distance [km]", false, myEdge->getDistance() / 1000);
892  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
893  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
894  ret->mkItem("permission code", false, myPermissions);
895  if (myEdge->getBidiEdge() != nullptr) {
896  ret->mkItem("bidi-edge", false, myEdge->getBidiEdge()->getID());
897  }
898  for (const auto& kv : myEdge->getParametersMap()) {
899  ret->mkItem(("edgeParam:" + kv.first).c_str(), false, kv.second);
900  }
901  ret->closeBuilding();
902  return ret;
903 }
904 
905 
906 Boundary
908  Boundary b;
909  b.add(myShape[0]);
910  b.add(myShape[-1]);
911  b.grow(10);
912  // ensure that vehicles and persons on the side are drawn even if the edge
913  // is outside the view
914  return b;
915 }
916 
917 
918 const PositionVector&
920  return myShape;
921 }
922 
923 
924 const std::vector<double>&
926  return myShapeRotations;
927 }
928 
929 
930 const std::vector<double>&
932  return myShapeLengths;
933 }
934 
935 
936 double
938  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
939 }
940 
941 
942 double
944  return (double) myEdge->getLanes().size();
945 }
946 
947 
948 double
951  if (!ews.knowsTravelTime(myEdge)) {
952  return -1;
953  } else {
954  double value(0);
955  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
956  return value;
957  }
958 }
959 
960 
961 double
964  if (!ews.knowsEffort(myEdge)) {
965  return -1;
966  } else {
967  double value(-1);
968  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
969  return value;
970  }
971 }
972 
973 
974 RGBColor
976  // setting and retrieving the color does not work in OSGView so we return it explicitliy
977  RGBColor col;
978  if (MSGlobals::gUseMesoSim && static_cast<const GUIEdge*>(myEdge)->getMesoColor() != MESO_USE_LANE_COLOR) {
979  col = static_cast<const GUIEdge*>(myEdge)->getMesoColor();
980  } else {
981  const GUIColorer& c = s.laneColorer;
982  if (!setFunctionalColor(c, col) && !setMultiColor(s, c, col)) {
983  col = c.getScheme().getColor(getColorValue(s, c.getActive()));
984  }
985  }
986  GLHelper::setColor(col);
987  return col;
988 }
989 
990 
991 bool
992 GUILane::setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme) const {
993  if (activeScheme < 0) {
994  activeScheme = c.getActive();
995  }
996  switch (activeScheme) {
997  case 0:
998  if (myEdge->isCrossing()) {
999  // determine priority to decide color
1000  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
1001  if (link->havePriority() || link->getTLLogic() != nullptr) {
1002  col = RGBColor(230, 230, 230);
1003  } else {
1004  col = RGBColor(26, 26, 26);
1005  }
1006  GLHelper::setColor(col);
1007  return true;
1008  } else {
1009  return false;
1010  }
1011  case 18: {
1012  double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
1013  col = RGBColor::fromHSV(hue, 1., 1.);
1014  GLHelper::setColor(col);
1015  return true;
1016  }
1017  case 30: { // taz color
1018  col = c.getScheme().getColor(0);
1019  std::vector<RGBColor> tazColors;
1020  for (MSEdge* e : myEdge->getPredecessors()) {
1021  if (e->isTazConnector() && e->knowsParameter("tazColor")) {
1022  tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
1023  }
1024  }
1025  for (MSEdge* e : myEdge->getSuccessors()) {
1026  if (e->isTazConnector() && e->knowsParameter("tazColor")) {
1027  tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
1028  }
1029  }
1030  if (tazColors.size() > 0) {
1031  int randColor = RandHelper::rand((int)tazColors.size(), RGBColor::getColorRNG());
1032  col = tazColors[randColor];
1033  }
1034  GLHelper::setColor(col);
1035  return true;
1036  }
1037  default:
1038  return false;
1039  }
1040 }
1041 
1042 
1043 bool
1045  const int activeScheme = c.getActive();
1046  myShapeColors.clear();
1047  switch (activeScheme) {
1048  case 22: // color by height at segment start
1049  for (PositionVector::const_iterator ii = myShape.begin(); ii != myShape.end() - 1; ++ii) {
1050  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
1051  }
1052  // osg fallback (edge height at start)
1053  col = c.getScheme().getColor(getColorValue(s, 21));
1054  return true;
1055  case 24: // color by inclination at segment start
1056  for (int ii = 1; ii < (int)myShape.size(); ++ii) {
1057  const double inc = (myShape[ii].z() - myShape[ii - 1].z()) / MAX2(POSITION_EPS, myShape[ii].distanceTo2D(myShape[ii - 1]));
1058  myShapeColors.push_back(c.getScheme().getColor(inc));
1059  }
1060  col = c.getScheme().getColor(getColorValue(s, 23));
1061  return true;
1062  default:
1063  return false;
1064  }
1065 }
1066 
1067 
1068 double
1069 GUILane::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
1070  switch (activeScheme) {
1071  case 0:
1072  switch (myPermissions) {
1073  case SVC_PEDESTRIAN:
1074  return 1;
1075  case SVC_BICYCLE:
1076  return 2;
1077  case 0:
1078  // forbidden road or green verge
1079  return myEdge->getPermissions() == 0 ? 10 : 3;
1080  case SVC_SHIP:
1081  return 4;
1082  case SVC_AUTHORITY:
1083  return 8;
1084  default:
1085  break;
1086  }
1087  if (myEdge->isTazConnector()) {
1088  return 9;
1089  } else if (isRailway(myPermissions)) {
1090  return 5;
1091  } else if ((myPermissions & SVC_PASSENGER) != 0) {
1092  if ((myPermissions & (SVC_RAIL_CLASSES & ~SVC_RAIL_FAST)) != 0 && (myPermissions & SVC_SHIP) == 0) {
1093  return 6;
1094  } else {
1095  return 0;
1096  }
1097  } else {
1098  return 7;
1099  }
1100  case 1:
1101  return isLaneOrEdgeSelected();
1102  case 2:
1103  return (double)myPermissions;
1104  case 3:
1105  return getSpeedLimit();
1106  case 4:
1107  return getBruttoOccupancy();
1108  case 5:
1109  return getNettoOccupancy();
1110  case 6:
1111  return firstWaitingTime();
1112  case 7:
1113  return getEdgeLaneNumber();
1114  case 8:
1115  return getCO2Emissions() / myLength;
1116  case 9:
1117  return getCOEmissions() / myLength;
1118  case 10:
1119  return getPMxEmissions() / myLength;
1120  case 11:
1121  return getNOxEmissions() / myLength;
1122  case 12:
1123  return getHCEmissions() / myLength;
1124  case 13:
1125  return getFuelConsumption() / myLength;
1126  case 14:
1128  case 15: {
1129  return getStoredEdgeTravelTime();
1130  }
1131  case 16: {
1133  if (!ews.knowsTravelTime(myEdge)) {
1134  return -1;
1135  } else {
1136  double value(0);
1137  ews.retrieveExistingTravelTime(myEdge, 0, value);
1138  return 100 * myLength / value / getSpeedLimit();
1139  }
1140  }
1141  case 17: {
1142  // geometrical length has no meaning for walkingAreas since it describes the outer boundary
1143  return myEdge->isWalkingArea() ? 1 : 1 / myLengthGeometryFactor;
1144  }
1145  case 19: {
1146  return getLoadedEdgeWeight();
1147  }
1148  case 20: {
1149  return myEdge->getPriority();
1150  }
1151  case 21: {
1152  // color by z of first shape point
1153  return getShape()[0].z();
1154  }
1155  case 23: {
1156  // color by incline
1157  return (getShape()[-1].z() - getShape()[0].z()) / getLength();
1158  }
1159  case 25: {
1160  // color by average speed
1161  return getMeanSpeed();
1162  }
1163  case 26: {
1164  // color by average relative speed
1165  return getMeanSpeed() / myMaxSpeed;
1166  }
1167  case 27: {
1168  // color by routing device assumed speed
1169  return myEdge->getRoutingSpeed();
1170  }
1171  case 28:
1173  case 29:
1174  return getPendingEmits();
1175  case 31: {
1176  // by numerical edge param value
1177  try {
1179  } catch (NumberFormatException&) {
1180  try {
1182  } catch (BoolFormatException&) {
1183  return -1;
1184  }
1185  }
1186  }
1187  case 32: {
1188  // by numerical lane param value
1189  try {
1191  } catch (NumberFormatException&) {
1192  try {
1193  return StringUtils::toBool(getParameter(s.laneParam, "0"));
1194  } catch (BoolFormatException&) {
1195  return -1;
1196  }
1197  }
1198  }
1199  case 33: {
1200  // by edge data value
1202  }
1203  case 34: {
1204  return myEdge->getDistance();
1205  }
1206  case 35: {
1207  return fabs(myEdge->getDistance());
1208  }
1209  case 36: {
1210  return myReachability;
1211  }
1212  case 37: {
1214  }
1215  }
1216  return 0;
1217 }
1218 
1219 
1220 double
1221 GUILane::getScaleValue(int activeScheme) const {
1222  switch (activeScheme) {
1223  case 0:
1224  return 0;
1225  case 1:
1226  return isLaneOrEdgeSelected();
1227  case 2:
1228  return getSpeedLimit();
1229  case 3:
1230  return getBruttoOccupancy();
1231  case 4:
1232  return getNettoOccupancy();
1233  case 5:
1234  return firstWaitingTime();
1235  case 6:
1236  return getEdgeLaneNumber();
1237  case 7:
1238  return getCO2Emissions() / myLength;
1239  case 8:
1240  return getCOEmissions() / myLength;
1241  case 9:
1242  return getPMxEmissions() / myLength;
1243  case 10:
1244  return getNOxEmissions() / myLength;
1245  case 11:
1246  return getHCEmissions() / myLength;
1247  case 12:
1248  return getFuelConsumption() / myLength;
1249  case 13:
1251  case 14: {
1252  return getStoredEdgeTravelTime();
1253  }
1254  case 15: {
1256  if (!ews.knowsTravelTime(myEdge)) {
1257  return -1;
1258  } else {
1259  double value(0);
1260  ews.retrieveExistingTravelTime(myEdge, 0, value);
1261  return 100 * myLength / value / getSpeedLimit();
1262  }
1263  }
1264  case 16: {
1265  return 1 / myLengthGeometryFactor;
1266  }
1267  case 17: {
1268  return getLoadedEdgeWeight();
1269  }
1270  case 18: {
1271  return myEdge->getPriority();
1272  }
1273  case 19: {
1274  // scale by average speed
1275  return getMeanSpeed();
1276  }
1277  case 20: {
1278  // scale by average relative speed
1279  return getMeanSpeed() / myMaxSpeed;
1280  }
1281  case 21:
1283  case 22:
1285  }
1286  return 0;
1287 }
1288 
1289 
1290 bool
1293 }
1294 
1295 
1296 bool
1298  return isWaterway(myPermissions) && s.showRails && !s.drawForRectangleSelection; // reusing the showRails setting
1299 }
1300 
1301 
1302 #ifdef HAVE_OSG
1303 void
1304 GUILane::updateColor(const GUIVisualizationSettings& s) {
1305  if (myGeom == 0) {
1306  // not drawn
1307  return;
1308  }
1309  const RGBColor col = setColor(s);
1310  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1311  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1312  myGeom->setColorArray(colors);
1313 }
1314 #endif
1315 
1316 
1317 void
1318 GUILane::closeTraffic(bool rebuildAllowed) {
1319  MSGlobals::gCheckRoutes = false;
1320  if (myAmClosed) {
1321  myPermissionChanges.clear(); // reset rerouters
1323  } else {
1325  }
1327  if (rebuildAllowed) {
1329  for (MSEdge* const pred : getEdge().getPredecessors()) {
1330  pred->rebuildAllowedTargets();
1331  }
1332  }
1333 }
1334 
1335 
1338  assert(MSGlobals::gUseMesoSim);
1339  int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1340  const double slength = myLength / no;
1341  PositionVector result = shape;
1342  double offset = 0;
1343  for (int i = 0; i < no; ++i) {
1344  offset += slength;
1345  Position pos = shape.positionAtOffset(offset);
1346  int index = result.indexOfClosest(pos);
1347  if (pos.distanceTo(result[index]) > POSITION_EPS) {
1348  index = result.insertAtClosest(pos, false);
1349  }
1350  while ((int)myShapeSegments.size() < index) {
1351  myShapeSegments.push_back(i);
1352  }
1353  //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1354  }
1355  while (myShapeSegments.size() < result.size()) {
1356  myShapeSegments.push_back(no - 1);
1357  }
1358  return result;
1359 }
1360 
1361 bool
1363  return gSelected.isSelected(GLO_LANE, getGlID());
1364 }
1365 
1366 bool
1368  return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1369 }
1370 
1371 double
1374 }
1375 
1376 
1377 /****************************************************************************/
@ MID_COPY_EDGE_NAME
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:405
@ MID_REACHABILITY
show reachability from a given lane
Definition: GUIAppEnum.h:471
@ MID_CLOSE_LANE
close lane
Definition: GUIAppEnum.h:584
@ MID_CLOSE_EDGE
close edge
Definition: GUIAppEnum.h:586
@ MID_ADD_REROUTER
add rerouter
Definition: GUIAppEnum.h:588
@ GLO_JUNCTION
a junction
@ GLO_LANE
a lane
@ GLO_EDGE
an edge
GUISelectedStorage gSelected
A global holder of selected objects.
#define RAD2DEG(x)
Definition: GeomHelper.h:36
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
long long int SUMOTime
Definition: SUMOTime.h:31
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
@ SVC_SHIP
is an arbitrary ship
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_RAIL_FAST
vehicle that is allowed to drive on high-speed rail tracks
@ SVC_AUTHORITY
authorities vehicles
@ SVC_PEDESTRIAN
pedestrian
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ TURN
The link is a 180 degree turn.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ TURN_LEFTHAND
The link is a 180 degree turn (left-hand network)
@ PARTRIGHT
The link is a partial right direction.
@ NODIR
The link has no direction (is a dead end link)
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_TL_REDYELLOW
The link has red light (must brake) but indicates upcoming green.
@ LINKSTATE_MAJOR
This is an uncontrolled, major link, may pass.
@ LINKSTATE_TL_YELLOW_MAJOR
The link has yellow light, may pass.
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_DEADEND
This is a dead end link.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
@ LINKSTATE_TL_YELLOW_MINOR
The link has yellow light, has to brake anyway.
@ LINKSTATE_TL_RED
The link has red light (must brake)
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
const double SUMO_const_laneWidth
Definition: StdDefs.h:47
T MIN2(T a, T b)
Definition: StdDefs.h:73
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:53
T MAX2(T a, T b)
Definition: StdDefs.h:79
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:49
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:81
static void debugVertices(const PositionVector &shape, double size, double layer=256)
draw vertex numbers for the given shape (in a random color)
Definition: GLHelper.cpp:638
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:100
static void drawCrossTies(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double length, double spacing, double halfWidth, bool drawForRectangleSelection)
draw crossties for railroads or pedestrian crossings
Definition: GLHelper.cpp:598
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:273
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
static void drawTextAtEnd(const std::string &text, const PositionVector &shape, double x, const GUIVisualizationTextSettings &settings, const double scale)
draw text and the end of shape
Definition: GLHelper.cpp:580
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:181
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:425
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:135
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:40
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:50
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:512
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIGlID getGlID() const
Returns the numerical id of the object.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1297
const PositionVector & getShape() const
Definition: GUILane.cpp:919
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:808
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1362
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:332
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:166
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:358
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1367
void drawArrows() const
Definition: GUILane.cpp:397
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:931
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1221
void integrateNewVehicles()
Definition: GUILane.cpp:187
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:341
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:173
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1337
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:338
double firstWaitingTime() const
Definition: GUILane.cpp:937
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:344
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:243
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:975
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1372
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:464
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:216
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:361
bool setMultiColor(const GUIVisualizationSettings &s, const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function
Definition: GUILane.cpp:1044
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:180
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:282
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:335
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:907
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:140
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1318
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GUILane.cpp:780
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:133
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1291
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:208
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:925
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:194
double getEdgeLaneNumber() const
Definition: GUILane.cpp:943
double myReachability
the time distance from a particular edge
Definition: GUILane.h:347
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:962
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:491
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:329
void executeMovements(const SUMOTime t)
Definition: GUILane.cpp:159
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: GUILane.cpp:123
~GUILane()
Destructor.
Definition: GUILane.cpp:113
void setJunctionApproaches(const SUMOTime t) const
Definition: GUILane.cpp:152
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:332
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:992
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:949
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:713
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:201
GUILane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: GUILane.cpp:80
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:754
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:354
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:146
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:833
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:875
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1069
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:81
int getLinkTLID(const MSLink *const link) const
Definition: GUINet.cpp:194
int getLinkTLIndex(const MSLink *const link) const
Definition: GUINet.cpp:209
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:526
double getEdgeData(const MSEdge *edge, const std::string &attr)
retrieve loaded edged weight for the given attribute and the current simulation time
Definition: GUINet.cpp:559
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
const T getColor(const double value) const
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:51
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings vehicleSize
GUIVisualizationSizeSettings junctionSize
bool showBikeMarkings
Information whether bicycle lane marking shall be drawn.
GUIScaler laneScaler
The lane scaler.
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
bool showLinkRules
Information whether link rules (colored bars) shall be drawn.
bool drawJunctionShape
whether the shape of the junction should be drawn
std::string edgeData
key for coloring by edgeData
GUIVisualizationTextSettings drawLinkJunctionIndex
bool showRails
Information whether rails shall be drawn.
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
bool showLane2Lane
Information whether lane-to-lane arrows shall be drawn.
bool showSublanes
Whether to show sublane boundaries.
static const RGBColor & getLinkColor(const LinkState &ls)
map from LinkState to color constants
double scale
information about a lane's width (temporary, used for a single view)
bool showLaneDirection
Whether to show direction indicators for lanes.
GUIScaler edgeScaler
The mesoscopic edge scaler.
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
GUIColorer laneColorer
The lane colorer.
bool laneShowBorders
Information whether lane borders shall be drawn.
double laneMinSize
The minimum visual lane width for drawing.
GUIVisualizationTextSettings drawLinkTLIndex
bool drawCrossingsAndWalkingareas
whether crosings and walkingareas shall be drawn
bool spreadSuperposed
Whether to improve visualisation of superposed (rail) edges.
std::string edgeParam
key for coloring by edge parameter
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:192
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length)
Definition: MELoop.cpp:255
A road/street connecting two junctions.
Definition: MSEdge.h:77
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:261
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:313
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition: MSEdge.h:594
const MSEdgeVector & getPredecessors() const
Definition: MSEdge.h:383
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:301
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:275
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:166
void rebuildAllowedLanes()
Definition: MSEdge.cpp:250
bool isTazConnector() const
Definition: MSEdge.h:279
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:256
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:294
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:307
const MSJunction * getToJunction() const
Definition: MSEdge.h:392
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:808
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition: MSEdge.h:270
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1013
double getDistance() const
Returns the kilometrage/mileage at the start of the edge.
Definition: MSEdge.h:319
A storage for edge travel times and efforts.
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
static bool gUseMesoSim
Definition: MSGlobals.h:88
static bool gCheckRoutes
Definition: MSGlobals.h:76
static double gLateralResolution
Definition: MSGlobals.h:82
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:115
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:136
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
const PositionVector & getShape() const
Returns this junction's shape.
Definition: MSJunction.h:88
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:130
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1375
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition: MSLane.cpp:1258
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2801
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:640
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2813
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1982
double myLength
Lane length [m].
Definition: MSLane.h:1358
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition: MSLane.cpp:2708
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2193
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1306
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1445
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: MSLane.cpp:341
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3065
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1369
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1372
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2777
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2128
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
Definition: MSLane.cpp:1218
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1322
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:531
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:92
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1355
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3740
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1431
int myRNGIndex
Definition: MSLane.h:1448
double getLength() const
Returns the lane's length.
Definition: MSLane.h:539
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2182
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:272
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:562
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:3728
const double myWidth
Lane width [m].
Definition: MSLane.h:1361
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1425
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1760
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2542
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2693
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2837
int myIndex
The lane index.
Definition: MSLane.h:1309
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1316
std::vector< MSLink * > myLinks
Definition: MSLane.h:1409
bool isInternal() const
Definition: MSLane.cpp:2036
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1240
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2849
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
std::map< SVCPermissions, double > myStopOffsets
Definition: MSLane.h:1366
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:476
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:509
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:290
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2861
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2789
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:555
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2736
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:503
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2825
Notification
Definition of a vehicle state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition: MSNet.cpp:1009
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:424
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
const std::string & getID() const
Returns the id.
Definition: Named.h:73
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:241
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:231
double x() const
Returns the x-position.
Definition: Position.h:54
double z() const
Returns the z-position.
Definition: Position.h:64
double y() const
Returns the y-position.
Definition: Position.h:59
A list of positions.
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0, double deg=90) const
return orthogonal through p (extending this vector if necessary)
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
int insertAtClosest(const Position &p, bool interpolateZ)
inserts p between the two closest positions
int indexOfClosest(const Position &p) const
index of the closest position to p
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
PositionVector reverse() const
reverse position vector
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:52
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:73
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:168
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:59
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition: RGBColor.cpp:300
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:66
static std::mt19937 * getColorRNG()
Definition: RGBColor.h:103
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:51
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
static const RGBColor SUMO_color_DEADEND_SHOW
color for highlighthing deadends
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double exaggeration
The size exaggeration (upscale)
bool constantSize
whether the object shall be drawn with constant size regardless of zoom
double minSize
The minimum size to draw this object.