 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
55 shapeRotations.clear();
63 int numberOfSegments = (int)shape.size() - 1;
65 if (numberOfSegments >= 0) {
67 shapeRotations.reserve(numberOfSegments);
68 shapeLengths.reserve(numberOfSegments);
70 for (
int i = 0; i < numberOfSegments; ++i) {
78 shapeRotations.push_back((
double)atan2((s.
x() - f.
x()), (f.
y() - s.
y())) * (double) 180.0 / (
double)
M_PI);
107 rotation(_rotation) {
135 myShapeSegments.push_back(
Segment(element, edge, pos, visible, valid));
142 myShapeSegments.push_back(
Segment(element, edge, pos, length, rotation, visible, valid));
149 myShapeSegments.push_back(
Segment(element, junction, pos, visible, valid));
156 myShapeSegments.clear();
163 int numberOfSegments = (int)myShapeSegments.size() - 1;
165 if (numberOfSegments >= 0) {
167 for (
int i = 0; i < numberOfSegments; ++i) {
169 if (myShapeSegments[i].length == -1) {
171 const Position& f = myShapeSegments[i].pos;
173 const Position& s = myShapeSegments[i + 1].pos;
177 myShapeSegments[i].rotation = ((double)atan2((s.
x() - f.
x()), (f.
y() - s.
y())) * (double) 180.0 / (
double)
M_PI);
184 std::vector<GNEDemandElement::DemandElementSegmentGeometry::Segment>::const_iterator
186 return myShapeSegments.cbegin();
190 std::vector<GNEDemandElement::DemandElementSegmentGeometry::Segment>::const_iterator
192 return myShapeSegments.cend();
208 delete myDijkstraRouter;
215 if (myDijkstraRouter) {
216 delete myDijkstraRouter;
219 myNet->getNetBuilder()->getEdgeCont().getAllRouterEdges(),
224 std::vector<GNEEdge*>
227 std::vector<GNEEdge*> solution;
229 if (partialEdges.size() == 1) {
231 solution.push_back(partialEdges.front());
234 NBVehicle tmpVehicle(
"temporalNBVehicle", vClass);
236 GNENet* net = partialEdges.front()->getNet();
238 for (
int i = 1; i < (int)partialEdges.size(); i++) {
240 std::vector<const NBRouterEdge*> partialRoute;
241 myDijkstraRouter->compute(partialEdges.at(i - 1)->getNBEdge(), partialEdges.at(i)->getNBEdge(), &tmpVehicle, 10, partialRoute);
243 for (
const auto& j : partialRoute) {
249 auto solutionIt = solution.begin();
251 while (solutionIt != solution.end()) {
252 if ((solutionIt + 1) != solution.end()) {
254 if (*solutionIt == *(solutionIt + 1)) {
255 solutionIt = solution.erase(solutionIt);
267 std::vector<GNEEdge*>
270 std::vector<GNEEdge*> partialEdges;
271 partialEdges.reserve(partialEdgesStr.size());
273 for (
const auto& i : partialEdgesStr) {
277 return calculateDijkstraRoute(vClass, partialEdges);
309 const std::vector<GNEEdge*>& edgeParents,
310 const std::vector<GNELane*>& laneParents,
311 const std::vector<GNEShape*>& shapeParents,
312 const std::vector<GNEAdditional*>& additionalParents,
313 const std::vector<GNEDemandElement*>& demandElementParents,
314 const std::vector<GNEEdge*>& edgeChildren,
315 const std::vector<GNELane*>& laneChildren,
316 const std::vector<GNEShape*>& shapeChildren,
317 const std::vector<GNEAdditional*>& additionalChildren,
318 const std::vector<GNEDemandElement*>& demandElementChildren) :
328 const std::vector<GNEEdge*>& edgeParents,
329 const std::vector<GNELane*>& laneParents,
330 const std::vector<GNEShape*>& shapeParents,
331 const std::vector<GNEAdditional*>& additionalParents,
332 const std::vector<GNEDemandElement*>& demandElementParents,
333 const std::vector<GNEEdge*>& edgeChildren,
334 const std::vector<GNELane*>& laneChildren,
335 const std::vector<GNEShape*>& shapeChildren,
336 const std::vector<GNEAdditional*>& additionalChildren,
337 const std::vector<GNEDemandElement*>& demandElementChildren) :
338 GUIGlObject(type, demandElementParent->generateChildID(tag)),
453 new FXMenuCommand(ret, (
"Copy " +
getTagStr() +
" name to clipboard").c_str(),
nullptr, ret,
MID_COPY_NAME);
455 new FXMenuSeparator(ret);
462 new FXMenuSeparator(ret);
490 if (edges.size() == 0) {
493 }
else if (edges.size() == 1) {
498 auto it = edges.begin();
499 while (it != edges.end() - 1) {
503 if (currentEdge->
getID() == nextEdge->
getID()) {
512 "' ins't consecutive to " + nextEdge->
getTagStr() +
" '" + nextEdge->
getID() +
"'");
573 throw ProcessError(
"Calling non-implemented function checkDemandElementChildRestriction during saving of " +
getTagStr() +
". It muss be reimplemented in child class");
void markSegmentGeometryDeprecated()
mark demand element segment geometry as deprecated
GNEViewNet * myViewNet
The GNEViewNet this demand element element belongs.
void updateDijkstraRouter()
update DijkstraRoute (called when SuperMode Demand is selected)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
FXIcon * getIcon() const
get FXIcon associated to this AC
An Element which don't belongs to GNENet but has influency in the simulation.
static void createRouteCalculatorInstance(GNENet *net)
create instance of RouteCalculator
A window containing a gl-object's parameter.
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
const std::string getID() const
function to support debugging
virtual std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
bool isValidDemandElementID(const std::string &newID) const
check if a new demand element ID is valid
#define WRITE_WARNING(msg)
static RouteCalculator * getRouteCalculatorInstance()
obtain instance of RouteCalculator
void calculatePartialShapeRotationsAndLengths()
calculate partial shape, rotations and lengths
static double getTravelTimeStatic(const NBRouterEdge *const edge, const NBVehicle *const, double)
void insertEdgeSegment(const GNEDemandElement *element, const GNEEdge *edge, const Position pos, const bool visible, const bool valid)
insert edge segment
void clearDemandElementSegmentGeometry()
clear demand element geometry
DemandElementGeometry myDemandElementGeometry
demand element geometry
A NBNetBuilder extended by visualisation and editing capabilities.
std::vector< Segment >::const_iterator end() const
end iterator
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
open additional dialog (used in netedit)
const DemandElementSegmentGeometry & getDemandElementSegmentGeometry() const
get demand element segment geometry
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which demand element element is located.
Copy object name - popup entry.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
An special type of Attribute carrier that owns hierarchical elements.
SumoXMLTag
Numbers representing SUMO-XML - element names.
Computes the shortest path through a network using the Dijkstra algorithm.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
NBEdgeCont & getEdgeCont()
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
The representation of a single edge during network building.
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
virtual void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
A road/street connecting two junctions (netedit-version)
void changeDemandElementID(const std::string &newID)
change ID of demand element
virtual Position getPositionInView() const =0
Returns position of demand element in view.
GNENet * getNet() const
get the net object
const DemandElementGeometry & getDemandElementGeometry() const
get demand element geometry
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
GNEDemandElement(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEShape * > &shapeParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEEdge * > &edgeChildren, const std::vector< GNELane * > &laneChildren, const std::vector< GNEShape * > &shapeChildren, const std::vector< GNEAdditional * > &additionalChildren, const std::vector< GNEDemandElement * > &demandElementChildren)
Constructor.
NBNetBuilder * getNetBuilder() const
get net builder
static RouteCalculator * myRouteCalculatorInstance
RouteCalculator instance.
std::vector< Segment >::const_iterator begin() const
begin iterator
void insertJunctionSegment(const GNEDemandElement *element, const GNEJunction *junction, const Position pos, const bool visible, const bool valid)
insert junction segment
SUMOAbstractRouter< NBRouterEdge, NBVehicle > * myDijkstraRouter
SUMO Abstract DijkstraRouter.
virtual bool checkDemandElementChildRestriction() const
check restriction with the number of children
GNENet * myNet
pointer to net
DemandElementSegmentGeometry()
constructor
virtual std::string getAttribute(SumoXMLAttr key) const =0
NBEdge * getNBEdge() const
returns the internal NBEdge
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Supermode currentSupermode
the current supermode
A point in 2D or 3D with translation and scaling methods.
A vehicle as used by router.
double x() const
Returns the x-position.
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
virtual void openDemandElementDialog()
open DemandElement Dialog
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
void updateDemandElementID(const std::string &oldID, GNEDemandElement *demandElement)
update demand element ID in container
struct for pack all variables related with geometry of stop
~RouteCalculator()
destructor
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
bool geometryDeprecated
mark geometry as deprecated (used to avoid multiple updates)
class used to calculate routes in nets
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void insertEdgeLengthRotSegment(const GNEDemandElement *element, const GNEEdge *edge, const Position pos, double length, double rotation, const bool visible, const bool valid)
insert edge segment with length and rotation (used to avoid unnecessary calculation in calculateParti...
bool areEdgesConsecutives(SUMOVehicleClass vClass, GNEEdge *from, GNEEdge *to) const
check if exist a route between the two given consecutives edges
DemandElementSegmentGeometry myDemandElementSegmentGeometry
demand element segment geometry
double y() const
Returns the y-position.
RouteCalculator(GNENet *net)
constructor
struct used for represent segments of demand element geometry
Demanding mode (Routes, Vehicles etc..)
DemandElementGeometry()
constructor
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
Segment(const GNEDemandElement *_element, const GNEEdge *_edge, const Position _pos, const bool _visible, const bool _valid)
parameter constructor for edges
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
const std::string & getDemandElementID() const
returns DemandElement ID
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
static bool isRouteValid(const std::vector< GNEEdge * > &edges, bool report)
check if a route is valid
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
static void deleteRouteCalculatorInstance()
delete instance of RouteCalculator
std::vector< GNEEdge * > calculateDijkstraRoute(SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra route between a list of partial edges
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
struct for pack all variables related with geometry of elemements divided in segments
const std::string & getTagStr() const
get tag assigned to this object in string format
virtual std::string getBegin() const
get begin time of demand element
Copy typed object name - popup entry.
A structure which describes a connection between edges or lanes.
const std::vector< GNEDemandElement * > & getDemandElementChildren() const
return vector of demand elements that have as Parent this edge (For example, Calibrators)
void clearGeometry()
reset geometry
virtual bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
~GNEDemandElement()
Destructor.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
An special type of Attribute carrier that owns hierarchical elements.
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
int getNumberOfAttributes() const
get number of attributes
RouterEdgeVector getAllRouterEdges() const