55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
79 myNodeCont(nb.getNodeCont()),
80 myTLLCont(nb.getTLLogicCont()),
85 myHaveSeenInternalEdge(false)
90 for (std::map<std::string, EdgeAttrs*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
92 for (std::vector<LaneAttrs*>::const_iterator j = ed->
lanes.begin(); j != ed->
lanes.end(); ++j) {
109 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
111 WRITE_ERROR(
"Could not open sumo-net-file '" + *file +
"'.");
120 for (std::map<std::string, EdgeAttrs*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
139 if (ed->
shape.size() > 0) {
149 (
unsigned int) ed->
lanes.size(),
161 for (std::map<std::string, EdgeAttrs*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
167 for (
unsigned int fromLaneIndex = 0; fromLaneIndex < (
unsigned int) ed->
lanes.size(); ++fromLaneIndex) {
170 const std::vector<Connection>& connections = lane->
connections;
171 for (std::vector<Connection>::const_iterator c_it = connections.begin(); c_it != connections.end(); c_it++) {
191 if (programs.size() > 0) {
192 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
193 for (it = programs.begin(); it != programs.end(); it++) {
198 throw ProcessError(
"Corrupt traffic light definition '" + c.
tlID +
"' (program '" + it->first +
"')");
223 NBEdge* prohibitedFrom =
myEdges[it->prohibitedFrom]->builtEdge;
224 if (prohibitedFrom == 0) {
225 WRITE_ERROR(
"Edge '" + it->prohibitedFrom +
"' in prohibition was not built");
234 oc.
set(
"no-internal-links",
"true");
243 for (std::vector<Crossing>::const_iterator it_c = (*it).second.begin(); it_c != (*it).second.end(); ++it_c) {
246 for (std::vector<std::string>::const_iterator it_e = crossing.
crossingEdges.begin(); it_e != crossing.
crossingEdges.end(); ++it_e) {
249 edges.push_back(edge);
332 WRITE_ERROR(
"Unmatched closing tag for tl-logic.");
346 for (std::vector<Crossing>::iterator it = crossings.begin(); it != crossings.end(); ++it) {
403 WRITE_ERROR(
"Unknown spreadType '" + lsfS +
"' for edge '" +
id +
"'.");
416 WRITE_ERROR(
"Found lane '" +
id +
"' not within edge element");
423 assert(crossings.size() > 0);
424 crossings.back().laneID = id;
472 WRITE_WARNING(
"Unknown node type for junction '" +
id +
"'.");
478 WRITE_ERROR(
"Problems on adding junction '" +
id +
"'.");
500 if (
myEdges.count(fromID) == 0) {
501 WRITE_ERROR(
"Unknown edge '" + fromID +
"' given in connection.");
511 if (conn.
tlID !=
"") {
514 if (from->
lanes.size() <= (size_t) fromLaneIdx) {
515 WRITE_ERROR(
"Invalid lane index '" +
toString(fromLaneIdx) +
"' for connection from '" + fromID +
"'.");
518 from->
lanes[fromLaneIdx]->connections.push_back(conn);
545 assert(edge->
id == edge_id);
546 if (edge->
lanes.size() <= (size_t) index) {
547 WRITE_ERROR(
"Unknown lane '" + lane_id +
"' given in succedge.");
550 return edge->
lanes[index];
558 size_t sep_index = lane_id.rfind(
'_');
559 if (sep_index == std::string::npos) {
560 WRITE_ERROR(
"Invalid lane id '" + lane_id +
"' (missing '_').");
562 edge_id = lane_id.substr(0, sep_index);
563 std::string index_string = lane_id.substr(sep_index + 1);
567 WRITE_ERROR(
"Invalid lane index '" + index_string +
"' for lane '" + lane_id +
"'.");
575 WRITE_ERROR(
"Definition of tl-logic '" + currentTL->
getID() +
"' was not finished.");
587 WRITE_ERROR(
"Unknown traffic light type '" + typeS +
"' for tlLogic '" +
id +
"'.");
604 const std::string&
id = currentTL->
getID();
617 currentTL->
addPhase(duration, state);
630 const size_t noLanes = edge->
lanes.size();
637 for (
unsigned int i = 1; i < firstLane.size() - 1; i++) {
645 Position(from.
x() + offsets.first, from.
y() + offsets.second),
646 Position(me.
x() + offsets.first, me.
y() + offsets.second));
649 Position(me.
x() + offsets2.first, me.
y() + offsets2.second),
650 Position(to.
x() + offsets2.first, to.
y() + offsets2.second));
655 WRITE_WARNING(
"Could not reconstruct shape for edge '" + edge->
id +
"'.");
675 result =
new GeoConvHelper(proj, networkOffset, origBoundary, convBoundary);
697 size_t div = attr.find(
"->");
698 if (div == std::string::npos) {
699 WRITE_ERROR(
"Missing connection divider in prohibition attribute '" + attr +
"'");
702 from = attr.substr(0, div);
703 to = attr.substr(div + 2);
705 if (from.find(
'_') != std::string::npos) {
706 from = from.substr(0, from.find(
'_'));
708 if (to.find(
'_') != std::string::npos) {
709 to = to.substr(0, to.find(
'_'));
712 if (
myEdges.count(from) == 0) {
713 WRITE_ERROR(
"Unknown edge prohibition '" + from +
"'");
717 WRITE_ERROR(
"Unknown edge prohibition '" + to +
"'");
std::map< std::string, EdgeAttrs * > myEdges
Loaded edge definitions.
LaneAttrs * myCurrentLane
The currently parsed lanes's definition (to add the shape to)
The information about how to spread the lanes from the given position.
bool hasConnectionTo(NBEdge *destEdge, unsigned int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
PositionVector shape
This edges's shape.
std::vector< Prohibition > myProhibitions
Loaded prohibitions.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
std::set< std::string > deprecatedVehicleClassesSeen
const SUMOReal SUMO_const_laneWidth
void haveSeenRoundabouts()
declare that roundabouts have been seen during loading
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
static bool isReadable(std::string path)
Checks whether the given file is readable.
NBNodeCont & myNodeCont
The node container to fill.
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
SUMOReal maxSpeed
The maximum velocity allowed on this lane.
A loaded (complete) traffic light logic.
std::vector< LaneAttrs * > lanes
This edge's lanes.
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Describes a pedestrian crossing.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea ...
const std::string & getProgramID() const
Returns the ProgramID.
The representation of a single edge during network building.
void declareConnectionsAsLoaded()
A connection description.
std::vector< std::string > response
void addCrossing(EdgeVector edges, SUMOReal width, bool priority)
add a pedestrian crossing to this node
static void setLoaded(const GeoConvHelper &loaded)
sets the coordinate transformation loaded from a location element
static std::pair< SUMOReal, SUMOReal > laneOffset(const Position &from, const Position &to, SUMOReal laneCenterOffset, bool leftHand)
Computes the offset from the edge shape on the current segment.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge's lane and an approached one.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
static NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
begins the reading of a traffic lights logic
const SUMOReal SUMO_const_laneOffset
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
SAX-handler base for SUMO-files.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
NIImporter_SUMO(NBNetBuilder &nb)
Constructor.
SUMOReal x() const
Returns the x-position.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
virtual SumoXMLEdgeFunc getEdgeFunc(bool &ok) const =0
Returns the value of the named attribute.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
Describes the values found in a lane's definition.
The connection was computed and validated.
LaneAttrs * getLaneAttrsFromID(EdgeAttrs *edge, std::string lane_id)
Parses lane index from lane ID an retrieve lane from EdgeAttrs.
static OptionsCont & getOptions()
Retrieves the options.
std::string toEdgeID
The id of the target edge.
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and stores the values in "myCurrentLane".
NBNetBuilder & myNetBuilder
The network builder to fill.
const std::string & getID() const
Returns the id.
void addConnection(const SUMOSAXAttributes &attrs)
Parses a connection and saves it into the lane's definition stored in "myCurrentLane".
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
std::string toNode
The node this edge ends at.
const Position & getPosition() const
Returns the position of this node.
Describes the values found in an edge's definition and this edge's lanes.
void setFileName(const std::string &name)
Sets the current file name.
JunctionAttrs myCurrentJunction
The currently parsed junction definition to help in reconstructing crossings.
static methods for processing the coordinates conversion for the current net
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string getLaneID(unsigned int lane) const
std::vector< std::string > crossingEdges
std::string allow
This lane's allowed vehicle classes.
Encapsulated SAX-Attributes.
static GeoConvHelper * loadLocation(const SUMOSAXAttributes &attrs)
Parses network location description and registers it with GeoConveHelper::setLoaded.
static StringBijection< TrafficLightType > TrafficLightTypes
Describes the values found in a prohibition.
A point in 2D or 3D with translation and scaling methods.
Importer for networks stored in SUMO format.
std::string tlID
The id of the traffic light that controls this connection.
NBEdgeCont & getEdgeCont()
Returns the edge container.
EdgeAttrs * myCurrentEdge
The currently parsed edge's definition (to add loaded lanes to)
virtual SUMOReal getFloat(int id) const =0
Returns the SUMOReal-value of the named (by its enum-value) attribute.
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file) ...
void parseProhibitionConnection(const std::string &attr, std::string &from, std::string &to, bool &ok)
parses connection string of a prohibition (very old school)
LaneSpreadFunction lsf
The lane spread function.
std::string prohibitorFrom
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
std::string prohibitedFrom
#define PROGRESS_BEGIN_MESSAGE(msg)
std::string disallow
This lane's disallowed vehicle classes.
unsigned int tlLinkNo
The index of this connection within the controlling traffic light.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void setLoadedLength(SUMOReal val)
NBEdge * builtEdge
The built edge.
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
static PositionVector reconstructEdgeShape(const EdgeAttrs *edge, const Position &from, const Position &to)
reconstructs the edge shape from the node positions and the given lane shapes since we do not know th...
SumoXMLEdgeFunc func
This edge's function.
void _loadNetwork(OptionsCont &oc)
load the network
SUMOReal width
The width of this lane.
SUMOReal getEndOffset() const
Returns the offset to the destination node.
static void interpretLaneID(const std::string &lane_id, std::string &edge_id, unsigned int &index)
parses edge-id and index from lane-id
bool intersects(const Line &l) const
std::vector< std::string > intLanes
SUMOReal endOffset
This lane's offset from the intersection.
std::string streetName
This edge's street name.
static void loadNetwork(OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
SUMOReal maxSpeed
The maximum velocity allowed on this edge (!!!)
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
void extrapolateBy(SUMOReal length)
void push_back(const PositionVector &p)
Appends all positions from the given vector.
static int _2int(const E *const data)
NBNode * getToNode() const
Returns the destination node of the edge.
std::vector< Connection > connections
This lane's connections.
void addJunction(const SUMOSAXAttributes &attrs)
Parses a junction and saves it in the node control.
std::string type
This edge's type.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Instance responsible for building networks.
unsigned int toLaneIdx
The index of the target lane.
void addPhase(SUMOTime duration, const std::string &state)
Adds a phase to the logic the new phase is inserted at the end of the list of already added phases...
std::vector< NBEdge * > EdgeVector
SUMOReal y() const
Returns the y-position.
static Position readPosition(const SUMOSAXAttributes &attrs, const std::string &id, bool &ok)
read position from the given attributes, attribute errors to id
std::map< std::string, std::vector< Crossing > > myPedestrianCrossings
The pedestrian crossings found in the network.
A storage for options typed value containers)
int priority
This edge's priority.
std::string id
This edge's id.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
void myEndElement(int element)
Called when a closing tag occurs.
std::string fromNode
The node this edge starts at.
Represents a single node (junction) during network building.
T get(const std::string &str) const
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
~NIImporter_SUMO()
Destructor.
void addRequest(const SUMOSAXAttributes &attrs)
Parses a reques and saves selected attributes in myCurrentJunction.
GeoConvHelper * myLocation
The coordinate transformation which was used to build the loaded network.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
PositionVector shape
This lane's shape (needed to reconstruct edge shape for legacy networks)
bool hasLaneSpecificWidth() const
whether lanes differ in width
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
NBTrafficLightLogicCont & myTLLCont
The node container to fill.
SUMOReal length
The length of the edge if set explicitly.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
#define PROGRESS_DONE_MESSAGE()
void addProhibition(const SUMOSAXAttributes &attrs)
Parses a prohibition and saves it.
Position intersectsAt(const Line &l) const
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex)
Adds a connection and immediately informs the edges.