Eclipse SUMO - Simulation of Urban MObility
NILoader.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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Perfoms network import
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
31 #include <utils/options/Option.h>
34 #include <utils/common/ToString.h>
37 #include <netbuild/NBTypeCont.h>
38 #include <netbuild/NBNodeCont.h>
39 #include <netbuild/NBEdgeCont.h>
41 #include <netbuild/NBNetBuilder.h>
59 #include <netimport/typemap.h>
60 #include "NILoader.h"
61 #include "NITypeLoader.h"
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
67  : myNetBuilder(nb) {}
68 
70 
71 void
73  // load types first
74  NIXMLTypesHandler* handler =
76  if (!oc.isSet("type-files")) {
77  std::vector<std::string> files;
78  if (oc.isSet("osm-files")) {
79  files.push_back(osmTypemap);
80  }
81  if (oc.isSet("opendrive-files")) {
82  files.push_back(opendriveTypemap);
83  }
84  NITypeLoader::load(handler, files, "types", true);
85  } else {
86  NITypeLoader::load(handler, oc.getStringVector("type-files"), "types");
87  }
88  // try to load height data so it is ready for use by other importers
90  // try to load using different methods
101  if (oc.getBool("tls.discard-loaded") || oc.getBool("tls.discard-simple")) {
103  oc.getBool("tls.guess-signals"));
104  int removed = myNetBuilder.getTLLogicCont().getNumExtracted();
105  if (removed > 0) {
106  WRITE_MESSAGE(" Removed " + toString(removed) + " traffic lights before loading plain-XML");
107  }
108  }
109  if (oc.getBool("railway.signals.discard")) {
111  }
112  loadXML(oc);
113  // check the loaded structures
114  if (myNetBuilder.getNodeCont().size() == 0) {
115  throw ProcessError("No nodes loaded.");
116  }
117  if (myNetBuilder.getEdgeCont().size() == 0) {
118  throw ProcessError("No edges loaded.");
119  }
120  // report loaded structures
121  WRITE_MESSAGE(" Import done:");
122  if (myNetBuilder.getDistrictCont().size() > 0) {
123  WRITE_MESSAGE(" " + toString(myNetBuilder.getDistrictCont().size()) + " districts loaded.");
124  }
125  WRITE_MESSAGE(" " + toString(myNetBuilder.getNodeCont().size()) + " nodes loaded.");
126  if (myNetBuilder.getTypeCont().size() > 0) {
127  WRITE_MESSAGE(" " + toString(myNetBuilder.getTypeCont().size()) + " types loaded.");
128  }
129  WRITE_MESSAGE(" " + toString(myNetBuilder.getEdgeCont().size()) + " edges loaded.");
132  "The split of edges was performed " + toString(myNetBuilder.getEdgeCont().getNoEdgeSplits()) + " times.");
133  }
134 
135  //TODO: uncomment the following lines + adapt tests! [Gregor March '17]
136 // if (myNetBuilder.getPTStopCont().size() > 0) {
137 // WRITE_MESSAGE(" " + toString(myNetBuilder.getPTStopCont().size()) + " pt stops loaded.");
138 // }
139  if (GeoConvHelper::getProcessing().usingGeoProjection()) {
140  WRITE_MESSAGE("Proj projection parameters used: '" + GeoConvHelper::getProcessing().getProjString() + "'.");
141  }
142 }
143 
144 /* -------------------------------------------------------------------------
145  * file loading methods
146  * ----------------------------------------------------------------------- */
147 void
149  // load nodes
152  oc.getStringVector("node-files"), "nodes");
153  // load the edges
159  oc),
160  oc.getStringVector("edge-files"), "edges");
161  if (!deprecatedVehicleClassesSeen.empty()) {
162  WRITE_WARNING("Deprecated vehicle class(es) '" + toString(deprecatedVehicleClassesSeen) + "' in input edge files.");
163  }
164  // load the connections
168  oc.getStringVector("connection-files"), "connections");
169  // load traffic lights (needs to come last, references loaded edges and connections)
172  oc.getStringVector("tllogic-files"), "traffic lights");
173 
174  // load public transport stops (used for restricting edge removal and as input when repairing railroad topology)
175  if (oc.exists("ptstop-files")) {
180  oc.getStringVector("ptstop-files"), "public transport stops");
181  }
182 
183  // load public transport lines (used as input when repairing railroad topology)
184  if (oc.exists("ptline-files")) {
189  oc.getStringVector("ptline-files"), "public transport lines");
190  }
191 
192  // load shapes for output formats that embed shape data
193  if (oc.exists("polygon-files")) {
197  oc.getStringVector("polygon-files"), "polygon data");
198  }
199 }
200 
201 /****************************************************************************/
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:135
NBHeightMapper.h
ToString.h
NIXMLEdgesHandler
Importer for network edges stored in XML.
Definition: NIXMLEdgesHandler.h:64
NIXMLNodesHandler
Importer for network nodes stored in XML.
Definition: NIXMLNodesHandler.h:52
NIImporter_OpenStreetMap::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given OSM file.
Definition: NIImporter_OpenStreetMap.cpp:102
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
NIXMLTypesHandler.h
NBNetBuilder
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
typemap.h
NBEdgeCont::getNoEdgeSplits
int getNoEdgeSplits() const
Returns the number of edge splits.
Definition: NBEdgeCont.h:319
NIImporter_DlrNavteq.h
OptionsCont.h
NIXMLTrafficLightsHandler
Importer for edge connections stored in XML.
Definition: NIXMLTrafficLightsHandler.h:49
MsgHandler.h
NIImporter_OpenStreetMap.h
NITypeLoader::load
static void load(SUMOSAXHandler *handler, const std::vector< std::string > &files, const std::string &type, const bool stringParse=false)
Definition: NITypeLoader.cpp:43
FileHelpers.h
GeoConvHelper::getProcessing
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:86
NIXMLConnectionsHandler
Importer for edge connections stored in XML.
Definition: NIXMLConnectionsHandler.h:51
OptionsCont::exists
bool exists(const std::string &name) const
Returns the information whether the named option is known.
Definition: OptionsCont.cpp:129
NBEdgeCont.h
NIXMLEdgesHandler.h
GeoConvHelper.h
NIXMLNodesHandler.h
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:222
NIImporter_OpenDrive.h
NIXMLShapeHandler
Definition: NIXMLShapeHandler.h:39
NIImporter_MATSim::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given MATSIM network files.
Definition: NIImporter_MATSim.cpp:85
NIXMLPTHandler.h
NIImporter_MATSim.h
NBNetBuilder::getEdgeCont
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:150
OptionsCont::getStringVector
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
Definition: OptionsCont.cpp:235
osmTypemap
const std::string osmTypemap
Definition: typemap.h:38
NILoader::~NILoader
~NILoader()
Destructor.
Definition: NILoader.cpp:69
NIXMLConnectionsHandler.h
NIXMLPTHandler
Importer for network edges stored in XML.
Definition: NIXMLPTHandler.h:61
NBNetBuilder::getPTStopCont
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
Definition: NBNetBuilder.h:176
NBNetBuilder::getPTLineCont
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
Definition: NBNetBuilder.h:181
NBEdgeCont::size
int size() const
Returns the number of edges.
Definition: NBEdgeCont.h:304
NIImporter_ArcView::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given ArcView Shape files.
Definition: NIImporter_ArcView.cpp:66
NBTypeCont.h
NIImporter_RobocupRescue.h
NIXMLTypesHandler
Importer for edge type information stored in XML.
Definition: NIXMLTypesHandler.h:46
NIImporter_RobocupRescue::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given RoboCup Rescue League files.
Definition: NIImporter_RobocupRescue.cpp:53
NBNetBuilder.h
NITypeLoader.h
ProcessError
Definition: UtilExceptions.h:39
NIImporter_SUMO.h
opendriveTypemap
const std::string opendriveTypemap
Definition: typemap.h:1
NIXMLTrafficLightsHandler.h
NIImporter_ITSUMO.h
UtilExceptions.h
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NIImporter_ITSUMO::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given ITSUMO network files.
Definition: NIImporter_ITSUMO.cpp:104
NIImporter_SUMO::loadNetwork
static void loadNetwork(OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
Definition: NIImporter_SUMO.cpp:57
NILoader::load
void load(OptionsCont &oc)
Definition: NILoader.cpp:72
NIXMLShapeHandler.h
NILoader::loadXML
void loadXML(OptionsCont &oc)
Definition: NILoader.cpp:148
NIImporter_DlrNavteq::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given dlr-navteq (aka Elmar-fomat) folder.
Definition: NIImporter_DlrNavteq.cpp:64
NBNodeCont.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
StringUtils.h
NILoader.h
Option.h
NBTypeCont::size
int size() const
Returns the number of known types.
Definition: NBTypeCont.h:99
deprecatedVehicleClassesSeen
std::set< std::string > deprecatedVehicleClassesSeen
Definition: SUMOVehicleClass.cpp:84
NBTrafficLightLogicCont::getNumExtracted
int getNumExtracted() const
return the number of extracted traffic light definitions
Definition: NBTrafficLightLogicCont.h:119
NBNetBuilder::getTLLogicCont
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
Definition: NBNetBuilder.h:165
NIImporter_VISUM.h
NBNodeCont::size
int size() const
Returns the number of nodes stored in this container.
Definition: NBNodeCont.h:263
NBNetBuilder::getDistrictCont
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
Definition: NBNetBuilder.h:170
NILoader::myNetBuilder
NBNetBuilder & myNetBuilder
The network builder to fill with loaded data.
Definition: NILoader.h:76
config.h
NBNodeCont::discardRailSignals
void discardRailSignals()
Definition: NBNodeCont.cpp:1850
NIImporter_VISUM::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder.
Definition: NIImporter_VISUM.cpp:92
NIImporter_ArcView.h
NBNetBuilder::getShapeCont
ShapeContainer & getShapeCont()
Definition: NBNetBuilder.h:190
NBHeightMapper::loadIfSet
static void loadIfSet(OptionsCont &oc)
loads heigh map data if any loading options are set
Definition: NBHeightMapper.cpp:148
NBNetBuilder::getNodeCont
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:155
NBNodeCont::discardTrafficLights
void discardTrafficLights(NBTrafficLightLogicCont &tlc, bool geometryLike, bool guessSignals)
Definition: NBNodeCont.cpp:1820
NBNetBuilder::getTypeCont
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:160
NIImporter_Vissim.h
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
NIImporter_OpenDrive::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
Definition: NIImporter_OpenDrive.cpp:171
NIImporter_Vissim::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder.
Definition: NIImporter_Vissim.cpp:193
NBDistrictCont::size
int size() const
Returns the number of districts inside the container.
Definition: NBDistrictCont.cpp:69
NILoader::NILoader
NILoader(NBNetBuilder &nb)
Constructor.
Definition: NILoader.cpp:66