86 if (!oc.
isSet(
"matsim-files")) {
94 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
97 WRITE_ERROR(
"Could not open matsim-file '" + *file +
"'.");
110 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
125 matsimAttrs, MATSIM_ATTR_NOTHING,
126 "matsim - file"), myNodeCont(toFill) {
148 WRITE_ERROR(
"Unable to project coordinates for node '" +
id +
"'.");
151 if (!myNodeCont.insert(node)) {
153 WRITE_ERROR(
"Could not add node '" +
id +
"'. Probably declared twice.");
163 bool keepEdgeLengths,
bool lanesFromCapacity,
167 myNodeCont(nc), myEdgeCont(toFill), myCapacityNorm(3600),
168 myKeepEdgeLengths(keepEdgeLengths), myLanesFromCapacity(lanesFromCapacity),
169 myCapacity2Lanes(capacity2Lanes) {
179 NBEdge* edge =
new NBEdge(
id, fromNode, toNode,
"", freeSpeed,
NBEdge::UNSPECIFIED_FRICTION, numLanes, -1,
NBEdge::UNSPECIFIED_WIDTH,
NBEdge::UNSPECIFIED_OFFSET,
LaneSpreadFunction::RIGHT);
181 if (myKeepEdgeLengths) {
184 if (!myEdgeCont.insert(edge)) {
186 WRITE_ERROR(
"Could not add edge '" +
id +
"'. Probably declared twice.");
199 myCapacityNorm = (double)(capDivider * 3600);
207 if (st.size() != 3) {
208 WRITE_ERROR(
TL(
"Bogus capacity period format; requires 'hh:mm:ss'."));
215 myCapacityNorm = (double)(hours * 3600 + minutes * 60 + seconds);
237 NBNode* fromNode = myNodeCont.retrieve(fromNodeID);
238 NBNode* toNode = myNodeCont.retrieve(toNodeID);
239 if (fromNode ==
nullptr) {
240 WRITE_ERROR(
"Could not find from-node for edge '" +
id +
"'.");
242 if (toNode ==
nullptr) {
243 WRITE_ERROR(
"Could not find to-node for edge '" +
id +
"'.");
245 if (fromNode ==
nullptr || toNode ==
nullptr) {
248 if (myLanesFromCapacity) {
249 permLanes = myCapacity2Lanes.get(capacity);
251 if (fromNode == toNode) {
254 if (myNodeCont.insert(intermediate)) {
255 insertEdge(
id +
".0", intermediate, toNode, freeSpeed, (
int)(permLanes + 0.5), capacity, length);
256 toNode = intermediate;
259 WRITE_ERROR(
"Could not add intermediate node to split loop edge '" +
id +
"'.");
262 insertEdge(
id, fromNode, toNode, freeSpeed, (
int)(permLanes + 0.5), capacity, length);
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool isReadable(std::string path)
Checks whether the given file is readable.
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)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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)
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)
Runs the given handler on the given file; returns if everything's ok.