Skip to content

Commit

Permalink
reading more attributes. refs #4916
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Dec 18, 2018
1 parent f95affc commit f38c0c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/guisim/GUINet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,18 @@ GUINet::getEdgeData(const MSEdge* edge, const std::string& attr) {

void
GUINet::DiscoverAttributes::myStartElement(int element, const SUMOSAXAttributes& attrs) {
if (element == SUMO_TAG_EDGE && edgeAttrs.size() == 0) {
edgeAttrs = attrs.getAttributeNames();
edgeAttrs.erase(std::find(edgeAttrs.begin(), edgeAttrs.end(), "id"));
if (element == SUMO_TAG_EDGE || element == SUMO_TAG_LANE) {
std::vector<std::string> tmp = attrs.getAttributeNames();
edgeAttrs.insert(tmp.begin(), tmp.end());
}
}

std::vector<std::string>
GUINet::DiscoverAttributes::getEdgeAttrs() {
edgeAttrs.erase(toString(SUMO_ATTR_ID));
return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
}

void
GUINet::EdgeFloatTimeLineRetriever_GUI::addEdgeWeight(const std::string& id,
double value, double begTime, double endTime) const {
Expand All @@ -579,14 +585,15 @@ GUINet::loadEdgeData(const std::string& file) {
// discover edge attributes
DiscoverAttributes discoveryHandler(file);
XMLSubSys::runParser(discoveryHandler, file);
std::vector<std::string> attrs = discoveryHandler.getEdgeAttrs();
WRITE_MESSAGE("Loading edgedata from '" + file
+ "' Found attributes " + toString(discoveryHandler.edgeAttrs.size())
+ ": " + toString(discoveryHandler.edgeAttrs));
+ "' Found attributes " + toString(attrs.size())
+ ": " + toString(attrs));
// create a retriever for each attribute
std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
retrieverDefsInternal.reserve(discoveryHandler.edgeAttrs.size());
retrieverDefsInternal.reserve(attrs.size());
std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
for (const std::string& attr : discoveryHandler.edgeAttrs) {
for (const std::string& attr : attrs) {
MSEdgeWeightsStorage* ws = new MSEdgeWeightsStorage();
myLoadedEdgeData[attr] = ws;
retrieverDefsInternal.push_back(EdgeFloatTimeLineRetriever_GUI(ws));
Expand Down
4 changes: 3 additions & 1 deletion src/guisim/GUINet.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ class GUINet : public MSNet, public GUIGlObject {
DiscoverAttributes(const std::string& file): SUMOSAXHandler(file) {};
~DiscoverAttributes() {};
void myStartElement(int element, const SUMOSAXAttributes& attrs);
std::vector<std::string> edgeAttrs;
std::vector<std::string> getEdgeAttrs();
private:
std::set<std::string> edgeAttrs;
};

class EdgeFloatTimeLineRetriever_GUI : public SAXWeightsHandler::EdgeFloatTimeLineRetriever {
Expand Down

0 comments on commit f38c0c6

Please sign in to comment.