Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNELaneAreaDetector.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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/****************************************************************************/
18//
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNESegment.h>
25#include <netedit/GNEUndoList.h>
26#include <netedit/GNEViewNet.h>
36
37#include "GNELaneAreaDetector.h"
39
40// ===========================================================================
41// member method definitions
42// ===========================================================================
43
47
48
49GNELaneAreaDetector::GNELaneAreaDetector(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane, double pos, double length, const SUMOTime freq,
50 const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
51 const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold, double speedThreshold, const double jamThreshold, const bool friendlyPos,
52 const bool show, const Parameterised::Map& parameters) :
53 GNEDetector(id, net, filename, SUMO_TAG_LANE_AREA_DETECTOR, pos, freq, lane, outputFilename, vehicleTypes, nextEdges,
54 detectPersons, name, friendlyPos, parameters),
55 myEndPositionOverLane(pos + length),
56 myTimeThreshold(timeThreshold),
57 mySpeedThreshold(speedThreshold),
58 myJamThreshold(jamThreshold),
59 myTrafficLight(trafficLight),
60 myShow(show) {
61}
62
63
64GNELaneAreaDetector::GNELaneAreaDetector(const std::string& id, GNENet* net, const std::string& filename, std::vector<GNELane*> lanes, double pos, double endPos, const SUMOTime freq,
65 const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
66 const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold, double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show,
67 const Parameterised::Map& parameters) :
68 GNEDetector(id, net, filename, GNE_TAG_MULTI_LANE_AREA_DETECTOR, pos, freq, lanes, outputFilename, vehicleTypes, nextEdges,
69 detectPersons, name, friendlyPos, parameters),
70 myEndPositionOverLane(endPos),
71 myTimeThreshold(timeThreshold),
72 mySpeedThreshold(speedThreshold),
73 myJamThreshold(jamThreshold),
74 myTrafficLight(trafficLight),
75 myShow(show) {
76}
77
78
81
82
83void
86 device.writeAttr(SUMO_ATTR_ID, getID());
87 // continue depending of E2 type
89 device.writeAttr(SUMO_ATTR_LANE, getParentLanes().front()->getID());
92 } else {
96 }
97 // write common detector parameters
98 writeDetectorValues(device);
99 // write specific attributes
100 if (myTrafficLight.size() > 0) {
102 }
105 }
108 }
111 }
114 }
115 // write parameters (Always after children to avoid problems with additionals.xsd)
116 writeParams(device);
117 device.closeTag();
118}
119
120
121bool
123 if (getParentLanes().size() == 1) {
124 // with friendly position enabled position are "always fixed"
125 if (myFriendlyPosition) {
126 return true;
127 } else {
128 return (myPositionOverLane >= 0) && (myEndPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
129 }
130 } else {
131 // first check if there is connection between all consecutive lanes
133 // with friendly position enabled position are "always fixed"
134 if (myFriendlyPosition) {
135 return true;
136 } else {
137 return (myPositionOverLane >= 0) &&
138 (myEndPositionOverLane >= 0) &&
139 (myPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) &&
140 (myEndPositionOverLane <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
141 }
142 } else {
143 return false;
144 }
145 }
146}
147
148
149std::string
151 // declare variable for error position
152 std::string errorFirstLanePosition, separator, errorLastLanePosition;
153 if (getParentLanes().size() == 1) {
154 // check positions over lane
155 if (myPositionOverLane < 0) {
156 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
157 }
158 if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
159 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
160 }
161 } else {
162 // abort if lanes aren't consecutives
164 return TL("lanes aren't consecutives");
165 }
166 // abort if lanes aren't connected
168 return TL("lanes aren't connected");
169 }
170 // check positions over first lane
171 if (myPositionOverLane < 0) {
172 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
173 }
174 if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
175 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
176 }
177 // check positions over last lane
178 if (myEndPositionOverLane < 0) {
179 errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
180 }
181 if (myEndPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
182 errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + TL(" > lanes's length"));
183 }
184 }
185 // check separator
186 if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
187 separator = TL(" and ");
188 }
189 // return error message
190 return errorFirstLanePosition + separator + errorLastLanePosition;
191}
192
193
194void
196 if (getParentLanes().size() == 1) {
197 // obtain position and length
198 double newPositionOverLane = myPositionOverLane;
199 double newLength = (myEndPositionOverLane - myPositionOverLane);
200 // fix pos and length using fixE2DetectorPosition
201 GNEAdditionalHandler::fixLanePosition(newPositionOverLane, newLength, getParentLanes().at(0)->getParentEdge()->getNBEdge()->getFinalLength());
202 // set new position and length
205 } else {
207 // build connections between all consecutive lanes
208 bool foundConnection = true;
209 int i = 0;
210 // iterate over all lanes, and stop if myE2valid is false
211 while (i < ((int)getParentLanes().size() - 1)) {
212 // change foundConnection to false
213 foundConnection = false;
214 // if a connection between "from" lane and "to" lane of connection is found, change myE2valid to true again
215 for (const auto& connection : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
216 if ((connection->getLaneFrom() == getParentLanes().at(i)) && (connection->getLaneTo() == getParentLanes().at(i + 1))) {
217 foundConnection = true;
218 }
219 }
220 // if connection wasn't found
221 if (!foundConnection) {
222 // create new connection manually
223 NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
224 // allow to undo creation of new lane
225 myNet->getViewNet()->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
226 }
227 // update lane iterator
228 i++;
229 }
230 } else {
231 // declare new positions
232 double newPositionOverLane = myPositionOverLane;
233 double newEndPositionOverLane = myEndPositionOverLane;
234 // fix pos and length checkAndFixDetectorPosition
236 newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
237 newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
238 // set new position and endPosition
240 setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myNet->getViewNet()->getUndoList());
241 }
242 }
243}
244
245
246void
248 // check E2 detector
250 // compute path
252 } else {
253 // Cut shape using as delimitators fixed start position and fixed end position
255 }
256}
257
258
259void
261 // check drawing conditions
265 // Obtain exaggeration of the draw
266 const double E2Exaggeration = getExaggeration(s);
267 // get detail level
268 const auto d = s.getDetailLevel(E2Exaggeration);
269 // draw geometry only if we'rent in drawForObjectUnderCursor mode
271 // draw E2
272 drawE2(s, d, E2Exaggeration);
273 // draw lock icon
275 // Draw additional ID
277 // draw additional name
279 // draw dotted contour
281 }
282 // calculate contour and draw dotted geometry
284 E2Exaggeration, true, true, 0, nullptr, getParentLanes().front()->getParentEdge());
285 }
286}
287
288
289void
294
295
296void
297GNELaneAreaDetector::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
298 // check if E2 can be drawn
301 const bool movingGeometryPoints = drawMovingGeometryPoints(false);
302 // Obtain exaggeration of the draw
303 const double E2Exaggeration = getExaggeration(s);
304 // get detail level
305 const auto d = s.getDetailLevel(E2Exaggeration);
306 // calculate startPos
307 const double geometryDepartPos = getAttributeDouble(SUMO_ATTR_POSITION);
308 // get endPos
309 const double geometryEndPos = getAttributeDouble(SUMO_ATTR_ENDPOS);
310 // declare path geometry
311 GUIGeometry E2Geometry;
312 // update pathGeometry depending of first and last segment
313 if (segment->isFirstSegment() && segment->isLastSegment()) {
314 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
315 geometryDepartPos,
317 geometryEndPos,
319 } else if (segment->isFirstSegment()) {
320 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
321 geometryDepartPos,
323 -1,
325 } else if (segment->isLastSegment()) {
326 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
327 -1,
329 geometryEndPos,
331 } else {
332 E2Geometry = segment->getLane()->getLaneGeometry();
333 }
334 // draw geometry only if we'rent in drawForObjectUnderCursor mode
336 // draw E2 partial
337 drawE2PartialLane(s, d, segment, offsetFront, E2Geometry, E2Exaggeration, movingGeometryPoints);
338 // draw additional ID
339 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
340 // draw dotted contour
341 if (movingGeometryPoints) {
342 // get mouse position
343 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
344 // get snap radius
346 if (segment->getFromContour() && E2Geometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
348 } else if (segment->getToContour() && E2Geometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
350 }
351 } else {
352 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
353 }
354 }
355 // calculate contour and draw dotted geometry
356 segment->getContour()->calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), getType(), s.detectorSettings.E2Width,
357 E2Exaggeration, segment->isFirstSegment(), segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge());
358 // check if create from-to contours
359 if (segment->getFromContour()) {
360 segment->getFromContour()->calculateContourCircleShape(s, d, this, E2Geometry.getShape().front(),
362 } else if (segment->getToContour()) {
363 segment->getToContour()->calculateContourCircleShape(s, d, this, E2Geometry.getShape().back(),
365 }
366 // check if add this path element to redraw buffer
369 }
370 }
371}
372
373
374void
375GNELaneAreaDetector::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
376 // check if E2 can be drawn
377 if ((myTagProperty->getTag() == GNE_TAG_MULTI_LANE_AREA_DETECTOR) && segment->getPreviousLane() && segment->getNextLane() &&
379 // Obtain exaggeration of the draw
380 const double E2Exaggeration = getExaggeration(s);
381 // get detail level
382 const auto d = s.getDetailLevel(E2Exaggeration);
383 // get flag for show only contour
385 // check if connection to next lane exist
386 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
387 // get geometry
388 const GUIGeometry& E2Geometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
389 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
390 // draw geometry only if we'rent in drawForObjectUnderCursor mode
392 // draw E2 partial
393 drawE2PartialJunction(s, d, onlyContour, offsetFront, E2Geometry, E2Exaggeration);
394 // draw dotted contour
395 if (!drawMovingGeometryPoints(false)) {
396 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
397 }
398 }
399 // calculate contour
400 segment->getContour()->calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), getType(), s.detectorSettings.E2Width, E2Exaggeration,
401 false, false, 0, segment, segment->getJunction());
402 // check if add this path element to redraw buffer
405 }
406 }
407}
408
409
410std::string
435
436
437double
439 switch (key) {
440 case SUMO_ATTR_LENGTH:
442 case SUMO_ATTR_ENDPOS:
444 default:
445 return getDetectorAttributeDouble(key);
446 }
447}
448
449
450void
451GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
452 switch (key) {
453 case SUMO_ATTR_LANES:
454 case SUMO_ATTR_ENDPOS:
455 case SUMO_ATTR_TLID:
456 case SUMO_ATTR_LENGTH:
461 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
462 break;
463 default:
464 setDetectorAttribute(key, value, undoList);
465 break;
466 }
467}
468
469
470bool
471GNELaneAreaDetector::isValid(SumoXMLAttr key, const std::string& value) {
472 switch (key) {
473 case SUMO_ATTR_LANES:
474 if (value.empty()) {
475 return false;
476 } else {
477 return canParse<std::vector<GNELane*> >(myNet, value, true);
478 }
479 case SUMO_ATTR_ENDPOS:
480 return canParse<double>(value);
481 case SUMO_ATTR_TLID:
482 // temporal
484 case SUMO_ATTR_LENGTH:
485 return (canParse<double>(value) && (parse<double>(value) >= 0));
487 return canParse<SUMOTime>(value) && (parse<SUMOTime>(value) >= 0);
489 return (canParse<double>(value) && (parse<double>(value) >= 0));
491 return (canParse<double>(value) && (parse<double>(value) >= 0));
493 return canParse<bool>(value);
494 default:
495 return isDetectorValid(key, value);
496 }
497}
498
499// ===========================================================================
500// private
501// ===========================================================================
502
503void
505 const double exaggeration) const {
506 // declare color
507 RGBColor E2Color, textColor;
508 // set color
509 if (drawUsingSelectColor()) {
511 textColor = E2Color.changedBrightness(-32);
512 } else if (areLaneConsecutives(getParentLanes())) {
513 E2Color = s.detectorSettings.E2Color;
514 textColor = RGBColor::BLACK;
515 }
516 // draw parent and child lines
518 // push layer matrix
520 // translate to front
522 // set color
523 GLHelper::setColor(E2Color);
524 // draw geometry
526 // draw arrow
527 if (myAdditionalGeometry.getShape().size() > 1) {
528 glTranslated(0, 0, 0.1);
530 }
531 // draw E2 Logo
532 drawE2DetectorLogo(s, d, exaggeration, "E2", textColor);
533 // draw geometry points
536 // pop layer matrix
538}
539
540
541void
543 const GNESegment* segment, const double offsetFront,
544 const GUIGeometry& geometry, const double exaggeration, const bool movingGeometryPoints) const {
545 // obtain color
547 // push layer matrix
549 // Start with the drawing of the area traslating matrix to origin
550 glTranslated(0, 0, getType() + offsetFront);
551 // Set color
552 GLHelper::setColor(E2Color);
553 // draw geometry
554 GUIGeometry::drawGeometry(d, geometry, s.detectorSettings.E2Width * exaggeration);
555 // check if draw moving geometry points
556 if (movingGeometryPoints) {
557 if (segment->isFirstSegment() && segment->isLastSegment()) {
558 drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
559 drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
560 } else if (segment->isFirstSegment()) {
561 drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
562 } else if (segment->isLastSegment()) {
563 drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
564 // draw arrow
565 if (geometry.getShape().size() > 1) {
566 glTranslated(0, 0, 0.1);
567 GLHelper::drawTriangleAtEnd(geometry.getShape()[-2], geometry.getShape()[-1], (double) 0.5, (double) 1, 0.5);
568 }
569 }
570 }
571 // Pop layer matrix
573 // check if this is the label segment
574 if (segment->isLabelSegment()) {
575 // calculate middle point
576 const double middlePoint = (geometry.getShape().length2D() * 0.5);
577 // calculate position
578 const Position pos = geometry.getShape().positionAtOffset2D(middlePoint);
579 // calculate rotation
580 const double rot = s.getTextAngle((geometry.getShape().rotationDegreeAtOffset(middlePoint) * -1) + 90);
581 // Start pushing matrix
583 // Traslate to position
584 glTranslated(pos.x(), pos.y(), getType() + offsetFront + 0.1);
585 // rotate
586 glRotated(rot, 0, 0, 1);
587 // move
588 glTranslated(-1, 0, 0);
589 // scale text
590 glScaled(exaggeration, exaggeration, 1);
591 // draw E1 logo
592 GLHelper::drawText("E2 Multilane", Position(), .1, 1.5, RGBColor::BLACK);
593 // pop matrix
595 }
596
597}
598
599
600void
602 const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,
603 const double exaggeration) const {
604 const bool invalid = geometry.getShape().length() == 2;
605 const double width = s.detectorSettings.E2Width * exaggeration * (invalid ? 0.5 : 1);
606 // Add a draw matrix
608 // Start with the drawing of the area traslating matrix to origin
609 glTranslated(0, 0, getType() + offsetFront);
610 // Set color of the base
611 if (drawUsingSelectColor()) {
613 } else if (invalid) {
615 } else {
617 }
618 // check if draw only contour
619 if (onlyContour) {
620 GUIGeometry::drawContourGeometry(geometry, width);
621 } else {
622 GUIGeometry::drawGeometry(d, geometry, width);
623 }
624 // Pop last matrix
626}
627
628
629void
630GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value) {
631 switch (key) {
632 case SUMO_ATTR_LANES:
634 break;
635 case SUMO_ATTR_ENDPOS:
636 myEndPositionOverLane = parse<double>(value);
637 // update geometry (except for template)
638 if (getParentLanes().size() > 0) {
640 }
641 break;
642 case SUMO_ATTR_TLID:
643 myTrafficLight = value;
644 break;
645 case SUMO_ATTR_LENGTH:
646 myEndPositionOverLane = (myPositionOverLane + parse<double>(value));
647 // update geometry (except for template)
648 if (getParentLanes().size() > 0) {
650 }
651 break;
653 myTimeThreshold = TIME2STEPS(parse<double>(value));
654 break;
656 mySpeedThreshold = parse<double>(value);
657 break;
659 myJamThreshold = parse<double>(value);
660 break;
662 myShow = parse<bool>(value);
663 break;
664 default:
665 setDetectorAttribute(key, value);
666 break;
667 }
668}
669
670
671void
675 // change only start position
676 myPositionOverLane = moveResult.newFirstPos;
679 // change only end position
681 } else {
683 const auto difference = moveResult.newFirstPos - myPositionOverLane;
684 // change start position
685 myPositionOverLane = moveResult.newFirstPos;
686 myEndPositionOverLane += difference;
688 const auto difference = moveResult.newFirstPos - myEndPositionOverLane;
689 // change end position
690 myPositionOverLane += difference;
692 }
693 // end position over lane
694 if (myPositionOverLane < 0) {
696 } else if (myPositionOverLane > getParentLanes().front()->getLaneShapeLength()) {
697 myPositionOverLane = getParentLanes().front()->getLaneShapeLength();
698 }
699 // adjust position over lane
700 if (myEndPositionOverLane < 0) {
702 } else if (myEndPositionOverLane > getParentLanes().back()->getLaneShapeLength()) {
703 myEndPositionOverLane = getParentLanes().back()->getLaneShapeLength();
704 }
705 }
706 // update geometry
708}
709
710
711void
713 // begin change attribute
714 undoList->begin(this, "position of " + getTagStr());
715 // set attributes depending of operation type
718 // set only start position
719 setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
722 // set only end position
723 setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newFirstPos), undoList);
724 } else {
725 double startPos = myPositionOverLane;
726 double endPos = myEndPositionOverLane;
727 // set positions
729 const auto difference = moveResult.newFirstPos - myPositionOverLane;
730 // change start position
731 startPos = moveResult.newFirstPos;
732 endPos += difference;
734 const auto difference = moveResult.newFirstPos - myEndPositionOverLane;
735 // change end position
736 startPos += difference;
737 endPos = moveResult.newFirstPos;
738 }
739 // end position over lane
740 if (startPos < 0) {
741 startPos = 0;
742 } else if (startPos > getParentLanes().front()->getLaneShapeLength()) {
743 startPos = getParentLanes().front()->getLaneShapeLength();
744 }
745 // adjust position over lane
746 if (endPos < 0) {
747 endPos = 0;
748 } else if (endPos > getParentLanes().back()->getLaneShapeLength()) {
749 endPos = getParentLanes().back()->getLaneShapeLength();
750 }
751 // set only end position
752 setAttribute(SUMO_ATTR_POSITION, toString(startPos), undoList);
753 setAttribute(SUMO_ATTR_ENDPOS, toString(endPos), undoList);
754 }
755 // end change attribute
756 undoList->end();
757}
758
759
760double
762 // get lane final and shape length
763 const double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
764 // get startPosition
765 double fixedPos = myPositionOverLane;
766 // adjust fixedPos
767 if (fixedPos < 0) {
768 fixedPos += laneLength;
769 }
770 fixedPos *= getParentLanes().front()->getLengthGeometryFactor();
771 // return depending of fixedPos
772 if (fixedPos < 0) {
773 return 0;
774 } else if (fixedPos > (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
775 return (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
776 } else {
777 return fixedPos;
778 }
779}
780
781
782double
784 // get lane final and shape length
785 const double laneLength = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
786 // get endPosition
787 double fixedPos = myEndPositionOverLane;
788 // adjust fixedPos
789 if (fixedPos < 0) {
790 fixedPos += laneLength;
791 }
792 fixedPos *= getParentLanes().back()->getLengthGeometryFactor();
793 // return depending of fixedPos
794 if (fixedPos < POSITION_EPS) {
795 return POSITION_EPS;
796 } else if (fixedPos > getParentLanes().back()->getLaneShapeLength()) {
797 return getParentLanes().back()->getLaneShapeLength();
798 } else {
799 return fixedPos;
800 }
801}
802
803/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ GLO_E2DETECTOR
a E2 detector
GUIViewObjectsHandler gViewObjectsHandler
#define TL(string)
Definition MsgHandler.h:305
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
#define TIME2STEPS(x)
Definition SUMOTime.h:57
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_LANE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_LANES
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_SHOW_DETECTOR
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
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:624
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition GLHelper.cpp:742
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
GNENet * myNet
pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (circle elements)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void drawE2DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E2 detector Logo
double myPositionOverLane
position of detector over Lane
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
void setDetectorAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
double getDetectorAttributeDouble(SumoXMLAttr key) const
void writeDetectorValues(OutputDevice &device) const
write additional element into a xml file
bool myFriendlyPosition
Flag for friendly position.
std::string getDetectorAttribute(SumoXMLAttr key) const
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateGeometry()
update pre-computed geometry information
double getAttributeDouble(SumoXMLAttr key) const
void fixAdditionalProblem()
fix additional problem
std::string getAttribute(SumoXMLAttr key) const
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool myShow
show or hidde detector in sumo-gui
bool isAdditionalValid() const
check if current additional is valid to be written into XML
void drawE2PartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNESegment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration, const bool movingGeometryPoints) const
draw E2 partial lane
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
void drawE2(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw E2 detector
GNELaneAreaDetector(SumoXMLTag tag, GNENet *net)
default Constructor
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
std::string getAdditionalProblem() const
return a string with the current additional problem
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
void computePathElement()
compute pathElement
void drawE2PartialJunction(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const bool onlyContour, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw E2 partial junction
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:220
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:692
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:214
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
move result
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getNetworkPathManager()
get network path manager
Definition GNENet.cpp:171
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
void calculateConsecutivePathLanes(GNEPathElement *pathElement, const std::vector< GNELane * > &lanes)
calculate consecutive path lanes
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getPreviousLane() const
get previous lane
GNEContour * getFromContour() const
get from contour associated with segment (only if this is the first path segment)
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
bool isLastSegment() const
check if segment is the last path's segment
bool isLabelSegment() const
check if segment is label segment
GNEContour * getToContour() const
get to contour associated with segment (only if this is the last path segment)
bool getDefaultBoolValue(SumoXMLAttr attr) const
get default bool value
double getDefaultDoubleValue(SumoXMLAttr attr) const
get default double value
SUMOTime getDefaultTimeValue(SumoXMLAttr attr) const
get default time value
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEUndoList * getUndoList() const
get the undoList object
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawContourGeometry(const GUIGeometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:319
double x() const
Returns the x-position.
Definition Position.h:52
double y() const
Returns the y-position.
Definition Position.h:57
double length2D() const
Returns the length.
double length() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor BLACK
Definition RGBColor.h:196
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
static const RGBColor RED
named colors
Definition RGBColor.h:188
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
bool showAdditionals() const
check if additionals has to be drawn
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool showConnections() const
check if select show connections checkbox is enabled
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const RGBColor E2Color
color for E2 detectors
static const double E2Width
E2 detector widths.
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double additionalGeometryPointRadius
moving additional geometry point radius
A structure which describes a connection between edges or lanes.
Definition NBEdge.h:201