91 const std::vector<std::string> files = oc.
getStringVector(
"matsim-files");
94 for (
const std::string& file : files) {
105 for (
const std::string& file : files) {
119 matsimAttrs, MATSIM_ATTR_NOTHING,
120 "matsim - file"), myNodeCont(toFill) {
142 WRITE_ERRORF(
TL(
"Unable to project coordinates for node '%'."),
id);
145 if (!myNodeCont.insert(node)) {
147 WRITE_ERRORF(
TL(
"Could not add node '%'. Probably declared twice."),
id);
157 bool keepEdgeLengths,
bool lanesFromCapacity,
161 myNodeCont(nc), myEdgeCont(toFill), myCapacityNorm(3600),
162 myKeepEdgeLengths(keepEdgeLengths), myLanesFromCapacity(lanesFromCapacity),
163 myCapacity2Lanes(capacity2Lanes) {
173 NBEdge* edge =
new NBEdge(
id, fromNode, toNode,
"", freeSpeed,
NBEdge::UNSPECIFIED_FRICTION, numLanes, -1,
NBEdge::UNSPECIFIED_WIDTH,
NBEdge::UNSPECIFIED_OFFSET,
LaneSpreadFunction::RIGHT);
175 if (myKeepEdgeLengths) {
178 if (!myEdgeCont.insert(edge)) {
180 WRITE_ERRORF(
TL(
"Could not add edge '%'. Probably declared twice."),
id);
193 myCapacityNorm = (double)(capDivider * 3600);
201 if (st.size() != 3) {
202 WRITE_ERROR(
TL(
"Bogus capacity period format; requires 'hh:mm:ss'."));
209 myCapacityNorm = (double)(hours * 3600 + minutes * 60 + seconds);
231 NBNode* fromNode = myNodeCont.retrieve(fromNodeID);
232 NBNode* toNode = myNodeCont.retrieve(toNodeID);
233 if (fromNode ==
nullptr) {
236 if (toNode ==
nullptr) {
239 if (fromNode ==
nullptr || toNode ==
nullptr) {
242 if (myLanesFromCapacity) {
243 permLanes = myCapacity2Lanes.get(capacity);
245 if (fromNode == toNode) {
248 if (myNodeCont.insert(intermediate)) {
249 insertEdge(
id +
".0", intermediate, toNode, freeSpeed, (
int)(permLanes + 0.5), capacity, length);
250 toNode = intermediate;
253 WRITE_ERRORF(
TL(
"Could not add intermediate node to split loop edge '%'."),
id);
256 insertEdge(
id, fromNode, toNode, freeSpeed, (
int)(permLanes + 0.5), capacity, length);
#define WRITE_ERRORF(...)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A handler which converts occuring elements and attributes into enums.
void setFileName(const std::string &name)
Sets the current file name.
A helper class which computes the lane number from given capacity.
Storage for edges, including some functionality operating on multiple edges.
The representation of a single edge during network building.
static const double UNSPECIFIED_FRICTION
unspecified lane friction
static const double UNSPECIFIED_WIDTH
unspecified lane width
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void setLoadedLength(double val)
set loaded length
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
Container for nodes during the netbuilding process.
Represents a single node (junction) during network building.
const Position & getPosition() const
A class which extracts MATSIM-edges from a parsed MATSIM-file.
~EdgesHandler()
Destructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
EdgesHandler(NBNodeCont &nc, NBEdgeCont &toFill, bool keepEdgeLengths, bool lanesFromCapacity, NBCapacity2Lanes capacity2Lanes)
Constructor.
void insertEdge(const std::string &id, NBNode *fromNode, NBNode *toNode, double freeSpeed, int numLanes, double capacity, double length)
A class which extracts MATSIM-nodes from a parsed MATSIM-file.
NodesHandler(NBNodeCont &toFill)
Contructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
~NodesHandler()
Destructor.
static StringBijection< int >::Entry matsimAttrs[]
The names of MATSIM-XML attributes (for passing to GenericSAXHandler)
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given MATSIM network files.
static StringBijection< int >::Entry matsimTags[]
The names of MATSIM-XML elements (for passing to GenericSAXHandler)
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file)
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
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.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.