78 updateFromAttributes(sumoBaseObject);
93 fromTrainStop.clear();
95 fromContainerStop.clear();
96 toContainerStop.clear();
97 fromChargingStation.clear();
98 toChargingStation.clear();
99 fromParkingArea.clear();
100 toParkingArea.clear();
101 consecutiveEdges.clear();
109 if (fromEdge.empty()) {
112 return getNumberOfDefinedParameters() == 1;
119 return (
int)consecutiveEdges.size() +
120 (fromJunction.empty() ? 0 : 1) +
121 (toJunction.empty() ? 0 : 1) +
122 (fromEdge.empty() ? 0 : 1) +
123 (toEdge.empty() ? 0 : 1) +
124 (fromTAZ.empty() ? 0 : 1) +
125 (toTAZ.empty() ? 0 : 1) +
126 (fromBusStop.empty() ? 0 : 1) +
127 (toBusStop.empty() ? 0 : 1) +
128 (fromTrainStop.empty() ? 0 : 1) +
129 (toTrainStop.empty() ? 0 : 1) +
130 (fromContainerStop.empty() ? 0 : 1) +
131 (toContainerStop.empty() ? 0 : 1) +
132 (fromChargingStation.empty() ? 0 : 1) +
133 (toChargingStation.empty() ? 0 : 1) +
134 (fromParkingArea.empty() ? 0 : 1) +
135 (toParkingArea.empty() ? 0 : 1) +
136 (fromRoute.empty() ? 0 : 1) +
137 (toRoute.empty() ? 0 : 1);
144 if (sumoBaseObject ==
nullptr) {
149 if (parentObject ==
nullptr) {
162 return *(objIterator - 1);
170 const auto previousPlanObj = getPreviousPlanObj(sumoBaseObject);
171 if (previousPlanObj) {
173 const auto previousPlanParameters = previousPlanObj->getPlanParameters();
174 if (!previousPlanParameters.toEdge.empty()) {
176 resetPreviousFromAttributes(previousPlanObj,
"edge", previousPlanParameters.toEdge);
177 fromEdge = previousPlanParameters.toEdge;
178 }
else if (!previousPlanParameters.consecutiveEdges.empty()) {
180 resetPreviousFromAttributes(previousPlanObj,
"consecutive edge", previousPlanParameters.consecutiveEdges.back());
181 fromEdge = previousPlanParameters.consecutiveEdges.back();
182 }
else if (!previousPlanParameters.toRoute.empty()) {
184 resetPreviousFromAttributes(previousPlanObj,
"route edge", previousPlanParameters.toRoute);
185 fromRoute = previousPlanParameters.toRoute;
186 }
else if (!previousPlanParameters.toJunction.empty()) {
188 resetPreviousFromAttributes(previousPlanObj,
"junction", previousPlanParameters.toJunction);
189 fromJunction = previousPlanParameters.toJunction;
190 }
else if (!previousPlanParameters.toTAZ.empty()) {
192 resetPreviousFromAttributes(previousPlanObj,
"TAZ", previousPlanParameters.toTAZ);
193 fromTAZ = previousPlanParameters.toTAZ;
194 }
else if (!previousPlanParameters.toBusStop.empty()) {
196 resetPreviousFromAttributes(previousPlanObj,
"bus stop", previousPlanParameters.toBusStop);
197 fromBusStop = previousPlanParameters.toBusStop;
198 }
else if (!previousPlanParameters.toTrainStop.empty()) {
200 resetPreviousFromAttributes(previousPlanObj,
"train stop", previousPlanParameters.toTrainStop);
201 fromTrainStop = previousPlanParameters.toTrainStop;
202 }
else if (!previousPlanParameters.toContainerStop.empty()) {
204 resetPreviousFromAttributes(previousPlanObj,
"container stop", previousPlanParameters.toContainerStop);
205 fromContainerStop = previousPlanParameters.toContainerStop;
206 }
else if (!previousPlanParameters.toChargingStation.empty()) {
208 resetPreviousFromAttributes(previousPlanObj,
"charging station", previousPlanParameters.toChargingStation);
209 fromChargingStation = previousPlanParameters.toChargingStation;
210 }
else if (!previousPlanParameters.toParkingArea.empty()) {
212 resetPreviousFromAttributes(previousPlanObj,
"parking area", previousPlanParameters.toParkingArea);
213 fromParkingArea = previousPlanParameters.toParkingArea;
221 const std::string& newType,
const std::string& newId)
const {
222 if (!fromEdge.empty()) {
223 writeIgnoringMessage(previousPlanObj,
"edge", fromEdge, newType, newId);
225 if (!fromJunction.empty()) {
226 writeIgnoringMessage(previousPlanObj,
"junction", fromJunction, newType, newId);
228 if (!fromTAZ.empty()) {
229 writeIgnoringMessage(previousPlanObj,
"TAZ", fromTAZ, newType, newId);
231 if (!fromBusStop.empty()) {
232 writeIgnoringMessage(previousPlanObj,
"bus stop", fromBusStop, newType, newId);
234 if (!fromTrainStop.empty()) {
235 writeIgnoringMessage(previousPlanObj,
"train stop", fromTrainStop, newType, newId);
237 if (!fromContainerStop.empty()) {
238 writeIgnoringMessage(previousPlanObj,
"container stop", fromContainerStop, newType, newId);
240 if (!fromChargingStation.empty()) {
241 writeIgnoringMessage(previousPlanObj,
"charging station", fromChargingStation, newType, newId);
243 if (!fromParkingArea.empty()) {
244 writeIgnoringMessage(previousPlanObj,
"parking area", fromParkingArea, newType, newId);
251 const std::string& oldType,
const std::string& oldId,
const std::string& newType,
const std::string& newId)
const {
252 WRITE_WARNING(
TLF(
"Ignoring from % '%' used in % '%' and using instead the previous end element % '%'",
264 mySumoBaseObjectParent(parent),
265 myVehicleTypeParameter(
"") {
275 if (mySumoBaseObjectParent) {
276 mySumoBaseObjectParent->removeSumoBaseObjectChild(
this);
279 while (mySumoBaseObjectChildren.size() > 0) {
280 delete mySumoBaseObjectChildren.back();
292 myStringAttributes.clear();
293 myIntAttributes.clear();
294 myDoubleAttributes.clear();
295 myBoolAttributes.clear();
296 myPositionAttributes.clear();
297 myTimeAttributes.clear();
298 myColorAttributes.clear();
299 myStringListAttributes.clear();
300 myDoubleListAttributes.clear();
301 myPositionVectorAttributes.clear();
302 myParameters.clear();
303 mySumoBaseObjectChildren.clear();
305 myDefinedVehicleTypeParameter =
false;
306 myDefinedVehicleParameter =
false;
307 myDefinedStopParameter =
false;
309 while (mySumoBaseObjectChildren.size() > 0) {
310 delete mySumoBaseObjectChildren.back();
341 return mySumoBaseObjectParent;
345std::map<std::string, std::string>
347 std::map<std::string, std::string> result;
348 for (
const auto& attr : myStringAttributes) {
349 result[
toString(attr.first)] = attr.second;
351 for (
const auto& attr : myIntAttributes) {
354 for (
const auto& attr : myDoubleAttributes) {
357 for (
const auto& attr : myBoolAttributes) {
360 for (
const auto& attr : myPositionAttributes) {
363 for (
const auto& attr : myTimeAttributes) {
366 for (
const auto& attr : myColorAttributes) {
369 for (
const auto& attr : myStringListAttributes) {
372 for (
const auto& attr : myDoubleListAttributes) {
375 for (
const auto& attr : myPositionVectorAttributes) {
384 if (hasStringAttribute(attr)) {
385 return myStringAttributes.at(attr);
387 handleAttributeError(attr,
"string");
395 if (hasIntAttribute(attr)) {
396 return myIntAttributes.at(attr);
398 handleAttributeError(attr,
"int");
406 if (hasDoubleAttribute(attr)) {
407 return myDoubleAttributes.at(attr);
409 handleAttributeError(attr,
"double");
417 if (hasBoolAttribute(attr)) {
418 return myBoolAttributes.at(attr);
420 handleAttributeError(attr,
"bool");
428 if (hasPositionAttribute(attr)) {
429 return myPositionAttributes.at(attr);
431 handleAttributeError(attr,
"position");
439 if (hasTimeAttribute(attr)) {
440 return myTimeAttributes.at(attr);
442 handleAttributeError(attr,
"time");
451 if (hasTimeAttribute(attr)) {
452 return myTimeAttributes.at(attr);
456 if (hasTimeAttribute(attr)) {
457 return myTimeAttributes.at(attr);
467 if (hasColorAttribute(attr)) {
468 return myColorAttributes.at(attr);
470 handleAttributeError(attr,
"color");
476const std::vector<std::string>&
478 if (hasStringListAttribute(attr)) {
479 return myStringListAttributes.at(attr);
481 handleAttributeError(attr,
"string list");
487const std::vector<double>&
489 if (hasDoubleListAttribute(attr)) {
490 return myDoubleListAttributes.at(attr);
492 handleAttributeError(attr,
"double list");
500 if (hasPositionVectorAttribute(attr)) {
501 return myPositionVectorAttributes.at(attr);
503 handleAttributeError(attr,
"position vector");
517 if (myDefinedVehicleTypeParameter) {
518 return myVehicleTypeParameter;
527 if (myDefinedVehicleParameter) {
528 return myVehicleParameter;
537 if (myDefinedStopParameter) {
538 return myStopParameter;
546const std::map<std::string, std::string>&
554 return myPlanParameters;
558const std::vector<CommonXMLStructure::SumoBaseObject*>&
560 return mySumoBaseObjectChildren;
566 return myStringAttributes.count(attr) > 0;
572 return myIntAttributes.count(attr) > 0;
578 return myDoubleAttributes.count(attr) > 0;
584 return myBoolAttributes.count(attr) > 0;
590 return myPositionAttributes.count(attr) > 0;
596 return myTimeAttributes.count(attr) > 0;
602 return myColorAttributes.count(attr) > 0;
608 return myStringListAttributes.count(attr) > 0;
614 return myDoubleListAttributes.count(attr) > 0;
620 return myPositionVectorAttributes.count(attr) > 0;
626 myStringAttributes[attr] = value;
632 myIntAttributes[attr] = value;
638 myDoubleAttributes[attr] = value;
644 myBoolAttributes[attr] = value;
650 myPositionAttributes[attr] = value;
656 myTimeAttributes[attr] = value;
662 myColorAttributes[attr] = value;
668 myStringListAttributes[attr] = value;
674 myDoubleListAttributes[attr] = value;
680 myPositionVectorAttributes[attr] = value;
687 if (myDefinedVehicleTypeParameter) {
688 myVehicleTypeParameter.setParameter(key, value);
689 }
else if (myDefinedVehicleParameter) {
690 myVehicleParameter.setParameter(key, value);
691 }
else if (myDefinedStopParameter) {
692 myStopParameter.setParameter(key, value);
694 myParameters[key] = value;
707 myVehicleTypeParameter = *vehicleTypeParameter;
708 myDefinedVehicleTypeParameter =
true;
710 addStringAttribute(
SUMO_ATTR_ID, myVehicleTypeParameter.id);
716 myVehicleParameter = *vehicleParameter;
717 myDefinedVehicleParameter =
true;
719 if (!myVehicleParameter.id.empty()) {
720 addStringAttribute(
SUMO_ATTR_ID, myVehicleParameter.id);
723 if (!vehicleParameter->
routeid.empty()) {
731 myStopParameter = stopParameter;
732 myDefinedStopParameter =
true;
734 if (!myStopParameter.edge.empty()) {
738 if (!myStopParameter.lane.empty()) {
742 if (!myStopParameter.busstop.empty()) {
746 if (!myStopParameter.containerstop.empty()) {
750 if (!myStopParameter.parkingarea.empty()) {
754 if (!myStopParameter.chargingStation.empty()) {
762 myPlanParameters = planParameters;
768 mySumoBaseObjectChildren.push_back(sumoBaseObject);
775 auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
777 if (it != mySumoBaseObjectChildren.end()) {
778 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 markAsCreated()
mark as successfully created
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
bool wasCreated() const
check if the object was successfully created in build<...> function
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.