SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIXMLTypesHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Importer for edge type information stored in XML
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <iostream>
36 #include <xercesc/sax/HandlerBase.hpp>
37 #include <xercesc/sax/AttributeList.hpp>
38 #include <xercesc/sax/SAXParseException.hpp>
39 #include <xercesc/sax/SAXException.hpp>
40 #include "NIXMLTypesHandler.h"
41 #include <netbuild/NBTypeCont.h>
46 #include <utils/common/ToString.h>
48 
49 #ifdef CHECK_MEMORY_LEAKS
50 #include <foreign/nvwa/debug_new.h>
51 #endif // CHECK_MEMORY_LEAKS
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
58  : SUMOSAXHandler("xml-types - file"),
59  myTypeCont(tc) {}
60 
61 
63 
64 
65 void
67  const SUMOSAXAttributes& attrs) {
68  if (element != SUMO_TAG_TYPE) {
69  return;
70  }
71  bool ok = true;
72  // get the id, report a warning if not given or empty...
73  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
74  int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, myTypeCont.getPriority(""));
75  int noLanes = myTypeCont.getNumLanes("");
76  noLanes = attrs.getOpt<int>(SUMO_ATTR_NUMLANES, id.c_str(), ok, noLanes);
77  SUMOReal speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, id.c_str(), ok, (SUMOReal) myTypeCont.getSpeed(""));
78  std::string allowS = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "");
79  std::string disallowS = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
80  bool oneway = attrs.getOpt<bool>(SUMO_ATTR_ONEWAY, id.c_str(), ok, false);
81  bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, id.c_str(), ok, false);
82  SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH);
83  if (!ok) {
84  return;
85  }
86  // build the type
87  SVCPermissions permissions = parseVehicleClasses(allowS, disallowS);
88  if (!myTypeCont.insert(id, noLanes, speed, priority, permissions, width, oneway)) {
89  WRITE_ERROR("Duplicate type occured. ID='" + id + "'");
90  } else {
91  if (discard) {
93  }
94  }
95 }
96 
97 
98 
99 /****************************************************************************/
100