105 importer.
load(oc, nb);
117 delete myEdge.second;
121 delete myPlatformShape.second;
128 if (!oc.
isSet(
"osm-files")) {
136 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
139 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
151 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
160 if (!oc.
getBool(
"osm.skip-duplicates-check")) {
163 std::set<const Edge*, CompareEdges> dupsFinder;
165 if (dupsFinder.count(it->second) > 0) {
170 dupsFinder.insert(it->second);
181 std::map<long long int, int> nodeUsage;
183 for (std::map<long long int, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
184 Edge* e = (*i).second;
186 for (std::vector<long long int>::const_iterator j = e->
myCurrentNodes.begin();
189 if (nodeUsage.find(*j) == nodeUsage.end()) {
192 nodeUsage[*j] = nodeUsage[*j] + 1;
196 for (std::map<long long int, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin();
199 if (nodesIt->second->tlsControlled || nodesIt->second->railwaySignal ) {
202 nodeUsage[nodesIt->first] += 1;
212 Edge* e = myEdge.second;
225 std::vector<long long int> passed;
227 passed.push_back(*j);
230 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
231 currentFrom = currentTo;
233 passed.push_back(*j);
239 insertEdge(e, running, currentFrom, last, passed, nb);
242 const double layerElevation = oc.
getFloat(
"osm.layer-elevation");
243 if (layerElevation > 0) {
256 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
293 if (!tlsc.
insert(tlDef)) {
308 const std::vector<long long int>& passed,
NBNetBuilder& nb) {
317 if (from == 0 || to == 0) {
318 WRITE_ERROR(
"Discarding edge '" +
id +
"' because the nodes could not be built.");
327 assert(passed.size() >= 2);
328 if (passed.size() == 2) {
329 WRITE_WARNING(
"Discarding edge '" +
id +
"' which connects two identical nodes without geometry.");
333 int intermediateIndex = (int) passed.size() / 2;
335 std::vector<long long int> part1(passed.begin(), passed.begin() + intermediateIndex + 1);
336 std::vector<long long int> part2(passed.begin() + intermediateIndex, passed.end());
337 index =
insertEdge(e, index, from, intermediate, part1, nb);
338 return insertEdge(e, index, intermediate, to, part2, nb);
340 const int newIndex = index + 1;
344 for (
long long i : passed) {
349 if (existingPtStop !=
nullptr) {
363 shape.push_back(pos);
366 WRITE_ERROR(
"Unable to project coordinates for edge '" +
id +
"'.");
371 if (!tc.
knows(type)) {
380 std::vector<std::string> types;
382 std::string t = tok.
next();
384 if (std::find(types.begin(), types.end(), t) == types.end()) {
387 }
else if (tok.
size() > 1) {
389 "Discarding unknown compound '" + t +
"' in type '" + type +
"' (first occurence for edge '" 395 WRITE_WARNING(
"Discarding unusable type '" + type +
"' (first occurence for edge '" +
id +
"').");
401 if (tc.
knows(newType)) {
414 bool defaultIsOneWay =
false;
417 for (
auto& type2 : types) {
444 "Discarding compound type '" + newType +
"' (first occurence for edge '" +
id +
"').");
449 WRITE_MESSAGE(
"Adding new type '" + type +
"' (first occurence for edge '" +
id +
"').");
450 tc.
insert(newType, numLanes, maxSpeed, prio, permissions, width, defaultIsOneWay, sidewalkWidth,
452 for (
auto& type3 : types) {
473 double forwardWidth = tc.
getWidth(type);
474 double backwardWidth = tc.
getWidth(type);
478 bool addForward =
true;
479 bool addBackward =
true;
482 e->
getParameter(
"railway:preferred_direction",
"") !=
"both")) {
496 if (addForward && !addBackward) {
498 }
else if (!addForward && addBackward) {
506 numLanesForward = (int) std::ceil(e->
myNoLanes / 2.0);
508 numLanesBackward = e->
myNoLanes - numLanesForward;
511 numLanesForward =
MAX2(1, numLanesForward);
512 numLanesBackward =
MAX2(1, numLanesBackward);
515 WRITE_WARNING(
"Skipping edge '" +
id +
"' because it has zero lanes.");
529 if (!addForward && (cyclewayType &
WAY_FORWARD) != 0) {
535 cyclewayType = (
WayType)(cyclewayType & ~WAY_FORWARD);
537 if (!addBackward && (cyclewayType &
WAY_BACKWARD) != 0) {
541 numLanesBackward = 1;
543 cyclewayType = (
WayType)(cyclewayType & ~WAY_BACKWARD);
549 if (!addForward && (sidewalkType &
WAY_FORWARD) != 0) {
555 sidewalkType = (
WayType)(sidewalkType & ~WAY_FORWARD);
557 if (!addBackward && (sidewalkType &
WAY_BACKWARD) != 0) {
561 numLanesBackward = 1;
563 sidewalkType = (
WayType)(sidewalkType & ~WAY_BACKWARD);
575 numLanesBackward = 1;
584 const std::string reverseID =
"-" + id;
587 assert(numLanesForward > 0);
601 if (addSidewalk && (sidewalkType ==
WAY_UNKNOWN || (sidewalkType & WAY_FORWARD) != 0)) {
611 assert(numLanesBackward > 0);
625 if (addSidewalk && (sidewalkType ==
WAY_UNKNOWN || (sidewalkType & WAY_BACKWARD) != 0)) {
631 throw ProcessError(
"Could not add edge '-" +
id +
"'.");
666 std::set<NIOSMNode*, CompareNodes>& uniqueNodes,
673 myIsInValidNodeTag(false),
676 myImportElevation(oc.getBool(
"osm.elevation")),
695 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
697 if (action ==
"delete" || !ok) {
725 auto* toAdd =
new NIOSMNode(
id, tlon, tlat);
733 toAdd = *similarNode;
741 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
747 if (key ==
"highway" || key ==
"ele" || key ==
"crossing" || key ==
"railway" || key ==
"public_transport" 748 || key ==
"name" || key ==
"train" || key ==
"bus" || key ==
"tram" || key ==
"light_rail" || key ==
"subway" || key ==
"station" || key ==
"noexit" 751 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
753 }
else if (key ==
"crossing" && value.find(
"traffic_signals") != std::string::npos) {
755 }
else if ((key ==
"noexit" && value ==
"yes")
756 || (key ==
"railway" && value ==
"buffer_stop")) {
758 }
else if (key ==
"railway" && value.find(
"crossing") != std::string::npos) {
761 value ==
"block" || value ==
"entry" || value ==
"exit" || value ==
"intermediate")) {
763 }
else if ((key ==
"public_transport" && value ==
"stop_position") ||
764 (key ==
"highway" && value ==
"bus_stop")) {
770 }
else if (key ==
"name") {
772 }
else if (key ==
"train") {
775 }
else if (key ==
"subway" || key ==
"light_rail" 776 || (key ==
"station" && (value ==
"subway" || value ==
"light_rail"))) {
779 }
else if (key ==
"bus") {
782 }
else if (key ==
"tram") {
789 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in node '" +
810 const std::map<long long int, NIOSMNode*>& osmNodes,
811 std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes)
816 myPlatformShapesMap(platformShapes) {
836 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
838 if (action ==
"delete" || !ok) {
855 ref = node->second->id;
873 const std::string cyclewaySpec = key.substr(9);
875 if (cyclewaySpec ==
"right") {
877 }
else if (cyclewaySpec ==
"left") {
879 }
else if (cyclewaySpec ==
"both") {
890 const std::string buswaySpec = key.substr(7);
892 if (buswaySpec ==
"right") {
894 }
else if (buswaySpec ==
"left") {
896 }
else if (buswaySpec ==
"both") {
907 && key !=
"maxspeed" && key !=
"junction" && key !=
"name" && key !=
"tracks" && key !=
"layer" 911 && key !=
"postal_code" && key !=
"railway:preferred_direction" && key !=
"public_transport") {
916 if ((key ==
"highway" && value !=
"platform") || key ==
"railway" || key ==
"waterway" || key ==
"cycleway" 917 || key ==
"busway" || key ==
"route" || key ==
"sidewalk") {
920 if (key ==
"cycleway") {
924 if (value ==
"opposite_track") {
926 }
else if (value ==
"opposite_lane") {
931 if (key ==
"sidewalk") {
932 if (value ==
"no" || value ==
"none") {
934 }
else if (value ==
"both") {
936 }
else if (value ==
"right") {
938 }
else if (value ==
"left") {
945 if (key ==
"busway") {
949 if (value ==
"opposite_track") {
951 }
else if (value ==
"opposite_lane") {
958 const std::string singleTypeID = key +
"." + value;
964 types.push_back(singleTypeID);
969 }
else if (key ==
"lanes") {
975 std::vector<std::string> list = st.
getVector();
976 if (list.size() >= 2) {
977 int minLanes = std::numeric_limits<int>::max();
979 for (
auto& i : list) {
981 minLanes =
MIN2(minLanes, numLanes);
985 "Using minimum lane number from list (" + value +
") for edge '" 989 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
994 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
997 }
else if (key ==
"lanes:forward") {
1001 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1004 }
else if (key ==
"lanes:backward") {
1009 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1012 }
else if (key ==
"maxspeed") {
1016 double conversion = 1;
1021 conversion = 1.609344;
1026 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1030 }
else if (key ==
"junction") {
1034 }
else if (key ==
"oneway") {
1036 }
else if (key ==
"name") {
1038 }
else if (key ==
"layer") {
1042 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1045 }
else if (key ==
"tracks") {
1053 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1058 }
else if (key ==
"railway:preferred_direction") {
1061 }
else if (key ==
"public_transport" && value ==
"platform") {
1092 const std::map<long long int, NIOSMNode*>& osmNodes,
1093 const std::map<long long int, Edge*>& osmEdges,
NBPTStopCont* nbptStopCont,
1094 const std::map<long long int, Edge*>& platformShapes,
1100 myOSMEdges(osmEdges),
1102 myNBPTStopCont(nbptStopCont),
1103 myNBPTLineCont(nbptLineCont),
1136 if (action ==
"delete" || !ok) {
1152 auto ref = attrs.
get<
long 1155 if (role ==
"via") {
1160 }
else if (memberType ==
"node") {
1165 "No node found for reference '" +
toString(ref) +
"' in relation '" 1174 }
else if (role ==
"stop") {
1176 }
else if (role ==
"platform") {
1178 if (memberType ==
"way") {
1179 const std::map<
long long int,
1184 platform.
isWay =
true;
1188 }
else if (memberType ==
"node") {
1190 platform.
isWay =
false;
1195 }
else if (role.empty()) {
1197 if (memberType ==
"way") {
1208 if (key ==
"type" || key ==
"restriction") {
1210 if (key ==
"type" && value ==
"restriction") {
1214 if (key ==
"type" && value ==
"route") {
1218 if (key ==
"restriction") {
1221 if (value.substr(0, 5) ==
"only_") {
1223 }
else if (value.substr(0, 3) ==
"no_") {
1232 }
else if (key ==
"public_transport") {
1234 if (value ==
"stop_area") {
1237 }
else if (key ==
"route") {
1239 if (value ==
"train" || value ==
"subway" || value ==
"light_rail" || value ==
"monorail" || value ==
"tram" || value ==
"bus" 1240 || value ==
"trolleybus" || value ==
"arialway" || value ==
"ferry") {
1244 }
else if (key ==
"name") {
1246 }
else if (key ==
"ref") {
1248 }
else if (key ==
"interval" || key ==
"headway") {
1250 }
else if (key ==
"by_night") {
1297 for (
long long ref :
myStops) {
1301 +
"' does not exist. Probably OSM file is incomplete.");
1310 +
toString(n->
id) +
"'. Probably OSM file is incomplete.");
1314 if (myPlatform.isWay) {
1317 if (edge->myCurrentNodes[0] == *(edge->myCurrentNodes.end() - 1)) {
1319 +
"' is given as polygon, which currently is not supported.");
1324 for (
auto nodeRef : edge->myCurrentNodes) {
1328 +
"' does not exist. Probably OSM file is incomplete.");
1337 p.push_back(pNodePos);
1339 if (p.size() == 0) {
1342 +
"' is corrupt. Probably OSM file is incomplete.");
1351 +
"' does not exist. Probably OSM file is incomplete.");
1360 "osm.stop-output.length"));
1370 for (
long long ref :
myStops) {
1374 +
"' does not exist. Probably OSM file is incomplete.");
1386 if (ptStop ==
nullptr) {
1388 +
"' refers to a non existing pt stop at node: '" +
toString(n->
id)
1389 +
"'. Probably OSM file is incomplete.");
1400 for (
long long& myWay :
myWays) {
1403 Edge* edge = entr->second;
1433 WRITE_WARNING(
"from-edge of restriction relation could not be determined");
1437 WRITE_WARNING(
"to-edge of restriction relation could not be determined");
1447 WRITE_WARNING(
"direction of restriction relation could not be determined");
1455 const std::vector<NBEdge*>& candidates)
const {
1456 const std::string prefix =
toString(wayRef);
1457 const std::string backPrefix =
"-" + prefix;
1460 for (
auto candidate : candidates) {
1461 if ((candidate->getID().substr(0, prefix.size()) == prefix) ||
1462 (candidate->getID().substr(0, backPrefix.size()) == backPrefix)) {
1468 WRITE_WARNING(
"Ambigous way reference '" + prefix +
"' in restriction relation");
1481 std::map<NBNode*, std::vector<std::pair<double, double> > > layerForces;
1484 std::set<NBNode*> knownElevation;
1485 for (
auto& myEdge :
myEdges) {
1486 Edge* e = myEdge.second;
1491 knownElevation.insert(node);
1497 #ifdef DEBUG_LAYER_ELEVATION 1498 std::cout <<
"known elevations:\n";
1499 for (std::set<NBNode*>::iterator it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1500 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1501 std::cout <<
" node=" << (*it)->
getID() <<
" ele=";
1502 for (std::vector<std::pair<double, double> >::const_iterator it_ele = primaryLayers.begin(); it_ele != primaryLayers.end(); ++it_ele) {
1503 std::cout << it_ele->first <<
" ";
1511 std::map<NBNode*, double> knownEleMax;
1512 for (
auto it : knownElevation) {
1513 double eleMax = -std::numeric_limits<double>::max();
1514 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[it];
1515 for (
const auto& primaryLayer : primaryLayers) {
1516 eleMax =
MAX2(eleMax, primaryLayer.first);
1518 knownEleMax[it] = eleMax;
1521 bool changed =
true;
1524 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1527 / gradeThreshold * 3,
1529 for (
auto& neighbor : neighbors) {
1530 if (knownElevation.count(neighbor.first) != 0) {
1531 const double grade = fabs(knownEleMax[*it] - knownEleMax[neighbor.first])
1533 #ifdef DEBUG_LAYER_ELEVATION 1534 std::cout <<
" grade at node=" << (*it)->getID() <<
" ele=" << knownEleMax[*it] <<
" neigh=" << it_neigh->first->getID() <<
" neighEle=" << knownEleMax[it_neigh->first] <<
" grade=" << grade <<
" dist=" << it_neigh->second.first <<
" speed=" << it_neigh->second.second <<
"\n";
1536 if (grade > gradeThreshold * 50 / 3.6 / neighbor.second.second) {
1538 const double eleMax =
MAX2(knownEleMax[*it], knownEleMax[neighbor.first]);
1539 if (knownEleMax[*it] < eleMax) {
1540 knownEleMax[*it] = eleMax;
1542 knownEleMax[neighbor.first] = eleMax;
1552 std::set<NBNode*> unknownElevation;
1553 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1554 const double eleMax = knownEleMax[*it];
1555 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1556 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1557 for (
auto& neighbor : neighbors) {
1558 if (knownElevation.count(neighbor.first) == 0) {
1559 unknownElevation.insert(neighbor.first);
1560 layerForces[neighbor.first].emplace_back(eleMax, neighbor.second.first);
1566 for (
auto it = unknownElevation.begin(); it != unknownElevation.end(); ++it) {
1567 double eleMax = -std::numeric_limits<double>::max();
1568 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1569 for (
const auto& primaryLayer : primaryLayers) {
1570 eleMax =
MAX2(eleMax, primaryLayer.first);
1572 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1573 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1574 for (
auto& neighbor : neighbors) {
1575 if (knownElevation.count(neighbor.first) == 0 && unknownElevation.count(neighbor.first) == 0) {
1576 layerForces[*it].emplace_back(0, neighbor.second.first);
1581 #ifdef DEBUG_LAYER_ELEVATION 1582 std::cout <<
"summation of forces\n";
1584 std::map<NBNode*, double> nodeElevation;
1585 for (
auto& layerForce : layerForces) {
1586 const std::vector<std::pair<double, double> >& forces = layerForce.second;
1587 if (knownElevation.count(layerForce.first) != 0) {
1595 #ifdef DEBUG_LAYER_ELEVATION 1596 std::cout <<
" node=" << it->first->getID() <<
" knownElevation=" << knownEleMax[it->first] <<
"\n";
1598 nodeElevation[layerForce.first] = knownEleMax[layerForce.first];
1599 }
else if (forces.size() == 1) {
1600 nodeElevation[layerForce.first] = forces.front().first;
1604 for (
const auto& force : forces) {
1605 distSum += force.second;
1607 double weightSum = 0;
1608 double elevation = 0;
1609 #ifdef DEBUG_LAYER_ELEVATION 1610 std::cout <<
" node=" << it->first->getID() <<
" distSum=" << distSum <<
"\n";
1612 for (
const auto& force : forces) {
1613 const double weight = (distSum - force.second) / distSum;
1614 weightSum += weight;
1615 elevation += force.first * weight;
1617 #ifdef DEBUG_LAYER_ELEVATION 1618 std::cout <<
" force=" << it_force->first <<
" dist=" << it_force->second <<
" weight=" << weight <<
" ele=" << elevation <<
"\n";
1621 nodeElevation[layerForce.first] = elevation / weightSum;
1624 #ifdef DEBUG_LAYER_ELEVATION 1625 std::cout <<
"final elevations:\n";
1626 for (std::map<NBNode*, double>::iterator it = nodeElevation.begin(); it != nodeElevation.end(); ++it) {
1627 std::cout <<
" node=" << (it->first)->getID() <<
" ele=" << it->second <<
"\n";;
1631 for (
auto& it : nodeElevation) {
1638 for (
const auto& it : ec) {
1639 NBEdge* edge = it.second;
1641 const double length = geom.
length2D();
1642 const double zFrom = nodeElevation[edge->
getFromNode()];
1643 const double zTo = nodeElevation[edge->
getToNode()];
1648 for (
auto it_pos = geom.begin(); it_pos != geom.end(); ++it_pos) {
1649 if (it_pos != geom.begin()) {
1650 dist += (*it_pos).distanceTo2D(*(it_pos - 1));
1652 newGeom.push_back((*it_pos) +
Position(0, 0, zFrom + (zTo - zFrom) * dist / length));
1658 std::map<NBNode*, std::pair<double, double> >
1660 std::map<NBNode*, std::pair<double, double> > result;
1661 std::set<NBNode*> visited;
1662 std::vector<NBNode*> open;
1663 open.push_back(node);
1664 result[node] = std::make_pair(0, 0);
1665 while (!open.empty()) {
1668 if (visited.count(n) != 0) {
1673 for (
auto e : edges) {
1676 s = e->getFromNode();
1680 const double dist = result[n].first + e->getGeometry().length2D();
1681 const double speed =
MAX2(e->getSpeed(), result[n].second);
1682 if (result.count(s) == 0) {
1683 result[s] = std::make_pair(dist, speed);
1685 result[s] = std::make_pair(
MIN2(dist, result[s].first),
MAX2(speed, result[s].second));
1687 if (dist < maxDist && knownElevation.count(s) == 0) {
const std::map< long long int, NIOSMNode * > & myOSMNodes
The previously parsed nodes.
An internal definition of a loaded edge.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
void insert(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth)
Adds a type into the list.
const bool myImportElevation
whether elevation data should be imported
const std::map< long long int, Edge * > & myOSMEdges
The previously parsed edges.
std::map< long long int, Edge * > & myPlatformShapesMap
A map of built edges.
The only invalid connection is declared.
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
An internal representation of an OSM-node.
const long long int id
The edge's id.
double length2D() const
Returns the length.
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
~RelationHandler() override
Destructor.
~EdgesHandler() override
Destructor.
std::string streetName
The edge's street name.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBPTLineCont * myNBPTLineCont
PT Line container to be filled.
RestrictionType myRestrictionType
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
const std::map< long long int, NIOSMNode * > & myOSMNodes
The previously parsed nodes.
const long long int id
The node's id.
static bool isReadable(std::string path)
Checks whether the given file is readable.
The only valid connection is declared.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
WayType myBuswayType
Information about the kind of busway along this road.
The relation tag was missing.
long long int myFromWay
the origination way for the current restriction
vehicle is a not electrified rail
A container for traffic light definitions and built programs.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
std::string myRef
ref of the pt line
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 continu...
NIImporter_OpenStreetMap()
const double SUMO_const_laneWidth
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
The representation of a single edge during network building.
int getPriority(const std::string &type) const
Returns the priority for the given type.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false)
Removes the specified connection(s)
long long int myCurrentRelation
The currently parsed relation.
bool checkEdgeRef(long long int ref) const
check whether a referenced way has a corresponding edge
void addPTStop(NBPTStop *pStop)
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
std::vector< NIIPTPlatform > myPlatforms
bus stop platforms
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
PositionVector reverse() const
reverse position vector
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
RelationHandler(const std::map< long long int, NIOSMNode *> &osmNodes, const std::map< long long int, Edge *> &osmEdges, NBPTStopCont *nbptStopCont, const std::map< long long int, Edge *> &platfromShapes, NBPTLineCont *nbptLineCont, const OptionsCont &oc)
Constructor.
The representation of a single pt stop.
std::vector< long long int > myStops
bus stop references
void registerAdditionalEdge(std::string wayId, std::string edgeId)
NBParkingCont & getParkingCont()
SAX-handler base for SUMO-files.
void myEndElement(int element) override
Called when a closing tag occurs.
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.
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
std::vector< long long int > myCurrentNodes
The list of nodes this edge is made of.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static const double UNSPECIFIED_WIDTH
unspecified lane width
#define WRITE_WARNING(msg)
bool railwaySignal
Whether this is a railway (main) signal.
static OptionsCont & getOptions()
Retrieves the options.
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
std::set< NIOSMNode *, CompareNodes > & myUniqueNodes
the set of unique nodes (used for duplicate detection/substitution)
NBNode * node
the NBNode that was instantiated
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
std::vector< long long int > myWays
ways in pt line references
const OptionsCont & myOptionsCont
the options cont
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given OSM file.
Functor which compares two Edges.
WayType myCyclewayType
Information about the kind of cycleway along this road.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
The representation of a single pt stop.
int myNoLanesForward
number of lanes in forward direction or 0 if unknown, negative if backwards lanes are meant ...
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
const std::map< long long int, Edge * > & myPlatformShapes
The previously parsed platform shapes.
NBEdge * findEdgeRef(long long int wayRef, const std::vector< NBEdge *> &candidates) const
try to find the way segment among candidates
bool knows(const std::string &type) const
Returns whether the named type is in the container.
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
void load(const OptionsCont &oc, NBNetBuilder &nb)
std::string myName
name of the relation
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
void setFileName(const std::string &name)
Sets the current file name.
void addWayNode(long long int way, long long int node)
void setMyNumOfStops(int numStops)
A class which extracts OSM-edges from a parsed OSM-file.
int insertEdge(Edge *e, int index, NBNode *from, NBNode *to, const std::vector< long long int > &passed, NBNetBuilder &nb)
Builds an NBEdge.
void insert(NBPTLine *pLine)
insert new line
double ele
The elevation of this node.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::vector< int > myParentElements
The element stack.
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
void updateParameter(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
bool ptStopPosition
Whether this is a public transport stop position.
Encapsulated SAX-Attributes.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
A point in 2D or 3D with translation and scaling methods.
classes which drive on tracks
void myEndElement(int element) override
Called when a closing tag occurs.
NBEdgeCont & getEdgeCont()
T get(const std::string &str) const
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
Storage for edges, including some functionality operating on multiple edges.
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) ...
#define PROGRESS_BEGIN_MESSAGE(msg)
void cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
bool operator()(const Edge *e1, const Edge *e2) const
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
int myParkingType
Information about road-side parking.
long long int myLastNodeID
ID of the currently parsed node, for reporting mainly.
std::map< long long int, NIOSMNode * > & myToFill
The nodes container to fill.
bool myIsRestriction
whether the currently parsed relation is a restriction
~NIImporter_OpenStreetMap()
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
void setIsMultipleStopPositions(bool multipleStopPositions)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool railwayCrossing
Whether this is a railway crossing.
~NodesHandler() override
Destructor.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
double myMaxSpeed
maximum speed in km/h, or MAXSPEED_UNGIVEN
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
void myEndElement(int element) override
Called when a closing tag occurs.
bool myIsInValidNodeTag
Hierarchy helper for parsing a node's tags.
std::map< long long int, Edge * > myEdges
the map from OSM way ids to edge objects
std::vector< std::string > getVector()
const double lat
The latitude the node is located at.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
int myNoLanes
number of lanes, or -1 if unknown
bool railwayBufferStop
Whether this is a railway buffer stop.
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
bool tlsControlled
Whether this is a tls controlled junction.
EdgesHandler(const std::map< long long int, NIOSMNode *> &osmNodes, std::map< long long int, Edge *> &toFill, std::map< long long int, Edge *> &platformShapes)
Constructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
WayType mySidewalkType
Information about the kind of sidwalk along this road.
std::map< std::string, std::string > myKnownCompoundTypes
The compound types that have already been mapped to other known types.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
double length() const
Returns the length.
std::map< long long int, Edge * > & myEdgeMap
A map of built edges.
bool myCurrentIsPlatform
Information whether this is a pt platform.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
NBNodeCont & getNodeCont()
Returns a reference to the node container.
long long int myToWay
the destination way for the current restriction
bool myIsRoute
indicates whether current relation is a route
int myLayer
Information about the relative z-ordering of ways.
Instance responsible for building networks.
std::string myPTRouteType
indicates whether current relation is a pt route
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
static const std::string compoundTypeSeparator
The separator within newly created compound type names.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
alternative definition for junction
A storage for options typed value containers)
long long int myViaNode
the via node/way for the current restriction
std::string joinToStringSorting(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
NBPTStop * get(std::string id)
Retrieve a previously inserted pt stop.
bool copyRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a type.
static double _2double(const E *const data)
converts a char-type array into the double value described by it
SumoXMLNodeType getType() const
Returns the type of this node.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connctions
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
void reconstructLayerElevation(double layerElevation, NBNetBuilder &nb)
reconstruct elevation from layer info
std::string name
The name of the node.
A class which extracts OSM-nodes from a parsed OSM-file.
const Position & getPosition() const
int myInterval
service interval of the pt line in seconds
Represents a single node (junction) during network building.
void resetValues()
reset members to their defaults for parsing a new relation
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
NBNode * insertNodeChecking(long long int id, NBNodeCont &nc, NBTrafficLightLogicCont &tlsc)
Builds an NBNode.
int myHierarchyLevel
The current hierarchy level.
std::string myHighWayType
The type, stored in "highway" key.
NodesHandler(std::map< long long int, NIOSMNode *> &toFill, std::set< NIOSMNode *, CompareNodes > &uniqueNodes, const OptionsCont &cont)
Contructor.
const double lon
The longitude the node is located at.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
std::string myNightService
night service information of the pt line
Importer for networks stored in OpenStreetMap format.
bool myIsStopArea
indicates whether current relation is a pt stop area
static const long long int INVALID_ID
bool myCurrentIsRoad
Information whether this is a road.
Edge * myCurrentEdge
The currently built edge.
std::map< long long int, Edge * > myPlatformShapes
the map from OSM way ids to platform shapes
std::set< std::string > myUnusableTypes
The compounds types that do not contain known types.
std::vector< NBPTStop * > getStops()
SVCPermissions permissions
type of pt stop
NBNode * getFromNode() const
Returns the origin node of the edge.
Container for nodes during the netbuilding process.
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
bool insert(NBPTStop *ptStop)
Inserts a node into the map.
#define PROGRESS_DONE_MESSAGE()
double ptStopLength
The length of the pt stop.
std::map< long long int, NIOSMNode * > myOSMNodes
the map from OSM node ids to actual nodes
A traffic light logics which must be computed (only nodes/edges are given)
std::vector< int > myParentElements
The element stack.
bool getIsOneWay(const std::string &type) const
Returns whether edges are one-way per default for the given type.
#define WRITE_MESSAGE(msg)
std::set< NIOSMNode *, CompareNodes > myUniqueNodes
the set of unique nodes used in NodesHandler, used when freeing memory
void addPlatformCand(NBPTPlatform platform)
static const double MAXSPEED_UNGIVEN
const OptionsCont & myOptionsCont
the options
NBNode * getToNode() const
Returns the destination node of the edge.
bool applyRestriction() const
try to apply the parsed restriction and return whether successful
A class which extracts relevant relation information from a parsed OSM-file.
std::string myIsOneWay
Information whether this is an one-way road.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::map< std::string, double > mySpeedMap
A map of non-numeric speed descriptions to their numeric values.
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
A storage for available types of edges.
NBPTStopCont * myNBPTStopCont
The previously filled pt stop container.