SUMO - Simulation of Urban MObility
NIImporter_OpenStreetMap Class Reference

Importer for networks stored in OpenStreetMap format. More...

#include <NIImporter_OpenStreetMap.h>

Collaboration diagram for NIImporter_OpenStreetMap:
Collaboration graph

Data Structures

class  CompareEdges
 Functor which compares two Edges. More...
 
class  CompareNodes
 Functor which compares two NIOSMNodes according to their coordinates. More...
 
struct  Edge
 An internal definition of a loaded edge. More...
 
class  EdgesHandler
 A class which extracts OSM-edges from a parsed OSM-file. More...
 
struct  NIOSMNode
 An internal representation of an OSM-node. More...
 
class  NodesHandler
 A class which extracts OSM-nodes from a parsed OSM-file. More...
 
class  RelationHandler
 A class which extracts relevant relation information from a parsed OSM-file. More...
 

Static Public Member Functions

static void loadNetwork (const OptionsCont &oc, NBNetBuilder &nb)
 Loads content of the optionally given OSM file. More...
 

Protected Types

enum  ParkingType {
  PARKING_NONE = 0, PARKING_LEFT = 1, PARKING_RIGHT = 2, PARKING_BOTH = WAY_FORWARD | WAY_BACKWARD,
  PARKING_UNKNOWN = 4, PARKING_FORBIDDEN = 8, PARKING_PERPENDICULAR = 16, PARKING_DIAGONAL = 32
}
 
enum  WayType {
  WAY_NONE = 0, WAY_FORWARD = 1, WAY_BACKWARD = 2, WAY_BOTH = WAY_FORWARD | WAY_BACKWARD,
  WAY_UNKNOWN = 4
}
 

Protected Member Functions

void load (const OptionsCont &oc, NBNetBuilder &nb)
 
 NIImporter_OpenStreetMap ()
 
 ~NIImporter_OpenStreetMap ()
 

Static Protected Attributes

static const long long int INVALID_ID = std::numeric_limits<long long int>::max()
 
static const double MAXSPEED_UNGIVEN = -1
 

Private Member Functions

std::map< NBNode *, std::pair< double, double > > getNeighboringNodes (NBNode *node, double maxDist, const std::set< NBNode *> &knownElevation)
 collect neighboring nodes with their road distance and maximum between-speed. Search does not continue beyond knownElevation-nodes More...
 
int insertEdge (Edge *e, int index, NBNode *from, NBNode *to, const std::vector< long long int > &passed, NBNetBuilder &nb)
 Builds an NBEdge. More...
 
NBNodeinsertNodeChecking (long long int id, NBNodeCont &nc, NBTrafficLightLogicCont &tlsc)
 Builds an NBNode. More...
 
void reconstructLayerElevation (double layerElevation, NBNetBuilder &nb)
 reconstruct elevation from layer info More...
 

Private Attributes

std::map< long long int, Edge * > myEdges
 the map from OSM way ids to edge objects More...
 
std::map< std::string, std::string > myKnownCompoundTypes
 The compound types that have already been mapped to other known types. More...
 
std::map< long long int, NIOSMNode * > myOSMNodes
 the map from OSM node ids to actual nodes More...
 
std::map< long long int, Edge * > myPlatformShapes
 the map from OSM way ids to platform shapes More...
 
std::set< NIOSMNode *, CompareNodesmyUniqueNodes
 the set of unique nodes used in NodesHandler, used when freeing memory More...
 
std::set< std::string > myUnusableTypes
 The compounds types that do not contain known types. More...
 

Static Private Attributes

static const std::string compoundTypeSeparator
 The separator within newly created compound type names. More...
 

Friends

class NodesHandler
 

Detailed Description

Importer for networks stored in OpenStreetMap format.

Definition at line 59 of file NIImporter_OpenStreetMap.h.

Member Enumeration Documentation

◆ ParkingType

Enumerator
PARKING_NONE 
PARKING_LEFT 
PARKING_RIGHT 
PARKING_BOTH 
PARKING_UNKNOWN 
PARKING_FORBIDDEN 
PARKING_PERPENDICULAR 
PARKING_DIAGONAL 

Definition at line 135 of file NIImporter_OpenStreetMap.h.

◆ WayType

Enumerator
WAY_NONE 
WAY_FORWARD 
WAY_BACKWARD 
WAY_BOTH 
WAY_UNKNOWN 

Definition at line 127 of file NIImporter_OpenStreetMap.h.

Constructor & Destructor Documentation

◆ NIImporter_OpenStreetMap()

NIImporter_OpenStreetMap::NIImporter_OpenStreetMap ( )
protecteddefault

Referenced by loadNetwork().

◆ ~NIImporter_OpenStreetMap()

NIImporter_OpenStreetMap::~NIImporter_OpenStreetMap ( )
protected

Definition at line 110 of file NIImporter_OpenStreetMap.cpp.

References myEdges, myPlatformShapes, and myUniqueNodes.

Member Function Documentation

◆ getNeighboringNodes()

std::map< NBNode *, std::pair< double, double > > NIImporter_OpenStreetMap::getNeighboringNodes ( NBNode node,
double  maxDist,
const std::set< NBNode *> &  knownElevation 
)
private

collect neighboring nodes with their road distance and maximum between-speed. Search does not continue beyond knownElevation-nodes

Definition at line 1662 of file NIImporter_OpenStreetMap.cpp.

References NBNode::getEdges(), NBNode::hasIncoming(), MAX2(), and MIN2().

Referenced by reconstructLayerElevation().

◆ insertEdge()

int NIImporter_OpenStreetMap::insertEdge ( Edge e,
int  index,
NBNode from,
NBNode to,
const std::vector< long long int > &  passed,
NBNetBuilder nb 
)
private

Builds an NBEdge.

Parameters
[in]eThe definition of the edge
[in]indexThe index of the edge (in the case it is split along her nodes)
[in]fromThe origin node of the edge
[in]toThe destination node of the edge
[in]passedThe list of passed nodes (geometry information)
[in]osmNodesContainer of node definitions for getting information about nodes from
[in,out]TheNetBuilder instance
Returns
the new index if the edge is split
Exceptions
ProcessErrorIf the edge could not be added to the container

XXX parking area should be added on the left side of a reverse one-way street

put it on the wrong side (better than nothing)

XXX parking area should be added on the left side of an one-way street

put it on the wrong side (better than nothing)

Definition at line 307 of file NIImporter_OpenStreetMap.cpp.

References NBEdge::addBikeLane(), NBEdge::addSidewalk(), compoundTypeSeparator, NBTypeCont::copyRestrictionsAndAttrs(), NIImporter_OpenStreetMap::NIOSMNode::ele, StringUtils::escapeXML(), NBPTStopCont::get(), NBTypeCont::getBikeLaneWidth(), OptionsCont::getBool(), NBNetBuilder::getEdgeCont(), OptionsCont::getFloat(), NBTypeCont::getIsOneWay(), NBNetBuilder::getNodeCont(), NBTypeCont::getNumLanes(), OptionsCont::getOptions(), Parameterised::getParameter(), Parameterised::getParametersMap(), NBNetBuilder::getParkingCont(), NBTypeCont::getPermissions(), NBEdge::getPermissions(), NBTypeCont::getPriority(), NBNetBuilder::getPTStopCont(), NBTypeCont::getShallBeDiscarded(), NBTypeCont::getSidewalkWidth(), NBTypeCont::getSpeed(), NBNetBuilder::getTLLogicCont(), NBNetBuilder::getTypeCont(), NBTypeCont::getWidth(), StringTokenizer::hasNext(), NIImporter_OpenStreetMap::NIOSMNode::id, NIImporter_OpenStreetMap::Edge::id, NBPTStopCont::insert(), NBTypeCont::insert(), NBEdgeCont::insert(), insertNodeChecking(), OptionsCont::isSet(), joinToString(), NBTypeCont::knows(), LANESPREAD_CENTER, LANESPREAD_RIGHT, NIImporter_OpenStreetMap::NIOSMNode::lat, NIImporter_OpenStreetMap::NIOSMNode::lon, MAX2(), MAXSPEED_UNGIVEN, NIImporter_OpenStreetMap::Edge::myBuswayType, NIImporter_OpenStreetMap::Edge::myCyclewayType, NIImporter_OpenStreetMap::Edge::myHighWayType, NIImporter_OpenStreetMap::Edge::myIsOneWay, myKnownCompoundTypes, NIImporter_OpenStreetMap::Edge::myMaxSpeed, NIImporter_OpenStreetMap::Edge::myNoLanes, NIImporter_OpenStreetMap::Edge::myNoLanesForward, myOSMNodes, NIImporter_OpenStreetMap::Edge::myParkingType, NIImporter_OpenStreetMap::Edge::mySidewalkType, myUnusableTypes, NIImporter_OpenStreetMap::NIOSMNode::name, StringTokenizer::next(), PARKING_BOTH, PARKING_LEFT, PARKING_RIGHT, NIImporter_OpenStreetMap::NIOSMNode::permissions, NIImporter_OpenStreetMap::NIOSMNode::ptStopLength, NIImporter_OpenStreetMap::NIOSMNode::ptStopPosition, NBPTStop::registerAdditionalEdge(), PositionVector::reverse(), NBEdge::setPermissions(), StringTokenizer::size(), NIImporter_OpenStreetMap::Edge::streetName, SUMO_const_laneWidth, SVC_BICYCLE, SVC_BUS, SVC_PEDESTRIAN, SVC_RAIL_CLASSES, toString(), NBNetBuilder::transformCoordinate(), NBNetBuilder::transformCoordinates(), NBEdge::UNSPECIFIED_OFFSET, NBEdge::UNSPECIFIED_WIDTH, Parameterised::updateParameter(), WAY_BACKWARD, WAY_FORWARD, WAY_UNKNOWN, WRITE_ERROR, WRITE_MESSAGE, and WRITE_WARNING.

Referenced by load().

◆ insertNodeChecking()

NBNode * NIImporter_OpenStreetMap::insertNodeChecking ( long long int  id,
NBNodeCont nc,
NBTrafficLightLogicCont tlsc 
)
private

Builds an NBNode.

If a node with the given id is already known, nothing is done. Otherwise, the position and other information of the node is retrieved from the given node map, the node is built and added to the given node container. If the node is controlled by a tls, the according tls is built and added to the tls container.

Parameters
[in]idThe id of the node to build
[in]osmNodesMap of node ids to information about these
[in,out]ncThe node container to add the built node to
[in,out]tlscThe traffic lights logic container to add the built tls to
Returns
The built/found node
Exceptions
ProcessErrorIf the tls could not be added to the container

Definition at line 266 of file NIImporter_OpenStreetMap.cpp.

References NIImporter_OpenStreetMap::NIOSMNode::ele, StringBijection< T >::get(), OptionsCont::getOptions(), NBNodeCont::insert(), NBTrafficLightLogicCont::insert(), NIImporter_OpenStreetMap::NIOSMNode::lat, NIImporter_OpenStreetMap::NIOSMNode::lon, myOSMNodes, NIImporter_OpenStreetMap::NIOSMNode::node, NODETYPE_RAIL_CROSSING, NODETYPE_RAIL_SIGNAL, NIImporter_OpenStreetMap::NIOSMNode::railwayBufferStop, NIImporter_OpenStreetMap::NIOSMNode::railwayCrossing, NIImporter_OpenStreetMap::NIOSMNode::railwaySignal, NBNode::reinit(), NBNodeCont::retrieve(), Parameterised::setParameter(), NIImporter_OpenStreetMap::NIOSMNode::tlsControlled, toString(), SUMOXMLDefinitions::TrafficLightTypes, NBNetBuilder::transformCoordinate(), and WRITE_ERROR.

Referenced by insertEdge(), and load().

◆ load()

◆ loadNetwork()

void NIImporter_OpenStreetMap::loadNetwork ( const OptionsCont oc,
NBNetBuilder nb 
)
static

Loads content of the optionally given OSM file.

If the option "osm-files" is set, the file(s) stored therein is read and the network definition stored therein is stored within the given network builder.

If the option "osm-files" is not set, this method simply returns.

Parameters
[in]ocThe options to use
[in,out]nbThe network builder to fill

Definition at line 103 of file NIImporter_OpenStreetMap.cpp.

References load(), and NIImporter_OpenStreetMap().

Referenced by NILoader::load().

◆ reconstructLayerElevation()

Friends And Related Function Documentation

◆ NodesHandler

friend class NodesHandler
friend

Definition at line 293 of file NIImporter_OpenStreetMap.h.

Field Documentation

◆ compoundTypeSeparator

const std::string NIImporter_OpenStreetMap::compoundTypeSeparator
staticprivate

The separator within newly created compound type names.

Definition at line 221 of file NIImporter_OpenStreetMap.h.

Referenced by insertEdge(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), and NIImporter_OpenStreetMap::CompareEdges::operator()().

◆ INVALID_ID

◆ MAXSPEED_UNGIVEN

const double NIImporter_OpenStreetMap::MAXSPEED_UNGIVEN = -1
staticprotected

◆ myEdges

std::map<long long int, Edge*> NIImporter_OpenStreetMap::myEdges
private

the map from OSM way ids to edge objects

Definition at line 235 of file NIImporter_OpenStreetMap.h.

Referenced by load(), reconstructLayerElevation(), and ~NIImporter_OpenStreetMap().

◆ myKnownCompoundTypes

std::map<std::string, std::string> NIImporter_OpenStreetMap::myKnownCompoundTypes
private

The compound types that have already been mapped to other known types.

Definition at line 244 of file NIImporter_OpenStreetMap.h.

Referenced by insertEdge().

◆ myOSMNodes

std::map<long long int, NIOSMNode*> NIImporter_OpenStreetMap::myOSMNodes
private

the map from OSM node ids to actual nodes

Note
: NIOSMNodes may appear multiple times due to substition

Definition at line 223 of file NIImporter_OpenStreetMap.h.

Referenced by insertEdge(), insertNodeChecking(), and load().

◆ myPlatformShapes

std::map<long long int, Edge*> NIImporter_OpenStreetMap::myPlatformShapes
private

the map from OSM way ids to platform shapes

Definition at line 238 of file NIImporter_OpenStreetMap.h.

Referenced by load(), and ~NIImporter_OpenStreetMap().

◆ myUniqueNodes

std::set<NIOSMNode*, CompareNodes> NIImporter_OpenStreetMap::myUniqueNodes
private

the set of unique nodes used in NodesHandler, used when freeing memory

Definition at line 231 of file NIImporter_OpenStreetMap.h.

Referenced by load(), and ~NIImporter_OpenStreetMap().

◆ myUnusableTypes

std::set<std::string> NIImporter_OpenStreetMap::myUnusableTypes
private

The compounds types that do not contain known types.

Definition at line 241 of file NIImporter_OpenStreetMap.h.

Referenced by insertEdge().


The documentation for this class was generated from the following files: