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-2022 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>
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>
42 #include <microsim/MSLink.h>
46 #include <microsim/MSNet.h>
48 #include <microsim/MSParkingArea.h>
50 #include <mesosim/MELoop.h>
51 #include <mesosim/MESegment.h>
52 #include "GUILane.h"
53 #include "GUIEdge.h"
54 #include "GUIVehicle.h"
55 #include "GUINet.h"
57 
58 #include <osgview/GUIOSGHeader.h>
59 
60 //#define GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
61 //#define GUILane_DEBUG_DRAW_VERTICES
62 //#define GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
63 
64 // ===========================================================================
65 // static member declaration
66 // ===========================================================================
67 const RGBColor GUILane::MESO_USE_LANE_COLOR(0, 0, 0, 0);
69 
70 
71 // ===========================================================================
72 // method definitions
73 // ===========================================================================
74 GUILane::GUILane(const std::string& id, double maxSpeed, double length,
75  MSEdge* const edge, int numericalID,
76  const PositionVector& shape, double width,
77  SVCPermissions permissions,
78  SVCPermissions changeLeft, SVCPermissions changeRight,
79  int index, bool isRampAccel,
80  const std::string& type) :
81  MSLane(id, maxSpeed, length, edge, numericalID, shape, width, permissions, changeLeft, changeRight, index, isRampAccel, type),
82  GUIGlObject(GLO_LANE, id),
83  myParkingAreas(nullptr),
84 #ifdef HAVE_OSG
85  myGeom(0),
86 #endif
87  myAmClosed(false),
88  myLock(true) {
90  myShape = splitAtSegments(shape);
91  assert(fabs(myShape.length() - shape.length()) < POSITION_EPS);
92  assert(myShapeSegments.size() == myShape.size());
93  }
94  myShapeRotations.reserve(myShape.size() - 1);
95  myShapeLengths.reserve(myShape.size() - 1);
96  myShapeColors.reserve(myShape.size() - 1);
97  int e = (int) myShape.size() - 1;
98  for (int i = 0; i < e; ++i) {
99  const Position& f = myShape[i];
100  const Position& s = myShape[i + 1];
101  myShapeLengths.push_back(f.distanceTo2D(s));
102  myShapeRotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
103  }
104  //
105  myHalfLaneWidth = myWidth / 2.;
107 }
108 
109 
111  // just to quit cleanly on a failure
112  if (myLock.locked()) {
113  myLock.unlock();
114  }
115  delete myParkingAreas;
116 }
117 
118 
119 // ------ Vehicle insertion ------
120 void
121 GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
122  const MSLane::VehCont::iterator& at,
123  MSMoveReminder::Notification notification) {
124  FXMutexLock locker(myLock);
125  MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
126 }
127 
128 
129 // ------ Access to vehicles ------
130 const MSLane::VehCont&
132  myLock.lock();
133  return myVehicles;
134 }
135 
136 
137 void
139  myLock.unlock();
140 }
141 
142 
143 void
145  FXMutexLock locker(myLock);
147 }
148 
149 void
151  FXMutexLock locker(myLock);
153 }
154 
155 
156 void
158  FXMutexLock locker(myLock);
160 }
161 
162 
163 MSVehicle*
164 GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
165  FXMutexLock locker(myLock);
166  return MSLane::removeVehicle(remVehicle, notification, notify);
167 }
168 
169 
170 void
172  FXMutexLock locker(myLock);
173  return MSLane::removeParking(remVehicle);
174 }
175 
176 
177 void
179  FXMutexLock locker(myLock);
181 }
182 
183 
184 void
186  FXMutexLock locker(myLock);
188 }
189 
190 
191 void
192 GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
193  FXMutexLock locker(myLock);
194  MSLane::detectCollisions(timestep, stage);
195 }
196 
197 
198 double
200  FXMutexLock locker(myLock);
202 }
203 
204 
205 void
207  FXMutexLock locker(myLock);
209 }
210 
211 
212 // ------ Drawing methods ------
213 void
215  int noLinks = (int)myLinks.size();
216  if (noLinks == 0) {
217  return;
218  }
219  // draw all links
220  if (getEdge().isCrossing()) {
221  // draw indices at the start and end of the crossing
222  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
223  PositionVector shape = getShape();
224  shape.extrapolate(0.5); // draw on top of the walking area
227  return;
228  }
229  // draw all links
230  double w = myWidth / (double) noLinks;
231  double x1 = myHalfLaneWidth;
232  for (int i = noLinks; --i >= 0;) {
233  double x2 = x1 - (double)(w / 2.);
235  x1 -= w;
236  }
237 }
238 
239 
240 void
242  int noLinks = (int)myLinks.size();
243  if (noLinks == 0) {
244  return;
245  }
246  if (getEdge().isCrossing()) {
247  // draw indices at the start and end of the crossing
248  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
249  int linkNo = net.getLinkTLIndex(link);
250  // maybe the reverse link is controlled separately
251  int linkNo2 = net.getLinkTLIndex(myLinks.front());
252  // otherwise, use the same index as the forward link
253  if (linkNo2 < 0) {
254  linkNo2 = linkNo;
255  }
256  if (linkNo >= 0) {
257  PositionVector shape = getShape();
258  shape.extrapolate(0.5); // draw on top of the walking area
259  GLHelper::drawTextAtEnd(toString(linkNo2), shape, 0, s.drawLinkTLIndex, s.scale);
260  GLHelper::drawTextAtEnd(toString(linkNo), shape.reverse(), 0, s.drawLinkTLIndex, s.scale);
261  }
262  return;
263  }
264  // draw all links
265  double w = myWidth / (double) noLinks;
266  double x1 = myHalfLaneWidth;
267  for (int i = noLinks; --i >= 0;) {
268  double x2 = x1 - (double)(w / 2.);
269  int linkNo = net.getLinkTLIndex(myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i]);
270  if (linkNo < 0) {
271  continue;
272  }
274  x1 -= w;
275  }
276 }
277 
278 
279 void
281  int noLinks = (int)myLinks.size();
282  if (noLinks == 0) {
283  drawLinkRule(s, net, nullptr, getShape(), 0, 0);
284  return;
285  }
286  if (getEdge().isCrossing()) {
287  // draw rules at the start and end of the crossing
288  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
289  const MSLink* link2 = myLinks.front();
290  if (link2->getTLLogic() == nullptr) {
291  link2 = link;
292  }
293  PositionVector shape = getShape();
294  shape.extrapolate(0.5); // draw on top of the walking area
295  drawLinkRule(s, net, link2, shape, 0, myWidth);
296  drawLinkRule(s, net, link, shape.reverse(), 0, myWidth);
297  return;
298  }
299  // draw all links
300  const double w = myWidth / (double) noLinks;
301  double x1 = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL ? -myWidth * 0.5 : 0;
302  for (int i = 0; i < noLinks; ++i) {
303  double x2 = x1 + w;
304  drawLinkRule(s, net, myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i], getShape(), x1, x2);
305  x1 = x2;
306  }
307  // draw stopOffset for passenger cars
309  const double stopOffsetPassenger = myLaneStopOffset.getOffset();
310  const Position& end = myShape.back();
311  const Position& f = myShape[-2];
312  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
315  glTranslated(end.x(), end.y(), 0);
316  glRotated(rot, 0, 0, 1);
317  glTranslated(0, stopOffsetPassenger, 0);
318  glBegin(GL_QUADS);
319  glVertex2d(-myHalfLaneWidth, 0.0);
320  glVertex2d(-myHalfLaneWidth, 0.2);
321  glVertex2d(myHalfLaneWidth, 0.2);
322  glVertex2d(myHalfLaneWidth, 0.0);
323  glEnd();
325  }
326 }
327 
328 
329 void
330 GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link, const PositionVector& shape, double x1, double x2) const {
331  const Position& end = shape.back();
332  const Position& f = shape[-2];
333  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
334  if (link == nullptr) {
335  if (static_cast<GUIEdge*>(myEdge)->showDeadEnd()) {
337  } else {
339  }
341  glTranslated(end.x(), end.y(), 0);
342  glRotated(rot, 0, 0, 1);
343  glBegin(GL_QUADS);
344  glVertex2d(-myHalfLaneWidth, 0.0);
345  glVertex2d(-myHalfLaneWidth, 0.5);
346  glVertex2d(myHalfLaneWidth, 0.5);
347  glVertex2d(myHalfLaneWidth, 0.0);
348  glEnd();
350  } else {
352  glTranslated(end.x(), end.y(), 0);
353  glRotated(rot, 0, 0, 1);
354  // select glID
355  switch (link->getState()) {
358  case LINKSTATE_TL_RED:
364  GLHelper::pushName(net.getLinkTLID(link));
365  break;
366  case LINKSTATE_MAJOR:
367  case LINKSTATE_MINOR:
368  case LINKSTATE_EQUAL:
369  default:
371  break;
372  }
374  if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
375  // the white bar should be the default for most railway
376  // links and looks ugly so we do not draw it
377  double scale = isInternal() ? 0.5 : 1;
379  scale *= MAX2(s.laneWidthExaggeration, s.junctionSize.getExaggeration(s, this, 10));
380  }
381  glScaled(scale, scale, 1);
382  glBegin(GL_QUADS);
383  glVertex2d(x1 - myHalfLaneWidth, 0.0);
384  glVertex2d(x1 - myHalfLaneWidth, 0.5);
385  glVertex2d(x2 - myHalfLaneWidth, 0.5);
386  glVertex2d(x2 - myHalfLaneWidth, 0.0);
387  glEnd();
388  }
391  }
392 }
393 
394 void
396  if (myLinks.size() == 0) {
397  return;
398  }
399  // draw all links
400  const Position& end = getShape().back();
401  const Position& f = getShape()[-2];
402  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
404  glColor3d(1, 1, 1);
405  glTranslated(end.x(), end.y(), 0);
406  glRotated(rot, 0, 0, 1);
408  glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
409  }
410  for (const MSLink* const link : myLinks) {
411  LinkDirection dir = link->getDirection();
412  LinkState state = link->getState();
413  if (state == LINKSTATE_DEADEND || dir == LinkDirection::NODIR) {
414  continue;
415  }
416  switch (dir) {
418  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
419  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
420  break;
421  case LinkDirection::TURN:
422  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
423  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
424  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
425  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
426  break;
428  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
429  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
430  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
431  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
432  break;
433  case LinkDirection::LEFT:
434  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
435  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
436  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
437  break;
439  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
440  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
441  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
442  break;
444  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
445  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
446  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
447  break;
449  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
450  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
451  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
452  break;
453  default:
454  break;
455  }
456  }
458 }
459 
460 
461 void
462 GUILane::drawLane2LaneConnections(double exaggeration) const {
463  Position centroid;
464  if (exaggeration > 1) {
465  centroid = myEdge->getToJunction()->getShape().getCentroid();
466  }
467  for (const MSLink* const link : myLinks) {
468  const MSLane* connected = link->getLane();
469  if (connected == nullptr) {
470  continue;
471  }
473  glBegin(GL_LINES);
475  Position p2 = connected->getEdge().isWalkingArea() ? connected->getShape().getCentroid() : connected->getShape()[0];
476  if (exaggeration > 1) {
477  p1 = centroid + ((p1 - centroid) * exaggeration);
478  p2 = centroid + ((p2 - centroid) * exaggeration);
479  }
480  glVertex2d(p1.x(), p1.y());
481  glVertex2d(p2.x(), p2.y());
482  glEnd();
483  GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
484  }
485 }
486 
487 
488 void
492  const bool isCrossing = myEdge->isCrossing();
493  const bool isWalkingArea = myEdge->isWalkingArea();
494  const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
495  bool mustDrawMarkings = false;
496  double exaggeration = s.laneWidthExaggeration;
498  GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
499  exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s.edgeScaler.getActive()));
500  } else {
502  }
503  const bool hasRailSignal = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL;
504  const bool detailZoom = s.scale * exaggeration > 5;
505  const bool drawDetails = (detailZoom || s.junctionSize.minSize == 0 || hasRailSignal) && !s.drawForPositionSelection;
506  const bool drawRails = drawAsRailway(s);
507  if (isCrossing || isWalkingArea) {
508  // draw internal lanes on top of junctions
509  glTranslated(0, 0, GLO_JUNCTION + 0.1);
510  } else if (isWaterway(myPermissions)) {
511  // draw waterways below normal roads
512  glTranslated(0, 0, getType() - 0.2);
513  } else {
514  glTranslated(0, 0, getType());
515  }
516  // set lane color
517  const RGBColor color = setColor(s);
519  myShapeColors.clear();
520  const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
521  if (segmentColors.size() > 0) {
522  // apply segment specific shape colors
523  //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
524  for (int ii = 0; ii < (int)myShape.size() - 1; ++ii) {
525  myShapeColors.push_back(segmentColors[myShapeSegments[ii]]);
526  }
527  }
528  }
529  // recognize full transparency and simply don't draw
530  bool hiddenBidi = myEdge->getBidiEdge() != nullptr && myEdge->getNumericalID() > myEdge->getBidiEdge()->getNumericalID();
531  if (color.alpha() != 0 && s.scale * exaggeration > s.laneMinSize) {
532  // scale tls-controlled lane2lane-arrows along with their junction shapes
533  double junctionExaggeration = 1;
534  if (!isInternal
537  junctionExaggeration = MAX2(1.001, s.junctionSize.getExaggeration(s, this, 4));
538  }
539  // draw lane
540  // check whether it is not too small
541  if (s.scale * exaggeration < 1. && junctionExaggeration == 1 && s.junctionSize.minSize != 0) {
542  if (!isInternal || hasRailSignal) {
543  if (myShapeColors.size() > 0) {
545  } else {
547  }
548  }
550  } else {
551  GUINet* net = (GUINet*) MSNet::getInstance();
552  const bool spreadSuperposed = s.spreadSuperposed && myEdge->getBidiEdge() != nullptr && drawRails;
553  if (hiddenBidi && !spreadSuperposed) {
554  // do not draw shape
555  } else if (drawRails) {
556  // draw as railway: assume standard gauge of 1435mm when lane width is not set
557  // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
558  // assume crosstie length of 181% gauge (2600mm for standard gauge)
559  PositionVector shape = myShape;
560  const double width = myWidth;
561  double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * exaggeration;
562  if (spreadSuperposed) {
563  try {
564  shape.move2side(halfGauge * 0.8);
565  } catch (InvalidArgument&) {}
566  halfGauge *= 0.4;
567  }
568  const double halfInnerFeetWidth = halfGauge - 0.039 * exaggeration;
569  const double halfRailWidth = detailZoom ? (halfInnerFeetWidth + 0.15 * exaggeration) : SUMO_const_halfLaneWidth;
570  const double halfCrossTieWidth = halfGauge * 1.81;
571  if (myShapeColors.size() > 0) {
573  } else {
575  }
576  // Draw white on top with reduced width (the area between the two tracks)
577  if (detailZoom) {
578  glColor3d(1, 1, 1);
579  glTranslated(0, 0, .1);
580  GLHelper::drawBoxLines(shape, myShapeRotations, myShapeLengths, halfInnerFeetWidth);
581  setColor(s);
582  GLHelper::drawCrossTies(shape, myShapeRotations, myShapeLengths, 0.26 * exaggeration, 0.6 * exaggeration, halfCrossTieWidth, s.drawForPositionSelection);
583  }
584  } else if (isCrossing) {
585  if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
586  glTranslated(0, 0, .2);
588  glTranslated(0, 0, -.2);
589  }
590  } else if (isWalkingArea) {
591  if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
592  glTranslated(0, 0, .2);
593  if (s.scale * exaggeration < 20.) {
595  } else {
597  }
598  glTranslated(0, 0, -.2);
599 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
601 #endif
602  }
603  } else {
604  // we draw the lanes with reduced width so that the lane markings below are visible
605  // (this avoids artifacts at geometry corners without having to
606  // compute lane-marking intersection points)
607  const double halfWidth = isInternal ? myQuarterLaneWidth : (myHalfLaneWidth - SUMO_const_laneMarkWidth / 2);
608  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
609  const int cornerDetail = drawDetails && !isInternal ? (int)(s.scale * exaggeration) : 0;
610  const double offset = halfWidth * MAX2(0., (exaggeration - 1)) * (MSGlobals::gLefthand ? -1 : 1);
611  if (myShapeColors.size() > 0) {
612  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myShapeColors, halfWidth * exaggeration, cornerDetail, offset);
613  } else {
614  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfWidth * exaggeration, cornerDetail, offset);
615  }
616  }
617 #ifdef GUILane_DEBUG_DRAW_VERTICES
619 #endif
620 #ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
623  }
624 #endif
626  // draw details
627  if ((!isInternal || isCrossing || !s.drawJunctionShape) && (drawDetails || s.drawForPositionSelection || junctionExaggeration > 1)) {
629  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
630  glTranslated(0, 0, .5);
631  if (drawDetails) {
632  if (s.showLaneDirection) {
633  if (drawRails) {
634  // improve visibility of superposed rail edges
635  GLHelper::setColor(setColor(s).changedBrightness(100));
636  } else {
637  glColor3d(0.3, 0.3, 0.3);
638  }
639  if (!isCrossing || s.drawCrossingsAndWalkingareas) {
640  drawDirectionIndicators(exaggeration, spreadSuperposed);
641  }
642  }
643  if (!isInternal || isCrossing
644  // controlled internal junction
645  || (getLinkCont().size() != 0 && getLinkCont()[0]->isInternalJunctionLink() && getLinkCont()[0]->getTLLogic() != nullptr)) {
646  if (MSGlobals::gLateralResolution > 0 && s.showSublanes && !hiddenBidi && (myPermissions & ~(SVC_PEDESTRIAN | SVC_RAIL_CLASSES)) != 0) {
647  // draw sublane-borders
648  const double offsetSign = MSGlobals::gLefthand ? -1 : 1;
650  for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
651  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, 0.01, 0, -offset * offsetSign);
652  }
653  }
655  // draw segment borders
657  for (int i : mySegmentStartIndex) {
658  if (myShapeColors.size() > 0) {
659  GLHelper::setColor(myShapeColors[i].changedBrightness(51));
660  }
661  GLHelper::drawBoxLine(myShape[i], myShapeRotations[i] + 90, myWidth / 3, 0.2, 0);
662  GLHelper::drawBoxLine(myShape[i], myShapeRotations[i] - 90, myWidth / 3, 0.2, 0);
663  }
664  }
665  if (s.showLinkDecals && !drawRails && !drawAsWaterway(s) && myPermissions != SVC_PEDESTRIAN) {
666  drawArrows();
667  }
668  glTranslated(0, 0, 1000);
669  if (s.drawLinkJunctionIndex.show(nullptr)) {
670  drawLinkNo(s);
671  }
672  if (s.drawLinkTLIndex.show(nullptr)) {
673  drawTLSLinkNo(s, *net);
674  }
675  glTranslated(0, 0, -1000);
676  }
677  glTranslated(0, 0, .1);
678  }
679  // make sure link rules are drawn so tls can be selected via right-click
680  if (s.showLinkRules && (drawDetails || s.drawForPositionSelection)
681  && !isWalkingArea
682  && (!myEdge->isInternal() || (getLinkCont().size() > 0 && getLinkCont()[0]->isInternalJunctionLink()))) {
683  drawLinkRules(s, *net);
684  }
685  if ((drawDetails || junctionExaggeration > 1) && s.showLane2Lane) {
686  // draw from end of first to the begin of second but respect junction scaling
687  drawLane2LaneConnections(junctionExaggeration);
688  }
690  }
691  }
692  if (mustDrawMarkings && drawDetails && s.laneShowBorders && !hiddenBidi) { // needs matrix reset
693  drawMarkings(s, exaggeration);
694  }
695  if (drawDetails && isInternal && s.showBikeMarkings && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi) {
697  }
698  if (drawDetails && isInternal && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi && myIndex > 0
699  && !(myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER) && allowsChangingRight(SVC_PASSENGER))) {
700  // draw lane changing prohibitions on junction
702  }
703  } else {
705  }
706  // draw vehicles
707  if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
708  // retrieve vehicles from lane; disallow simulation
709  const MSLane::VehCont& vehicles = getVehiclesSecure();
710  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
711  if ((*v)->getLane() == this) {
712  static_cast<const GUIVehicle*>(*v)->drawGL(s);
713  } // else: this is the shadow during a continuous lane change
714  }
715  // draw parking vehicles
716  for (const MSBaseVehicle* const v : myParkingVehicles) {
717  dynamic_cast<const GUIBaseVehicle*>(v)->drawGL(s);
718  }
719  // allow lane simulation
720  releaseVehicles();
721  }
723 }
724 
725 
726 void
727 GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale) const {
729  glTranslated(0, 0, GLO_EDGE);
730  setColor(s);
731  // optionally draw inverse markings
732  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
733  const bool cl = myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER);
734  const bool cr = allowsChangingRight(SVC_PASSENGER);
736  }
737  // draw white boundings and white markings
738  glColor3d(1, 1, 1);
740  getShape(),
742  getShapeLengths(),
745 }
746 
747 
748 void
750  // draw bike lane markings onto the intersection
751  glColor3d(1, 1, 1);
752  const int e = (int) getShape().size() - 1;
753  const double markWidth = 0.1;
754  const double mw = myHalfLaneWidth;
755  for (int i = 0; i < e; ++i) {
757  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.4);
758  glRotated(myShapeRotations[i], 0, 0, 1);
759  for (double t = 0; t < myShapeLengths[i]; t += 0.5) {
760  // left and right marking
761  for (int side = -1; side <= 1; side += 2) {
762  glBegin(GL_QUADS);
763  glVertex2d(side * mw, -t);
764  glVertex2d(side * mw, -t - 0.35);
765  glVertex2d(side * (mw + markWidth), -t - 0.35);
766  glVertex2d(side * (mw + markWidth), -t);
767  glEnd();
768  }
769  }
771  }
772 }
773 
774 
775 void
777  // draw white markings
778  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
779  glColor3d(1, 1, 1);
780  const bool cl = myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER);
781  const bool cr = allowsChangingRight(SVC_PASSENGER);
782  // solid line marking
783  double mw, mw2;
784  // optional broken line marking
785  double mw3, mw4;
786  if (!cl && !cr) {
787  // draw a single solid line
790  mw3 = myHalfLaneWidth;
791  mw4 = myHalfLaneWidth;
792  } else {
793  // draw one solid and one broken line
794  if (cl) {
799  } else {
804  }
805  }
806  if (MSGlobals::gLefthand) {
807  mw *= -1;
808  mw2 *= -1;
809  }
810  int e = (int) getShape().size() - 1;
811  for (int i = 0; i < e; ++i) {
813  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.4);
814  glRotated(myShapeRotations[i], 0, 0, 1);
815  for (double t = 0; t < myShapeLengths[i]; t += 6) {
816  const double lengthSolid = MIN2(6.0, myShapeLengths[i] - t);
817  glBegin(GL_QUADS);
818  glVertex2d(-mw, -t);
819  glVertex2d(-mw, -t - lengthSolid);
820  glVertex2d(-mw2, -t - lengthSolid);
821  glVertex2d(-mw2, -t);
822  glEnd();
823  if (cl || cr) {
824  const double lengthBroken = MIN2(3.0, myShapeLengths[i] - t);
825  glBegin(GL_QUADS);
826  glVertex2d(-mw3, -t);
827  glVertex2d(-mw3, -t - lengthBroken);
828  glVertex2d(-mw4, -t - lengthBroken);
829  glVertex2d(-mw4, -t);
830  glEnd();
831  }
832  }
834  }
835  }
836 }
837 
838 void
839 GUILane::drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const {
841  glTranslated(0, 0, GLO_EDGE);
842  int e = (int) getShape().size() - 1;
843  const double widthFactor = spreadSuperposed ? 0.4 : 1;
844  const double w = MAX2(POSITION_EPS, myWidth * widthFactor);
845  const double w2 = MAX2(POSITION_EPS, myHalfLaneWidth * widthFactor);
846  const double w4 = MAX2(POSITION_EPS, myQuarterLaneWidth * widthFactor);
847  const double sideOffset = spreadSuperposed ? w * -0.5 : 0;
848  for (int i = 0; i < e; ++i) {
850  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
851  glRotated(myShapeRotations[i], 0, 0, 1);
852  for (double t = 0; t < myShapeLengths[i]; t += w) {
853  const double length = MIN2(w2, myShapeLengths[i] - t) * exaggeration;
854  glBegin(GL_TRIANGLES);
855  glVertex2d(sideOffset, -t - length);
856  glVertex2d(sideOffset - w4 * exaggeration, -t);
857  glVertex2d(sideOffset + w4 * exaggeration, -t);
858  glEnd();
859  }
861  }
863 }
864 
865 
866 void
869  glColor3d(1.0, 0.3, 0.3);
870  const double orthoLength = 0.5;
871  const MSLink* link = getLinkCont().front();
872  const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
873  const std::vector<std::pair<double, double> >& lengthsBehind = link->getLengthsBehindCrossing();
874  if (foeLanes.size() == lengthsBehind.size()) {
875  for (int i = 0; i < (int)foeLanes.size(); ++i) {
876  const MSLane* l = foeLanes[i];
877  Position pos = l->geometryPositionAtOffset(l->getLength() - lengthsBehind[i].second);
878  PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
879  if (ortho.length() < orthoLength) {
880  ortho.extrapolate(orthoLength - ortho.length(), false, true);
881  }
882  GLHelper::drawLine(ortho);
883  //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - lengthsBehind[i].second << " pos=" << pos << "\n";
884  }
885  }
887 }
888 
889 
890 // ------ inherited from GUIGlObject
893  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
894  buildPopupHeader(ret, app);
896  //
897  GUIDesigns::buildFXMenuCommand(ret, "Copy edge name to clipboard", nullptr, ret, MID_COPY_EDGE_NAME);
900  //
901  buildShowParamsPopupEntry(ret, false);
903  const double height = myShape.positionAtOffset(pos).z();
904  GUIDesigns::buildFXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), nullptr, nullptr, 0);
905  new FXMenuSeparator(ret);
906  buildPositionCopyEntry(ret, false);
907  new FXMenuSeparator(ret);
908  if (myAmClosed) {
909  if (myPermissionChanges.empty()) {
910  GUIDesigns::buildFXMenuCommand(ret, "Reopen lane", nullptr, &parent, MID_CLOSE_LANE);
911  GUIDesigns::buildFXMenuCommand(ret, "Reopen edge", nullptr, &parent, MID_CLOSE_EDGE);
912  } else {
913  GUIDesigns::buildFXMenuCommand(ret, "Reopen lane (override rerouter)", nullptr, &parent, MID_CLOSE_LANE);
914  GUIDesigns::buildFXMenuCommand(ret, "Reopen edge (override rerouter)", nullptr, &parent, MID_CLOSE_EDGE);
915  }
916  } else {
917  GUIDesigns::buildFXMenuCommand(ret, "Close lane", nullptr, &parent, MID_CLOSE_LANE);
918  GUIDesigns::buildFXMenuCommand(ret, "Close edge", nullptr, &parent, MID_CLOSE_EDGE);
919  }
920  GUIDesigns::buildFXMenuCommand(ret, "Add rerouter", nullptr, &parent, MID_ADD_REROUTER);
921  new FXMenuSeparator(ret);
922  // reachability menu
923  FXMenuPane* reachableByClass = new FXMenuPane(ret);
924  ret->insertMenuPaneChild(reachableByClass);
925  new FXMenuCascade(ret, "Select reachable", GUIIconSubSys::getIcon(GUIIcon::FLAG), reachableByClass);
926  for (auto i : SumoVehicleClassStrings.getStrings()) {
927  GUIDesigns::buildFXMenuCommand(reachableByClass, i.c_str(), nullptr, &parent, MID_REACHABILITY);
928  }
929  return ret;
930 }
931 
932 
936  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
937  // add items
938  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
939  ret->mkItem("length [m]", false, myLength);
940  ret->mkItem("width [m]", false, myWidth);
941  ret->mkItem("street name", false, myEdge->getStreetName());
942  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
943  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
944  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
945  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
946  ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
947  ret->mkItem("pending insertions [#]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getPendingEmits));
948  ret->mkItem("edge type", false, myEdge->getEdgeType());
949  ret->mkItem("type", false, myLaneType);
950  ret->mkItem("priority", false, myEdge->getPriority());
951  ret->mkItem("distance [km]", false, myEdge->getDistance() / 1000);
952  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
953  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
954  ret->mkItem("permission code", false, myPermissions);
955  ret->mkItem("color value", true, new FunctionBinding<GUILane, double>(this, &GUILane::getColorValueForTracker));
956  if (myEdge->getBidiEdge() != nullptr) {
957  ret->mkItem("bidi-edge", false, myEdge->getBidiEdge()->getID());
958  }
959  for (const auto& kv : myEdge->getParametersMap()) {
960  ret->mkItem(("edgeParam:" + kv.first).c_str(), false, kv.second);
961  }
962  ret->checkFont(myEdge->getStreetName());
963  ret->closeBuilding();
964  return ret;
965 }
966 
967 
968 double
970  return 1;
971 }
972 
973 
974 Boundary
976  Boundary b;
977  b.add(myShape[0]);
978  b.add(myShape[-1]);
979  b.grow(10);
980  // ensure that vehicles and persons on the side are drawn even if the edge
981  // is outside the view
982  return b;
983 }
984 
985 
986 const PositionVector&
988  return myShape;
989 }
990 
991 
992 const std::vector<double>&
994  return myShapeRotations;
995 }
996 
997 
998 const std::vector<double>&
1000  return myShapeLengths;
1001 }
1002 
1003 
1004 double
1006  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
1007 }
1008 
1009 
1010 double
1012  return (double) myEdge->getLanes().size();
1013 }
1014 
1015 
1016 double
1019  if (!ews.knowsTravelTime(myEdge)) {
1020  return -1;
1021  } else {
1022  double value(0);
1023  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
1024  return value;
1025  }
1026 }
1027 
1028 
1029 double
1032  if (!ews.knowsEffort(myEdge)) {
1033  return -1;
1034  } else {
1035  double value(-1);
1036  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
1037  return value;
1038  }
1039 }
1040 
1041 
1042 double
1044  switch (activeScheme) {
1045  case 18: {
1046  return GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
1047  }
1048  default:
1049  return getColorValue(s, activeScheme);
1050  }
1051 
1052 }
1053 
1054 
1055 RGBColor
1057  // setting and retrieving the color does not work in OSGView so we return it explicitliy
1058  RGBColor col;
1059  if (MSGlobals::gUseMesoSim && static_cast<const GUIEdge*>(myEdge)->getMesoColor() != MESO_USE_LANE_COLOR) {
1060  col = static_cast<const GUIEdge*>(myEdge)->getMesoColor();
1061  } else {
1062  const GUIColorer& c = s.laneColorer;
1063  if (!setFunctionalColor(c, col) && !setMultiColor(s, c, col)) {
1064  col = c.getScheme().getColor(getColorValue(s, c.getActive()));
1065  }
1066  }
1067  GLHelper::setColor(col);
1068  return col;
1069 }
1070 
1071 
1072 bool
1073 GUILane::setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme) const {
1074  if (activeScheme < 0) {
1075  activeScheme = c.getActive();
1076  }
1077  switch (activeScheme) {
1078  case 0:
1079  if (myEdge->isCrossing()) {
1080  // determine priority to decide color
1081  const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
1082  if (link->havePriority() || link->getTLLogic() != nullptr) {
1083  col = RGBColor(230, 230, 230);
1084  } else {
1085  col = RGBColor(26, 26, 26);
1086  }
1087  GLHelper::setColor(col);
1088  return true;
1089  } else {
1090  return false;
1091  }
1092  case 18: {
1093  double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
1094  col = RGBColor::fromHSV(hue, 1., 1.);
1095  GLHelper::setColor(col);
1096  return true;
1097  }
1098  case 30: { // taz color
1099  col = c.getScheme().getColor(0);
1100  std::vector<RGBColor> tazColors;
1101  for (MSEdge* e : myEdge->getPredecessors()) {
1102  if (e->isTazConnector() && e->knowsParameter("tazColor")) {
1103  tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
1104  }
1105  }
1106  for (MSEdge* e : myEdge->getSuccessors()) {
1107  if (e->isTazConnector() && e->knowsParameter("tazColor")) {
1108  tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
1109  }
1110  }
1111  if (tazColors.size() > 0) {
1112  int randColor = RandHelper::rand((int)tazColors.size(), RGBColor::getColorRNG());
1113  col = tazColors[randColor];
1114  }
1115  GLHelper::setColor(col);
1116  return true;
1117  }
1118  default:
1119  return false;
1120  }
1121 }
1122 
1123 
1124 bool
1126  const int activeScheme = c.getActive();
1127  myShapeColors.clear();
1128  switch (activeScheme) {
1129  case 22: // color by height at segment start
1130  for (PositionVector::const_iterator ii = myShape.begin(); ii != myShape.end() - 1; ++ii) {
1131  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
1132  }
1133  // osg fallback (edge height at start)
1134  col = c.getScheme().getColor(getColorValue(s, 21));
1135  return true;
1136  case 24: // color by inclination at segment start
1137  for (int ii = 1; ii < (int)myShape.size(); ++ii) {
1138  const double inc = (myShape[ii].z() - myShape[ii - 1].z()) / MAX2(POSITION_EPS, myShape[ii].distanceTo2D(myShape[ii - 1]));
1139  myShapeColors.push_back(c.getScheme().getColor(inc));
1140  }
1141  col = c.getScheme().getColor(getColorValue(s, 23));
1142  return true;
1143  default:
1144  return false;
1145  }
1146 }
1147 
1148 double
1150  if (myCachedGUISettings != nullptr) {
1152  const GUIColorer& c = s.laneColorer;
1153  return getColorValueWithFunctional(s, c.getActive());
1154  } else {
1155  return 0;
1156  }
1157 }
1158 
1159 
1160 double
1161 GUILane::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
1162  switch (activeScheme) {
1163  case 0:
1164  switch (myPermissions) {
1165  case SVC_PEDESTRIAN:
1166  return 1;
1167  case SVC_BICYCLE:
1168  return 2;
1169  case 0:
1170  // forbidden road or green verge
1171  return myEdge->getPermissions() == 0 ? 10 : 3;
1172  case SVC_SHIP:
1173  return 4;
1174  case SVC_AUTHORITY:
1175  return 8;
1176  default:
1177  break;
1178  }
1179  if (myEdge->isTazConnector()) {
1180  return 9;
1181  } else if (isRailway(myPermissions)) {
1182  if ((myPermissions & SVC_BUS) != 0) {
1183  return 6;
1184  } else {
1185  return 5;
1186  }
1187  } else if ((myPermissions & SVC_PASSENGER) != 0) {
1188  if ((myPermissions & (SVC_RAIL_CLASSES & ~SVC_RAIL_FAST)) != 0 && (myPermissions & SVC_SHIP) == 0) {
1189  return 6;
1190  } else {
1191  return 0;
1192  }
1193  } else {
1194  return 7;
1195  }
1196  case 1:
1197  return isLaneOrEdgeSelected();
1198  case 2:
1199  return (double)myPermissions;
1200  case 3:
1201  return getSpeedLimit();
1202  case 4:
1203  return getBruttoOccupancy();
1204  case 5:
1205  return getNettoOccupancy();
1206  case 6:
1207  return firstWaitingTime();
1208  case 7:
1209  return getEdgeLaneNumber();
1210  case 8:
1211  return getCO2Emissions() / myLength;
1212  case 9:
1213  return getCOEmissions() / myLength;
1214  case 10:
1215  return getPMxEmissions() / myLength;
1216  case 11:
1217  return getNOxEmissions() / myLength;
1218  case 12:
1219  return getHCEmissions() / myLength;
1220  case 13:
1221  return getFuelConsumption() / myLength;
1222  case 14:
1224  case 15: {
1225  return getStoredEdgeTravelTime();
1226  }
1227  case 16: {
1229  if (!ews.knowsTravelTime(myEdge)) {
1230  return -1;
1231  } else {
1232  double value(0);
1233  ews.retrieveExistingTravelTime(myEdge, 0, value);
1234  return 100 * myLength / value / getSpeedLimit();
1235  }
1236  }
1237  case 17: {
1238  // geometrical length has no meaning for walkingAreas since it describes the outer boundary
1239  return myEdge->isWalkingArea() ? 1 : 1 / myLengthGeometryFactor;
1240  }
1241  case 19: {
1242  return getLoadedEdgeWeight();
1243  }
1244  case 20: {
1245  return myEdge->getPriority();
1246  }
1247  case 21: {
1248  // color by z of first shape point
1249  return getShape()[0].z();
1250  }
1251  case 23: {
1252  // color by incline
1253  return (getShape()[-1].z() - getShape()[0].z()) / getLength();
1254  }
1255  case 25: {
1256  // color by average speed
1257  return getMeanSpeed();
1258  }
1259  case 26: {
1260  // color by average relative speed
1261  return getMeanSpeed() / myMaxSpeed;
1262  }
1263  case 27: {
1264  // color by routing device assumed speed
1265  return myEdge->getRoutingSpeed();
1266  }
1267  case 28:
1269  case 29:
1270  return getPendingEmits();
1271  case 31: {
1272  // by numerical edge param value
1273  try {
1275  } catch (NumberFormatException&) {
1276  try {
1278  } catch (BoolFormatException&) {
1279  return -1;
1280  }
1281  }
1282  }
1283  case 32: {
1284  // by numerical lane param value
1285  try {
1287  } catch (NumberFormatException&) {
1288  try {
1289  return StringUtils::toBool(getParameter(s.laneParam, "0"));
1290  } catch (BoolFormatException&) {
1291  return -1;
1292  }
1293  }
1294  }
1295  case 33: {
1296  // by edge data value
1298  }
1299  case 34: {
1300  return myEdge->getDistance();
1301  }
1302  case 35: {
1303  return fabs(myEdge->getDistance());
1304  }
1305  case 36: {
1306  return myReachability;
1307  }
1308  case 37: {
1310  }
1311  case 38: {
1312  if (myParkingAreas == nullptr) {
1313  // init
1314  myParkingAreas = new std::vector<MSParkingArea*>();
1315  for (auto& item : MSNet::getInstance()->getStoppingPlaces(SUMO_TAG_PARKING_AREA)) {
1316  if (&item.second->getLane().getEdge() == myEdge) {
1317  myParkingAreas->push_back(dynamic_cast<MSParkingArea*>(item.second));
1318  }
1319  }
1320  }
1321  int capacity = 0;
1322  for (MSParkingArea* pa : *myParkingAreas) {
1323  capacity += pa->getCapacity() - pa->getOccupancy();
1324  }
1325  return capacity;
1326  }
1327  }
1328  return 0;
1329 }
1330 
1331 
1332 double
1333 GUILane::getScaleValue(int activeScheme) const {
1334  switch (activeScheme) {
1335  case 0:
1336  return 0;
1337  case 1:
1338  return isLaneOrEdgeSelected();
1339  case 2:
1340  return getSpeedLimit();
1341  case 3:
1342  return getBruttoOccupancy();
1343  case 4:
1344  return getNettoOccupancy();
1345  case 5:
1346  return firstWaitingTime();
1347  case 6:
1348  return getEdgeLaneNumber();
1349  case 7:
1350  return getCO2Emissions() / myLength;
1351  case 8:
1352  return getCOEmissions() / myLength;
1353  case 9:
1354  return getPMxEmissions() / myLength;
1355  case 10:
1356  return getNOxEmissions() / myLength;
1357  case 11:
1358  return getHCEmissions() / myLength;
1359  case 12:
1360  return getFuelConsumption() / myLength;
1361  case 13:
1363  case 14: {
1364  return getStoredEdgeTravelTime();
1365  }
1366  case 15: {
1368  if (!ews.knowsTravelTime(myEdge)) {
1369  return -1;
1370  } else {
1371  double value(0);
1372  ews.retrieveExistingTravelTime(myEdge, 0, value);
1373  return 100 * myLength / value / getSpeedLimit();
1374  }
1375  }
1376  case 16: {
1377  return 1 / myLengthGeometryFactor;
1378  }
1379  case 17: {
1380  return getLoadedEdgeWeight();
1381  }
1382  case 18: {
1383  return myEdge->getPriority();
1384  }
1385  case 19: {
1386  // scale by average speed
1387  return getMeanSpeed();
1388  }
1389  case 20: {
1390  // scale by average relative speed
1391  return getMeanSpeed() / myMaxSpeed;
1392  }
1393  case 21:
1395  case 22:
1397  }
1398  return 0;
1399 }
1400 
1401 
1402 bool
1405 }
1406 
1407 
1408 bool
1410  return isWaterway(myPermissions) && s.showRails && !s.drawForPositionSelection; // reusing the showRails setting
1411 }
1412 
1413 
1414 #ifdef HAVE_OSG
1415 void
1416 GUILane::updateColor(const GUIVisualizationSettings& s) {
1417  if (myGeom == 0) {
1418  // not drawn
1419  return;
1420  }
1421  const RGBColor col = setColor(s);
1422  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1423  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1424  myGeom->setColorArray(colors);
1425 }
1426 #endif
1427 
1428 
1429 void
1430 GUILane::closeTraffic(bool rebuildAllowed) {
1431  MSGlobals::gCheckRoutes = false;
1432  if (myAmClosed) {
1433  myPermissionChanges.clear(); // reset rerouters
1435  } else {
1437  }
1439  if (rebuildAllowed) {
1441  }
1442 }
1443 
1444 
1447  assert(MSGlobals::gUseMesoSim);
1448  int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1449  const double slength = myLength / no;
1450  PositionVector result = shape;
1451  double offset = 0;
1452  for (int i = 0; i < no; ++i) {
1453  offset += slength;
1454  Position pos = shape.positionAtOffset(offset);
1455  int index = result.indexOfClosest(pos);
1456  if (pos.distanceTo(result[index]) > POSITION_EPS) {
1457  index = result.insertAtClosest(pos, false);
1458  }
1459  if (i != no - 1) {
1460  mySegmentStartIndex.push_back(index);
1461  }
1462  while ((int)myShapeSegments.size() < index) {
1463  myShapeSegments.push_back(i);
1464  }
1465  //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1466  }
1467  while (myShapeSegments.size() < result.size()) {
1468  myShapeSegments.push_back(no - 1);
1469  }
1470  return result;
1471 }
1472 
1473 bool
1475  return gSelected.isSelected(GLO_LANE, getGlID());
1476 }
1477 
1478 bool
1480  return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1481 }
1482 
1483 double
1486 }
1487 
1488 
1489 /****************************************************************************/
@ MID_COPY_EDGE_NAME
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:415
@ MID_REACHABILITY
show reachability from a given lane
Definition: GUIAppEnum.h:485
@ MID_CLOSE_LANE
close lane
Definition: GUIAppEnum.h:606
@ MID_CLOSE_EDGE
close edge
Definition: GUIAppEnum.h:608
@ MID_ADD_REROUTER
add rerouter
Definition: GUIAppEnum.h:610
@ 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:32
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_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_PARKING_AREA
A parking area.
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:48
T MIN2(T a, T b)
Definition: StdDefs.h:74
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:54
T MAX2(T a, T b)
Definition: StdDefs.h:80
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:50
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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:170
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:792
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:189
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:369
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:485
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:691
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
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:277
static void drawCrossTies(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double length, double spacing, double halfWidth, bool drawForSelection)
draw crossties for railroads or pedestrian crossings
Definition: GLHelper.cpp:709
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:231
static void popName()
pop Name
Definition: GLHelper.cpp:141
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
static void drawInverseMarkings(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double maxLength, double spacing, double halfWidth, bool cl, bool cr, bool lefthand, double scale)
@bried draw the space between markings (in road color)
Definition: GLHelper.cpp:748
A MSVehicle extended by some values for usage within the gui.
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:42
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:556
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:1409
const PositionVector & getShape() const
Definition: GUILane.cpp:987
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:867
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1474
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:347
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition: GUILane.h:367
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:164
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:381
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1479
void drawArrows() const
Definition: GUILane.cpp:395
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:999
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1333
void integrateNewVehicles()
Definition: GUILane.cpp:185
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:358
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1446
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:353
double firstWaitingTime() const
Definition: GUILane.cpp:1005
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:361
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:241
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:1056
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1484
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:462
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:214
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:776
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:384
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:1125
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:178
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition: GUILane.h:355
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:280
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:350
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:975
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GUILane.cpp:969
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:138
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1430
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GUILane.cpp:839
GUILane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: GUILane.cpp:74
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:131
double getColorValueWithFunctional(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index including values for things that set the c...
Definition: GUILane.cpp:1043
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1403
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:206
void removeParking(MSBaseVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:171
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:993
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:192
double getColorValueForTracker() const
return color value based on cached settings
Definition: GUILane.cpp:1149
double getEdgeLaneNumber() const
Definition: GUILane.cpp:1011
double myReachability
the time distance from a particular edge
Definition: GUILane.h:364
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:1030
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:489
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:344
void executeMovements(const SUMOTime t)
Definition: GUILane.cpp:157
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:121
~GUILane()
Destructor.
Definition: GUILane.cpp:110
void setJunctionApproaches(const SUMOTime t) const
Definition: GUILane.cpp:150
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:330
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1073
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:1017
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:727
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:199
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:749
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:374
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:144
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:892
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:934
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1161
static const GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition: GUILane.h:377
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:192
int getLinkTLIndex(const MSLink *const link) const
Definition: GUINet.cpp:207
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:533
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:566
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.
void checkFont(const std::string &text)
ensure that the font covers the given text
const T getColor(const double value) const
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
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 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
bool realisticLinkRules
Information whether link rules (colored bars) shall be drawn with a realistic color scheme.
GUIVisualizationTextSettings drawLinkJunctionIndex
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
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, bool realistic=false)
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:267
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
A road/street connecting two junctions.
Definition: MSEdge.h:77
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:267
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:322
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition: MSEdge.h:605
const MSEdgeVector & getPredecessors() const
Definition: MSEdge.h:392
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:307
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:281
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
void rebuildAllowedLanes()
Definition: MSEdge.cpp:271
bool isTazConnector() const
Definition: MSEdge.h:285
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:262
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:300
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:313
const MSJunction * getToJunction() const
Definition: MSEdge.h:401
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:879
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition: MSEdge.h:276
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1084
double getDistance() const
Returns the kilometrage/mileage at the start of the edge.
Definition: MSEdge.h:328
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:94
static bool gCheckRoutes
Definition: MSGlobals.h:82
static double gLateralResolution
Definition: MSGlobals.h:88
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:133
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:157
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:1389
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition: MSLane.cpp:1293
std::set< const MSBaseVehicle * > myParkingVehicles
Definition: MSLane.h:1369
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2896
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:641
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2908
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3160
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:2068
double myLength
Lane length [m].
Definition: MSLane.h:1372
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition: MSLane.cpp:2803
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2282
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1320
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1463
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:348
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1383
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:824
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1386
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2872
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2214
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:1253
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1336
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:533
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:92
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3950
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1449
int myRNGIndex
Definition: MSLane.h:1466
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2268
StopOffset myLaneStopOffset
Definition: MSLane.h:1380
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:277
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:563
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:3938
const double myWidth
Lane width [m].
Definition: MSLane.h:1375
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1443
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1831
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2637
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2788
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2932
int myIndex
The lane index.
Definition: MSLane.h:1323
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1353
std::vector< MSLink * > myLinks
Definition: MSLane.h:1427
bool isInternal() const
Definition: MSLane.cpp:2122
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1257
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2944
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:511
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:296
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2956
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2884
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:556
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2831
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2920
Notification
Definition of a vehicle state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition: MSNet.cpp:1082
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:429
A lane area vehicles can halt at.
Definition: MSParkingArea.h:58
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
const std::string & getID() const
Returns the id.
Definition: Named.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
virtual 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:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:242
double x() const
Returns the x-position.
Definition: Position.h:55
double z() const
Returns the z-position.
Definition: Position.h:65
double y() const
Returns the y-position.
Definition: Position.h:60
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)
int indexOfClosest(const Position &p, bool twoD=false) const
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
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.cpp:74
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.cpp:92
static SumoRNG * getColorRNG()
get color RNG
Definition: RGBColor.cpp:191
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:236
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.cpp:80
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:368
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.cpp:86
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:197
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:119
bool isDefined() const
check if stopOffset was defined
SVCPermissions getPermissions() const
get permissions
double getOffset() const
get offset
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.
bool show(const GUIGlObject *o) const
whether to show the text