SUMO - Simulation of Urban MObility
GNEAdditionalHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // Builds trigger objects for netedit
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNEAdditionalHandler_h
21 #define GNEAdditionalHandler_h
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <vector>
36 #include <utils/geom/Position.h>
37 
38 #include "GNECalibrator.h"
39 #include "GNEVariableSpeedSign.h"
40 #include "GNERerouterInterval.h"
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 
46 class GNENet;
47 class GNEViewNet;
48 class GNEUndoList;
49 class GNEJunction;
50 class GNEEdge;
51 class GNELane;
52 class GNEDetectorE3;
53 class GNECalibrator;
54 
55 // ===========================================================================
56 // class definitions
57 // ===========================================================================
58 
62 public:
64  GNEAdditionalHandler(const std::string& file, GNEViewNet* viewNet, bool undoAdditionals = true);
65 
68 
71 
77  void myStartElement(int element, const SUMOSAXAttributes& attrs);
79 
85 
90  void parseAndBuildVaporizer(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
91 
97  void parseAndBuildVariableSpeedSign(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
98 
103  void parseAndBuildRerouter(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
104 
109  void parseAndBuildBusStop(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
110 
115  void parseAndBuildContainerStop(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
116 
121  void parseAndBuildChargingStation(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
122 
127  void parseAndBuildCalibrator(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
128 
133  void parseAndBuildDetectorE1(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
134 
139  void parseAndBuildDetectorE2(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
140 
145  void parseAndBuildDetectorE3(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
146 
151  void parseAndBuildDetectorEntry(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
152 
157  void parseAndBuildDetectorExit(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
158 
163  void parseAndBuildRouteProbe(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
164 
169  void parseCalibratorRoute(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
170 
175  void parseCalibratorVehicleType(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
176 
181  void parseCalibratorFlow(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
182 
187  void parseVariableSpeedSignStep(const SUMOSAXAttributes& attrs, const SumoXMLTag& tag);
189 
194 
201  static bool buildAdditional(GNEViewNet* viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map<SumoXMLAttr, std::string> values);
202 
216  static bool buildBusStop(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double startPos, double endPos, const std::string& name, const std::vector<std::string>& lines, bool friendlyPosition);
217 
231  static bool buildContainerStop(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double startPos, double endPos, const std::string& name, const std::vector<std::string>& lines, bool friendlyPosition);
232 
249  static bool buildChargingStation(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double startPos, double endPos, const std::string& name, double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay, bool friendlyPosition);
250 
264  static bool buildDetectorE1(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double freq, const std::string& filename, const std::string& vehicleTypes, bool friendlyPos);
265 
283  static bool buildDetectorE2(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double length, double freq, const std::string& filename,
284  bool cont, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos);
285 
298  static bool buildDetectorE3(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, double freq, const std::string& filename, const double timeThreshold, double speedThreshold);
299 
310  static bool buildDetectorEntry(GNEViewNet* viewNet, bool allowUndoRedo, GNEDetectorE3* E3Parent, GNELane* lane, double pos, bool friendlyPos);
311 
322  static bool buildDetectorExit(GNEViewNet* viewNet, bool allowUndoRedo, GNEDetectorE3* E3Parent, GNELane* lane, double pos, bool friendlyPos);
323 
339  static bool buildCalibrator(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, const std::string& outfile, double freq,
340  const std::vector<GNECalibratorRoute>& calibratorRoutes, const std::vector<GNECalibratorFlow>& calibratorFlows,
341  const std::vector<GNECalibratorVehicleType>& calibratorVehicleTypes);
342 
353  static bool buildRerouter(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNEEdge*>& edges, double prob, const std::string& file, bool off);
354 
366  static bool buildRouteProbe(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNEEdge* edge, double freq, const std::string& file, double begin);
367 
378  static bool buildVariableSpeedSign(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNELane*>& destLanes, const std::string& file, const std::vector<GNEVariableSpeedSignStep>& steps);
379 
389  static bool buildVaporizer(GNEViewNet* viewNet, bool allowUndoRedo, GNEEdge* edge, double startTime, double end);
390 
397  std::string getFileName(const SUMOSAXAttributes& attrs, const std::string& base, const bool allowEmpty = false);
398 
406  double getPosition(double pos, GNELane& lane, bool friendlyPos, const std::string& additionalID);
407 
416  static bool fixStoppinPlacePosition(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos);
417 
424  static bool checkAndFixDetectorPositionPosition(double& pos, const double laneLength, const bool friendlyPos);
425 
433  static bool fixE2DetectorPositionPosition(double& pos, double& length, const double laneLength, const bool friendlyPos);
434 
438  void resetLastTag();
439 
440 protected:
443 
446 
449 
452 
455 
458 
461 
463  std::vector<GNECalibratorVehicleType> myLoadingCalibratorVehicleTypes;
464 
466  bool checkAdditionalParent(SumoXMLTag currentTag);
467 
468 private:
470  GNECalibratorFlow::TypeOfFlow getTypeOfFlowDistribution(std::string flowID, double vehsPerHour, double period, double probability);
471 };
472 
473 
474 #endif
void parseVariableSpeedSignStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses step values of VariableSpeedSigns.
SumoXMLTag
Numbers representing SUMO-XML - element names.
void parseCalibratorVehicleType(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses vehicle type values of Calibrators.
void parseCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
void parseAndBuildDetectorE1(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a induction loop detector (E1)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
static bool buildRerouter(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNEEdge * > &edges, double prob, const std::string &file, bool off)
builds a rerouter
bool myUndoAdditionals
flag to check if created additionals must be undo and redo
static bool buildAdditional(GNEViewNet *viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Build additionals.
static bool checkAndFixDetectorPositionPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
void parseAndBuildDetectorExit(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Exit detector.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
std::vector< GNECalibratorVehicleType > myLoadingCalibratorVehicleTypes
vector in wich save calibratorVehicleTypes during loading calibrators
GNEVariableSpeedSign * myVariableSpeedSignParent
Pointer to the last inserted variableSpeedSign.
static bool buildVaporizer(GNEViewNet *viewNet, bool allowUndoRedo, GNEEdge *edge, double startTime, double end)
Builds a vaporizer (lane speed trigger)
SAX-handler base for SUMO-files.
double getPosition(double pos, GNELane &lane, bool friendlyPos, const std::string &additionalID)
extracts the position, checks whether it shall be mirrored and checks whether it is within the lane...
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
static bool buildDetectorEntry(GNEViewNet *viewNet, bool allowUndoRedo, GNEDetectorE3 *E3Parent, GNELane *lane, double pos, bool friendlyPos)
Builds a entry detector (E3)
void parseAndBuildVariableSpeedSign(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Variable Speed Signal (lane speed trigger)
void parseAndBuildDetectorE2(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a lane area detector (E2)
GNECalibratorFlow::TypeOfFlow getTypeOfFlowDistribution(std::string flowID, double vehsPerHour, double period, double probability)
get a error message, if configuration of flow distribution is invalid
~GNEAdditionalHandler()
Destructor.
TypeOfFlow
type of flow
const std::string & getFileName() const
returns the current file name
Encapsulated SAX-Attributes.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
static bool buildRouteProbe(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNEEdge *edge, double freq, const std::string &file, double begin)
builds a Route probe
GNEAdditionalHandler(const std::string &file, GNEViewNet *viewNet, bool undoAdditionals=true)
Constructor.
void parseAndBuildRerouter(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a rerouter.
static bool buildDetectorE2(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, double length, double freq, const std::string &filename, bool cont, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos)
Builds a lane Area Detector (E2)
static bool buildChargingStation(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double startPos, double endPos, const std::string &name, double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay, bool friendlyPosition)
Builds a charging Station.
bool checkAdditionalParent(SumoXMLTag currentTag)
used to check hierarchy of aditionals with parents and childs (for example, E3)
GNEViewNet * myViewNet
pointer to View&#39;s Net
GNECalibrator * myCalibratorParent
Pointer to the last inserted Calibrator.
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
void parseAndBuildRouteProbe(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds routeProbe.
GNEDetectorE3 * myE3Parent
Pointer to the last inserted E3.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
static bool buildContainerStop(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double startPos, double endPos, const std::string &name, const std::vector< std::string > &lines, bool friendlyPosition)
Builds a container stop.
void parseAndBuildBusStop(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a bus stop.
void parseAndBuildContainerStop(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a container stop.
static bool fixE2DetectorPositionPosition(double &pos, double &length, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a vaporization.
void resetLastTag()
reset last Tag and clear non-valid Additionals (For example, created E3 withouts Entry/Exit childs) ...
SumoXMLTag myLastTag
last used Tag
static bool buildDetectorE3(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, double freq, const std::string &filename, const double timeThreshold, double speedThreshold)
Builds a multi entry exit detector (E3)
static bool buildVariableSpeedSign(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNELane * > &destLanes, const std::string &file, const std::vector< GNEVariableSpeedSignStep > &steps)
Builds a VariableSpeedSign (lane speed trigger)
static bool buildBusStop(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double startPos, double endPos, const std::string &name, const std::vector< std::string > &lines, bool friendlyPosition)
Builds a bus stop.
static bool fixStoppinPlacePosition(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check if the position of an stoppingPlace over a lane is valid
GNERerouterInterval * rerouterIntervalToInsertValues
pointer to rerouterInterval in which insert GNEClosingReroute, GNEDestProbReroute, etc.
void parseCalibratorRoute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses route values of Calibrators.
void parseAndBuildDetectorEntry(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Entry detector.
static bool buildDetectorExit(GNEViewNet *viewNet, bool allowUndoRedo, GNEDetectorE3 *E3Parent, GNELane *lane, double pos, bool friendlyPos)
Builds a exit detector (E3)
static bool buildDetectorE1(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, double freq, const std::string &filename, const std::string &vehicleTypes, bool friendlyPos)
Builds a induction loop detector (E1)
static bool buildCalibrator(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, const std::string &outfile, double freq, const std::vector< GNECalibratorRoute > &calibratorRoutes, const std::vector< GNECalibratorFlow > &calibratorFlows, const std::vector< GNECalibratorVehicleType > &calibratorVehicleTypes)
builds a microscopic calibrator