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