Eclipse SUMO - Simulation of Urban MObility
GNEDetector.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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
26 
27 #include "GNEDetector.h"
28 
29 
30 // ===========================================================================
31 // member method definitions
32 // ===========================================================================
33 
34 GNEDetector::GNEDetector(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag,
35  double pos, SUMOTime freq, const std::string& filename, const std::string& vehicleTypes,
36  const std::string& name, bool friendlyPos, bool blockMovement, const std::vector<GNELane*>& laneParents) :
37  GNEAdditional(id, viewNet, type, tag, name, blockMovement, {}, laneParents, {}, {}, {}, {}, {}, {}, {}, {}),
38  myPositionOverLane(pos),
39  myFreq(freq),
40  myFilename(filename),
41  myVehicleTypes(vehicleTypes),
42 myFriendlyPosition(friendlyPos) {
43 }
44 
45 
47  double pos, SUMOTime freq, const std::string& filename,
48  const std::string& name, bool friendlyPos, bool blockMovement, const std::vector<GNELane*>& laneParents) :
49  GNEAdditional(additionalParent, viewNet, type, tag, name, blockMovement,
50 {}, laneParents, {}, {additionalParent}, {}, {}, {}, {}, {}, {}),
51 myPositionOverLane(pos),
52 myFreq(freq),
53 myFilename(filename),
54 myFriendlyPosition(friendlyPos) {
55 }
56 
57 
59 
60 
61 double
63  return myPositionOverLane;
64 }
65 
66 
67 GNELane*
69  return getLaneParents().front();
70 }
71 
72 
76 }
77 
78 
81  if (myGeometry.multiShapeUnified.size() > 0) {
83  } else {
84  return myGeometry.shape.getBoxBoundary().grow(10);
85  }
86 }
87 
88 
89 double
91  double fixedPos = myPositionOverLane;
92  const double len = getLane()->getParentEdge().getNBEdge()->getFinalLength();
93  if (fixedPos < 0) {
94  fixedPos += len;
95  }
97  return fixedPos * getLane()->getLengthGeometryFactor();
98 }
99 
100 
101 std::string
103  return getLane()->getMicrosimID();
104 }
105 
106 
107 std::string
109  return getTagStr() + ": " + getID();
110 }
111 
112 
113 std::string
115  return getTagStr();
116 }
117 
118 /****************************************************************************/
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1187
GNEAdditional::AdditionalGeometry::shape
PositionVector shape
The shape of the additional element.
Definition: GNEAdditional.h:68
GNEDetector::~GNEDetector
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:58
GNEDetector::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:74
GNEDetector::getPositionOverLane
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:62
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
GNEViewNet
Definition: GNEViewNet.h:43
GNEDetector::myPositionOverLane
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:161
PositionVector::getBoxBoundary
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Definition: PositionVector.cpp:382
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
GNENetElement::NetElementGeometry::shape
PositionVector shape
The shape of the netElement element.
Definition: GNENetElement.h:57
GNEDetector::getGeometryPositionOverLane
double getGeometryPositionOverLane() const
get position over lane that is applicable to the shape
Definition: GNEDetector.cpp:90
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:40
GNEHierarchicalElementParents::getLaneParents
const std::vector< GNELane * > & getLaneParents() const
get lanes of VSS
Definition: GNEHierarchicalElementParents.cpp:182
GNEDetector::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEDetector.cpp:102
GNEEdge::getNBEdge
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:625
GNEAdditionalHandler.h
PositionVector::positionAtOffset
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Definition: PositionVector.cpp:246
GNELane::getLengthGeometryFactor
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1355
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNELane::getParentEdge
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1292
GNEDetector::getLane
GNELane * getLane() const
get lane
Definition: GNEDetector.cpp:68
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEEdge.h
GNELane.h
GNENetElement::getGeometry
const NetElementGeometry & getGeometry() const
Definition: GNENetElement.cpp:95
GNEDetector::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEDetector.cpp:114
GNEDetector::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEDetector.cpp:80
GNEDetector.h
GNEAdditional::myGeometry
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
Definition: GNEAdditional.h:368
NBEdge::getFinalLength
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:3704
GNEDetector::GNEDetector
GNEDetector(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, double pos, SUMOTime freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, bool friendlyPos, bool blockMovement, const std::vector< GNELane * > &laneParents)
Constructor.
Definition: GNEDetector.cpp:34
config.h
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1165
GNEAdditional::AdditionalGeometry::multiShapeUnified
PositionVector multiShapeUnified
multi shape unified
Definition: GNEAdditional.h:86
GUIGlObject::getMicrosimID
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.cpp:164
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
GNEAdditionalHandler::checkAndFixDetectorPosition
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
Definition: GNEAdditionalHandler.cpp:977
GNEDetector::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEDetector.cpp:108