Eclipse SUMO - Simulation of Urban MObility
GNEDataHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Builds data objects for netedit
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
33 #include <netedit/GNEViewNet.h>
34 #include <netedit/GNENet.h>
35 #include <netedit/GNEUndoList.h>
37 
38 #include "GNEDataHandler.h"
39 
40 
41 // ===========================================================================
42 // member method definitions
43 // ===========================================================================
44 
46  FXDialogBox(viewNet, "Netedit Parameters Help", GUIDesignDialogBox),
47  myViewNet(viewNet),
48  myCounter(0) {
49  // set decoration
50  setDecorations(DECOR_BORDER);
51  // create label
52  myLabel = new FXLabel(this, "counter:", 0, GUIDesignLabelFrameInformation);
53  // create Dialog
54  create();
55  // show in the given position
56  show(PLACEMENT_SCREEN);
57  // refresh APP
58  viewNet->getApp()->refresh();
59  // open as modal dialog (will block all windows until stop() or stopModal() is called)
60  viewNet->getApp()->runModalWhileEvents(this);
61 }
62 
63 
65  myViewNet->getApp()->stopModal(this);
66 }
67 
68 
69 void
71  // update counter
72  myCounter++;
73  // update label
74  myLabel->setText(("Loaded: " + toString(myCounter)).c_str());
75  // repaint
76  repaint();
77 }
78 
79 
80 // ---------------------------------------------------------------------------
81 // GNEAdditionalHandler::HierarchyInsertedDatas method definitions
82 // ---------------------------------------------------------------------------
83 
84 void
86  myInsertedElements.push_back(std::make_pair(tag, std::make_pair(nullptr, nullptr)));
87 }
88 
89 
90 
91 void
93  myInsertedElements.back().second.first = dataIntervalCreated;
94 }
95 
96 
97 void
99  myInsertedElements.back().second.second = genericDataCreated;
100 }
101 
102 
103 void
105  if (!myInsertedElements.empty()) {
106  myInsertedElements.pop_back();
107  }
108 }
109 
110 
113  if (myInsertedElements.size() < 2) {
114  // currently we're finding parent additional in the additional XML root
115  WRITE_WARNING("A " + toString(myInsertedElements.back().first) + " must be declared within the definition of a " + toString(expectedTag) + ".");
116  return nullptr;
117  } else {
118  if (myInsertedElements.size() < 2) {
119  // additional was hierarchically bad loaded, then return nullptr
120  return nullptr;
121  } else if ((myInsertedElements.end() - 2)->second.first == nullptr) {
122  WRITE_WARNING(toString(expectedTag) + " parent of " + toString((myInsertedElements.end() - 1)->first) + " was not loaded sucesfully.");
123  // parent additional wasn't sucesfully loaded, then return nullptr
124  return nullptr;
125  }
126  return nullptr;
127  }
128 }
129 
130 
133  // ierate in reverse mode over myInsertedElements to obtain last inserted additional
134  for (std::vector<std::pair<SumoXMLTag, std::pair<GNEDataInterval*, GNEGenericData* > > >::const_reverse_iterator i = myInsertedElements.rbegin(); i != myInsertedElements.rend(); i++) {
135  // we need to avoid Tag Param because isn't a data element
136  if ((i->first != SUMO_TAG_PARAM) && (i->first == SUMO_TAG_INTERVAL)) {
137  return i->second.first;
138  }
139  }
140  return nullptr;
141 }
142 
143 
146  if (myInsertedElements.size() < 2) {
147  // currently we're finding parent additional in the additional XML root
148  WRITE_WARNING("A " + toString(myInsertedElements.back().first) + " must be declared within the definition of a " + toString(expectedTag) + ".");
149  return nullptr;
150  } else {
151  if (myInsertedElements.size() < 2) {
152  // additional was hierarchically bad loaded, then return nullptr
153  return nullptr;
154  } else if ((myInsertedElements.end() - 2)->second.second == nullptr) {
155  WRITE_WARNING(toString(expectedTag) + " parent of " + toString((myInsertedElements.end() - 1)->first) + " was not loaded sucesfully.");
156  // parent additional wasn't sucesfully loaded, then return nullptr
157  return nullptr;
158  }
159  return nullptr;
160  }
161 }
162 
163 
166  // ierate in reverse mode over myInsertedElements to obtain last inserted additional
167  for (std::vector<std::pair<SumoXMLTag, std::pair<GNEDataInterval*, GNEGenericData* > > >::const_reverse_iterator i = myInsertedElements.rbegin(); i != myInsertedElements.rend(); i++) {
168  // we need to avoid Tag Param because isn't a data element
169  if ((i->first != SUMO_TAG_PARAM) && (i->first != SUMO_TAG_INTERVAL)) {
170  return i->second.second;
171  }
172  }
173  return nullptr;
174 }
175 
176 // ---------------------------------------------------------------------------
177 // GNEAdditionalHandler::HierarchyInsertedDatas method definitions
178 // ---------------------------------------------------------------------------
179 
180 GNEDataHandler::GNEDataHandler(const std::string& file, GNENet* net) :
181  SUMOSAXHandler(file),
182  myNet(net) {
183  /* currently disabled
184  // create loadDialog
185  myLoadDialog = new GNEDataLoadDialog(net->getViewNet());
186  */
187 }
188 
189 
191  /* currently disabled
192  // delete loadDialog
193  delete myLoadDialog;
194  */
195 }
196 
197 
198 void
200  // Obtain tag of element
201  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
202  // check if we're parsing a parameter
203  if (tag == SUMO_TAG_PARAM) {
204  // push element int stack
206  // parse parameter
207  parseParameter(attrs);
208  } else if (tag != SUMO_TAG_NOTHING) {
209  // push element int stack
211  // build data
212  buildData(myNet, true, tag, attrs, &myHierarchyInsertedGenericDatas);
213  /* currently disabled
214  // increase load dialog
215  myLoadDialog->increase();
216  */
217  }
218 }
219 
220 
221 void
223  // pop last inserted element
225 }
226 
227 
228 bool
229 GNEDataHandler::buildData(GNENet* net, bool allowUndoRedo, SumoXMLTag tag, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas) {
230  // Call parse and build depending of tag
231  switch (tag) {
232  case SUMO_TAG_INTERVAL:
233  return parseAndBuildInterval(net, allowUndoRedo, attrs, insertedDatas);
234  case SUMO_TAG_EDGE:
235  return parseAndBuildEdgeData(net, allowUndoRedo, attrs, insertedDatas);
236  case SUMO_TAG_EDGEREL:
237  return parseAndBuildEdgeRelationData(net, allowUndoRedo, attrs, insertedDatas);
238  case SUMO_TAG_TAZREL:
239  return parseAndBuildTAZRelationData(net, allowUndoRedo, attrs, insertedDatas);
240  default:
241  return false;
242  }
243 }
244 
245 
246 GNEDataSet*
247 GNEDataHandler::buildDataSet(GNENet* net, bool allowUndoRedo, const std::string& dataSetID) {
248  GNEDataSet* dataSet = new GNEDataSet(net, dataSetID);
249  if (allowUndoRedo) {
251  net->getViewNet()->getUndoList()->add(new GNEChange_DataSet(dataSet, true), true);
252  net->getViewNet()->getUndoList()->p_end();
253  } else {
254  dataSet->incRef("buildDataSet");
255  }
256  return dataSet;
257 }
258 
259 
261 GNEDataHandler::buildDataInterval(GNENet* net, bool allowUndoRedo, GNEDataSet* dataSetParent, const double begin, const double end) {
262  GNEDataInterval* dataInterval = new GNEDataInterval(dataSetParent, begin, end);
263  if (allowUndoRedo) {
265  net->getViewNet()->getUndoList()->add(new GNEChange_DataInterval(dataInterval, true), true);
266  net->getViewNet()->getUndoList()->p_end();
267  } else {
268  dataSetParent->addDataIntervalChild(dataInterval);
269  dataInterval->incRef("buildDataInterval");
270  }
271  return dataInterval;
272 }
273 
274 
276 GNEDataHandler::buildEdgeData(GNENet* net, bool allowUndoRedo, GNEDataInterval* dataIntervalParent, GNEEdge* edge,
277  const std::map<std::string, std::string>& parameters) {
278  GNEGenericData* edgeData = new GNEEdgeData(dataIntervalParent, edge, parameters);
279  if (allowUndoRedo) {
281  net->getViewNet()->getUndoList()->add(new GNEChange_GenericData(edgeData, true), true);
282  net->getViewNet()->getUndoList()->p_end();
283  } else {
284  dataIntervalParent->addGenericDataChild(edgeData);
285  edge->addChildElement(edgeData);
286  edgeData->incRef("buildEdgeData");
287  }
288  return edgeData;
289 }
290 
291 
293 GNEDataHandler::buildEdgeRelationData(GNENet* net, bool allowUndoRedo, GNEDataInterval* dataIntervalParent,
294  GNEEdge* fromEdge, GNEEdge* toEdge, const std::map<std::string, std::string>& parameters) {
295  GNEGenericData* edgeRelationData = new GNEEdgeRelData(dataIntervalParent, fromEdge, toEdge, parameters);
296  if (allowUndoRedo) {
298  net->getViewNet()->getUndoList()->add(new GNEChange_GenericData(edgeRelationData, true), true);
299  net->getViewNet()->getUndoList()->p_end();
300  } else {
301  dataIntervalParent->addGenericDataChild(edgeRelationData);
302  fromEdge->addChildElement(edgeRelationData);
303  toEdge->addChildElement(edgeRelationData);
304  edgeRelationData->incRef("buildEdgeRelationData");
305  }
306  return edgeRelationData;
307 }
308 
309 
311 GNEDataHandler::buildTAZRelationData(GNENet* net, bool allowUndoRedo, GNEDataInterval* dataIntervalParent,
312  GNETAZElement* fromTAZ, GNETAZElement* toTAZ, const std::map<std::string, std::string>& parameters) {
313  GNEGenericData* TAZRelationData = new GNETAZRelData(dataIntervalParent, fromTAZ, toTAZ, parameters);
314  if (allowUndoRedo) {
315  net->getViewNet()->getUndoList()->p_begin("add " + toString(SUMO_TAG_TAZREL));
316  net->getViewNet()->getUndoList()->add(new GNEChange_GenericData(TAZRelationData, true), true);
317  net->getViewNet()->getUndoList()->p_end();
318  } else {
319  dataIntervalParent->addGenericDataChild(TAZRelationData);
320  fromTAZ->addChildElement(TAZRelationData);
321  toTAZ->addChildElement(TAZRelationData);
322  TAZRelationData->incRef("buildTAZRelationData");
323  }
324  return TAZRelationData;
325 }
326 
327 
328 bool
329 GNEDataHandler::parseAndBuildInterval(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas) {
330  bool abort = false;
331  // parse edgeData attributes
332  const std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", SUMO_TAG_DATAINTERVAL, SUMO_ATTR_ID, abort);
333  const double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", SUMO_TAG_DATAINTERVAL, SUMO_ATTR_BEGIN, abort);
334  const double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", SUMO_TAG_DATAINTERVAL, SUMO_ATTR_END, abort);
335  // Continue if all parameters were sucesfully loaded
336  if (!abort) {
337  // retrieve data set parent
338  GNEDataSet* dataSet = net->retrieveDataSet(id, false);
339  // check if we need to create a new data set
340  if (dataSet == nullptr) {
341  dataSet = buildDataSet(net, true, id);
342  }
343  // retrieve data interval
344  GNEDataInterval* dataInterval = dataSet->retrieveInterval(begin, end);
345  // check if data interval exist
346  if (dataInterval) {
347  // check if insertion has to be commited
348  if (insertedDatas) {
349  insertedDatas->commitDataIntervalInsertion(dataInterval);
350  }
351  } else {
352  // create data interval
353  dataInterval = buildDataInterval(net, allowUndoRedo, dataSet, begin, end);
354  // check if insertion has to be commited
355  if (insertedDatas) {
356  insertedDatas->commitDataIntervalInsertion(dataInterval);
357  }
358  }
359  return true;
360  }
361  return false;
362 }
363 
364 
365 bool
366 GNEDataHandler::parseAndBuildEdgeData(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas) {
367  bool abort = false;
368  // parse edgeData attributes
369  std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", SUMO_TAG_MEANDATA_EDGE, SUMO_ATTR_ID, abort);
370  // Continue if all parameters were sucesfully loaded
371  if (!abort) {
372  // get pointer to edge
373  GNEEdge* edge = net->retrieveEdge(edgeID, false);
374  // check that edge is valid
375  if (edge == nullptr) {
376  // Write error if lane isn't valid
377  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(SUMO_TAG_MEANDATA_EDGE) + " '" + edgeID + "' is not known.");
378  } else if (insertedDatas->getLastInsertedDataInterval() == nullptr) {
379  // Write error if lane isn't valid
380  WRITE_WARNING(toString(SUMO_TAG_MEANDATA_EDGE) + " '" + edgeID + "' must be created within a data interval.");
381  } else {
382  // check if there is already a edge data for the given edge in the given interval
383  for (const auto& genericData : insertedDatas->getLastInsertedDataInterval()->getGenericDataChildren()) {
384  if ((genericData->getTagProperty().getTag() == SUMO_TAG_MEANDATA_EDGE) &&
385  (genericData->getParentEdges().front() == edge)) {
386  WRITE_WARNING("There is already a " + genericData->getTagStr() + " in edge '" +
387  edge->getID() + "' in interval " +
388  insertedDatas->getLastInsertedDataInterval()->getID() + " [" +
389  insertedDatas->getLastInsertedDataInterval()->getAttribute(SUMO_ATTR_BEGIN) + ", " +
390  insertedDatas->getLastInsertedDataInterval()->getAttribute(SUMO_ATTR_END) + "]");
391  return false;
392  }
393  }
394  // declare parameter map
395  std::map<std::string, std::string> parameters;
396  // obtain all attribute
397  const std::vector<std::string> attributes = attrs.getAttributeNames();
398  // iterate over attributes and fill parameters map
399  for (const auto& attribute : attributes) {
400  if (attribute != toString(SUMO_ATTR_ID)) {
401  parameters[attribute] = attrs.getStringSecure(attribute, "");
402  }
403  }
404  // save ID of last created element
405  GNEGenericData* dataCreated = buildEdgeData(net, allowUndoRedo, insertedDatas->getLastInsertedDataInterval(), edge, parameters);
406  // check if insertion has to be commited
407  if (insertedDatas) {
408  insertedDatas->commitGenericDataInsertion(dataCreated);
409  }
410  return true;
411  }
412  }
413  return false;
414 }
415 
416 
417 bool
418 GNEDataHandler::parseAndBuildEdgeRelationData(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas) {
419  bool abort = false;
420  // parse edgeRelationData attributes
421  std::string fromEdgeStr = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", SUMO_TAG_EDGEREL, SUMO_ATTR_FROM, abort);
422  std::string toEdgeStr = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", SUMO_TAG_EDGEREL, SUMO_ATTR_TO, abort);
423  // Continue if all parameters were sucesfully loaded
424  if (!abort) {
425  // get pointers to edges
426  GNEEdge* fromEdge = net->retrieveEdge(fromEdgeStr, false);
427  GNEEdge* toEdge = net->retrieveEdge(toEdgeStr, false);
428  // check that edge is valid
429  if (fromEdge == nullptr) {
430  // Write error if lane isn't valid
431  WRITE_WARNING("The from edge '" + fromEdgeStr + "' to use within " + toString(SUMO_TAG_EDGEREL) + " is not known.");
432  } else if (toEdge == nullptr) {
433  // Write error if lane isn't valid
434  WRITE_WARNING("The to edge '" + toEdgeStr + "' to use within " + toString(SUMO_TAG_EDGEREL) + " is not known.");
435  } else if (insertedDatas->getLastInsertedDataInterval() == nullptr) {
436  // Write error if lane isn't valid
437  WRITE_WARNING(toString(SUMO_TAG_EDGEREL) + " must be created within a data interval.");
438  } else {
439  // check if there is already a edge data for the given edge in the interval
440  for (const auto& genericData : insertedDatas->getLastInsertedDataInterval()->getGenericDataChildren()) {
441  if ((genericData->getTagProperty().getTag() == SUMO_TAG_EDGEREL) &&
442  (genericData->getParentEdges().front() == fromEdge) &&
443  (genericData->getParentEdges().back() == toEdge)) {
444  WRITE_WARNING("There is already a " + genericData->getTagStr() + " for edges '" +
445  fromEdge->getID() + "'->'" + toEdge->getID() + "' in interval " +
446  insertedDatas->getLastInsertedDataInterval()->getID() + " [" +
447  insertedDatas->getLastInsertedDataInterval()->getAttribute(SUMO_ATTR_BEGIN) + ", " +
448  insertedDatas->getLastInsertedDataInterval()->getAttribute(SUMO_ATTR_END) + "]");
449  return false;
450  }
451  }
452  // declare parameter map
453  std::map<std::string, std::string> parameters;
454  // obtain all attribute
455  const std::vector<std::string> attributes = attrs.getAttributeNames();
456  // iterate over attributes and fill parameters map
457  for (const auto& attribute : attributes) {
458  if ((attribute != toString(SUMO_ATTR_ID)) && (attribute != toString(SUMO_ATTR_FROM)) && (attribute != toString(SUMO_ATTR_TO))) {
459  parameters[attribute] = attrs.getStringSecure(attribute, "");
460  }
461  }
462  // save ID of last created element
463  GNEGenericData* dataCreated = buildEdgeRelationData(net, allowUndoRedo, insertedDatas->getLastInsertedDataInterval(),
464  fromEdge, toEdge, parameters);
465  // check if insertion has to be commited
466  if (insertedDatas) {
467  insertedDatas->commitGenericDataInsertion(dataCreated);
468  }
469  return true;
470  }
471  }
472  return false;
473 }
474 
475 
476 bool
477 GNEDataHandler::parseAndBuildTAZRelationData(GNENet* net, bool allowUndoRedo, const SUMOSAXAttributes& attrs, HierarchyInsertedDatas* insertedDatas) {
478  bool abort = false;
479  // parse TAZRelationData attributes
480  std::string fromTAZStr = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", SUMO_TAG_TAZREL, SUMO_ATTR_FROM, abort);
481  std::string toTAZStr = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", SUMO_TAG_TAZREL, SUMO_ATTR_TO, abort);
482  // Continue if all parameters were sucesfully loaded
483  if (!abort) {
484  // get pointers to TAZs
485  GNETAZElement* fromTAZ = net->retrieveTAZElement(SUMO_TAG_TAZ, fromTAZStr, false);
486  GNETAZElement* toTAZ = net->retrieveTAZElement(SUMO_TAG_TAZ, toTAZStr, false);
487  // check that TAZ is valid
488  if (fromTAZ == nullptr) {
489  // Write error if lane isn't valid
490  WRITE_WARNING("The from TAZ '" + fromTAZStr + "' to use within " + toString(SUMO_TAG_TAZREL) + " is not known.");
491  } else if (toTAZ == nullptr) {
492  // Write error if lane isn't valid
493  WRITE_WARNING("The to TAZ '" + toTAZStr + "' to use within " + toString(SUMO_TAG_TAZREL) + " is not known.");
494  } else if (insertedDatas->getLastInsertedDataInterval() == nullptr) {
495  // Write error if lane isn't valid
496  WRITE_WARNING(toString(SUMO_TAG_TAZREL) + " must be created within a data interval.");
497  } else {
498  // declare parameter map
499  std::map<std::string, std::string> parameters;
500  // obtain all attribute
501  const std::vector<std::string> attributes = attrs.getAttributeNames();
502  // iterate over attributes and fill parameters map
503  for (const auto& attribute : attributes) {
504  if ((attribute != toString(SUMO_ATTR_ID)) && (attribute != toString(SUMO_ATTR_FROM)) && (attribute != toString(SUMO_ATTR_TO))) {
505  parameters[attribute] = attrs.getStringSecure(attribute, "");
506  }
507  }
508  // save ID of last created element
509  GNEGenericData* dataCreated = buildTAZRelationData(net, allowUndoRedo, insertedDatas->getLastInsertedDataInterval(),
510  fromTAZ, toTAZ, parameters);
511  // check if insertion has to be commited
512  if (insertedDatas) {
513  insertedDatas->commitGenericDataInsertion(dataCreated);
514  }
515  return true;
516  }
517  }
518  return false;
519 }
520 
521 // ===========================================================================
522 // private method definitions
523 // ===========================================================================
524 
525 void
528  // first check if given data supports parameters
530  bool ok = true;
531  std::string key;
532  if (attrs.hasAttribute(SUMO_ATTR_KEY)) {
533  // obtain key
534  key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
535  if (key.empty()) {
536  WRITE_WARNING("Error parsing key from data parameter. Key cannot be empty");
537  ok = false;
538  }
540  WRITE_WARNING("Error parsing key from data parameter. Key contains invalid characters");
541  ok = false;
542  }
543  } else {
544  WRITE_WARNING("Error parsing key from data parameter. Key doesn't exist");
545  ok = false;
546  }
547  // circumventing empty string test
548  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
550  WRITE_WARNING("Error parsing value from data parameter. Value contains invalid characters");
551  ok = false;
552  }
553  // check double values
554  if (myHierarchyInsertedGenericDatas.getLastInsertedGenericData()->getTagProperty().hasParameters() && !GNEAttributeCarrier::canParse<double>(val)) {
555  WRITE_WARNING("Error parsing value from data float parameter. Value cannot be parsed to float");
556  ok = false;
557  }
558  // set parameter in last inserted data
559  if (ok) {
560  WRITE_DEBUG("Inserting parameter '" + key + "|" + val + "' into data " + myHierarchyInsertedGenericDatas.getLastInsertedGenericData()->getTagStr() + ".");
562  }
563  } else {
564  WRITE_WARNING("Datas of type '" + myHierarchyInsertedGenericDatas.getLastInsertedGenericData()->getTagStr() + "' doesn't support parameters");
565  }
566  } else {
567  WRITE_WARNING("Parameters has to be declared within the definition of an data");
568  }
569 }
570 
571 /****************************************************************************/
#define GUIDesignDialogBox
Definition: GUIDesigns.h:494
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:223
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_TAG_DATAINTERVAL
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_MEANDATA_EDGE
an edge based mean data detector
@ SUMO_TAG_DATASET
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
@ SUMO_ATTR_KEY
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get Tag Property assigned to this object
static bool parseAndBuildEdgeData(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a edge data.
~GNEDataHandler()
Destructor.
static bool parseAndBuildTAZRelationData(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a TAZ relation data.
HierarchyInsertedDatas myHierarchyInsertedGenericDatas
load dialog (currently disabled)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static bool buildData(GNENet *net, bool allowUndoRedo, SumoXMLTag tag, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Build datas.
GNEDataHandler(const std::string &file, GNENet *net)
Constructor.
void myEndElement(int element)
Called when a closing tag occurs.
static GNEDataInterval * buildDataInterval(GNENet *net, bool allowUndoRedo, GNEDataSet *dataSetParent, const double begin, const double end)
Builds DataInterval.
static bool parseAndBuildEdgeRelationData(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a edge relation data.
static GNEGenericData * buildTAZRelationData(GNENet *net, bool allowUndoRedo, GNEDataInterval *dataIntervalParent, GNETAZElement *fromTAZ, GNETAZElement *toTAZ, const std::map< std::string, std::string > &parameters)
Builds TAZRelationData.
static bool parseAndBuildInterval(GNENet *net, bool allowUndoRedo, const SUMOSAXAttributes &attrs, HierarchyInsertedDatas *insertedDatas)
Parses his values and builds a interval.
static GNEGenericData * buildEdgeData(GNENet *net, bool allowUndoRedo, GNEDataInterval *dataIntervalParent, GNEEdge *edge, const std::map< std::string, std::string > &parameters)
Builds edgeData.
GNENet * myNet
pointer to net
static GNEGenericData * buildEdgeRelationData(GNENet *net, bool allowUndoRedo, GNEDataInterval *dataIntervalParent, GNEEdge *fromEdge, GNEEdge *toEdge, const std::map< std::string, std::string > &parameters)
Builds edgeRelationData.
void parseParameter(const SUMOSAXAttributes &attrs)
Parse parameter and insert it in the last created data.
static GNEDataSet * buildDataSet(GNENet *net, bool allowUndoRedo, const std::string &dataSetID)
Builds DataSet.
An Element which don't belongs to GNENet but has influency in the simulation.
std::string getAttribute(SumoXMLAttr key) const
const std::string & getID() const
get ID
const std::vector< GNEGenericData * > & getGenericDataChildren() const
get generic data children
void addGenericDataChild(GNEGenericData *genericData)
add generic data child
FXLabel * myLabel
label
int myCounter
counter
~GNEDataLoadDialog()
destructor
void increase()
increase counter
GNEDataLoadDialog(GNEViewNet *viewNet)
constructor
GNEViewNet * myViewNet
pointer to viewNet
GNEDataInterval * retrieveInterval(const double begin, const double end) const
return interval
Definition: GNEDataSet.cpp:281
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:211
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEEdgeData.h:37
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
An Element which don't belongs to GNENet but has influency in the simulation.
An Element which don't belongs to GNENet but has influency in the simulation.
void addChildElement(T *element)
add child element
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true) const
get edge by id
Definition: GNENet.cpp:1141
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
Definition: GNENet.cpp:2590
GNETAZElement * retrieveTAZElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named TAZElement.
Definition: GNENet.cpp:3001
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
const std::string & getID() const
get ID
void incRef(const std::string &debugMsg="")
Increarse reference.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZRelData.h:37
bool hasParameters() const
return true if Tag correspond to an element that supports parameters "key1=value1|key2=value2|....
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:71
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:78
GNEUndoList * getUndoList() const
get the undoList object
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Encapsulated SAX-Attributes.
virtual std::vector< std::string > getAttributeNames() const =0
Retrieves all attribute names.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
Stack used to save the last inserted element.
void insertElement(SumoXMLTag tag)
insert new element (called only in function myStartElement)
GNEGenericData * getLastInsertedGenericData() const
return last generic data inserted
GNEDataInterval * retrieveParentDataInterval(SumoXMLTag expectedTag) const
retrieve parent generic data correspond to current status of myInsertedElements
void commitGenericDataInsertion(GNEGenericData *dataElementCreated)
commit element insertion (used to save last correct generic data element)
std::vector< std::pair< SumoXMLTag, std::pair< GNEDataInterval *, GNEGenericData * > > > myInsertedElements
vector used as stack
void commitDataIntervalInsertion(GNEDataInterval *dataIntervalCreated)
commit element insertion (used to save last correct data interval element)
void popElement()
pop last inserted element (used only in function myEndElement)
GNEGenericData * retrieveParentGenericData(SumoXMLTag expectedTag) const
retrieve parent generic data correspond to current status of myInsertedElements
GNEDataInterval * getLastInsertedDataInterval() const
return last generic data inserted