26#include <xercesc/sax/HandlerBase.hpp>
27#include <xercesc/sax/AttributeList.hpp>
28#include <xercesc/sax/SAXParseException.hpp>
29#include <xercesc/sax/SAXException.hpp>
55 myCurrentStop(nullptr),
56 myCurrentLine(nullptr),
57 myCurrentCompletion(0),
58 myCurrentStopWasIgnored(false)
101 if (key ==
"completeness") {
103 }
else if (key ==
"name") {
143 const std::string
id = attrs.
get<std::string>(
SUMO_ATTR_ID,
"busStop", ok);
145 const std::string laneID = attrs.
get<std::string>(
SUMO_ATTR_LANE,
id.c_str(), ok);
154 if (edge ==
nullptr) {
156 WRITE_ERROR(
"Edge '" + edgeID +
"' for stop '" +
id +
"' not found");
164 WRITE_ERROR(
"Lane '" + laneID +
"' for stop '" +
id +
"' not found");
174 myCurrentStop =
new NBPTStop(
id, pos, edgeID, edgeID, endPos - startPos, name, permissions, parkingLength, color, startPos);
176 WRITE_ERROR(
"Could not add public transport stop '" +
id +
"' (already exists)");
187 throw InvalidArgument(
"Could not add access outside a stopping place.");
210 const std::string
id = attrs.
get<std::string>(
SUMO_ATTR_ID,
"ptLine", ok);
220 const std::string nightService = attrs.
getStringSecure(
"nightService",
"");
232 const std::string
id = attrs.
get<std::string>(
SUMO_ATTR_ID,
"flow", ok);
257 const std::vector<std::string>& edgeIDs = attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES,
nullptr, ok);
259 for (
const std::string& edgeID : edgeIDs) {
261 if (edge ==
nullptr) {
266 edges.push_back(edge);
279 for (
const std::string& edgeID : edgeIDs) {
281 if (edge ==
nullptr) {
286 edges.push_back(edge);
300 if (stop ==
nullptr) {
317 if (stop ==
nullptr) {
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_SHIP
is an arbitrary ship
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_PT_LINE
A pt line.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_COLOR
A color information.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Storage for edges, including some functionality operating on multiple edges.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
The representation of a single edge during network building.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
int getNumLanes() const
Returns the number of lanes.
Position geometryPositionAtOffset(double offset) const
return position taking into account loaded length
static int getLaneIndexFromLaneID(const std::string laneID)
void insert(NBPTLine *ptLine)
insert new line
void setName(const std::string &name)
void addPTStop(NBPTStop *pStop)
const std::vector< NBPTStop * > & getStops()
const std::string & getName() const
const std::string & getLineID() const
void setMyNumOfStops(int numStops)
void setEdges(const std::vector< NBEdge * > &edges)
bool insert(NBPTStop *ptStop, bool floating=false)
Inserts a node into the map.
static void addIgnored(const std::string &stopID)
NBPTStop * get(std::string id) const
Retrieve a previously inserted pt stop.
static bool wasIgnored(const std::string &stopID)
The representation of a single pt stop.
std::string getID() const
void addAccess(std::string laneID, double offset, double length)
static SUMOVehicleClass interpretTransportType(const std::string &type, NIOSMNode *toSet=nullptr)
translate osm transport designations into sumo vehicle class
NBPTStop * myCurrentStop
The currently processed stop.
NIXMLPTHandler(NBEdgeCont &ec, NBPTStopCont &sc, NBPTLineCont &lc)
Constructor.
void addPTLine(const SUMOSAXAttributes &attrs)
Parses a public transport line.
~NIXMLPTHandler()
Destructor.
std::string myCurrentRouteID
The currently processed stand-alone route.
void addPTLineStop(const SUMOSAXAttributes &attrs)
Parses an public transport stop reference within a line element.
void addPTLineFromFlow(const SUMOSAXAttributes &attrs)
Parses a public transport line.
NBPTStopCont & myStopCont
The stop container (for loading of stops)
void myEndElement(int element)
Called when a closing tag occurs.
NBEdgeCont & myEdgeCont
The edges container (for retrieving referenced stop edge)
std::map< std::string, std::vector< NBPTStop * > > myRouteStops
stand-alone route information
std::map< std::string, EdgeVector > myRouteEdges
NBPTLineCont & myLineCont
The line container (for loading of lines)
bool myCurrentStopWasIgnored
whether the current stop should be discarded
void addPTLineRoute(const SUMOSAXAttributes &attrs)
Parses a route as port of a public transport line.
void addPTStop(const SUMOSAXAttributes &attrs)
Parses an public transport stop.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
double myCurrentCompletion
the completion level of the current line
void addRoute(const SUMOSAXAttributes &attrs)
Parses a stand-alone route when parsing implicit ptlines from routes and flows.
void addRouteStop(const SUMOSAXAttributes &attrs)
Parses an public transport stop reference within a route element.
void addAccess(const SUMOSAXAttributes &attrs)
Parses an stop access definition.
NBPTLine * myCurrentLine
The currently processed line.
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.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
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.
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.
SAX-handler base for SUMO-files.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter