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;
226 std::vector<long long int> passed;
228 passed.push_back(*j);
231 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
232 currentFrom = currentTo;
234 passed.push_back(*j);
240 insertEdge(e, running, currentFrom, last, passed, nb);
243 const double layerElevation = oc.
getFloat(
"osm.layer-elevation");
244 if (layerElevation > 0) {
257 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
269 if (node ==
nullptr) {
294 if (!tlsc.
insert(tlDef)) {
309 const std::vector<long long int>& passed,
NBNetBuilder& nb) {
318 if (from ==
nullptr || to ==
nullptr) {
319 WRITE_ERROR(
"Discarding edge '" +
id +
"' because the nodes could not be built.");
328 assert(passed.size() >= 2);
329 if (passed.size() == 2) {
330 WRITE_WARNING(
"Discarding edge '" +
id +
"' which connects two identical nodes without geometry.");
334 int intermediateIndex = (int) passed.size() / 2;
336 std::vector<long long int> part1(passed.begin(), passed.begin() + intermediateIndex + 1);
337 std::vector<long long int> part2(passed.begin() + intermediateIndex, passed.end());
338 index =
insertEdge(e, index, from, intermediate, part1, nb);
339 return insertEdge(e, index, intermediate, to, part2, nb);
341 const int newIndex = index + 1;
345 double distanceStart =
myOSMNodes[passed.front()]->positionMeters;
346 double distanceEnd =
myOSMNodes[passed.back()]->positionMeters;
347 const bool useDistance = distanceStart != std::numeric_limits<double>::max() && distanceEnd != std::numeric_limits<double>::max();
350 if (distanceStart < distanceEnd) {
359 for (
long long i : passed) {
363 if (existingPtStop !=
nullptr) {
377 shape.push_back(pos);
380 WRITE_ERROR(
"Unable to project coordinates for edge '" +
id +
"'.");
400 double forwardWidth = tc.
getWidth(type);
401 double backwardWidth = tc.
getWidth(type);
405 bool addForward =
true;
406 bool addBackward =
true;
423 if (addForward && !addBackward) {
425 }
else if (!addForward && addBackward) {
433 numLanesForward = (int) std::ceil(e->
myNoLanes / 2.0);
435 numLanesBackward = e->
myNoLanes - numLanesForward;
438 numLanesForward =
MAX2(1, numLanesForward);
439 numLanesBackward =
MAX2(1, numLanesBackward);
442 WRITE_WARNING(
"Skipping edge '" +
id +
"' because it has zero lanes.");
456 if (!addForward && (cyclewayType &
WAY_FORWARD) != 0) {
462 cyclewayType = (
WayType)(cyclewayType & ~WAY_FORWARD);
464 if (!addBackward && (cyclewayType &
WAY_BACKWARD) != 0) {
468 numLanesBackward = 1;
470 cyclewayType = (
WayType)(cyclewayType & ~WAY_BACKWARD);
476 if (!addForward && (sidewalkType &
WAY_FORWARD) != 0) {
482 sidewalkType = (
WayType)(sidewalkType & ~WAY_FORWARD);
484 if (!addBackward && (sidewalkType &
WAY_BACKWARD) != 0) {
488 numLanesBackward = 1;
490 sidewalkType = (
WayType)(sidewalkType & ~WAY_BACKWARD);
502 numLanesBackward = 1;
511 const std::string reverseID =
"-" + id;
514 assert(numLanesForward > 0);
528 if (addSidewalk && (sidewalkType ==
WAY_UNKNOWN || (sidewalkType & WAY_FORWARD) != 0)) {
539 assert(numLanesBackward > 0);
553 if (addSidewalk && (sidewalkType ==
WAY_UNKNOWN || (sidewalkType & WAY_BACKWARD) != 0)) {
560 throw ProcessError(
"Could not add edge '-" +
id +
"'.");
595 std::set<NIOSMNode*, CompareNodes>& uniqueNodes,
602 myIsInValidNodeTag(false),
605 myImportElevation(oc.getBool(
"osm.elevation")),
624 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
626 if (action ==
"delete" || !ok) {
654 auto* toAdd =
new NIOSMNode(
id, tlon, tlat);
662 toAdd = *similarNode;
670 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
676 if (key ==
"highway" || key ==
"ele" || key ==
"crossing" || key ==
"railway" || key ==
"public_transport" 677 || key ==
"name" || key ==
"train" || key ==
"bus" || key ==
"tram" || key ==
"light_rail" || key ==
"subway" || key ==
"station" || key ==
"noexit" 682 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
684 }
else if (key ==
"crossing" && value.find(
"traffic_signals") != std::string::npos) {
686 }
else if ((key ==
"noexit" && value ==
"yes")
687 || (key ==
"railway" && value ==
"buffer_stop")) {
689 }
else if (key ==
"railway" && value.find(
"crossing") != std::string::npos) {
692 value ==
"block" || value ==
"entry" || value ==
"exit" || value ==
"intermediate")) {
697 }
else if ((key ==
"public_transport" && value ==
"stop_position") ||
698 (key ==
"highway" && value ==
"bus_stop")) {
704 }
else if (key ==
"name") {
706 }
else if (key ==
"train") {
709 }
else if (key ==
"subway" || key ==
"light_rail" 710 || (key ==
"station" && (value ==
"subway" || value ==
"light_rail"))) {
713 }
else if (key ==
"bus") {
716 }
else if (key ==
"tram") {
723 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in node '" +
744 const std::map<long long int, NIOSMNode*>& osmNodes,
745 std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes):
749 myPlatformShapesMap(platformShapes) {
770 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
772 if (action ==
"delete" || !ok) {
789 ref = node->second->id;
807 const std::string cyclewaySpec = key.substr(9);
809 if (cyclewaySpec ==
"right") {
811 }
else if (cyclewaySpec ==
"left") {
813 }
else if (cyclewaySpec ==
"both") {
824 const std::string buswaySpec = key.substr(7);
826 if (buswaySpec ==
"right") {
828 }
else if (buswaySpec ==
"left") {
830 }
else if (buswaySpec ==
"both") {
841 && key !=
"maxspeed" && key !=
"junction" && key !=
"name" && key !=
"tracks" && key !=
"layer" 845 && key !=
"highspeed" 847 && key !=
"postal_code" 848 && key !=
"railway:preferred_direction" 849 && key !=
"railway:bidirectional" 850 && key !=
"railway:track_ref" 852 && key !=
"electrified" 853 && key !=
"public_transport") {
858 if ((key ==
"highway" && value !=
"platform") || key ==
"railway" || key ==
"waterway" || key ==
"cycleway" 859 || key ==
"busway" || key ==
"route" || key ==
"sidewalk" || key ==
"highspeed" 862 std::string singleTypeID = key +
"." + value;
865 if (key ==
"cycleway") {
869 if (value ==
"opposite_track") {
871 }
else if (value ==
"opposite_lane") {
876 if (key ==
"sidewalk") {
877 if (value ==
"no" || value ==
"none") {
879 }
else if (value ==
"both") {
881 }
else if (value ==
"right") {
883 }
else if (value ==
"left") {
890 if (key ==
"busway") {
894 if (value ==
"opposite_track") {
896 }
else if (value ==
"opposite_lane") {
902 if (key ==
"highspeed") {
906 singleTypeID =
"railway.highspeed";
917 types.push_back(singleTypeID);
922 }
else if (key ==
"lanes") {
928 std::vector<std::string> list = st.
getVector();
929 if (list.size() >= 2) {
930 int minLanes = std::numeric_limits<int>::max();
932 for (
auto& i : list) {
934 minLanes =
MIN2(minLanes, numLanes);
938 "Using minimum lane number from list (" + value +
") for edge '" 942 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
947 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
950 }
else if (key ==
"lanes:forward") {
954 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
957 }
else if (key ==
"lanes:backward") {
962 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
965 }
else if (key ==
"maxspeed") {
969 double conversion = 1;
974 conversion = 1.609344;
979 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
983 }
else if (key ==
"junction") {
987 }
else if (key ==
"oneway") {
989 }
else if (key ==
"name") {
991 }
else if (key ==
"ref") {
993 }
else if (key ==
"layer") {
1000 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1003 }
else if (key ==
"tracks") {
1011 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1016 }
else if (key ==
"railway:preferred_direction") {
1017 if (value ==
"both") {
1019 }
else if (value ==
"backward") {
1022 }
else if (key ==
"railway:bidirectional") {
1023 if (value ==
"regular") {
1026 }
else if (key ==
"electrified") {
1027 if (value !=
"no") {
1030 }
else if (key ==
"railway:track_ref") {
1032 }
else if (key ==
"public_transport" && value ==
"platform") {
1063 const std::map<long long int, NIOSMNode*>& osmNodes,
1064 const std::map<long long int, Edge*>& osmEdges,
NBPTStopCont* nbptStopCont,
1065 const std::map<long long int, Edge*>& platformShapes,
1071 myOSMEdges(osmEdges),
1073 myNBPTStopCont(nbptStopCont),
1074 myNBPTLineCont(nbptLineCont),
1107 if (action ==
"delete" || !ok) {
1123 auto ref = attrs.
get<
long 1126 if (role ==
"via") {
1131 }
else if (memberType ==
"node") {
1136 "No node found for reference '" +
toString(ref) +
"' in relation '" 1145 }
else if (role ==
"stop") {
1147 }
else if (role ==
"platform") {
1149 if (memberType ==
"way") {
1150 const std::map<
long long int,
1155 platform.
isWay =
true;
1159 }
else if (memberType ==
"node") {
1161 platform.
isWay =
false;
1166 }
else if (role.empty()) {
1168 if (memberType ==
"way") {
1179 if (key ==
"type" || key ==
"restriction") {
1181 if (key ==
"type" && value ==
"restriction") {
1185 if (key ==
"type" && value ==
"route") {
1189 if (key ==
"restriction") {
1192 if (value.substr(0, 5) ==
"only_") {
1194 }
else if (value.substr(0, 3) ==
"no_") {
1203 }
else if (key ==
"public_transport") {
1205 if (value ==
"stop_area") {
1208 }
else if (key ==
"route") {
1210 if (value ==
"train" || value ==
"subway" || value ==
"light_rail" || value ==
"monorail" || value ==
"tram" || value ==
"bus" 1211 || value ==
"trolleybus" || value ==
"arialway" || value ==
"ferry") {
1215 }
else if (key ==
"name") {
1217 }
else if (key ==
"ref") {
1219 }
else if (key ==
"interval" || key ==
"headway") {
1221 }
else if (key ==
"by_night") {
1268 for (
long long ref :
myStops) {
1278 if (ptStop ==
nullptr) {
1285 if (myPlatform.isWay) {
1288 if (edge->myCurrentNodes[0] == *(edge->myCurrentNodes.end() - 1)) {
1290 +
"' is given as polygon, which currently is not supported.");
1295 for (
auto nodeRef : edge->myCurrentNodes) {
1308 p.push_back(pNodePos);
1310 if (p.size() == 0) {
1313 +
"' is corrupt. Probably OSM file is incomplete.");
1331 "osm.stop-output.length"));
1341 for (
long long ref :
myStops) {
1357 if (ptStop ==
nullptr) {
1371 for (
long long& myWay :
myWays) {
1374 Edge* edge = entr->second;
1402 if (viaNode ==
nullptr) {
1408 if (from ==
nullptr) {
1409 WRITE_WARNING(
"from-edge of restriction relation could not be determined");
1412 if (to ==
nullptr) {
1413 WRITE_WARNING(
"to-edge of restriction relation could not be determined");
1423 WRITE_WARNING(
"direction of restriction relation could not be determined");
1431 const std::vector<NBEdge*>& candidates)
const {
1432 const std::string prefix =
toString(wayRef);
1433 const std::string backPrefix =
"-" + prefix;
1434 NBEdge* result =
nullptr;
1436 for (
auto candidate : candidates) {
1437 if ((candidate->getID().substr(0, prefix.size()) == prefix) ||
1438 (candidate->getID().substr(0, backPrefix.size()) == backPrefix)) {
1444 WRITE_WARNING(
"Ambigous way reference '" + prefix +
"' in restriction relation");
1457 std::map<NBNode*, std::vector<std::pair<double, double> > > layerForces;
1460 std::set<NBNode*> knownElevation;
1461 for (
auto& myEdge :
myEdges) {
1462 Edge* e = myEdge.second;
1466 if (node !=
nullptr) {
1467 knownElevation.insert(node);
1473 #ifdef DEBUG_LAYER_ELEVATION 1474 std::cout <<
"known elevations:\n";
1475 for (std::set<NBNode*>::iterator it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1476 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1477 std::cout <<
" node=" << (*it)->
getID() <<
" ele=";
1478 for (std::vector<std::pair<double, double> >::const_iterator it_ele = primaryLayers.begin(); it_ele != primaryLayers.end(); ++it_ele) {
1479 std::cout << it_ele->first <<
" ";
1487 std::map<NBNode*, double> knownEleMax;
1488 for (
auto it : knownElevation) {
1489 double eleMax = -std::numeric_limits<double>::max();
1490 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[it];
1491 for (
const auto& primaryLayer : primaryLayers) {
1492 eleMax =
MAX2(eleMax, primaryLayer.first);
1494 knownEleMax[it] = eleMax;
1497 bool changed =
true;
1500 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1503 / gradeThreshold * 3,
1505 for (
auto& neighbor : neighbors) {
1506 if (knownElevation.count(neighbor.first) != 0) {
1507 const double grade = fabs(knownEleMax[*it] - knownEleMax[neighbor.first])
1509 #ifdef DEBUG_LAYER_ELEVATION 1510 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";
1512 if (grade > gradeThreshold * 50 / 3.6 / neighbor.second.second) {
1514 const double eleMax =
MAX2(knownEleMax[*it], knownEleMax[neighbor.first]);
1515 if (knownEleMax[*it] < eleMax) {
1516 knownEleMax[*it] = eleMax;
1518 knownEleMax[neighbor.first] = eleMax;
1528 std::set<NBNode*> unknownElevation;
1529 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1530 const double eleMax = knownEleMax[*it];
1531 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1532 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1533 for (
auto& neighbor : neighbors) {
1534 if (knownElevation.count(neighbor.first) == 0) {
1535 unknownElevation.insert(neighbor.first);
1536 layerForces[neighbor.first].emplace_back(eleMax, neighbor.second.first);
1542 for (
auto it = unknownElevation.begin(); it != unknownElevation.end(); ++it) {
1543 double eleMax = -std::numeric_limits<double>::max();
1544 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1545 for (
const auto& primaryLayer : primaryLayers) {
1546 eleMax =
MAX2(eleMax, primaryLayer.first);
1548 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1549 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1550 for (
auto& neighbor : neighbors) {
1551 if (knownElevation.count(neighbor.first) == 0 && unknownElevation.count(neighbor.first) == 0) {
1552 layerForces[*it].emplace_back(0, neighbor.second.first);
1557 #ifdef DEBUG_LAYER_ELEVATION 1558 std::cout <<
"summation of forces\n";
1560 std::map<NBNode*, double> nodeElevation;
1561 for (
auto& layerForce : layerForces) {
1562 const std::vector<std::pair<double, double> >& forces = layerForce.second;
1563 if (knownElevation.count(layerForce.first) != 0) {
1571 #ifdef DEBUG_LAYER_ELEVATION 1572 std::cout <<
" node=" << it->first->getID() <<
" knownElevation=" << knownEleMax[it->first] <<
"\n";
1574 nodeElevation[layerForce.first] = knownEleMax[layerForce.first];
1575 }
else if (forces.size() == 1) {
1576 nodeElevation[layerForce.first] = forces.front().first;
1580 for (
const auto& force : forces) {
1581 distSum += force.second;
1583 double weightSum = 0;
1584 double elevation = 0;
1585 #ifdef DEBUG_LAYER_ELEVATION 1586 std::cout <<
" node=" << it->first->getID() <<
" distSum=" << distSum <<
"\n";
1588 for (
const auto& force : forces) {
1589 const double weight = (distSum - force.second) / distSum;
1590 weightSum += weight;
1591 elevation += force.first * weight;
1593 #ifdef DEBUG_LAYER_ELEVATION 1594 std::cout <<
" force=" << it_force->first <<
" dist=" << it_force->second <<
" weight=" << weight <<
" ele=" << elevation <<
"\n";
1597 nodeElevation[layerForce.first] = elevation / weightSum;
1600 #ifdef DEBUG_LAYER_ELEVATION 1601 std::cout <<
"final elevations:\n";
1602 for (std::map<NBNode*, double>::iterator it = nodeElevation.begin(); it != nodeElevation.end(); ++it) {
1603 std::cout <<
" node=" << (it->first)->getID() <<
" ele=" << it->second <<
"\n";;
1607 for (
auto& it : nodeElevation) {
1614 for (
const auto& it : ec) {
1615 NBEdge* edge = it.second;
1617 const double length = geom.
length2D();
1618 const double zFrom = nodeElevation[edge->
getFromNode()];
1619 const double zTo = nodeElevation[edge->
getToNode()];
1624 for (
auto it_pos = geom.begin(); it_pos != geom.end(); ++it_pos) {
1625 if (it_pos != geom.begin()) {
1626 dist += (*it_pos).distanceTo2D(*(it_pos - 1));
1628 newGeom.push_back((*it_pos) +
Position(0, 0, zFrom + (zTo - zFrom) * dist / length));
1634 std::map<NBNode*, std::pair<double, double> >
1636 std::map<NBNode*, std::pair<double, double> > result;
1637 std::set<NBNode*> visited;
1638 std::vector<NBNode*> open;
1639 open.push_back(node);
1640 result[node] = std::make_pair(0, 0);
1641 while (!open.empty()) {
1644 if (visited.count(n) != 0) {
1649 for (
auto e : edges) {
1652 s = e->getFromNode();
1656 const double dist = result[n].first + e->getGeometry().length2D();
1657 const double speed =
MAX2(e->getSpeed(), result[n].second);
1658 if (result.count(s) == 0) {
1659 result[s] = std::make_pair(dist, speed);
1661 result[s] = std::make_pair(
MIN2(dist, result[s].first),
MAX2(speed, result[s].second));
1663 if (dist < maxDist && knownElevation.count(s) == 0) {
1675 if (tc.
knows(type)) {
1686 std::vector<std::string> types;
1688 std::string t = tok.
next();
1690 if (std::find(types.begin(), types.end(), t) == types.end()) {
1693 }
else if (tok.
size() > 1) {
1695 "Discarding unknown compound '" + t +
"' in type '" + type +
"' (first occurence for edge '" 1700 if (types.empty()) {
1701 WRITE_WARNING(
"Discarding unusable type '" + type +
"' (first occurence for edge '" +
id +
"').");
1706 if (tc.
knows(newType)) {
1714 double maxSpeed = 0;
1719 bool defaultIsOneWay =
false;
1721 bool discard =
true;
1722 for (
auto& type2 : types) {
1749 "Discarding compound type '" + newType +
"' (first occurence for edge '" +
id +
"').");
1754 WRITE_MESSAGE(
"Adding new type '" + type +
"' (first occurence for edge '" +
id +
"').");
1755 tc.
insert(newType, numLanes, maxSpeed, prio, permissions, width, defaultIsOneWay,
1756 sidewalkWidth, bikelaneWidth, 0, 0, 0);
1757 for (
auto& type3 : types) {
1772 std::vector<NIOSMNode*> nodes;
1773 std::vector<double> usablePositions;
1774 std::vector<int> usableIndex;
1779 if (node->
positionMeters != std::numeric_limits<double>::max()) {
1781 usableIndex.push_back(i);
1784 nodes.push_back(node);
1786 if (usablePositions.size() == 0) {
1789 bool forward =
true;
1790 if (usablePositions.size() == 1) {
1791 WRITE_WARNING(
"Ambiguous railway kilometrage direction for way '" +
id +
"' (assuming forward)");
1793 forward = usablePositions.front() < usablePositions.back();
1796 for (
int i = 1; i < (int)usablePositions.size(); i++) {
1797 if ((usablePositions[i - 1] < usablePositions[i]) != forward) {
1798 WRITE_WARNING(
"Inconsistent railway kilometrage direction for way '" +
id +
"': " +
toString(usablePositions) +
" (skipping)");
1802 if (nodes.size() > usablePositions.size()) {
1806 shape.push_back(
Position(node->lon, node->lat, 0));
1811 double sign = forward ? 1 : -1;
1813 for (
int i = usableIndex.front() - 1; i >= 0; i--) {
1814 nodes[i]->positionMeters = nodes[i + 1]->positionMeters - sign * shape[i].distanceTo2D(shape[i + 1]);
1817 for (
int i = usableIndex.front() + 1; i < (int)nodes.size(); i++) {
1818 if (nodes[i]->positionMeters == std::numeric_limits<double>::max()) {
1819 nodes[i]->positionMeters = nodes[i - 1]->positionMeters + sign * shape[i].distanceTo2D(shape[i - 1]);
1847 return std::numeric_limits<double>::max();
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.
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...
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
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.
const std::map< std::string, NBPTLine * > & getLines() const
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()
void extendRailwayDistances(Edge *e, NBTypeCont &tc)
extend kilometrage data for all nodes along railway
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.
bool myCurrentIsElectrified
Information whether this is railway is electrified.
int getPriority(const std::string &type) const
Returns the priority for the given type.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
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)
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
bool hasNext()
returns the information whether further substrings exist
NBParkingCont & getParkingCont()
std::string usableType(const std::string &type, const std::string &id, NBTypeCont &tc)
check whether the type is known or consists of known type compounds. return empty string otherwise ...
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
rail vehicle that requires electrified tracks
#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
bool myAllAttributes
whether additional way attributes shall be added to the edge
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.
int size() const
returns the number of existing substrings
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.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
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)
const std::string & getLineID() const
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.
void insert(NBPTLine *ptLine)
insert new line
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.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
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.
std::string position
kilometrage/mileage
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()
return vector of strings
const double lat
The latitude the node is located at.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
std::string ref
The edge's track name.
int myNoLanes
number of lanes, or -1 if unknown
bool railwayBufferStop
Whether this is a railway buffer stop.
double positionMeters
position converted to m (using highest precision available)
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
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
static double interpretDistance(NIOSMNode *node)
read distance value from node and return value in m
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.
SumoXMLNodeType getType() const
Returns the type of this node.
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
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false, const bool keepPossibleTurns=false)
Removes the specified connection(s)
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 minutes
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
void insert(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth, double widthResolution, double maxWidth, double minWidth)
Adds a type into the list.
NBNode * getFromNode() const
Returns the origin node of the edge.
Container for nodes during the netbuilding process.
void setDistance(double distance)
set lane specific speed (negative lane implies set for all lanes)
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)
WayType myRailDirection
Information about the direction(s) of railway usage.
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
vehicle that is allowed to drive on high-speed rail tracks
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.