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}, {}, {}, {}, {}, {}, {}),
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 /****************************************************************************/
SumoXMLTag
Numbers representing SUMO-XML - element names.
long long int SUMOTime
Definition: SUMOTime.h:35
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:62
PositionVector shape
The shape of the netElement element.
Definition: GNENetElement.h:57
PositionVector multiShapeUnified
multi shape unified
Definition: GNEAdditional.h:86
std::string getParentName() const
Returns the name of the parent object.
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
GUIGlObjectType
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:58
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEDetector.cpp:80
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:625
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
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1292
double getGeometryPositionOverLane() const
get position over lane that is applicable to the shape
Definition: GNEDetector.cpp:90
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
PositionVector shape
The shape of the additional element.
Definition: GNEAdditional.h:68
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:74
const std::vector< GNELane * > & getLaneParents() const
get lanes of VSS
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:170
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1355
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
const std::string getID() const
function to support debugging
const NetElementGeometry & getGeometry() const
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:173
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:3704
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:167
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:164
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
const std::string & getTagStr() const
get tag assigned to this object in string format
GNELane * getLane() const
get lane
Definition: GNEDetector.cpp:68
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:161