Skip to content

Commit

Permalink
Updated GNEDemandElement. Refs #12846
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Jun 23, 2023
1 parent 41f7833 commit 5c2e13a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/netedit/elements/demand/GNEDemandElement.cpp
Expand Up @@ -408,7 +408,23 @@ GNEDemandElement::getTypeParent() const {
} else if (getParentDemandElements().at(0)->getTagProperty().getTag() == SUMO_TAG_VTYPE) {
return getParentDemandElements().at(0);
} else {
return nullptr;
// get typeDistribution ID
const auto typeDistributionID = getParentDemandElements().at(0)->getID();
// obtain all types with the given typeDistribution sorted by ID
std::map<std::string, GNEDemandElement*> sortedTypes;
for (const auto &type : myNet->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_VTYPE)) {
if (type->getAttribute(GNE_ATTR_VTYPE_DISTRIBUTION) == typeDistributionID) {
sortedTypes[type->getID()] = type;
}
}
// return first type, or default vType
if (sortedTypes.size() > 0) {
return sortedTypes.begin()->second;
} else if (myNet->getAttributeCarriers()->getDemandElements().size() > 0){
return *myNet->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_VTYPE).begin();
} else {
throw InvalidArgument("no vTypes");
}
}
}

Expand Down

0 comments on commit 5c2e13a

Please sign in to comment.