77 updateFromAttributes(sumoBaseObject);
91 fromTrainStop.clear();
93 fromContainerStop.clear();
94 toContainerStop.clear();
95 fromChargingStation.clear();
96 toChargingStation.clear();
97 fromParkingArea.clear();
98 toParkingArea.clear();
99 consecutiveEdges.clear();
107 if (fromEdge.empty()) {
110 return getNumberOfDefinedParameters() == 1;
117 return (
int)consecutiveEdges.size() +
118 (fromJunction.empty() ? 0 : 1) +
119 (toJunction.empty() ? 0 : 1) +
120 (fromEdge.empty() ? 0 : 1) +
121 (toEdge.empty() ? 0 : 1) +
122 (fromTAZ.empty() ? 0 : 1) +
123 (toTAZ.empty() ? 0 : 1) +
124 (fromBusStop.empty() ? 0 : 1) +
125 (toBusStop.empty() ? 0 : 1) +
126 (fromTrainStop.empty() ? 0 : 1) +
127 (toTrainStop.empty() ? 0 : 1) +
128 (fromContainerStop.empty() ? 0 : 1) +
129 (toContainerStop.empty() ? 0 : 1) +
130 (fromChargingStation.empty() ? 0 : 1) +
131 (toChargingStation.empty() ? 0 : 1) +
132 (fromParkingArea.empty() ? 0 : 1) +
133 (toParkingArea.empty() ? 0 : 1) +
134 (fromRoute.empty() ? 0 : 1) +
135 (toRoute.empty() ? 0 : 1);
142 if (sumoBaseObject ==
nullptr) {
147 if (parentObject ==
nullptr) {
160 return *(objIterator - 1);
168 const auto previousPlanObj = getPreviousPlanObj(sumoBaseObject);
169 if (previousPlanObj) {
171 const auto previousPlanParameters = previousPlanObj->getPlanParameters();
172 if (!previousPlanParameters.toEdge.empty()) {
174 resetPreviousFromAttributes(previousPlanObj,
"edge", previousPlanParameters.toEdge);
175 fromEdge = previousPlanParameters.toEdge;
176 }
else if (!previousPlanParameters.consecutiveEdges.empty()) {
178 resetPreviousFromAttributes(previousPlanObj,
"consecutive edge", previousPlanParameters.consecutiveEdges.back());
179 fromEdge = previousPlanParameters.consecutiveEdges.back();
180 }
else if (!previousPlanParameters.toRoute.empty()) {
182 resetPreviousFromAttributes(previousPlanObj,
"route edge", previousPlanParameters.toRoute);
183 fromRoute = previousPlanParameters.toRoute;
184 }
else if (!previousPlanParameters.toJunction.empty()) {
186 resetPreviousFromAttributes(previousPlanObj,
"junction", previousPlanParameters.toJunction);
187 fromJunction = previousPlanParameters.toJunction;
188 }
else if (!previousPlanParameters.toTAZ.empty()) {
190 resetPreviousFromAttributes(previousPlanObj,
"TAZ", previousPlanParameters.toTAZ);
191 fromTAZ = previousPlanParameters.toTAZ;
192 }
else if (!previousPlanParameters.toBusStop.empty()) {
194 resetPreviousFromAttributes(previousPlanObj,
"bus stop", previousPlanParameters.toBusStop);
195 fromBusStop = previousPlanParameters.toBusStop;
196 }
else if (!previousPlanParameters.toTrainStop.empty()) {
198 resetPreviousFromAttributes(previousPlanObj,
"train stop", previousPlanParameters.toTrainStop);
199 fromTrainStop = previousPlanParameters.toTrainStop;
200 }
else if (!previousPlanParameters.toContainerStop.empty()) {
202 resetPreviousFromAttributes(previousPlanObj,
"container stop", previousPlanParameters.toContainerStop);
203 fromContainerStop = previousPlanParameters.toContainerStop;
204 }
else if (!previousPlanParameters.toChargingStation.empty()) {
206 resetPreviousFromAttributes(previousPlanObj,
"charging station", previousPlanParameters.toChargingStation);
207 fromChargingStation = previousPlanParameters.toChargingStation;
208 }
else if (!previousPlanParameters.toParkingArea.empty()) {
210 resetPreviousFromAttributes(previousPlanObj,
"parking area", previousPlanParameters.toParkingArea);
211 fromParkingArea = previousPlanParameters.toParkingArea;
219 const std::string& newType,
const std::string& newId)
const {
220 if (!fromEdge.empty()) {
221 writeIgnoringMessage(previousPlanObj,
"edge", fromEdge, newType, newId);
223 if (!fromJunction.empty()) {
224 writeIgnoringMessage(previousPlanObj,
"junction", fromJunction, newType, newId);
226 if (!fromTAZ.empty()) {
227 writeIgnoringMessage(previousPlanObj,
"TAZ", fromTAZ, newType, newId);
229 if (!fromBusStop.empty()) {
230 writeIgnoringMessage(previousPlanObj,
"bus stop", fromBusStop, newType, newId);
232 if (!fromTrainStop.empty()) {
233 writeIgnoringMessage(previousPlanObj,
"train stop", fromTrainStop, newType, newId);
235 if (!fromContainerStop.empty()) {
236 writeIgnoringMessage(previousPlanObj,
"container stop", fromContainerStop, newType, newId);
238 if (!fromChargingStation.empty()) {
239 writeIgnoringMessage(previousPlanObj,
"charging station", fromChargingStation, newType, newId);
241 if (!fromParkingArea.empty()) {
242 writeIgnoringMessage(previousPlanObj,
"parking area", fromParkingArea, newType, newId);
249 const std::string& oldType,
const std::string& oldId,
const std::string& newType,
const std::string& newId)
const {
250 WRITE_WARNING(
TLF(
"Ignoring from % '%' used in % '%' and using instead the previous end element % '%'",
262 mySumoBaseObjectParent(parent),
265 myVehicleTypeParameter(
""),
266 myDefinedVehicleTypeParameter(false),
267 myDefinedVehicleParameter(false),
268 myDefinedStopParameter(false) {
278 if (mySumoBaseObjectParent) {
279 mySumoBaseObjectParent->removeSumoBaseObjectChild(
this);
282 while (mySumoBaseObjectChildren.size() > 0) {
283 delete mySumoBaseObjectChildren.back();
295 myStringAttributes.clear();
296 myIntAttributes.clear();
297 myDoubleAttributes.clear();
298 myBoolAttributes.clear();
299 myPositionAttributes.clear();
300 myTimeAttributes.clear();
301 myColorAttributes.clear();
302 myStringListAttributes.clear();
303 myDoubleListAttributes.clear();
304 myPositionVectorAttributes.clear();
305 myParameters.clear();
306 mySumoBaseObjectChildren.clear();
308 myDefinedVehicleTypeParameter =
false;
309 myDefinedVehicleParameter =
false;
310 myDefinedStopParameter =
false;
312 while (mySumoBaseObjectChildren.size() > 0) {
313 delete mySumoBaseObjectChildren.back();
332 return mySumoBaseObjectParent;
336std::map<std::string, std::string>
338 std::map<std::string, std::string> result;
339 for (
const auto& attr : myStringAttributes) {
340 result[
toString(attr.first)] = attr.second;
342 for (
const auto& attr : myIntAttributes) {
345 for (
const auto& attr : myDoubleAttributes) {
348 for (
const auto& attr : myBoolAttributes) {
351 for (
const auto& attr : myPositionAttributes) {
354 for (
const auto& attr : myTimeAttributes) {
357 for (
const auto& attr : myColorAttributes) {
360 for (
const auto& attr : myStringListAttributes) {
363 for (
const auto& attr : myDoubleListAttributes) {
366 for (
const auto& attr : myPositionVectorAttributes) {
375 if (hasStringAttribute(attr)) {
376 return myStringAttributes.at(attr);
378 handleAttributeError(attr,
"string");
386 if (hasIntAttribute(attr)) {
387 return myIntAttributes.at(attr);
389 handleAttributeError(attr,
"int");
397 if (hasDoubleAttribute(attr)) {
398 return myDoubleAttributes.at(attr);
400 handleAttributeError(attr,
"double");
408 if (hasBoolAttribute(attr)) {
409 return myBoolAttributes.at(attr);
411 handleAttributeError(attr,
"bool");
419 if (hasPositionAttribute(attr)) {
420 return myPositionAttributes.at(attr);
422 handleAttributeError(attr,
"position");
430 if (hasTimeAttribute(attr)) {
431 return myTimeAttributes.at(attr);
433 handleAttributeError(attr,
"time");
442 if (hasTimeAttribute(attr)) {
443 return myTimeAttributes.at(attr);
447 if (hasTimeAttribute(attr)) {
448 return myTimeAttributes.at(attr);
458 if (hasColorAttribute(attr)) {
459 return myColorAttributes.at(attr);
461 handleAttributeError(attr,
"color");
467const std::vector<std::string>&
469 if (hasStringListAttribute(attr)) {
470 return myStringListAttributes.at(attr);
472 handleAttributeError(attr,
"string list");
478const std::vector<double>&
480 if (hasDoubleListAttribute(attr)) {
481 return myDoubleListAttributes.at(attr);
483 handleAttributeError(attr,
"double list");
491 if (hasPositionVectorAttribute(attr)) {
492 return myPositionVectorAttributes.at(attr);
494 handleAttributeError(attr,
"position vector");
508 if (myDefinedVehicleTypeParameter) {
509 return myVehicleTypeParameter;
518 if (myDefinedVehicleParameter) {
519 return myVehicleParameter;
528 if (myDefinedStopParameter) {
529 return myStopParameter;
537const std::map<std::string, std::string>&
545 return myPlanParameters;
549const std::vector<CommonXMLStructure::SumoBaseObject*>&
551 return mySumoBaseObjectChildren;
557 return myStringAttributes.count(attr) > 0;
563 return myIntAttributes.count(attr) > 0;
569 return myDoubleAttributes.count(attr) > 0;
575 return myBoolAttributes.count(attr) > 0;
581 return myPositionAttributes.count(attr) > 0;
587 return myTimeAttributes.count(attr) > 0;
593 return myColorAttributes.count(attr) > 0;
599 return myStringListAttributes.count(attr) > 0;
605 return myDoubleListAttributes.count(attr) > 0;
611 return myPositionVectorAttributes.count(attr) > 0;
617 myStringAttributes[attr] = value;
623 myIntAttributes[attr] = value;
629 myDoubleAttributes[attr] = value;
635 myBoolAttributes[attr] = value;
641 myPositionAttributes[attr] = value;
647 myTimeAttributes[attr] = value;
653 myColorAttributes[attr] = value;
659 myStringListAttributes[attr] = value;
665 myDoubleListAttributes[attr] = value;
671 myPositionVectorAttributes[attr] = value;
678 if (myDefinedVehicleTypeParameter) {
679 myVehicleTypeParameter.setParameter(key, value);
680 }
else if (myDefinedVehicleParameter) {
681 myVehicleParameter.setParameter(key, value);
682 }
else if (myDefinedStopParameter) {
683 myStopParameter.setParameter(key, value);
685 myParameters[key] = value;
698 myVehicleTypeParameter = *vehicleTypeParameter;
699 myDefinedVehicleTypeParameter =
true;
701 addStringAttribute(
SUMO_ATTR_ID, myVehicleTypeParameter.id);
707 myVehicleParameter = *vehicleParameter;
708 myDefinedVehicleParameter =
true;
710 if (!myVehicleParameter.id.empty()) {
711 addStringAttribute(
SUMO_ATTR_ID, myVehicleParameter.id);
714 if (!vehicleParameter->
routeid.empty()) {
722 myStopParameter = stopParameter;
723 myDefinedStopParameter =
true;
725 if (!myStopParameter.edge.empty()) {
729 if (!myStopParameter.lane.empty()) {
733 if (!myStopParameter.busstop.empty()) {
737 if (!myStopParameter.containerstop.empty()) {
741 if (!myStopParameter.parkingarea.empty()) {
745 if (!myStopParameter.chargingStation.empty()) {
753 myPlanParameters = planParameters;
759 mySumoBaseObjectChildren.push_back(sumoBaseObject);
766 auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
768 if (it != mySumoBaseObjectChildren.end()) {
769 mySumoBaseObjectChildren.erase(it);
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_ROOTFILE
root file
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_FROM_TRAINSTOP
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_CHARGING_STATION
@ GNE_ATTR_FROM_PARKINGAREA
@ GNE_ATTR_FROM_CONTAINERSTOP
@ GNE_ATTR_FROM_CHARGINGSTATION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
plan parameters (used for group all from-to parameters related with plans)
void writeIgnoringMessage(const CommonXMLStructure::SumoBaseObject *previousPlanObj, const std::string &oldType, const std::string &oldId, const std::string &newType, const std::string &newId) const
write ignoring message
int getNumberOfDefinedParameters() const
get number of defined plans
const CommonXMLStructure::SumoBaseObject * getPreviousPlanObj(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get previous plan obj
void clear()
clear parameters
bool isSingleEdgePlan() const
check if this is a single-edge plan
void updateFromAttributes(const CommonXMLStructure::SumoBaseObject *sumoBaseObject)
update the from attributes
void resetPreviousFromAttributes(const CommonXMLStructure::SumoBaseObject *previousPlanObj, const std::string &newType, const std::string &newId) const
reste all previous from attributes
void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector< double > &value)
add double list attribute into current SumoBaseObject node
const std::vector< double > & getDoubleListAttribute(const SumoXMLAttr attr) const
get double list attribute
void addIntAttribute(const SumoXMLAttr attr, const int value)
add int attribute into current SumoBaseObject node
void setVehicleTypeParameter(const SUMOVTypeParameter *vehicleTypeParameter)
set vehicle type parameters
void addSumoBaseObjectChild(SumoBaseObject *sumoBaseObject)
add SumoBaseObject child
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
const PositionVector & getPositionVectorAttribute(const SumoXMLAttr attr) const
get PositionVector attribute
SumoBaseObject(SumoBaseObject *sumoBaseObjectParent)
constructor
bool hasBoolAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given bool attribute
void removeSumoBaseObjectChild(SumoBaseObject *sumoBaseObject)
remove SumoBaseObject child
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
std::map< std::string, std::string > getAllAttributes() const
get all attributes in string format
bool hasPositionAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given bool attribute
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
const Position & getPositionAttribute(const SumoXMLAttr attr) const
get Position attribute
const CommonXMLStructure::PlanParameters & getPlanParameters() const
get plan parameteres
void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector &value)
add PositionVector attribute into current SumoBaseObject node
const std::map< std::string, std::string > & getParameters() const
get parameters
SUMOVehicleClass getVClass() const
vehicle class
SumoBaseObject * mySumoBaseObjectParent
pointer to SumoBaseObject parent (If is null, then is the root)
bool hasPositionVectorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given positionVector attribute
bool hasTimeAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given time attribute
void addBoolAttribute(const SumoXMLAttr attr, const bool value)
add bool attribute into current SumoBaseObject node
void setPlanParameters(const CommonXMLStructure::PlanParameters &planParameters)
set plan parmeter
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
SumoXMLTag getTag() const
get XML myTag
void addParameter(const std::string &key, const std::string &value)
add parameter into current SumoBaseObject node
~SumoBaseObject()
destructor
bool hasColorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given color attribute
void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value)
add time attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
bool hasIntAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given int attribute
int getIntAttribute(const SumoXMLAttr attr) const
get int attribute
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void handleAttributeError(const SumoXMLAttr attr, const std::string &type) const
handle attribute error
bool hasDoubleAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given double attribute
void addPositionAttribute(const SumoXMLAttr attr, const Position &value)
add Position attribute into current SumoBaseObject node
bool getBoolAttribute(const SumoXMLAttr attr) const
get bool attribute
void setVClass(SUMOVehicleClass vClass)
set vehicle class
SUMOTime getPeriodAttribute() const
get 'period' attribute
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
void setStopParameter(const SUMOVehicleParameter::Stop &stopParameter)
add stop parameters
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
const SUMOVehicleParameter & getVehicleParameter() const
get vehicle parameters
bool hasDoubleListAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given double list attribute
const std::vector< std::string > & getStringListAttribute(const SumoXMLAttr attr) const
get string list attribute
bool hasStringListAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given string list attribute
void clear()
clear SumoBaseObject
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
void abortSUMOBaseOBject()
abort SUMOBaseOBject
CommonXMLStructure::SumoBaseObject * getSumoBaseObjectRoot() const
get SumoBaseObject root
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
void openSUMOBaseOBject()
open SUMOBaseOBject
CommonXMLStructure::SumoBaseObject * mySumoBaseObjectRoot
SumoBaseObject root.
CommonXMLStructure()
Constructor.
CommonXMLStructure::SumoBaseObject * myCurrentSumoBaseObject
last inserted SumoBaseObject
void closeSUMOBaseOBject()
close SUMOBaseOBject
~CommonXMLStructure()
Destructor.
A point in 2D or 3D with translation and scaling methods.
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
std::string routeid
The vehicle's route id.